12 |
- (window.webpackJsonp=window.webpackJsonp||[]).push([[1,24],{710:function(t,e,n){"use strict";n.r(e);n(98),n(40),n(320),n(64),n(65),n(323),n(521),n(46),n(11);var r=n(837),o=n(657),l=n(711),marker=n(712),h={name:"ElSlider",components:{ElInputNumber:r.a,SliderButton:l.default,SliderMarker:marker.default},mixins:[o.a],inject:{elForm:{default:""}},props:{min:{type:Number,default:0},max:{type:Number,default:100},step:{type:Number,default:1},value:{type:[Number,Array,String],default:0},showInput:{type:Boolean,default:!1},showInputControls:{type:Boolean,default:!0},inputSize:{type:String,default:"small"},showStops:{type:Boolean,default:!1},showTooltip:{type:Boolean,default:!0},formatTooltip:Function,disabled:{type:Boolean,default:!1},range:{type:Boolean,default:!1},vertical:{type:Boolean,default:!1},height:{type:String},debounce:{type:Number,default:300},label:{type:String},tooltipClass:String,marks:Object},data:function(){return{firstValue:null,secondValue:null,oldValue:null,dragging:!1,sliderSize:1}},computed:{stops:function(){var t=this;if(!this.showStops||this.min>this.max)return[];if(0===this.step)return[];for(var e=(this.max-this.min)/this.step,n=100*this.step/(this.max-this.min),r=[],i=1;i<e;i++)r.push(i*n);return this.range?r.filter((function(e){return e<100*(t.minValue-t.min)/(t.max-t.min)||e>100*(t.maxValue-t.min)/(t.max-t.min)})):r.filter((function(e){return e>100*(t.firstValue-t.min)/(t.max-t.min)}))},markList:function(){var t=this;if(!this.marks)return[];var e=Object.keys(this.marks);return e.map(parseFloat).sort((function(a,b){return a-b})).filter((function(e){return e<=t.max&&e>=t.min})).map((function(n,r){return{point:n,position:100*r*(t.max-t.min)/(e.length-1)/(t.max-t.min),mark:t.marks[n]}}))},minValue:function(){return Math.min(this.firstValue,this.secondValue)},maxValue:function(){return Math.max(this.firstValue,this.secondValue)},barSize:function(){var t=this;if(this.marks){var e=Object.keys(this.marks).map(Number),n=e.findIndex((function(i){return t.firstValue<i}));if(this.range)return"".concat(100*(this.maxValue-this.minValue)/(this.max-this.min),"%");if(-1===n)return"100%";var r=(n-1)/(e.length-1)+(this.firstValue-e[n-1])/(e[n]-e[n-1])/(e.length-1);return r>1?"100%":"".concat(100*r,"%")}return this.range?"".concat(100*(this.maxValue-this.minValue)/(this.max-this.min),"%"):"".concat(100*(this.firstValue-this.min)/(this.max-this.min),"%")},barStart:function(){return this.range?"".concat(100*(this.minValue-this.min)/(this.max-this.min),"%"):"0%"},precision:function(){var t=[this.min,this.max,this.step].map((function(t){var e=(""+t).split(".")[1];return e?e.length:0}));return Math.max.apply(null,t)},runwayStyle:function(){return this.vertical?{height:this.height}:{}},barStyle:function(){return this.vertical?{height:this.barSize,bottom:this.barStart}:{width:this.barSize,left:this.barStart}},sliderDisabled:function(){return this.disabled||(this.elForm||{}).disabled}},watch:{value:function(t,e){this.dragging||Array.isArray(t)&&Array.isArray(e)&&t.every((function(t,n){return t===e[n]}))||this.setValues()},dragging:function(t){t||this.setValues()},firstValue:function(t){this.range?this.$emit("input",[this.minValue,this.maxValue]):this.$emit("input",t)},secondValue:function(){this.range&&this.$emit("input",[this.minValue,this.maxValue])},min:function(){this.setValues()},max:function(){this.setValues()}},mounted:function(){var t;this.range?(Array.isArray(this.value)?(this.firstValue=Math.max(this.min,this.value[0]),this.secondValue=Math.min(this.max,this.value[1])):(this.firstValue=this.min,this.secondValue=this.max),this.oldValue=[this.firstValue,this.secondValue],t="".concat(this.firstValue,"-").concat(this.secondValue)):("number"!=typeof this.value||isNaN(this.value)?this.firstValue=this.min:this.firstValue=Math.min(this.max,Math.max(this.min,this.value)),this.oldValue=this.firstValue,t=this.firstValue),this.$el.setAttribute("aria-valuetext",t),this.$el.setAttribute("aria-label",this.label?this.label:"slider between ".concat(this.min," and ").concat(this.max)),this.resetSize(),window.addEventListener("resize",this.resetSize)},beforeDestroy:function(){window.removeEventListener("resize",this.resetSize)},methods:{valueChanged:function(){var t=this;return this.range?![this.minValue,this.maxValue].every((function(e,n){return e===t.oldValue[n]})):this.value!==this.oldValue},setValues:function(){if(this.min>this.max)console.error("[Element Error][Slider]min should not be greater than max.");else{var t=this.value;this.range&&Array.isArray(t)?t[1]<this.min?this.$emit("input",[this.min,this.min]):t[0]>this.max?this.$emit("input",[this.max,this.max]):t[0]<this.min?this.$emit("input",[this.min,t[1]]):t[1]>this.max?this.$emit("input",[t[0],this.max]):(this.firstValue=t[0],this.secondValue=t[1],this.valueChanged()&&(this.dispatch("ElFormItem","el.form.change",[this.minValue,this.maxValue]),this.oldValue=t.slice())):this.range||"number"!=typeof t||isNaN(t)||(t<this.min?this.$emit("input",this.min):t>this.max?this.$emit("input",this.max):(this.firstValue=t,this.valueChanged()&&(this.dispatch("ElFormItem","el.form.change",t),this.oldValue=t)))}},setPosition:function(t){var button,e=this.min+t*(this.max-this.min)/100;this.range?(button=Math.abs(this.minValue-e)<Math.abs(this.maxValue-e)?this.firstValue<this.secondValue?"button1":"button2":this.firstValue>this.secondValue?"button1":"button2",this.$refs[button].setPosition(t)):this.$refs.button1.setPosition(t)},onSliderClick:function(t){if(!this.sliderDisabled&&!this.dragging){if(this.resetSize(),this.vertical){var e=this.$refs.slider.getBoundingClientRect().bottom;this.setPosition((e-t.clientY)/this.sliderSize*100)}else{var n=this.$refs.slider.getBoundingClientRect().left;this.setPosition((t.clientX-n)/this.sliderSize*100)}this.emitChange()}},onMarkClick:function(t){if("number"==typeof t&&!this.sliderDisabled&&!this.dragging){this.resetSize();var e=Object.keys(this.marks).map(Number);this.setPosition(100*t/(e.length-1)),this.emitChange()}},resetSize:function(){this.$refs.slider&&(this.sliderSize=this.$refs.slider["client".concat(this.vertical?"Height":"Width")])},emitChange:function(){var t=this;this.$nextTick((function(){t.$emit("change",t.range?[t.minValue,t.maxValue]:t.value)}))},getStopStyle:function(t){return this.vertical?{bottom:t+"%"}:{left:t+"%"}}}},c=n(22),component=Object(c.a)(h,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"el-slider",class:{"is-vertical":t.vertical,"el-slider--with-input":t.showInput},attrs:{role:"slider","aria-valuemin":t.min,"aria-valuemax":t.max,"aria-orientation":t.vertical?"vertical":"horizontal","aria-disabled":t.sliderDisabled}},[t.showInput&&!t.range?e("el-input-number",{ref:"input",staticClass:"el-slider__input",attrs:{step:t.step,disabled:t.sliderDisabled,controls:t.showInputControls,min:t.min,max:t.max,debounce:t.debounce,size:t.inputSize},on:{change:t.emitChange},model:{value:t.firstValue,callback:function(e){t.firstValue=e},expression:"firstValue"}}):t._e(),t._v(" "),e("div",{ref:"slider",staticClass:"el-slider__runway",class:{"show-input":t.showInput,disabled:t.sliderDisabled},style:t.runwayStyle,on:{click:t.onSliderClick}},[e("div",{staticClass:"el-slider__bar",style:t.barStyle}),t._v(" "),e("slider-button",{ref:"button1",attrs:{vertical:t.vertical,marks:t.marks,"tooltip-class":t.tooltipClass},model:{value:t.firstValue,callback:function(e){t.firstValue=e},expression:"firstValue"}}),t._v(" "),t.range?e("slider-button",{ref:"button2",attrs:{vertical:t.vertical,marks:t.marks,"tooltip-class":t.tooltipClass},model:{value:t.secondValue,callback:function(e){t.secondValue=e},expression:"secondValue"}}):t._e(),t._v(" "),t._l(t.stops,(function(n,r){return e("div",{directives:[{name:"show",rawName:"v-show",value:t.showStops,expression:"showStops"}],key:r,staticClass:"el-slider__stop",style:t.getStopStyle(n)})})),t._v(" "),t.markList.length>0?[e("div",t._l(t.markList,(function(n,r){return e("div",{key:r,staticClass:"el-slider__stop el-slider__marks-stop",style:t.getStopStyle(n.position),on:{click:function(e){return e.stopPropagation(),t.onMarkClick(r)}}})})),0),t._v(" "),e("div",{staticClass:"el-slider__marks"},t._l(t.markList,(function(n,r){return e("slider-marker",{key:r,style:t.getStopStyle(n.position),attrs:{mark:n.mark},on:{click:function(e){return t.onMarkClick(r)}}})})),1)]:t._e()],2)],1)}),[],!1,null,null,null);e.default=component.exports},711:function(t,e,n){"use strict";n.r(e);n(320),n(64),n(521),n(523),n(46),n(79);var r={name:"ElSliderButton",components:{},props:{value:{type:Number,default:0},vertical:{type:Boolean,default:!1},tooltipClass:String,marks:Object},data:function(){return{hovering:!1,dragging:!1,isClick:!1,startX:0,currentX:0,startY:0,currentY:0,startPosition:0,newPosition:null,oldValue:this.value}},computed:{disabled:function(){return this.$parent.sliderDisabled},max:function(){return this.$parent.max},min:function(){return this.$parent.min},step:function(){return this.$parent.step},showTooltip:function(){return this.$parent.showTooltip},precision:function(){return this.$parent.precision},currentPosition:function(){var t=this;if(this.marks){var e=Object.keys(this.marks).map(Number),n=e.findIndex((function(i){return t.value<i}));if(-1===n)return"100%";var r=(n-1)/(e.length-1)+(this.value-e[n-1])/(e[n]-e[n-1])/(e.length-1);return r>1?"100%":"".concat(100*r,"%")}return"".concat((this.value-this.min)/(this.max-this.min)*100,"%")},enableFormat:function(){return this.$parent.formatTooltip instanceof Function},formatValue:function(){return this.enableFormat&&this.$parent.formatTooltip(this.value)||this.value},wrapperStyle:function(){return this.vertical?{bottom:this.currentPosition}:{left:this.currentPosition}}},watch:{dragging:function(t){this.$parent.dragging=t}},methods:{displayTooltip:function(){this.$refs.tooltip&&(this.$refs.tooltip.showPopper=!0)},hideTooltip:function(){this.$refs.tooltip&&(this.$refs.tooltip.showPopper=!1)},handleMouseEnter:function(){this.hovering=!0,this.displayTooltip()},handleMouseLeave:function(){this.hovering=!1,this.hideTooltip()},onButtonDown:function(t){this.disabled||(t.preventDefault(),this.onDragStart(t),window.addEventListener("mousemove",this.onDragging),window.addEventListener("touchmove",this.onDragging),window.addEventListener("mouseup",this.onDragEnd),window.addEventListener("touchend",this.onDragEnd),window.addEventListener("contextmenu",this.onDragEnd))},onLeftKeyDown:function(){this.disabled||(this.newPosition=parseFloat(this.currentPosition)-this.step/(this.max-this.min)*100,this.setPosition(this.newPosition),this.$parent.emitChange())},onRightKeyDown:function(){this.disabled||(this.newPosition=parseFloat(this.currentPosition)+this.step/(this.max-this.min)*100,this.setPosition(this.newPosition),this.$parent.emitChange())},onDragStart:function(t){this.dragging=!0,this.isClick=!0,"touchstart"===t.type&&(t.clientY=t.touches[0].clientY,t.clientX=t.touches[0].clientX),this.vertical?this.startY=t.clientY:this.startX=t.clientX,this.startPosition=parseFloat(this.currentPosition),this.newPosition=this.startPosition},onDragging:function(t){if(this.dragging){this.isClick=!1,this.displayTooltip(),this.$parent.resetSize();var e=0;"touchmove"===t.type&&(t.clientY=t.touches[0].clientY,t.clientX=t.touches[0].clientX),this.vertical?(this.currentY=t.clientY,e=(this.startY-this.currentY)/this.$parent.sliderSize*100):(this.currentX=t.clientX,e=(this.currentX-this.startX)/this.$parent.sliderSize*100),this.newPosition=this.startPosition+e,this.setPosition(this.newPosition)}},onDragEnd:function(){var t=this;this.dragging&&(setTimeout((function(){t.dragging=!1,t.hideTooltip(),t.isClick||(t.setPosition(t.newPosition),t.$parent.emitChange())}),0),window.removeEventListener("mousemove",this.onDragging),window.removeEventListener("touchmove",this.onDragging),window.removeEventListener("mouseup",this.onDragEnd),window.removeEventListener("touchend",this.onDragEnd),window.removeEventListener("contextmenu",this.onDragEnd))},setPosition:function(t){var e=this;if(null!==t&&!isNaN(t)){t<0?t=0:t>100&&(t=100);var n=100/((this.max-this.min)/this.step),r=Math.round(t/n)*n*(this.max-this.min)*.01+this.min;if(this.marks){var o=Object.keys(this.marks).map((function(t,e,n){return{value:Number(t),perc:100*e/(n.length-1)}}));if(100===t)r=o[o.length-1].value;else{var l=o.findIndex((function(e){return e.perc>t}));r=-1===l?o[o.length-2].value+(o.length-1)*((t-o[o.length-2].perc)/100*(o[o.length-1].value-o[o.length-2].value)):o[l-1].value+(o.length-1)*((t-o[l-1].perc)/100*(o[l].value-o[l-1].value))}}r=parseFloat(r.toFixed(this.precision)),this.$emit("input",r),this.$nextTick((function(){e.displayTooltip(),e.$refs.tooltip&&e.$refs.tooltip.updatePopper()})),this.dragging||this.value===this.oldValue||(this.oldValue=this.value)}}}},o=n(22),component=Object(o.a)(r,(function(){var t=this,e=t._self._c;return e("div",{ref:"button",staticClass:"el-slider__button-wrapper",class:{hover:t.hovering,dragging:t.dragging},style:t.wrapperStyle,attrs:{tabindex:"0"},on:{mouseenter:t.handleMouseEnter,mouseleave:t.handleMouseLeave,mousedown:t.onButtonDown,touchstart:t.onButtonDown,focus:t.handleMouseEnter,blur:t.handleMouseLeave,keydown:[function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"left",37,e.key,["Left","ArrowLeft"])||"button"in e&&0!==e.button?null:t.onLeftKeyDown.apply(null,arguments)},function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"right",39,e.key,["Right","ArrowRight"])||"button"in e&&2!==e.button?null:t.onRightKeyDown.apply(null,arguments)},function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"down",40,e.key,["Down","ArrowDown"])?null:(e.preventDefault(),t.onLeftKeyDown.apply(null,arguments))},function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"up",38,e.key,["Up","ArrowUp"])?null:(e.preventDefault(),t.onRightKeyDown.apply(null,arguments))}]}},[e("el-tooltip",{ref:"tooltip",attrs:{placement:"top","popper-class":t.tooltipClass,disabled:!t.showTooltip}},[e("span",{attrs:{slot:"content"},slot:"content"},[t._v(t._s(t.formatValue))]),t._v(" "),e("div",{staticClass:"el-slider__button",class:{hover:t.hovering,dragging:t.dragging}})])],1)}),[],!1,null,null,null);e.default=component.exports},712:function(t,e,n){"use strict";n.r(e);var r={name:"ElMarker",props:{mark:{type:[String,Object]}},data:function(){return{label:""}},mounted:function(){this.label="string"==typeof this.mark?this.mark:this.mark.label},methods:{onMarkClick:function(t){this.$emit("click")}}},o=n(22),component=Object(o.a)(r,(function(){var t=this;return(0,t._self._c)("div",{staticClass:"el-slider__marks-text",staticStyle:{},on:{click:function(e){return e.stopPropagation(),t.onMarkClick.apply(null,arguments)}}},[t._v("\n "+t._s(t.label)+"\n")])}),[],!1,null,null,null);e.default=component.exports}}]);
- //# sourceMappingURL=e3f1b7b.js.map
|