Completely updated React, fixed #11, (hopefully)
This commit is contained in:
285
goTorrentWebUI/node_modules/material-ui/es/Snackbar/Snackbar.js
generated
vendored
285
goTorrentWebUI/node_modules/material-ui/es/Snackbar/Snackbar.js
generated
vendored
@@ -1,19 +1,16 @@
|
||||
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 _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
||||
import _extends from 'babel-runtime/helpers/extends';
|
||||
import React from 'react';
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import EventListener from 'react-event-listener';
|
||||
import withStyles from '../styles/withStyles';
|
||||
import { duration } from '../styles/transitions';
|
||||
import ClickAwayListener from '../utils/ClickAwayListener';
|
||||
import { capitalizeFirstLetter, createChainedFunction } from '../utils/helpers';
|
||||
import { capitalize, createChainedFunction } from '../utils/helpers';
|
||||
import Slide from '../transitions/Slide';
|
||||
import SnackbarContent from './SnackbarContent';
|
||||
|
||||
|
||||
export const styles = theme => {
|
||||
const gutter = theme.spacing.unit * 3;
|
||||
const top = { top: 0 };
|
||||
@@ -40,46 +37,32 @@ export const styles = theme => {
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center'
|
||||
},
|
||||
anchorTopCenter: {
|
||||
extend: [top],
|
||||
[theme.breakpoints.up('md')]: {
|
||||
extend: [center]
|
||||
}
|
||||
},
|
||||
anchorBottomCenter: {
|
||||
extend: [bottom],
|
||||
[theme.breakpoints.up('md')]: {
|
||||
extend: [center]
|
||||
}
|
||||
},
|
||||
anchorTopRight: {
|
||||
extend: [top, right],
|
||||
[theme.breakpoints.up('md')]: {
|
||||
left: 'auto',
|
||||
extend: [topSpace, rightSpace]
|
||||
}
|
||||
},
|
||||
anchorBottomRight: {
|
||||
extend: [bottom, right],
|
||||
[theme.breakpoints.up('md')]: {
|
||||
left: 'auto',
|
||||
extend: [bottomSpace, rightSpace]
|
||||
}
|
||||
},
|
||||
anchorTopLeft: {
|
||||
extend: [top, left],
|
||||
[theme.breakpoints.up('md')]: {
|
||||
right: 'auto',
|
||||
extend: [topSpace, leftSpace]
|
||||
}
|
||||
},
|
||||
anchorBottomLeft: {
|
||||
extend: [bottom, left],
|
||||
[theme.breakpoints.up('md')]: {
|
||||
right: 'auto',
|
||||
extend: [bottomSpace, leftSpace]
|
||||
}
|
||||
}
|
||||
anchorTopCenter: _extends({}, top, {
|
||||
[theme.breakpoints.up('md')]: _extends({}, center)
|
||||
}),
|
||||
anchorBottomCenter: _extends({}, bottom, {
|
||||
[theme.breakpoints.up('md')]: _extends({}, center)
|
||||
}),
|
||||
anchorTopRight: _extends({}, top, right, {
|
||||
[theme.breakpoints.up('md')]: _extends({
|
||||
left: 'auto'
|
||||
}, topSpace, rightSpace)
|
||||
}),
|
||||
anchorBottomRight: _extends({}, bottom, right, {
|
||||
[theme.breakpoints.up('md')]: _extends({
|
||||
left: 'auto'
|
||||
}, bottomSpace, rightSpace)
|
||||
}),
|
||||
anchorTopLeft: _extends({}, top, left, {
|
||||
[theme.breakpoints.up('md')]: _extends({
|
||||
right: 'auto'
|
||||
}, topSpace, leftSpace)
|
||||
}),
|
||||
anchorBottomLeft: _extends({}, bottom, left, {
|
||||
[theme.breakpoints.up('md')]: _extends({
|
||||
right: 'auto'
|
||||
}, bottomSpace, leftSpace)
|
||||
})
|
||||
};
|
||||
};
|
||||
|
||||
@@ -101,20 +84,20 @@ class Snackbar extends React.Component {
|
||||
}
|
||||
this.handleResume();
|
||||
}, this.handleClickAway = event => {
|
||||
if (this.props.onRequestClose) {
|
||||
this.props.onRequestClose(event, 'clickaway');
|
||||
if (this.props.onClose) {
|
||||
this.props.onClose(event, 'clickaway');
|
||||
}
|
||||
}, this.handlePause = () => {
|
||||
clearTimeout(this.timerAutoHide);
|
||||
}, this.handleResume = () => {
|
||||
if (this.props.autoHideDuration !== undefined) {
|
||||
if (this.props.autoHideDuration != null) {
|
||||
if (this.props.resumeHideDuration !== undefined) {
|
||||
this.setAutoHideTimer(this.props.resumeHideDuration);
|
||||
return;
|
||||
}
|
||||
this.setAutoHideTimer((this.props.autoHideDuration || 0) * 0.5);
|
||||
}
|
||||
}, this.handleTransitionExited = () => {
|
||||
}, this.handleExited = () => {
|
||||
this.setState({ exited: true });
|
||||
}, _temp;
|
||||
}
|
||||
@@ -132,7 +115,7 @@ class Snackbar extends React.Component {
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (nextProps.open && this.state.exited) {
|
||||
if (nextProps.open) {
|
||||
this.setState({ exited: false });
|
||||
}
|
||||
}
|
||||
@@ -153,17 +136,17 @@ class Snackbar extends React.Component {
|
||||
|
||||
// Timer that controls delay before snackbar auto hides
|
||||
setAutoHideTimer(autoHideDuration = null) {
|
||||
if (!this.props.onRequestClose || this.props.autoHideDuration === undefined) {
|
||||
if (!this.props.onClose || this.props.autoHideDuration == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearTimeout(this.timerAutoHide);
|
||||
this.timerAutoHide = setTimeout(() => {
|
||||
if (!this.props.onRequestClose || this.props.autoHideDuration === undefined) {
|
||||
if (!this.props.onClose || this.props.autoHideDuration == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.onRequestClose(null, 'timeout');
|
||||
this.props.onClose(null, 'timeout');
|
||||
}, autoHideDuration || this.props.autoHideDuration || 0);
|
||||
}
|
||||
|
||||
@@ -181,84 +164,204 @@ class Snackbar extends React.Component {
|
||||
action,
|
||||
anchorOrigin: { vertical, horizontal },
|
||||
autoHideDuration,
|
||||
resumeHideDuration,
|
||||
children,
|
||||
classes,
|
||||
className,
|
||||
transitionDuration,
|
||||
disableWindowBlurListener,
|
||||
message,
|
||||
onClose,
|
||||
onEnter,
|
||||
onEntering,
|
||||
onEntered,
|
||||
onEntering,
|
||||
onExit,
|
||||
onExiting,
|
||||
onExited,
|
||||
onExiting,
|
||||
onMouseEnter,
|
||||
onMouseLeave,
|
||||
onRequestClose,
|
||||
open,
|
||||
resumeHideDuration,
|
||||
SnackbarContentProps,
|
||||
transition: TransitionProp
|
||||
transition: TransitionProp,
|
||||
transitionDuration
|
||||
} = _props,
|
||||
other = _objectWithoutProperties(_props, ['action', 'anchorOrigin', 'autoHideDuration', 'resumeHideDuration', 'children', 'classes', 'className', 'transitionDuration', 'message', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'onExited', 'onMouseEnter', 'onMouseLeave', 'onRequestClose', 'open', 'SnackbarContentProps', 'transition']);
|
||||
other = _objectWithoutProperties(_props, ['action', 'anchorOrigin', 'autoHideDuration', 'children', 'classes', 'className', 'disableWindowBlurListener', 'message', 'onClose', 'onEnter', 'onEntered', 'onEntering', 'onExit', 'onExited', 'onExiting', 'onMouseEnter', 'onMouseLeave', 'open', 'resumeHideDuration', 'SnackbarContentProps', 'transition', 'transitionDuration']);
|
||||
|
||||
if (!open && this.state.exited) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const transitionProps = {
|
||||
in: open,
|
||||
appear: true,
|
||||
timeout: transitionDuration,
|
||||
onEnter,
|
||||
onEntering,
|
||||
onEntered,
|
||||
onExit,
|
||||
onExiting,
|
||||
onExited: createChainedFunction(this.handleTransitionExited, onExited)
|
||||
};
|
||||
const transitionContent = children || React.createElement(SnackbarContent, _extends({ message: message, action: action }, SnackbarContentProps));
|
||||
const transitionProps = {};
|
||||
|
||||
let transition;
|
||||
if (TransitionProp) {
|
||||
transition = React.createElement(
|
||||
TransitionProp,
|
||||
transitionProps,
|
||||
transitionContent
|
||||
);
|
||||
} else {
|
||||
transition = React.createElement(
|
||||
Slide,
|
||||
_extends({ direction: vertical === 'top' ? 'down' : 'up' }, transitionProps),
|
||||
transitionContent
|
||||
);
|
||||
// The provided transition might not support the direction property.
|
||||
if (TransitionProp === Slide) {
|
||||
transitionProps.direction = vertical === 'top' ? 'down' : 'up';
|
||||
}
|
||||
|
||||
return React.createElement(
|
||||
EventListener,
|
||||
{ target: 'window', onFocus: this.handleResume, onBlur: this.handlePause },
|
||||
{
|
||||
target: 'window',
|
||||
onFocus: disableWindowBlurListener ? undefined : this.handleResume,
|
||||
onBlur: disableWindowBlurListener ? undefined : this.handlePause
|
||||
},
|
||||
React.createElement(
|
||||
ClickAwayListener,
|
||||
{ onClickAway: this.handleClickAway },
|
||||
React.createElement(
|
||||
'div',
|
||||
_extends({
|
||||
className: classNames(classes.root, classes[`anchor${capitalizeFirstLetter(vertical)}${capitalizeFirstLetter(horizontal)}`], className),
|
||||
className: classNames(classes.root, classes[`anchor${capitalize(vertical)}${capitalize(horizontal)}`], className),
|
||||
onMouseEnter: this.handleMouseEnter,
|
||||
onMouseLeave: this.handleMouseLeave
|
||||
}, other),
|
||||
transition
|
||||
React.createElement(
|
||||
TransitionProp,
|
||||
_extends({
|
||||
appear: true,
|
||||
'in': open,
|
||||
onEnter: onEnter,
|
||||
onEntered: onEntered,
|
||||
onEntering: onEntering,
|
||||
onExit: onExit,
|
||||
onExited: createChainedFunction(this.handleExited, onExited),
|
||||
onExiting: onExiting,
|
||||
timeout: transitionDuration
|
||||
}, transitionProps),
|
||||
children || React.createElement(SnackbarContent, _extends({ message: message, action: action }, SnackbarContentProps))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Snackbar.propTypes = process.env.NODE_ENV !== "production" ? {
|
||||
/**
|
||||
* The action to display.
|
||||
*/
|
||||
action: PropTypes.node,
|
||||
/**
|
||||
* The anchor of the `Snackbar`.
|
||||
*/
|
||||
anchorOrigin: PropTypes.shape({
|
||||
horizontal: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['left', 'center', 'right'])]),
|
||||
vertical: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['top', 'center', 'bottom'])])
|
||||
}),
|
||||
/**
|
||||
* The number of milliseconds to wait before automatically calling the
|
||||
* `onClose` function. `onClose` should then set the state of the `open`
|
||||
* prop to hide the Snackbar. This behavior is disabled by default with
|
||||
* the `null` value.
|
||||
*/
|
||||
autoHideDuration: PropTypes.number,
|
||||
/**
|
||||
* If you wish the take control over the children of the component you can use this property.
|
||||
* When used, you replace the `SnackbarContent` component with the children.
|
||||
*/
|
||||
children: PropTypes.element,
|
||||
/**
|
||||
* Useful to extend the style applied to components.
|
||||
*/
|
||||
classes: PropTypes.object.isRequired,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the `autoHideDuration` timer will expire even if the window is not focused.
|
||||
*/
|
||||
disableWindowBlurListener: PropTypes.bool,
|
||||
/**
|
||||
* When displaying multiple consecutive Snackbars from a parent rendering a single
|
||||
* <Snackbar/>, add the key property to ensure independent treatment of each message.
|
||||
* e.g. <Snackbar key={message} />, otherwise, the message may update-in-place and
|
||||
* features such as autoHideDuration may be canceled.
|
||||
*/
|
||||
key: PropTypes.any,
|
||||
/**
|
||||
* The message to display.
|
||||
*/
|
||||
message: PropTypes.node,
|
||||
/**
|
||||
* Callback fired when the component requests to be closed.
|
||||
* Typically `onClose` is used to set state in the parent component,
|
||||
* which is used to control the `Snackbar` `open` prop.
|
||||
* The `reason` parameter can optionally be used to control the response to `onClose`,
|
||||
* for example ignoring `clickaway`.
|
||||
*
|
||||
* @param {object} event The event source of the callback
|
||||
* @param {string} reason Can be:`"timeout"` (`autoHideDuration` expired) or: `"clickaway"`
|
||||
*/
|
||||
onClose: PropTypes.func,
|
||||
/**
|
||||
* Callback fired before the transition is entering.
|
||||
*/
|
||||
onEnter: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the transition has entered.
|
||||
*/
|
||||
onEntered: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the transition is entering.
|
||||
*/
|
||||
onEntering: PropTypes.func,
|
||||
/**
|
||||
* Callback fired before the transition is exiting.
|
||||
*/
|
||||
onExit: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the transition has exited.
|
||||
*/
|
||||
onExited: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the transition is exiting.
|
||||
*/
|
||||
onExiting: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onMouseEnter: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onMouseLeave: PropTypes.func,
|
||||
/**
|
||||
* If true, `Snackbar` is open.
|
||||
*/
|
||||
open: PropTypes.bool,
|
||||
/**
|
||||
* The number of milliseconds to wait before dismissing after user interaction.
|
||||
* If `autoHideDuration` property isn't specified, it does nothing.
|
||||
* If `autoHideDuration` property is specified but `resumeHideDuration` isn't,
|
||||
* we default to `autoHideDuration / 2` ms.
|
||||
*/
|
||||
resumeHideDuration: PropTypes.number,
|
||||
/**
|
||||
* Properties applied to the `SnackbarContent` element.
|
||||
*/
|
||||
SnackbarContentProps: PropTypes.object,
|
||||
/**
|
||||
* Transition component.
|
||||
*/
|
||||
transition: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
||||
/**
|
||||
* The duration for the transition, in milliseconds.
|
||||
* You may specify a single timeout for all transitions, or individually with an object.
|
||||
*/
|
||||
transitionDuration: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({ enter: PropTypes.number, exit: PropTypes.number })])
|
||||
} : {};
|
||||
|
||||
Snackbar.defaultProps = {
|
||||
anchorOrigin: { vertical: 'bottom', horizontal: 'center' },
|
||||
anchorOrigin: {
|
||||
vertical: 'bottom',
|
||||
horizontal: 'center'
|
||||
},
|
||||
disableWindowBlurListener: false,
|
||||
transition: Slide,
|
||||
transitionDuration: {
|
||||
enter: duration.enteringScreen,
|
||||
exit: duration.leavingScreen
|
||||
}
|
||||
};
|
||||
|
||||
export default withStyles(styles, { flip: false, name: 'MuiSnackbar' })(Snackbar);
|
Reference in New Issue
Block a user