{"size": 1886, "ext": "js", "max_stars_repo_path": "packages/bitbucket/panel/components/Expandable/index.js", "max_stars_repo_name": "HeartCommunity/uiKit", "max_stars_repo_stars_event_min_datetime": "2020-08-09T09:10:20.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-09T09:10:20.000Z", "max_issues_repo_path": "packages/bitbucket/panel/components/Expandable/index.js", "max_issues_repo_name": "fnamazing/uiKit", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/bitbucket/panel/components/Expandable/index.js", "max_forks_repo_name": "fnamazing/uiKit", "max_forks_repo_forks_event_min_datetime": "2019-10-02T19:17:44.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-25T11:44:11.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 29.0153846154, "max_line_length": 92, "alphanum_fraction": 0.7221633086}
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/inherits";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import { PureComponent } from 'react';

var toggleExpandedStateUpdater = function toggleExpandedStateUpdater(prevState) {
  var isExpanded = prevState.isExpanded;
  return {
    isExpanded: !isExpanded
  };
};

var Expandable =
/*#__PURE__*/
function (_PureComponent) {
  _inherits(Expandable, _PureComponent);

  function Expandable(props) {
    var _this;

    _classCallCheck(this, Expandable);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Expandable).call(this, props));

    _defineProperty(_assertThisInitialized(_this), "toggleExpanded", function (isExpanded) {
      if (typeof isExpanded !== 'boolean') {
        _this.setState(toggleExpandedStateUpdater);
      } else {
        _this.setState({
          isExpanded: isExpanded
        });
      }
    });

    var defaultIsExpanded = _this.props.defaultIsExpanded;
    _this.state = {
      isExpanded: defaultIsExpanded
    };
    return _this;
  }

  _createClass(Expandable, [{
    key: "render",
    value: function render() {
      var isExpanded = this.state.isExpanded;
      var toggleExpanded = this.toggleExpanded;
      return this.props.children({
        isExpanded: isExpanded,
        toggleExpanded: toggleExpanded
      });
    }
  }]);

  return Expandable;
}(PureComponent);

_defineProperty(Expandable, "defaultProps", {
  defaultIsExpanded: false
});

export { Expandable as default };