element-gui
Version:
A Component Library for Vue.js.
1 lines • 7.83 kB
JavaScript
module.exports=function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/dist/",i(i.s=105)}({0:function(e,t,i){"use strict";function n(e,t,i,n,o,a,s,r){var c,l="function"==typeof e?e.options:e;if(t&&(l.render=t,l.staticRenderFns=i,l._compiled=!0),n&&(l.functional=!0),a&&(l._scopeId="data-v-"+a),s?(c=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__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},l._ssrRegister=c):o&&(c=r?function(){o.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:o),c)if(l.functional){l._injectStyles=c;var u=l.render;l.render=function(e,t){return c.call(t),u(e,t)}}else{var d=l.beforeCreate;l.beforeCreate=d?[].concat(d,c):[c]}return{exports:e,options:l}}i.d(t,"a",(function(){return n}))},105:function(e,t,i){"use strict";i.r(t);var n=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"el-switch",class:[e.switchSize?"el-switch--"+e.switchSize:"",{"is-disabled":e.switchDisabled,"is-checked":e.checked}],attrs:{role:"switch","aria-checked":e.checked,"aria-disabled":e.switchDisabled},on:{click:function(t){return t.preventDefault(),e.switchValue(t)}}},[i("input",{ref:"input",staticClass:"el-switch__input",attrs:{type:"checkbox",id:e.id,tabindex:e.tabindex,name:e._elFormItemName,"true-value":e.activeValue,"false-value":e.inactiveValue,disabled:e.switchDisabled},on:{change:e.handleChange,keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.switchValue(t)}}}),i("span",{ref:"core",staticClass:"el-switch__core",style:{width:e.formateWidth}},[e.loading?i("i",{class:["el-icon-loading is-loading"]}):e._e(),e.activeIconClass||e.activeText?i("span",{class:["el-switch__label",e.checked?"is-active":""]},[e.activeIconClass&&e.checked?i("i",{class:[e.activeIconClass]}):e._e(),e.inactiveIconClass&&!e.checked?i("i",{class:[e.inactiveIconClass]}):e._e(),i("span",{directives:[{name:"show",rawName:"v-show",value:!e.activeIconClass&&e.activeText&&e.checked,expression:"!activeIconClass && activeText && checked"}],staticClass:"el-switch__label--left",style:{color:this.activeTextColor},attrs:{"aria-hidden":!e.checked}},[i("em",{directives:[{name:"ellipsis",rawName:"v-ellipsis"}]},[e._v(e._s(e.activeText))])]),i("span",{directives:[{name:"show",rawName:"v-show",value:!e.inactiveIconClass&&e.inactiveText&&!e.checked,expression:"!inactiveIconClass && inactiveText && !checked"}],staticClass:"el-switch__label--right",style:{color:this.inactiveTextColor},attrs:{"aria-hidden":e.checked}},[i("em",{directives:[{name:"ellipsis",rawName:"v-ellipsis"}]},[e._v(e._s(e.inactiveText))])])]):e._e()])])};n._withStripped=!0;var o=i(4),a=i.n(o),s=i(26),r=i.n(s),c=i(13),l=i.n(c),u=i(9),d=i(16),h={name:"ElSwitch",mixins:[r()("input"),l.a,a.a],directives:{ellipsis:u.a},inject:{elForm:{default:""},elFormItem:{default:""}},props:{value:{type:[Boolean,String,Number],default:!1},disabled:Boolean,loading:Boolean,activeIconClass:{type:String,default:""},inactiveIconClass:{type:String,default:""},size:{type:String,default:""},width:{type:String,default:""},activeText:String,inactiveText:String,activeColor:{type:String,default:""},activeTextColor:{type:String,default:""},inactiveColor:{type:String,default:""},inactiveTextColor:{type:String,default:""},activeValue:{type:[Boolean,String,Number],default:!0},inactiveValue:{type:[Boolean,String,Number],default:!1},name:String,validateEvent:{type:Boolean,default:!0},id:String,tabindex:[String,Number],beforeChange:[Boolean,Function]},data:function(){return{}},created:function(){~[this.activeValue,this.inactiveValue].indexOf(this.value)||this.$emit("input",this.inactiveValue)},computed:{_elFormItemName:function(){return this.elFormItem.prop?this.elFormItem.prop:this.name},_elFormItemSize:function(){return(this.elFormItem||{}).elFormItemSize},switchSize:function(){return this.size||this._elFormItemSize||(this.$ELEMENT||{}).size},formateWidth:function(){return/(%|px)/.test(this.width)?this.width:this.width+"px"},checked:function(){return this.value===this.activeValue},switchDisabled:function(){return this.disabled||this.loading||(this.elForm||{}).disabled}},watch:{checked:function(){this.$refs.input.checked=this.checked,(this.activeColor||this.inactiveColor)&&this.setBackgroundColor(),this.validateEvent&&this.dispatch("ElFormItem","el.form.change",[this.value])},activeColor:function(){(this.activeColor||this.inactiveColor)&&this.setBackgroundColor()},inactiveColor:function(){(this.activeColor||this.inactiveColor)&&this.setBackgroundColor()}},methods:{handleChange:function(e){var t=this,i=this.checked?this.inactiveValue:this.activeValue;this.$emit("input",i),this.$emit("change",i),this.$nextTick((function(){t.$refs.input&&(t.$refs.input.checked=t.checked)}))},setBackgroundColor:function(){var e=this.checked?this.activeColor:this.inactiveColor;this.$refs.core.style.borderColor=e,this.$refs.core.style.backgroundColor=e},switchValue:function(){var e=this;if(!this.switchDisabled)if(this.beforeChange){var t=this.beforeChange();[Object(d.isPromise)(t),Object(d.isBoolean)(t)].includes(!0)||console.warn("[Element Warn][Switch] beforeChange must return type `Promise<boolean>` or `boolean`"),Object(d.isPromise)(t)?t.then((function(t){t&&e.handleChange()})).catch((function(e){console.warn("[Element Warn][Switch] some error occurred: "+e)})):t&&this.handleChange()}else this.handleChange()},getMigratingConfig:function(){return{props:{"on-color":"on-color is renamed to active-color.","off-color":"off-color is renamed to inactive-color.","on-text":"on-text is renamed to active-text.","off-text":"off-text is renamed to inactive-text.","on-value":"on-value is renamed to active-value.","off-value":"off-value is renamed to inactive-value.","on-icon-class":"on-icon-class is renamed to active-icon-class.","off-icon-class":"off-icon-class is renamed to inactive-icon-class."}}}},mounted:function(){(this.activeColor||this.inactiveColor)&&this.setBackgroundColor(),this.$refs.input.checked=this.checked}},f=i(0),v=Object(f.a)(h,n,[],!1,null,null,null).exports;v.install=function(e){e.component(v.name,v)};t.default=v},13:function(e,t){e.exports=require("element-gui/lib/mixins/migrating")},16:function(e,t){e.exports=require("element-gui/lib/utils/types")},2:function(e,t){e.exports=require("element-gui/lib/utils/util")},26:function(e,t){e.exports=require("element-gui/lib/mixins/focus")},4:function(e,t){e.exports=require("element-gui/lib/mixins/emitter")},9:function(e,t,i){"use strict";var n=i(2);t.a={inserted:function(e,t){e.onmouseover=function(){var t=e.offsetWidth;Object(n.isIE)()&&(e.parentNode.style.textOverflow="clip",t=e.offsetWidth,e.parentNode.style.textOverflow="ellipsis"),e.parentNode.offsetWidth<t&&(e.title=e.innerHTML.replace(/<[^>]*>/g,""))},e.onmouseout=function(){e.title&&e.removeAttribute("title")}}}}});