UNPKG

element-gui

Version:

A Component Library for Vue.js.

1 lines 6 kB
module.exports=function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=111)}({0:function(e,t,n){"use strict";function i(e,t,n,i,r,o,l,a){var s,d="function"==typeof e?e.options:e;if(t&&(d.render=t,d.staticRenderFns=n,d._compiled=!0),i&&(d.functional=!0),o&&(d._scopeId="data-v-"+o),l?(s=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(l)},d._ssrRegister=s):r&&(s=a?function(){r.call(this,(d.functional?this.parent:this).$root.$options.shadowRoot)}:r),s)if(d.functional){d._injectStyles=s;var u=d.render;d.render=function(e,t){return s.call(t),u(e,t)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,s):[s]}return{exports:e,options:d}}n.d(t,"a",(function(){return i}))},111:function(e,t,n){"use strict";n.r(t);var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("form",{staticClass:"el-form",class:[e.labelPosition?"el-form--label-"+e.labelPosition:"",{"el-form--inline":e.inline},{"is-symbol":e.symbol}]},[e.grid?[n("el-row",{attrs:{gutter:e.gutter}},[e._t("default")],2)]:[e._t("default")]],2)};i._withStripped=!0;var r=n(14),o=n.n(r),l=n(50),a=n.n(l),s=n(2),d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},u={name:"ElForm",componentName:"ElForm",components:{ElRow:a.a},provide:function(){return{elForm:this,labelWidthArr:this.potentialLabelWidthArr,gridStatus:this.gridObj}},props:{model:Object,rules:Object,labelPosition:String,labelWidth:String,labelMaxWidth:String,labelSuffix:{type:String,default:""},labelEllipsis:{type:Boolean,default:!1},inline:Boolean,symbol:{type:Boolean,default:!0},grid:{type:Boolean,default:!1},gutter:{type:Number,default:20},inlineMessage:Boolean,statusIcon:Boolean,showMessage:{type:Boolean,default:!0},size:String,disabled:Boolean,validateOnRuleChange:{type:Boolean,default:!0},hideRequiredAsterisk:{type:Boolean,default:!1},scrollToError:{type:Boolean,default:!1},scrollIntoViewOptions:Object},watch:{rules:function(){this.fields.forEach((function(e){e.removeValidateEvents(),e.addValidateEvents()})),this.validateOnRuleChange&&this.validate((function(){}))},grid:{handler:function(e){this.gridObj.status=e},immediate:!0,deep:!0}},computed:{autoLabelWidth:function(){if(!this.potentialLabelWidthArr.length)return 0;var e=void 0;e=this.labelMaxWidth&&Math.max.apply(Math,this.potentialLabelWidthArr)>=parseInt(this.labelMaxWidth,10)?parseInt(this.labelMaxWidth,10):Math.max.apply(Math,this.potentialLabelWidthArr);var t=Object(s.isIE)()?5:0;return e?e+t+"px":""}},data:function(){return{fields:[],potentialLabelWidthArr:[],gridObj:{status:null}}},created:function(){var e=this;this.$on("el.form.addField",(function(t){t&&e.fields.push(t)})),this.$on("el.form.removeField",(function(t){t.prop&&e.fields.splice(e.fields.indexOf(t),1)}))},methods:{resetFields:function(){this.model?this.fields.forEach((function(e){e.resetField()})):console.warn("[Element Warn][Form]model is required for resetFields to work.")},clearValidate:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=e.length?"string"==typeof e?this.fields.filter((function(t){return e===t.prop})):this.fields.filter((function(t){return e.indexOf(t.prop)>-1})):this.fields;t.forEach((function(e){e.clearValidate()}))},validate:function(e){var t=this;if(this.model){var n=void 0,i=[];"function"!=typeof e&&window.Promise&&(n=new window.Promise((function(t,n){e=function(e,i){e?t(e):n(i)}})));var r=!0,l=0;0===this.fields.length&&e&&e(!0);var a={};if(this.fields.forEach((function(n){n.validate("",(function(n,s){n&&(r=!1,t.scrollToError&&i.push("__"+Object.keys(s)[0])),a=o()({},a,s),"function"==typeof e&&++l===t.fields.length&&e(r,a)}))})),this.scrollToError){var s=document.getElementById(i[0]);s&&s.scrollIntoView(d({behavior:"smooth",block:"start"},this.scrollIntoViewOptions))}return n||void 0}console.warn("[Element Warn][Form]model is required for validate to work!")},validateField:function(e,t){e=[].concat(e);var n=this.fields.filter((function(t){return-1!==e.indexOf(t.prop)}));n.length?n.forEach((function(e){e.validate("",t)})):console.warn("[Element Warn]please pass correct props!")},scrollToField:function(e){document.getElementById("__"+e).scrollIntoView(this.scrollIntoViewOptions)},getLabelWidthIndex:function(e){return this.potentialLabelWidthArr.indexOf(e)},registerLabelWidth:function(e,t){if(e&&t){var n=this.getLabelWidthIndex(t);n>-1&&this.potentialLabelWidthArr.splice(n,1,e)}else e&&this.potentialLabelWidthArr.push(e)},deregisterLabelWidth:function(e){var t=this.getLabelWidthIndex(e);t>-1&&this.potentialLabelWidthArr.splice(t,1)}}},f=n(0),c=Object(f.a)(u,i,[],!1,null,null,null).exports;c.install=function(e){e.component(c.name,c)};t.default=c},14:function(e,t){e.exports=require("element-gui/lib/utils/merge")},2:function(e,t){e.exports=require("element-gui/lib/utils/util")},50:function(e,t){e.exports=require("element-gui/lib/row")}});