'use strict';

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

exports.__esModule = true;
exports.SplitButton = void 0;

var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

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

var _propTypes = _interopRequireDefault(require("prop-types"));

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

var _Dropdown = _interopRequireDefault(require("react-bootstrap/lib/Dropdown"));

var _SplitToggle = _interopRequireDefault(require("react-bootstrap/lib/SplitToggle"));

var _Button = require("./Button");

var SplitButton =
/*#__PURE__*/
function (_React$Component) {
  (0, _inheritsLoose2.default)(SplitButton, _React$Component);

  function SplitButton() {
    return _React$Component.apply(this, arguments) || this;
  }

  var _proto = SplitButton.prototype;

  _proto.render = function render() {
    var _this$props = this.props,
        id = _this$props.id,
        testAutomationId = _this$props.testAutomationId,
        className = _this$props.className,
        bsStyle = _this$props.bsStyle,
        disabled = _this$props.disabled,
        buttonDisabled = _this$props.buttonDisabled,
        splitToggleDisabled = _this$props.splitToggleDisabled,
        splitToggleLabel = _this$props.splitToggleLabel,
        title = _this$props.title,
        onClick = _this$props.onClick,
        children = _this$props.children;
    var splitButtonClassNames = (0, _classnames.default)('split-button', className);
    var splitDecoratorClassNames = (0, _classnames.default)('split-button-decorator', "split-button-decorator-" + bsStyle);
    return _react.default.createElement(_Dropdown.default, {
      id: id || Date.now(),
      className: splitButtonClassNames,
      disabled: disabled || buttonDisabled && splitToggleDisabled,
      "data-test-automation-id": testAutomationId
    }, _react.default.createElement("div", {
      className: splitDecoratorClassNames
    }, _react.default.createElement(_Button.Button, {
      className: "split-button-btn",
      bsStyle: bsStyle,
      disabled: disabled || buttonDisabled,
      onClick: onClick
    }, title)), _react.default.createElement(_SplitToggle.default, {
      bsStyle: bsStyle,
      "data-test-automation-id": "splitToggle",
      className: "split-button-dropdown-toggle",
      "aria-label": splitToggleLabel
    }), _react.default.createElement(_Dropdown.default.Menu, null, children));
  };

  return SplitButton;
}(_react.default.Component);

exports.SplitButton = SplitButton;
(0, _defineProperty2.default)(SplitButton, "propTypes", {
  children: _propTypes.default.node.isRequired,
  id: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
  testAutomationId: _propTypes.default.string,
  className: _propTypes.default.string,
  bsStyle: _propTypes.default.string,
  disabled: _propTypes.default.bool,
  buttonDisabled: _propTypes.default.bool,
  splitToggleDisabled: _propTypes.default.bool,
  splitToggleLabel: _propTypes.default.string,
  title: _propTypes.default.string,
  onClick: _propTypes.default.func
});
(0, _defineProperty2.default)(SplitButton, "defaultProps", {
  id: null,
  testAutomationId: 'splitButton',
  className: null,
  bsStyle: 'primary',
  disabled: false,
  buttonDisabled: false,
  splitToggleDisabled: false,
  splitToggleLabel: 'TRANSLATE:MORE_OPTIONS',
  title: '',
  onClick: null
});