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,12 +1,9 @@
// @flow
import React from 'react';
import type { ElementType, Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
fontFamily: theme.typography.fontFamily,
width: '100%',
@@ -16,36 +13,7 @@ export const styles = (theme: Object) => ({
},
});
type ProvidedProps = {
classes: Object,
component: ElementType,
};
export type Props = {
/**
* The content of the table, normally `TableHeader` and `TableBody`.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component?: ElementType,
};
class Table extends React.Component<ProvidedProps & Props> {
static defaultProps = {
component: 'table',
};
class Table extends React.Component {
getChildContext() {
// eslint-disable-line class-methods-use-this
return {
@@ -54,23 +22,36 @@ class Table extends React.Component<ProvidedProps & Props> {
}
render() {
const {
classes,
className: classNameProp,
children,
component: ComponentProp,
...other
} = this.props;
const className = classNames(classes.root, classNameProp);
const { classes, className: classNameProp, component: Component, ...other } = this.props;
return (
<ComponentProp className={className} {...other}>
{children}
</ComponentProp>
);
return <Component className={classNames(classes.root, classNameProp)} {...other} />;
}
}
Table.propTypes = {
/**
* The content of the table, normally `TableHeader` and `TableBody`.
*/
children: PropTypes.node.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
};
Table.defaultProps = {
component: 'table',
};
Table.childContextTypes = {
table: PropTypes.object,
};