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
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
var _warning = require('../../../_util/warning');
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var calcPoints = function calcPoints(vertical, marks, dots, step, min, max) {
(0, _warning2['default'])(dots ? step > 0 : true, '`Slider[step]` should be a positive number in order to make Slider[dots] work.');
var points = Object.keys(marks).map(parseFloat).sort(function (a, b) {
return a - b;
});
if (dots) {
for (var i = min; i <= max; i += step) {
if (points.indexOf(i) === -1) {
points.push(i);
}
}
}
return points;
};
var Steps = {
functional: true,
render: function render(h, context) {
var _context$props = context.props,
prefixCls = _context$props.prefixCls,
vertical = _context$props.vertical,
marks = _context$props.marks,
dots = _context$props.dots,
step = _context$props.step,
included = _context$props.included,
lowerBound = _context$props.lowerBound,
upperBound = _context$props.upperBound,
max = _context$props.max,
min = _context$props.min,
dotStyle = _context$props.dotStyle,
activeDotStyle = _context$props.activeDotStyle;
var range = max - min;
var elements = calcPoints(vertical, marks, dots, step, min, max).map(function (point) {
var _classNames;
var offset = Math.abs(point - min) / range * 100 + '%';
var isActived = !included && point === upperBound || included && point <= upperBound && point >= lowerBound;
var style = vertical ? (0, _extends3['default'])({ bottom: offset }, dotStyle) : (0, _extends3['default'])({ left: offset }, dotStyle);
if (isActived) {
style = (0, _extends3['default'])({}, style, activeDotStyle);
}
var pointClassName = (0, _classnames2['default'])((_classNames = {}, (0, _defineProperty3['default'])(_classNames, prefixCls + '-dot', true), (0, _defineProperty3['default'])(_classNames, prefixCls + '-dot-active', isActived), _classNames));
return h('span', { 'class': pointClassName, style: style, key: point });
});
return h(
'div',
{ 'class': prefixCls + '-step' },
[elements]
);
}
};
exports['default'] = Steps;