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

16 lines
52 KiB
JavaScript
Raw Normal View History

2020-04-16 16:22:58 +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 n;return Object.assign({},e,((n={})[r]=t("text"),n))}),{}),{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(n);if(!e)return!1;var r=e[1];if(!r)return!1;if(o.test(r)||i.test(r))return!0;return!1},n=/^(?:\w+:)?\/\/(\S+)$/,o=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,i=/^[^\s\.]+\.\S{2,}$/;for(var a="-_",s=36;s--;)a+=s.toString(36);for(s=36;s---10;)a+=s.toString(36).toUpperCase();var l=function(t){var e="";for(s=t||21;s--;)e+=a[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 n in t)r[n]=e(n,t[n]);return r}function d(t,e){if(t===e)return!0;if(!t||!e)return!1;var r=Object.keys(t),n=Object.keys(e),o=r.length;if(n.length!==o)return!1;for(var i=0;i<o;i++){var a=r[i];if(t[a]!==e[a])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 n=t.split(":"),o=p(n.shift());if(e.hasOwnProperty(o))return[e[o],n.length?n.join(":").split(","):[],o];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}}u.prototype.rehydrateFileList=function(t){var e=this,r=t.reduce((function(t,r){var n=r[e.options?e.options.fileUrlKey:"url"],o=!(!n||-1===n.lastIndexOf("."))&&n.substr(n.lastIndexOf(".")+1),i=e.options.mimes[o]||!1;return t.push(Object.assign({},r,n?{name:n.substr(n.lastIndexOf("/")+1||0),type:r.type?r.type:i,previewData:n}:{})),t}),[]);this.results=t,this.addFileList(r)},u.prototype.addFileList=function(t){for(var e=this,r=function(r){var n=t[r],o=l();e.files.push({progress:!1,error:!1,complete:!1,justFinished:!1,name:n.name||"file-upload",file:n,uuid:o,path:!1,removeFile:function(){this.removeFile(o)}.bind(e),previewData:n.previewData||!1})},n=0;n<t.length;n++)r(n)},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 n=new FormData;if(n.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,n,{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=this.context).uploader.apply(t,e)},u.prototype.upload=function(){var
/*!
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/
function g(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-04-16 16:22:58 +03:00
var e}function x(t){var e,r;return!1!==g(t)&&("function"==typeof(e=t.constructor)&&(!1!==g(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}function E(t){return"string"==typeof t?t[0].toUpperCase()+t.substr(1):t}var w={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(e)+" must be after "+r[0]+".":E(e)+" must be a later date."},alpha:function(t){return E(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return E(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(e)+" must be before "+r[0]+".":E(e)+" must be an earlier date."},between:function(t){var e=t.name,r=t.value,n=t.args,o=!(!Array.isArray(n)||!n[2])&&n[2];return!isNaN(r)&&"length"!==o||"value"===o?E(e)+" must be between "+n[0]+" and "+n[1]+".":E(e)+" must be between "+n[0]+" and "+n[1]+" characters long."},confirm:function(t){var e=t.name;return t.args,E(e)+" does not match."},date:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?E(e)+" is not a valid, please use the format "+r[0]:E(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?"“"+E(r)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return E(t.name)+" is not an allowed value."},max:function(t){var e=t.name,r=t.value,n=t.args;if(Array.isArray(r))return"You may only select "+n[0]+" "+e+".";var o=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(r)&&"length"!==o||"value"===o?E(e)+" must be less than or equal to "+n[0]+".":E(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,r=t.args;return E(e)+" must be of the the type: "+(r[0]||"No file formats allowed.")},min:function(t){var e=t.name,r=t.value,n=t.args;if(Array.isArray(r))return"You must select at least "+n[0]+" "+e+".";var o=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(r)&&"length"!==o||"value"===o?E(e)+" must be more than "+n[0]+".":E(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return E(t.name)+" must be a number."},required:function(t){return E(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=w,e)})}function _(t,e,r,n){return new Promise((function(r,o){var i=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,o=Math.min(100,Math.round(n/i*100));if(e(o),o>=100)return r({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var P={inheritAttrs:!1,functional:!0,render:function(t,e){for(var r=e.props,n=e.data,o=e.parent,i=e.children,a=o;a&&"FormulateInput"!==a.$options.name;)a=a.$parent;return a.$scopedSlots&&a.$scopedSlots[r.name]?a.$scopedSlots[r.name](r):t("div",n,i)}},O={context:function(){return $.call(this,Object.assign({},{attributes:this.elementAttributes,blurHandler:A.bind(this),classification:this.classification,component:this.component,disableErrors:this.disableErrors,errors:this.explicitErrors,getValidationErrors:this.getValidationErrors.bind(this),hasLabel:this.label&&"button"!==this.classification,hasValidationErrors:this.hasValidationErrors.bind(this),help:this.help,id:this.id||this.defaultId,imageBehavior:this.imageBehavior,label:this.label,labelPosition:this.logicalLabelPosition,name:this.nameOrFallback,performValidation:this.