diff --git a/README.md b/README.md index 2702330..dc449e8 100644 --- a/README.md +++ b/README.md @@ -57,14 +57,20 @@ root store: **Root Store** ```js -import {formulateState, formulateGetters, formulateMutation} from 'vue-formulate' +import Vue from 'vue' +import Vuex from 'vuex' +import {formulateState, formulateGetters, formulateMutations} from 'vue-formulate' + +Vue.use(Vuex) const state = () => ({ + // your own state data can live next to vue-formulate's data your: 'data', ...formulateState() }) const getters = { + // Your own getters can live next to vue-formulate's getters yourGetter (state) { return state.your }, @@ -72,17 +78,18 @@ const getters = { } const mutations = { + // Your own mutations can live next to vue-formulate's mutations setYour (state, payload) { state.your = payload }, ...formulateMutations() } -export default { +export default new Vuex.Store({ state, getters, mutations -} +}) ``` ### Usage diff --git a/dist/index.js b/dist/index.js index 9c30fb9..896b52c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1,43 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("vue-formulate",[],e):"object"==typeof exports?exports["vue-formulate"]=e():t["vue-formulate"]=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=7)}([function(t,e,r){"use strict";function n(){d=!1}function o(t){if(!t)return void(c!==p&&(c=p,n()));if(t!==c){if(t.length!==p.length)throw new Error("Custom alphabet for shortid must be "+p.length+" unique characters. You submitted "+t.length+" characters: "+t);var e=t.split("").filter(function(t,e,r){return e!==r.lastIndexOf(t)});if(e.length)throw new Error("Custom alphabet for shortid must be "+p.length+" unique characters. These characters were not unique: "+e.join(", "));c=t,n()}}function i(t){return o(t),c}function a(t){h.seed(t),f!==t&&(n(),f=t)}function u(){c||o(p);for(var t,e=c.split(""),r=[],n=h.nextValue();e.length>0;)n=h.nextValue(),t=Math.floor(n*e.length),r.push(e.splice(t,1)[0]);return r.join("")}function s(){return d||(d=u())}function l(t){return s()[t]}var c,f,d,h=r(16),p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";t.exports={characters:i,seed:a,lookup:l,shuffled:s}},function(t,e,r){t.exports=r(8)},function(t,e,r){"use strict";function n(t,e){var r=t.length;if(r!==e.length)return!1;for(var n=0;n1&&(t=[])}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.errors[this.name]||[]},localAndValidationErrors:function(){return this.errors.concat(this.validationErrors)},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(e){return!1!==t[e]}).reduce(function(e,r){return e[r]=t[r],e},{})},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,e,r){return t.concat({value:e,label:r,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})}},created:function(){this.form.registerField(this.name,this.$props),!1!==this.initial&&this.form.hydrate(n({},this.name,this.initial))}}},function(t,e,r){"use strict";function n(t,e){for(var r,n=0,i="";!r;)i+=t(e>>4*n&15|o()),r=e1&&void 0!==arguments[1]?arguments[1]:{};t.prototype.$formulate=this,e=Object.assign(this.defaultOptions,e),e.registerComponents&&(t.component(e.tags.Formulate,h.default),t.component(e.tags.FormulateElement,v.default)),e.errors&&(this.errors=Object.assign(this.errors,e.errors)),e.rules&&(this.rules=Object.assign(this.rules,e.rules)),this.options=e}},{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 e=l(t,3),r=(e[0],e[1]),n=e[2];return Object.assign({},{rule:r},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,r,n){return e.apply(this,arguments)}var e=i(s.default.mark(function t(e,r,n){var i=e.field,a=e.value,u=e.label,l=this;return s.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",!!r&&Promise.all(this.parseRules(r).map(function(t){var e,r=t.rule,s=t.args;if("function"!=typeof l.rules[r])throw new Error("Validation rule is invalid: "+r);return(e=l.rules)[r].apply(e,[{field:i,value:a,label:u,error:l.errorFactory(r),values:n}].concat(o(s)))})).then(function(t){return t.reduce(function(t,e){return e?Array.isArray(t)?t.concat(e):[e]:t},!1)}));case 1:case"end":return t.stop()}},t,this)}));return t}()}]),t}(),w=new x;e.default=w;e.mapModels=function(t){var e={};for(var r in t)!function(r){var n=t[r].split("/"),o=l(n,2),i=o[0],a=o[1];e[r]={set:function(t){var e=w.options.vuexModule?w.options.vuexModule+"/":"";this.$store.commit(e+"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]:""}}}(r);return e}},function(t,e,r){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=r(9),o)n.regeneratorRuntime=i;else try{delete n.regeneratorRuntime}catch(t){n.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";function r(t,e,r,n){var i=e&&e.prototype instanceof o?e:o,a=Object.create(i.prototype),u=new h(n||[]);return a._invoke=l(t,r,u),a}function n(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}function o(){}function i(){}function a(){}function u(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function s(t){function e(r,o,i,a){var u=n(t[r],t,o);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&b.call(l,"__await")?Promise.resolve(l.__await).then(function(t){e("next",t,i,a)},function(t){e("throw",t,i,a)}):Promise.resolve(l).then(function(t){s.value=t,i(s)},a)}a(u.arg)}function r(t,r){function n(){return new Promise(function(n,o){e(t,r,n,o)})}return o=o?o.then(n,n):n()}var o;this._invoke=r}function l(t,e,r){var o=j;return function(i,a){if(o===S)throw new Error("Generator is already running");if(o===F){if("throw"===i)throw a;return v()}for(r.method=i,r.arg=a;;){var u=r.delegate;if(u){var s=c(u,r);if(s){if(s===P)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===j)throw o=F,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=S;var l=n(t,e,r);if("normal"===l.type){if(o=r.done?F:k,l.arg===P)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(o=F,r.method="throw",r.arg=l.arg)}}}function c(t,e){var r=t.iterator[e.method];if(r===m){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=m,c(t,e),"throw"===e.method))return P;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return P}var o=n(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,P;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=m),e.delegate=null,P):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,P)}function f(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function d(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function h(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(f,this),this.reset(!0)}function p(t){if(t){var e=t[x];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=b.call(o,"catchLoc"),u=b.call(o,"finallyLoc");if(a&&u){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&b.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),d(r),P}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;d(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:p(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=m),P}}}(function(){return this}()||Function("return this")())},function(t,e,r){"use strict";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}Object.defineProperty(e,"__esModule",{value:!0}),e.formulateModule=e.formulateMutations=e.formulateActions=e.formulateGetters=e.formulateState=void 0;var o=function(){function t(t,e){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){o=!0,i=t}finally{try{!n&&u.return&&u.return()}finally{if(o)throw i}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=r(2),a=e.formulateState=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(){return Object.assign({values:{},errors:{},validationErrors:{},meta:{}},t)}},u=e.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,i.map)(t.meta,function(t,e){return Object.entries(e).map(function(t){var e=o(t,2);e[0];return e[1]})})},hasErrors:function(t){return(0,i.map)(t.errors,function(t,e){return(0,i.reduce)(e,function(t,e,r){return t||!!r.length},!1)})}},t)},s=e.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)},l=e.formulateMutations=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign({setFieldValue:function(t,e){var r=e.form,o=e.field,i=e.value;t.values=Object.assign({},t.values,n({},r,Object.assign({},t.values[r]||{},n({},o,i))))},setFieldErrors:function(t,e){var r=e.form,o=e.field,i=e.errors;t.errors=Object.assign({},t.errors,n({},r,Object.assign({},t.errors[r]||{},n({},o,i))))},setFieldValidationErrors:function(t,e){var r=e.form,o=e.field,i=e.errors;t.validationErrors=Object.assign({},t.validationErrors,n({},r,Object.assign({},t.validationErrors[r]||{},n({},o,i))))},setFieldMeta:function(t,e){var r=e.form,o=e.field,i=e.data;t.meta=Object.assign({},t.meta,n({},r,Object.assign({},t.meta[r]||{},n({},o,i))))}},t)};e.formulateModule=function(t){return{state:a(),getters:u(t),actions:s(t),mutations:l(),namespaced:!0}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(4),o=r.n(n);for(var i in n)"default"!==i&&function(t){r.d(e,t,function(){return n[t]})}(i);var a=r(12),u=r(3),s=u(o.a,a.a,!1,null,null,null);s.options.__file="src/components/Formulate.vue",e.default=s.exports},function(t,e,r){"use strict";var n=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{staticClass:"formulate-element",on:{submit:function(e){e.preventDefault(),t.submit(e)}}},[t._t("default")],2)},o=[];n._withStripped=!0;var i={render:n,staticRenderFns:o};e.a=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(5),o=r.n(n);for(var i in n)"default"!==i&&function(t){r.d(e,t,function(){return n[t]})}(i);var a=r(22),u=r(3),s=u(o.a,a.a,!1,null,null,null);s.options.__file="src/components/FormulateElement.vue",e.default=s.exports},function(t,e,r){"use strict";t.exports=r(15)},function(t,e,r){"use strict";function n(e){return u.seed(e),t.exports}function o(e){return f=e,t.exports}function i(t){return void 0!==t&&u.characters(t),u.shuffled()}function a(){return l(f)}var u=r(0),s=(r(6),r(18)),l=r(19),c=r(20),f=r(21)||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=c},function(t,e,r){"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,e,r){"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,e,r){"use strict";function n(t){var e=o.shuffled();return{version:15&e.indexOf(t.substr(0,1)),worker:15&e.indexOf(t.substr(1,1))}}var o=r(0);t.exports=n},function(t,e,r){"use strict";function n(t){var e="",r=Math.floor(.001*(Date.now()-s));return r===i?o++:(o=0,i=r),e+=a(u.lookup,l),e+=a(u.lookup,t),o>0&&(e+=a(u.lookup,o)),e+=a(u.lookup,r)}var o,i,a=r(6),u=r(0),s=1459707606518,l=6;t.exports=n},function(t,e,r){"use strict";function n(t){if(!t||"string"!=typeof t||t.length<6)return!1;for(var e=o.characters(),r=t.length,n=0;n1)?r("label",{attrs:{for:t.id},domProps:{textContent:t._s(t.label)}}):t._e(),t._v(" "),"checkbox"===t.type&&t.isTextInput?r("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(e){t.errorBlurState=!0},change:function(e){var r=t.val,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t._i(r,null);n.checked?i<0&&(t.val=r.concat([null])):i>-1&&(t.val=r.slice(0,i).concat(r.slice(i+1)))}else t.val=o}}},"input",t.attributes,!1)):"radio"===t.type&&t.isTextInput?r("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(e){t.errorBlurState=!0},change:function(e){t.val=null}}},"input",t.attributes,!1)):t.isTextInput?r("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(e){t.errorBlurState=!0},input:function(e){e.target.composing||(t.val=e.target.value)}}},"input",t.attributes,!1)):t._e(),t._v(" "),t.isButtonInput?r("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?r("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],attrs:{name:t.name},on:{blur:function(e){t.errorBlurState=!0},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.val=e.target.multiple?r:r[0]}}},"select",t.attributes,!1),t._l(t.optionList,function(e){return r("option",{key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}})})):t._e(),t._v(" "),t.isBoxInput?r("div",{staticClass:"formulate-element-box-input-group"},[t._l(t.optionList,function(e){return["radio"===t.type?r("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],key:e.id+"-input",attrs:{type:"radio",name:t.name,id:e.id},domProps:{value:e.value,checked:t._q(t.val,e.value)},on:{blur:function(e){t.errorBlurState=!0},change:function(r){t.val=e.value}}},"input",t.attributes,!1)):t._e(),t._v(" "),"checkbox"===t.type?r("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],key:e.id+"-input",attrs:{type:"checkbox",name:t.name,id:e.id},domProps:{value:e.value,checked:Array.isArray(t.val)?t._i(t.val,e.value)>-1:t.val},on:{blur:function(e){t.errorBlurState=!0},change:function(r){var n=t.val,o=r.target,i=!!o.checked;if(Array.isArray(n)){var a=e.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(" "),r("label",{key:e.id+"-label",attrs:{for:e.id},domProps:{textContent:t._s(e.label)}})]})],2):t._e(),t._v(" "),t.hasCustomInput?t._t("default"):t._e(),t._v(" "),t.isUnsupportedInput?r("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?r("ul",{staticClass:"formulate-errors"},t._l(t.localAndValidationErrors,function(e){return r("li",{key:e,domProps:{textContent:t._s(e)}})})):t._e()])},o=[];n._withStripped=!0;var i={render:n,staticRenderFns:o};e.a=i},function(t,e,r){"use strict";function n(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,r){function n(o,i){try{var a=e[o](i),u=a.value}catch(t){return void r(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(e,"__esModule",{value:!0});var o=r(1),i=function(t){return t&&t.__esModule?t:{default:t}}(o);e.default={required:function(){function t(t){return e.apply(this,arguments)}var e=n(i.default.mark(function t(e){var r=e.value,n=e.error,o=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",!(r&&(!Array.isArray(r)||r.length))&&n.apply(void 0,o));case 1:case"end":return t.stop()}},t,this)}));return t}(),email:function(){function t(t){return e.apply(this,arguments)}var e=n(i.default.mark(function t(e){var r,n=e.value,o=e.error,a=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=/^(?:[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||r.test(n.toLowerCase()))&&o.apply(void 0,a));case 2:case"end":return t.stop()}},t,this)}));return t}(),confirmed:function(){function t(t,r){return e.apply(this,arguments)}var e=n(i.default.mark(function t(e,r){var n=e.field,o=e.value,a=e.error,u=e.values,s=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=r||n+"_confirmation",t.abrupt("return",!(!o||o===u[r])&&a.apply(void 0,s));case 2:case"end":return t.stop()}},t,this)}));return t}()}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={required:function(t){var e=t.label;t.value;return e+" is required"},email:function(t){var e=t.label;t.value;return e+" is invalid."},confirmed:function(t){var e=t.label;t.value;return e+" does not match the confirmation field."},default:function(t){t.label,t.value;return"This field is invalid."}}}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("vue-formulate",[],e):"object"==typeof exports?exports["vue-formulate"]=e():t["vue-formulate"]=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=9)}([function(t,e,r){"use strict";function n(){p=!1}function o(t){if(!t)return void(l!==h&&(l=h,n()));if(t!==l){if(t.length!==h.length)throw new Error("Custom alphabet for shortid must be "+h.length+" unique characters. You submitted "+t.length+" characters: "+t);var e=t.split("").filter(function(t,e,r){return e!==r.lastIndexOf(t)});if(e.length)throw new Error("Custom alphabet for shortid must be "+h.length+" unique characters. These characters were not unique: "+e.join(", "));l=t,n()}}function i(t){return o(t),l}function a(t){d.seed(t),f!==t&&(n(),f=t)}function u(){l||o(h);for(var t,e=l.split(""),r=[],n=d.nextValue();e.length>0;)n=d.nextValue(),t=Math.floor(n*e.length),r.push(e.splice(t,1)[0]);return r.join("")}function s(){return p||(p=u())}function c(t){return s()[t]}var l,f,p,d=r(27),h="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";t.exports={characters:i,seed:a,lookup:c,shuffled:s}},function(t,e,r){t.exports=r(10)},function(t,e,r){"use strict";function n(t,e){var r=t.length;if(r!==e.length)return!1;for(var n=0;n + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ +var o=r(14);t.exports=function(t){var e,r;return!1!==n(t)&&("function"==typeof(e=t.constructor)&&(r=e.prototype,!1!==n(r)&&!1!==r.hasOwnProperty("isPrototypeOf")))}},function(t,e,r){"use strict";/*! + * for-in + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ +t.exports=function(t,e,r){for(var n in t)if(!1===e.call(r,t[n],n,t))break}},function(t,e){t.exports=function(t,e,r,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;e&&(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0),r&&(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,e){return l.call(e),p(t,e)}):c.beforeCreate=p?[].concat(p,l):[l]}return{esModule:a,exports:u,options:c}}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function o(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,r){function n(o,i){try{var a=e[o](i),u=a.value}catch(t){return void r(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(e,"__esModule",{value:!0});var i=r(1),a=n(i),u=r(2),s=r(13),c=n(s);e.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{}}}},data:function(){return{parentIdentifier:"vue-formulate-wrapper-element",forceErrors:null}},computed:{m:function(){return this.module?this.module+"/":""},hasErrors:function(){return this.$store.getters[this.m+"hasErrors"][this.name]||!1},values:function(){return(0,c.default)(this.$store.getters[this.m+"formValues"][this.name]||{})},errors: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}},created:function(){this.hydrate(this.initial)},mounted:function(){this.hydrate(this.initial)},methods:{registerField:function(t,e){this.$store.commit(this.m+"setFieldMeta",{form:this.name,field:t,data:e}),this.updateFormValidation()},hydrate:function(t){for(var e in this.fields)"submit"!==e.type&&this.$store.commit(this.m+"setFieldValue",{field:e.name,value:t[e.name],form:this.name});this.updateFormValidation()},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 e.apply(this,arguments)}var e=o(a.default.mark(function t(e){var r,n=e.field,o=e.validation,i=e.label;return a.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 r=t.sent,(0,u.equals)(r||[],this.validationErrors[n]||[])||this.updateFieldValidationErrors({field:n,errors:r||[]}),t.abrupt("return",r);case 5:case"end":return t.stop()}},t,this)}));return t}(),updateFormValidation:function(){var t=this;this.fields.map(function(){var e=o(a.default.mark(function e(r){return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.validateField({field:r.name,validation:r.validation,label:r.validationLabel||r.label||r.name}));case 1:case"end":return e.stop()}},e,t)}));return function(t){return e.apply(this,arguments)}}())},submit:function(){this.hasErrors?this.forceErrors=!0:this.$emit("submit",Object.assign({},this.values))}}}},function(t,e,r){"use strict";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}Object.defineProperty(e,"__esModule",{value:!0});var o=r(2),i=r(25),a=function(t){return t&&t.__esModule?t:{default:t}}(i);e.default={props:{type:{type:[String,Boolean],default:"text"},name:{type:String,required:!0},initial:{type:[String,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{}}}},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(){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.errors[this.name]||[]},localAndValidationErrors:function(){return this.errors.concat(this.validationErrors)},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(e){return!1!==t[e]}).reduce(function(e,r){return e[r]=t[r],e},{})},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,e,r){return t.concat({value:e,label:r,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})}},created:function(){this.form.registerField(this.name,(0,o.filter)(this.$props,function(t,e){return["name","type","id","label","validation"].includes(t)})),!1!==this.initial&&this.form.hydrate(n({},this.name,this.initial))}}},function(t,e,r){"use strict";function n(t,e){for(var r,n=0,i="";!r;)i+=t(e>>4*n&15|o()),r=e1&&void 0!==arguments[1]?arguments[1]:{};t.prototype.$formulate=this,e=Object.assign(this.defaultOptions,e),e.registerComponents&&(t.component(e.tags.Formulate,d.default),t.component(e.tags.FormulateElement,m.default)),e.errors&&(this.errors=Object.assign(this.errors,e.errors)),e.rules&&(this.rules=Object.assign(this.rules,e.rules)),this.options=e}},{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 e=c(t,3),r=(e[0],e[1]),n=e[2];return Object.assign({},{rule:r},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,r,n){return e.apply(this,arguments)}var e=i(s.default.mark(function t(e,r,n){var i=e.field,a=e.value,u=e.label,c=this;return s.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",!!r&&Promise.all(this.parseRules(r).map(function(t){var e,r=t.rule,s=t.args;if("function"!=typeof c.rules[r])throw new Error("Validation rule is invalid: "+r);return(e=c.rules)[r].apply(e,[{field:i,value:a,label:u,error:c.errorFactory(r),values:n}].concat(o(s)))})).then(function(t){return t.reduce(function(t,e){return e?Array.isArray(t)?t.concat(e):[e]:t},!1)}));case 1:case"end":return t.stop()}},t,this)}));return t}()}]),t}(),w=new x;e.default=w;e.mapModels=function(t){var e={};for(var r in t)!function(r){var n=t[r].split("/"),o=c(n,2),i=o[0],a=o[1];e[r]={set:function(t){var e=w.options.vuexModule?w.options.vuexModule+"/":"";this.$store.commit(e+"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]:""}}}(r);return e}},function(t,e,r){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=r(11),o)n.regeneratorRuntime=i;else try{delete n.regeneratorRuntime}catch(t){n.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";function r(t,e,r,n){var i=e&&e.prototype instanceof o?e:o,a=Object.create(i.prototype),u=new d(n||[]);return a._invoke=c(t,r,u),a}function n(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}function o(){}function i(){}function a(){}function u(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function s(t){function e(r,o,i,a){var u=n(t[r],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){e("next",t,i,a)},function(t){e("throw",t,i,a)}):Promise.resolve(c).then(function(t){s.value=t,i(s)},a)}a(u.arg)}function r(t,r){function n(){return new Promise(function(n,o){e(t,r,n,o)})}return o=o?o.then(n,n):n()}var o;this._invoke=r}function c(t,e,r){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(r.method=i,r.arg=a;;){var u=r.delegate;if(u){var s=l(u,r);if(s){if(s===F)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===O)throw o=k,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=S;var c=n(t,e,r);if("normal"===c.type){if(o=r.done?k:A,c.arg===F)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(o=k,r.method="throw",r.arg=c.arg)}}}function l(t,e){var r=t.iterator[e.method];if(r===v){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=v,l(t,e),"throw"===e.method))return F;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return F}var o=n(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,F;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=v),e.delegate=null,F):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,F)}function f(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function p(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function d(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(f,this),this.reset(!0)}function h(t){if(t){var e=t[x];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=b.call(o,"catchLoc"),u=b.call(o,"finallyLoc");if(a&&u){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&b.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),p(r),F}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;p(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:h(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=v),F}}}(function(){return this}()||Function("return this")())},function(t,e,r){"use strict";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}Object.defineProperty(e,"__esModule",{value:!0}),e.formulateModule=e.formulateMutations=e.formulateActions=e.formulateGetters=e.formulateState=void 0;var o=r(2),i=e.formulateState=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(){return Object.assign({values:{},errors:{},validationErrors:{},meta:{}},t)}},a=e.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,e,r){return t[e]=(0,o.reduce)(r,function(t,e,r){return t.concat(r)},[]),t},{})},hasErrors:function(t){return(0,o.map)(t.errors,function(t,e){return(0,o.reduce)(e,function(t,e,r){return t||!!r.length},!1)})}},t)},u=e.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=e.formulateMutations=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign({setFieldValue:function(t,e){var r=e.form,o=e.field,i=e.value;t.values=Object.assign({},t.values,n({},r,Object.assign({},t.values[r]||{},n({},o,i))))},setFieldErrors:function(t,e){var r=e.form,o=e.field,i=e.errors;t.errors=Object.assign({},t.errors,n({},r,Object.assign({},t.errors[r]||{},n({},o,i))))},setFieldValidationErrors:function(t,e){var r=e.form,o=e.field,i=e.errors;t.validationErrors=Object.assign({},t.validationErrors,n({},r,Object.assign({},t.validationErrors[r]||{},n({},o,i))))},setFieldMeta:function(t,e){var r=e.form,o=e.field,i=e.data;t.meta=Object.assign({},t.meta,n({},r,Object.assign({},t.meta[r]||{},n({},o,i))))}},t)};e.formulateModule=function(t){return{state:i(),getters:a(t),actions:u(t),mutations:s(),namespaced:!0}}},function(t,e,r){"use strict";function n(t,e){switch(s(t)){case"object":return o(t,e);case"array":return i(t,e);default:return u(t)}}function o(t,e){if(a(t)||!0===e&&"object"===s(t)){var r={};return c(t,function(t,r){this[r]=n(t,e)},r),r}return"function"==typeof e?e(t):t}function i(t,e){for(var r=[],o=0;o + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ +t.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},function(t,e,r){"use strict";function n(t){var e=a(t);return n.hasOwnProperty(e)?n[e](t):t}/*! + * shallow-clone + * + * Copyright (c) 2015-2017, Jon Schlinkert. + * Released under the MIT License. + */ +var o=r(16),i=r(17),a=r(19);n.array=function(t){return t.slice()},n.date=function(t){return new Date(+t)},n.object=function(t){return o(t)?i({},t):t},n.map=function(t){return new Map(t)},n.regexp=function(t){var e="";return e+=t.multiline?"m":"",e+=t.global?"g":"",e+=t.ignoreCase?"i":"",new RegExp(t.source,e)},n.set=function(t){return new Set(t)},t.exports=n},function(t,e,r){"use strict";/*! + * is-extendable + * + * Copyright (c) 2015-2017, Jon Schlinkert. + * Released under the MIT License. + */ +var n=r(3);t.exports=function(t){return n(t)||"function"==typeof t||Array.isArray(t)}},function(t,e,r){"use strict";function n(t,e){o(e)&&i(e,function(e,r){t[r]=e})}var o=r(18),i=r(4);t.exports=function(t,e){if(!o(t))throw new TypeError("expected the first argument to be an object");for(var r=arguments.length,i=0;++i + * + * Copyright (c) 2015-2017, Jon Schlinkert. + * Released under the MIT License. + */ +var n=r(3);t.exports=function(t){return n(t)||"function"==typeof t||Array.isArray(t)}},function(t,e){function r(t){return t.constructor?t.constructor.name:null}function n(t){return Array.isArray?Array.isArray(t):t instanceof Array}function o(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}function i(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}function a(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}function u(t,e){return"GeneratorFunction"===r(t)}function s(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}function c(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}function l(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}var f=Object.prototype.toString;t.exports=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var e=typeof t;if("boolean"===e)return"boolean";if("string"===e)return"string";if("number"===e)return"number";if("symbol"===e)return"symbol";if("function"===e)return u(t)?"generatorfunction":"function";if(n(t))return"array";if(l(t))return"buffer";if(c(t))return"arguments";if(i(t))return"date";if(o(t))return"error";if(a(t))return"regexp";switch(r(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(s(t))return"generator";switch(e=f.call(t)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return e.slice(8,-1).toLowerCase().replace(/\s/g,"")}},function(t,e){function r(t){return t.constructor?t.constructor.name:null}function n(t){return Array.isArray?Array.isArray(t):t instanceof Array}function o(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}function i(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}function a(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}function u(t,e){return"GeneratorFunction"===r(t)}function s(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}function c(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}function l(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}var f=Object.prototype.toString;t.exports=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var e=typeof t;if("boolean"===e)return"boolean";if("string"===e)return"string";if("number"===e)return"number";if("symbol"===e)return"symbol";if("function"===e)return u(t)?"generatorfunction":"function";if(n(t))return"array";if(l(t))return"buffer";if(c(t))return"arguments";if(i(t))return"date";if(o(t))return"error";if(a(t))return"regexp";switch(r(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(s(t))return"generator";switch(e=f.call(t)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return e.slice(8,-1).toLowerCase().replace(/\s/g,"")}},function(t,e,r){"use strict";/*! + * for-own + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ +var n=r(4),o=Object.prototype.hasOwnProperty;t.exports=function(t,e,r){n(t,function(n,i){if(o.call(t,i))return e.call(r,t[i],i,t)})}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(6),o=r.n(n);for(var i in n)"default"!==i&&function(t){r.d(e,t,function(){return n[t]})}(i);var a=r(23),u=r(5),s=u(o.a,a.a,!1,null,null,null);s.options.__file="src/components/Formulate.vue",e.default=s.exports},function(t,e,r){"use strict";var n=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{staticClass:"formulate-element",on:{submit:function(e){e.preventDefault(),t.submit(e)}}},[t._t("default")],2)},o=[];n._withStripped=!0;var i={render:n,staticRenderFns:o};e.a=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(7),o=r.n(n);for(var i in n)"default"!==i&&function(t){r.d(e,t,function(){return n[t]})}(i);var a=r(33),u=r(5),s=u(o.a,a.a,!1,null,null,null);s.options.__file="src/components/FormulateElement.vue",e.default=s.exports},function(t,e,r){"use strict";t.exports=r(26)},function(t,e,r){"use strict";function n(e){return u.seed(e),t.exports}function o(e){return f=e,t.exports}function i(t){return void 0!==t&&u.characters(t),u.shuffled()}function a(){return c(f)}var u=r(0),s=(r(8),r(29)),c=r(30),l=r(31),f=r(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,e,r){"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,e,r){"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,e,r){"use strict";function n(t){var e=o.shuffled();return{version:15&e.indexOf(t.substr(0,1)),worker:15&e.indexOf(t.substr(1,1))}}var o=r(0);t.exports=n},function(t,e,r){"use strict";function n(t){var e="",r=Math.floor(.001*(Date.now()-s));return r===i?o++:(o=0,i=r),e+=a(u.lookup,c),e+=a(u.lookup,t),o>0&&(e+=a(u.lookup,o)),e+=a(u.lookup,r)}var o,i,a=r(8),u=r(0),s=1459707606518,c=6;t.exports=n},function(t,e,r){"use strict";function n(t){if(!t||"string"!=typeof t||t.length<6)return!1;for(var e=o.characters(),r=t.length,n=0;n1)?r("label",{attrs:{for:t.id},domProps:{textContent:t._s(t.label)}}):t._e(),t._v(" "),"checkbox"===t.type&&t.isTextInput?r("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(e){t.errorBlurState=!0},change:function(e){var r=t.val,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t._i(r,null);n.checked?i<0&&(t.val=r.concat([null])):i>-1&&(t.val=r.slice(0,i).concat(r.slice(i+1)))}else t.val=o}}},"input",t.attributes,!1)):"radio"===t.type&&t.isTextInput?r("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(e){t.errorBlurState=!0},change:function(e){t.val=null}}},"input",t.attributes,!1)):t.isTextInput?r("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(e){t.errorBlurState=!0},input:function(e){e.target.composing||(t.val=e.target.value)}}},"input",t.attributes,!1)):t._e(),t._v(" "),t.isButtonInput?r("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?r("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],attrs:{name:t.name},on:{blur:function(e){t.errorBlurState=!0},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.val=e.target.multiple?r:r[0]}}},"select",t.attributes,!1),t._l(t.optionList,function(e){return r("option",{key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}})})):t._e(),t._v(" "),t.isBoxInput?r("div",{staticClass:"formulate-element-box-input-group"},[t._l(t.optionList,function(e){return["radio"===t.type?r("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],key:e.id+"-input",attrs:{type:"radio",name:t.name,id:e.id},domProps:{value:e.value,checked:t._q(t.val,e.value)},on:{blur:function(e){t.errorBlurState=!0},change:function(r){t.val=e.value}}},"input",t.attributes,!1)):t._e(),t._v(" "),"checkbox"===t.type?r("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.val,expression:"val"}],key:e.id+"-input",attrs:{type:"checkbox",name:t.name,id:e.id},domProps:{value:e.value,checked:Array.isArray(t.val)?t._i(t.val,e.value)>-1:t.val},on:{blur:function(e){t.errorBlurState=!0},change:function(r){var n=t.val,o=r.target,i=!!o.checked;if(Array.isArray(n)){var a=e.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(" "),r("label",{key:e.id+"-label",attrs:{for:e.id},domProps:{textContent:t._s(e.label)}})]})],2):t._e(),t._v(" "),t.hasCustomInput?t._t("default"):t._e(),t._v(" "),t.isUnsupportedInput?r("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?r("ul",{staticClass:"formulate-errors"},t._l(t.localAndValidationErrors,function(e){return r("li",{key:e,domProps:{textContent:t._s(e)}})})):t._e()])},o=[];n._withStripped=!0;var i={render:n,staticRenderFns:o};e.a=i},function(t,e,r){"use strict";function n(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,r){function n(o,i){try{var a=e[o](i),u=a.value}catch(t){return void r(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(e,"__esModule",{value:!0});var o=r(1),i=function(t){return t&&t.__esModule?t:{default:t}}(o);e.default={required:function(){function t(t){return e.apply(this,arguments)}var e=n(i.default.mark(function t(e){var r=e.value,n=e.error,o=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",!(r&&(!Array.isArray(r)||r.length))&&n.apply(void 0,o));case 1:case"end":return t.stop()}},t,this)}));return t}(),email:function(){function t(t){return e.apply(this,arguments)}var e=n(i.default.mark(function t(e){var r,n=e.value,o=e.error,a=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=/^(?:[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||r.test(n.toLowerCase()))&&o.apply(void 0,a));case 2:case"end":return t.stop()}},t,this)}));return t}(),confirmed:function(){function t(t,r){return e.apply(this,arguments)}var e=n(i.default.mark(function t(e,r){var n=e.field,o=e.value,a=e.error,u=e.values,s=arguments;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=r||n+"_confirmation",t.abrupt("return",!(!o||o===u[r])&&a.apply(void 0,s));case 2:case"end":return t.stop()}},t,this)}));return t}()}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={required:function(t){var e=t.label;t.value;return e+" is required"},email:function(t){var e=t.label;t.value;return e+" is invalid."},confirmed:function(t){var e=t.label;t.value;return e+" does not match the confirmation field."},default:function(t){t.label,t.value;return"This field is invalid."}}}])}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6c8b0d4..22f62ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1943,6 +1943,32 @@ "wordwrap": "0.0.2" } }, + "clone-deep": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-3.0.1.tgz", + "integrity": "sha512-kWn5hGUnIA4algk62xJIp9jxQZ8DxSPg9ktkkK1WxRGhU/0GKZBekYJHXAXaZKMpxoq/7R4eygeIl9Cf7si+bA==", + "requires": { + "for-own": "1.0.0", + "is-plain-object": "2.0.4", + "kind-of": "6.0.2", + "shallow-clone": "2.0.2" + }, + "dependencies": { + "for-own": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", + "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", + "requires": { + "for-in": "1.0.2" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + } + } + }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -3053,8 +3079,7 @@ "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" }, "for-own": { "version": "0.1.5", @@ -4587,6 +4612,21 @@ "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", "dev": true }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "requires": { + "isobject": "3.0.1" + }, + "dependencies": { + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" + } + } + }, "is-posix-bracket": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", @@ -5163,6 +5203,25 @@ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, + "mixin-object": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mixin-object/-/mixin-object-3.0.0.tgz", + "integrity": "sha512-RsUqTd3DyF9+UPqhLzJIWwGm4ZGIPYOu6WcQhQuBqqVBGhc6LOC8LrFk9KD7PvVwmqri45IJT88WLrNNrMWjxg==", + "requires": { + "for-in": "1.0.2", + "is-extendable": "1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "requires": { + "is-plain-object": "2.0.4" + } + } + } + }, "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", @@ -6303,6 +6362,31 @@ "safe-buffer": "5.1.1" } }, + "shallow-clone": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-2.0.2.tgz", + "integrity": "sha512-2o81AG/RpLTAG/ZXQekPtH/6yTffzKlJ+i6UhtVTtnP6zWQaNo9vt6LI28bhZLSesB12VQSfJYtXopTogVBveg==", + "requires": { + "is-extendable": "1.0.1", + "kind-of": "6.0.2", + "mixin-object": "3.0.0" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "requires": { + "is-plain-object": "2.0.4" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + } + } + }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", diff --git a/package.json b/package.json index 59936aa..07240b7 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ ] }, "dependencies": { + "clone-deep": "^3.0.1", "shortid": "^2.2.8" } } diff --git a/src/components/Formulate.vue b/src/components/Formulate.vue index 7e15946..2713f48 100644 --- a/src/components/Formulate.vue +++ b/src/components/Formulate.vue @@ -9,6 +9,7 @@