import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import EmptyCard from './EmptyCard.jsx';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import IconButton from '@material-ui/core/IconButton';
import Paper from '@material-ui/core/Paper';
import PropTypes from 'prop-types';
import React from 'react';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import { Trans } from '@lingui/macro';
import { withStyles } from '@material-ui/core/styles';
const styles = theme => ({
root: {
width: '100%',
marginTop: theme.spacing(3),
overflowX: 'auto',
},
expandedWrap: {
wordBreak: 'break-word',
paddingTop: '10px',
},
table: {
minWidth: 700,
},
tableHeader: {
fontSize: '12px',
opacity: 0.6,
lineHeight: 1,
},
denseTable: {
paddingRight: '8px',
'&:last-child': {
paddingRight: '24px',
},
},
});
class ExpandableTable extends React.Component {
constructor(props) {
super(props);
this.state = {
open: false,
datum: {},
};
}
handleDialogOpen = d => () => {
this.setState({ open: true, datum: d });
}
handleDialogClose = () => {
this.setState({ open: false, datum: {} });
};
render() {
const { datum, open } = this.state;
const { expandedRowRender, classes, tableRows, tableColumns, tableClassName } = this.props;
const columns = [{
title: ' ',
key: 'expansion',
render: d => {
return (
);
},
}].concat(tableColumns);
return (
{
columns.map(c => (
{c.title}
))
}
{ tableRows.length > 0 && (
{ tableRows.map(d => {
return (
{
this.container = ref;
}}>
{
columns.map(c => (
{c.render(d)}
))
}
);
})}
)}
{ tableRows.length === 0 && (
)}
);
}
}
ExpandableTable.propTypes = {
expandedRowRender: PropTypes.func.isRequired,
tableClassName: PropTypes.string,
tableColumns: PropTypes.arrayOf(PropTypes.shape({
title: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
isNumeric: PropTypes.bool,
render: PropTypes.func,
})).isRequired,
tableRows: PropTypes.arrayOf(PropTypes.shape({})),
};
ExpandableTable.defaultProps = {
tableClassName: '',
tableRows: [],
};
export default withStyles(styles)(ExpandableTable);