"use strict";

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

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

var _unstyledButton = require("../unstyled-button");

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

var ControllableExpander = function ControllableExpander(_ref) {
  var children = _ref.children,
      HeadingComponent = _ref.HeadingComponent,
      _ref$isOpen = _ref.isOpen,
      isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
      onToggle = _ref.onToggle,
      buttonStyles = _ref.buttonStyles,
      dataQa = _ref['data-qa'],
      dataCy = _ref['data-cy'],
      id = _ref.id;
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_unstyledButton.UnstyledButton, {
    style: buttonStyles,
    onClick: onToggle,
    "data-cy": dataCy,
    "data-qa": dataQa,
    id: id,
    "aria-haspopup": true,
    "aria-expanded": isOpen
  }, /*#__PURE__*/_react["default"].createElement(HeadingComponent, {
    isOpen: isOpen
  })), isOpen ? children : null);
};

exports.ControllableExpander = ControllableExpander;
ControllableExpander.displayName = 'ControllableExpander';