'use strict';

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

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _button = require('../button');

var _button2 = _interopRequireDefault(_button);

var _icon = require('../icon');

var _icon2 = _interopRequireDefault(_icon);

var _dropdown = require('./dropdown');

var _dropdown2 = _interopRequireDefault(_dropdown);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var __rest = undefined && undefined.__rest || function (s, e) {
    var t = {};
    for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
    }if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
        if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
    }return t;
};

var ButtonGroup = _button2["default"].Group;

var DropdownButton = function (_React$Component) {
    (0, _inherits3["default"])(DropdownButton, _React$Component);

    function DropdownButton() {
        (0, _classCallCheck3["default"])(this, DropdownButton);
        return (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));
    }

    DropdownButton.prototype.render = function render() {
        var _a = this.props,
            type = _a.type,
            overlay = _a.overlay,
            trigger = _a.trigger,
            align = _a.align,
            children = _a.children,
            className = _a.className,
            onClick = _a.onClick,
            prefixCls = _a.prefixCls,
            disabled = _a.disabled,
            visible = _a.visible,
            onVisibleChange = _a.onVisibleChange,
            restProps = __rest(_a, ["type", "overlay", "trigger", "align", "children", "className", "onClick", "prefixCls", "disabled", "visible", "onVisibleChange"]);
        var cls = (0, _classnames2["default"])(prefixCls, className);
        var dropdownProps = {
            align: align,
            overlay: overlay,
            trigger: disabled ? [] : trigger,
            onVisibleChange: onVisibleChange
        };
        if ('visible' in this.props) {
            dropdownProps.visible = visible;
        }
        return _react2["default"].createElement(
            ButtonGroup,
            (0, _extends3["default"])({}, restProps, { className: cls }),
            _react2["default"].createElement(
                _button2["default"],
                { type: type, onClick: onClick, disabled: disabled },
                children
            ),
            _react2["default"].createElement(
                _dropdown2["default"],
                dropdownProps,
                _react2["default"].createElement(
                    _button2["default"],
                    { type: type, disabled: disabled },
                    _react2["default"].createElement(_icon2["default"], { type: 'down' })
                )
            )
        );
    };

    return DropdownButton;
}(_react2["default"].Component);

exports["default"] = DropdownButton;

DropdownButton.defaultProps = {
    align: {
        points: ['tr', 'br'],
        overlay: {
            adjustX: 1,
            adjustY: 1
        },
        offset: [0, 4],
        targetOffset: [0, 0]
    },
    type: 'default',
    prefixCls: 'ant-dropdown-button'
};
module.exports = exports['default'];