2020-03-02 06:29:54 +03:00
|
|
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("is-url"),require("nanoid/non-secure"),require("is-plain-object")):"function"==typeof define&&define.amd?define(["is-url","nanoid/non-secure","is-plain-object"],e):(t=t||self).Formulate=e(t.isUrl,t.nanoid,t.isPlainObject)}(this,(function(t,e,n){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n;var o={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},r=function(t,e,n){this.input=t,this.fileList=t.files,this.files=[],this.options=n,this.addFileList(this.fileList),this.context=e,this.results=!1};function i(t,e){var n={};for(var o in t)n[o]=e(o,t[o]);return n}function a(t,e){if(t===e)return!0;if(!t||!e)return!1;var n=Object.keys(t),o=Object.keys(e),r=n.length;if(o.length!==r)return!1;for(var i=0;i<r;i++){var a=n[i];if(t[a]!==e[a])return!1}return!0}function s(t){return t?"string"==typeof t?[t]:Array.isArray(t)?t:"object"==typeof t?Object.values(t):[]:[]}function l(t){return"string"==typeof t?t[0].toUpperCase()+t.substr(1):t}function u(t,e){return"string"==typeof t?u(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){if("string"==typeof(t=t.map((function(t){return t})))[0]&&e.hasOwnProperty(t[0]))return[e[t.shift()],t];if("function"==typeof t[0])return[t.shift(),t]}if("string"==typeof t){var n=t.split(":"),o=n.shift();if(e.hasOwnProperty(o))return[e[o],n.length?n.join(":").split(","):[]];throw new Error("Unknown validation rule "+t)}return!1}(t,e)})).filter((function(t){return!!t})):[]}function c(t){switch(typeof t){case"symbol":case"number":case"string":case"boolean":case"undefined":return!0;default:return null===t}}r.prototype.addFileList=function(t){for(var n=this,o=function(o){var r=t[o],i=e();n.files.push({progress:!1,error:!1,complete:!1,justFinished:!1,name:r.name||"file-upload",file:r,uuid:i,path:!1,removeFile:function(){this.removeFile(i)}.bind(n),previewData:!1})},r=0;r<t.length;r++)o(r)},r.prototype.hasUploader=function(){return!!this.context.uploader},r.prototype.uploaderIsAxios=function(){return!(!this.hasUploader||"function"!=typeof this.hasUploader.request||"function"!=typeof this.hasUploader.get||"function"!=typeof this.hasUploader.delete||"function"!=typeof this.hasUploader.post)},r.prototype.getUploader=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];if(this.uploaderIsAxios()){var o=new FormData;return o.append(this.context.name||"file",e[0]),this.uploader.post(this.context.uploadUrl,o,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress
|