wix-style-react
Version:
wix-style-react
35 lines • 1.87 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
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';
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';
TableContent.propTypes = {
titleBarVisible: PropTypes.bool,
titleBarDisplay: PropTypes.bool,
dataHook: PropTypes.string,
};
//# sourceMappingURL=TableContent.js.map