From 03054ebef7a7c4ceb63931c7ec7c90ab69d30e73 Mon Sep 17 00:00:00 2001 From: Justin Schroeder Date: Mon, 26 Feb 2018 22:15:15 -0500 Subject: [PATCH] Adds data-type attribute, and formulate-element--type-- to formulate elment wrappers --- dist/index.js | 4 ++-- src/components/FormulateElement.vue | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index ac599cb..5366f16 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10,7 +10,7 @@ var o=e(14);t.exports=function(t){var r,e;return!1!==n(t)&&"function"==typeof(r= * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ -t.exports=function(t,r,e){for(var n in t)if(!1===r.call(e,t[n],n,t))break}},function(t,r){t.exports=function(t,r,e,n,o,i){var a,u=t=t||{},s=typeof t.default;"object"!==s&&"function"!==s||(a=t,u=t.default);var c="function"==typeof u?u.options:u;r&&(c.render=r.render,c.staticRenderFns=r.staticRenderFns,c._compiled=!0),e&&(c.functional=!0),o&&(c._scopeId=o);var l;if(i?(l=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),n&&n.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},c._ssrRegister=l):n&&(l=n),l){var f=c.functional,p=f?c.render:c.beforeCreate;f?(c._injectStyles=l,c.render=function(t,r){return l.call(r),p(t,r)}):c.beforeCreate=p?[].concat(p,l):[l]}return{esModule:a,exports:u,options:c}}},function(t,r,e){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function o(t){return function(){var r=t.apply(this,arguments);return new Promise(function(t,e){function n(o,i){try{var a=r[o](i),u=a.value}catch(t){return void e(t)}if(!a.done)return Promise.resolve(u).then(function(t){n("next",t)},function(t){n("throw",t)});t(u)}return n("next")})}}function i(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}Object.defineProperty(r,"__esModule",{value:!0});var a=e(1),u=n(a),s=e(2),c=e(4),l=n(c);r.default={props:{name:{type:String,required:!0},module:{type:[String,Boolean],default:function(){return this.$formulate.options.vuexModule}},initial:{type:Object,default:function(){return{}}},behavior:{type:String,default:"blur"},showErrors:{type:[Boolean,Object],default:function(){return{}}},errors:{type:Object,default:function(){return{}}},prevent:{type:String,default:"validation"}},data:function(){return{parentIdentifier:"vue-formulate-wrapper-element",forceErrors:null,fieldInitials:{}}},computed:{m:function(){return this.module?this.module+"/":""},hasErrors:function(){return this.$store.getters[this.m+"hasErrors"][this.name]||!1},hasValidationErrors:function(){return this.$store.getters[this.m+"hasValidationErrors"][this.name]||!1},values:function(){return(0,l.default)(this.$store.getters[this.m+"formValues"][this.name]||{})},storeErrors:function(){return this.$store.getters[this.m+"formErrors"][this.name]||{}},validationErrors:function(){return this.$store.getters[this.m+"formValidationErrors"][this.name]||{}},fields:function(){return this.$store.getters[this.m+"formMeta"][this.name]||[]},shouldShowErrors:function(){return!1===this.forceErrors||!0===this.forceErrors?this.forceErrors:!1===this.showErrors||!0===this.showErrors?this.showErrors:"live"===this.behavior},mergedInitial:function(){return Object.assign({},this.initial,this.fieldInitials)}},watch:{mergedInitial:function(){this.hydrate(this.mergedInitial)}},created:function(){this.hydrate(this.mergedInitial)},mounted:function(){this.hydrate(this.mergedInitial)},methods:{registerField:function(t,r){this.$store.commit(this.m+"setFieldMeta",{form:this.name,field:t,data:r}),this.updateFormValidation()},hydrate:function(t){var r=!0,e=!1,n=void 0;try{for(var o,i=this.fields[Symbol.iterator]();!(r=(o=i.next()).done);r=!0){var a=o.value;"submit"!==a.type&&this.$store.commit(this.m+"setFieldValue",{field:a.name,value:t[a.name],form:this.name})}}catch(t){e=!0,n=t}finally{try{!r&&i.return&&i.return()}finally{if(e)throw n}}this.updateFormValidation()},setInitial:function(t,r){this.fieldInitials=Object.assign({},this.fieldInitials,i({},t,r))},update:function(t){this.$store.commit(this.m+"setFieldValue",Object.assign(t,{form:this.name})),this.updateFormValidation()},updateFieldErrors:function(t){this.$store.commit(this.m+"setFieldErrors",Object.assign(t,{form:this.name}))},updateFieldValidationErrors:function(t){this.$store.commit(this.m+"setFieldValidationErrors",Object.assign(t,{form:this.name}))},validateField:function(){function t(t){return r.apply(this,arguments)}var r=o(u.default.mark(function t(r){var e,n=r.field,o=r.validation,i=r.label;return u.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.$formulate.validationErrors({field:n,value:this.values[n],label:i},o,this.values);case 2:return e=t.sent,(0,s.equals)(e||[],this.validationErrors[n]||[])||this.updateFieldValidationErrors({field:n,errors:e||[]}),t.abrupt("return",e);case 5:case"end":return t.stop()}},t,this)}));return t}(),updateFormValidation:function(){var t=this;this.fields.map(function(){var r=o(u.default.mark(function r(e){return u.default.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.validateField({field:e.name,validation:e.validation,label:e.validationLabel||e.label||e.name}));case 1:case"end":return r.stop()}},r,t)}));return function(t){return r.apply(this,arguments)}}())},submit:function(){"validation"===this.prevent&&this.hasValidationErrors||"any"===this.prevent&&this.hasErrors?this.forceErrors=!0:this.$emit("submit",Object.assign({},this.values))}}}},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e(2),o=e(25),i=function(t){return t&&t.__esModule?t:{default:t}}(o);r.default={props:{type:{type:[String,Boolean],default:"text"},name:{type:String,required:!0},initial:{type:[String,Number,Boolean],default:!1},validation:{type:[String,Boolean],default:!1},errors:{type:Array,default:function(){return[]}},label:{type:[String,Boolean],default:!1},id:{type:[String],default:function(){return i.default.generate()}},min:{type:[String,Number,Boolean],default:function(){return!1}},max:{type:[String,Number,Boolean],default:function(){return!1}},placeholder:{type:[String,Number,Boolean],default:function(){return!1}},options:{type:[Object,Array],default:function(){return[]}},multiple:{type:Boolean,default:!1},showErrors:{type:[Object,Boolean],default:function(){return{}}},validationLabel:{type:[String,Boolean],default:!1}},data:function(){return{errorBlurState:!1}},computed:{hasCustomInput:function(){return this.$slots.default&&this.$slots.default.length},isTextInput:function(){return!this.hasCustomInput&&n.inputTypes.text.includes(this.type)},isButtonInput:function(){return!this.hasCustomInput&&n.inputTypes.button.includes(this.type)},isSelectInput:function(){return!this.hasCustomInput&&n.inputTypes.select.includes(this.type)},isBoxInput:function(){return!this.hasCustomInput&&n.inputTypes.box.includes(this.type)},isUnsupportedInput:function(){return!(this.hasCustomInput||this.isTextInput||this.isButtonInput||this.isSelectInput||this.isBoxInput)},form:function(){for(var t=this.$parent;t&&t.$data&&"vue-formulate-wrapper-element"!==t.$data.parentIdentifier;)t=t.$parent;if(!t.$data||"vue-formulate-wrapper-element"!==t.$data.parentIdentifier)throw new Error("FormulateElement has no FormulateWrapper element");return t},values:function(){return this.form.values},value:function(){var t=this.values[this.name];if(void 0===t)switch(this.type){case"color":return"#000000";case"checkbox":if(this.optionList.length>1)return[]}return t},module:function(){return this.form.$props.module},formName:function(){return this.form.$props.name},classes:function(){return{"formulate-element":!0,"formulate-element--has-value":!!this.value,"formulate-element--has-errors":this.localAndValidationErrors.length&&this.shouldShowErrors}},validationErrors:function(){return this.form.validationErrors[this.name]||[]},storeErrors:function(){return this.form.storeErrors[this.name]||[]},formErrors:function(){return this.form.errors[this.name]||[]},localAndValidationErrors:function(){return this.errors.concat(this.validationErrors).concat(this.formErrors)},shouldShowErrors:function(){var t=this.form.shouldShowErrors;return"blur"===this.form.behavior&&(t=t||this.errorBlurState),!1!==this.showErrors&&!0!==this.showErrors||(t=this.showErrors),t},attributes:function(){var t=this;return["min","max","placeholder","id","multiple"].filter(function(r){return!1!==t[r]}).reduce(function(r,e){return r[e]=t[e],r},{})},optionList:function(){return Array.isArray(this.options)?Array.isArray(this.options)&&!this.options.length?[{value:this.name,label:this.label||this.name,id:i.default.generate()}]:this.options:(0,n.reduce)(this.options,function(t,r,e){return t.concat({value:r,label:e,id:i.default.generate()})},[])},val:{set:function(t){this.form.update({field:this.name,value:t}),this.isTextInput&&(this.$refs.input.value=t)},get:function(){return this.value}}},watch:{localAndValidationErrors:function(){(0,n.equals)(this.localAndValidationErrors,this.storeErrors)||this.form.updateFieldErrors({field:this.name,errors:this.localAndValidationErrors})},initial:function(){this.form.update({field:this.name,value:this.initial})}},created:function(){this.form.registerField(this.name,(0,n.filter)(this.$props,function(t,r){return["name","type","id","label","validation","validationLabel"].includes(t)})),!1!==this.initial&&this.form.setInitial(this.name,this.initial)}}},function(t,r,e){"use strict";function n(t,r){for(var e,n=0,i="";!e;)i+=t(r>>4*n&15|o()),e=r1&&void 0!==arguments[1]?arguments[1]:{};t.prototype.$formulate=this,r=Object.assign(this.defaultOptions,r),r.registerComponents&&(t.component(r.tags.Formulate,d.default),t.component(r.tags.FormulateElement,m.default)),r.errors&&(this.errors=Object.assign(this.errors,r.errors)),r.rules&&(this.rules=Object.assign(this.rules,r.rules)),this.options=r}},{key:"parseRules",value:function(t){return t.split("|").map(function(t){return t.trim()}).map(function(t){return t.match(/([a-zA-Z0-9]+)\((.*)?\)/)||[null,t,""]}).map(function(t){var r=c(t,3),e=(r[0],r[1]),n=r[2];return Object.assign({},{rule:e},n?{args:n.split(",").map(function(t){return t.trim()})}:{args:[]})})}},{key:"errorFactory",value:function(t){return this.errors[t]?this.errors[t]:this.errors.default}},{key:"validationErrors",value:function(){function t(t,e,n){return r.apply(this,arguments)}var r=i(s.default.mark(function t(r,e,n){var i=r.field,a=r.value,u=r.label,c=this;return s.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",!!e&&Promise.all(this.parseRules(e).map(function(t){var r,e=t.rule,s=t.args;if("function"!=typeof c.rules[e])throw new Error("Validation rule is invalid: "+e);return(r=c.rules)[e].apply(r,[{field:i,value:a,label:u,error:c.errorFactory(e),values:n}].concat(o(s)))})).then(function(t){return t.reduce(function(t,r){return r?Array.isArray(t)?t.concat(r):[r]:t},!1)}));case 1:case"end":return t.stop()}},t,this)}));return t}()}]),t}(),w=new x;r.default=w,r.mapModels=function(t){var r={};for(var e in t)!function(e){var n=t[e].split("/"),o=c(n,2),i=o[0],a=o[1];r[e]={set:function(t){var r=w.options.vuexModule?w.options.vuexModule+"/":"";this.$store.commit(r+"setFieldValue",{form:i,field:a,value:t})},get:function(){var t=w.options.vuexModule?w.options.vuexModule+"/":"";return this.$store.getters[t+"formValues"][i]?this.$store.getters[t+"formValues"][i][a]:""}}}(e);return r}},function(t,r,e){var n=function(){return this}()||Function("return this")(),o=n.regeneratorRuntime&&Object.getOwnPropertyNames(n).indexOf("regeneratorRuntime")>=0,i=o&&n.regeneratorRuntime;if(n.regeneratorRuntime=void 0,t.exports=e(12),o)n.regeneratorRuntime=i;else try{delete n.regeneratorRuntime}catch(t){n.regeneratorRuntime=void 0}},function(t,r){!function(r){"use strict";function e(t,r,e,n){var i=r&&r.prototype instanceof o?r:o,a=Object.create(i.prototype),u=new d(n||[]);return a._invoke=c(t,e,u),a}function n(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}function o(){}function i(){}function a(){}function u(t){["next","throw","return"].forEach(function(r){t[r]=function(t){return this._invoke(r,t)}})}function s(t){function r(e,o,i,a){var u=n(t[e],t,o);if("throw"!==u.type){var s=u.arg,c=s.value;return c&&"object"==typeof c&&b.call(c,"__await")?Promise.resolve(c.__await).then(function(t){r("next",t,i,a)},function(t){r("throw",t,i,a)}):Promise.resolve(c).then(function(t){s.value=t,i(s)},a)}a(u.arg)}function e(t,e){function n(){return new Promise(function(n,o){r(t,e,n,o)})}return o=o?o.then(n,n):n()}var o;this._invoke=e}function c(t,r,e){var o=O;return function(i,a){if(o===S)throw new Error("Generator is already running");if(o===k){if("throw"===i)throw a;return m()}for(e.method=i,e.arg=a;;){var u=e.delegate;if(u){var s=l(u,e);if(s){if(s===I)continue;return s}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if(o===O)throw o=k,e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);o=S;var c=n(t,r,e);if("normal"===c.type){if(o=e.done?k:A,c.arg===I)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(o=k,e.method="throw",e.arg=c.arg)}}}function l(t,r){var e=t.iterator[r.method];if(e===v){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=v,l(t,r),"throw"===r.method))return I;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return I}var o=n(e,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,I;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=v),r.delegate=null,I):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,I)}function f(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function p(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function d(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(f,this),this.reset(!0)}function h(t){if(t){var r=t[x];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,n=function r(){for(;++e=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=b.call(o,"catchLoc"),u=b.call(o,"finallyLoc");if(a&&u){if(this.prev=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&b.call(n,"finallyLoc")&&this.prev=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),p(e),I}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;p(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:h(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=v),I}}}(function(){return this}()||Function("return this")())},function(t,r,e){"use strict";function n(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}Object.defineProperty(r,"__esModule",{value:!0}),r.formulateModule=r.formulateMutations=r.formulateActions=r.formulateGetters=r.formulateState=void 0;var o=e(2),i=r.formulateState=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(){return Object.assign({values:{},errors:{},validationErrors:{},meta:{}},t)}},a=r.formulateGetters=function(){var t=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return Object.assign({formValues:function(t){return t.values},formErrors:function(t){return t.errors},formValidationErrors:function(t){return t.validationErrors},formMeta:function(t){return(0,o.reduce)(t.meta,function(t,r,e){return t[r]=(0,o.reduce)(e,function(t,r,e){return t.concat(e)},[]),t},{})},hasErrors:function(t){return(0,o.map)(t.errors,function(t,r){return(0,o.reduce)(r,function(t,r,e){return t||!!e.length},!1)})},hasValidationErrors:function(t){return(0,o.map)(t.validationErrors,function(t,r){return(0,o.reduce)(r,function(t,r,e){return t||!!e.length},!1)})}},t)},u=r.formulateActions=function(){var t=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return Object.assign({},t)},s=r.formulateMutations=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign({setFieldValue:function(t,r){var e=r.form,o=r.field,i=r.value;t.values=Object.assign({},t.values,n({},e,Object.assign({},t.values[e]||{},n({},o,i))))},setFieldErrors:function(t,r){var e=r.form,o=r.field,i=r.errors;t.errors=Object.assign({},t.errors,n({},e,Object.assign({},t.errors[e]||{},n({},o,i))))},setFieldValidationErrors:function(t,r){var e=r.form,o=r.field,i=r.errors;t.validationErrors=Object.assign({},t.validationErrors,n({},e,Object.assign({},t.validationErrors[e]||{},n({},o,i))))},setFieldMeta:function(t,r){var e=r.form,o=r.field,i=r.data;t.meta=Object.assign({},t.meta,n({},e,Object.assign({},t.meta[e]||{},n({},o,i))))}},t)};r.formulateModule=function(t){return{state:i(),getters:a(t),actions:u(t),mutations:s(),namespaced:!0}}},function(t,r,e){"use strict";/*! +t.exports=function(t,r,e){for(var n in t)if(!1===r.call(e,t[n],n,t))break}},function(t,r){t.exports=function(t,r,e,n,o,i){var a,u=t=t||{},s=typeof t.default;"object"!==s&&"function"!==s||(a=t,u=t.default);var c="function"==typeof u?u.options:u;r&&(c.render=r.render,c.staticRenderFns=r.staticRenderFns,c._compiled=!0),e&&(c.functional=!0),o&&(c._scopeId=o);var l;if(i?(l=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),n&&n.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},c._ssrRegister=l):n&&(l=n),l){var f=c.functional,p=f?c.render:c.beforeCreate;f?(c._injectStyles=l,c.render=function(t,r){return l.call(r),p(t,r)}):c.beforeCreate=p?[].concat(p,l):[l]}return{esModule:a,exports:u,options:c}}},function(t,r,e){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function o(t){return function(){var r=t.apply(this,arguments);return new Promise(function(t,e){function n(o,i){try{var a=r[o](i),u=a.value}catch(t){return void e(t)}if(!a.done)return Promise.resolve(u).then(function(t){n("next",t)},function(t){n("throw",t)});t(u)}return n("next")})}}function i(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}Object.defineProperty(r,"__esModule",{value:!0});var a=e(1),u=n(a),s=e(2),c=e(4),l=n(c);r.default={props:{name:{type:String,required:!0},module:{type:[String,Boolean],default:function(){return this.$formulate.options.vuexModule}},initial:{type:Object,default:function(){return{}}},behavior:{type:String,default:"blur"},showErrors:{type:[Boolean,Object],default:function(){return{}}},errors:{type:Object,default:function(){return{}}},prevent:{type:String,default:"validation"}},data:function(){return{parentIdentifier:"vue-formulate-wrapper-element",forceErrors:null,fieldInitials:{}}},computed:{m:function(){return this.module?this.module+"/":""},hasErrors:function(){return this.$store.getters[this.m+"hasErrors"][this.name]||!1},hasValidationErrors:function(){return this.$store.getters[this.m+"hasValidationErrors"][this.name]||!1},values:function(){return(0,l.default)(this.$store.getters[this.m+"formValues"][this.name]||{})},storeErrors:function(){return this.$store.getters[this.m+"formErrors"][this.name]||{}},validationErrors:function(){return this.$store.getters[this.m+"formValidationErrors"][this.name]||{}},fields:function(){return this.$store.getters[this.m+"formMeta"][this.name]||[]},shouldShowErrors:function(){return!1===this.forceErrors||!0===this.forceErrors?this.forceErrors:!1===this.showErrors||!0===this.showErrors?this.showErrors:"live"===this.behavior},mergedInitial:function(){return Object.assign({},this.initial,this.fieldInitials)}},watch:{mergedInitial:function(){this.hydrate(this.mergedInitial)}},created:function(){this.hydrate(this.mergedInitial)},mounted:function(){this.hydrate(this.mergedInitial)},methods:{registerField:function(t,r){this.$store.commit(this.m+"setFieldMeta",{form:this.name,field:t,data:r}),this.updateFormValidation()},hydrate:function(t){var r=!0,e=!1,n=void 0;try{for(var o,i=this.fields[Symbol.iterator]();!(r=(o=i.next()).done);r=!0){var a=o.value;"submit"!==a.type&&this.$store.commit(this.m+"setFieldValue",{field:a.name,value:t[a.name],form:this.name})}}catch(t){e=!0,n=t}finally{try{!r&&i.return&&i.return()}finally{if(e)throw n}}this.updateFormValidation()},setInitial:function(t,r){this.fieldInitials=Object.assign({},this.fieldInitials,i({},t,r))},update:function(t){this.$store.commit(this.m+"setFieldValue",Object.assign(t,{form:this.name})),this.updateFormValidation()},updateFieldErrors:function(t){this.$store.commit(this.m+"setFieldErrors",Object.assign(t,{form:this.name}))},updateFieldValidationErrors:function(t){this.$store.commit(this.m+"setFieldValidationErrors",Object.assign(t,{form:this.name}))},validateField:function(){function t(t){return r.apply(this,arguments)}var r=o(u.default.mark(function t(r){var e,n=r.field,o=r.validation,i=r.label;return u.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.$formulate.validationErrors({field:n,value:this.values[n],label:i},o,this.values);case 2:return e=t.sent,(0,s.equals)(e||[],this.validationErrors[n]||[])||this.updateFieldValidationErrors({field:n,errors:e||[]}),t.abrupt("return",e);case 5:case"end":return t.stop()}},t,this)}));return t}(),updateFormValidation:function(){var t=this;this.fields.map(function(){var r=o(u.default.mark(function r(e){return u.default.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.validateField({field:e.name,validation:e.validation,label:e.validationLabel||e.label||e.name}));case 1:case"end":return r.stop()}},r,t)}));return function(t){return r.apply(this,arguments)}}())},submit:function(){"validation"===this.prevent&&this.hasValidationErrors||"any"===this.prevent&&this.hasErrors?this.forceErrors=!0:this.$emit("submit",Object.assign({},this.values))}}}},function(t,r,e){"use strict";function n(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}Object.defineProperty(r,"__esModule",{value:!0});var o=e(2),i=e(25),a=function(t){return t&&t.__esModule?t:{default:t}}(i);r.default={props:{type:{type:[String,Boolean],default:"text"},name:{type:String,required:!0},initial:{type:[String,Number,Boolean],default:!1},validation:{type:[String,Boolean],default:!1},errors:{type:Array,default:function(){return[]}},label:{type:[String,Boolean],default:!1},id:{type:[String],default:function(){return a.default.generate()}},min:{type:[String,Number,Boolean],default:function(){return!1}},max:{type:[String,Number,Boolean],default:function(){return!1}},placeholder:{type:[String,Number,Boolean],default:function(){return!1}},options:{type:[Object,Array],default:function(){return[]}},multiple:{type:Boolean,default:!1},showErrors:{type:[Object,Boolean],default:function(){return{}}},validationLabel:{type:[String,Boolean],default:!1}},data:function(){return{errorBlurState:!1}},computed:{hasCustomInput:function(){return this.$slots.default&&this.$slots.default.length},isTextInput:function(){return!this.hasCustomInput&&o.inputTypes.text.includes(this.type)},isButtonInput:function(){return!this.hasCustomInput&&o.inputTypes.button.includes(this.type)},isSelectInput:function(){return!this.hasCustomInput&&o.inputTypes.select.includes(this.type)},isBoxInput:function(){return!this.hasCustomInput&&o.inputTypes.box.includes(this.type)},isUnsupportedInput:function(){return!(this.hasCustomInput||this.isTextInput||this.isButtonInput||this.isSelectInput||this.isBoxInput)},form:function(){for(var t=this.$parent;t&&t.$data&&"vue-formulate-wrapper-element"!==t.$data.parentIdentifier;)t=t.$parent;if(!t.$data||"vue-formulate-wrapper-element"!==t.$data.parentIdentifier)throw new Error("FormulateElement has no FormulateWrapper element");return t},values:function(){return this.form.values},value:function(){var t=this.values[this.name];if(void 0===t)switch(this.type){case"color":return"#000000";case"checkbox":if(this.optionList.length>1)return[]}return t},module:function(){return this.form.$props.module},formName:function(){return this.form.$props.name},classes:function(){var t;return t={"formulate-element":!0},n(t,"formulate-element--type--"+this.type,!0),n(t,"formulate-element--has-value",!!this.value),n(t,"formulate-element--has-errors",this.localAndValidationErrors.length&&this.shouldShowErrors),t},validationErrors:function(){return this.form.validationErrors[this.name]||[]},storeErrors:function(){return this.form.storeErrors[this.name]||[]},formErrors:function(){return this.form.errors[this.name]||[]},localAndValidationErrors:function(){return this.errors.concat(this.validationErrors).concat(this.formErrors)},shouldShowErrors:function(){var t=this.form.shouldShowErrors;return"blur"===this.form.behavior&&(t=t||this.errorBlurState),!1!==this.showErrors&&!0!==this.showErrors||(t=this.showErrors),t},attributes:function(){var t=this;return["min","max","placeholder","id","multiple"].filter(function(r){return!1!==t[r]}).reduce(function(r,e){return r[e]=t[e],r},{})},optionList:function(){return Array.isArray(this.options)?Array.isArray(this.options)&&!this.options.length?[{value:this.name,label:this.label||this.name,id:a.default.generate()}]:this.options:(0,o.reduce)(this.options,function(t,r,e){return t.concat({value:r,label:e,id:a.default.generate()})},[])},val:{set:function(t){this.form.update({field:this.name,value:t}),this.isTextInput&&(this.$refs.input.value=t)},get:function(){return this.value}}},watch:{localAndValidationErrors:function(){(0,o.equals)(this.localAndValidationErrors,this.storeErrors)||this.form.updateFieldErrors({field:this.name,errors:this.localAndValidationErrors})},initial:function(){this.form.update({field:this.name,value:this.initial})}},created:function(){this.form.registerField(this.name,(0,o.filter)(this.$props,function(t,r){return["name","type","id","label","validation","validationLabel"].includes(t)})),!1!==this.initial&&this.form.setInitial(this.name,this.initial)}}},function(t,r,e){"use strict";function n(t,r){for(var e,n=0,i="";!e;)i+=t(r>>4*n&15|o()),e=r1&&void 0!==arguments[1]?arguments[1]:{};t.prototype.$formulate=this,r=Object.assign(this.defaultOptions,r),r.registerComponents&&(t.component(r.tags.Formulate,d.default),t.component(r.tags.FormulateElement,m.default)),r.errors&&(this.errors=Object.assign(this.errors,r.errors)),r.rules&&(this.rules=Object.assign(this.rules,r.rules)),this.options=r}},{key:"parseRules",value:function(t){return t.split("|").map(function(t){return t.trim()}).map(function(t){return t.match(/([a-zA-Z0-9]+)\((.*)?\)/)||[null,t,""]}).map(function(t){var r=c(t,3),e=(r[0],r[1]),n=r[2];return Object.assign({},{rule:e},n?{args:n.split(",").map(function(t){return t.trim()})}:{args:[]})})}},{key:"errorFactory",value:function(t){return this.errors[t]?this.errors[t]:this.errors.default}},{key:"validationErrors",value:function(){function t(t,e,n){return r.apply(this,arguments)}var r=i(s.default.mark(function t(r,e,n){var i=r.field,a=r.value,u=r.label,c=this;return s.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",!!e&&Promise.all(this.parseRules(e).map(function(t){var r,e=t.rule,s=t.args;if("function"!=typeof c.rules[e])throw new Error("Validation rule is invalid: "+e);return(r=c.rules)[e].apply(r,[{field:i,value:a,label:u,error:c.errorFactory(e),values:n}].concat(o(s)))})).then(function(t){return t.reduce(function(t,r){return r?Array.isArray(t)?t.concat(r):[r]:t},!1)}));case 1:case"end":return t.stop()}},t,this)}));return t}()}]),t}(),w=new x;r.default=w,r.mapModels=function(t){var r={};for(var e in t)!function(e){var n=t[e].split("/"),o=c(n,2),i=o[0],a=o[1];r[e]={set:function(t){var r=w.options.vuexModule?w.options.vuexModule+"/":"";this.$store.commit(r+"setFieldValue",{form:i,field:a,value:t})},get:function(){var t=w.options.vuexModule?w.options.vuexModule+"/":"";return this.$store.getters[t+"formValues"][i]?this.$store.getters[t+"formValues"][i][a]:""}}}(e);return r}},function(t,r,e){var n=function(){return this}()||Function("return this")(),o=n.regeneratorRuntime&&Object.getOwnPropertyNames(n).indexOf("regeneratorRuntime")>=0,i=o&&n.regeneratorRuntime;if(n.regeneratorRuntime=void 0,t.exports=e(12),o)n.regeneratorRuntime=i;else try{delete n.regeneratorRuntime}catch(t){n.regeneratorRuntime=void 0}},function(t,r){!function(r){"use strict";function e(t,r,e,n){var i=r&&r.prototype instanceof o?r:o,a=Object.create(i.prototype),u=new d(n||[]);return a._invoke=c(t,e,u),a}function n(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}function o(){}function i(){}function a(){}function u(t){["next","throw","return"].forEach(function(r){t[r]=function(t){return this._invoke(r,t)}})}function s(t){function r(e,o,i,a){var u=n(t[e],t,o);if("throw"!==u.type){var s=u.arg,c=s.value;return c&&"object"==typeof c&&b.call(c,"__await")?Promise.resolve(c.__await).then(function(t){r("next",t,i,a)},function(t){r("throw",t,i,a)}):Promise.resolve(c).then(function(t){s.value=t,i(s)},a)}a(u.arg)}function e(t,e){function n(){return new Promise(function(n,o){r(t,e,n,o)})}return o=o?o.then(n,n):n()}var o;this._invoke=e}function c(t,r,e){var o=O;return function(i,a){if(o===S)throw new Error("Generator is already running");if(o===k){if("throw"===i)throw a;return m()}for(e.method=i,e.arg=a;;){var u=e.delegate;if(u){var s=l(u,e);if(s){if(s===I)continue;return s}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if(o===O)throw o=k,e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);o=S;var c=n(t,r,e);if("normal"===c.type){if(o=e.done?k:A,c.arg===I)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(o=k,e.method="throw",e.arg=c.arg)}}}function l(t,r){var e=t.iterator[r.method];if(e===v){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=v,l(t,r),"throw"===r.method))return I;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return I}var o=n(e,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,I;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=v),r.delegate=null,I):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,I)}function f(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function p(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function d(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(f,this),this.reset(!0)}function h(t){if(t){var r=t[x];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,n=function r(){for(;++e=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=b.call(o,"catchLoc"),u=b.call(o,"finallyLoc");if(a&&u){if(this.prev=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&b.call(n,"finallyLoc")&&this.prev=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),p(e),I}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;p(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:h(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=v),I}}}(function(){return this}()||Function("return this")())},function(t,r,e){"use strict";function n(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}Object.defineProperty(r,"__esModule",{value:!0}),r.formulateModule=r.formulateMutations=r.formulateActions=r.formulateGetters=r.formulateState=void 0;var o=e(2),i=r.formulateState=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(){return Object.assign({values:{},errors:{},validationErrors:{},meta:{}},t)}},a=r.formulateGetters=function(){var t=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return Object.assign({formValues:function(t){return t.values},formErrors:function(t){return t.errors},formValidationErrors:function(t){return t.validationErrors},formMeta:function(t){return(0,o.reduce)(t.meta,function(t,r,e){return t[r]=(0,o.reduce)(e,function(t,r,e){return t.concat(e)},[]),t},{})},hasErrors:function(t){return(0,o.map)(t.errors,function(t,r){return(0,o.reduce)(r,function(t,r,e){return t||!!e.length},!1)})},hasValidationErrors:function(t){return(0,o.map)(t.validationErrors,function(t,r){return(0,o.reduce)(r,function(t,r,e){return t||!!e.length},!1)})}},t)},u=r.formulateActions=function(){var t=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return Object.assign({},t)},s=r.formulateMutations=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign({setFieldValue:function(t,r){var e=r.form,o=r.field,i=r.value;t.values=Object.assign({},t.values,n({},e,Object.assign({},t.values[e]||{},n({},o,i))))},setFieldErrors:function(t,r){var e=r.form,o=r.field,i=r.errors;t.errors=Object.assign({},t.errors,n({},e,Object.assign({},t.errors[e]||{},n({},o,i))))},setFieldValidationErrors:function(t,r){var e=r.form,o=r.field,i=r.errors;t.validationErrors=Object.assign({},t.validationErrors,n({},e,Object.assign({},t.validationErrors[e]||{},n({},o,i))))},setFieldMeta:function(t,r){var e=r.form,o=r.field,i=r.data;t.meta=Object.assign({},t.meta,n({},e,Object.assign({},t.meta[e]||{},n({},o,i))))}},t)};r.formulateModule=function(t){return{state:i(),getters:a(t),actions:u(t),mutations:s(),namespaced:!0}}},function(t,r,e){"use strict";/*! * isobject * * Copyright (c) 2014-2017, Jon Schlinkert. @@ -40,4 +40,4 @@ var n=e(3);t.exports=function(t){return n(t)||"function"==typeof t||Array.isArra * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ -var n=e(5),o=Object.prototype.hasOwnProperty;t.exports=function(t,r,e){n(t,function(n,i){if(o.call(t,i))return r.call(e,t[i],i,t)})}},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e(7),o=e.n(n);for(var i in n)"default"!==i&&function(t){e.d(r,t,function(){return n[t]})}(i);var a=e(23),u=e(6),s=u(o.a,a.a,!1,null,null,null);r.default=s.exports},function(t,r,e){"use strict";var n=function(){var t=this,r=t.$createElement;return(t._self._c||r)("form",{staticClass:"formulate-form",on:{submit:function(r){r.preventDefault(),t.submit(r)}}},[t._t("default")],2)},o=[],i={render:n,staticRenderFns:o};r.a=i},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e(8),o=e.n(n);for(var i in n)"default"!==i&&function(t){e.d(r,t,function(){return n[t]})}(i);var a=e(33),u=e(6),s=u(o.a,a.a,!1,null,null,null);r.default=s.exports},function(t,r,e){"use strict";t.exports=e(26)},function(t,r,e){"use strict";function n(r){return u.seed(r),t.exports}function o(r){return f=r,t.exports}function i(t){return void 0!==t&&u.characters(t),u.shuffled()}function a(){return c(f)}var u=e(0),s=(e(9),e(29)),c=e(30),l=e(31),f=e(32)||0;t.exports=a,t.exports.generate=a,t.exports.seed=n,t.exports.worker=o,t.exports.characters=i,t.exports.decode=s,t.exports.isValid=l},function(t,r,e){"use strict";function n(){return(i=(9301*i+49297)%233280)/233280}function o(t){i=t}var i=1;t.exports={nextValue:n,seed:o}},function(t,r,e){"use strict";function n(){if(!o||!o.getRandomValues)return 48&Math.floor(256*Math.random());var t=new Uint8Array(1);return o.getRandomValues(t),48&t[0]}var o="object"==typeof window&&(window.crypto||window.msCrypto);t.exports=n},function(t,r,e){"use strict";function n(t){var r=o.shuffled();return{version:15&r.indexOf(t.substr(0,1)),worker:15&r.indexOf(t.substr(1,1))}}var o=e(0);t.exports=n},function(t,r,e){"use strict";function n(t){var r="",e=Math.floor(.001*(Date.now()-s));return e===i?o++:(o=0,i=e),r+=a(u.lookup,c),r+=a(u.lookup,t),o>0&&(r+=a(u.lookup,o)),r+=a(u.lookup,e)}var o,i,a=e(9),u=e(0),s=1459707606518,c=6;t.exports=n},function(t,r,e){"use strict";function n(t){if(!t||"string"!=typeof t||t.length<6)return!1;for(var r=o.characters(),e=t.length,n=0;n1)?e("label",{attrs:{for:t.id},domProps:{textContent:t._s(t.label)}}):t._e(),t._v(" "),"checkbox"===t.type&&t.isTextInput?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],ref:"input",attrs:{name:t.name,type:"checkbox"},domProps:{checked:Array.isArray(t.val)?t._i(t.val,null)>-1:t.val},on:{blur:function(r){t.errorBlurState=!0},change:function(r){var e=t.val,n=r.target,o=!!n.checked;if(Array.isArray(e)){var i=t._i(e,null);n.checked?i<0&&(t.val=e.concat([null])):i>-1&&(t.val=e.slice(0,i).concat(e.slice(i+1)))}else t.val=o}}},"input",t.attributes,!1)):"radio"===t.type&&t.isTextInput?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],ref:"input",attrs:{name:t.name,type:"radio"},domProps:{checked:t._q(t.val,null)},on:{blur:function(r){t.errorBlurState=!0},change:function(r){t.val=null}}},"input",t.attributes,!1)):t.isTextInput?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],ref:"input",attrs:{name:t.name,type:t.type},domProps:{value:t.val},on:{blur:function(r){t.errorBlurState=!0},input:function(r){r.target.composing||(t.val=r.target.value)}}},"input",t.attributes,!1)):t._e(),t._v(" "),t.isButtonInput?e("button",{attrs:{type:t.type,disabled:"submit"===t.type&&t.form.hasErrors&&"live"===t.form.behavior},domProps:{textContent:t._s(t.label||t.name)}}):t._e(),t._v(" "),t.isSelectInput?e("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],attrs:{name:t.name},on:{blur:function(r){t.errorBlurState=!0},change:function(r){var e=Array.prototype.filter.call(r.target.options,function(t){return t.selected}).map(function(t){return"_value"in t?t._value:t.value});t.val=r.target.multiple?e:e[0]}}},"select",t.attributes,!1),t._l(t.optionList,function(r){return e("option",t._b({key:r.id,domProps:{value:r.value,textContent:t._s(r.label)}},"option",r.attributes||{},!1))})):t._e(),t._v(" "),t.isBoxInput?e("div",{staticClass:"formulate-element-box-input-group"},[t._l(t.optionList,function(r){return["radio"===t.type?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],key:r.id+"-input",attrs:{type:"radio",name:t.name,id:r.id},domProps:{value:r.value,checked:t._q(t.val,r.value)},on:{blur:function(r){t.errorBlurState=!0},change:function(e){t.val=r.value}}},"input",t.attributes,!1)):t._e(),t._v(" "),"checkbox"===t.type?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],key:r.id+"-input",attrs:{type:"checkbox",name:t.name,id:r.id},domProps:{value:r.value,checked:Array.isArray(t.val)?t._i(t.val,r.value)>-1:t.val},on:{blur:function(r){t.errorBlurState=!0},change:function(e){var n=t.val,o=e.target,i=!!o.checked;if(Array.isArray(n)){var a=r.value,u=t._i(n,a);o.checked?u<0&&(t.val=n.concat([a])):u>-1&&(t.val=n.slice(0,u).concat(n.slice(u+1)))}else t.val=i}}},"input",t.attributes,!1)):t._e(),t._v(" "),e("label",{key:r.id+"-label",attrs:{for:r.id},domProps:{textContent:t._s(r.label)}})]})],2):t._e(),t._v(" "),t.hasCustomInput?t._t("default"):t._e(),t._v(" "),t.isUnsupportedInput?e("div",{staticStyle:{"background-color":"red",color:"white"},domProps:{textContent:t._s("Unsupported field type: “"+t.type+"”.")}}):t._e()],2),t._v(" "),t.shouldShowErrors&&t.localAndValidationErrors.length?e("ul",{staticClass:"formulate-errors"},t._l(t.localAndValidationErrors,function(r){return e("li",{key:r,domProps:{textContent:t._s(r)}})})):t._e()])},o=[],i={render:n,staticRenderFns:o};r.a=i},function(t,r,e){"use strict";function n(t){return function(){var r=t.apply(this,arguments);return new Promise(function(t,e){function n(o,i){try{var a=r[o](i),u=a.value}catch(t){return void e(t)}if(!a.done)return Promise.resolve(u).then(function(t){n("next",t)},function(t){n("throw",t)});t(u)}return n("next")})}}Object.defineProperty(r,"__esModule",{value:!0});var o=e(1),i=function(t){return t&&t.__esModule?t:{default:t}}(o);r.default={required:function(){function t(t){return r.apply(this,arguments)}var r=n(i.default.mark(function t(r){var e=r.value,n=r.error,o=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",!(e&&(!Array.isArray(e)||e.length))&&n.apply(void 0,o));case 1:case"end":return t.stop()}},t,this)}));return t}(),email:function(){function t(t){return r.apply(this,arguments)}var r=n(i.default.mark(function t(r){var e,n=r.value,o=r.error,a=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=/^(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/,t.abrupt("return",!(!n||e.test(n.toLowerCase()))&&o.apply(void 0,a));case 2:case"end":return t.stop()}},t,this)}));return t}(),confirmed:function(){function t(t,e){return r.apply(this,arguments)}var r=n(i.default.mark(function t(r,e){var n=r.field,o=r.value,a=r.error,u=r.values,s=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=e||n+"_confirmation",t.abrupt("return",!(!o||o===u[e])&&a.apply(void 0,s));case 2:case"end":return t.stop()}},t,this)}));return t}()}},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default={required:function(t){var r=t.label;return t.value,r+" is required"},email:function(t){var r=t.label;return t.value,r+" is invalid."},confirmed:function(t){var r=t.label;return t.value,r+" does not match the confirmation field."},default:function(t){return t.label,t.value,"This field is invalid."}}}])}); \ No newline at end of file +var n=e(5),o=Object.prototype.hasOwnProperty;t.exports=function(t,r,e){n(t,function(n,i){if(o.call(t,i))return r.call(e,t[i],i,t)})}},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e(7),o=e.n(n);for(var i in n)"default"!==i&&function(t){e.d(r,t,function(){return n[t]})}(i);var a=e(23),u=e(6),s=u(o.a,a.a,!1,null,null,null);r.default=s.exports},function(t,r,e){"use strict";var n=function(){var t=this,r=t.$createElement;return(t._self._c||r)("form",{staticClass:"formulate-form",on:{submit:function(r){r.preventDefault(),t.submit(r)}}},[t._t("default")],2)},o=[],i={render:n,staticRenderFns:o};r.a=i},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e(8),o=e.n(n);for(var i in n)"default"!==i&&function(t){e.d(r,t,function(){return n[t]})}(i);var a=e(33),u=e(6),s=u(o.a,a.a,!1,null,null,null);r.default=s.exports},function(t,r,e){"use strict";t.exports=e(26)},function(t,r,e){"use strict";function n(r){return u.seed(r),t.exports}function o(r){return f=r,t.exports}function i(t){return void 0!==t&&u.characters(t),u.shuffled()}function a(){return c(f)}var u=e(0),s=(e(9),e(29)),c=e(30),l=e(31),f=e(32)||0;t.exports=a,t.exports.generate=a,t.exports.seed=n,t.exports.worker=o,t.exports.characters=i,t.exports.decode=s,t.exports.isValid=l},function(t,r,e){"use strict";function n(){return(i=(9301*i+49297)%233280)/233280}function o(t){i=t}var i=1;t.exports={nextValue:n,seed:o}},function(t,r,e){"use strict";function n(){if(!o||!o.getRandomValues)return 48&Math.floor(256*Math.random());var t=new Uint8Array(1);return o.getRandomValues(t),48&t[0]}var o="object"==typeof window&&(window.crypto||window.msCrypto);t.exports=n},function(t,r,e){"use strict";function n(t){var r=o.shuffled();return{version:15&r.indexOf(t.substr(0,1)),worker:15&r.indexOf(t.substr(1,1))}}var o=e(0);t.exports=n},function(t,r,e){"use strict";function n(t){var r="",e=Math.floor(.001*(Date.now()-s));return e===i?o++:(o=0,i=e),r+=a(u.lookup,c),r+=a(u.lookup,t),o>0&&(r+=a(u.lookup,o)),r+=a(u.lookup,e)}var o,i,a=e(9),u=e(0),s=1459707606518,c=6;t.exports=n},function(t,r,e){"use strict";function n(t){if(!t||"string"!=typeof t||t.length<6)return!1;for(var r=o.characters(),e=t.length,n=0;n1)?e("label",{attrs:{for:t.id},domProps:{textContent:t._s(t.label)}}):t._e(),t._v(" "),"checkbox"===t.type&&t.isTextInput?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],ref:"input",attrs:{name:t.name,type:"checkbox"},domProps:{checked:Array.isArray(t.val)?t._i(t.val,null)>-1:t.val},on:{blur:function(r){t.errorBlurState=!0},change:function(r){var e=t.val,n=r.target,o=!!n.checked;if(Array.isArray(e)){var i=t._i(e,null);n.checked?i<0&&(t.val=e.concat([null])):i>-1&&(t.val=e.slice(0,i).concat(e.slice(i+1)))}else t.val=o}}},"input",t.attributes,!1)):"radio"===t.type&&t.isTextInput?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],ref:"input",attrs:{name:t.name,type:"radio"},domProps:{checked:t._q(t.val,null)},on:{blur:function(r){t.errorBlurState=!0},change:function(r){t.val=null}}},"input",t.attributes,!1)):t.isTextInput?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],ref:"input",attrs:{name:t.name,type:t.type},domProps:{value:t.val},on:{blur:function(r){t.errorBlurState=!0},input:function(r){r.target.composing||(t.val=r.target.value)}}},"input",t.attributes,!1)):t._e(),t._v(" "),t.isButtonInput?e("button",{attrs:{type:t.type,disabled:"submit"===t.type&&t.form.hasErrors&&"live"===t.form.behavior},domProps:{textContent:t._s(t.label||t.name)}}):t._e(),t._v(" "),t.isSelectInput?e("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],attrs:{name:t.name},on:{blur:function(r){t.errorBlurState=!0},change:function(r){var e=Array.prototype.filter.call(r.target.options,function(t){return t.selected}).map(function(t){return"_value"in t?t._value:t.value});t.val=r.target.multiple?e:e[0]}}},"select",t.attributes,!1),t._l(t.optionList,function(r){return e("option",t._b({key:r.id,domProps:{value:r.value,textContent:t._s(r.label)}},"option",r.attributes||{},!1))})):t._e(),t._v(" "),t.isBoxInput?e("div",{staticClass:"formulate-element-box-input-group"},[t._l(t.optionList,function(r){return["radio"===t.type?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],key:r.id+"-input",attrs:{type:"radio",name:t.name,id:r.id},domProps:{value:r.value,checked:t._q(t.val,r.value)},on:{blur:function(r){t.errorBlurState=!0},change:function(e){t.val=r.value}}},"input",t.attributes,!1)):t._e(),t._v(" "),"checkbox"===t.type?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],key:r.id+"-input",attrs:{type:"checkbox",name:t.name,id:r.id},domProps:{value:r.value,checked:Array.isArray(t.val)?t._i(t.val,r.value)>-1:t.val},on:{blur:function(r){t.errorBlurState=!0},change:function(e){var n=t.val,o=e.target,i=!!o.checked;if(Array.isArray(n)){var a=r.value,u=t._i(n,a);o.checked?u<0&&(t.val=n.concat([a])):u>-1&&(t.val=n.slice(0,u).concat(n.slice(u+1)))}else t.val=i}}},"input",t.attributes,!1)):t._e(),t._v(" "),e("label",{key:r.id+"-label",attrs:{for:r.id},domProps:{textContent:t._s(r.label)}})]})],2):t._e(),t._v(" "),t.hasCustomInput?t._t("default"):t._e(),t._v(" "),t.isUnsupportedInput?e("div",{staticStyle:{"background-color":"red",color:"white"},domProps:{textContent:t._s("Unsupported field type: “"+t.type+"”.")}}):t._e()],2),t._v(" "),t.shouldShowErrors&&t.localAndValidationErrors.length?e("ul",{staticClass:"formulate-errors"},t._l(t.localAndValidationErrors,function(r){return e("li",{key:r,domProps:{textContent:t._s(r)}})})):t._e()])},o=[],i={render:n,staticRenderFns:o};r.a=i},function(t,r,e){"use strict";function n(t){return function(){var r=t.apply(this,arguments);return new Promise(function(t,e){function n(o,i){try{var a=r[o](i),u=a.value}catch(t){return void e(t)}if(!a.done)return Promise.resolve(u).then(function(t){n("next",t)},function(t){n("throw",t)});t(u)}return n("next")})}}Object.defineProperty(r,"__esModule",{value:!0});var o=e(1),i=function(t){return t&&t.__esModule?t:{default:t}}(o);r.default={required:function(){function t(t){return r.apply(this,arguments)}var r=n(i.default.mark(function t(r){var e=r.value,n=r.error,o=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",!(e&&(!Array.isArray(e)||e.length))&&n.apply(void 0,o));case 1:case"end":return t.stop()}},t,this)}));return t}(),email:function(){function t(t){return r.apply(this,arguments)}var r=n(i.default.mark(function t(r){var e,n=r.value,o=r.error,a=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=/^(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/,t.abrupt("return",!(!n||e.test(n.toLowerCase()))&&o.apply(void 0,a));case 2:case"end":return t.stop()}},t,this)}));return t}(),confirmed:function(){function t(t,e){return r.apply(this,arguments)}var r=n(i.default.mark(function t(r,e){var n=r.field,o=r.value,a=r.error,u=r.values,s=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=e||n+"_confirmation",t.abrupt("return",!(!o||o===u[e])&&a.apply(void 0,s));case 2:case"end":return t.stop()}},t,this)}));return t}()}},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default={required:function(t){var r=t.label;return t.value,r+" is required"},email:function(t){var r=t.label;return t.value,r+" is invalid."},confirmed:function(t){var r=t.label;return t.value,r+" does not match the confirmation field."},default:function(t){return t.label,t.value,"This field is invalid."}}}])}); \ No newline at end of file diff --git a/src/components/FormulateElement.vue b/src/components/FormulateElement.vue index cbbec71..c7c543b 100644 --- a/src/components/FormulateElement.vue +++ b/src/components/FormulateElement.vue @@ -1,6 +1,9 @@