import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["trigger", "overlay", "onHiddenChange", "onHiddenBeforeChange", "onVisibleChange", "onOverlayClick", "hidden", "visible", "defaultHidden", "defaultVisible", "disabled", "loading", "getPopupContainer", "suffixCls", "prefixCls", "className", "placement", "popupClassName", "block", "style", "icon", "size", "color", "funcType", "children", "buttonProps", "buttonGroupPrefixCls"],
    _excluded2 = ["color", "funcType", "size", "disabled", "loading"];
import React, { useContext } from 'react';
import classNames from 'classnames';
import ButtonGroup from '../../../es/button/ButtonGroup';
import ConfigContext from '../../../es/config-provider/ConfigContext';
import Dropdown from './Dropdown';
import { FuncType } from '../button/interface';
import Button from '../button';
import { Placements } from './enum';

var DropdownButton = function DropdownButton(props) {
  var _classNames;

  var trigger = props.trigger,
      overlay = props.overlay,
      onHiddenChange = props.onHiddenChange,
      onHiddenBeforeChange = props.onHiddenBeforeChange,
      onVisibleChange = props.onVisibleChange,
      onOverlayClick = props.onOverlayClick,
      hidden = props.hidden,
      visible = props.visible,
      defaultHidden = props.defaultHidden,
      defaultVisible = props.defaultVisible,
      disabled = props.disabled,
      loading = props.loading,
      getPopupContainer = props.getPopupContainer,
      customizeSuffixCls = props.suffixCls,
      customizePrefixCls = props.prefixCls,
      className = props.className,
      placement = props.placement,
      popupClassName = props.popupClassName,
      block = props.block,
      style = props.style,
      icon = props.icon,
      size = props.size,
      color = props.color,
      funcType = props.funcType,
      children = props.children,
      buttonProps = props.buttonProps,
      buttonGroupPrefixCls = props.buttonGroupPrefixCls,
      restProps = _objectWithoutProperties(props, _excluded);

  var _ref = buttonProps || {},
      btnPropsColor = _ref.color,
      btnPropsFuncType = _ref.funcType,
      btnPropsSize = _ref.size,
      btnPropsDisabled = _ref.disabled,
      btnPropsLoading = _ref.loading,
      restButtonProps = _objectWithoutProperties(_ref, _excluded2);

  var _useContext = useContext(ConfigContext),
      getProPrefixCls = _useContext.getProPrefixCls;

  var prefixCls = getProPrefixCls('dropdown', customizePrefixCls);
  var dropdownProps = {
    trigger: disabled ? [] : trigger,
    overlay: overlay,
    onHiddenChange: onHiddenChange,
    onHiddenBeforeChange: onHiddenBeforeChange,
    onVisibleChange: onVisibleChange,
    onOverlayClick: onOverlayClick,
    hidden: hidden,
    visible: visible,
    defaultHidden: defaultHidden,
    defaultVisible: defaultVisible,
    disabled: disabled || loading || btnPropsLoading,
    getPopupContainer: getPopupContainer,
    suffixCls: customizeSuffixCls,
    prefixCls: prefixCls,
    placement: placement,
    popupClassName: popupClassName
  };
  return /*#__PURE__*/React.createElement(ButtonGroup, {
    size: size,
    style: style,
    prefixCls: buttonGroupPrefixCls,
    className: classNames("".concat(prefixCls, "-button"), className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-button-raised"), !funcType || funcType === FuncType.raised), _defineProperty(_classNames, "".concat(prefixCls, "-button-flat"), funcType === FuncType.flat), _defineProperty(_classNames, "".concat(prefixCls, "-button-link"), funcType === FuncType.link), _defineProperty(_classNames, "".concat(prefixCls, "-button-block"), block), _classNames))
  }, /*#__PURE__*/React.createElement(Button, _extends({}, restProps, restButtonProps, {
    disabled: disabled || btnPropsDisabled,
    loading: loading || btnPropsLoading,
    color: color || btnPropsColor,
    funcType: funcType || btnPropsFuncType,
    size: size || btnPropsSize
  }), children), /*#__PURE__*/React.createElement(Dropdown, _extends({}, dropdownProps), icon ? /*#__PURE__*/React.createElement(Button, {
    color: color || btnPropsColor,
    funcType: funcType || btnPropsFuncType,
    size: size || btnPropsSize,
    disabled: dropdownProps.disabled
  }, icon) : /*#__PURE__*/React.createElement(Button, {
    color: color || btnPropsColor,
    funcType: funcType || btnPropsFuncType,
    size: size || btnPropsSize,
    disabled: dropdownProps.disabled,
    icon: "arrow_drop_down"
  })));
};

DropdownButton.__PRO_DROPDOWN_BUTTON = true;
DropdownButton.displayName = 'DropdownButton';
DropdownButton.defaultProps = {
  placement: Placements.bottomRight
};
export default DropdownButton;
//# sourceMappingURL=DropdownButton.js.map
