"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _styles = require("@material-ui/core/styles");

var _reactTransitionGroup = require("react-transition-group");

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

var Expander = function Expander(props) {
  var classes = props.classes,
      show = props.show,
      children = props.children;
  return /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
    "in": show,
    appear: true,
    mountOnEnter: false,
    timeout: 300,
    classNames: _objectSpread({}, classes)
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: classes.expander
  }, children));
};

Expander.propTypes = {
  show: _propTypes["default"].bool.isRequired,
  className: _propTypes["default"].string,
  classes: _propTypes["default"].object,
  children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired
};
var transition = 'height ease-in 300ms, opacity ease-in 300ms';

var _default = (0, _styles.withStyles)(function () {
  return {
    expander: {
      position: 'relative',
      height: 0,
      overflow: 'hidden',
      display: 'flex',
      visibility: 'hidden',
      width: 0
    },
    enter: {
      transition: transition,
      opacity: 1,
      height: 'auto',
      width: 'auto',
      visibility: 'visible',
      minHeight: '25px'
    },
    enterDone: {
      height: 'auto',
      visibility: 'visible',
      width: 'auto',
      minHeight: '25px'
    },
    exit: {
      transition: transition,
      opacity: 0,
      height: 0,
      visibility: 'visible',
      width: 0
    },
    exitDone: {
      opacity: 0,
      visibility: 'hidden',
      height: 0,
      width: 0
    }
  };
})(Expander);

exports["default"] = _default;
//# sourceMappingURL=expander.js.map