"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

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

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

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

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

var _button = _interopRequireDefault(require("../button"));

var _icon = _interopRequireDefault(require("../icon"));

var _dropdown = _interopRequireDefault(require("./dropdown"));

var _ConfigContext = _interopRequireDefault(require("../config-provider/ConfigContext"));

var _excluded = ["prefixCls", "type", "disabled", "onClick", "children", "className", "overlay", "trigger", "align", "visible", "onVisibleChange", "placement", "getPopupContainer", "buttonProps", "buttonGroupPrefixCls", "overlayPlacements"];
var ButtonGroup = _button["default"].Group;

var DropdownButton = function DropdownButton(props) {
  var customizePrefixCls = props.prefixCls,
      type = props.type,
      disabled = props.disabled,
      onClick = props.onClick,
      children = props.children,
      className = props.className,
      overlay = props.overlay,
      trigger = props.trigger,
      align = props.align,
      visible = props.visible,
      onVisibleChange = props.onVisibleChange,
      placement = props.placement,
      getPopupContainer = props.getPopupContainer,
      buttonProps = props.buttonProps,
      buttonGroupPrefixCls = props.buttonGroupPrefixCls,
      overlayPlacements = props.overlayPlacements,
      restProps = (0, _objectWithoutProperties2["default"])(props, _excluded);

  var _useContext = (0, _react.useContext)(_ConfigContext["default"]),
      getPrefixCls = _useContext.getPrefixCls;

  var prefixCls = getPrefixCls('dropdown', customizePrefixCls);
  var dropdownProps = {
    prefixCls: prefixCls,
    align: align,
    overlay: overlay,
    disabled: disabled,
    trigger: disabled ? [] : trigger,
    onVisibleChange: onVisibleChange,
    placement: placement,
    getPopupContainer: getPopupContainer,
    overlayPlacements: overlayPlacements
  };

  if ('visible' in props) {
    dropdownProps.visible = visible;
  }

  return /*#__PURE__*/_react["default"].createElement(ButtonGroup, (0, _extends2["default"])({}, restProps, {
    prefixCls: buttonGroupPrefixCls,
    className: (0, _classnames["default"])("".concat(prefixCls, "-button"), className)
  }), /*#__PURE__*/_react["default"].createElement(_button["default"], (0, _extends2["default"])({}, buttonProps, {
    type: type,
    disabled: disabled,
    onClick: onClick
  }), children), /*#__PURE__*/_react["default"].createElement(_dropdown["default"], (0, _extends2["default"])({}, dropdownProps), /*#__PURE__*/_react["default"].createElement(_button["default"], (0, _extends2["default"])({}, buttonProps, {
    type: type
  }), /*#__PURE__*/_react["default"].createElement(_icon["default"], {
    type: "arrow_drop_down"
  }))));
};

DropdownButton.displayName = 'DropdownButton';
DropdownButton.defaultProps = {
  placement: 'bottomRight'
};

var _default = /*#__PURE__*/(0, _react.memo)(DropdownButton);

exports["default"] = _default;
//# sourceMappingURL=dropdown-button.js.map
