/* @flow */ import * as React from 'react'; import Caption from './components/Caption'; import Header from './components/Header'; import Body from './components/Body'; import Footer from './components/Footer'; import type { TableProps } from "../GridView"; import { PageContext } from "../contexts/PageContext"; export default class Table extends React.Component { static defaultProps = { data: [], headerCells: {}, footerCells: [], captionOptions: {}, tableOptions: {}, showHeader: true, showFooter: false, headerRowOptions: {}, footerRowOptions: {}, rowOptions: {}, notSetText: '(not set)', emptyCaption: 'Nothing found', placeFooterAfterBody: true }; render(): React.Node { return { ({ tableId }) => { let tableContent: Array> = []; let somethingFound = true; if (this.props.data.length) { tableContent.push(); } else { somethingFound = false; } if (this.props.showHeader) { tableContent.unshift(
); } if (this.props.caption || !somethingFound) { let captionProps = { options: this.props.captionOptions, key: `tcaption-${tableId}`, text: somethingFound ? this.props.caption : this.props.emptyCaption }; const caption = ; if (somethingFound) { tableContent.unshift(caption); } else { tableContent.push(caption); } } if (this.props.showFooter) { let footer =