'use strict';

exports.__esModule = true;

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

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

/**
 * Collapse is component for rendering dropdown menu
 * @param props
 * @returns {XML}
 * @constructor
 */

var _ref = _react2.default.createElement('hr', null);

var Collapse = function (_React$Component) {
  (0, _inherits3.default)(Collapse, _React$Component);

  function Collapse() {
    var _temp, _this, _ret;

    (0, _classCallCheck3.default)(this, Collapse);

    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
      dropdownClass: ''
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  Collapse.prototype.componentDidUpdate = function componentDidUpdate(nextProps) {
    var _this2 = this;

    window.requestAnimationFrame(function () {
      return _this2.props.isOpen !== nextProps.isOpen && nextProps.isOpen ? _this2.setState({
        dropdownClass: 'in'
      }) : _this2.setState({ dropdownClass: '' });
    });
  };

  Collapse.prototype.render = function render() {
    var _props = this.props,
        isOpen = _props.isOpen,
        children = _props.children;
    var dropdownClass = this.state.dropdownClass;


    var changeHeight = isOpen ? { height: 'auto' } : { height: '0px' };

    return _react2.default.createElement(
      'div',
      null,
      _ref,
      _react2.default.createElement(
        'collapse',
        {
          className: 'collapse' + ('' + dropdownClass),
          'aria-expanded': isOpen,
          'aria-hidden': !isOpen,
          style: changeHeight
        },
        _react2.default.createElement(
          'div',
          { className: 'well well-lg' },
          children
        )
      )
    );
  };

  return Collapse;
}(_react2.default.Component);

Collapse.displayName = 'Collapse';
exports.default = Collapse;


// export default Collapse;

/**
* @name Collapse
* @description Default Collapse
* @category containers
* @component collapse
* @section default
*
* @js
import { Button } from '@collab-ui/react';

export default class Collapse extends React.PureComponent {
  state = {
    showCollapseBody: true,
  }

  render() {
    return (
     <div>
       <div>
         <Collapse
           show={this.state.showCollapseBody}
         >
           <div>Test</div>
         </Collapse>
       </div>
       <div>
         <div className='row'>
           <br />
           <Button
             onClick={() => this.setState({showCollapseBody: !this.state.showCollapseBody})}
             ariaLabel='Toggle Collapse'
             className='btn--primary btn--large'
           >
            Toggle Collapse
           </Button>
         </div>
       </div>
     </div>
    );
  }
}
**/
Collapse.defaultProps = {
  children: null,
  isOpen: false
};

module.exports = exports['default'];