Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,23 @@
import * as React from 'react';
import { StandardProps } from '..';
import { Theme } from '../styles/createMuiTheme';
import { TransitionDuration, TransitionProps } from '../internal/transition';
export interface CollapseProps extends StandardProps<
TransitionProps,
CollapseClassKey,
'children'
> {
children?: React.ReactNode;
theme?: Theme;
timeout?: TransitionDuration | 'auto';
}
export type CollapseClassKey =
| 'container'
| 'entered'
;
declare const Collapse: React.ComponentType<CollapseProps>;
export default Collapse;

View File

@@ -0,0 +1,177 @@
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; }
// @inheritedComponent Transition
import React from 'react';
import classNames from 'classnames';
import Transition from 'react-transition-group/Transition';
import withStyles from '../styles/withStyles';
import { duration } from '../styles/transitions';
export const styles = theme => ({
container: {
height: 0,
overflow: 'hidden',
transition: theme.transitions.create('height')
},
entered: {
height: 'auto'
},
wrapper: {
// Hack to get children with a negative margin to not falsify the height computation.
display: 'flex'
},
wrapperInner: {
width: '100%'
}
});
class Collapse extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.wrapper = null, this.autoTransitionDuration = undefined, this.handleEnter = node => {
node.style.height = this.props.collapsedHeight;
if (this.props.onEnter) {
this.props.onEnter(node);
}
}, this.handleEntering = node => {
const { timeout, theme } = this.props;
const wrapperHeight = this.wrapper ? this.wrapper.clientHeight : 0;
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.height = `${wrapperHeight}px`;
if (this.props.onEntering) {
this.props.onEntering(node);
}
}, this.handleEntered = node => {
node.style.height = 'auto';
if (this.props.onEntered) {
this.props.onEntered(node);
}
}, this.handleExit = node => {
const wrapperHeight = this.wrapper ? this.wrapper.clientHeight : 0;
node.style.height = `${wrapperHeight}px`;
if (this.props.onExit) {
this.props.onExit(node);
}
}, this.handleExiting = node => {
const { timeout, theme } = this.props;
const wrapperHeight = this.wrapper ? this.wrapper.clientHeight : 0;
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.height = this.props.collapsedHeight;
if (this.props.onExiting) {
this.props.onExiting(node);
}
}, this.addEndListener = (node, next) => {
let timeout;
if (this.props.timeout === 'auto') {
timeout = this.autoTransitionDuration || 0;
} else {
timeout = this.props.timeout;
}
setTimeout(next, timeout);
}, _temp;
}
render() {
const _props = this.props,
{
appear,
children,
classes,
collapsedHeight,
onEnter,
onEntering,
onEntered,
onExit,
onExiting,
style,
timeout,
theme
} = _props,
other = _objectWithoutProperties(_props, ['appear', 'children', 'classes', 'collapsedHeight', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'style', 'timeout', 'theme']);
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)
}, other),
state => {
return React.createElement(
'div',
{
className: classNames(classes.container, {
[classes.entered]: state === 'entered'
})
},
React.createElement(
'div',
{
className: classes.wrapper,
ref: node => {
this.wrapper = node;
}
},
React.createElement(
'div',
{ className: classes.wrapperInner },
children
)
)
);
}
);
}
}
Collapse.defaultProps = {
appear: false,
collapsedHeight: '0px',
timeout: duration.standard
};
export default withStyles(styles, {
withTheme: true,
name: 'MuiCollapse'
})(Collapse);

View File

@@ -0,0 +1,12 @@
import * as React from 'react';
import { Theme } from '../styles/createMuiTheme';
import { TransitionDuration, TransitionProps } from '../internal/transition';
export interface FadeProps extends TransitionProps {
theme?: Theme;
timeout?: TransitionDuration;
}
declare const Fade: React.ComponentType<FadeProps>;
export default Fade;

View File

@@ -0,0 +1,103 @@
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; }
// @inheritedComponent Transition
import React from 'react';
import Transition from 'react-transition-group/Transition';
import { duration } from '../styles/transitions';
import withTheme from '../styles/withTheme';
const reflow = node => 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.
*/
class Fade extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.handleEnter = node => {
node.style.opacity = '0';
reflow(node);
if (this.props.onEnter) {
this.props.onEnter(node);
}
}, this.handleEntering = node => {
const { theme, timeout } = this.props;
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 = node => {
const { theme, timeout } = this.props;
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;
}
render() {
const _props = this.props,
{
appear,
children,
onEnter,
onEntering,
onExit,
style: styleProp,
theme
} = _props,
other = _objectWithoutProperties(_props, ['appear', 'children', 'onEnter', 'onEntering', 'onExit', 'style', 'theme']);
const style = _extends({}, styleProp);
// For server side rendering.
if (!this.props.in || appear) {
style.opacity = '0';
}
return React.createElement(
Transition,
_extends({
appear: appear,
style: style,
onEnter: this.handleEnter,
onEntering: this.handleEntering,
onExit: this.handleExit
}, other),
children
);
}
}
Fade.defaultProps = {
appear: true,
timeout: {
enter: duration.enteringScreen,
exit: duration.leavingScreen
}
};
export default withTheme()(Fade);

View File

@@ -0,0 +1,12 @@
import * as React from 'react';
import { Theme } from '../styles/createMuiTheme';
import { TransitionDuration, TransitionProps } from '../internal/transition';
export interface GrowProps extends TransitionProps {
theme?: Theme;
timeout?: TransitionDuration | 'auto';
}
declare const Grow: React.ComponentType<GrowProps>;
export default Grow;

View File

@@ -0,0 +1,147 @@
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; }
// @inheritedComponent CSSTransition
import React from 'react';
import CSSTransition from 'react-transition-group/CSSTransition';
import withTheme from '../styles/withTheme';
// Only exported for tests.
export function getScale(value) {
return `scale(${value}, ${Math.pow(value, 2)})`;
}
/**
* The Grow transition is used by the Popover component.
* It's using [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
*/
class Grow extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.autoTimeout = undefined, this.handleEnter = node => {
node.style.opacity = '0';
node.style.transform = getScale(0.75);
if (this.props.onEnter) {
this.props.onEnter(node);
}
}, this.handleEntering = node => {
const { theme, timeout } = this.props;
let duration = 0;
if (timeout === 'auto') {
duration = theme.transitions.getAutoHeightDuration(node.clientHeight);
this.autoTimeout = duration;
} else if (typeof timeout === 'number') {
duration = timeout;
} else if (timeout) {
duration = timeout.enter;
} else {
// The propType will warn in this case.
}
node.style.transition = [theme.transitions.create('opacity', {
duration
}), theme.transitions.create('transform', {
duration: duration * 0.666
})].join(',');
node.style.opacity = '1';
node.style.transform = getScale(1);
if (this.props.onEntering) {
this.props.onEntering(node);
}
}, this.handleExit = node => {
const { theme, timeout } = this.props;
let duration = 0;
if (timeout === 'auto') {
duration = theme.transitions.getAutoHeightDuration(node.clientHeight);
this.autoTimeout = duration;
} else if (typeof timeout === 'number') {
duration = timeout;
} else if (timeout) {
duration = timeout.exit;
} else {
// The propType will warn in this case.
}
node.style.transition = [theme.transitions.create('opacity', {
duration
}), theme.transitions.create('transform', {
duration: duration * 0.666,
delay: duration * 0.333
})].join(',');
node.style.opacity = '0';
node.style.transform = getScale(0.75);
if (this.props.onExit) {
this.props.onExit(node);
}
}, this.addEndListener = (node, next) => {
let timeout;
if (this.props.timeout === 'auto') {
timeout = this.autoTimeout || 0;
} else {
timeout = this.props.timeout;
}
setTimeout(next, timeout);
}, _temp;
}
render() {
const _props = this.props,
{
appear,
children,
onEnter,
onEntering,
onExit,
rootRef,
style: styleProp,
transitionClasses,
timeout,
theme
} = _props,
other = _objectWithoutProperties(_props, ['appear', 'children', 'onEnter', 'onEntering', 'onExit', 'rootRef', 'style', 'transitionClasses', 'timeout', 'theme']);
const style = _extends({}, children.props.style, styleProp);
// For server side rendering.
if (!this.props.in || appear) {
style.opacity = '0';
}
return React.createElement(
CSSTransition,
_extends({
classNames: transitionClasses,
onEnter: this.handleEnter,
onEntering: this.handleEntering,
onExit: this.handleExit,
addEndListener: this.addEndListener,
appear: appear,
style: style
}, other, {
ref: rootRef
}),
children
);
}
}
Grow.defaultProps = {
appear: true,
timeout: 'auto',
transitionClasses: {}
};
export default withTheme()(Grow);

View File

@@ -0,0 +1,13 @@
import * as React from 'react';
import { Theme } from '../styles/createMuiTheme';
import { TransitionDuration, TransitionProps } from '../internal/transition';
export interface SlideProps extends TransitionProps {
direction?: 'left' | 'right' | 'up' | 'down';
theme?: Theme;
timeout?: TransitionDuration;
}
declare const Slide: React.ComponentType<SlideProps>;
export default Slide;

View File

@@ -0,0 +1,190 @@
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; }
// @inheritedComponent Transition
import React from 'react';
import { findDOMNode } from 'react-dom';
import EventListener from 'react-event-listener';
import debounce from 'lodash/debounce';
import Transition from 'react-transition-group/Transition';
import withTheme from '../styles/withTheme';
import { duration } from '../styles/transitions';
const GUTTER = 24;
// Translate the node so he can't be seen on the screen.
// Later, we gonna translate back the node to his original location
// with `translate3d(0, 0, 0)`.`
function getTranslateValue(props, node) {
const { direction } = props;
const rect = node.getBoundingClientRect();
let transform;
if (node.fakeTransform) {
transform = node.fakeTransform;
} else {
const computedStyle = window.getComputedStyle(node);
transform = computedStyle.getPropertyValue('-webkit-transform') || computedStyle.getPropertyValue('transform');
}
let offsetX = 0;
let offsetY = 0;
if (transform && transform !== 'none' && typeof transform === 'string') {
const transformValues = transform.split('(')[1].split(')')[0].split(',');
offsetX = parseInt(transformValues[4], 10);
offsetY = parseInt(transformValues[5], 10);
}
if (direction === 'left') {
return `translateX(100vw) translateX(-${rect.left - offsetX}px)`;
} else if (direction === 'right') {
return `translateX(-${rect.left + rect.width + GUTTER - offsetX}px)`;
} else if (direction === 'up') {
return `translateY(100vh) translateY(-${rect.top - offsetY}px)`;
}
// direction === 'down
return `translate3d(0, ${0 - (rect.top + rect.height)}px, 0)`;
}
export function setTranslateValue(props, node) {
const transform = getTranslateValue(props, node);
if (transform) {
node.style.transform = transform;
node.style.webkitTransform = transform;
}
}
const reflow = node => node.scrollTop;
class Slide extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = {
// We use this state to handle the server-side rendering.
firstMount: true
}, this.transition = null, this.handleResize = debounce(() => {
// Skip configuration where the position is screen size invariant.
if (this.props.in || this.props.direction === 'down' || this.props.direction === 'right') {
return;
}
const node = findDOMNode(this.transition);
if (node instanceof HTMLElement) {
setTranslateValue(this.props, node);
}
}, 166), this.handleEnter = node => {
setTranslateValue(this.props, node);
reflow(node);
if (this.props.onEnter) {
this.props.onEnter(node);
}
}, this.handleEntering = node => {
const { theme, timeout } = this.props;
node.style.transition = theme.transitions.create('transform', {
duration: typeof timeout === 'number' ? timeout : timeout.enter,
easing: theme.transitions.easing.easeOut
});
// $FlowFixMe - https://github.com/facebook/flow/pull/5161
node.style.webkitTransition = theme.transitions.create('-webkit-transform', {
duration: typeof timeout === 'number' ? timeout : timeout.enter,
easing: theme.transitions.easing.easeOut
});
node.style.transform = 'translate3d(0, 0, 0)';
node.style.webkitTransform = 'translate3d(0, 0, 0)';
if (this.props.onEntering) {
this.props.onEntering(node);
}
}, this.handleExit = node => {
const { theme, timeout } = this.props;
node.style.transition = theme.transitions.create('transform', {
duration: typeof timeout === 'number' ? timeout : timeout.exit,
easing: theme.transitions.easing.sharp
});
// $FlowFixMe - https://github.com/facebook/flow/pull/5161
node.style.webkitTransition = theme.transitions.create('-webkit-transform', {
duration: typeof timeout === 'number' ? timeout : timeout.exit,
easing: theme.transitions.easing.sharp
});
setTranslateValue(this.props, node);
if (this.props.onExit) {
this.props.onExit(node);
}
}, _temp;
}
componentDidMount() {
// state.firstMount handle SSR, once the component is mounted, we need
// to propery hide it.
if (!this.props.in) {
// We need to set initial translate values of transition element
// otherwise component will be shown when in=false.
const element = findDOMNode(this.transition);
if (element instanceof HTMLElement) {
element.style.visibility = 'inherit';
setTranslateValue(this.props, element);
}
}
}
componentWillReceiveProps() {
this.setState({
firstMount: false
});
}
componentWillUnmount() {
this.handleResize.cancel();
}
render() {
const _props = this.props,
{ children, onEnter, onEntering, onExit, style: styleProp, theme } = _props,
other = _objectWithoutProperties(_props, ['children', 'onEnter', 'onEntering', 'onExit', 'style', 'theme']);
const style = _extends({}, styleProp);
if (!this.props.in && this.state.firstMount) {
style.visibility = 'hidden';
}
return React.createElement(
EventListener,
{ target: 'window', onResize: this.handleResize },
React.createElement(
Transition,
_extends({
onEnter: this.handleEnter,
onEntering: this.handleEntering,
onExit: this.handleExit,
appear: true,
style: style
}, other, {
ref: node => {
this.transition = node;
}
}),
children
)
);
}
}
Slide.defaultProps = {
direction: 'down',
timeout: {
enter: duration.enteringScreen,
exit: duration.leavingScreen
}
};
export default withTheme()(Slide);