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

2 lines
54 KiB
JavaScript
Raw Normal View History

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("is-url"),require("nanoid/non-secure"),require("is-plain-object"),require("@braid/vue-formulate-i18n")):"function"==typeof define&&define.amd?define(["is-url","nanoid/non-secure","is-plain-object","@braid/vue-formulate-i18n"],e):(t=t||self).Formulate=e(t.isUrl,t.nanoid,t.isPlainObject,t.VueFormulateI18n)}(this,(function(t,e,r,o){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;var n=function(t,e){return{classification:t,component:"FormulateInput"+(e||t[0].toUpperCase()+t.substr(1))}},s=Object.assign({},["text","email","number","color","date","hidden","month","password","search","tel","time","url","week","datetime-local"].reduce((function(t,e){var r;return Object.assign({},t,((r={})[e]=n("text"),r))}),{}),{range:n("slider"),textarea:n("textarea","TextArea"),checkbox:n("box"),radio:n("box"),submit:n("button"),button:n("button"),select:n("select"),file:n("file"),image:n("file"),group:n("group")}),a=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 l(t,e){var r={};for(var o in t)r[o]=e(o,t[o]);return r}function u(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 c(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 d(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=c((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(":"),i=c(o.shift());if(e.hasOwnProperty(i))return[e[i],o.length?o.join(":").split(","):[],i];throw new Error("Unknown validation rule "+t)}return!1}(t,e)})).filter((function(t){return!!t})):[]}function f(t){switch(typeof t){case"symbol":case"number":case"string":case"boolean":case"undefined":return!0;default:return null===t}}function h(t,e){return Object.prototype.hasOwnProperty.call(t,e)}a.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)},a.prototype.addFileList=function(t){for(var r=this,o=function(o){var i=t[o],n=e();r.files.push({progress:!1,error:!1,complete:!1,justFinished:!1,name:i.name||"file-upload",file:i,uuid:n,path:!1,removeFile:function(){this.removeFile(n)}.bind(r),previewData:i.previewData||!1})},i=0;i<t.length;i++)o(i)},a.prototype.hasUploader=function(){return!!this.context.uploader},a.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)},a.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:{"