import React from 'react';
import defaultTo from 'lodash/defaultTo';
import DataTable from '../DataTable';
import { createColumns, getDataTableProps } from '../Table';
import { TableContext } from '../TableContext';
import { classes, st } from '../Table.st.css.js';
import { BulkSelectionConsumer } from '../BulkSelection';
export const TableContent = ({ titleBarVisible = true, titleBarDisplay = true, dataHook, }) => {
    // TODO: figure out if we need to put result of createColumns() on state, in order to avoid
    // redundant renders.
    return (React.createElement(TableContext.Consumer, null, tableProps => {
        const dataTableProps = {
            ...getDataTableProps(tableProps),
            dataHook: tableProps.withWrapper ? 'table-content' : dataHook,
            hideHeader: !titleBarVisible,
            hideHeaderAccessible: !titleBarDisplay,
        };
        return (React.createElement("div", { className: st(classes.content, {
                titleBarPresent: titleBarDisplay && titleBarVisible,
            }) }, tableProps.showSelection ? (React.createElement(BulkSelectionConsumer, { consumerCompName: "Table.Content", providerCompName: "Table" }, bulkSelectionContext => (React.createElement(DataTable, { ...dataTableProps, isRowSelected: (rowData, rowIndex) => bulkSelectionContext.isSelected(defaultTo(rowData.id, rowIndex)), columns: createColumns({
                tableProps,
                bulkSelectionContext,
            }) })))) : (React.createElement(DataTable, { ...dataTableProps, columns: createColumns({
                tableProps,
            }) }))));
    }));
};
TableContent.displayName = 'Table.Content';
//# sourceMappingURL=TableContent.js.map