'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _inputHelpers = require('../helpers/inputHelpers');

var _InputTableRow = require('../../styles/cspace-input/InputTableRow.css');

var _InputTableRow2 = _interopRequireDefault(_InputTableRow);

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

var propTypes = {
  children: _react.PropTypes.node,
  embedded: _react.PropTypes.bool
};

function InputTableRow(props) {
  var children = props.children,
      embedded = props.embedded;


  var inputs = (0, _inputHelpers.extractInputs)(children);

  var modifiedInputs = inputs.map(function (input) {
    return _react2.default.cloneElement(input, {
      label: undefined,
      embedded: true
    });
  });

  var inputContainers = modifiedInputs.map(function (input) {
    return _react2.default.createElement(
      'div',
      { key: input.props.name },
      input
    );
  });

  var className = embedded ? _InputTableRow2.default.embedded : _InputTableRow2.default.normal;

  return _react2.default.createElement(
    'div',
    { className: className },
    inputContainers
  );
}

InputTableRow.propTypes = propTypes;