import _defineProperty from"babel-runtime/helpers/defineProperty";import _extends from"babel-runtime/helpers/extends";import _classCallCheck from"babel-runtime/helpers/classCallCheck";import _createClass from"babel-runtime/helpers/createClass";import _possibleConstructorReturn from"babel-runtime/helpers/possibleConstructorReturn";import _inherits from"babel-runtime/helpers/inherits";var __rest=this&&this.__rest||function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&(r[i[o]]=e[i[o]])}return r};import*as React from"react";import RcSlider from"rc-slider/es/Slider";import RcRange from"rc-slider/es/Range";import RcHandle from"rc-slider/es/Handle";import Tooltip from"../tooltip";var Slider=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.toggleTooltipVisible=function(e,t){r.setState(function(r){var i=r.visibles;return{visibles:_extends({},i,_defineProperty({},e,t))}})},r.handleWithTooltip=function(e){var t=e.value,i=e.dragging,o=e.index,l=__rest(e,["value","dragging","index"]),n=r.props,s=n.tooltipPrefixCls,a=n.tipFormatter,c=r.state.visibles,p=!!a&&(c[o]||i);return React.createElement(Tooltip,{prefixCls:s,title:a?a(t):"",visible:p,placement:"top",transitionName:"zoom-down",key:o},React.createElement(RcHandle,_extends({},l,{value:t,onMouseEnter:function(){return r.toggleTooltipVisible(o,!0)},onMouseLeave:function(){return r.toggleTooltipVisible(o,!1)}})))},r.saveSlider=function(e){r.rcSlider=e},r.state={visibles:{}},r}return _inherits(t,e),_createClass(t,[{key:"focus",value:function(){this.rcSlider.focus()}},{key:"blur",value:function(){this.rcSlider.focus()}},{key:"render",value:function(){var e=this.props,t=e.range,r=__rest(e,["range"]);return t?React.createElement(RcRange,_extends({},r,{ref:this.saveSlider,handle:this.handleWithTooltip})):React.createElement(RcSlider,_extends({},r,{ref:this.saveSlider,handle:this.handleWithTooltip}))}}]),t}(React.Component);export default Slider;Slider.defaultProps={prefixCls:"dt-slider",tooltipPrefixCls:"dt-tooltip",tipFormatter:function(e){return e.toString()}};