import React from 'react'; import {ClassNamesFn} from '../../theme'; import {IColumn, IRow} from '../../store/table'; import {SchemaNode, Action} from '../../types'; import {TableBody} from './TableBody'; import {LocaleProps} from '../../locale'; export interface TableContentProps extends LocaleProps { className?: string; tableClassName?: string; classnames: ClassNamesFn; columns: Array; columnsGroup: Array<{ label: string; index: number; colSpan: number; has: Array; }>; rows: Array; placeholder?: string; render: (region: string, node: SchemaNode, props?: any) => JSX.Element; onMouseMove: (event: React.MouseEvent) => void; onScroll: (event: React.UIEvent) => void; tableRef: (table?: HTMLTableElement | null) => void; renderHeadCell: (column: IColumn, props?: any) => JSX.Element; renderCell: ( region: string, column: IColumn, item: IRow, props: any ) => React.ReactNode; onCheck: (item: IRow) => void; onQuickChange?: ( item: IRow, values: object, saveImmediately?: boolean | any, savePristine?: boolean ) => void; footable?: boolean; footableColumns: Array; checkOnItemClick?: boolean; buildItemProps?: (item: IRow, index: number) => any; onAction?: (e: React.UIEvent, action: Action, ctx: object) => void; rowClassNameExpr?: string; rowClassName?: string; data?: any; prefixRow?: Array; affixRow?: Array; } export class TableContent extends React.Component { render() { const { placeholder, classnames: cx, render, className, columns, columnsGroup, onMouseMove, onScroll, tableRef, rows, renderHeadCell, renderCell, onCheck, rowClassName, onQuickChange, footable, footableColumns, checkOnItemClick, buildItemProps, onAction, rowClassNameExpr, data, prefixRow, locale, translate, affixRow } = this.props; const tableClassName = cx('Table-table', this.props.tableClassName); const hideHeader = columns.every(column => !column.label); return (
{columnsGroup.length ? ( {columnsGroup.map((item, index) => ( ))} ) : null} {columns.map(column => renderHeadCell(column, { 'data-index': column.index, 'key': column.index }) )} {!rows.length ? ( ) : ( )}
{item.label ? render('tpl', item.label) : null}
{render( 'placeholder', translate(placeholder || 'placeholder.noData') )}
); } }