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

@@ -1,16 +1,14 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
// @inheritedComponent Transition
import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import Transition from 'react-transition-group/Transition';
import withStyles from '../styles/withStyles';
import { duration } from '../styles/transitions';
import { getTransitionProps } from './utils';
export const styles = theme => ({
container: {
@@ -30,11 +28,16 @@ export const styles = theme => ({
}
});
/**
* The Collapes transition is used by the
* [Vetical Stepper](/demos/steppers#vertical-stepper) StepContent component.
* It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
*/
class Collapse extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.wrapper = null, this.autoTransitionDuration = undefined, this.handleEnter = node => {
return _temp = super(...args), this.wrapper = null, this.autoTransitionDuration = undefined, this.timer = null, this.handleEnter = node => {
node.style.height = this.props.collapsedHeight;
if (this.props.onEnter) {
@@ -44,16 +47,16 @@ class Collapse extends React.Component {
const { timeout, theme } = this.props;
const wrapperHeight = this.wrapper ? this.wrapper.clientHeight : 0;
const { duration: transitionDuration } = getTransitionProps(this.props, {
mode: 'enter'
});
if (timeout === 'auto') {
const duration2 = theme.transitions.getAutoHeightDuration(wrapperHeight);
node.style.transitionDuration = `${duration2}ms`;
this.autoTransitionDuration = duration2;
} else if (typeof timeout === 'number') {
node.style.transitionDuration = `${timeout}ms`;
} else if (timeout) {
node.style.transitionDuration = `${timeout.enter}ms`;
} else {
// The propType will warn in this case.
node.style.transitionDuration = typeof transitionDuration === 'string' ? transitionDuration : `${transitionDuration}ms`;
}
node.style.height = `${wrapperHeight}px`;
@@ -78,16 +81,16 @@ class Collapse extends React.Component {
const { timeout, theme } = this.props;
const wrapperHeight = this.wrapper ? this.wrapper.clientHeight : 0;
const { duration: transitionDuration } = getTransitionProps(this.props, {
mode: 'exit'
});
if (timeout === 'auto') {
const duration2 = theme.transitions.getAutoHeightDuration(wrapperHeight);
node.style.transitionDuration = `${duration2}ms`;
this.autoTransitionDuration = duration2;
} else if (typeof timeout === 'number') {
node.style.transitionDuration = `${timeout}ms`;
} else if (timeout) {
node.style.transitionDuration = `${timeout.exit}ms`;
} else {
// The propType will warn in this case.
node.style.transitionDuration = typeof transitionDuration === 'string' ? transitionDuration : `${transitionDuration}ms`;
}
node.style.height = this.props.collapsedHeight;
@@ -95,57 +98,58 @@ class Collapse extends React.Component {
if (this.props.onExiting) {
this.props.onExiting(node);
}
}, this.addEndListener = (node, next) => {
let timeout;
}, this.addEndListener = (_, next) => {
if (this.props.timeout === 'auto') {
timeout = this.autoTransitionDuration || 0;
} else {
timeout = this.props.timeout;
this.timer = setTimeout(next, this.autoTransitionDuration || 0);
}
setTimeout(next, timeout);
}, _temp;
}
componentWillUnmount() {
clearTimeout(this.timer);
}
render() {
const _props = this.props,
{
appear,
children,
classes,
className,
collapsedHeight,
component: Component,
onEnter,
onEntering,
onEntered,
onEntering,
onExit,
onExiting,
style,
timeout,
theme
theme,
timeout
} = _props,
other = _objectWithoutProperties(_props, ['appear', 'children', 'classes', 'collapsedHeight', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'style', 'timeout', 'theme']);
other = _objectWithoutProperties(_props, ['children', 'classes', 'className', 'collapsedHeight', 'component', 'onEnter', 'onEntered', 'onEntering', 'onExit', 'onExiting', 'style', 'theme', 'timeout']);
return React.createElement(
Transition,
_extends({
appear: appear,
onEntering: this.handleEntering,
onEnter: this.handleEnter,
onEntered: this.handleEntered,
onExiting: this.handleExiting,
onExit: this.handleExit,
addEndListener: this.addEndListener,
style: _extends({ minHeight: collapsedHeight }, style)
timeout: timeout === 'auto' ? null : timeout
}, other),
state => {
(state, childProps) => {
return React.createElement(
'div',
{
Component,
_extends({
className: classNames(classes.container, {
[classes.entered]: state === 'entered'
}, className),
style: _extends({}, style, {
minHeight: collapsedHeight
})
},
}, childProps),
React.createElement(
'div',
{
@@ -166,11 +170,75 @@ class Collapse extends React.Component {
}
}
Collapse.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content node to be collapsed.
*/
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The height of the container when collapsed.
*/
collapsedHeight: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* If `true`, the component will transition in.
*/
in: PropTypes.bool,
/**
* @ignore
*/
onEnter: PropTypes.func,
/**
* @ignore
*/
onEntered: PropTypes.func,
/**
* @ignore
*/
onEntering: PropTypes.func,
/**
* @ignore
*/
onExit: PropTypes.func,
/**
* @ignore
*/
onExiting: PropTypes.func,
/**
* @ignore
*/
style: PropTypes.object,
/**
* @ignore
*/
theme: PropTypes.object.isRequired,
/**
* The duration for the transition, in milliseconds.
* You may specify a single timeout for all transitions, or individually with an object.
*
* Set to 'auto' to automatically calculate transition time based on height.
*/
timeout: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({ enter: PropTypes.number, exit: PropTypes.number }), PropTypes.oneOf(['auto'])])
} : {};
Collapse.defaultProps = {
appear: false,
collapsedHeight: '0px',
component: 'div',
timeout: duration.standard
};
export default withStyles(styles, {
withTheme: true,
name: 'MuiCollapse'