import React from 'react'; import cn from 'classnames'; import { Button } from 'UI'; import stl from './table.module.css'; export default class Table extends React.PureComponent { state = { showAll: false }; onLoadMoreClick = () => { this.setState({ showAll: true }); } render() { const { cols, rows = [], rowProps, rowClass = '', small = false, compare = false, maxHeight = 200, onRowClick = null, isTemplate, } = this.props; const { showAll } = this.state; const isShowMoreButtonVisible = !isTemplate && rows.size > (small ? 3 : 5) && !showAll return (
{ cols.map(({ key, title, width, }) =>
{ title }
) }
{ rows.take(showAll ? rows.size : (small ? 3 : 5)).map(row => (
onRowClick(e, row) : () => null} > { cols.map(({ cellClass = '', className = '', Component, key, toText = t => t, width }) => (
{ Component ? :
{ toText(row[ key ]) }
}
)) }
)) }
{isShowMoreButtonVisible &&
}
); } }