'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _styledComponents = require('styled-components');

var _styledComponents2 = _interopRequireDefault(_styledComponents);

var _TableBody = require('./styles/TableBody');

var _TableBody2 = _interopRequireDefault(_TableBody);

var _TableRowDetailsRow = require('./styles/TableRowDetailsRow');

var _TableRowDetailsRow2 = _interopRequireDefault(_TableRowDetailsRow);

var _TableRowDetailsStyles = require('./styles/TableRowDetailsStyles');

var _TableRowDetailsStyles2 = _interopRequireDefault(_TableRowDetailsStyles);

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

// Firefox has an artificial limit on colspan of 1000. This is obviously an arbitrary
// number of columns, but there are no cleaner or easier solutions to spanning the entire
// table at time of writing.
var COLSPAN = 1000;

var TableRowDetails = function TableRowDetails(_ref) {
  var children = _ref.children,
      _ref$rowIndex = _ref.rowIndex,
      rowIndex = _ref$rowIndex === undefined ? 0 : _ref$rowIndex,
      Row = _ref.Row,
      Styles = _ref.Styles;
  return _react2.default.createElement(
    TableBody,
    { startIndex: rowIndex },
    _react2.default.createElement(
      Row,
      null,
      _react2.default.createElement(
        Styles,
        { colSpan: COLSPAN },
        children
      )
    )
  );
};

TableRowDetails.propTypes = {
  /**
   * Contents of the details
   */
  children: _propTypes2.default.node.isRequired,
  /**
   * The row index the details are related to
   */
  rowIndex: _propTypes2.default.number,
  /**
   * A component to render the styles of the tr
   */
  Row: _propTypes2.default.func,
  /**
   * A component to render the styles of the td
   */
  Styles: _propTypes2.default.func,
  /**
   * A tbody element
   */
  TableBody: _propTypes2.default.func
};

TableRowDetails.defaultProps = {
  Row: _TableRowDetailsRow2.default,
  Styles: _TableRowDetailsStyles2.default,
  TBody: _TableBody2.default
};

exports.default = TableRowDetails;