"use strict";

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

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

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

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

var _recompose = require("recompose");

var _recomposeUtils = require("../../../utils/recompose-utils");

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 DiscloseRow = function DiscloseRow(_ref) {
  var children = _ref.children,
      className = _ref.className,
      isOpen = _ref.isOpen,
      rowContents = _ref.rowContents,
      toggle = _ref.toggle,
      props = _objectWithoutProperties(_ref, ["children", "className", "isOpen", "rowContents", "toggle"]);

  var linkClass = (0, _classnames["default"])("oui-disclose-table--row__toggle", _defineProperty({}, "is-active", isOpen), className);
  return _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement("tr", _extends({
    onClick: toggle,
    className: linkClass
  }, props), _react["default"].createElement("td", {
    className: "soft--left vertical-align--middle"
  }, _react["default"].createElement("span", {
    className: "oui-disclose__symbol push-half--right"
  })), rowContents), isOpen && _react["default"].createElement("tr", {
    className: "oui-disclose-table--row__content"
  }, _react["default"].createElement("td", {
    colSpan: rowContents.length + 1
  }, children)));
};

DiscloseRow.propTypes = {
  /** Can be any valid HTML node */
  children: _propTypes["default"].node.isRequired,

  /** CSS class names. */
  className: _propTypes["default"].string,
  isOpen: _propTypes["default"].bool.isRequired,
  rowContents: _propTypes["default"].array.isRequired,
  toggle: _propTypes["default"].func.isRequired
};

var _default = (0, _recomposeUtils.withToggle)((0, _recompose.toClass)(DiscloseRow));

exports["default"] = _default;