218 lines
7.4 KiB
JavaScript
218 lines
7.4 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _extends2 = require('babel-runtime/helpers/extends');
|
|
|
|
var _extends3 = _interopRequireDefault(_extends2);
|
|
|
|
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
|
|
|
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
|
|
|
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
|
|
|
|
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
|
|
|
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 _Transition = require('react-transition-group/Transition');
|
|
|
|
var _Transition2 = _interopRequireDefault(_Transition);
|
|
|
|
var _transitions = require('../styles/transitions');
|
|
|
|
var _withTheme = require('../styles/withTheme');
|
|
|
|
var _withTheme2 = _interopRequireDefault(_withTheme);
|
|
|
|
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;
|
|
};
|
|
|
|
/**
|
|
* The Fade transition is used by the Modal component.
|
|
* It's using [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
|
|
*/
|
|
|
|
var Fade = function (_React$Component) {
|
|
(0, _inherits3.default)(Fade, _React$Component);
|
|
|
|
function Fade() {
|
|
var _ref;
|
|
|
|
var _temp, _this, _ret;
|
|
|
|
(0, _classCallCheck3.default)(this, Fade);
|
|
|
|
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 = Fade.__proto__ || (0, _getPrototypeOf2.default)(Fade)).call.apply(_ref, [this].concat(args))), _this), _this.handleEnter = function (node) {
|
|
node.style.opacity = '0';
|
|
reflow(node);
|
|
|
|
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;
|
|
|
|
node.style.transition = theme.transitions.create('opacity', {
|
|
duration: typeof timeout === 'number' ? timeout : timeout.exit
|
|
});
|
|
// $FlowFixMe - https://github.com/facebook/flow/pull/5161
|
|
node.style.webkitTransition = theme.transitions.create('opacity', {
|
|
duration: typeof timeout === 'number' ? timeout : timeout.exit
|
|
});
|
|
node.style.opacity = '0';
|
|
|
|
if (_this.props.onExit) {
|
|
_this.props.onExit(node);
|
|
}
|
|
}, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
|
|
}
|
|
|
|
(0, _createClass3.default)(Fade, [{
|
|
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']);
|
|
|
|
|
|
var style = (0, _extends3.default)({}, styleProp);
|
|
|
|
// For server side rendering.
|
|
if (!this.props.in || appear) {
|
|
style.opacity = '0';
|
|
}
|
|
|
|
return _react2.default.createElement(
|
|
_Transition2.default,
|
|
(0, _extends3.default)({
|
|
appear: appear,
|
|
style: style,
|
|
onEnter: this.handleEnter,
|
|
onEntering: this.handleEntering,
|
|
onExit: this.handleExit
|
|
}, other),
|
|
children
|
|
);
|
|
}
|
|
}]);
|
|
return Fade;
|
|
}(_react2.default.Component);
|
|
|
|
Fade.defaultProps = {
|
|
appear: true,
|
|
timeout: {
|
|
enter: _transitions.duration.enteringScreen,
|
|
exit: _transitions.duration.leavingScreen
|
|
}
|
|
};
|
|
exports.default = (0, _withTheme2.default)()(Fade); |