'use strict';

exports.__esModule = true;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

require('./style.css');

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

var AccordionWrapper = function AccordionWrapper(props) {
  var children = props.children;
  return _react2.default.createElement(
    'div',
    { className: 'ma__accordion-wrapper' },
    _react2.default.Children.map(children, function (child) {
      if (_react2.default.isValidElement(child)) {
        var clone = _react2.default.cloneElement(child, {
          secondary: props.secondary,
          emphasize: props.emphasize,
          border: props.border,
          headerLevel: props.headerLevel
        });
        return clone;
      }
      return (
        /* eslint-disable-next-line no-console */
        console.warn('Warning! You can only pass an AccordionItem child to AccordionWrapper.')
      );
    })
  );
};

AccordionWrapper.propTypes = process.env.NODE_ENV !== "production" ? {
  /** Only AccordionItem can be passed as a Child to the AccordionWrapper */
  children: _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.arrayOf(_propTypes2.default.element)]),
  /** Whether accordion children are emphasized or not. */
  emphasize: _propTypes2.default.bool,
  /** Whether accordion children are with border or not. */
  border: _propTypes2.default.bool,
  /** Whether accordion is a primary or secondary accordion. */
  secondary: _propTypes2.default.bool,
  /** The heading levels of children accordion */
  headerLevel: _propTypes2.default.number
} : {};

AccordionWrapper.defaultProps = {
  border: true,
  emphasize: true,
  secondary: false,
  headerLevel: 2
};

exports.default = AccordionWrapper;
module.exports = exports['default'];