1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _index = require('../index');
var _index2 = _interopRequireDefault(_index);
var _vcTooltip = require('../../vc-tooltip');
var _vcTooltip2 = _interopRequireDefault(_vcTooltip);
require('../assets/index.less');
require('../../vc-tooltip/assets/bootstrap.less');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var Handle = _index2['default'].Handle;
var createSliderWithTooltip = _index2['default'].createSliderWithTooltip;
var Range = createSliderWithTooltip(_index2['default'].Range);
exports['default'] = {
data: function data() {
return {
visibles: []
};
},
methods: {
handleTooltipVisibleChange: function handleTooltipVisibleChange(index, visible) {
this.visibles[index] = visible;
this.visibles = (0, _extends3['default'])({}, this.visibles);
}
},
render: function render() {
var h = arguments[0];
var handle = function handle(props) {
var value = props.value,
dragging = props.dragging,
index = props.index,
ref = props.ref,
style = props.style,
restProps = (0, _objectWithoutProperties3['default'])(props, ['value', 'dragging', 'index', 'ref', 'style']);
var handleProps = {
props: (0, _extends3['default'])({}, restProps, {
value: value
}),
key: index,
style: style,
ref: ref
};
return h(
_vcTooltip2['default'],
{
attrs: {
prefixCls: 'rc-slider-tooltip',
overlay: value,
visible: dragging,
placement: 'top'
},
key: index
},
[h(Handle, handleProps)]
);
};
// const handleRange = (h, { value, ref, dragging, index, disabled, style, ...restProps }) => {
// const tipFormatter = value => `${value}%`
// const tipProps = {}
// const {
// prefixCls = 'rc-slider-tooltip',
// overlay = tipFormatter(value),
// placement = 'top',
// visible = visible || false,
// ...restTooltipProps } = tipProps
// let handleStyleWithIndex
// if (Array.isArray(style)) {
// handleStyleWithIndex = style[index] || style[0]
// } else {
// handleStyleWithIndex = style
// }
// const tooltipProps = {
// props: {
// prefixCls,
// overlay,
// placement,
// visible: (!disabled && (this.visibles[index] || dragging)) || visible,
// ...restTooltipProps,
// },
// key: index,
// }
// const handleProps = {
// props: {
// value,
// ...restProps,
// },
// on: {
// mouseenter: () => this.handleTooltipVisibleChange(index, true),
// mouseleave: () => this.handleTooltipVisibleChange(index, false),
// },
// style: {
// ...handleStyleWithIndex,
// },
// ref,
// }
// return (
// <Tooltip
// {...tooltipProps}
// >
// <Handle
// {...handleProps}
// />
// </Tooltip>
// )
// }
var wrapperStyle = 'width: 400px; margin: 50px';
return h('div', [h(
'div',
{ style: wrapperStyle },
[h('p', ['Slider with custom handle']), h(_index2['default'], {
attrs: { min: 0, max: 20, defaultValue: 3, handle: handle }
})]
), h(
'div',
{ style: wrapperStyle },
[h('p', ['Range with custom handle']), h(Range, {
attrs: { min: 0, max: 20, defaultValue: [3, 10], tipFormatter: function tipFormatter(value) {
return value + '%';
} }
})]
)]);
}
};