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 _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);