1
0
mirror of synced 2025-02-16 20:53:13 +03:00
vue-formulario/dist/formulate.min.js

16 lines
48 KiB
JavaScript
Raw Normal View History

2020-05-18 16:58:56 +03:00
var VueFormulate=function(){"use strict";var t=function(t,e){return{classification:t,component:"FormulateInput"+(e||t[0].toUpperCase()+t.substr(1))}},e=Object.assign({},["text","email","number","color","date","hidden","month","password","search","tel","time","url","week","datetime-local"].reduce((function(e,r){var i;return Object.assign({},e,((i={})[r]=t("text"),i))}),{}),{range:t("slider"),textarea:t("textarea","TextArea"),checkbox:t("box"),radio:t("box"),submit:t("button"),button:t("button"),select:t("select"),file:t("file"),image:t("file"),group:t("group")}),r=function(t){if("string"!=typeof t)return!1;var e=t.match(i);if(!e)return!1;var r=e[1];if(!r)return!1;if(o.test(r)||n.test(r))return!0;return!1},i=/^(?:\w+:)?\/\/(\S+)$/,o=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,n=/^[^\s\.]+\.\S{2,}$/;for(var s="-_",a=36;a--;)s+=a.toString(36);for(a=36;a---10;)s+=a.toString(36).toUpperCase();var u=function(t){var e="";for(a=t||21;a--;)e+=s[64*Math.random()|0];return e},l=function(t,e,r){void 0===r&&(r={}),this.input=t,this.fileList=t.files,this.files=[],this.options=Object.assign({},{mimes:{}},r),this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function c(t,e){var r={};for(var i in t)r[i]=e(i,t[i]);return r}function h(t,e){if(t===e)return!0;if(!t||!e)return!1;var r=Object.keys(t),i=Object.keys(e),o=r.length;if(i.length!==o)return!1;for(var n=0;n<o;n++){var s=r[n];if(t[s]!==e[s])return!1}return!0}function d(t){return"string"==typeof t?t.replace(/([_][a-z0-9])/gi,(function(e){return 0!==t.indexOf(e)&&"_"!==t[t.indexOf(e)-1]?e.toUpperCase().replace("_",""):e})):t}function f(t){return t?"string"==typeof t?[t]:Array.isArray(t)?t:"object"==typeof t?Object.values(t):[]:[]}function p(t,e){return"string"==typeof t?p(t.split("|"),e):Array.isArray(t)?t.map((function(t){return function(t,e){if("function"==typeof t)return[t,[]];if(Array.isArray(t)&&t.length){var r=m((t=t.map((function(t){return t}))).shift()),i=r[0],o=r[1];if("string"==typeof i&&e.hasOwnProperty(i))return[e[i],t,i,o];if("function"==typeof i)return[i,t,i,o]}if("string"==typeof t){var n=t.split(":"),s=m(n.shift()),a=s[0],u=s[1];if(e.hasOwnProperty(a))return[e[a],n.length?n.join(":").split(","):[],a,u];throw new Error("Unknown validation rule "+t)}return!1}(t,e)})).filter((function(t){return!!t})):[]}function m(t){return/^[\^]/.test(t.charAt(0))?[d(t.substr(1)),t.charAt(0)]:[d(t),null]}function v(t){switch(typeof t){case"symbol":case"number":case"string":case"boolean":case"undefined":return!0;default:return null===t}}function y(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function g(t,e){return Object.defineProperty(t,"__id",Object.assign(Object.create(null),{value:e||Symbol("uuid")}))}l.prototype.rehydrateFileList=function(t){var e=this,r=t.reduce((function(t,r){var i=r[e.options?e.options.fileUrlKey:"url"],o=!(!i||-1===i.lastIndexOf("."))&&i.substr(i.lastIndexOf(".")+1),n=e.options.mimes[o]||!1;return t.push(Object.assign({},r,i?{name:i.substr(i.lastIndexOf("/")+1||0),type:r.type?r.type:n,previewData:i}:{})),t}),[]);this.results=t,this.addFileList(r)},l.prototype.addFileList=function(t){for(var e=this,r=function(r){var i=t[r],o=u();e.files.push({progress:!1,error:!1,complete:!1,justFinished:!1,name:i.name||"file-upload",file:i,uuid:o,path:!1,removeFile:function(){this.removeFile(o)}.bind(e),previewData:i.previewData||!1})},i=0;i<t.length;i++)r(i)},l.prototype.hasUploader=function(){return!!this.context.uploader},l.prototype.uploaderIsAxios=function(){return!(!this.hasUploader||"function"!=typeof this.context.uploader.request||"function"!=typeof this.context.uploader.get||"function"!=typeof this.context.uploader.delete||"function"!=typeof this.context.uploader.post)},l.prototype.getUploader=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];if(this.uploaderIsAxios()){var i=new FormData;if(i.append(this.context.name||"file",e[0]),!1===this.context.uploadUrl)throw new Error("No uploadURL specified: https://vueformulate.com/guide/inputs/file/#props");return this.context.uploa
/*!
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/
function w(t){return!0==(null!=(e=t)&&"object"==typeof e&&!1===Array.isArray(e))&&"[object Object]"===Object.prototype.toString.call(t);
/*!
* isobject <https://github.com/jonschlinkert/isobject>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/
2020-05-18 16:58:56 +03:00
var e}function F(t){var e,r;return!1!==w(t)&&("function"==typeof(e=t.constructor)&&(!1!==w(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}function O(t){return"string"==typeof t?t[0].toUpperCase()+t.substr(1):t}var V={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?O(e)+" must be after "+r[0]+".":O(e)+" must be a later date."},alpha:function(t){return O(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return O(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?O(e)+" must be before "+r[0]+".":O(e)+" must be an earlier date."},between:function(t){var e=t.name,r=t.value,i=t.args,o=!(!Array.isArray(i)||!i[2])&&i[2];return!isNaN(r)&&"length"!==o||"value"===o?O(e)+" must be between "+i[0]+" and "+i[1]+".":O(e)+" must be between "+i[0]+" and "+i[1]+" characters long."},confirm:function(t){var e=t.name;return t.args,O(e)+" does not match."},date:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?O(e)+" is not a valid, please use the format "+r[0]:O(e)+" is not a valid date."},default:function(t){return t.name,"This field isnt valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},endsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesnt end with a valid value.":"This field doesnt end with a valid value."},in:function(t){var e=t.name,r=t.value;return"string"==typeof r&&r?"“"+O(r)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return O(t.name)+" is not an allowed value."},max:function(t){var e=t.name,r=t.value,i=t.args;if(Array.isArray(r))return"You may only select "+i[0]+" "+e+".";var o=!(!Array.isArray(i)||!i[1])&&i[1];return!isNaN(r)&&"length"!==o||"value"===o?O(e)+" must be less than or equal to "+i[0]+".":O(e)+" must be less than or equal to "+i[0]+" characters long."},mime:function(t){var e=t.name,r=t.args;return O(e)+" must be of the the type: "+(r[0]||"No file formats allowed.")},min:function(t){var e=t.name,r=t.value,i=t.args;if(Array.isArray(r))return"You must select at least "+i[0]+" "+e+".";var o=!(!Array.isArray(i)||!i[1])&&i[1];return!isNaN(r)&&"length"!==o||"value"===o?O(e)+" must be more than "+i[0]+".":O(e)+" must be more than "+i[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return O(t.name)+" must be a number."},required:function(t){return O(t.name)+" is required."},startsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesnt start with a valid value.":"This field doesnt start with a valid value."},url:function(t){return t.name,"Please include a valid url."}};function A(t){var e;t.extend({locales:(e={},e.en=V,e)})}function S(t,e,r,i){return new Promise((function(r,o){var n=(i.fauxUploaderDuration||2e3)*(.5+Math.random()),s=performance.now(),a=function(){return setTimeout((function(){var i=performance.now()-s,o=Math.min(100,Math.round(i/n*100));if(e(o),o>=100)return r({url:"http://via.placeholder.com/350x150.png",name:t.name});a()}),20)};a()}))}function j(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&-1===e.indexOf(i)&&(r[i]=t[i]);return r}var P={inheritAttrs:!1,functional:!0,render:function(t,e){for(var r=e.props,i=e.data,o=e.parent,n=e.children,s=o,a=(r.name,r.forceWrap),u=r.context,l=j(r,["name","forceWrap","context"]);s&&"FormulateInput"!==s.$options.name;)s=s.$parent;if(!s)return null;if(s.$scopedSlots&&s.$scopedSlots[r.name])return s.$scopedSlots[r.name](Object.assign({},u,l));if(Array.isArray(n)&&(n.length>1||a&&n.length>0)){var c=i.attrs,h=(c.name,c.context,j(c,["name","context"]));return t("div",Object.assign({},i,{attrs:h}),n)}return Array.isArray(n)&&1===n.length?n[0]:null}};function _(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&-1===e.indexOf(i)&&(r[i]=t[i]);return r}var $=function(t){this.registr