UNPKG

wix-style-react

Version:
42 lines (40 loc) 1.53 kB
import _extends from "@babel/runtime/helpers/extends"; import React from 'react'; import PropTypes from 'prop-types'; import { DataTableHeader } from '../DataTable'; import { getDataTableProps, createColumns } from '../Table'; import { TableContext } from '../TableContext'; import { BulkSelectionConsumer } from '../BulkSelection'; /** * TitleBar (aka DataTableHeader) */ export var TableTitleBar = function TableTitleBar(_ref) { var dataHook = _ref.dataHook; return /*#__PURE__*/React.createElement(TableContext.Consumer, null, function (tableProps) { var dataTableProps = getDataTableProps(tableProps); if (tableProps.showSelection) { return /*#__PURE__*/React.createElement(BulkSelectionConsumer, { consumerCompName: "Table.TitleBar", providerCompName: "Table" }, function (bulkSelectionContext) { return /*#__PURE__*/React.createElement("div", { "data-hook": "table-title-bar" }, /*#__PURE__*/React.createElement(DataTableHeader, _extends({}, dataTableProps, { columns: createColumns({ tableProps: tableProps, bulkSelectionContext: bulkSelectionContext }), dataHook: dataHook }))); }); } else { return /*#__PURE__*/React.createElement("div", { "data-hook": "table-title-bar" }, /*#__PURE__*/React.createElement(DataTableHeader, dataTableProps)); } }); }; TableTitleBar.displayName = 'Table.TitleBar'; TableTitleBar.propTypes = { dataHook: PropTypes.string };