UNPKG

wix-style-react

Version:
52 lines (47 loc) 1.84 kB
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; import React from 'react'; import { bool, string } from 'prop-types'; import DataTable from '../../DataTable'; import { getDataTableProps, createColumns } from '../Table'; import { TableContext } from '../TableContext'; import { BulkSelectionConsumer } from '../BulkSelection'; export var TableContent = function TableContent(_ref) { var titleBarVisible = _ref.titleBarVisible, dataHook = _ref.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, function (tableProps) { var dataTableProps = _extends({}, getDataTableProps(tableProps), { dataHook: tableProps.withWrapper ? 'table-content' : dataHook, hideHeader: !titleBarVisible }); if (tableProps.showSelection) { return React.createElement( BulkSelectionConsumer, { consumerCompName: 'Table.Content', providerCompName: 'Table' }, function (bulkSelectionContext) { return React.createElement(DataTable, _extends({}, dataTableProps, { columns: createColumns({ tableProps: tableProps, bulkSelectionContext: bulkSelectionContext }) })); } ); } else { return React.createElement(DataTable, dataTableProps); } } ); }; TableContent.displayName = 'Table.Content'; TableContent.propTypes = { titleBarVisible: bool, dataHook: string }; TableContent.defaultProps = { titleBarVisible: true };