'use strict';

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

var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

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

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

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);

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

var _ListItem = require('@material-ui/core/ListItem');

var _ListItem2 = _interopRequireDefault(_ListItem);

var _ListItemIcon = require('@material-ui/core/ListItemIcon');

var _ListItemIcon2 = _interopRequireDefault(_ListItemIcon);

var _ListItemText = require('@material-ui/core/ListItemText');

var _ListItemText2 = _interopRequireDefault(_ListItemText);

var _ListItemSecondaryAction = require('@material-ui/core/ListItemSecondaryAction');

var _ListItemSecondaryAction2 = _interopRequireDefault(_ListItemSecondaryAction);

var _IconButton = require('@material-ui/core/IconButton');

var _IconButton2 = _interopRequireDefault(_IconButton);

var _Collapse = require('@material-ui/core/Collapse');

var _Collapse2 = _interopRequireDefault(_Collapse);

var _ExpandMore = require('@material-ui/icons/ExpandMore');

var _ExpandMore2 = _interopRequireDefault(_ExpandMore);

var _ExpandLess = require('@material-ui/icons/ExpandLess');

var _ExpandLess2 = _interopRequireDefault(_ExpandLess);

var _ShowAllButton = require('./ShowAllButton');

var _ShowAllButton2 = _interopRequireDefault(_ShowAllButton);

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

var styleSheet = {
  listItemText: {
    fontSize: 14,
    padding: '0 32px 0 0'
  },
  showAll: {
    top: 6,
    fontSize: 12
  },
  collapse: {
    position: 'relative'
  }

  // const ColorButton = () => (
  //   <IconButton>
  //     <ColorIcon />
  //   </IconButton>
  // )

};
// import ColorIcon from '@material-ui/icons/ColorLens'

var ExpandButton = function ExpandButton(_ref) {
  var expanded = _ref.expanded,
      onClick = _ref.onClick;
  return _react2.default.createElement(
    _IconButton2.default,
    { onClick: onClick },
    expanded ? _react2.default.createElement(_ExpandLess2.default, null) : _react2.default.createElement(_ExpandMore2.default, null)
  );
};

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

  function FilterSection() {
    var _ref2;

    var _temp, _this, _ret;

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

    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, (_ref2 = FilterSection.__proto__ || (0, _getPrototypeOf2.default)(FilterSection)).call.apply(_ref2, [this].concat(args))), _this), _this.state = {
      expanded: true
    }, _this.handleExpandClick = function () {
      _this.setState({
        expanded: !_this.state.expanded
      });
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(FilterSection, [{
    key: 'render',
    value: function render() {
      var _props = this.props,
          icon = _props.icon,
          title = _props.title,
          subtitle = _props.subtitle,
          isFiltered = _props.isFiltered,
          children = _props.children,
          showAll = _props.showAll,
          classes = _props.classes;
      var expanded = this.state.expanded;

      return _react2.default.createElement(
        'div',
        null,
        _react2.default.createElement(
          _ListItem2.default,
          null,
          _react2.default.createElement(
            _ListItemIcon2.default,
            null,
            icon
          ),
          _react2.default.createElement(_ListItemText2.default, {
            classes: { root: classes.listItemText },
            primary: title,
            secondary: subtitle
          }),
          _react2.default.createElement(
            _ListItemSecondaryAction2.default,
            null,
            expanded && isFiltered ? _react2.default.createElement(_ShowAllButton2.default, { onClick: showAll, className: classes.showAll }) : _react2.default.createElement(ExpandButton, { expanded: expanded, onClick: this.handleExpandClick })
          )
        ),
        _react2.default.createElement(
          _Collapse2.default,
          { 'in': expanded, classes: { wrapperInner: classes.collapse } },
          children
        )
      );
    }
  }]);
  return FilterSection;
}(_react2.default.Component);

FilterSection.propTypes = {
  icon: _propTypes2.default.element,
  title: _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.string]),
  subtitle: _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.string]),
  isFiltered: _propTypes2.default.bool,
  children: _propTypes2.default.node
};

exports.default = (0, _styles.withStyles)(styleSheet)(FilterSection);
//# sourceMappingURL=FilterSection.js.map