import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["prefixCls", "type", "disabled", "onClick", "children", "className", "overlay", "trigger", "align", "visible", "onVisibleChange", "placement", "getPopupContainer", "buttonProps", "buttonGroupPrefixCls", "overlayPlacements"];
import React, { memo, useContext } from 'react';
import classNames from 'classnames';
import Button from '../button';
import Icon from '../icon';
import Dropdown from './dropdown';
import ConfigContext from '../config-provider/ConfigContext';
var ButtonGroup = Button.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 = _objectWithoutProperties(props, _excluded);

  var _useContext = useContext(ConfigContext),
      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.createElement(ButtonGroup, _extends({}, restProps, {
    prefixCls: buttonGroupPrefixCls,
    className: classNames("".concat(prefixCls, "-button"), className)
  }), /*#__PURE__*/React.createElement(Button, _extends({}, buttonProps, {
    type: type,
    disabled: disabled,
    onClick: onClick
  }), children), /*#__PURE__*/React.createElement(Dropdown, _extends({}, dropdownProps), /*#__PURE__*/React.createElement(Button, _extends({}, buttonProps, {
    type: type
  }), /*#__PURE__*/React.createElement(Icon, {
    type: "arrow_drop_down"
  }))));
};

DropdownButton.displayName = 'DropdownButton';
DropdownButton.defaultProps = {
  placement: 'bottomRight'
};
export default /*#__PURE__*/memo(DropdownButton);
//# sourceMappingURL=dropdown-button.js.map
