Completely updated React, fixed #11, (hopefully)
This commit is contained in:
24
goTorrentWebUI/node_modules/material-ui/es/Tabs/Tab.d.ts
generated
vendored
24
goTorrentWebUI/node_modules/material-ui/es/Tabs/Tab.d.ts
generated
vendored
@@ -3,35 +3,28 @@ import { StandardProps } from '..';
|
||||
import { ButtonBaseProps } from '../ButtonBase';
|
||||
import { ButtonBaseClassKey } from '../ButtonBase/ButtonBase';
|
||||
|
||||
export interface TabProps extends StandardProps<
|
||||
ButtonBaseProps,
|
||||
TabClassKey,
|
||||
'onChange'
|
||||
> {
|
||||
export interface TabProps extends StandardProps<ButtonBaseProps, TabClassKey, 'onChange'> {
|
||||
disabled?: boolean;
|
||||
fullWidth?: boolean;
|
||||
icon?: string | React.ReactElement<any>;
|
||||
value?: any;
|
||||
label?: React.ReactNode;
|
||||
onChange?: (
|
||||
event: React.ChangeEvent<{ checked: boolean }>,
|
||||
value: any
|
||||
) => void;
|
||||
onChange?: (event: React.ChangeEvent<{ checked: boolean }>, value: any) => void;
|
||||
onClick?: React.EventHandler<any>;
|
||||
selected?: boolean;
|
||||
style?: object;
|
||||
textColor?: string | 'accent' | 'primary' | 'inherit';
|
||||
style?: React.CSSProperties;
|
||||
textColor?: string | 'secondary' | 'primary' | 'inherit';
|
||||
}
|
||||
|
||||
export type TabClassKey =
|
||||
| ButtonBaseClassKey
|
||||
| 'rootLabelIcon'
|
||||
| 'rootAccent'
|
||||
| 'rootAccentSelected'
|
||||
| 'rootAccentDisabled'
|
||||
| 'rootPrimary'
|
||||
| 'rootPrimarySelected'
|
||||
| 'rootPrimaryDisabled'
|
||||
| 'rootSecondary'
|
||||
| 'rootSecondarySelected'
|
||||
| 'rootSecondaryDisabled'
|
||||
| 'rootInherit'
|
||||
| 'rootInheritSelected'
|
||||
| 'rootInheritDisabled'
|
||||
@@ -39,8 +32,7 @@ export type TabClassKey =
|
||||
| 'wrapper'
|
||||
| 'labelContainer'
|
||||
| 'label'
|
||||
| 'labelWrapped'
|
||||
;
|
||||
| 'labelWrapped';
|
||||
|
||||
declare const Tab: React.ComponentType<TabProps>;
|
||||
|
||||
|
124
goTorrentWebUI/node_modules/material-ui/es/Tabs/Tab.js
generated
vendored
124
goTorrentWebUI/node_modules/material-ui/es/Tabs/Tab.js
generated
vendored
@@ -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 _Object$keys from 'babel-runtime/core-js/object/keys';
|
||||
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
||||
import _extends from 'babel-runtime/helpers/extends';
|
||||
// @inheritedComponent ButtonBase
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import withStyles from '../styles/withStyles';
|
||||
import ButtonBase from '../ButtonBase';
|
||||
import { capitalizeFirstLetter } from '../utils/helpers';
|
||||
import Icon from '../Icon';
|
||||
import { capitalize } from '../utils/helpers';
|
||||
|
||||
export const styles = theme => ({
|
||||
root: _extends({}, theme.typography.button, {
|
||||
@@ -28,27 +26,27 @@ export const styles = theme => ({
|
||||
rootLabelIcon: {
|
||||
height: 72
|
||||
},
|
||||
rootAccent: {
|
||||
color: theme.palette.text.secondary
|
||||
},
|
||||
rootAccentSelected: {
|
||||
color: theme.palette.secondary.A200
|
||||
},
|
||||
rootAccentDisabled: {
|
||||
color: theme.palette.text.disabled
|
||||
rootInherit: {
|
||||
color: 'inherit',
|
||||
opacity: 0.7
|
||||
},
|
||||
rootPrimary: {
|
||||
color: theme.palette.text.secondary
|
||||
},
|
||||
rootPrimarySelected: {
|
||||
color: theme.palette.primary[500]
|
||||
color: theme.palette.primary.main
|
||||
},
|
||||
rootPrimaryDisabled: {
|
||||
color: theme.palette.text.disabled
|
||||
},
|
||||
rootInherit: {
|
||||
color: 'inherit',
|
||||
opacity: 0.7
|
||||
rootSecondary: {
|
||||
color: theme.palette.text.secondary
|
||||
},
|
||||
rootSecondarySelected: {
|
||||
color: theme.palette.secondary.main
|
||||
},
|
||||
rootSecondaryDisabled: {
|
||||
color: theme.palette.text.disabled
|
||||
},
|
||||
rootInheritSelected: {
|
||||
opacity: 1
|
||||
@@ -84,7 +82,7 @@ export const styles = theme => ({
|
||||
}
|
||||
},
|
||||
labelWrapped: {
|
||||
[theme.breakpoints.down('md')]: {
|
||||
[theme.breakpoints.down('sm')]: {
|
||||
fontSize: theme.typography.pxToRem(theme.typography.fontSize - 2)
|
||||
}
|
||||
}
|
||||
@@ -138,7 +136,7 @@ class Tab extends React.Component {
|
||||
className: classNameProp,
|
||||
disabled,
|
||||
fullWidth,
|
||||
icon: iconProp,
|
||||
icon,
|
||||
indicator,
|
||||
label: labelProp,
|
||||
onChange,
|
||||
@@ -149,21 +147,11 @@ class Tab extends React.Component {
|
||||
} = _props,
|
||||
other = _objectWithoutProperties(_props, ['classes', 'className', 'disabled', 'fullWidth', 'icon', 'indicator', 'label', 'onChange', 'selected', 'style', 'textColor', 'value']);
|
||||
|
||||
let icon;
|
||||
|
||||
if (iconProp !== undefined) {
|
||||
icon = React.isValidElement(iconProp) ? iconProp : React.createElement(
|
||||
Icon,
|
||||
null,
|
||||
iconProp
|
||||
);
|
||||
}
|
||||
|
||||
let label;
|
||||
|
||||
if (labelProp !== undefined) {
|
||||
label = React.createElement(
|
||||
'div',
|
||||
'span',
|
||||
{ className: classes.labelContainer },
|
||||
React.createElement(
|
||||
'span',
|
||||
@@ -180,21 +168,20 @@ class Tab extends React.Component {
|
||||
);
|
||||
}
|
||||
|
||||
const className = classNames(classes.root, {
|
||||
[classes[`root${capitalizeFirstLetter(textColor)}`]]: true,
|
||||
[classes[`root${capitalizeFirstLetter(textColor)}Disabled`]]: disabled,
|
||||
[classes[`root${capitalizeFirstLetter(textColor)}Selected`]]: selected,
|
||||
const className = classNames(classes.root, classes[`root${capitalize(textColor)}`], {
|
||||
[classes[`root${capitalize(textColor)}Disabled`]]: disabled,
|
||||
[classes[`root${capitalize(textColor)}Selected`]]: selected,
|
||||
[classes.rootLabelIcon]: icon && label,
|
||||
[classes.fullWidth]: fullWidth
|
||||
}, classNameProp);
|
||||
|
||||
let style = {};
|
||||
|
||||
if (textColor !== 'accent' && textColor !== 'inherit') {
|
||||
if (textColor !== 'secondary' && textColor !== 'inherit') {
|
||||
style.color = textColor;
|
||||
}
|
||||
|
||||
style = Object.keys(style).length > 0 ? _extends({}, style, styleProp) : styleProp;
|
||||
style = _Object$keys(style).length > 0 ? _extends({}, style, styleProp) : styleProp;
|
||||
|
||||
return React.createElement(
|
||||
ButtonBase,
|
||||
@@ -219,7 +206,66 @@ class Tab extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
Tab.propTypes = process.env.NODE_ENV !== "production" ? {
|
||||
/**
|
||||
* Useful to extend the style applied to components.
|
||||
*/
|
||||
classes: PropTypes.object.isRequired,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* If `true`, the tab will be disabled.
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
fullWidth: PropTypes.bool,
|
||||
/**
|
||||
* The icon element.
|
||||
*/
|
||||
icon: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
* For server side rendering consideration, we let the selected tab
|
||||
* render the indicator.
|
||||
*/
|
||||
indicator: PropTypes.node,
|
||||
/**
|
||||
* The label element.
|
||||
*/
|
||||
label: PropTypes.node,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
selected: PropTypes.bool,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
style: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
textColor: PropTypes.oneOfType([PropTypes.string, PropTypes.oneOf(['secondary', 'primary', 'inherit'])]),
|
||||
/**
|
||||
* You can provide your own value. Otherwise, we fallback to the child position index.
|
||||
*/
|
||||
value: PropTypes.any
|
||||
} : {};
|
||||
|
||||
Tab.defaultProps = {
|
||||
disabled: false
|
||||
disabled: false,
|
||||
textColor: 'inherit'
|
||||
};
|
||||
|
||||
export default withStyles(styles, { name: 'MuiTab' })(Tab);
|
14
goTorrentWebUI/node_modules/material-ui/es/Tabs/TabIndicator.d.ts
generated
vendored
14
goTorrentWebUI/node_modules/material-ui/es/Tabs/TabIndicator.d.ts
generated
vendored
@@ -1,19 +1,13 @@
|
||||
import * as React from 'react';
|
||||
import { StandardProps } from '..';
|
||||
|
||||
export interface TabIndicatorProps extends StandardProps<
|
||||
React.HTMLAttributes<HTMLDivElement>,
|
||||
TabIndicatorClassKey
|
||||
> {
|
||||
color: 'accent' | 'primary' | string;
|
||||
export interface TabIndicatorProps
|
||||
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, TabIndicatorClassKey> {
|
||||
color: 'secondary' | 'primary' | string;
|
||||
style: { left: number; width: number };
|
||||
}
|
||||
|
||||
export type TabIndicatorClassKey =
|
||||
| 'root'
|
||||
| 'colorAccent'
|
||||
| 'colorPrimary'
|
||||
;
|
||||
export type TabIndicatorClassKey = 'root' | 'colorSecondary' | 'colorPrimary';
|
||||
|
||||
declare const TabIndicator: React.ComponentType<TabIndicatorProps>;
|
||||
|
||||
|
43
goTorrentWebUI/node_modules/material-ui/es/Tabs/TabIndicator.js
generated
vendored
43
goTorrentWebUI/node_modules/material-ui/es/Tabs/TabIndicator.js
generated
vendored
@@ -1,11 +1,9 @@
|
||||
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; };
|
||||
|
||||
// weak
|
||||
|
||||
import _extends from 'babel-runtime/helpers/extends';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import withStyles from '../styles/withStyles';
|
||||
import { capitalizeFirstLetter } from '../utils/helpers';
|
||||
import { capitalize } from '../utils/helpers';
|
||||
|
||||
export const styles = theme => ({
|
||||
root: {
|
||||
@@ -16,11 +14,11 @@ export const styles = theme => ({
|
||||
transition: theme.transitions.create(),
|
||||
willChange: 'left, width'
|
||||
},
|
||||
colorAccent: {
|
||||
backgroundColor: theme.palette.secondary.A200
|
||||
},
|
||||
colorPrimary: {
|
||||
backgroundColor: theme.palette.primary[500]
|
||||
backgroundColor: theme.palette.primary.main
|
||||
},
|
||||
colorSecondary: {
|
||||
backgroundColor: theme.palette.secondary.main
|
||||
}
|
||||
});
|
||||
|
||||
@@ -29,16 +27,37 @@ export const styles = theme => ({
|
||||
*/
|
||||
function TabIndicator(props) {
|
||||
const { classes, className: classNameProp, color, style: styleProp } = props;
|
||||
const colorPredefined = ['primary', 'accent'].indexOf(color) !== -1;
|
||||
const colorPredefined = ['primary', 'secondary'].indexOf(color) !== -1;
|
||||
const className = classNames(classes.root, {
|
||||
[classes[`color${capitalizeFirstLetter(color)}`]]: colorPredefined
|
||||
[classes[`color${capitalize(color)}`]]: colorPredefined
|
||||
}, classNameProp);
|
||||
|
||||
const style = colorPredefined ? styleProp : _extends({}, styleProp, {
|
||||
backgroundColor: color
|
||||
});
|
||||
|
||||
return React.createElement('div', { className: className, style: style });
|
||||
return React.createElement('span', { className: className, style: style });
|
||||
}
|
||||
|
||||
TabIndicator.propTypes = process.env.NODE_ENV !== "production" ? {
|
||||
/**
|
||||
* Useful to extend the style applied to components.
|
||||
*/
|
||||
classes: PropTypes.object.isRequired,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
* The color of the tab indicator.
|
||||
*/
|
||||
color: PropTypes.oneOfType([PropTypes.string, PropTypes.oneOf(['primary', 'secondary'])]),
|
||||
/**
|
||||
* @ignore
|
||||
* The style of the root element.
|
||||
*/
|
||||
style: PropTypes.object
|
||||
} : {};
|
||||
|
||||
export default withStyles(styles, { name: 'MuiTabIndicator' })(TabIndicator);
|
11
goTorrentWebUI/node_modules/material-ui/es/Tabs/TabScrollButton.d.ts
generated
vendored
11
goTorrentWebUI/node_modules/material-ui/es/Tabs/TabScrollButton.d.ts
generated
vendored
@@ -1,18 +1,13 @@
|
||||
import { StandardProps } from '..';
|
||||
import { ButtonBaseProps, ButtonBaseClassKey } from '../ButtonBase/ButtonBase';
|
||||
|
||||
export interface TabScrollButtonProps extends StandardProps<
|
||||
ButtonBaseProps,
|
||||
TabScrollButtonClassKey
|
||||
> {
|
||||
export interface TabScrollButtonProps
|
||||
extends StandardProps<ButtonBaseProps, TabScrollButtonClassKey> {
|
||||
direction?: 'left' | 'right';
|
||||
visible?: boolean;
|
||||
}
|
||||
|
||||
export type TabScrollButtonClassKey =
|
||||
| ButtonBaseClassKey
|
||||
| 'root'
|
||||
;
|
||||
export type TabScrollButtonClassKey = ButtonBaseClassKey | 'root';
|
||||
|
||||
declare const TabScrollButton: React.ComponentType<TabScrollButtonProps>;
|
||||
|
||||
|
43
goTorrentWebUI/node_modules/material-ui/es/Tabs/TabScrollButton.js
generated
vendored
43
goTorrentWebUI/node_modules/material-ui/es/Tabs/TabScrollButton.js
generated
vendored
@@ -1,15 +1,12 @@
|
||||
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; }
|
||||
|
||||
// weak
|
||||
|
||||
import _extends from 'babel-runtime/helpers/extends';
|
||||
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import KeyboardArrowLeft from '../internal/svg-icons/KeyboardArrowLeft';
|
||||
import KeyboardArrowRight from '../internal/svg-icons/KeyboardArrowRight';
|
||||
import withStyles from '../styles/withStyles';
|
||||
import ButtonBase from '../ButtonBase';
|
||||
import KeyboardArrowLeft from '../svg-icons/KeyboardArrowLeft';
|
||||
import KeyboardArrowRight from '../svg-icons/KeyboardArrowRight';
|
||||
|
||||
export const styles = theme => ({
|
||||
root: {
|
||||
@@ -21,6 +18,11 @@ export const styles = theme => ({
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
|
||||
var _ref = React.createElement(KeyboardArrowLeft, null);
|
||||
|
||||
var _ref2 = React.createElement(KeyboardArrowRight, null);
|
||||
|
||||
function TabScrollButton(props) {
|
||||
const { classes, className: classNameProp, direction, onClick, visible } = props,
|
||||
other = _objectWithoutProperties(props, ['classes', 'className', 'direction', 'onClick', 'visible']);
|
||||
@@ -34,10 +36,33 @@ function TabScrollButton(props) {
|
||||
return React.createElement(
|
||||
ButtonBase,
|
||||
_extends({ className: className, onClick: onClick, tabIndex: -1 }, other),
|
||||
direction === 'left' ? React.createElement(KeyboardArrowLeft, null) : React.createElement(KeyboardArrowRight, null)
|
||||
direction === 'left' ? _ref : _ref2
|
||||
);
|
||||
}
|
||||
|
||||
TabScrollButton.propTypes = process.env.NODE_ENV !== "production" ? {
|
||||
/**
|
||||
* Useful to extend the style applied to components.
|
||||
*/
|
||||
classes: PropTypes.object.isRequired,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* Which direction should the button indicate?
|
||||
*/
|
||||
direction: PropTypes.oneOf(['left', 'right']),
|
||||
/**
|
||||
* Callback to execute for button press.
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
/**
|
||||
* Should the button be present or just consume space.
|
||||
*/
|
||||
visible: PropTypes.bool
|
||||
} : {};
|
||||
|
||||
TabScrollButton.defaultProps = {
|
||||
visible: true
|
||||
};
|
||||
|
24
goTorrentWebUI/node_modules/material-ui/es/Tabs/Tabs.d.ts
generated
vendored
24
goTorrentWebUI/node_modules/material-ui/es/Tabs/Tabs.d.ts
generated
vendored
@@ -2,23 +2,20 @@ import * as React from 'react';
|
||||
import { StandardProps } from '..';
|
||||
import { ButtonBaseProps, ButtonBaseClassKey } from '../ButtonBase/ButtonBase';
|
||||
|
||||
export interface TabsProps extends StandardProps<
|
||||
ButtonBaseProps,
|
||||
TabsClassKey,
|
||||
'onChange'
|
||||
> {
|
||||
export interface TabsProps extends StandardProps<ButtonBaseProps, TabsClassKey, 'onChange'> {
|
||||
action?: (actions: TabsActions) => void;
|
||||
buttonClassName?: string;
|
||||
centered?: boolean;
|
||||
children?: React.ReactNode;
|
||||
fullWidth?: boolean;
|
||||
value: any;
|
||||
indicatorClassName?: string;
|
||||
indicatorColor?: 'accent' | 'primary' | string;
|
||||
onChange: (event: React.ChangeEvent<{}>, value: any) => void;
|
||||
indicatorColor?: 'secondary' | 'primary' | string;
|
||||
onChange?: (event: React.ChangeEvent<{}>, value: any) => void;
|
||||
scrollable?: boolean;
|
||||
scrollButtons?: 'auto' | 'on' | 'off';
|
||||
TabScrollButton?: React.ReactType,
|
||||
textColor?: 'accent' | 'primary' | 'inherit' | string;
|
||||
TabScrollButton?: React.ReactType;
|
||||
textColor?: 'secondary' | 'primary' | 'inherit' | string;
|
||||
value: any;
|
||||
width?: string;
|
||||
}
|
||||
|
||||
@@ -28,8 +25,11 @@ export type TabsClassKey =
|
||||
| 'scrollingContainer'
|
||||
| 'fixed'
|
||||
| 'scrollable'
|
||||
| 'centered'
|
||||
;
|
||||
| 'centered';
|
||||
|
||||
export interface TabsActions {
|
||||
updateIndicator(): void;
|
||||
}
|
||||
|
||||
declare const Tabs: React.ComponentType<TabsProps>;
|
||||
|
||||
|
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