"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 TD = function TD(_ref) {
  var children = _ref.children,
      className = _ref.className,
      colSpan = _ref.colSpan,
      _ref$isNumerical = _ref.isNumerical,
      isNumerical = _ref$isNumerical === void 0 ? false : _ref$isNumerical,
      testSection = _ref.testSection,
      textAlign = _ref.textAlign,
      verticalAlign = _ref.verticalAlign,
      width = _ref.width,
      props = _objectWithoutProperties(_ref, ["children", "className", "colSpan", "isNumerical", "testSection", "textAlign", "verticalAlign", "width"]);

  var classes = (0, _classnames["default"])(_defineProperty({
    "oui-numerical": isNumerical
  }, "vertical-align--".concat(verticalAlign), verticalAlign), className);
  var styles = {
    width: width,
    textAlign: textAlign
  };
  return _react["default"].createElement("td", _extends({
    className: classes,
    "data-test-section": testSection,
    style: styles,
    colSpan: colSpan
  }, props), children);
};

TD.propTypes = {
  /** Content within the `Table.TD` component */
  children: _propTypes["default"].node,

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

  /** Number of columns that the cell should span */
  colSpan: _propTypes["default"].number,

  /** Right-align the cell if the contents are numerical */
  isNumerical: _propTypes["default"].bool,

  /** Hook for automated JavaScript tests */
  testSection: _propTypes["default"].string,

  /** Text alignment */
  textAlign: _propTypes["default"].oneOf(["center", "right", "left"]),

  /** Apply a class that vertically aligns the cells within the children */
  verticalAlign: _propTypes["default"].oneOf(["top", "middle", "bottom"]),

  /** A number with a unit that becomes the width of the `Table` cell */
  width: _propTypes["default"].string
};
TD.displayName = "Table.TD";
var _default = TD;
exports["default"] = _default;