Latest updates from IceHrmPro

This commit is contained in:
Thilina Pituwala
2020-05-20 18:47:29 +02:00
parent 60c92d7935
commit 7453a58aad
18012 changed files with 2089245 additions and 10173 deletions

140
web/node_modules/rc-slider/es/Handle.js generated vendored Normal file
View File

@@ -0,0 +1,140 @@
import _extends from 'babel-runtime/helpers/extends';
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
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';
import React from 'react';
import classNames from 'classnames';
import addEventListener from 'rc-util/es/Dom/addEventListener';
var Handle = function (_React$Component) {
_inherits(Handle, _React$Component);
function Handle() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, Handle);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Handle.__proto__ || Object.getPrototypeOf(Handle)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
clickFocused: false
}, _this.setHandleRef = function (node) {
_this.handle = node;
}, _this.handleMouseUp = function () {
if (document.activeElement === _this.handle) {
_this.setClickFocus(true);
}
}, _this.handleMouseDown = function () {
// fix https://github.com/ant-design/ant-design/issues/15324
_this.focus();
}, _this.handleBlur = function () {
_this.setClickFocus(false);
}, _this.handleKeyDown = function () {
_this.setClickFocus(false);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(Handle, [{
key: 'componentDidMount',
value: function componentDidMount() {
// mouseup won't trigger if mouse moved out of handle,
// so we listen on document here.
this.onMouseUpListener = addEventListener(document, 'mouseup', this.handleMouseUp);
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
if (this.onMouseUpListener) {
this.onMouseUpListener.remove();
}
}
}, {
key: 'setClickFocus',
value: function setClickFocus(focused) {
this.setState({ clickFocused: focused });
}
}, {
key: 'clickFocus',
value: function clickFocus() {
this.setClickFocus(true);
this.focus();
}
}, {
key: 'focus',
value: function focus() {
this.handle.focus();
}
}, {
key: 'blur',
value: function blur() {
this.handle.blur();
}
}, {
key: 'render',
value: function render() {
var _ref2, _ref3;
var _props = this.props,
prefixCls = _props.prefixCls,
vertical = _props.vertical,
reverse = _props.reverse,
offset = _props.offset,
style = _props.style,
disabled = _props.disabled,
min = _props.min,
max = _props.max,
value = _props.value,
tabIndex = _props.tabIndex,
ariaLabel = _props.ariaLabel,
ariaLabelledBy = _props.ariaLabelledBy,
ariaValueTextFormatter = _props.ariaValueTextFormatter,
restProps = _objectWithoutProperties(_props, ['prefixCls', 'vertical', 'reverse', 'offset', 'style', 'disabled', 'min', 'max', 'value', 'tabIndex', 'ariaLabel', 'ariaLabelledBy', 'ariaValueTextFormatter']);
var className = classNames(this.props.className, _defineProperty({}, prefixCls + '-handle-click-focused', this.state.clickFocused));
var positionStyle = vertical ? (_ref2 = {}, _defineProperty(_ref2, reverse ? 'top' : 'bottom', offset + '%'), _defineProperty(_ref2, reverse ? 'bottom' : 'top', 'auto'), _defineProperty(_ref2, 'transform', reverse ? null : 'translateY(+50%)'), _ref2) : (_ref3 = {}, _defineProperty(_ref3, reverse ? 'right' : 'left', offset + '%'), _defineProperty(_ref3, reverse ? 'left' : 'right', 'auto'), _defineProperty(_ref3, 'transform', 'translateX(' + (reverse ? '+' : '-') + '50%)'), _ref3);
var elStyle = _extends({}, style, positionStyle);
var _tabIndex = tabIndex || 0;
if (disabled || tabIndex === null) {
_tabIndex = null;
}
var ariaValueText = void 0;
if (ariaValueTextFormatter) {
ariaValueText = ariaValueTextFormatter(value);
}
return React.createElement('div', _extends({
ref: this.setHandleRef,
tabIndex: _tabIndex
}, restProps, {
className: className,
style: elStyle,
onBlur: this.handleBlur,
onKeyDown: this.handleKeyDown,
onMouseDown: this.handleMouseDown
// aria attribute
, role: 'slider',
'aria-valuemin': min,
'aria-valuemax': max,
'aria-valuenow': value,
'aria-disabled': !!disabled,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledBy,
'aria-valuetext': ariaValueText
}));
}
}]);
return Handle;
}(React.Component);
export default Handle;

525
web/node_modules/rc-slider/es/Range.js generated vendored Normal file
View File

@@ -0,0 +1,525 @@
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _extends from 'babel-runtime/helpers/extends';
import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray';
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';
import React from 'react';
import classNames from 'classnames';
import shallowEqual from 'shallowequal';
import Track from './common/Track';
import createSlider from './common/createSlider';
import * as utils from './utils';
var _trimAlignValue = function _trimAlignValue(_ref) {
var value = _ref.value,
handle = _ref.handle,
bounds = _ref.bounds,
props = _ref.props;
var allowCross = props.allowCross,
pushable = props.pushable;
var thershold = Number(pushable);
var valInRange = utils.ensureValueInRange(value, props);
var valNotConflict = valInRange;
if (!allowCross && handle != null && bounds !== undefined) {
if (handle > 0 && valInRange <= bounds[handle - 1] + thershold) {
valNotConflict = bounds[handle - 1] + thershold;
}
if (handle < bounds.length - 1 && valInRange >= bounds[handle + 1] - thershold) {
valNotConflict = bounds[handle + 1] - thershold;
}
}
return utils.ensureValuePrecision(valNotConflict, props);
};
var Range = function (_React$Component) {
_inherits(Range, _React$Component);
function Range(props) {
_classCallCheck(this, Range);
var _this = _possibleConstructorReturn(this, (Range.__proto__ || Object.getPrototypeOf(Range)).call(this, props));
_this.onEnd = function (force) {
var handle = _this.state.handle;
_this.removeDocumentEvents();
if (handle !== null || force) {
_this.props.onAfterChange(_this.getValue());
}
_this.setState({
handle: null
});
};
var count = props.count,
min = props.min,
max = props.max;
var initialValue = Array.apply(undefined, _toConsumableArray(Array(count + 1))).map(function () {
return min;
});
var defaultValue = 'defaultValue' in props ? props.defaultValue : initialValue;
var value = props.value !== undefined ? props.value : defaultValue;
var bounds = value.map(function (v, i) {
return _trimAlignValue({
value: v,
handle: i,
props: props
});
});
var recent = bounds[0] === max ? 0 : bounds.length - 1;
_this.state = {
handle: null,
recent: recent,
bounds: bounds
};
return _this;
}
_createClass(Range, [{
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps, prevState) {
var _this2 = this;
if (!('value' in this.props || 'min' in this.props || 'max' in this.props)) {
return;
}
if (this.props.min === prevProps.min && this.props.max === prevProps.max && shallowEqual(this.props.value, prevProps.value)) {
return;
}
var _props = this.props,
onChange = _props.onChange,
value = _props.value;
var currentValue = value || prevState.bounds;
if (currentValue.some(function (v) {
return utils.isValueOutOfRange(v, _this2.props);
})) {
var newValues = currentValue.map(function (v) {
return utils.ensureValueInRange(v, _this2.props);
});
onChange(newValues);
}
}
}, {
key: 'onChange',
value: function onChange(state) {
var props = this.props;
var isNotControlled = !('value' in props);
if (isNotControlled) {
this.setState(state);
} else {
var controlledState = {};
['handle', 'recent'].forEach(function (item) {
if (state[item] !== undefined) {
controlledState[item] = state[item];
}
});
if (Object.keys(controlledState).length) {
this.setState(controlledState);
}
}
var data = _extends({}, this.state, state);
var changedValue = data.bounds;
props.onChange(changedValue);
}
}, {
key: 'onStart',
value: function onStart(position) {
var props = this.props;
var state = this.state;
var bounds = this.getValue();
props.onBeforeChange(bounds);
var value = this.calcValueByPos(position);
this.startValue = value;
this.startPosition = position;
var closestBound = this.getClosestBound(value);
this.prevMovedHandleIndex = this.getBoundNeedMoving(value, closestBound);
this.setState({
handle: this.prevMovedHandleIndex,
recent: this.prevMovedHandleIndex
});
var prevValue = bounds[this.prevMovedHandleIndex];
if (value === prevValue) return;
var nextBounds = [].concat(_toConsumableArray(state.bounds));
nextBounds[this.prevMovedHandleIndex] = value;
this.onChange({ bounds: nextBounds });
}
}, {
key: 'onMove',
value: function onMove(e, position) {
utils.pauseEvent(e);
var state = this.state;
var value = this.calcValueByPos(position);
var oldValue = state.bounds[state.handle];
if (value === oldValue) return;
this.moveTo(value);
}
}, {
key: 'onKeyboard',
value: function onKeyboard(e) {
var _props2 = this.props,
reverse = _props2.reverse,
vertical = _props2.vertical;
var valueMutator = utils.getKeyboardValueMutator(e, vertical, reverse);
if (valueMutator) {
utils.pauseEvent(e);
var state = this.state,
props = this.props;
var bounds = state.bounds,
handle = state.handle;
var oldValue = bounds[handle === null ? state.recent : handle];
var mutatedValue = valueMutator(oldValue, props);
var value = _trimAlignValue({
value: mutatedValue,
handle: handle,
bounds: state.bounds,
props: props
});
if (value === oldValue) return;
var isFromKeyboardEvent = true;
this.moveTo(value, isFromKeyboardEvent);
}
}
}, {
key: 'getValue',
value: function getValue() {
return this.state.bounds;
}
}, {
key: 'getClosestBound',
value: function getClosestBound(value) {
var bounds = this.state.bounds;
var closestBound = 0;
for (var i = 1; i < bounds.length - 1; ++i) {
if (value >= bounds[i]) {
closestBound = i;
}
}
if (Math.abs(bounds[closestBound + 1] - value) < Math.abs(bounds[closestBound] - value)) {
closestBound += 1;
}
return closestBound;
}
}, {
key: 'getBoundNeedMoving',
value: function getBoundNeedMoving(value, closestBound) {
var _state = this.state,
bounds = _state.bounds,
recent = _state.recent;
var boundNeedMoving = closestBound;
var isAtTheSamePoint = bounds[closestBound + 1] === bounds[closestBound];
if (isAtTheSamePoint && bounds[recent] === bounds[closestBound]) {
boundNeedMoving = recent;
}
if (isAtTheSamePoint && value !== bounds[closestBound + 1]) {
boundNeedMoving = value < bounds[closestBound + 1] ? closestBound : closestBound + 1;
}
return boundNeedMoving;
}
}, {
key: 'getLowerBound',
value: function getLowerBound() {
return this.state.bounds[0];
}
}, {
key: 'getUpperBound',
value: function getUpperBound() {
var bounds = this.state.bounds;
return bounds[bounds.length - 1];
}
/**
* Returns an array of possible slider points, taking into account both
* `marks` and `step`. The result is cached.
*/
}, {
key: 'getPoints',
value: function getPoints() {
var _props3 = this.props,
marks = _props3.marks,
step = _props3.step,
min = _props3.min,
max = _props3.max;
var cache = this._getPointsCache;
if (!cache || cache.marks !== marks || cache.step !== step) {
var pointsObject = _extends({}, marks);
if (step !== null) {
for (var point = min; point <= max; point += step) {
pointsObject[point] = point;
}
}
var points = Object.keys(pointsObject).map(parseFloat);
points.sort(function (a, b) {
return a - b;
});
this._getPointsCache = { marks: marks, step: step, points: points };
}
return this._getPointsCache.points;
}
}, {
key: 'moveTo',
value: function moveTo(value, isFromKeyboardEvent) {
var _this3 = this;
var state = this.state,
props = this.props;
var nextBounds = [].concat(_toConsumableArray(state.bounds));
var handle = state.handle === null ? state.recent : state.handle;
nextBounds[handle] = value;
var nextHandle = handle;
if (props.pushable !== false) {
this.pushSurroundingHandles(nextBounds, nextHandle);
} else if (props.allowCross) {
nextBounds.sort(function (a, b) {
return a - b;
});
nextHandle = nextBounds.indexOf(value);
}
this.onChange({
recent: nextHandle,
handle: nextHandle,
bounds: nextBounds
});
if (isFromKeyboardEvent) {
// known problem: because setState is async,
// so trigger focus will invoke handler's onEnd and another handler's onStart too early,
// cause onBeforeChange and onAfterChange receive wrong value.
// here use setState callback to hackbut not elegant
this.props.onAfterChange(nextBounds);
this.setState({}, function () {
_this3.handlesRefs[nextHandle].focus();
});
this.onEnd();
}
}
}, {
key: 'pushSurroundingHandles',
value: function pushSurroundingHandles(bounds, handle) {
var value = bounds[handle];
var threshold = this.props.pushable;
threshold = Number(threshold);
var direction = 0;
if (bounds[handle + 1] - value < threshold) {
direction = +1; // push to right
}
if (value - bounds[handle - 1] < threshold) {
direction = -1; // push to left
}
if (direction === 0) {
return;
}
var nextHandle = handle + direction;
var diffToNext = direction * (bounds[nextHandle] - value);
if (!this.pushHandle(bounds, nextHandle, direction, threshold - diffToNext)) {
// revert to original value if pushing is impossible
bounds[handle] = bounds[nextHandle] - direction * threshold;
}
}
}, {
key: 'pushHandle',
value: function pushHandle(bounds, handle, direction, amount) {
var originalValue = bounds[handle];
var currentValue = bounds[handle];
while (direction * (currentValue - originalValue) < amount) {
if (!this.pushHandleOnePoint(bounds, handle, direction)) {
// can't push handle enough to create the needed `amount` gap, so we
// revert its position to the original value
bounds[handle] = originalValue;
return false;
}
currentValue = bounds[handle];
}
// the handle was pushed enough to create the needed `amount` gap
return true;
}
}, {
key: 'pushHandleOnePoint',
value: function pushHandleOnePoint(bounds, handle, direction) {
var points = this.getPoints();
var pointIndex = points.indexOf(bounds[handle]);
var nextPointIndex = pointIndex + direction;
if (nextPointIndex >= points.length || nextPointIndex < 0) {
// reached the minimum or maximum available point, can't push anymore
return false;
}
var nextHandle = handle + direction;
var nextValue = points[nextPointIndex];
var threshold = this.props.pushable;
var diffToNext = direction * (bounds[nextHandle] - nextValue);
if (!this.pushHandle(bounds, nextHandle, direction, threshold - diffToNext)) {
// couldn't push next handle, so we won't push this one either
return false;
}
// push the handle
bounds[handle] = nextValue;
return true;
}
}, {
key: 'trimAlignValue',
value: function trimAlignValue(value) {
var _state2 = this.state,
handle = _state2.handle,
bounds = _state2.bounds;
return _trimAlignValue({
value: value,
handle: handle,
bounds: bounds,
props: this.props
});
}
}, {
key: 'render',
value: function render() {
var _this4 = this;
var _state3 = this.state,
handle = _state3.handle,
bounds = _state3.bounds;
var _props4 = this.props,
prefixCls = _props4.prefixCls,
vertical = _props4.vertical,
included = _props4.included,
disabled = _props4.disabled,
min = _props4.min,
max = _props4.max,
reverse = _props4.reverse,
handleGenerator = _props4.handle,
trackStyle = _props4.trackStyle,
handleStyle = _props4.handleStyle,
tabIndex = _props4.tabIndex,
ariaLabelGroupForHandles = _props4.ariaLabelGroupForHandles,
ariaLabelledByGroupForHandles = _props4.ariaLabelledByGroupForHandles,
ariaValueTextFormatterGroupForHandles = _props4.ariaValueTextFormatterGroupForHandles;
var offsets = bounds.map(function (v) {
return _this4.calcOffset(v);
});
var handleClassName = prefixCls + '-handle';
var handles = bounds.map(function (v, i) {
var _classNames;
var _tabIndex = tabIndex[i] || 0;
if (disabled || tabIndex[i] === null) {
_tabIndex = null;
}
var dragging = handle === i;
return handleGenerator({
className: classNames((_classNames = {}, _defineProperty(_classNames, handleClassName, true), _defineProperty(_classNames, handleClassName + '-' + (i + 1), true), _defineProperty(_classNames, handleClassName + '-dragging', dragging), _classNames)),
prefixCls: prefixCls,
vertical: vertical,
dragging: dragging,
offset: offsets[i],
value: v,
index: i,
tabIndex: _tabIndex,
min: min,
max: max,
reverse: reverse,
disabled: disabled,
style: handleStyle[i],
ref: function ref(h) {
return _this4.saveHandle(i, h);
},
ariaLabel: ariaLabelGroupForHandles[i],
ariaLabelledBy: ariaLabelledByGroupForHandles[i],
ariaValueTextFormatter: ariaValueTextFormatterGroupForHandles[i]
});
});
var tracks = bounds.slice(0, -1).map(function (_, index) {
var _classNames2;
var i = index + 1;
var trackClassName = classNames((_classNames2 = {}, _defineProperty(_classNames2, prefixCls + '-track', true), _defineProperty(_classNames2, prefixCls + '-track-' + i, true), _classNames2));
return React.createElement(Track, {
className: trackClassName,
vertical: vertical,
reverse: reverse,
included: included,
offset: offsets[i - 1],
length: offsets[i] - offsets[i - 1],
style: trackStyle[index],
key: i
});
});
return { tracks: tracks, handles: handles };
}
}], [{
key: 'getDerivedStateFromProps',
value: function getDerivedStateFromProps(props, state) {
if ('value' in props || 'min' in props || 'max' in props) {
var value = props.value || state.bounds;
var nextBounds = value.map(function (v, i) {
return _trimAlignValue({
value: v,
handle: i,
bounds: state.bounds,
props: props
});
});
if (nextBounds.length === state.bounds.length && nextBounds.every(function (v, i) {
return v === state.bounds[i];
})) {
return null;
}
return _extends({}, state, {
bounds: nextBounds
});
}
return null;
}
}]);
return Range;
}(React.Component);
Range.displayName = 'Range';
Range.defaultProps = {
count: 1,
allowCross: true,
pushable: false,
tabIndex: [],
ariaLabelGroupForHandles: [],
ariaLabelledByGroupForHandles: [],
ariaValueTextFormatterGroupForHandles: []
};
export default createSlider(Range);

222
web/node_modules/rc-slider/es/Slider.js generated vendored Normal file
View File

@@ -0,0 +1,222 @@
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';
import React from 'react';
import warning from 'warning';
import Track from './common/Track';
import createSlider from './common/createSlider';
import * as utils from './utils';
var Slider = function (_React$Component) {
_inherits(Slider, _React$Component);
function Slider(props) {
_classCallCheck(this, Slider);
var _this = _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).call(this, props));
_this.onEnd = function (force) {
var dragging = _this.state.dragging;
_this.removeDocumentEvents();
if (dragging || force) {
_this.props.onAfterChange(_this.getValue());
}
_this.setState({ dragging: false });
};
var defaultValue = props.defaultValue !== undefined ? props.defaultValue : props.min;
var value = props.value !== undefined ? props.value : defaultValue;
_this.state = {
value: _this.trimAlignValue(value),
dragging: false
};
warning(!('minimumTrackStyle' in props), 'minimumTrackStyle will be deprecated, please use trackStyle instead.');
warning(!('maximumTrackStyle' in props), 'maximumTrackStyle will be deprecated, please use railStyle instead.');
return _this;
}
_createClass(Slider, [{
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps, prevState) {
if (!('value' in this.props || 'min' in this.props || 'max' in this.props)) {
return;
}
var _props = this.props,
value = _props.value,
onChange = _props.onChange;
var theValue = value !== undefined ? value : prevState.value;
var nextValue = this.trimAlignValue(theValue, this.props);
if (nextValue !== prevState.value) {
// eslint-disable-next-line
this.setState({ value: nextValue });
if (utils.isValueOutOfRange(theValue, this.props)) {
onChange(nextValue);
}
}
}
}, {
key: 'onChange',
value: function onChange(state) {
var props = this.props;
var isNotControlled = !('value' in props);
var nextState = state.value > this.props.max ? _extends({}, state, { value: this.props.max }) : state;
if (isNotControlled) {
this.setState(nextState);
}
var changedValue = nextState.value;
props.onChange(changedValue);
}
}, {
key: 'onStart',
value: function onStart(position) {
this.setState({ dragging: true });
var props = this.props;
var prevValue = this.getValue();
props.onBeforeChange(prevValue);
var value = this.calcValueByPos(position);
this.startValue = value;
this.startPosition = position;
if (value === prevValue) return;
this.prevMovedHandleIndex = 0;
this.onChange({ value: value });
}
}, {
key: 'onMove',
value: function onMove(e, position) {
utils.pauseEvent(e);
var oldValue = this.state.value;
var value = this.calcValueByPos(position);
if (value === oldValue) return;
this.onChange({ value: value });
}
}, {
key: 'onKeyboard',
value: function onKeyboard(e) {
var _props2 = this.props,
reverse = _props2.reverse,
vertical = _props2.vertical;
var valueMutator = utils.getKeyboardValueMutator(e, vertical, reverse);
if (valueMutator) {
utils.pauseEvent(e);
var state = this.state;
var oldValue = state.value;
var mutatedValue = valueMutator(oldValue, this.props);
var value = this.trimAlignValue(mutatedValue);
if (value === oldValue) return;
this.onChange({ value: value });
this.props.onAfterChange(value);
this.onEnd();
}
}
}, {
key: 'getValue',
value: function getValue() {
return this.state.value;
}
}, {
key: 'getLowerBound',
value: function getLowerBound() {
return this.props.min;
}
}, {
key: 'getUpperBound',
value: function getUpperBound() {
return this.state.value;
}
}, {
key: 'trimAlignValue',
value: function trimAlignValue(v) {
var nextProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (v === null) {
return null;
}
var mergedProps = _extends({}, this.props, nextProps);
var val = utils.ensureValueInRange(v, mergedProps);
return utils.ensureValuePrecision(val, mergedProps);
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
var _props3 = this.props,
prefixCls = _props3.prefixCls,
vertical = _props3.vertical,
included = _props3.included,
disabled = _props3.disabled,
minimumTrackStyle = _props3.minimumTrackStyle,
trackStyle = _props3.trackStyle,
handleStyle = _props3.handleStyle,
tabIndex = _props3.tabIndex,
ariaLabelForHandle = _props3.ariaLabelForHandle,
ariaLabelledByForHandle = _props3.ariaLabelledByForHandle,
ariaValueTextFormatterForHandle = _props3.ariaValueTextFormatterForHandle,
min = _props3.min,
max = _props3.max,
startPoint = _props3.startPoint,
reverse = _props3.reverse,
handleGenerator = _props3.handle;
var _state = this.state,
value = _state.value,
dragging = _state.dragging;
var offset = this.calcOffset(value);
var handle = handleGenerator({
className: prefixCls + '-handle',
prefixCls: prefixCls,
vertical: vertical,
offset: offset,
value: value,
dragging: dragging,
disabled: disabled,
min: min,
max: max,
reverse: reverse,
index: 0,
tabIndex: tabIndex,
ariaLabel: ariaLabelForHandle,
ariaLabelledBy: ariaLabelledByForHandle,
ariaValueTextFormatter: ariaValueTextFormatterForHandle,
style: handleStyle[0] || handleStyle,
ref: function ref(h) {
return _this2.saveHandle(0, h);
}
});
var trackOffset = startPoint !== undefined ? this.calcOffset(startPoint) : 0;
var _trackStyle = trackStyle[0] || trackStyle;
var track = React.createElement(Track, {
className: prefixCls + '-track',
vertical: vertical,
included: included,
offset: trackOffset,
reverse: reverse,
length: offset - trackOffset,
style: _extends({}, minimumTrackStyle, _trackStyle)
});
return { tracks: track, handles: handle };
}
}]);
return Slider;
}(React.Component);
export default createSlider(Slider);

71
web/node_modules/rc-slider/es/common/Marks.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
import _extends from 'babel-runtime/helpers/extends';
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import React from 'react';
import classNames from 'classnames';
var Marks = function Marks(_ref) {
var className = _ref.className,
vertical = _ref.vertical,
reverse = _ref.reverse,
marks = _ref.marks,
included = _ref.included,
upperBound = _ref.upperBound,
lowerBound = _ref.lowerBound,
max = _ref.max,
min = _ref.min,
onClickLabel = _ref.onClickLabel;
var marksKeys = Object.keys(marks);
var range = max - min;
var elements = marksKeys.map(parseFloat).sort(function (a, b) {
return a - b;
}).map(function (point) {
var _classNames;
var markPoint = marks[point];
var markPointIsObject = typeof markPoint === 'object' && !React.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 = _defineProperty({
marginBottom: '-50%'
}, reverse ? 'top' : 'bottom', (point - min) / range * 100 + '%');
var leftStyle = _defineProperty({
transform: 'translateX(' + (reverse ? '50%' : '-50%') + ')',
msTransform: 'translateX(' + (reverse ? '50%' : '-50%') + ')'
}, reverse ? 'right' : 'left', (point - min) / range * 100 + '%');
var style = vertical ? bottomStyle : leftStyle;
var markStyle = markPointIsObject ? _extends({}, style, markPoint.style) : style;
return React.createElement(
'span',
{
className: markClassName,
style: markStyle,
key: point,
onMouseDown: function onMouseDown(e) {
return onClickLabel(e, point);
},
onTouchStart: function onTouchStart(e) {
return onClickLabel(e, point);
}
},
markLabel
);
});
return React.createElement(
'div',
{ className: className },
elements
);
};
export default Marks;

61
web/node_modules/rc-slider/es/common/Steps.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _extends from 'babel-runtime/helpers/extends';
import React from 'react';
import classNames from 'classnames';
import warning from 'warning';
var calcPoints = function calcPoints(vertical, marks, dots, step, min, max) {
warning(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 && step) {
for (var i = min; i <= max; i += step) {
if (points.indexOf(i) === -1) {
points.push(i);
}
}
}
return points;
};
var Steps = function Steps(_ref) {
var prefixCls = _ref.prefixCls,
vertical = _ref.vertical,
reverse = _ref.reverse,
marks = _ref.marks,
dots = _ref.dots,
step = _ref.step,
included = _ref.included,
lowerBound = _ref.lowerBound,
upperBound = _ref.upperBound,
max = _ref.max,
min = _ref.min,
dotStyle = _ref.dotStyle,
activeDotStyle = _ref.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 ? _extends({}, dotStyle, _defineProperty({}, reverse ? 'top' : 'bottom', offset)) : _extends({}, dotStyle, _defineProperty({}, reverse ? 'right' : 'left', offset));
if (isActived) {
style = _extends({}, style, activeDotStyle);
}
var pointClassName = classNames((_classNames = {}, _defineProperty(_classNames, prefixCls + '-dot', true), _defineProperty(_classNames, prefixCls + '-dot-active', isActived), _defineProperty(_classNames, prefixCls + '-dot-reverse', reverse), _classNames));
return React.createElement('span', { className: pointClassName, style: style, key: point });
});
return React.createElement(
'div',
{ className: prefixCls + '-step' },
elements
);
};
export default Steps;

28
web/node_modules/rc-slider/es/common/Track.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
import _extends from 'babel-runtime/helpers/extends';
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import React from 'react';
var Track = function Track(props) {
var _ref, _ref2;
var className = props.className,
included = props.included,
vertical = props.vertical,
style = props.style;
var length = props.length,
offset = props.offset,
reverse = props.reverse;
if (length < 0) {
reverse = !reverse;
length = Math.abs(length);
offset = 100 - offset;
}
var positonStyle = vertical ? (_ref = {}, _defineProperty(_ref, reverse ? 'top' : 'bottom', offset + '%'), _defineProperty(_ref, reverse ? 'bottom' : 'top', 'auto'), _defineProperty(_ref, 'height', length + '%'), _ref) : (_ref2 = {}, _defineProperty(_ref2, reverse ? 'right' : 'left', offset + '%'), _defineProperty(_ref2, reverse ? 'left' : 'right', 'auto'), _defineProperty(_ref2, 'width', length + '%'), _ref2);
var elStyle = _extends({}, style, positonStyle);
return included ? React.createElement('div', { className: className, style: elStyle }) : null;
};
export default Track;

383
web/node_modules/rc-slider/es/common/createSlider.js generated vendored Normal file
View File

@@ -0,0 +1,383 @@
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _extends from 'babel-runtime/helpers/extends';
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _get from 'babel-runtime/helpers/get';
import _inherits from 'babel-runtime/helpers/inherits';
import React from 'react';
import addEventListener from 'rc-util/es/Dom/addEventListener';
import classNames from 'classnames';
import warning from 'warning';
import Steps from './Steps';
import Marks from './Marks';
import Handle from '../Handle';
import * as utils from '../utils';
function noop() {}
export default function createSlider(Component) {
var _class, _temp;
return _temp = _class = function (_Component) {
_inherits(ComponentEnhancer, _Component);
function ComponentEnhancer(props) {
_classCallCheck(this, ComponentEnhancer);
var _this = _possibleConstructorReturn(this, (ComponentEnhancer.__proto__ || Object.getPrototypeOf(ComponentEnhancer)).call(this, props));
_this.onMouseDown = function (e) {
if (e.button !== 0) {
return;
}
var isVertical = _this.props.vertical;
var position = utils.getMousePosition(isVertical, e);
if (!utils.isEventFromHandle(e, _this.handlesRefs)) {
_this.dragOffset = 0;
} else {
var handlePosition = utils.getHandleCenterPosition(isVertical, e.target);
_this.dragOffset = position - handlePosition;
position = handlePosition;
}
_this.removeDocumentEvents();
_this.onStart(position);
_this.addDocumentMouseEvents();
};
_this.onTouchStart = function (e) {
if (utils.isNotTouchEvent(e)) return;
var isVertical = _this.props.vertical;
var position = utils.getTouchPosition(isVertical, e);
if (!utils.isEventFromHandle(e, _this.handlesRefs)) {
_this.dragOffset = 0;
} else {
var handlePosition = utils.getHandleCenterPosition(isVertical, e.target);
_this.dragOffset = position - handlePosition;
position = handlePosition;
}
_this.onStart(position);
_this.addDocumentTouchEvents();
utils.pauseEvent(e);
};
_this.onFocus = function (e) {
var _this$props = _this.props,
onFocus = _this$props.onFocus,
vertical = _this$props.vertical;
if (utils.isEventFromHandle(e, _this.handlesRefs)) {
var handlePosition = utils.getHandleCenterPosition(vertical, e.target);
_this.dragOffset = 0;
_this.onStart(handlePosition);
utils.pauseEvent(e);
if (onFocus) {
onFocus(e);
}
}
};
_this.onBlur = function (e) {
var onBlur = _this.props.onBlur;
_this.onEnd();
if (onBlur) {
onBlur(e);
}
};
_this.onMouseUp = function () {
if (_this.handlesRefs[_this.prevMovedHandleIndex]) {
_this.handlesRefs[_this.prevMovedHandleIndex].clickFocus();
}
};
_this.onMouseMove = function (e) {
if (!_this.sliderRef) {
_this.onEnd();
return;
}
var position = utils.getMousePosition(_this.props.vertical, e);
_this.onMove(e, position - _this.dragOffset);
};
_this.onTouchMove = function (e) {
if (utils.isNotTouchEvent(e) || !_this.sliderRef) {
_this.onEnd();
return;
}
var position = utils.getTouchPosition(_this.props.vertical, e);
_this.onMove(e, position - _this.dragOffset);
};
_this.onKeyDown = function (e) {
if (_this.sliderRef && utils.isEventFromHandle(e, _this.handlesRefs)) {
_this.onKeyboard(e);
}
};
_this.onClickMarkLabel = function (e, value) {
e.stopPropagation();
_this.onChange({ value: value });
_this.setState({ value: value }, function () {
return _this.onEnd(true);
});
};
_this.saveSlider = function (slider) {
_this.sliderRef = slider;
};
var step = props.step,
max = props.max,
min = props.min;
var isPointDiffEven = isFinite(max - min) ? (max - min) % step === 0 : true; // eslint-disable-line
warning(step && Math.floor(step) === step ? isPointDiffEven : true, 'Slider[max] - Slider[min] (%s) should be a multiple of Slider[step] (%s)', max - min, step);
_this.handlesRefs = {};
return _this;
}
_createClass(ComponentEnhancer, [{
key: 'componentDidMount',
value: function componentDidMount() {
// Snapshot testing cannot handle refs, so be sure to null-check this.
this.document = this.sliderRef && this.sliderRef.ownerDocument;
var _props = this.props,
autoFocus = _props.autoFocus,
disabled = _props.disabled;
if (autoFocus && !disabled) {
this.focus();
}
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
if (_get(ComponentEnhancer.prototype.__proto__ || Object.getPrototypeOf(ComponentEnhancer.prototype), 'componentWillUnmount', this)) _get(ComponentEnhancer.prototype.__proto__ || Object.getPrototypeOf(ComponentEnhancer.prototype), 'componentWillUnmount', this).call(this);
this.removeDocumentEvents();
}
}, {
key: 'getSliderStart',
value: function getSliderStart() {
var slider = this.sliderRef;
var _props2 = this.props,
vertical = _props2.vertical,
reverse = _props2.reverse;
var rect = slider.getBoundingClientRect();
if (vertical) {
return reverse ? rect.bottom : rect.top;
}
return window.pageXOffset + (reverse ? rect.right : rect.left);
}
}, {
key: 'getSliderLength',
value: function getSliderLength() {
var slider = this.sliderRef;
if (!slider) {
return 0;
}
var coords = slider.getBoundingClientRect();
return this.props.vertical ? coords.height : coords.width;
}
}, {
key: 'addDocumentTouchEvents',
value: function addDocumentTouchEvents() {
// just work for Chrome iOS Safari and Android Browser
this.onTouchMoveListener = addEventListener(this.document, 'touchmove', this.onTouchMove);
this.onTouchUpListener = addEventListener(this.document, 'touchend', this.onEnd);
}
}, {
key: 'addDocumentMouseEvents',
value: function addDocumentMouseEvents() {
this.onMouseMoveListener = addEventListener(this.document, 'mousemove', this.onMouseMove);
this.onMouseUpListener = addEventListener(this.document, 'mouseup', this.onEnd);
}
}, {
key: 'removeDocumentEvents',
value: function removeDocumentEvents() {
/* eslint-disable no-unused-expressions */
this.onTouchMoveListener && this.onTouchMoveListener.remove();
this.onTouchUpListener && this.onTouchUpListener.remove();
this.onMouseMoveListener && this.onMouseMoveListener.remove();
this.onMouseUpListener && this.onMouseUpListener.remove();
/* eslint-enable no-unused-expressions */
}
}, {
key: 'focus',
value: function focus() {
if (!this.props.disabled) {
this.handlesRefs[0].focus();
}
}
}, {
key: 'blur',
value: function blur() {
var _this2 = this;
if (!this.props.disabled) {
Object.keys(this.handlesRefs).forEach(function (key) {
if (_this2.handlesRefs[key] && _this2.handlesRefs[key].blur) {
_this2.handlesRefs[key].blur();
}
});
}
}
}, {
key: 'calcValue',
value: function calcValue(offset) {
var _props3 = this.props,
vertical = _props3.vertical,
min = _props3.min,
max = _props3.max;
var ratio = Math.abs(Math.max(offset, 0) / this.getSliderLength());
var value = vertical ? (1 - ratio) * (max - min) + min : ratio * (max - min) + min;
return value;
}
}, {
key: 'calcValueByPos',
value: function calcValueByPos(position) {
var sign = this.props.reverse ? -1 : +1;
var pixelOffset = sign * (position - this.getSliderStart());
var nextValue = this.trimAlignValue(this.calcValue(pixelOffset));
return nextValue;
}
}, {
key: 'calcOffset',
value: function calcOffset(value) {
var _props4 = this.props,
min = _props4.min,
max = _props4.max;
var ratio = (value - min) / (max - min);
return Math.max(0, ratio * 100);
}
}, {
key: 'saveHandle',
value: function saveHandle(index, handle) {
this.handlesRefs[index] = handle;
}
}, {
key: 'render',
value: function render() {
var _classNames;
var _props5 = this.props,
prefixCls = _props5.prefixCls,
className = _props5.className,
marks = _props5.marks,
dots = _props5.dots,
step = _props5.step,
included = _props5.included,
disabled = _props5.disabled,
vertical = _props5.vertical,
reverse = _props5.reverse,
min = _props5.min,
max = _props5.max,
children = _props5.children,
maximumTrackStyle = _props5.maximumTrackStyle,
style = _props5.style,
railStyle = _props5.railStyle,
dotStyle = _props5.dotStyle,
activeDotStyle = _props5.activeDotStyle;
var _get$call = _get(ComponentEnhancer.prototype.__proto__ || Object.getPrototypeOf(ComponentEnhancer.prototype), 'render', this).call(this),
tracks = _get$call.tracks,
handles = _get$call.handles;
var sliderClassName = classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, prefixCls + '-with-marks', Object.keys(marks).length), _defineProperty(_classNames, prefixCls + '-disabled', disabled), _defineProperty(_classNames, prefixCls + '-vertical', vertical), _defineProperty(_classNames, className, className), _classNames));
return React.createElement(
'div',
{
ref: this.saveSlider,
className: sliderClassName,
onTouchStart: disabled ? noop : this.onTouchStart,
onMouseDown: disabled ? noop : this.onMouseDown,
onMouseUp: disabled ? noop : this.onMouseUp,
onKeyDown: disabled ? noop : this.onKeyDown,
onFocus: disabled ? noop : this.onFocus,
onBlur: disabled ? noop : this.onBlur,
style: style
},
React.createElement('div', {
className: prefixCls + '-rail',
style: _extends({}, maximumTrackStyle, railStyle)
}),
tracks,
React.createElement(Steps, {
prefixCls: prefixCls,
vertical: vertical,
reverse: reverse,
marks: marks,
dots: dots,
step: step,
included: included,
lowerBound: this.getLowerBound(),
upperBound: this.getUpperBound(),
max: max,
min: min,
dotStyle: dotStyle,
activeDotStyle: activeDotStyle
}),
handles,
React.createElement(Marks, {
className: prefixCls + '-mark',
onClickLabel: disabled ? noop : this.onClickMarkLabel,
vertical: vertical,
marks: marks,
included: included,
lowerBound: this.getLowerBound(),
upperBound: this.getUpperBound(),
max: max,
min: min,
reverse: reverse
}),
children
);
}
}]);
return ComponentEnhancer;
}(Component), _class.displayName = 'ComponentEnhancer(' + Component.displayName + ')', _class.defaultProps = _extends({}, Component.defaultProps, {
prefixCls: 'rc-slider',
className: '',
min: 0,
max: 100,
step: 1,
marks: {},
handle: function handle(_ref) {
var index = _ref.index,
restProps = _objectWithoutProperties(_ref, ['index']);
delete restProps.dragging;
if (restProps.value === null) {
return null;
}
return React.createElement(Handle, _extends({}, restProps, { key: index }));
},
onBeforeChange: noop,
onChange: noop,
onAfterChange: noop,
included: true,
disabled: false,
dots: false,
vertical: false,
reverse: false,
trackStyle: [{}],
handleStyle: [{}],
railStyle: {},
dotStyle: {},
activeDotStyle: {}
}), _temp;
}

View File

@@ -0,0 +1,110 @@
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
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';
import React from 'react';
import Tooltip from 'rc-tooltip';
import Handle from './Handle';
export default function createSliderWithTooltip(Component) {
var _class, _temp2;
return _temp2 = _class = function (_React$Component) {
_inherits(ComponentWrapper, _React$Component);
function ComponentWrapper() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, ComponentWrapper);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ComponentWrapper.__proto__ || Object.getPrototypeOf(ComponentWrapper)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
visibles: {}
}, _this.handleTooltipVisibleChange = function (index, visible) {
_this.setState(function (prevState) {
return {
visibles: _extends({}, prevState.visibles, _defineProperty({}, index, visible))
};
});
}, _this.handleWithTooltip = function (_ref2) {
var value = _ref2.value,
dragging = _ref2.dragging,
index = _ref2.index,
disabled = _ref2.disabled,
restProps = _objectWithoutProperties(_ref2, ['value', 'dragging', 'index', 'disabled']);
var _this$props = _this.props,
tipFormatter = _this$props.tipFormatter,
tipProps = _this$props.tipProps,
handleStyle = _this$props.handleStyle,
getTooltipContainer = _this$props.getTooltipContainer;
var _tipProps$prefixCls = tipProps.prefixCls,
prefixCls = _tipProps$prefixCls === undefined ? 'rc-slider-tooltip' : _tipProps$prefixCls,
_tipProps$overlay = tipProps.overlay,
overlay = _tipProps$overlay === undefined ? tipFormatter(value) : _tipProps$overlay,
_tipProps$placement = tipProps.placement,
placement = _tipProps$placement === undefined ? 'top' : _tipProps$placement,
_tipProps$visible = tipProps.visible,
visible = _tipProps$visible === undefined ? false : _tipProps$visible,
restTooltipProps = _objectWithoutProperties(tipProps, ['prefixCls', 'overlay', 'placement', 'visible']);
var handleStyleWithIndex = void 0;
if (Array.isArray(handleStyle)) {
handleStyleWithIndex = handleStyle[index] || handleStyle[0];
} else {
handleStyleWithIndex = handleStyle;
}
return React.createElement(
Tooltip,
_extends({}, restTooltipProps, {
getTooltipContainer: getTooltipContainer,
prefixCls: prefixCls,
overlay: overlay,
placement: placement,
visible: !disabled && (_this.state.visibles[index] || dragging) || visible,
key: index
}),
React.createElement(Handle, _extends({}, restProps, {
style: _extends({}, handleStyleWithIndex),
value: value,
onMouseEnter: function onMouseEnter() {
return _this.handleTooltipVisibleChange(index, true);
},
onMouseLeave: function onMouseLeave() {
return _this.handleTooltipVisibleChange(index, false);
}
}))
);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(ComponentWrapper, [{
key: 'render',
value: function render() {
return React.createElement(Component, _extends({}, this.props, { handle: this.handleWithTooltip }));
}
}]);
return ComponentWrapper;
}(React.Component), _class.defaultProps = {
tipFormatter: function tipFormatter(value) {
return value;
},
handleStyle: [{}],
tipProps: {},
getTooltipContainer: function getTooltipContainer(node) {
return node.parentNode;
}
}, _temp2;
}

10
web/node_modules/rc-slider/es/index.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
import Slider from './Slider';
import Range from './Range';
import Handle from './Handle';
import createSliderWithTooltip from './createSliderWithTooltip';
Slider.Range = Range;
Slider.Handle = Handle;
Slider.createSliderWithTooltip = createSliderWithTooltip;
export default Slider;
export { Range, Handle, createSliderWithTooltip };

150
web/node_modules/rc-slider/es/utils.js generated vendored Normal file
View File

@@ -0,0 +1,150 @@
import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray';
import { findDOMNode } from 'react-dom';
import keyCode from 'rc-util/es/KeyCode';
export function isEventFromHandle(e, handles) {
try {
return Object.keys(handles).some(function (key) {
return e.target === findDOMNode(handles[key]);
});
} catch (error) {
return false;
}
}
export function isValueOutOfRange(value, _ref) {
var min = _ref.min,
max = _ref.max;
return value < min || value > max;
}
export function isNotTouchEvent(e) {
return e.touches.length > 1 || e.type.toLowerCase() === 'touchend' && e.touches.length > 0;
}
export function getClosestPoint(val, _ref2) {
var marks = _ref2.marks,
step = _ref2.step,
min = _ref2.min,
max = _ref2.max;
var points = Object.keys(marks).map(parseFloat);
if (step !== null) {
var maxSteps = Math.floor((max - min) / step);
var steps = Math.min((val - min) / step, maxSteps);
var closestStep = Math.round(steps) * step + min;
points.push(closestStep);
}
var diffs = points.map(function (point) {
return Math.abs(val - point);
});
return points[diffs.indexOf(Math.min.apply(Math, _toConsumableArray(diffs)))];
}
export function getPrecision(step) {
var stepString = step.toString();
var precision = 0;
if (stepString.indexOf('.') >= 0) {
precision = stepString.length - stepString.indexOf('.') - 1;
}
return precision;
}
export function getMousePosition(vertical, e) {
return vertical ? e.clientY : e.pageX;
}
export function getTouchPosition(vertical, e) {
return vertical ? e.touches[0].clientY : e.touches[0].pageX;
}
export function getHandleCenterPosition(vertical, handle) {
var coords = handle.getBoundingClientRect();
return vertical ? coords.top + coords.height * 0.5 : window.pageXOffset + coords.left + coords.width * 0.5;
}
export function ensureValueInRange(val, _ref3) {
var max = _ref3.max,
min = _ref3.min;
if (val <= min) {
return min;
}
if (val >= max) {
return max;
}
return val;
}
export function ensureValuePrecision(val, props) {
var step = props.step;
var closestPoint = isFinite(getClosestPoint(val, props)) ? getClosestPoint(val, props) : 0; // eslint-disable-line
return step === null ? closestPoint : parseFloat(closestPoint.toFixed(getPrecision(step)));
}
export function pauseEvent(e) {
e.stopPropagation();
e.preventDefault();
}
export function calculateNextValue(func, value, props) {
var operations = {
increase: function increase(a, b) {
return a + b;
},
decrease: function decrease(a, b) {
return a - b;
}
};
var indexToGet = operations[func](Object.keys(props.marks).indexOf(JSON.stringify(value)), 1);
var keyToGet = Object.keys(props.marks)[indexToGet];
if (props.step) {
return operations[func](value, props.step);
} else if (!!Object.keys(props.marks).length && !!props.marks[keyToGet]) {
return props.marks[keyToGet];
}
return value;
}
export function getKeyboardValueMutator(e, vertical, reverse) {
var increase = 'increase';
var decrease = 'decrease';
var method = increase;
switch (e.keyCode) {
case keyCode.UP:
method = vertical && reverse ? decrease : increase;break;
case keyCode.RIGHT:
method = !vertical && reverse ? decrease : increase;break;
case keyCode.DOWN:
method = vertical && reverse ? increase : decrease;break;
case keyCode.LEFT:
method = !vertical && reverse ? increase : decrease;break;
case keyCode.END:
return function (value, props) {
return props.max;
};
case keyCode.HOME:
return function (value, props) {
return props.min;
};
case keyCode.PAGE_UP:
return function (value, props) {
return value + props.step * 2;
};
case keyCode.PAGE_DOWN:
return function (value, props) {
return value - props.step * 2;
};
default:
return undefined;
}
return function (value, props) {
return calculateNextValue(method, value, props);
};
}