"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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

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

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

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

var _ButtonGroup = _interopRequireDefault(require("../../../lib/button/ButtonGroup"));

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

var _Dropdown = _interopRequireDefault(require("./Dropdown"));

var _interface = require("../button/interface");

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

var _enum = require("./enum");

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"];

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 = (0, _objectWithoutProperties2["default"])(props, _excluded);

  var _ref = buttonProps || {},
      btnPropsColor = _ref.color,
      btnPropsFuncType = _ref.funcType,
      btnPropsSize = _ref.size,
      btnPropsDisabled = _ref.disabled,
      btnPropsLoading = _ref.loading,
      restButtonProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded2);

  var _useContext = (0, _react.useContext)(_ConfigContext["default"]),
      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["default"].createElement(_ButtonGroup["default"], {
    size: size,
    style: style,
    prefixCls: buttonGroupPrefixCls,
    className: (0, _classnames["default"])("".concat(prefixCls, "-button"), className, (_classNames = {}, (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-button-raised"), !funcType || funcType === _interface.FuncType.raised), (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-button-flat"), funcType === _interface.FuncType.flat), (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-button-link"), funcType === _interface.FuncType.link), (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-button-block"), block), _classNames))
  }, /*#__PURE__*/_react["default"].createElement(_button["default"], (0, _extends2["default"])({}, restProps, restButtonProps, {
    disabled: disabled || btnPropsDisabled,
    loading: loading || btnPropsLoading,
    color: color || btnPropsColor,
    funcType: funcType || btnPropsFuncType,
    size: size || btnPropsSize
  }), children), /*#__PURE__*/_react["default"].createElement(_Dropdown["default"], (0, _extends2["default"])({}, dropdownProps), icon ? /*#__PURE__*/_react["default"].createElement(_button["default"], {
    color: color || btnPropsColor,
    funcType: funcType || btnPropsFuncType,
    size: size || btnPropsSize,
    disabled: dropdownProps.disabled
  }, icon) : /*#__PURE__*/_react["default"].createElement(_button["default"], {
    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: _enum.Placements.bottomRight
};
var _default = DropdownButton;
exports["default"] = _default;
//# sourceMappingURL=DropdownButton.js.map
