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
import _extends from 'babel-runtime/helpers/extends';
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _typeof from 'babel-runtime/helpers/typeof';
import classNames from 'classnames';
import { isValidElement } from '../../../_util/props-util';
var Marks = {
functional: true,
render: function render(h, context) {
var _context$props = context.props,
className = _context$props.className,
vertical = _context$props.vertical,
marks = _context$props.marks,
included = _context$props.included,
upperBound = _context$props.upperBound,
lowerBound = _context$props.lowerBound,
max = _context$props.max,
min = _context$props.min;
var clickLabel = context.listeners.clickLabel;
var marksKeys = Object.keys(marks);
var marksCount = marksKeys.length;
var unit = marksCount > 1 ? 100 / (marksCount - 1) : 100;
var markWidth = unit * 0.9;
var range = max - min;
var elements = marksKeys.map(parseFloat).sort(function (a, b) {
return a - b;
}).map(function (point) {
var _classNames;
var markPoint = typeof marks[point] === 'function' ? marks[point](h) : marks[point];
var markPointIsObject = (typeof markPoint === 'undefined' ? 'undefined' : _typeof(markPoint)) === 'object' && !isValidElement(markPoint);
var markLabel = markPointIsObject ? markPoint.label : markPoint;
if (!markLabel && markLabel !== 0) {
return null;
}
var isActive = !included && point === upperBound || included && point <= upperBound && point >= lowerBound;
var markClassName = classNames((_classNames = {}, _defineProperty(_classNames, className + '-text', true), _defineProperty(_classNames, className + '-text-active', isActive), _classNames));
var bottomStyle = {
marginBottom: '-50%',
bottom: (point - min) / range * 100 + '%'
};
var leftStyle = {
width: markWidth + '%',
marginLeft: -markWidth / 2 + '%',
left: (point - min) / range * 100 + '%'
};
var style = vertical ? bottomStyle : leftStyle;
var markStyle = markPointIsObject ? _extends({}, style, markPoint.style) : style;
return h(
'span',
{
'class': markClassName,
style: markStyle,
key: point,
on: {
'mousedown': function mousedown(e) {
return clickLabel(e, point);
},
'touchstart': function touchstart(e) {
return clickLabel(e, point);
}
}
},
[markLabel]
);
});
return h(
'div',
{ 'class': className },
[elements]
);
}
};
export default Marks;