var _class, _temp;

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

import './style.scss';

import React from 'react';
import PropTypes from 'prop-types';

var ShowMore = (_temp = _class = function (_React$Component) {
  _inherits(ShowMore, _React$Component);

  function ShowMore(props) {
    _classCallCheck(this, ShowMore);

    var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));

    _this.handleClick = function () {
      return _this.setState({ open: !_this.state.open });
    };

    _this.state = {
      open: props.open || false
    };
    return _this;
  }

  ShowMore.prototype.render = function render() {
    var _props = this.props,
        children = _props.children,
        fade = _props.fade,
        height = _props.height,
        label = _props.label,
        labelClose = _props.labelClose,
        open = _props.open,
        props = _objectWithoutProperties(_props, ['children', 'fade', 'height', 'label', 'labelClose', 'open']);

    return React.createElement(
      'div',
      {
        className: 'ShowMore ' + (!fade || 'ShowMore_fade') + ' ' + props.className,
        open: this.state.open,
        style: { maxHeight: this.state.open ? '' : height }
      },
      children,
      React.createElement(
        'div',
        {
          className: 'ShowMore-toggle',
          onClick: this.handleClick,
          onKeyDown: this.handleClick,
          role: 'button',
          tabIndex: 0
        },
        this.state.open ? labelClose : label
      )
    );
  };

  return ShowMore;
}(React.Component), _class.defaultProps = {
  fade: true,
  height: '',
  label: 'Show More',
  labelClose: 'Show Less',
  open: false
}, _temp);
ShowMore.propTypes = process.env.NODE_ENV !== "production" ? {
  children: PropTypes.array,
  className: PropTypes.array,
  fade: PropTypes.bool,
  height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
  label: PropTypes.string,
  labelClose: PropTypes.string,
  open: PropTypes.bool
} : {};


export default ShowMore;