Latest updates from IceHrmPro
This commit is contained in:
395
web/node_modules/rc-animate/lib/Animate.js
generated
vendored
Normal file
395
web/node_modules/rc-animate/lib/Animate.js
generated
vendored
Normal file
@@ -0,0 +1,395 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _extends2 = require('babel-runtime/helpers/extends');
|
||||
|
||||
var _extends3 = _interopRequireDefault(_extends2);
|
||||
|
||||
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
||||
|
||||
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
||||
|
||||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
||||
|
||||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
||||
|
||||
var _createClass2 = require('babel-runtime/helpers/createClass');
|
||||
|
||||
var _createClass3 = _interopRequireDefault(_createClass2);
|
||||
|
||||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
||||
|
||||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
||||
|
||||
var _inherits2 = require('babel-runtime/helpers/inherits');
|
||||
|
||||
var _inherits3 = _interopRequireDefault(_inherits2);
|
||||
|
||||
var _react = require('react');
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _propTypes = require('prop-types');
|
||||
|
||||
var _propTypes2 = _interopRequireDefault(_propTypes);
|
||||
|
||||
var _unsafeLifecyclesPolyfill = require('rc-util/lib/unsafeLifecyclesPolyfill');
|
||||
|
||||
var _unsafeLifecyclesPolyfill2 = _interopRequireDefault(_unsafeLifecyclesPolyfill);
|
||||
|
||||
var _ChildrenUtils = require('./ChildrenUtils');
|
||||
|
||||
var _AnimateChild = require('./AnimateChild');
|
||||
|
||||
var _AnimateChild2 = _interopRequireDefault(_AnimateChild);
|
||||
|
||||
var _animate = require('./util/animate');
|
||||
|
||||
var _animate2 = _interopRequireDefault(_animate);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
var defaultKey = 'rc_animate_' + Date.now();
|
||||
|
||||
function getChildrenFromProps(props) {
|
||||
var children = props.children;
|
||||
if (_react2['default'].isValidElement(children)) {
|
||||
if (!children.key) {
|
||||
return _react2['default'].cloneElement(children, {
|
||||
key: defaultKey
|
||||
});
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
var Animate = function (_React$Component) {
|
||||
(0, _inherits3['default'])(Animate, _React$Component);
|
||||
|
||||
// eslint-disable-line
|
||||
|
||||
function Animate(props) {
|
||||
(0, _classCallCheck3['default'])(this, Animate);
|
||||
|
||||
var _this = (0, _possibleConstructorReturn3['default'])(this, (Animate.__proto__ || Object.getPrototypeOf(Animate)).call(this, props));
|
||||
|
||||
_initialiseProps.call(_this);
|
||||
|
||||
_this.currentlyAnimatingKeys = {};
|
||||
_this.keysToEnter = [];
|
||||
_this.keysToLeave = [];
|
||||
|
||||
_this.state = {
|
||||
children: (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props))
|
||||
};
|
||||
|
||||
_this.childrenRefs = {};
|
||||
return _this;
|
||||
}
|
||||
|
||||
(0, _createClass3['default'])(Animate, [{
|
||||
key: 'componentDidMount',
|
||||
value: function componentDidMount() {
|
||||
var _this2 = this;
|
||||
|
||||
var showProp = this.props.showProp;
|
||||
var children = this.state.children;
|
||||
if (showProp) {
|
||||
children = children.filter(function (child) {
|
||||
return !!child.props[showProp];
|
||||
});
|
||||
}
|
||||
children.forEach(function (child) {
|
||||
if (child) {
|
||||
_this2.performAppear(child.key);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillReceiveProps',
|
||||
value: function componentWillReceiveProps(nextProps) {
|
||||
var _this3 = this;
|
||||
|
||||
this.nextProps = nextProps;
|
||||
var nextChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(nextProps));
|
||||
var props = this.props;
|
||||
// exclusive needs immediate response
|
||||
if (props.exclusive) {
|
||||
Object.keys(this.currentlyAnimatingKeys).forEach(function (key) {
|
||||
_this3.stop(key);
|
||||
});
|
||||
}
|
||||
var showProp = props.showProp;
|
||||
var currentlyAnimatingKeys = this.currentlyAnimatingKeys;
|
||||
// last props children if exclusive
|
||||
var currentChildren = props.exclusive ? (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props)) : this.state.children;
|
||||
// in case destroy in showProp mode
|
||||
var newChildren = [];
|
||||
if (showProp) {
|
||||
currentChildren.forEach(function (currentChild) {
|
||||
var nextChild = currentChild && (0, _ChildrenUtils.findChildInChildrenByKey)(nextChildren, currentChild.key);
|
||||
var newChild = void 0;
|
||||
if ((!nextChild || !nextChild.props[showProp]) && currentChild.props[showProp]) {
|
||||
newChild = _react2['default'].cloneElement(nextChild || currentChild, (0, _defineProperty3['default'])({}, showProp, true));
|
||||
} else {
|
||||
newChild = nextChild;
|
||||
}
|
||||
if (newChild) {
|
||||
newChildren.push(newChild);
|
||||
}
|
||||
});
|
||||
nextChildren.forEach(function (nextChild) {
|
||||
if (!nextChild || !(0, _ChildrenUtils.findChildInChildrenByKey)(currentChildren, nextChild.key)) {
|
||||
newChildren.push(nextChild);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
newChildren = (0, _ChildrenUtils.mergeChildren)(currentChildren, nextChildren);
|
||||
}
|
||||
|
||||
// need render to avoid update
|
||||
this.setState({
|
||||
children: newChildren
|
||||
});
|
||||
|
||||
nextChildren.forEach(function (child) {
|
||||
var key = child && child.key;
|
||||
if (child && currentlyAnimatingKeys[key]) {
|
||||
return;
|
||||
}
|
||||
var hasPrev = child && (0, _ChildrenUtils.findChildInChildrenByKey)(currentChildren, key);
|
||||
if (showProp) {
|
||||
var showInNext = child.props[showProp];
|
||||
if (hasPrev) {
|
||||
var showInNow = (0, _ChildrenUtils.findShownChildInChildrenByKey)(currentChildren, key, showProp);
|
||||
if (!showInNow && showInNext) {
|
||||
_this3.keysToEnter.push(key);
|
||||
}
|
||||
} else if (showInNext) {
|
||||
_this3.keysToEnter.push(key);
|
||||
}
|
||||
} else if (!hasPrev) {
|
||||
_this3.keysToEnter.push(key);
|
||||
}
|
||||
});
|
||||
|
||||
currentChildren.forEach(function (child) {
|
||||
var key = child && child.key;
|
||||
if (child && currentlyAnimatingKeys[key]) {
|
||||
return;
|
||||
}
|
||||
var hasNext = child && (0, _ChildrenUtils.findChildInChildrenByKey)(nextChildren, key);
|
||||
if (showProp) {
|
||||
var showInNow = child.props[showProp];
|
||||
if (hasNext) {
|
||||
var showInNext = (0, _ChildrenUtils.findShownChildInChildrenByKey)(nextChildren, key, showProp);
|
||||
if (!showInNext && showInNow) {
|
||||
_this3.keysToLeave.push(key);
|
||||
}
|
||||
} else if (showInNow) {
|
||||
_this3.keysToLeave.push(key);
|
||||
}
|
||||
} else if (!hasNext) {
|
||||
_this3.keysToLeave.push(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'componentDidUpdate',
|
||||
value: function componentDidUpdate() {
|
||||
var keysToEnter = this.keysToEnter;
|
||||
this.keysToEnter = [];
|
||||
keysToEnter.forEach(this.performEnter);
|
||||
var keysToLeave = this.keysToLeave;
|
||||
this.keysToLeave = [];
|
||||
keysToLeave.forEach(this.performLeave);
|
||||
}
|
||||
}, {
|
||||
key: 'isValidChildByKey',
|
||||
value: function isValidChildByKey(currentChildren, key) {
|
||||
var showProp = this.props.showProp;
|
||||
if (showProp) {
|
||||
return (0, _ChildrenUtils.findShownChildInChildrenByKey)(currentChildren, key, showProp);
|
||||
}
|
||||
return (0, _ChildrenUtils.findChildInChildrenByKey)(currentChildren, key);
|
||||
}
|
||||
}, {
|
||||
key: 'stop',
|
||||
value: function stop(key) {
|
||||
delete this.currentlyAnimatingKeys[key];
|
||||
var component = this.childrenRefs[key];
|
||||
if (component) {
|
||||
component.stop();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var _this4 = this;
|
||||
|
||||
var props = this.props;
|
||||
this.nextProps = props;
|
||||
var stateChildren = this.state.children;
|
||||
var children = null;
|
||||
if (stateChildren) {
|
||||
children = stateChildren.map(function (child) {
|
||||
if (child === null || child === undefined) {
|
||||
return child;
|
||||
}
|
||||
if (!child.key) {
|
||||
throw new Error('must set key for <rc-animate> children');
|
||||
}
|
||||
return _react2['default'].createElement(
|
||||
_AnimateChild2['default'],
|
||||
{
|
||||
key: child.key,
|
||||
ref: function ref(node) {
|
||||
_this4.childrenRefs[child.key] = node;
|
||||
},
|
||||
animation: props.animation,
|
||||
transitionName: props.transitionName,
|
||||
transitionEnter: props.transitionEnter,
|
||||
transitionAppear: props.transitionAppear,
|
||||
transitionLeave: props.transitionLeave
|
||||
},
|
||||
child
|
||||
);
|
||||
});
|
||||
}
|
||||
var Component = props.component;
|
||||
if (Component) {
|
||||
var passedProps = props;
|
||||
if (typeof Component === 'string') {
|
||||
passedProps = (0, _extends3['default'])({
|
||||
className: props.className,
|
||||
style: props.style
|
||||
}, props.componentProps);
|
||||
}
|
||||
return _react2['default'].createElement(
|
||||
Component,
|
||||
passedProps,
|
||||
children
|
||||
);
|
||||
}
|
||||
return children[0] || null;
|
||||
}
|
||||
}]);
|
||||
return Animate;
|
||||
}(_react2['default'].Component);
|
||||
|
||||
Animate.isAnimate = true;
|
||||
Animate.propTypes = {
|
||||
className: _propTypes2['default'].string,
|
||||
style: _propTypes2['default'].object,
|
||||
component: _propTypes2['default'].any,
|
||||
componentProps: _propTypes2['default'].object,
|
||||
animation: _propTypes2['default'].object,
|
||||
transitionName: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].object]),
|
||||
transitionEnter: _propTypes2['default'].bool,
|
||||
transitionAppear: _propTypes2['default'].bool,
|
||||
exclusive: _propTypes2['default'].bool,
|
||||
transitionLeave: _propTypes2['default'].bool,
|
||||
onEnd: _propTypes2['default'].func,
|
||||
onEnter: _propTypes2['default'].func,
|
||||
onLeave: _propTypes2['default'].func,
|
||||
onAppear: _propTypes2['default'].func,
|
||||
showProp: _propTypes2['default'].string,
|
||||
children: _propTypes2['default'].node
|
||||
};
|
||||
Animate.defaultProps = {
|
||||
animation: {},
|
||||
component: 'span',
|
||||
componentProps: {},
|
||||
transitionEnter: true,
|
||||
transitionLeave: true,
|
||||
transitionAppear: false,
|
||||
onEnd: noop,
|
||||
onEnter: noop,
|
||||
onLeave: noop,
|
||||
onAppear: noop
|
||||
};
|
||||
|
||||
var _initialiseProps = function _initialiseProps() {
|
||||
var _this5 = this;
|
||||
|
||||
this.performEnter = function (key) {
|
||||
// may already remove by exclusive
|
||||
if (_this5.childrenRefs[key]) {
|
||||
_this5.currentlyAnimatingKeys[key] = true;
|
||||
_this5.childrenRefs[key].componentWillEnter(_this5.handleDoneAdding.bind(_this5, key, 'enter'));
|
||||
}
|
||||
};
|
||||
|
||||
this.performAppear = function (key) {
|
||||
if (_this5.childrenRefs[key]) {
|
||||
_this5.currentlyAnimatingKeys[key] = true;
|
||||
_this5.childrenRefs[key].componentWillAppear(_this5.handleDoneAdding.bind(_this5, key, 'appear'));
|
||||
}
|
||||
};
|
||||
|
||||
this.handleDoneAdding = function (key, type) {
|
||||
var props = _this5.props;
|
||||
delete _this5.currentlyAnimatingKeys[key];
|
||||
// if update on exclusive mode, skip check
|
||||
if (props.exclusive && props !== _this5.nextProps) {
|
||||
return;
|
||||
}
|
||||
var currentChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props));
|
||||
if (!_this5.isValidChildByKey(currentChildren, key)) {
|
||||
// exclusive will not need this
|
||||
_this5.performLeave(key);
|
||||
} else if (type === 'appear') {
|
||||
if (_animate2['default'].allowAppearCallback(props)) {
|
||||
props.onAppear(key);
|
||||
props.onEnd(key, true);
|
||||
}
|
||||
} else if (_animate2['default'].allowEnterCallback(props)) {
|
||||
props.onEnter(key);
|
||||
props.onEnd(key, true);
|
||||
}
|
||||
};
|
||||
|
||||
this.performLeave = function (key) {
|
||||
// may already remove by exclusive
|
||||
if (_this5.childrenRefs[key]) {
|
||||
_this5.currentlyAnimatingKeys[key] = true;
|
||||
_this5.childrenRefs[key].componentWillLeave(_this5.handleDoneLeaving.bind(_this5, key));
|
||||
}
|
||||
};
|
||||
|
||||
this.handleDoneLeaving = function (key) {
|
||||
var props = _this5.props;
|
||||
delete _this5.currentlyAnimatingKeys[key];
|
||||
// if update on exclusive mode, skip check
|
||||
if (props.exclusive && props !== _this5.nextProps) {
|
||||
return;
|
||||
}
|
||||
var currentChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props));
|
||||
// in case state change is too fast
|
||||
if (_this5.isValidChildByKey(currentChildren, key)) {
|
||||
_this5.performEnter(key);
|
||||
} else {
|
||||
var end = function end() {
|
||||
if (_animate2['default'].allowLeaveCallback(props)) {
|
||||
props.onLeave(key);
|
||||
props.onEnd(key, false);
|
||||
}
|
||||
};
|
||||
if (!(0, _ChildrenUtils.isSameChildren)(_this5.state.children, currentChildren, props.showProp)) {
|
||||
_this5.setState({
|
||||
children: currentChildren
|
||||
}, end);
|
||||
} else {
|
||||
end();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports['default'] = (0, _unsafeLifecyclesPolyfill2['default'])(Animate);
|
||||
module.exports = exports['default'];
|
||||
146
web/node_modules/rc-animate/lib/AnimateChild.js
generated
vendored
Normal file
146
web/node_modules/rc-animate/lib/AnimateChild.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
||||
|
||||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
||||
|
||||
var _createClass2 = require('babel-runtime/helpers/createClass');
|
||||
|
||||
var _createClass3 = _interopRequireDefault(_createClass2);
|
||||
|
||||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
||||
|
||||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
||||
|
||||
var _inherits2 = require('babel-runtime/helpers/inherits');
|
||||
|
||||
var _inherits3 = _interopRequireDefault(_inherits2);
|
||||
|
||||
var _react = require('react');
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _reactDom = require('react-dom');
|
||||
|
||||
var _reactDom2 = _interopRequireDefault(_reactDom);
|
||||
|
||||
var _propTypes = require('prop-types');
|
||||
|
||||
var _propTypes2 = _interopRequireDefault(_propTypes);
|
||||
|
||||
var _cssAnimation = require('css-animation');
|
||||
|
||||
var _cssAnimation2 = _interopRequireDefault(_cssAnimation);
|
||||
|
||||
var _animate = require('./util/animate');
|
||||
|
||||
var _animate2 = _interopRequireDefault(_animate);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
var transitionMap = {
|
||||
enter: 'transitionEnter',
|
||||
appear: 'transitionAppear',
|
||||
leave: 'transitionLeave'
|
||||
};
|
||||
|
||||
var AnimateChild = function (_React$Component) {
|
||||
(0, _inherits3['default'])(AnimateChild, _React$Component);
|
||||
|
||||
function AnimateChild() {
|
||||
(0, _classCallCheck3['default'])(this, AnimateChild);
|
||||
return (0, _possibleConstructorReturn3['default'])(this, (AnimateChild.__proto__ || Object.getPrototypeOf(AnimateChild)).apply(this, arguments));
|
||||
}
|
||||
|
||||
(0, _createClass3['default'])(AnimateChild, [{
|
||||
key: 'componentWillUnmount',
|
||||
value: function componentWillUnmount() {
|
||||
this.stop();
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillEnter',
|
||||
value: function componentWillEnter(done) {
|
||||
if (_animate2['default'].isEnterSupported(this.props)) {
|
||||
this.transition('enter', done);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillAppear',
|
||||
value: function componentWillAppear(done) {
|
||||
if (_animate2['default'].isAppearSupported(this.props)) {
|
||||
this.transition('appear', done);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillLeave',
|
||||
value: function componentWillLeave(done) {
|
||||
if (_animate2['default'].isLeaveSupported(this.props)) {
|
||||
this.transition('leave', done);
|
||||
} else {
|
||||
// always sync, do not interupt with react component life cycle
|
||||
// update hidden -> animate hidden ->
|
||||
// didUpdate -> animate leave -> unmount (if animate is none)
|
||||
done();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'transition',
|
||||
value: function transition(animationType, finishCallback) {
|
||||
var _this2 = this;
|
||||
|
||||
var node = _reactDom2['default'].findDOMNode(this);
|
||||
var props = this.props;
|
||||
var transitionName = props.transitionName;
|
||||
var nameIsObj = typeof transitionName === 'object';
|
||||
this.stop();
|
||||
var end = function end() {
|
||||
_this2.stopper = null;
|
||||
finishCallback();
|
||||
};
|
||||
if ((_cssAnimation.isCssAnimationSupported || !props.animation[animationType]) && transitionName && props[transitionMap[animationType]]) {
|
||||
var name = nameIsObj ? transitionName[animationType] : transitionName + '-' + animationType;
|
||||
var activeName = name + '-active';
|
||||
if (nameIsObj && transitionName[animationType + 'Active']) {
|
||||
activeName = transitionName[animationType + 'Active'];
|
||||
}
|
||||
this.stopper = (0, _cssAnimation2['default'])(node, {
|
||||
name: name,
|
||||
active: activeName
|
||||
}, end);
|
||||
} else {
|
||||
this.stopper = props.animation[animationType](node, end);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'stop',
|
||||
value: function stop() {
|
||||
var stopper = this.stopper;
|
||||
if (stopper) {
|
||||
this.stopper = null;
|
||||
stopper.stop();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
return this.props.children;
|
||||
}
|
||||
}]);
|
||||
return AnimateChild;
|
||||
}(_react2['default'].Component);
|
||||
|
||||
AnimateChild.propTypes = {
|
||||
children: _propTypes2['default'].any,
|
||||
animation: _propTypes2['default'].any,
|
||||
transitionName: _propTypes2['default'].any
|
||||
};
|
||||
exports['default'] = AnimateChild;
|
||||
module.exports = exports['default'];
|
||||
387
web/node_modules/rc-animate/lib/CSSMotion.js
generated
vendored
Normal file
387
web/node_modules/rc-animate/lib/CSSMotion.js
generated
vendored
Normal file
@@ -0,0 +1,387 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.MotionPropTypes = undefined;
|
||||
|
||||
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
||||
|
||||
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
||||
|
||||
var _extends2 = require('babel-runtime/helpers/extends');
|
||||
|
||||
var _extends3 = _interopRequireDefault(_extends2);
|
||||
|
||||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
||||
|
||||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
||||
|
||||
var _createClass2 = require('babel-runtime/helpers/createClass');
|
||||
|
||||
var _createClass3 = _interopRequireDefault(_createClass2);
|
||||
|
||||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
||||
|
||||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
||||
|
||||
var _inherits2 = require('babel-runtime/helpers/inherits');
|
||||
|
||||
var _inherits3 = _interopRequireDefault(_inherits2);
|
||||
|
||||
exports.genCSSMotion = genCSSMotion;
|
||||
|
||||
var _react = require('react');
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _propTypes = require('prop-types');
|
||||
|
||||
var _propTypes2 = _interopRequireDefault(_propTypes);
|
||||
|
||||
var _reactLifecyclesCompat = require('react-lifecycles-compat');
|
||||
|
||||
var _findDOMNode = require('rc-util/lib/Dom/findDOMNode');
|
||||
|
||||
var _findDOMNode2 = _interopRequireDefault(_findDOMNode);
|
||||
|
||||
var _classnames = require('classnames');
|
||||
|
||||
var _classnames2 = _interopRequireDefault(_classnames);
|
||||
|
||||
var _raf = require('raf');
|
||||
|
||||
var _raf2 = _interopRequireDefault(_raf);
|
||||
|
||||
var _motion = require('./util/motion');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
var STATUS_NONE = 'none'; /* eslint-disable react/default-props-match-prop-types, react/no-multi-comp */
|
||||
|
||||
var STATUS_APPEAR = 'appear';
|
||||
var STATUS_ENTER = 'enter';
|
||||
var STATUS_LEAVE = 'leave';
|
||||
|
||||
var MotionPropTypes = exports.MotionPropTypes = {
|
||||
eventProps: _propTypes2['default'].object, // Internal usage. Only pass by CSSMotionList
|
||||
visible: _propTypes2['default'].bool,
|
||||
children: _propTypes2['default'].func,
|
||||
motionName: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].object]),
|
||||
motionAppear: _propTypes2['default'].bool,
|
||||
motionEnter: _propTypes2['default'].bool,
|
||||
motionLeave: _propTypes2['default'].bool,
|
||||
motionLeaveImmediately: _propTypes2['default'].bool, // Trigger leave motion immediately
|
||||
removeOnLeave: _propTypes2['default'].bool,
|
||||
leavedClassName: _propTypes2['default'].string,
|
||||
onAppearStart: _propTypes2['default'].func,
|
||||
onAppearActive: _propTypes2['default'].func,
|
||||
onAppearEnd: _propTypes2['default'].func,
|
||||
onEnterStart: _propTypes2['default'].func,
|
||||
onEnterActive: _propTypes2['default'].func,
|
||||
onEnterEnd: _propTypes2['default'].func,
|
||||
onLeaveStart: _propTypes2['default'].func,
|
||||
onLeaveActive: _propTypes2['default'].func,
|
||||
onLeaveEnd: _propTypes2['default'].func
|
||||
};
|
||||
|
||||
/**
|
||||
* `transitionSupport` is used for none transition test case.
|
||||
* Default we use browser transition event support check.
|
||||
*/
|
||||
function genCSSMotion(config) {
|
||||
var transitionSupport = config;
|
||||
var forwardRef = !!_react2['default'].forwardRef;
|
||||
|
||||
if (typeof config === 'object') {
|
||||
transitionSupport = config.transitionSupport;
|
||||
forwardRef = 'forwardRef' in config ? config.forwardRef : forwardRef;
|
||||
}
|
||||
|
||||
function isSupportTransition(props) {
|
||||
return !!(props.motionName && transitionSupport);
|
||||
}
|
||||
|
||||
var CSSMotion = function (_React$Component) {
|
||||
(0, _inherits3['default'])(CSSMotion, _React$Component);
|
||||
|
||||
function CSSMotion() {
|
||||
(0, _classCallCheck3['default'])(this, CSSMotion);
|
||||
|
||||
var _this = (0, _possibleConstructorReturn3['default'])(this, (CSSMotion.__proto__ || Object.getPrototypeOf(CSSMotion)).call(this));
|
||||
|
||||
_this.onDomUpdate = function () {
|
||||
var _this$state = _this.state,
|
||||
status = _this$state.status,
|
||||
newStatus = _this$state.newStatus;
|
||||
var _this$props = _this.props,
|
||||
onAppearStart = _this$props.onAppearStart,
|
||||
onEnterStart = _this$props.onEnterStart,
|
||||
onLeaveStart = _this$props.onLeaveStart,
|
||||
onAppearActive = _this$props.onAppearActive,
|
||||
onEnterActive = _this$props.onEnterActive,
|
||||
onLeaveActive = _this$props.onLeaveActive,
|
||||
motionAppear = _this$props.motionAppear,
|
||||
motionEnter = _this$props.motionEnter,
|
||||
motionLeave = _this$props.motionLeave;
|
||||
|
||||
|
||||
if (!isSupportTransition(_this.props)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Event injection
|
||||
var $ele = _this.getElement();
|
||||
if (_this.$cacheEle !== $ele) {
|
||||
_this.removeEventListener(_this.$cacheEle);
|
||||
_this.addEventListener($ele);
|
||||
_this.$cacheEle = $ele;
|
||||
}
|
||||
|
||||
// Init status
|
||||
if (newStatus && status === STATUS_APPEAR && motionAppear) {
|
||||
_this.updateStatus(onAppearStart, null, null, function () {
|
||||
_this.updateActiveStatus(onAppearActive, STATUS_APPEAR);
|
||||
});
|
||||
} else if (newStatus && status === STATUS_ENTER && motionEnter) {
|
||||
_this.updateStatus(onEnterStart, null, null, function () {
|
||||
_this.updateActiveStatus(onEnterActive, STATUS_ENTER);
|
||||
});
|
||||
} else if (newStatus && status === STATUS_LEAVE && motionLeave) {
|
||||
_this.updateStatus(onLeaveStart, null, null, function () {
|
||||
_this.updateActiveStatus(onLeaveActive, STATUS_LEAVE);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_this.onMotionEnd = function (event) {
|
||||
var _this$state2 = _this.state,
|
||||
status = _this$state2.status,
|
||||
statusActive = _this$state2.statusActive;
|
||||
var _this$props2 = _this.props,
|
||||
onAppearEnd = _this$props2.onAppearEnd,
|
||||
onEnterEnd = _this$props2.onEnterEnd,
|
||||
onLeaveEnd = _this$props2.onLeaveEnd;
|
||||
|
||||
if (status === STATUS_APPEAR && statusActive) {
|
||||
_this.updateStatus(onAppearEnd, { status: STATUS_NONE }, event);
|
||||
} else if (status === STATUS_ENTER && statusActive) {
|
||||
_this.updateStatus(onEnterEnd, { status: STATUS_NONE }, event);
|
||||
} else if (status === STATUS_LEAVE && statusActive) {
|
||||
_this.updateStatus(onLeaveEnd, { status: STATUS_NONE }, event);
|
||||
}
|
||||
};
|
||||
|
||||
_this.setNodeRef = function (node) {
|
||||
var internalRef = _this.props.internalRef;
|
||||
|
||||
_this.node = node;
|
||||
|
||||
if (typeof internalRef === 'function') {
|
||||
internalRef(node);
|
||||
} else if (internalRef && 'current' in internalRef) {
|
||||
internalRef.current = node;
|
||||
}
|
||||
};
|
||||
|
||||
_this.getElement = function () {
|
||||
return (0, _findDOMNode2['default'])(_this.node || _this);
|
||||
};
|
||||
|
||||
_this.addEventListener = function ($ele) {
|
||||
if (!$ele) return;
|
||||
|
||||
$ele.addEventListener(_motion.transitionEndName, _this.onMotionEnd);
|
||||
$ele.addEventListener(_motion.animationEndName, _this.onMotionEnd);
|
||||
};
|
||||
|
||||
_this.removeEventListener = function ($ele) {
|
||||
if (!$ele) return;
|
||||
|
||||
$ele.removeEventListener(_motion.transitionEndName, _this.onMotionEnd);
|
||||
$ele.removeEventListener(_motion.animationEndName, _this.onMotionEnd);
|
||||
};
|
||||
|
||||
_this.updateStatus = function (styleFunc, additionalState, event, callback) {
|
||||
var statusStyle = styleFunc ? styleFunc(_this.getElement(), event) : null;
|
||||
|
||||
if (statusStyle === false || _this._destroyed) return;
|
||||
|
||||
var nextStep = void 0;
|
||||
if (callback) {
|
||||
nextStep = function nextStep() {
|
||||
_this.nextFrame(callback);
|
||||
};
|
||||
}
|
||||
|
||||
_this.setState((0, _extends3['default'])({
|
||||
statusStyle: typeof statusStyle === 'object' ? statusStyle : null,
|
||||
newStatus: false
|
||||
}, additionalState), nextStep); // Trigger before next frame & after `componentDidMount`
|
||||
};
|
||||
|
||||
_this.updateActiveStatus = function (styleFunc, currentStatus) {
|
||||
// `setState` use `postMessage` to trigger at the end of frame.
|
||||
// Let's use requestAnimationFrame to update new state in next frame.
|
||||
_this.nextFrame(function () {
|
||||
var status = _this.state.status;
|
||||
|
||||
if (status !== currentStatus) return;
|
||||
|
||||
_this.updateStatus(styleFunc, { statusActive: true });
|
||||
});
|
||||
};
|
||||
|
||||
_this.nextFrame = function (func) {
|
||||
_this.cancelNextFrame();
|
||||
_this.raf = (0, _raf2['default'])(func);
|
||||
};
|
||||
|
||||
_this.cancelNextFrame = function () {
|
||||
if (_this.raf) {
|
||||
_raf2['default'].cancel(_this.raf);
|
||||
_this.raf = null;
|
||||
}
|
||||
};
|
||||
|
||||
_this.state = {
|
||||
status: STATUS_NONE,
|
||||
statusActive: false,
|
||||
newStatus: false,
|
||||
statusStyle: null
|
||||
};
|
||||
_this.$cacheEle = null;
|
||||
_this.node = null;
|
||||
_this.raf = null;
|
||||
return _this;
|
||||
}
|
||||
|
||||
(0, _createClass3['default'])(CSSMotion, [{
|
||||
key: 'componentDidMount',
|
||||
value: function componentDidMount() {
|
||||
this.onDomUpdate();
|
||||
}
|
||||
}, {
|
||||
key: 'componentDidUpdate',
|
||||
value: function componentDidUpdate() {
|
||||
this.onDomUpdate();
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillUnmount',
|
||||
value: function componentWillUnmount() {
|
||||
this._destroyed = true;
|
||||
this.removeEventListener(this.$cacheEle);
|
||||
this.cancelNextFrame();
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var _classNames;
|
||||
|
||||
var _state = this.state,
|
||||
status = _state.status,
|
||||
statusActive = _state.statusActive,
|
||||
statusStyle = _state.statusStyle;
|
||||
var _props = this.props,
|
||||
children = _props.children,
|
||||
motionName = _props.motionName,
|
||||
visible = _props.visible,
|
||||
removeOnLeave = _props.removeOnLeave,
|
||||
leavedClassName = _props.leavedClassName,
|
||||
eventProps = _props.eventProps;
|
||||
|
||||
|
||||
if (!children) return null;
|
||||
|
||||
if (status === STATUS_NONE || !isSupportTransition(this.props)) {
|
||||
if (visible) {
|
||||
return children((0, _extends3['default'])({}, eventProps), this.setNodeRef);
|
||||
} else if (!removeOnLeave) {
|
||||
return children((0, _extends3['default'])({}, eventProps, { className: leavedClassName }), this.setNodeRef);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return children((0, _extends3['default'])({}, eventProps, {
|
||||
className: (0, _classnames2['default'])((_classNames = {}, (0, _defineProperty3['default'])(_classNames, (0, _motion.getTransitionName)(motionName, status), status !== STATUS_NONE), (0, _defineProperty3['default'])(_classNames, (0, _motion.getTransitionName)(motionName, status + '-active'), status !== STATUS_NONE && statusActive), (0, _defineProperty3['default'])(_classNames, motionName, typeof motionName === 'string'), _classNames)),
|
||||
style: statusStyle
|
||||
}), this.setNodeRef);
|
||||
}
|
||||
}], [{
|
||||
key: 'getDerivedStateFromProps',
|
||||
value: function getDerivedStateFromProps(props, _ref) {
|
||||
var prevProps = _ref.prevProps,
|
||||
prevStatus = _ref.status;
|
||||
|
||||
if (!isSupportTransition(props)) return {};
|
||||
|
||||
var visible = props.visible,
|
||||
motionAppear = props.motionAppear,
|
||||
motionEnter = props.motionEnter,
|
||||
motionLeave = props.motionLeave,
|
||||
motionLeaveImmediately = props.motionLeaveImmediately;
|
||||
|
||||
var newState = {
|
||||
prevProps: props
|
||||
};
|
||||
|
||||
// Clean up status if prop set to false
|
||||
if (prevStatus === STATUS_APPEAR && !motionAppear || prevStatus === STATUS_ENTER && !motionEnter || prevStatus === STATUS_LEAVE && !motionLeave) {
|
||||
newState.status = STATUS_NONE;
|
||||
newState.statusActive = false;
|
||||
newState.newStatus = false;
|
||||
}
|
||||
|
||||
// Appear
|
||||
if (!prevProps && visible && motionAppear) {
|
||||
newState.status = STATUS_APPEAR;
|
||||
newState.statusActive = false;
|
||||
newState.newStatus = true;
|
||||
}
|
||||
|
||||
// Enter
|
||||
if (prevProps && !prevProps.visible && visible && motionEnter) {
|
||||
newState.status = STATUS_ENTER;
|
||||
newState.statusActive = false;
|
||||
newState.newStatus = true;
|
||||
}
|
||||
|
||||
// Leave
|
||||
if (prevProps && prevProps.visible && !visible && motionLeave || !prevProps && motionLeaveImmediately && !visible && motionLeave) {
|
||||
newState.status = STATUS_LEAVE;
|
||||
newState.statusActive = false;
|
||||
newState.newStatus = true;
|
||||
}
|
||||
|
||||
return newState;
|
||||
}
|
||||
}]);
|
||||
return CSSMotion;
|
||||
}(_react2['default'].Component);
|
||||
|
||||
CSSMotion.propTypes = (0, _extends3['default'])({}, MotionPropTypes, {
|
||||
|
||||
internalRef: _propTypes2['default'].oneOfType([_propTypes2['default'].object, _propTypes2['default'].func])
|
||||
});
|
||||
CSSMotion.defaultProps = {
|
||||
visible: true,
|
||||
motionEnter: true,
|
||||
motionAppear: true,
|
||||
motionLeave: true,
|
||||
removeOnLeave: true
|
||||
};
|
||||
|
||||
|
||||
(0, _reactLifecyclesCompat.polyfill)(CSSMotion);
|
||||
|
||||
if (!forwardRef) {
|
||||
return CSSMotion;
|
||||
}
|
||||
|
||||
return _react2['default'].forwardRef(function (props, ref) {
|
||||
return _react2['default'].createElement(CSSMotion, (0, _extends3['default'])({ internalRef: ref }, props));
|
||||
});
|
||||
}
|
||||
|
||||
exports['default'] = genCSSMotion(_motion.supportTransition);
|
||||
194
web/node_modules/rc-animate/lib/CSSMotionList.js
generated
vendored
Normal file
194
web/node_modules/rc-animate/lib/CSSMotionList.js
generated
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
||||
|
||||
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
||||
|
||||
var _extends2 = require('babel-runtime/helpers/extends');
|
||||
|
||||
var _extends3 = _interopRequireDefault(_extends2);
|
||||
|
||||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
||||
|
||||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
||||
|
||||
var _createClass2 = require('babel-runtime/helpers/createClass');
|
||||
|
||||
var _createClass3 = _interopRequireDefault(_createClass2);
|
||||
|
||||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
||||
|
||||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
||||
|
||||
var _inherits2 = require('babel-runtime/helpers/inherits');
|
||||
|
||||
var _inherits3 = _interopRequireDefault(_inherits2);
|
||||
|
||||
exports.genCSSMotionList = genCSSMotionList;
|
||||
|
||||
var _react = require('react');
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _reactLifecyclesCompat = require('react-lifecycles-compat');
|
||||
|
||||
var _propTypes = require('prop-types');
|
||||
|
||||
var _propTypes2 = _interopRequireDefault(_propTypes);
|
||||
|
||||
var _CSSMotion = require('./CSSMotion');
|
||||
|
||||
var _CSSMotion2 = _interopRequireDefault(_CSSMotion);
|
||||
|
||||
var _motion = require('./util/motion');
|
||||
|
||||
var _diff = require('./util/diff');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
var MOTION_PROP_NAMES = Object.keys(_CSSMotion.MotionPropTypes);
|
||||
|
||||
function genCSSMotionList(transitionSupport) {
|
||||
var CSSMotion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _CSSMotion2['default'];
|
||||
|
||||
var CSSMotionList = function (_React$Component) {
|
||||
(0, _inherits3['default'])(CSSMotionList, _React$Component);
|
||||
|
||||
function CSSMotionList() {
|
||||
var _ref;
|
||||
|
||||
var _temp, _this, _ret;
|
||||
|
||||
(0, _classCallCheck3['default'])(this, CSSMotionList);
|
||||
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3['default'])(this, (_ref = CSSMotionList.__proto__ || Object.getPrototypeOf(CSSMotionList)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
|
||||
keyEntities: []
|
||||
}, _this.removeKey = function (removeKey) {
|
||||
_this.setState(function (_ref2) {
|
||||
var keyEntities = _ref2.keyEntities;
|
||||
return {
|
||||
keyEntities: keyEntities.map(function (entity) {
|
||||
if (entity.key !== removeKey) return entity;
|
||||
return (0, _extends3['default'])({}, entity, {
|
||||
status: _diff.STATUS_REMOVED
|
||||
});
|
||||
})
|
||||
};
|
||||
});
|
||||
}, _temp), (0, _possibleConstructorReturn3['default'])(_this, _ret);
|
||||
}
|
||||
|
||||
(0, _createClass3['default'])(CSSMotionList, [{
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var _this2 = this;
|
||||
|
||||
var keyEntities = this.state.keyEntities;
|
||||
var _props = this.props,
|
||||
component = _props.component,
|
||||
children = _props.children,
|
||||
restProps = (0, _objectWithoutProperties3['default'])(_props, ['component', 'children']);
|
||||
|
||||
|
||||
var Component = component || _react2['default'].Fragment;
|
||||
|
||||
var motionProps = {};
|
||||
MOTION_PROP_NAMES.forEach(function (prop) {
|
||||
motionProps[prop] = restProps[prop];
|
||||
delete restProps[prop];
|
||||
});
|
||||
delete restProps.keys;
|
||||
|
||||
return _react2['default'].createElement(
|
||||
Component,
|
||||
restProps,
|
||||
keyEntities.map(function (_ref3) {
|
||||
var status = _ref3.status,
|
||||
eventProps = (0, _objectWithoutProperties3['default'])(_ref3, ['status']);
|
||||
|
||||
var visible = status === _diff.STATUS_ADD || status === _diff.STATUS_KEEP;
|
||||
return _react2['default'].createElement(
|
||||
CSSMotion,
|
||||
(0, _extends3['default'])({}, motionProps, {
|
||||
key: eventProps.key,
|
||||
visible: visible,
|
||||
eventProps: eventProps,
|
||||
onLeaveEnd: function onLeaveEnd() {
|
||||
if (motionProps.onLeaveEnd) {
|
||||
motionProps.onLeaveEnd.apply(motionProps, arguments);
|
||||
}
|
||||
_this2.removeKey(eventProps.key);
|
||||
}
|
||||
}),
|
||||
children
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}], [{
|
||||
key: 'getDerivedStateFromProps',
|
||||
value: function getDerivedStateFromProps(_ref4, _ref5) {
|
||||
var keys = _ref4.keys;
|
||||
var keyEntities = _ref5.keyEntities;
|
||||
|
||||
var parsedKeyObjects = (0, _diff.parseKeys)(keys);
|
||||
|
||||
// Always as keep when motion not support
|
||||
if (!transitionSupport) {
|
||||
return {
|
||||
keyEntities: parsedKeyObjects.map(function (obj) {
|
||||
return (0, _extends3['default'])({}, obj, { status: _diff.STATUS_KEEP });
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
var mixedKeyEntities = (0, _diff.diffKeys)(keyEntities, parsedKeyObjects);
|
||||
|
||||
var keyEntitiesLen = keyEntities.length;
|
||||
return {
|
||||
keyEntities: mixedKeyEntities.filter(function (entity) {
|
||||
// IE 9 not support Array.prototype.find
|
||||
var prevEntity = null;
|
||||
for (var i = 0; i < keyEntitiesLen; i += 1) {
|
||||
var currentEntity = keyEntities[i];
|
||||
if (currentEntity.key === entity.key) {
|
||||
prevEntity = currentEntity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove if already mark as removed
|
||||
if (prevEntity && prevEntity.status === _diff.STATUS_REMOVED && entity.status === _diff.STATUS_REMOVE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
};
|
||||
}
|
||||
}]);
|
||||
return CSSMotionList;
|
||||
}(_react2['default'].Component);
|
||||
|
||||
CSSMotionList.propTypes = (0, _extends3['default'])({}, CSSMotion.propTypes, {
|
||||
component: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].bool]),
|
||||
keys: _propTypes2['default'].array
|
||||
});
|
||||
CSSMotionList.defaultProps = {
|
||||
component: 'div'
|
||||
};
|
||||
|
||||
|
||||
(0, _reactLifecyclesCompat.polyfill)(CSSMotionList);
|
||||
|
||||
return CSSMotionList;
|
||||
}
|
||||
|
||||
exports['default'] = genCSSMotionList(_motion.supportTransition);
|
||||
117
web/node_modules/rc-animate/lib/ChildrenUtils.js
generated
vendored
Normal file
117
web/node_modules/rc-animate/lib/ChildrenUtils.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.toArrayChildren = toArrayChildren;
|
||||
exports.findChildInChildrenByKey = findChildInChildrenByKey;
|
||||
exports.findShownChildInChildrenByKey = findShownChildInChildrenByKey;
|
||||
exports.findHiddenChildInChildrenByKey = findHiddenChildInChildrenByKey;
|
||||
exports.isSameChildren = isSameChildren;
|
||||
exports.mergeChildren = mergeChildren;
|
||||
|
||||
var _react = require('react');
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function toArrayChildren(children) {
|
||||
var ret = [];
|
||||
_react2['default'].Children.forEach(children, function (child) {
|
||||
ret.push(child);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
function findChildInChildrenByKey(children, key) {
|
||||
var ret = null;
|
||||
if (children) {
|
||||
children.forEach(function (child) {
|
||||
if (ret) {
|
||||
return;
|
||||
}
|
||||
if (child && child.key === key) {
|
||||
ret = child;
|
||||
}
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
function findShownChildInChildrenByKey(children, key, showProp) {
|
||||
var ret = null;
|
||||
if (children) {
|
||||
children.forEach(function (child) {
|
||||
if (child && child.key === key && child.props[showProp]) {
|
||||
if (ret) {
|
||||
throw new Error('two child with same key for <rc-animate> children');
|
||||
}
|
||||
ret = child;
|
||||
}
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
function findHiddenChildInChildrenByKey(children, key, showProp) {
|
||||
var found = 0;
|
||||
if (children) {
|
||||
children.forEach(function (child) {
|
||||
if (found) {
|
||||
return;
|
||||
}
|
||||
found = child && child.key === key && !child.props[showProp];
|
||||
});
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
function isSameChildren(c1, c2, showProp) {
|
||||
var same = c1.length === c2.length;
|
||||
if (same) {
|
||||
c1.forEach(function (child, index) {
|
||||
var child2 = c2[index];
|
||||
if (child && child2) {
|
||||
if (child && !child2 || !child && child2) {
|
||||
same = false;
|
||||
} else if (child.key !== child2.key) {
|
||||
same = false;
|
||||
} else if (showProp && child.props[showProp] !== child2.props[showProp]) {
|
||||
same = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return same;
|
||||
}
|
||||
|
||||
function mergeChildren(prev, next) {
|
||||
var ret = [];
|
||||
|
||||
// For each key of `next`, the list of keys to insert before that key in
|
||||
// the combined list
|
||||
var nextChildrenPending = {};
|
||||
var pendingChildren = [];
|
||||
prev.forEach(function (child) {
|
||||
if (child && findChildInChildrenByKey(next, child.key)) {
|
||||
if (pendingChildren.length) {
|
||||
nextChildrenPending[child.key] = pendingChildren;
|
||||
pendingChildren = [];
|
||||
}
|
||||
} else {
|
||||
pendingChildren.push(child);
|
||||
}
|
||||
});
|
||||
|
||||
next.forEach(function (child) {
|
||||
if (child && Object.prototype.hasOwnProperty.call(nextChildrenPending, child.key)) {
|
||||
ret = ret.concat(nextChildrenPending[child.key]);
|
||||
}
|
||||
ret.push(child);
|
||||
});
|
||||
|
||||
ret = ret.concat(pendingChildren);
|
||||
|
||||
return ret;
|
||||
}
|
||||
27
web/node_modules/rc-animate/lib/util/animate.js
generated
vendored
Normal file
27
web/node_modules/rc-animate/lib/util/animate.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var util = {
|
||||
isAppearSupported: function isAppearSupported(props) {
|
||||
return props.transitionName && props.transitionAppear || props.animation.appear;
|
||||
},
|
||||
isEnterSupported: function isEnterSupported(props) {
|
||||
return props.transitionName && props.transitionEnter || props.animation.enter;
|
||||
},
|
||||
isLeaveSupported: function isLeaveSupported(props) {
|
||||
return props.transitionName && props.transitionLeave || props.animation.leave;
|
||||
},
|
||||
allowAppearCallback: function allowAppearCallback(props) {
|
||||
return props.transitionAppear || props.animation.appear;
|
||||
},
|
||||
allowEnterCallback: function allowEnterCallback(props) {
|
||||
return props.transitionEnter || props.animation.enter;
|
||||
},
|
||||
allowLeaveCallback: function allowLeaveCallback(props) {
|
||||
return props.transitionLeave || props.animation.leave;
|
||||
}
|
||||
};
|
||||
exports["default"] = util;
|
||||
module.exports = exports['default'];
|
||||
121
web/node_modules/rc-animate/lib/util/diff.js
generated
vendored
Normal file
121
web/node_modules/rc-animate/lib/util/diff.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.STATUS_REMOVED = exports.STATUS_REMOVE = exports.STATUS_KEEP = exports.STATUS_ADD = undefined;
|
||||
|
||||
var _extends2 = require('babel-runtime/helpers/extends');
|
||||
|
||||
var _extends3 = _interopRequireDefault(_extends2);
|
||||
|
||||
exports.wrapKeyToObject = wrapKeyToObject;
|
||||
exports.parseKeys = parseKeys;
|
||||
exports.diffKeys = diffKeys;
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
var STATUS_ADD = exports.STATUS_ADD = 'add';
|
||||
var STATUS_KEEP = exports.STATUS_KEEP = 'keep';
|
||||
var STATUS_REMOVE = exports.STATUS_REMOVE = 'remove';
|
||||
var STATUS_REMOVED = exports.STATUS_REMOVED = 'removed';
|
||||
|
||||
function wrapKeyToObject(key) {
|
||||
var keyObj = void 0;
|
||||
if (key && typeof key === 'object' && 'key' in key) {
|
||||
keyObj = key;
|
||||
} else {
|
||||
keyObj = { key: key };
|
||||
}
|
||||
return (0, _extends3['default'])({}, keyObj, {
|
||||
key: String(keyObj.key)
|
||||
});
|
||||
}
|
||||
|
||||
function parseKeys() {
|
||||
var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
|
||||
return keys.map(wrapKeyToObject);
|
||||
}
|
||||
|
||||
function diffKeys() {
|
||||
var prevKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
var currentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
|
||||
var list = [];
|
||||
var currentIndex = 0;
|
||||
var currentLen = currentKeys.length;
|
||||
|
||||
var prevKeyObjects = parseKeys(prevKeys);
|
||||
var currentKeyObjects = parseKeys(currentKeys);
|
||||
|
||||
// Check prev keys to insert or keep
|
||||
prevKeyObjects.forEach(function (keyObj) {
|
||||
var hit = false;
|
||||
|
||||
for (var i = currentIndex; i < currentLen; i += 1) {
|
||||
var currentKeyObj = currentKeyObjects[i];
|
||||
if (currentKeyObj.key === keyObj.key) {
|
||||
// New added keys should add before current key
|
||||
if (currentIndex < i) {
|
||||
list = list.concat(currentKeyObjects.slice(currentIndex, i).map(function (obj) {
|
||||
return (0, _extends3['default'])({}, obj, { status: STATUS_ADD });
|
||||
}));
|
||||
currentIndex = i;
|
||||
}
|
||||
list.push((0, _extends3['default'])({}, currentKeyObj, {
|
||||
status: STATUS_KEEP
|
||||
}));
|
||||
currentIndex += 1;
|
||||
|
||||
hit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If not hit, it means key is removed
|
||||
if (!hit) {
|
||||
list.push((0, _extends3['default'])({}, keyObj, {
|
||||
status: STATUS_REMOVE
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
// Add rest to the list
|
||||
if (currentIndex < currentLen) {
|
||||
list = list.concat(currentKeyObjects.slice(currentIndex).map(function (obj) {
|
||||
return (0, _extends3['default'])({}, obj, { status: STATUS_ADD });
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge same key when it remove and add again:
|
||||
* [1 - add, 2 - keep, 1 - remove] -> [1 - keep, 2 - keep]
|
||||
*/
|
||||
var keys = {};
|
||||
list.forEach(function (_ref) {
|
||||
var key = _ref.key;
|
||||
|
||||
keys[key] = (keys[key] || 0) + 1;
|
||||
});
|
||||
var duplicatedKeys = Object.keys(keys).filter(function (key) {
|
||||
return keys[key] > 1;
|
||||
});
|
||||
duplicatedKeys.forEach(function (matchKey) {
|
||||
// Remove `STATUS_REMOVE` node.
|
||||
list = list.filter(function (_ref2) {
|
||||
var key = _ref2.key,
|
||||
status = _ref2.status;
|
||||
return key !== matchKey || status !== STATUS_REMOVE;
|
||||
});
|
||||
|
||||
// Update `STATUS_ADD` to `STATUS_KEEP`
|
||||
list.forEach(function (node) {
|
||||
if (node.key === matchKey) {
|
||||
node.status = STATUS_KEEP;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
91
web/node_modules/rc-animate/lib/util/motion.js
generated
vendored
Normal file
91
web/node_modules/rc-animate/lib/util/motion.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getVendorPrefixes = getVendorPrefixes;
|
||||
exports.getVendorPrefixedEventName = getVendorPrefixedEventName;
|
||||
exports.getTransitionName = getTransitionName;
|
||||
var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
||||
|
||||
// ================= Transition =================
|
||||
// Event wrapper. Copy from react source code
|
||||
function makePrefixMap(styleProp, eventName) {
|
||||
var prefixes = {};
|
||||
|
||||
prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
|
||||
prefixes['Webkit' + styleProp] = 'webkit' + eventName;
|
||||
prefixes['Moz' + styleProp] = 'moz' + eventName;
|
||||
prefixes['ms' + styleProp] = 'MS' + eventName;
|
||||
prefixes['O' + styleProp] = 'o' + eventName.toLowerCase();
|
||||
|
||||
return prefixes;
|
||||
}
|
||||
|
||||
function getVendorPrefixes(domSupport, win) {
|
||||
var prefixes = {
|
||||
animationend: makePrefixMap('Animation', 'AnimationEnd'),
|
||||
transitionend: makePrefixMap('Transition', 'TransitionEnd')
|
||||
};
|
||||
|
||||
if (domSupport) {
|
||||
if (!('AnimationEvent' in win)) {
|
||||
delete prefixes.animationend.animation;
|
||||
}
|
||||
|
||||
if (!('TransitionEvent' in win)) {
|
||||
delete prefixes.transitionend.transition;
|
||||
}
|
||||
}
|
||||
|
||||
return prefixes;
|
||||
}
|
||||
|
||||
var vendorPrefixes = getVendorPrefixes(canUseDOM, typeof window !== 'undefined' ? window : {});
|
||||
|
||||
var style = {};
|
||||
|
||||
if (canUseDOM) {
|
||||
style = document.createElement('div').style;
|
||||
}
|
||||
|
||||
var prefixedEventNames = {};
|
||||
|
||||
function getVendorPrefixedEventName(eventName) {
|
||||
if (prefixedEventNames[eventName]) {
|
||||
return prefixedEventNames[eventName];
|
||||
}
|
||||
|
||||
var prefixMap = vendorPrefixes[eventName];
|
||||
|
||||
if (prefixMap) {
|
||||
var stylePropList = Object.keys(prefixMap);
|
||||
var len = stylePropList.length;
|
||||
for (var i = 0; i < len; i += 1) {
|
||||
var styleProp = stylePropList[i];
|
||||
if (Object.prototype.hasOwnProperty.call(prefixMap, styleProp) && styleProp in style) {
|
||||
prefixedEventNames[eventName] = prefixMap[styleProp];
|
||||
return prefixedEventNames[eventName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
var animationEndName = exports.animationEndName = getVendorPrefixedEventName('animationend');
|
||||
var transitionEndName = exports.transitionEndName = getVendorPrefixedEventName('transitionend');
|
||||
var supportTransition = exports.supportTransition = !!(animationEndName && transitionEndName);
|
||||
|
||||
function getTransitionName(transitionName, transitionType) {
|
||||
if (!transitionName) return null;
|
||||
|
||||
if (typeof transitionName === 'object') {
|
||||
var type = transitionType.replace(/-\w/g, function (match) {
|
||||
return match[1].toUpperCase();
|
||||
});
|
||||
return transitionName[type];
|
||||
}
|
||||
|
||||
return transitionName + '-' + transitionType;
|
||||
}
|
||||
Reference in New Issue
Block a user