diff --git a/packages/material-ui/src/Table/Table.js b/packages/material-ui/src/Table/Table.js index 0c790b068dc727..81d260355393c8 100644 --- a/packages/material-ui/src/Table/Table.js +++ b/packages/material-ui/src/Table/Table.js @@ -1,8 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; -import makeStyles from '../styles/makeStyles'; -import useThemeProps from '../styles/useThemeProps'; +import withStyles from '../styles/withStyles'; import TableContext from './TableContext'; export const styles = { @@ -15,18 +14,8 @@ export const styles = { }, }; -export const useStyles = makeStyles(styles, { name: 'MuiTable' }); - const Table = React.forwardRef(function Table(props, ref) { - const { - classes: classesProp, - className, - component: Component, - padding, - size, - ...other - } = useThemeProps(props, { name: 'MuiTable' }); - const classes = useStyles(props); + const { classes, className, component: Component, padding, size, ...other } = props; const table = React.useMemo(() => ({ padding, size }), [padding, size]); return ( @@ -45,7 +34,7 @@ Table.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object, + classes: PropTypes.object.isRequired, /** * @ignore */ @@ -76,9 +65,4 @@ Table.defaultProps = { size: 'medium', }; -Table.useStyles = useStyles; -Table.options = { - name: 'MuiTable', -}; - -export default Table; +export default withStyles(styles, { name: 'MuiTable' })(Table); diff --git a/packages/material-ui/src/TableBody/TableBody.js b/packages/material-ui/src/TableBody/TableBody.js index d69e9f388817a0..fb4f6c7102c2c8 100644 --- a/packages/material-ui/src/TableBody/TableBody.js +++ b/packages/material-ui/src/TableBody/TableBody.js @@ -1,14 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; -import makeStyles from '../styles/makeStyles'; -import useThemeProps from '../styles/useThemeProps'; +import withStyles from '../styles/withStyles'; import Tablelvl2Context from '../Table/Tablelvl2Context'; -const tablelvl2 = { - variant: 'body', -}; - export const styles = { /* Styles applied to the root element. */ root: { @@ -16,13 +11,12 @@ export const styles = { }, }; -const useStyles = makeStyles(styles, { name: 'MuiTableBody' }); +const tablelvl2 = { + variant: 'body', +}; const TableBody = React.forwardRef(function TableBody(props, ref) { - const { classes: classesProp, className, component: Component, ...other } = useThemeProps(props, { - name: 'MuiTableBody', - }); - const classes = useStyles(props); + const { classes, className, component: Component, ...other } = props; return ( @@ -40,7 +34,7 @@ TableBody.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object, + classes: PropTypes.object.isRequired, /** * @ignore */ @@ -56,9 +50,4 @@ TableBody.defaultProps = { component: 'tbody', }; -TableBody.useStyles = useStyles; -TableBody.options = { - name: 'MuiTableBody', -}; - -export default TableBody; +export default withStyles(styles, { name: 'MuiTableBody' })(TableBody); diff --git a/packages/material-ui/src/TableCell/TableCell.js b/packages/material-ui/src/TableCell/TableCell.js index ecbf6ca74afe8c..0b5480e8d876bf 100644 --- a/packages/material-ui/src/TableCell/TableCell.js +++ b/packages/material-ui/src/TableCell/TableCell.js @@ -1,8 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; -import makeStyles from '../styles/makeStyles'; -import useThemeProps from '../styles/useThemeProps'; +import withStyles from '../styles/withStyles'; import { capitalize } from '../utils/helpers'; import { darken, fade, lighten } from '../styles/colorManipulator'; import TableContext from '../Table/TableContext'; @@ -99,13 +98,11 @@ export const styles = theme => ({ }, }); -const useStyles = makeStyles(styles, { name: 'MuiTableCell' }); - const TableCell = React.forwardRef(function TableCell(props, ref) { const { align, children, - classes: classesProp, + classes, className, component, padding: paddingProp, @@ -114,9 +111,8 @@ const TableCell = React.forwardRef(function TableCell(props, ref) { sortDirection, variant, ...other - } = useThemeProps(props, { name: 'MuiTableCell' }); + } = props; - const classes = useStyles(props); const table = React.useContext(TableContext); const tablelvl2 = React.useContext(Tablelvl2Context); @@ -181,7 +177,7 @@ TableCell.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object, + classes: PropTypes.object.isRequired, /** * @ignore */ @@ -220,9 +216,4 @@ TableCell.defaultProps = { align: 'inherit', }; -TableCell.useStyles = useStyles; -TableCell.options = { - name: 'MuiTableCell', -}; - -export default TableCell; +export default withStyles(styles, { name: 'MuiTableCell' })(TableCell); diff --git a/packages/material-ui/src/TableFooter/TableFooter.js b/packages/material-ui/src/TableFooter/TableFooter.js index c49260cff04566..ba9e344a3d7560 100644 --- a/packages/material-ui/src/TableFooter/TableFooter.js +++ b/packages/material-ui/src/TableFooter/TableFooter.js @@ -1,14 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; -import makeStyles from '../styles/makeStyles'; -import useThemeProps from '../styles/useThemeProps'; +import withStyles from '../styles/withStyles'; import Tablelvl2Context from '../Table/Tablelvl2Context'; -const tablelvl2 = { - variant: 'footer', -}; - export const styles = { /* Styles applied to the root element. */ root: { @@ -16,13 +11,12 @@ export const styles = { }, }; -const useStyles = makeStyles(styles, { name: 'MuiTableFooter' }); +const tablelvl2 = { + variant: 'footer', +}; const TableFooter = React.forwardRef(function TableFooter(props, ref) { - const { classes: classesProp, className, component: Component, ...other } = useThemeProps(props, { - name: 'MuiTableFooter', - }); - const classes = useStyles(props); + const { classes, className, component: Component, ...other } = props; return ( @@ -40,7 +34,7 @@ TableFooter.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object, + classes: PropTypes.object.isRequired, /** * @ignore */ @@ -56,9 +50,4 @@ TableFooter.defaultProps = { component: 'tfoot', }; -TableFooter.useStyles = useStyles; -TableFooter.options = { - name: 'MuiTableFooter', -}; - -export default TableFooter; +export default withStyles(styles, { name: 'MuiTableFooter' })(TableFooter); diff --git a/packages/material-ui/src/TableHead/TableHead.js b/packages/material-ui/src/TableHead/TableHead.js index a61d0fa1cd5836..fda71dced55d36 100644 --- a/packages/material-ui/src/TableHead/TableHead.js +++ b/packages/material-ui/src/TableHead/TableHead.js @@ -1,14 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; -import makeStyles from '../styles/makeStyles'; -import useThemeProps from '../styles/useThemeProps'; +import withStyles from '../styles/withStyles'; import Tablelvl2Context from '../Table/Tablelvl2Context'; -const tablelvl2 = { - variant: 'head', -}; - export const styles = { /* Styles applied to the root element. */ root: { @@ -16,13 +11,12 @@ export const styles = { }, }; -const useStyles = makeStyles(styles, { name: 'MuiTableHead' }); +const tablelvl2 = { + variant: 'head', +}; const TableHead = React.forwardRef(function TableHead(props, ref) { - const { classes: classesProp, className, component: Component, ...other } = useThemeProps(props, { - name: 'MuiTableHead', - }); - const classes = useStyles(props); + const { classes, className, component: Component, ...other } = props; return ( @@ -40,7 +34,7 @@ TableHead.propTypes = { * Override or extend the styles applied to the component. * See [CSS API](#css) below for more details. */ - classes: PropTypes.object, + classes: PropTypes.object.isRequired, /** * @ignore */ @@ -56,9 +50,4 @@ TableHead.defaultProps = { component: 'thead', }; -TableHead.useStyles = useStyles; -TableHead.options = { - name: 'MuiTableHead', -}; - -export default TableHead; +export default withStyles(styles, { name: 'MuiTableHead' })(TableHead); diff --git a/packages/material-ui/src/TableRow/TableRow.js b/packages/material-ui/src/TableRow/TableRow.js index 792bad36e1c36f..2d49ac4732ec86 100644 --- a/packages/material-ui/src/TableRow/TableRow.js +++ b/packages/material-ui/src/TableRow/TableRow.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; -import makeStyles from '../styles/makeStyles'; +import withStyles from '../styles/withStyles'; import Tablelvl2Context from '../Table/Tablelvl2Context'; export const styles = theme => ({ @@ -35,23 +35,13 @@ export const styles = theme => ({ footer: {}, }); -const useStyles = makeStyles(styles, { name: 'MuiTableRow' }); - /** * Will automatically set dynamic row height * based on the material table element parent (head, body, etc). */ const TableRow = React.forwardRef(function TableRow(props, ref) { - const { - classes: classesProp, - className, - component: Component, - hover, - selected, - ...other - } = props; + const { classes, className, component: Component, hover, selected, ...other } = props; const tablelvl2 = React.useContext(Tablelvl2Context); - const classes = useStyles(props); return ( ({ }, }); -const useStyles = makeStyles(styles, { name: 'MuiTableSortLabel' }); - /** * A button based label for placing inside `TableCell` for column sorting. */ @@ -69,14 +66,13 @@ const TableSortLabel = React.forwardRef(function TableSortLabel(props, ref) { const { active, children, - classes: classesProp, + classes, className, direction, hideSortIcon, IconComponent, ...other - } = useThemeProps(props, { name: 'MuiTableSortLabel' }); - const classes = useStyles(props); + } = props; return (