/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' import { StyledTH, StyledNoContent, StyledTable, StyledTD, StyledTR } from './style' export interface Cell { customStyle?: {[key: string]: string} content: React.ReactNode } export interface Row { customStyle?: {[key: string]: string} content: Cell[] } export interface Props { id?: string header?: Cell[] children?: React.ReactNode rows?: Row[] rowTheme?: {[key: string]: string} } export default class Table extends React.PureComponent { render () { const { id, header, rows, children } = this.props return (
{ header && header.length > 0 ? { header ? { header.map((cell: Cell, i: number) => { return {cell.content} }) } : null } { rows ? { rows.map((row: Row, i: number) => { row.content.map((cell: Cell, j: number) => { return {cell.content} }) } ) } : null } : null } { !rows || rows.length === 0 ? {children} : null }
) } }