"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.StyledTable = exports.StyledHeadCell = exports.StyledBodyCell = void 0;

var React = _interopRequireWildcard(require("react"));

var _styles = require("../styles");

var _table = require("../table");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }

var StyledTableElement = (0, _styles.withStyle)(_table.StyledTable, function (props) {
  return {
    display: 'grid',
    gridTemplateColumns: props.$gridTemplateColumns,
    flexDirection: 'unset',
    // Creates a stacking context so we can use z-index on the StyledHeadCell
    // without affecting anything outside of this component.
    transform: 'scale(1)'
  };
});
StyledTableElement.displayName = "StyledTableElement";
StyledTableElement.displayName = 'StyledTableElement';
var StyledTable = (0, _styles.withWrapper)(StyledTableElement, function (StyledComponent) {
  return function StyledTable(props) {
    return /*#__PURE__*/React.createElement(StyledComponent, _extends({
      "data-baseweb": "table-grid"
    }, props));
  };
});
exports.StyledTable = StyledTable;
var StyledHeadCell = (0, _styles.withStyle)(_table.StyledHeadCell, function (_ref) {
  var _ref$$sticky = _ref.$sticky,
      $sticky = _ref$$sticky === void 0 ? true : _ref$$sticky,
      $isFocusVisible = _ref.$isFocusVisible,
      $theme = _ref.$theme;
  return {
    backgroundColor: $theme.colors.tableHeadBackgroundColor,
    boxShadow: $theme.lighting.shadow400,
    position: $sticky ? 'sticky' : null,
    top: $sticky ? 0 : null,
    width: 'unset',
    ':focus': {
      outline: $isFocusVisible ? "3px solid ".concat($theme.colors.borderAccent) : 'none',
      outlineOffset: '-3px'
    },
    zIndex: $sticky ? 1 : 'auto'
  };
});
exports.StyledHeadCell = StyledHeadCell;
StyledHeadCell.displayName = "StyledHeadCell";
StyledHeadCell.displayName = 'StyledHeadCell';
var StyledBodyCell = (0, _styles.withStyle)(_table.StyledCell, function (props) {
  return {
    display: 'block',
    flex: 'unset',
    gridColumn: props.$gridColumn || null,
    gridRow: props.$gridRow || null,
    ':focus': {
      outline: props.$isFocusVisible ? "3px solid ".concat(props.$theme.colors.borderAccent) : 'none',
      outlineOffset: '-3px'
    }
  };
});
exports.StyledBodyCell = StyledBodyCell;
StyledBodyCell.displayName = "StyledBodyCell";
StyledBodyCell.displayName = 'StyledBodyCell';