"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _propTypes = _interopRequireDefault(require("prop-types"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _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; }; return _extends.apply(this, arguments); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var TR = _react["default"].forwardRef(function (_ref, ref) {
  var _classNames;

  var backgroundColor = _ref.backgroundColor,
      borderStyle = _ref.borderStyle,
      children = _ref.children,
      className = _ref.className,
      isActive = _ref.isActive,
      isHighlighted = _ref.isHighlighted,
      isLink = _ref.isLink,
      noBorder = _ref.noBorder,
      noHover = _ref.noHover,
      _ref$onRowClick = _ref.onRowClick,
      onRowClick = _ref$onRowClick === void 0 ? function () {
    return null;
  } : _ref$onRowClick,
      testSection = _ref.testSection,
      props = _objectWithoutProperties(_ref, ["backgroundColor", "borderStyle", "children", "className", "isActive", "isHighlighted", "isLink", "noBorder", "noHover", "onRowClick", "testSection"]);

  var classes = (0, _classnames["default"])((_classNames = {
    "oui-table-row--active": isActive,
    "oui-table-row--highlighted": isHighlighted,
    "oui-table-row--link": isLink,
    "no-border": noBorder,
    "hover--disabled": noHover
  }, _defineProperty(_classNames, "border--".concat(borderStyle), borderStyle), _defineProperty(_classNames, "background--".concat(backgroundColor), backgroundColor), _classNames), className);
  return _react["default"].createElement("tr", _extends({
    className: classes,
    "data-test-section": testSection,
    onClick: onRowClick,
    ref: ref
  }, props), children);
});

TR.propTypes = {
  /** Background color for each row */
  backgroundColor: _propTypes["default"].oneOf(["faint", "light"]),

  /** Border style for each row */
  borderStyle: _propTypes["default"].oneOf(["bottom", "top", "sides", "ends", "none"]),

  /** Expects a `Table.TD` or `Table.TH` component */
  children: _propTypes["default"].node,

  /** CSS class names. */
  className: _propTypes["default"].string,

  /** If true, add active class */
  isActive: _propTypes["default"].bool,

  /** If true, add highlight class */
  isHighlighted: _propTypes["default"].bool,

  /** If true, add link class */
  isLink: _propTypes["default"].bool,

  /** If true, add class to remove border */
  noBorder: _propTypes["default"].bool,

  /** If true, remove hover on inner TDs */
  noHover: _propTypes["default"].bool,

  /** Function to handle row click action */
  onRowClick: _propTypes["default"].func,

  /** Hook for automated JavaScript tests */
  testSection: _propTypes["default"].string
};
TR.displayName = "TR";
var _default = TR;
exports["default"] = _default;