1
0
mirror of synced 2024-11-22 21:36:04 +03:00
vue-formulario/dist/formulate.min.js

16 lines
60 KiB
JavaScript
Raw Normal View History

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 o;return Object.assign({},e,((o={})[r]=t("text"),o))}),{}),{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(o);if(!e)return!1;var r=e[1];if(!r)return!1;if(i.test(r)||n.test(r))return!0;return!1},o=/^(?:\w+:)?\/\/(\S+)$/,i=/^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 l=function(t){var e="";for(a=t||21;a--;)e+=s[64*Math.random()|0];return e},u=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 o in t)r[o]=e(o,t[o]);return r}function d(t,e){if(t===e)return!0;if(!t||!e)return!1;var r=Object.keys(t),o=Object.keys(e),i=r.length;if(o.length!==i)return!1;for(var n=0;n<i;n++){var s=r[n];if(t[s]!==e[s])return!1}return!0}function p(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 h(t){return t?"string"==typeof t?[t]:Array.isArray(t)?t:"object"==typeof t?Object.values(t):[]:[]}function f(t,e){return"string"==typeof t?f(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()),o=r[0],i=r[1];if("string"==typeof o&&e.hasOwnProperty(o))return[e[o],t,o,i];if("function"==typeof o)return[o,t,o,i]}if("string"==typeof t){var n=t.split(":"),s=m(n.shift()),a=s[0],l=s[1];if(e.hasOwnProperty(a))return[e[a],n.length?n.join(":").split(","):[],a,l];throw new Error("Unknown validation rule "+t)}return!1}(t,e)})).filter((function(t){return!!t})):[]}function m(t){return/^[\^]/.test(t.charAt(0))?[p(t.substr(1)),t.charAt(0)]:[p(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)}u.prototype.rehydrateFileList=function(t){var e=this,r=t.reduce((function(t,r){var o=r[e.options?e.options.fileUrlKey:"url"],i=!(!o||-1===o.lastIndexOf("."))&&o.substr(o.lastIndexOf(".")+1),n=e.options.mimes[i]||!1;return t.push(Object.assign({},r,o?{name:o.substr(o.lastIndexOf("/")+1||0),type:r.type?r.type:n,previewData:o}:{})),t}),[]);this.results=t,this.addFileList(r)},u.prototype.addFileList=function(t){for(var e=this,r=function(r){var o=t[r],i=l();e.files.push({progress:!1,error:!1,complete:!1,justFinished:!1,name:o.name||"file-upload",file:o,uuid:i,path:!1,removeFile:function(){this.removeFile(i)}.bind(e),previewData:o.previewData||!1})},o=0;o<t.length;o++)r(o)},u.prototype.hasUploader=function(){return!!this.context.uploader},u.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)},u.prototype.getUploader=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];if(this.uploaderIsAxios()){var o=new FormData;if(o.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.uploader.post(this.context.uploadUrl,o,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:function(t){e[1](
/*!
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/
2020-05-15 21:08:58 +03:00
function E(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.
*/
var e}function w(t){var e,r;return!1!==E(t)&&("function"==typeof(e=t.constructor)&&(!1!==E(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}function _(t){return"string"==typeof t?t[0].toUpperCase()+t.substr(1):t}var F={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?_(e)+" must be after "+r[0]+".":_(e)+" must be a later date."},alpha:function(t){return _(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return _(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?_(e)+" must be before "+r[0]+".":_(e)+" must be an earlier date."},between:function(t){var e=t.name,r=t.value,o=t.args,i=!(!Array.isArray(o)||!o[2])&&o[2];return!isNaN(r)&&"length"!==i||"value"===i?_(e)+" must be between "+o[0]+" and "+o[1]+".":_(e)+" must be between "+o[0]+" and "+o[1]+" characters long."},confirm:function(t){var e=t.name;return t.args,_(e)+" does not match."},date:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?_(e)+" is not a valid date, please use the format "+r[0]:_(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?"“"+_(r)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return _(t.name)+" is not an allowed value."},max:function(t){var e=t.name,r=t.value,o=t.args;if(Array.isArray(r))return"You may only select "+o[0]+" "+e+".";var i=!(!Array.isArray(o)||!o[1])&&o[1];return!isNaN(r)&&"length"!==i||"value"===i?_(e)+" must be less than or equal to "+o[0]+".":_(e)+" must be less than or equal to "+o[0]+" characters long."},mime:function(t){var e=t.name,r=t.args;return _(e)+" must be of the the type: "+(r[0]||"No file formats allowed.")},min:function(t){var e=t.name,r=t.value,o=t.args;if(Array.isArray(r))return"You need at least "+o[0]+" "+e+".";var i=!(!Array.isArray(o)||!o[1])&&o[1];return!isNaN(r)&&"length"!==i||"value"===i?_(e)+" must be more than "+o[0]+".":_(e)+" must be more than "+o[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return _(t.name)+" must be a number."},required:function(t){return _(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 O(t){var e;t.extend({locales:(e={},e.en=F,e)})}function V(t,e,r,o){return new Promise((function(r,i){var n=(o.fauxUploaderDuration||2e3)*(.5+Math.random()),s=performance.now(),a=function(){return setTimeout((function(){var o=performance.now()-s,i=Math.min(100,Math.round(o/n*100));if(e(i),i>=100)return r({url:"http://via.placeholder.com/350x150.png",name:t.name});a()}),20)};a()}))}function A(t,e){var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&-1===e.indexOf(o)&&(r[o]=t[o]);return r}var P={inheritAttrs:!1,functional:!0,render:function(t,e){for(var r=e.props,o=e.data,i=e.parent,n=e.children,s=i,a=(r.name,r.forceWrap),l=r.context,u=A(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({},l,u));if(Array.isArray(n)&&(n.length>1||a&&n.length>0)){var c=o.attrs,d=(c.name,c.context,A(c,["name","context"]));return t("div",Object.assign({},o,{attrs:d}),n)}return Array.isArray(n)&&1===n.length?n[0]:null}};function S(t,e){var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&-1===e.indexOf(o)&&(r[o]=t[o]);return r}var $=function(t){this.registry=