'use strict';

import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import Dropdown from 'react-bootstrap/lib/Dropdown';
import SplitToggle from 'react-bootstrap/lib/SplitToggle';
import { Button } from './Button';
export var SplitButton =
/*#__PURE__*/
function (_React$Component) {
  _inheritsLoose(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 = classnames('split-button', className);
    var splitDecoratorClassNames = classnames('split-button-decorator', "split-button-decorator-" + bsStyle);
    return React.createElement(Dropdown, {
      id: id || Date.now(),
      className: splitButtonClassNames,
      disabled: disabled || buttonDisabled && splitToggleDisabled,
      "data-test-automation-id": testAutomationId
    }, React.createElement("div", {
      className: splitDecoratorClassNames
    }, React.createElement(Button, {
      className: "split-button-btn",
      bsStyle: bsStyle,
      disabled: disabled || buttonDisabled,
      onClick: onClick
    }, title)), React.createElement(SplitToggle, {
      bsStyle: bsStyle,
      "data-test-automation-id": "splitToggle",
      className: "split-button-dropdown-toggle",
      "aria-label": splitToggleLabel
    }), React.createElement(Dropdown.Menu, null, children));
  };

  return SplitButton;
}(React.Component);

_defineProperty(SplitButton, "propTypes", {
  children: PropTypes.node.isRequired,
  id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
  testAutomationId: PropTypes.string,
  className: PropTypes.string,
  bsStyle: PropTypes.string,
  disabled: PropTypes.bool,
  buttonDisabled: PropTypes.bool,
  splitToggleDisabled: PropTypes.bool,
  splitToggleLabel: PropTypes.string,
  title: PropTypes.string,
  onClick: PropTypes.func
});

_defineProperty(SplitButton, "defaultProps", {
  id: null,
  testAutomationId: 'splitButton',
  className: null,
  bsStyle: 'primary',
  disabled: false,
  buttonDisabled: false,
  splitToggleDisabled: false,
  splitToggleLabel: 'TRANSLATE:MORE_OPTIONS',
  title: '',
  onClick: null
});