var _excluded = ["open", "icon", "label", "caret"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
import React, { forwardRef } from "react";
import styled from "styled-components";
import Flex from "../../templates/flex";
import { Icon } from "../../icon";
import { Text } from "../../typography";
var MenuContainer = styled(Flex).withConfig({
  displayName: "menuButton__MenuContainer",
  componentId: "sc-aj99z3-0"
})(["cursor:pointer;"]);
var MenuButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var open = _ref.open,
    icon = _ref.icon,
    label = _ref.label,
    caret = _ref.caret,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  return /*#__PURE__*/React.createElement(MenuContainer, _extends({
    gap: 2,
    padding: [2, 4],
    justifyContent: "between",
    alignItems: "center",
    role: "button",
    tabindex: "0",
    "aria-haspopup": "listbox",
    "aria-expanded": open,
    ref: ref
  }, rest), /*#__PURE__*/React.createElement(Flex, {
    alignItems: "center",
    gap: 2
  }, icon, typeof label === "string" ? /*#__PURE__*/React.createElement(Text, null, label) : label), caret === true ? /*#__PURE__*/React.createElement(Icon, {
    name: "chevron_down",
    color: "text",
    width: "12px",
    height: "12px",
    rotate: open ? 2 : null
  }) : caret);
});
export default MenuButton;