"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.TableContent = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireDefault(require("react"));
var _defaultTo = _interopRequireDefault(require("lodash/defaultTo"));
var _DataTable = _interopRequireDefault(require("../DataTable"));
var _Table = require("../Table");
var _TableContext = require("../TableContext");
var _TableSt = require("../Table.st.css.js");
var _BulkSelection = require("../BulkSelection");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/Table/components/TableContent.jsx",
  _this = void 0;
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var TableContent = exports.TableContent = function TableContent(_ref) {
  var _ref$titleBarVisible = _ref.titleBarVisible,
    titleBarVisible = _ref$titleBarVisible === void 0 ? true : _ref$titleBarVisible,
    _ref$titleBarDisplay = _ref.titleBarDisplay,
    titleBarDisplay = _ref$titleBarDisplay === void 0 ? true : _ref$titleBarDisplay,
    dataHook = _ref.dataHook;
  // TODO: figure out if we need to put result of createColumns() on state, in order to avoid
  // redundant renders.
  return /*#__PURE__*/_react["default"].createElement(_TableContext.TableContext.Consumer, {
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 18,
      columnNumber: 5
    }
  }, function (tableProps) {
    var dataTableProps = _objectSpread(_objectSpread({}, (0, _Table.getDataTableProps)(tableProps)), {}, {
      dataHook: tableProps.withWrapper ? 'table-content' : dataHook,
      hideHeader: !titleBarVisible,
      hideHeaderAccessible: !titleBarDisplay
    });
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _TableSt.st)(_TableSt.classes.content, {
        titleBarPresent: titleBarDisplay && titleBarVisible
      }),
      __self: _this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 28,
        columnNumber: 11
      }
    }, tableProps.showSelection ? /*#__PURE__*/_react["default"].createElement(_BulkSelection.BulkSelectionConsumer, {
      consumerCompName: "Table.Content",
      providerCompName: "Table",
      __self: _this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 34,
        columnNumber: 15
      }
    }, function (bulkSelectionContext) {
      return /*#__PURE__*/_react["default"].createElement(_DataTable["default"], (0, _extends2["default"])({}, dataTableProps, {
        isRowSelected: function isRowSelected(rowData, rowIndex) {
          return bulkSelectionContext.isSelected((0, _defaultTo["default"])(rowData.id, rowIndex));
        },
        columns: (0, _Table.createColumns)({
          tableProps: tableProps,
          bulkSelectionContext: bulkSelectionContext
        }),
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 39,
          columnNumber: 19
        }
      }));
    }) : /*#__PURE__*/_react["default"].createElement(_DataTable["default"], (0, _extends2["default"])({}, dataTableProps, {
      columns: (0, _Table.createColumns)({
        tableProps: tableProps
      }),
      __self: _this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 54,
        columnNumber: 15
      }
    })));
  });
};
TableContent.displayName = 'Table.Content';