1
0
mirror of synced 2024-11-23 13:56:04 +03:00
vue-formulario/dist/formulate.min.js

16 lines
57 KiB
JavaScript
Raw Normal View History

2020-05-09 06:55:43 +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 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(n.test(r)||i.test(r))return!0;return!1},o=/^(?:\w+:)?\/\/(\S+)$/,n=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,i=/^[^\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),n=r.length;if(o.length!==n)return!1;for(var i=0;i<n;i++){var s=r[i];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 f(t){return t?"string"==typeof t?[t]:Array.isArray(t)?t:"object"==typeof t?Object.values(t):[]:[]}function h(t,e){return"string"==typeof t?h(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=p((t=t.map((function(t){return t}))).shift());if("string"==typeof r&&e.hasOwnProperty(r))return[e[r],t,r];if("function"==typeof r)return[r,t,r]}if("string"==typeof t){var o=t.split(":"),n=p(o.shift());if(e.hasOwnProperty(n))return[e[n],o.length?o.join(":").split(","):[],n];throw new Error("Unknown validation rule "+t)}return!1}(t,e)})).filter((function(t){return!!t})):[]}function m(t){switch(typeof t){case"symbol":case"number":case"string":case"boolean":case"undefined":return!0;default:return null===t}}function v(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"],n=!(!o||-1===o.lastIndexOf("."))&&o.substr(o.lastIndexOf(".")+1),i=e.options.mimes[n]||!1;return t.push(Object.assign({},r,o?{name:o.substr(o.lastIndexOf("/")+1||0),type:r.type?r.type:i,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],n=l();e.files.push({progress:!1,error:!1,complete:!1,justFinished:!1,name:o.name||"file-upload",file:o,uuid:n,path:!1,removeFile:function(){this.removeFile(n)}.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](Math.round(100*t.loaded/t.total))}}).then((function(t){return t.data})).catch((function(t){return e[2](t)}))}return(t=thi
/*!
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/
2020-05-09 06:55:43 +03:00
function x(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 E(t){var e,r;return!1!==x(t)&&("function"==typeof(e=t.constructor)&&(!1!==x(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}function w(t){return"string"==typeof t?t[0].toUpperCase()+t.substr(1):t}var _={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?w(e)+" must be after "+r[0]+".":w(e)+" must be a later date."},alpha:function(t){return w(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return w(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?w(e)+" must be before "+r[0]+".":w(e)+" must be an earlier date."},between:function(t){var e=t.name,r=t.value,o=t.args,n=!(!Array.isArray(o)||!o[2])&&o[2];return!isNaN(r)&&"length"!==n||"value"===n?w(e)+" must be between "+o[0]+" and "+o[1]+".":w(e)+" must be between "+o[0]+" and "+o[1]+" characters long."},confirm:function(t){var e=t.name;return t.args,w(e)+" does not match."},date:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?w(e)+" is not a valid, please use the format "+r[0]:w(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?"“"+w(r)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return w(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 n=!(!Array.isArray(o)||!o[1])&&o[1];return!isNaN(r)&&"length"!==n||"value"===n?w(e)+" must be less than or equal to "+o[0]+".":w(e)+" must be less than or equal to "+o[0]+" characters long."},mime:function(t){var e=t.name,r=t.args;return w(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 must select at least "+o[0]+" "+e+".";var n=!(!Array.isArray(o)||!o[1])&&o[1];return!isNaN(r)&&"length"!==n||"value"===n?w(e)+" must be more than "+o[0]+".":w(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 w(t.name)+" must be a number."},required:function(t){return w(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 F(t){var e;t.extend({locales:(e={},e.en=_,e)})}function V(t,e,r,o){return new Promise((function(r,n){var i=(o.fauxUploaderDuration||2e3)*(.5+Math.random()),s=performance.now(),a=function(){return setTimeout((function(){var o=performance.now()-s,n=Math.min(100,Math.round(o/i*100));if(e(n),n>=100)return r({url:"http://via.placeholder.com/350x150.png",name:t.name});a()}),20)};a()}))}function O(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 A={inheritAttrs:!1,functional:!0,render:function(t,e){for(var r=e.props,o=e.data,n=e.parent,i=e.children,s=n,a=(r.name,r.forceWrap),l=r.context,u=O(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(i)&&(i.length>1||a&&i.length>0)){var c=o.attrs,d=(c.name,c.context,O(c,["name","context"]));return t("div",Object.assign({},o,{attrs:d}),i)}return Array.isArray(i)&&1===i.length?i[0]:null}},P=function(t){this.registry=new Map,this.ctx=t};function S(t){return new P(t).dataProps()}function $(){return{hasInitialValue:function(){return this.form