"use strict";

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

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

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

var _classnames = _interopRequireDefault(require("classnames"));

var _recompose = require("recompose");

var _recomposeUtils = require("../../utils/recompose-utils");

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

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

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 = (0, _classnames["default"])("oui-disclose__content", (_classNames = {}, _defineProperty(_classNames, "border--sides border--bottom", childrenStyle === "border"), _defineProperty(_classNames, "border--bottom", childrenStyle === "divider" && isOpen), _classNames));
  var linkClass = (0, _classnames["default"])("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 = (0, _classnames["default"])("oui-disclose", _defineProperty({}, "is-active", isOpen));
  return _react["default"].createElement("div", {
    className: arrowClass,
    style: {
      marginTop: "-1px"
    }
  }, _react["default"].createElement("a", _extends({
    onClick: toggle,
    className: linkClass
  }, props), _react["default"].createElement("div", {
    className: "flex oui-disclose__arrow"
  }, _react["default"].createElement("span", {
    className: "oui-disclose__symbol push--right"
  }), title)), _react["default"].createElement("div", {
    className: contentClass
  }, isOpen && children));
};

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

var _default = (0, _recomposeUtils.withToggle)((0, _recompose.toClass)(Disclose));

exports["default"] = _default;