function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

import React from "react";
import PropTypes from "prop-types";
import classNames from "classnames";
import { toClass } from "recompose";
import { withToggle } from "../../utils/recompose-utils";

var Disclose = function Disclose(_ref) {
  var _classNames, _classNames2;

  var children = _ref.children,
      childrenStyle = _ref.childrenStyle,
      className = _ref.className,
      headerStyle = _ref.headerStyle,
      isOpen = _ref.isOpen,
      indented = _ref.indented,
      title = _ref.title,
      toggle = _ref.toggle,
      props = _objectWithoutProperties(_ref, ["children", "childrenStyle", "className", "headerStyle", "isOpen", "indented", "title", "toggle"]);

  var contentClass = classNames("oui-disclose__content", (_classNames = {}, _defineProperty(_classNames, "border--sides border--bottom", childrenStyle === "border"), _defineProperty(_classNames, "border--bottom", childrenStyle === "divider" && isOpen), _classNames));
  var linkClass = classNames("oui-disclose__link link--dark soft-half flush", (_classNames2 = {}, _defineProperty(_classNames2, "background--faint display--block", headerStyle === "header"), _defineProperty(_classNames2, "border--all background--faint display--block", headerStyle === "header-bordered"), _defineProperty(_classNames2, "hard--left", !indented), _classNames2), className);
  var arrowClass = classNames("oui-disclose", _defineProperty({}, "is-active", isOpen));
  return React.createElement("div", {
    className: arrowClass,
    style: {
      marginTop: "-1px"
    }
  }, React.createElement("a", _extends({
    onClick: toggle,
    className: linkClass
  }, props), React.createElement("div", {
    className: "flex oui-disclose__arrow"
  }, React.createElement("span", {
    className: "oui-disclose__symbol push--right"
  }), title)), React.createElement("div", {
    className: contentClass
  }, isOpen && children));
};

Disclose.propTypes = {
  children: PropTypes.node.isRequired,
  childrenStyle: PropTypes.string,
  headerStyle: PropTypes.string,
  indented: PropTypes.bool,
  isOpen: PropTypes.bool,
  noBorder: PropTypes.bool,
  title: PropTypes.oneOfType([PropTypes.node, PropTypes.string]).isRequired,
  toggle: PropTypes.func
};
Disclose.defaultProps = {
  indented: true
};
export default withToggle(toClass(Disclose));