rc-slider
Version:
slider ui component for react
1,580 lines (1,321 loc) • 224 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react-dom"), require("react"));
else if(typeof define === 'function' && define.amd)
define(["react-dom", "react"], factory);
else if(typeof exports === 'object')
exports["rc-slider"] = factory(require("react-dom"), require("react"));
else
root["rc-slider"] = factory(root["ReactDOM"], root["React"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_102__, __WEBPACK_EXTERNAL_MODULE_103__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(1);
module.exports = __webpack_require__(2);
/***/ },
/* 1 */
/***/ function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
module.exports = __webpack_require__(3);
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process) {'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _defineProperty2 = __webpack_require__(5);
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _toConsumableArray2 = __webpack_require__(24);
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _extends2 = __webpack_require__(63);
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = __webpack_require__(70);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(71);
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(94);
var _inherits3 = _interopRequireDefault(_inherits2);
var _reactDom = __webpack_require__(102);
var _react = __webpack_require__(103);
var _react2 = _interopRequireDefault(_react);
var _addEventListener = __webpack_require__(104);
var _addEventListener2 = _interopRequireDefault(_addEventListener);
var _classnames = __webpack_require__(109);
var _classnames2 = _interopRequireDefault(_classnames);
var _Track = __webpack_require__(110);
var _Track2 = _interopRequireDefault(_Track);
var _Handle = __webpack_require__(111);
var _Handle2 = _interopRequireDefault(_Handle);
var _Steps = __webpack_require__(145);
var _Steps2 = _interopRequireDefault(_Steps);
var _Marks = __webpack_require__(147);
var _Marks2 = _interopRequireDefault(_Marks);
var _warning = __webpack_require__(146);
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function noop() {}
function isNotTouchEvent(e) {
return e.touches.length > 1 || e.type.toLowerCase() === 'touchend' && e.touches.length > 0;
}
function getTouchPosition(vertical, e) {
return vertical ? e.touches[0].clientY : e.touches[0].pageX;
}
function getMousePosition(vertical, e) {
return vertical ? e.clientY : e.pageX;
}
function getHandleCenterPosition(vertical, handle) {
var coords = handle.getBoundingClientRect();
return vertical ? coords.top + coords.height * 0.5 : coords.left + coords.width * 0.5;
}
function pauseEvent(e) {
e.stopPropagation();
e.preventDefault();
}
var Slider = function (_React$Component) {
(0, _inherits3.default)(Slider, _React$Component);
function Slider(props) {
(0, _classCallCheck3.default)(this, Slider);
var _this = (0, _possibleConstructorReturn3.default)(this, _React$Component.call(this, props));
var range = props.range,
min = props.min,
max = props.max,
step = props.step;
var initialValue = range ? Array.apply(null, Array(range + 1)).map(function () {
return min;
}) : min;
var defaultValue = 'defaultValue' in props ? props.defaultValue : initialValue;
var value = props.value !== undefined ? props.value : defaultValue;
var bounds = (range ? value : [min, value]).map(function (v) {
return _this.trimAlignValue(v);
});
var recent = void 0;
if (range && bounds[0] === bounds[bounds.length - 1] && bounds[0] === max) {
recent = 0;
} else {
recent = bounds.length - 1;
}
if (process.env.NODE_ENV !== 'production' && step && Math.floor(step) === step && (max - min) % step !== 0) {
(0, _warning2.default)(false, 'Slider[max] - Slider[min] (%s) should be a multiple of Slider[step] (%s)', max - min, step);
}
_this.state = {
handle: null,
recent: recent,
bounds: bounds
};
return _this;
}
Slider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
var _this2 = this;
if (!('value' in nextProps || 'min' in nextProps || 'max' in nextProps)) return;
var bounds = this.state.bounds;
if (nextProps.range) {
var value = nextProps.value || bounds;
var nextBounds = value.map(function (v) {
return _this2.trimAlignValue(v, nextProps);
});
if (nextBounds.every(function (v, i) {
return v === bounds[i];
})) return;
this.setState({ bounds: nextBounds });
if (bounds.some(function (v) {
return _this2.isValueOutOfBounds(v, nextProps);
})) {
this.props.onChange(nextBounds);
}
} else {
var _value = nextProps.value !== undefined ? nextProps.value : bounds[1];
var nextValue = this.trimAlignValue(_value, nextProps);
if (nextValue === bounds[1] && bounds[0] === nextProps.min) return;
this.setState({ bounds: [nextProps.min, nextValue] });
if (this.isValueOutOfBounds(bounds[1], nextProps)) {
this.props.onChange(nextValue);
}
}
};
Slider.prototype.onChange = function onChange(state) {
var props = this.props;
var isNotControlled = !('value' in props);
if (isNotControlled) {
this.setState(state);
} else if (state.handle !== undefined) {
this.setState({ handle: state.handle });
}
var data = (0, _extends3.default)({}, this.state, state);
var changedValue = props.range ? data.bounds : data.bounds[1];
props.onChange(changedValue);
};
Slider.prototype.onMouseDown = function onMouseDown(e) {
if (e.button !== 0) {
return;
}
var position = getMousePosition(this.props.vertical, e);
if (!this.isEventFromHandle(e)) {
this.dragOffset = 0;
} else {
var handlePosition = getHandleCenterPosition(this.props.vertical, e.target);
this.dragOffset = position - handlePosition;
position = handlePosition;
}
this.onStart(position);
this.addDocumentEvents('mouse');
pauseEvent(e);
};
Slider.prototype.onMouseMove = function onMouseMove(e) {
var position = getMousePosition(this.props.vertical, e);
this.onMove(e, position - this.dragOffset);
};
Slider.prototype.onMove = function onMove(e, position) {
pauseEvent(e);
var props = this.props;
var state = this.state;
var diffPosition = position - this.startPosition;
diffPosition = this.props.vertical ? -diffPosition : diffPosition;
var diffValue = diffPosition / this.getSliderLength() * (props.max - props.min);
var value = this.trimAlignValue(this.startValue + diffValue);
var oldValue = state.bounds[state.handle];
if (value === oldValue) return;
var nextBounds = [].concat((0, _toConsumableArray3.default)(state.bounds));
nextBounds[state.handle] = value;
var nextHandle = state.handle;
if (props.pushable !== false) {
var originalValue = state.bounds[nextHandle];
this.pushSurroundingHandles(nextBounds, nextHandle, originalValue);
} else if (props.allowCross) {
nextBounds.sort(function (a, b) {
return a - b;
});
nextHandle = nextBounds.indexOf(value);
}
this.onChange({
handle: nextHandle,
bounds: nextBounds
});
};
Slider.prototype.onStart = function onStart(position) {
var props = this.props;
props.onBeforeChange(this.getValue());
var value = this.calcValueByPos(position);
this.startValue = value;
this.startPosition = position;
var state = this.state;
var bounds = state.bounds;
var valueNeedChanging = 1;
if (this.props.range) {
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 = closestBound + 1;
}
valueNeedChanging = closestBound;
var isAtTheSamePoint = bounds[closestBound + 1] === bounds[closestBound];
if (isAtTheSamePoint) {
valueNeedChanging = state.recent;
}
if (isAtTheSamePoint && value !== bounds[closestBound + 1]) {
valueNeedChanging = value < bounds[closestBound + 1] ? closestBound : closestBound + 1;
}
}
this.setState({
handle: valueNeedChanging,
recent: valueNeedChanging
});
var oldValue = state.bounds[valueNeedChanging];
if (value === oldValue) return;
var nextBounds = [].concat((0, _toConsumableArray3.default)(state.bounds));
nextBounds[valueNeedChanging] = value;
this.onChange({ bounds: nextBounds });
};
Slider.prototype.onTouchMove = function onTouchMove(e) {
if (isNotTouchEvent(e)) {
this.end('touch');
return;
}
var position = getTouchPosition(this.props.vertical, e);
this.onMove(e, position - this.dragOffset);
};
Slider.prototype.onTouchStart = function onTouchStart(e) {
if (isNotTouchEvent(e)) return;
var position = getTouchPosition(this.props.vertical, e);
if (!this.isEventFromHandle(e)) {
this.dragOffset = 0;
} else {
var handlePosition = getHandleCenterPosition(this.props.vertical, e.target);
this.dragOffset = position - handlePosition;
position = handlePosition;
}
this.onStart(position);
this.addDocumentEvents('touch');
pauseEvent(e);
};
/**
* Returns an array of possible slider points, taking into account both
* `marks` and `step`. The result is cached.
*/
Slider.prototype.getPoints = function getPoints() {
var _props = this.props,
marks = _props.marks,
step = _props.step,
min = _props.min,
max = _props.max;
var cache = this._getPointsCache;
if (!cache || cache.marks !== marks || cache.step !== step) {
var pointsObject = (0, _extends3.default)({}, 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;
};
Slider.prototype.getPrecision = function getPrecision(step) {
var stepString = step.toString();
var precision = 0;
if (stepString.indexOf('.') >= 0) {
precision = stepString.length - stepString.indexOf('.') - 1;
}
return precision;
};
Slider.prototype.getSliderLength = function getSliderLength() {
var slider = this.refs.slider;
if (!slider) {
return 0;
}
return this.props.vertical ? slider.clientHeight : slider.clientWidth;
};
Slider.prototype.getSliderStart = function getSliderStart() {
var slider = this.refs.slider;
var rect = slider.getBoundingClientRect();
return this.props.vertical ? rect.top : rect.left;
};
Slider.prototype.getValue = function getValue() {
var bounds = this.state.bounds;
return this.props.range ? bounds : bounds[1];
};
Slider.prototype.addDocumentEvents = function addDocumentEvents(type) {
if (type === 'touch') {
// just work for chrome iOS Safari and Android Browser
this.onTouchMoveListener = (0, _addEventListener2.default)(document, 'touchmove', this.onTouchMove.bind(this));
this.onTouchUpListener = (0, _addEventListener2.default)(document, 'touchend', this.end.bind(this, 'touch'));
} else if (type === 'mouse') {
this.onMouseMoveListener = (0, _addEventListener2.default)(document, 'mousemove', this.onMouseMove.bind(this));
this.onMouseUpListener = (0, _addEventListener2.default)(document, 'mouseup', this.end.bind(this, 'mouse'));
}
};
Slider.prototype.calcOffset = function calcOffset(value) {
var _props2 = this.props,
min = _props2.min,
max = _props2.max;
var ratio = (value - min) / (max - min);
return ratio * 100;
};
Slider.prototype.calcValue = function calcValue(offset) {
var _props3 = this.props,
vertical = _props3.vertical,
min = _props3.min,
max = _props3.max;
var ratio = Math.abs(offset / this.getSliderLength());
var value = vertical ? (1 - ratio) * (max - min) + min : ratio * (max - min) + min;
return value;
};
Slider.prototype.calcValueByPos = function calcValueByPos(position) {
var pixelOffset = position - this.getSliderStart();
var nextValue = this.trimAlignValue(this.calcValue(pixelOffset));
return nextValue;
};
Slider.prototype.end = function end(type) {
this.removeEvents(type);
this.props.onAfterChange(this.getValue());
this.setState({ handle: null });
};
Slider.prototype.isEventFromHandle = function isEventFromHandle(e) {
var _this3 = this;
return this.state.bounds.some(function (x, i) {
return _this3.refs['handle-' + i] && e.target === (0, _reactDom.findDOMNode)(_this3.refs['handle-' + i]);
});
};
Slider.prototype.isValueOutOfBounds = function isValueOutOfBounds(value, props) {
return value < props.min || value > props.max;
};
Slider.prototype.pushHandle = 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;
};
Slider.prototype.pushHandleOnePoint = 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;
};
Slider.prototype.pushSurroundingHandles = function pushSurroundingHandles(bounds, handle, originalValue) {
var threshold = this.props.pushable;
var value = bounds[handle];
var direction = 0;
if (bounds[handle + 1] - value < threshold) {
direction = +1;
} else if (value - bounds[handle - 1] < threshold) {
direction = -1;
}
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] = originalValue;
}
};
Slider.prototype.removeEvents = function removeEvents(type) {
if (type === 'touch') {
this.onTouchMoveListener.remove();
this.onTouchUpListener.remove();
} else if (type === 'mouse') {
this.onMouseMoveListener.remove();
this.onMouseUpListener.remove();
}
};
Slider.prototype.trimAlignValue = function trimAlignValue(v, nextProps) {
var state = this.state || {};
var handle = state.handle,
bounds = state.bounds;
var _props4 = (0, _extends3.default)({}, this.props, nextProps || {}),
marks = _props4.marks,
step = _props4.step,
min = _props4.min,
max = _props4.max,
allowCross = _props4.allowCross;
var val = v;
if (val <= min) {
val = min;
}
if (val >= max) {
val = max;
}
/* eslint-disable eqeqeq */
if (!allowCross && handle != null && handle > 0 && val <= bounds[handle - 1]) {
val = bounds[handle - 1];
}
if (!allowCross && handle != null && handle < bounds.length - 1 && val >= bounds[handle + 1]) {
val = bounds[handle + 1];
}
/* eslint-enable eqeqeq */
var points = Object.keys(marks).map(parseFloat);
if (step !== null) {
var closestStep = Math.round((val - min) / step) * step + min;
points.push(closestStep);
}
var diffs = points.map(function (point) {
return Math.abs(val - point);
});
var closestPoint = points[diffs.indexOf(Math.min.apply(Math, diffs))];
return step !== null ? parseFloat(closestPoint.toFixed(this.getPrecision(step))) : closestPoint;
};
Slider.prototype.render = function render() {
var _this4 = this,
_classNames3;
var _state = this.state,
handle = _state.handle,
bounds = _state.bounds;
var _props5 = this.props,
className = _props5.className,
prefixCls = _props5.prefixCls,
tooltipPrefixCls = _props5.tooltipPrefixCls,
disabled = _props5.disabled,
vertical = _props5.vertical,
dots = _props5.dots,
included = _props5.included,
range = _props5.range,
step = _props5.step,
marks = _props5.marks,
max = _props5.max,
min = _props5.min,
tipTransitionName = _props5.tipTransitionName,
tipFormatter = _props5.tipFormatter,
children = _props5.children;
var customHandle = this.props.handle;
var offsets = bounds.map(function (v) {
return _this4.calcOffset(v);
});
var handleClassName = prefixCls + '-handle';
var handlesClassNames = bounds.map(function (v, i) {
var _classNames;
return (0, _classnames2.default)((_classNames = {}, (0, _defineProperty3.default)(_classNames, handleClassName, true), (0, _defineProperty3.default)(_classNames, handleClassName + '-' + (i + 1), true), (0, _defineProperty3.default)(_classNames, handleClassName + '-lower', i === 0), (0, _defineProperty3.default)(_classNames, handleClassName + '-upper', i === bounds.length - 1), _classNames));
});
var isNoTip = step === null || tipFormatter === null;
var commonHandleProps = {
prefixCls: prefixCls,
tooltipPrefixCls: tooltipPrefixCls,
noTip: isNoTip,
tipTransitionName: tipTransitionName,
tipFormatter: tipFormatter,
vertical: vertical
};
var handles = bounds.map(function (v, i) {
return (0, _react.cloneElement)(customHandle, (0, _extends3.default)({}, commonHandleProps, {
className: handlesClassNames[i],
value: v,
offset: offsets[i],
dragging: handle === i,
index: i,
key: i,
ref: 'handle-' + i
}));
});
if (!range) {
handles.shift();
}
var isIncluded = included || range;
var tracks = [];
for (var i = 1; i < bounds.length; ++i) {
var _classNames2;
var trackClassName = (0, _classnames2.default)((_classNames2 = {}, (0, _defineProperty3.default)(_classNames2, prefixCls + '-track', true), (0, _defineProperty3.default)(_classNames2, prefixCls + '-track-' + i, true), _classNames2));
tracks.push(_react2.default.createElement(_Track2.default, { className: trackClassName, vertical: vertical, included: isIncluded,
offset: offsets[i - 1], length: offsets[i] - offsets[i - 1], key: i
}));
}
var sliderClassName = (0, _classnames2.default)((_classNames3 = {}, (0, _defineProperty3.default)(_classNames3, prefixCls, true), (0, _defineProperty3.default)(_classNames3, prefixCls + '-with-marks', Object.keys(marks).length), (0, _defineProperty3.default)(_classNames3, prefixCls + '-disabled', disabled), (0, _defineProperty3.default)(_classNames3, prefixCls + '-vertical', this.props.vertical), (0, _defineProperty3.default)(_classNames3, className, !!className), _classNames3));
return _react2.default.createElement(
'div',
{ ref: 'slider', className: sliderClassName,
onTouchStart: disabled ? noop : this.onTouchStart.bind(this),
onMouseDown: disabled ? noop : this.onMouseDown.bind(this)
},
_react2.default.createElement('div', { className: prefixCls + '-rail' }),
tracks,
_react2.default.createElement(_Steps2.default, { prefixCls: prefixCls, vertical: vertical, marks: marks, dots: dots, step: step,
included: isIncluded, lowerBound: bounds[0],
upperBound: bounds[bounds.length - 1], max: max, min: min
}),
handles,
_react2.default.createElement(_Marks2.default, { className: prefixCls + '-mark', vertical: vertical, marks: marks,
included: isIncluded, lowerBound: bounds[0],
upperBound: bounds[bounds.length - 1], max: max, min: min
}),
children
);
};
return Slider;
}(_react2.default.Component);
Slider.propTypes = {
min: _react2.default.PropTypes.number,
max: _react2.default.PropTypes.number,
step: _react2.default.PropTypes.number,
defaultValue: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.number, _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.number)]),
value: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.number, _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.number)]),
marks: _react2.default.PropTypes.object,
included: _react2.default.PropTypes.bool,
className: _react2.default.PropTypes.string,
prefixCls: _react2.default.PropTypes.string,
tooltipPrefixCls: _react2.default.PropTypes.string,
disabled: _react2.default.PropTypes.bool,
children: _react2.default.PropTypes.any,
onBeforeChange: _react2.default.PropTypes.func,
onChange: _react2.default.PropTypes.func,
onAfterChange: _react2.default.PropTypes.func,
handle: _react2.default.PropTypes.element,
tipTransitionName: _react2.default.PropTypes.string,
tipFormatter: _react2.default.PropTypes.func,
dots: _react2.default.PropTypes.bool,
range: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.bool, _react2.default.PropTypes.number]),
vertical: _react2.default.PropTypes.bool,
allowCross: _react2.default.PropTypes.bool,
pushable: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.bool, _react2.default.PropTypes.number])
};
Slider.defaultProps = {
prefixCls: 'rc-slider',
className: '',
tipTransitionName: '',
min: 0,
max: 100,
step: 1,
marks: {},
handle: _react2.default.createElement(_Handle2.default, null),
onBeforeChange: noop,
onChange: noop,
onAfterChange: noop,
tipFormatter: function tipFormatter(value) {
return value;
},
included: true,
disabled: false,
dots: false,
range: false,
vertical: false,
allowCross: true,
pushable: false
};
exports.default = Slider;
module.exports = exports['default'];
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
/***/ },
/* 4 */
/***/ function(module, exports) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _defineProperty = __webpack_require__(6);
var _defineProperty2 = _interopRequireDefault(_defineProperty);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (obj, key, value) {
if (key in obj) {
(0, _defineProperty2.default)(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
};
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(7), __esModule: true };
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(8);
var $Object = __webpack_require__(11).Object;
module.exports = function defineProperty(it, key, desc){
return $Object.defineProperty(it, key, desc);
};
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
var $export = __webpack_require__(9);
// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
$export($export.S + $export.F * !__webpack_require__(19), 'Object', {defineProperty: __webpack_require__(15).f});
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
var global = __webpack_require__(10)
, core = __webpack_require__(11)
, ctx = __webpack_require__(12)
, hide = __webpack_require__(14)
, PROTOTYPE = 'prototype';
var $export = function(type, name, source){
var IS_FORCED = type & $export.F
, IS_GLOBAL = type & $export.G
, IS_STATIC = type & $export.S
, IS_PROTO = type & $export.P
, IS_BIND = type & $export.B
, IS_WRAP = type & $export.W
, exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
, expProto = exports[PROTOTYPE]
, target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]
, key, own, out;
if(IS_GLOBAL)source = name;
for(key in source){
// contains in native
own = !IS_FORCED && target && target[key] !== undefined;
if(own && key in exports)continue;
// export native or passed
out = own ? target[key] : source[key];
// prevent global pollution for namespaces
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
// bind timers to global for call from export context
: IS_BIND && own ? ctx(out, global)
// wrap global constructors for prevent change them in library
: IS_WRAP && target[key] == out ? (function(C){
var F = function(a, b, c){
if(this instanceof C){
switch(arguments.length){
case 0: return new C;
case 1: return new C(a);
case 2: return new C(a, b);
} return new C(a, b, c);
} return C.apply(this, arguments);
};
F[PROTOTYPE] = C[PROTOTYPE];
return F;
// make static versions for prototype methods
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
if(IS_PROTO){
(exports.virtual || (exports.virtual = {}))[key] = out;
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out);
}
}
};
// type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
module.exports = $export;
/***/ },
/* 10 */
/***/ function(module, exports) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math
? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
/***/ },
/* 11 */
/***/ function(module, exports) {
var core = module.exports = {version: '2.4.0'};
if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
/***/ },
/* 12 */
/***/ function(module, exports, __webpack_require__) {
// optional / simple context binding
var aFunction = __webpack_require__(13);
module.exports = function(fn, that, length){
aFunction(fn);
if(that === undefined)return fn;
switch(length){
case 1: return function(a){
return fn.call(that, a);
};
case 2: return function(a, b){
return fn.call(that, a, b);
};
case 3: return function(a, b, c){
return fn.call(that, a, b, c);
};
}
return function(/* ...args */){
return fn.apply(that, arguments);
};
};
/***/ },
/* 13 */
/***/ function(module, exports) {
module.exports = function(it){
if(typeof it != 'function')throw TypeError(it + ' is not a function!');
return it;
};
/***/ },
/* 14 */
/***/ function(module, exports, __webpack_require__) {
var dP = __webpack_require__(15)
, createDesc = __webpack_require__(23);
module.exports = __webpack_require__(19) ? function(object, key, value){
return dP.f(object, key, createDesc(1, value));
} : function(object, key, value){
object[key] = value;
return object;
};
/***/ },
/* 15 */
/***/ function(module, exports, __webpack_require__) {
var anObject = __webpack_require__(16)
, IE8_DOM_DEFINE = __webpack_require__(18)
, toPrimitive = __webpack_require__(22)
, dP = Object.defineProperty;
exports.f = __webpack_require__(19) ? Object.defineProperty : function defineProperty(O, P, Attributes){
anObject(O);
P = toPrimitive(P, true);
anObject(Attributes);
if(IE8_DOM_DEFINE)try {
return dP(O, P, Attributes);
} catch(e){ /* empty */ }
if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
if('value' in Attributes)O[P] = Attributes.value;
return O;
};
/***/ },
/* 16 */
/***/ function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(17);
module.exports = function(it){
if(!isObject(it))throw TypeError(it + ' is not an object!');
return it;
};
/***/ },
/* 17 */
/***/ function(module, exports) {
module.exports = function(it){
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
/***/ },
/* 18 */
/***/ function(module, exports, __webpack_require__) {
module.exports = !__webpack_require__(19) && !__webpack_require__(20)(function(){
return Object.defineProperty(__webpack_require__(21)('div'), 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ },
/* 19 */
/***/ function(module, exports, __webpack_require__) {
// Thank's IE8 for his funny defineProperty
module.exports = !__webpack_require__(20)(function(){
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ },
/* 20 */
/***/ function(module, exports) {
module.exports = function(exec){
try {
return !!exec();
} catch(e){
return true;
}
};
/***/ },
/* 21 */
/***/ function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(17)
, document = __webpack_require__(10).document
// in old IE typeof document.createElement is 'object'
, is = isObject(document) && isObject(document.createElement);
module.exports = function(it){
return is ? document.createElement(it) : {};
};
/***/ },
/* 22 */
/***/ function(module, exports, __webpack_require__) {
// 7.1.1 ToPrimitive(input [, PreferredType])
var isObject = __webpack_require__(17);
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
module.exports = function(it, S){
if(!isObject(it))return it;
var fn, val;
if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
throw TypeError("Can't convert object to primitive value");
};
/***/ },
/* 23 */
/***/ function(module, exports) {
module.exports = function(bitmap, value){
return {
enumerable : !(bitmap & 1),
configurable: !(bitmap & 2),
writable : !(bitmap & 4),
value : value
};
};
/***/ },
/* 24 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _from = __webpack_require__(25);
var _from2 = _interopRequireDefault(_from);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
arr2[i] = arr[i];
}
return arr2;
} else {
return (0, _from2.default)(arr);
}
};
/***/ },
/* 25 */
/***/ function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(26), __esModule: true };
/***/ },
/* 26 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(27);
__webpack_require__(56);
module.exports = __webpack_require__(11).Array.from;
/***/ },
/* 27 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var $at = __webpack_require__(28)(true);
// 21.1.3.27 String.prototype[@@iterator]()
__webpack_require__(31)(String, 'String', function(iterated){
this._t = String(iterated); // target
this._i = 0; // next index
// 21.1.5.2.1 %StringIteratorPrototype%.next()
}, function(){
var O = this._t
, index = this._i
, point;
if(index >= O.length)return {value: undefined, done: true};
point = $at(O, index);
this._i += point.length;
return {value: point, done: false};
});
/***/ },
/* 28 */
/***/ function(module, exports, __webpack_require__) {
var toInteger = __webpack_require__(29)
, defined = __webpack_require__(30);
// true -> String#at
// false -> String#codePointAt
module.exports = function(TO_STRING){
return function(that, pos){
var s = String(defined(that))
, i = toInteger(pos)
, l = s.length
, a, b;
if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
a = s.charCodeAt(i);
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
? TO_STRING ? s.charAt(i) : a
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
};
};
/***/ },
/* 29 */
/***/ function(module, exports) {
// 7.1.4 ToInteger
var ceil = Math.ceil
, floor = Math.floor;
module.exports = function(it){
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
/***/ },
/* 30 */
/***/ function(module, exports) {
// 7.2.1 RequireObjectCoercible(argument)
module.exports = function(it){
if(it == undefined)throw TypeError("Can't call method on " + it);
return it;
};
/***/ },
/* 31 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var LIBRARY = __webpack_require__(32)
, $export = __webpack_require__(9)
, redefine = __webpack_require__(33)
, hide = __webpack_require__(14)
, has = __webpack_require__(34)
, Iterators = __webpack_require__(35)
, $iterCreate = __webpack_require__(36)
, setToStringTag = __webpack_require__(52)
, getPrototypeOf = __webpack_require__(54)
, ITERATOR = __webpack_require__(53)('iterator')
, BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
, FF_ITERATOR = '@@iterator'
, KEYS = 'keys'
, VALUES = 'values';
var returnThis = function(){ return this; };
module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){
$iterCreate(Constructor, NAME, next);
var getMethod = function(kind){
if(!BUGGY && kind in proto)return proto[kind];
switch(kind){
case KEYS: return function keys(){ return new Constructor(this, kind); };
case VALUES: return function values(){ return new Constructor(this, kind); };
} return function entries(){ return new Constructor(this, kind); };
};
var TAG = NAME + ' Iterator'
, DEF_VALUES = DEFAULT == VALUES
, VALUES_BUG = false
, proto = Base.prototype
, $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
, $default = $native || getMethod(DEFAULT)
, $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined
, $anyNative = NAME == 'Array' ? proto.entries || $native : $native
, methods, key, IteratorPrototype;
// Fix native
if($anyNative){
IteratorPrototype = getPrototypeOf($anyNative.call(new Base));
if(IteratorPrototype !== Object.prototype){
// Set @@toStringTag to native iterators
setToStringTag(IteratorPrototype, TAG, true);
// fix for some old engines
if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);
}
}
// fix Array#{values, @@iterator}.name in V8 / FF
if(DEF_VALUES && $native && $native.name !== VALUES){
VALUES_BUG = true;
$default = function values(){ return $native.call(this); };
}
// Define iterator
if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){
hide(proto, ITERATOR, $default);
}
// Plug for library
Iterators[NAME] = $default;
Iterators[TAG] = returnThis;
if(DEFAULT){
methods = {
values: DEF_VALUES ? $default : getMethod(VALUES),
keys: IS_SET ? $default : getMethod(KEYS),
entries: $entries
};
if(FORCED)for(key in methods){
if(!(key in proto))redefine(proto, key, methods[key]);
} else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
}
return methods;
};
/***/ },
/* 32 */
/***/ function(module, exports) {
module.exports = true;
/***/ },
/* 33 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(14);
/***/ },
/* 34 */
/***/ function(module, exports) {
var hasOwnProperty = {}.hasOwnProperty;
module.exports = function(it, key){
return hasOwnProperty.call(it, key);
};
/***/ },
/* 35 */
/***/ function(module, exports) {
module.exports = {};
/***/ },
/* 36 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var create = __webpack_require__(37)
, descriptor = __webpack_require__(23)
, setToStringTag = __webpack_require__(52)
, IteratorPrototype = {};
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
__webpack_require__(14)(IteratorPrototype, __webpack_require__(53)('iterator'), function(){ return this; });
module.exports = function(Constructor, NAME, next){
Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)});
setToStringTag(Constructor, NAME + ' Iterator');
};
/***/ },
/* 37 */
/***/ function(module, exports, __webpack_require__) {
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
var anObject = __webpack_require__(16)
, dPs = __webpack_require__(38)
, enumBugKeys = __webpack_require__(50)
, IE_PROTO = __webpack_require__(47)('IE_PROTO')
, Empty = function(){ /* empty */ }
, PROTOTYPE = 'prototype';
// Create object with fake `null` prototype: use iframe Object with cleared prototype
var createDict = function(){
// Thrash, waste and sodomy: IE GC bug
var iframe = __webpack_require__(21)('iframe')
, i = enumBugKeys.length
, lt = '<'
, gt = '>'
, iframeDocument;
iframe.style.display = 'none';
__webpack_require__(51).appendChild(iframe);
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
// createDict = iframe.contentWindow.Object;
// html.removeChild(iframe);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];
return createDict();
};
module.exports = Object.create || function create(O, Properties){
var result;
if(O !== null){
Empty[PROTOTYPE] = anObject(O);
result = new Empty;
Empty[PROTOTYPE] = null;
// add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO] = O;
} else result = createDict();
return Properties === undefined ? result : dPs(result, Properties);
};
/***/ },
/* 38 */
/***/ function(module, exports, __webpack_require__) {
var dP = __webpack_require__(15)
, anObject = __webpack_require__(16)
, getKeys = __webpack_require__(39);
module.exports = __webpack_require__(19) ? Object.defineProperties : function defineProperties(O, Properties){
anObject(O);
var keys = getKeys(Properties)
, length = keys.length
, i = 0
, P;
while(length > i)dP.f(O, P = keys[i++], Properties[P]);
return O;
};
/***/ },
/* 39 */
/***/ function(module, exports, __webpack_require__) {
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
var $keys = __webpack_require__(40)
, enumBugKeys = __webpack_require__(50);
module.exports = Object.keys || function keys(O){
return $keys(O, enumBugKeys);
};
/***/ },
/* 40 */
/***/ function(module, exports, __webpack_require__) {
var has = __webpack_require__(34)
, toIObject = __webpack_require__(41)
, arrayIndexOf = __webpack_require__(44)(false)
, IE_PROTO = __webpack_require__(47)('IE_PROTO');
module.exports = function(object, names){
var O = toIObject(object)
, i = 0
, result = []
, key;
for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
// Don't enum bug & hidden keys
while(names.length > i)if(has(O, key = names[i++])){
~arrayIndexOf(result, key) || result.push(key);
}
return result;
};
/***/ },
/* 41 */
/***/ function(module, exports, __webpack_require__) {
// to indexed object, toObject with fallback for non-a