Completely updated React, fixed #11, (hopefully)
This commit is contained in:
124
goTorrentWebUI/node_modules/material-ui/es/Tabs/Tabs.js
generated
vendored
124
goTorrentWebUI/node_modules/material-ui/es/Tabs/Tabs.js
generated
vendored
@@ -1,9 +1,8 @@
|
||||
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';
|
||||
import _Number$isNaN from 'babel-runtime/core-js/number/is-nan';
|
||||
import React from 'react';
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
import warning from 'warning';
|
||||
import classNames from 'classnames';
|
||||
import EventListener from 'react-event-listener';
|
||||
@@ -15,7 +14,6 @@ import withStyles from '../styles/withStyles';
|
||||
import TabIndicator from './TabIndicator';
|
||||
import TabScrollButton from './TabScrollButton';
|
||||
|
||||
|
||||
export const styles = theme => ({
|
||||
root: {
|
||||
overflow: 'hidden',
|
||||
@@ -42,7 +40,7 @@ export const styles = theme => ({
|
||||
justifyContent: 'center'
|
||||
},
|
||||
buttonAuto: {
|
||||
[theme.breakpoints.down('sm')]: {
|
||||
[theme.breakpoints.down('xs')]: {
|
||||
display: 'none'
|
||||
}
|
||||
}
|
||||
@@ -53,10 +51,7 @@ class Tabs extends React.Component {
|
||||
var _temp;
|
||||
|
||||
return _temp = super(...args), this.state = {
|
||||
indicatorStyle: {
|
||||
left: 0,
|
||||
width: 0
|
||||
},
|
||||
indicatorStyle: {},
|
||||
scrollerStyle: {
|
||||
marginBottom: 0
|
||||
},
|
||||
@@ -81,7 +76,7 @@ class Tabs extends React.Component {
|
||||
const showScrollButtons = scrollable && (scrollButtons === 'auto' || scrollButtons === 'on');
|
||||
|
||||
conditionalElements.scrollButtonLeft = showScrollButtons ? React.createElement(TabScrollButtonProp, {
|
||||
direction: theme.direction === 'rtl' ? 'right' : 'left',
|
||||
direction: theme && theme.direction === 'rtl' ? 'right' : 'left',
|
||||
onClick: this.handleLeftScrollClick,
|
||||
visible: this.state.showLeftScroll,
|
||||
className: classNames({
|
||||
@@ -90,7 +85,7 @@ class Tabs extends React.Component {
|
||||
}) : null;
|
||||
|
||||
conditionalElements.scrollButtonRight = showScrollButtons ? React.createElement(TabScrollButtonProp, {
|
||||
direction: theme.direction === 'rtl' ? 'left' : 'right',
|
||||
direction: theme && theme.direction === 'rtl' ? 'left' : 'right',
|
||||
onClick: this.handleRightScrollClick,
|
||||
visible: this.state.showRightScroll,
|
||||
className: classNames({
|
||||
@@ -120,7 +115,7 @@ class Tabs extends React.Component {
|
||||
|
||||
if (children.length > 0) {
|
||||
const tab = children[this.valueToIndex[value]];
|
||||
warning(Boolean(tab), `Material-UI: the value provided \`${value}\` is invalid`);
|
||||
process.env.NODE_ENV !== "production" ? warning(tab, `Material-UI: the value provided \`${value}\` is invalid`) : void 0;
|
||||
tabMeta = tab ? tab.getBoundingClientRect() : null;
|
||||
}
|
||||
}
|
||||
@@ -156,7 +151,6 @@ class Tabs extends React.Component {
|
||||
}
|
||||
}, this.scrollSelectedIntoView = () => {
|
||||
const { theme, value } = this.props;
|
||||
|
||||
const { tabsMeta, tabMeta } = this.getTabsMeta(value, theme.direction);
|
||||
|
||||
if (!tabMeta || !tabsMeta) {
|
||||
@@ -195,6 +189,12 @@ class Tabs extends React.Component {
|
||||
this.setState({ mounted: true });
|
||||
this.updateIndicatorState(this.props);
|
||||
this.updateScrollButtonState();
|
||||
|
||||
if (this.props.action) {
|
||||
this.props.action({
|
||||
updateIndicator: this.handleResize
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
@@ -231,7 +231,7 @@ class Tabs extends React.Component {
|
||||
width: tabMeta ? tabMeta.width : 0
|
||||
};
|
||||
|
||||
if ((indicatorStyle.left !== this.state.indicatorStyle.left || indicatorStyle.width !== this.state.indicatorStyle.width) && !Number.isNaN(indicatorStyle.left) && !Number.isNaN(indicatorStyle.width)) {
|
||||
if ((indicatorStyle.left !== this.state.indicatorStyle.left || indicatorStyle.width !== this.state.indicatorStyle.width) && !_Number$isNaN(indicatorStyle.left) && !_Number$isNaN(indicatorStyle.width)) {
|
||||
this.setState({ indicatorStyle });
|
||||
}
|
||||
}
|
||||
@@ -239,10 +239,11 @@ class Tabs extends React.Component {
|
||||
render() {
|
||||
const _props = this.props,
|
||||
{
|
||||
action,
|
||||
buttonClassName,
|
||||
centered,
|
||||
classes,
|
||||
children: childrenProp,
|
||||
classes,
|
||||
className: classNameProp,
|
||||
fullWidth,
|
||||
indicatorClassName,
|
||||
@@ -255,7 +256,7 @@ class Tabs extends React.Component {
|
||||
theme,
|
||||
value
|
||||
} = _props,
|
||||
other = _objectWithoutProperties(_props, ['buttonClassName', 'centered', 'classes', 'children', 'className', 'fullWidth', 'indicatorClassName', 'indicatorColor', 'onChange', 'scrollable', 'scrollButtons', 'TabScrollButton', 'textColor', 'theme', 'value']);
|
||||
other = _objectWithoutProperties(_props, ['action', 'buttonClassName', 'centered', 'children', 'classes', 'className', 'fullWidth', 'indicatorClassName', 'indicatorColor', 'onChange', 'scrollable', 'scrollButtons', 'TabScrollButton', 'textColor', 'theme', 'value']);
|
||||
|
||||
const className = classNames(classes.root, classNameProp);
|
||||
const scrollerClassName = classNames(classes.scrollingContainer, {
|
||||
@@ -329,13 +330,96 @@ class Tabs extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
Tabs.propTypes = process.env.NODE_ENV !== "production" ? {
|
||||
/**
|
||||
* Callback fired when the component mounts.
|
||||
* This is useful when you want to trigger an action programmatically.
|
||||
* It currently only supports `updateIndicator()` action.
|
||||
*
|
||||
* @param {object} actions This object contains all possible actions
|
||||
* that can be triggered programmatically.
|
||||
*/
|
||||
action: PropTypes.func,
|
||||
/**
|
||||
* The CSS class name of the scroll button elements.
|
||||
*/
|
||||
buttonClassName: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the tabs will be centered.
|
||||
* This property is intended for large views.
|
||||
*/
|
||||
centered: PropTypes.bool,
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Useful to extend the style applied to components.
|
||||
*/
|
||||
classes: PropTypes.object.isRequired,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the tabs will grow to use all the available space.
|
||||
* This property is intended for small views, like on mobile.
|
||||
*/
|
||||
fullWidth: PropTypes.bool,
|
||||
/**
|
||||
* The CSS class name of the indicator element.
|
||||
*/
|
||||
indicatorClassName: PropTypes.string,
|
||||
/**
|
||||
* Determines the color of the indicator.
|
||||
*/
|
||||
indicatorColor: PropTypes.oneOfType([PropTypes.string, PropTypes.oneOf(['secondary', 'primary'])]),
|
||||
/**
|
||||
* Callback fired when the value changes.
|
||||
*
|
||||
* @param {object} event The event source of the callback
|
||||
* @param {number} value We default to the index of the child
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* True invokes scrolling properties and allow for horizontally scrolling
|
||||
* (or swiping) the tab bar.
|
||||
*/
|
||||
scrollable: PropTypes.bool,
|
||||
/**
|
||||
* Determine behavior of scroll buttons when tabs are set to scroll
|
||||
* `auto` will only present them on medium and larger viewports
|
||||
* `on` will always present them
|
||||
* `off` will never present them
|
||||
*/
|
||||
scrollButtons: PropTypes.oneOf(['auto', 'on', 'off']),
|
||||
/**
|
||||
* The component used to render the scroll buttons.
|
||||
*/
|
||||
TabScrollButton: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
||||
/**
|
||||
* Determines the color of the `Tab`.
|
||||
*/
|
||||
textColor: PropTypes.oneOf(['secondary', 'primary', 'inherit']),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
theme: PropTypes.object.isRequired,
|
||||
/**
|
||||
* The value of the currently selected `Tab`.
|
||||
* If you don't want any selected `Tab`, you can set this property to `false`.
|
||||
*/
|
||||
value: PropTypes.any
|
||||
} : {};
|
||||
|
||||
Tabs.defaultProps = {
|
||||
centered: false,
|
||||
fullWidth: false,
|
||||
indicatorColor: 'accent',
|
||||
indicatorColor: 'secondary',
|
||||
scrollable: false,
|
||||
scrollButtons: 'auto',
|
||||
TabScrollButton,
|
||||
textColor: 'inherit'
|
||||
};
|
||||
export default withStyles(styles, { withTheme: true, name: 'MuiTabs' })(Tabs);
|
||||
|
||||
export default withStyles(styles, { name: 'MuiTabs', withTheme: true })(Tabs);
|
Reference in New Issue
Block a user