mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 03:59:01 +08:00
deps: upgrade rc-slider, ref: #4719
This commit is contained in:
parent
bed59cf658
commit
89d77b2354
@ -1,6 +1,8 @@
|
||||
import React from 'react';
|
||||
import { PropTypes } from 'react';
|
||||
import RcSlider from 'rc-slider';
|
||||
import RcSlider from 'rc-slider/lib/Slider';
|
||||
import RcRange from 'rc-slider/lib/Range';
|
||||
import RcHandle from 'rc-slider/lib/Handle';
|
||||
import Tooltip from '../tooltip';
|
||||
|
||||
export interface SliderMarks {
|
||||
[key: number]: React.ReactNode | {
|
||||
@ -12,6 +14,8 @@ export interface SliderMarks {
|
||||
export type SliderValue = number | [number, number];
|
||||
|
||||
export interface SliderProps {
|
||||
prefixCls?: string;
|
||||
tooltipPrefixCls?: string;
|
||||
range?: boolean;
|
||||
min?: number;
|
||||
max?: number;
|
||||
@ -32,15 +36,46 @@ export default class Slider extends React.Component<SliderProps, any> {
|
||||
static defaultProps = {
|
||||
prefixCls: 'ant-slider',
|
||||
tooltipPrefixCls: 'ant-tooltip',
|
||||
tipTransitionName: 'zoom-down',
|
||||
tipFormatter(value) {
|
||||
return value.toString();
|
||||
},
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
prefixCls: PropTypes.string,
|
||||
tipTransitionName: PropTypes.string,
|
||||
};
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { visibles: {} };
|
||||
}
|
||||
|
||||
handleTooltipVisibleChange = (index, visible) => {
|
||||
this.setState({
|
||||
visibles: {
|
||||
...this.state.visibles,
|
||||
[index]: visible,
|
||||
},
|
||||
});
|
||||
}
|
||||
handleWithTooltip = ({ value, dragging, index, ...restProps }) => {
|
||||
const { tooltipPrefixCls, tipFormatter } = this.props;
|
||||
return (
|
||||
<Tooltip
|
||||
prefixCls={tooltipPrefixCls}
|
||||
title={tipFormatter ? tipFormatter(value) : ''}
|
||||
visible={tipFormatter && (this.state.visibles[index] || dragging)}
|
||||
onVisibleChange={visible => this.handleTooltipVisibleChange(index, visible)}
|
||||
placement="top"
|
||||
transitionName="zoom-down"
|
||||
key={index}
|
||||
>
|
||||
<RcHandle {...restProps} />
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <RcSlider {...this.props} />;
|
||||
const { range, ...restProps } = this.props;
|
||||
if (range) {
|
||||
return <RcRange {...restProps} handle={this.handleWithTooltip} />;
|
||||
}
|
||||
return <RcSlider {...restProps} handle={this.handleWithTooltip} />;
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@
|
||||
"rc-radio": "~2.0.0",
|
||||
"rc-rate": "~1.1.2",
|
||||
"rc-select": "~6.7.1",
|
||||
"rc-slider": "~5.4.0",
|
||||
"rc-slider": "~6.1.0",
|
||||
"rc-steps": "~2.3.0",
|
||||
"rc-switch": "~1.4.2",
|
||||
"rc-table": "~5.2.0",
|
||||
|
Loading…
Reference in New Issue
Block a user