Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

@@ -36,6 +36,10 @@ var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _Transition = require('react-transition-group/Transition');
var _Transition2 = _interopRequireDefault(_Transition);
@@ -46,71 +50,24 @@ var _withTheme = require('../styles/withTheme');
var _withTheme2 = _interopRequireDefault(_withTheme);
var _utils = require('./utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Element = require('react').babelPluginFlowReactPropTypes_proptype_Element || require('prop-types').any;
// @inheritedComponent Transition
var babelPluginFlowReactPropTypes_proptype_TransitionCallback = require('../internal/transition').babelPluginFlowReactPropTypes_proptype_TransitionCallback || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_TransitionDuration = require('../internal/transition').babelPluginFlowReactPropTypes_proptype_TransitionDuration || require('prop-types').any;
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* @ignore
*/
appear: require('prop-types').bool,
/**
* A single child content element.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Element === 'function' ? babelPluginFlowReactPropTypes_proptype_Element.isRequired ? babelPluginFlowReactPropTypes_proptype_Element.isRequired : babelPluginFlowReactPropTypes_proptype_Element : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Element).isRequired,
/**
* If `true`, the component will transition in.
*/
in: require('prop-types').bool.isRequired,
/**
* @ignore
*/
onEnter: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* @ignore
*/
onEntering: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* @ignore
*/
onExit: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
/**
* @ignore
*/
theme: require('prop-types').object,
/**
* @ignore
*/
style: require('prop-types').object,
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
*/
timeout: typeof babelPluginFlowReactPropTypes_proptype_TransitionDuration === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionDuration : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionDuration)
};
var reflow = function reflow(node) {
return node.scrollTop;
var styles = {
entering: {
opacity: 1
},
entered: {
opacity: 1
}
};
/**
* The Fade transition is used by the Modal component.
* It's using [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
* The Fade transition is used by the [Modal](/demos/modals) component.
* It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
*/
var Fade = function (_React$Component) {
@@ -128,42 +85,45 @@ var Fade = function (_React$Component) {
}
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = Fade.__proto__ || (0, _getPrototypeOf2.default)(Fade)).call.apply(_ref, [this].concat(args))), _this), _this.handleEnter = function (node) {
node.style.opacity = '0';
reflow(node);
var theme = _this.props.theme;
(0, _utils.reflow)(node); // So the animation always start from the start.
var _getTransitionProps = (0, _utils.getTransitionProps)(_this.props, {
mode: 'enter'
}),
transitionDuration = _getTransitionProps.duration,
delay = _getTransitionProps.delay;
node.style.transition = theme.transitions.create('opacity', {
duration: transitionDuration,
delay: delay
});
node.style.webkitTransition = theme.transitions.create('opacity', {
duration: transitionDuration,
delay: delay
});
if (_this.props.onEnter) {
_this.props.onEnter(node);
}
}, _this.handleEntering = function (node) {
var _this$props = _this.props,
theme = _this$props.theme,
timeout = _this$props.timeout;
node.style.transition = theme.transitions.create('opacity', {
duration: typeof timeout === 'number' ? timeout : timeout.enter
});
// $FlowFixMe - https://github.com/facebook/flow/pull/5161
node.style.webkitTransition = theme.transitions.create('opacity', {
duration: typeof timeout === 'number' ? timeout : timeout.enter
});
node.style.opacity = '1';
if (_this.props.onEntering) {
_this.props.onEntering(node);
}
}, _this.handleExit = function (node) {
var _this$props2 = _this.props,
theme = _this$props2.theme,
timeout = _this$props2.timeout;
var theme = _this.props.theme;
var _getTransitionProps2 = (0, _utils.getTransitionProps)(_this.props, {
mode: 'exit'
}),
transitionDuration = _getTransitionProps2.duration,
delay = _getTransitionProps2.delay;
node.style.transition = theme.transitions.create('opacity', {
duration: typeof timeout === 'number' ? timeout : timeout.exit
duration: transitionDuration,
delay: delay
});
// $FlowFixMe - https://github.com/facebook/flow/pull/5161
node.style.webkitTransition = theme.transitions.create('opacity', {
duration: typeof timeout === 'number' ? timeout : timeout.exit
duration: transitionDuration,
delay: delay
});
node.style.opacity = '0';
if (_this.props.onExit) {
_this.props.onExit(node);
@@ -175,44 +135,73 @@ var Fade = function (_React$Component) {
key: 'render',
value: function render() {
var _props = this.props,
appear = _props.appear,
children = _props.children,
onEnter = _props.onEnter,
onEntering = _props.onEntering,
onExit = _props.onExit,
styleProp = _props.style,
theme = _props.theme,
other = (0, _objectWithoutProperties3.default)(_props, ['appear', 'children', 'onEnter', 'onEntering', 'onExit', 'style', 'theme']);
other = (0, _objectWithoutProperties3.default)(_props, ['children', 'onEnter', 'onExit', 'style', 'theme']);
var style = (0, _extends3.default)({}, styleProp);
// For server side rendering.
if (!this.props.in || appear) {
style.opacity = '0';
}
var style = (0, _extends3.default)({}, styleProp, _react2.default.isValidElement(children) ? children.props.style : {});
return _react2.default.createElement(
_Transition2.default,
(0, _extends3.default)({
appear: appear,
style: style,
onEnter: this.handleEnter,
onEntering: this.handleEntering,
onExit: this.handleExit
}, other),
children
(0, _extends3.default)({ appear: true, onEnter: this.handleEnter, onExit: this.handleExit }, other),
function (state, childProps) {
return _react2.default.cloneElement(children, (0, _extends3.default)({
style: (0, _extends3.default)({
opacity: 0
}, styles[state], style)
}, childProps));
}
);
}
}]);
return Fade;
}(_react2.default.Component);
Fade.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* A single child content element.
*/
children: _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.func]),
/**
* If `true`, the component will transition in.
*/
in: _propTypes2.default.bool,
/**
* @ignore
*/
onEnter: _propTypes2.default.func,
/**
* @ignore
*/
onEntering: _propTypes2.default.func,
/**
* @ignore
*/
onExit: _propTypes2.default.func,
/**
* @ignore
*/
style: _propTypes2.default.object,
/**
* @ignore
*/
theme: _propTypes2.default.object.isRequired,
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
*/
timeout: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.shape({ enter: _propTypes2.default.number, exit: _propTypes2.default.number })])
} : {};
Fade.defaultProps = {
appear: true,
timeout: {
enter: _transitions.duration.enteringScreen,
exit: _transitions.duration.leavingScreen
}
};
exports.default = (0, _withTheme2.default)()(Fade);