import React__default from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import { settings } from '../../constants/Settings.js';
import Button from '../Button/Button.js';

var iotPrefix = settings.iotPrefix;
var propTypes = {
  testId: PropTypes.string.isRequired,
  /**
   * The label on a single menu button
   */
  label: PropTypes.string.isRequired,
  /**
   * These are passed from the MenuButton to open to the menu.
   */
  onSecondaryActionClick: PropTypes.func.isRequired,
  /**
   * This is passed from the MenuButton to trigger the primary action
   * on this split button.
   */
  onPrimaryActionClick: PropTypes.func.isRequired,
  /**
   * Optional prop to change the closed state icon on the button
   * Can be a React component class
   */
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
  /**
   * If specifying the `renderIcon` prop, provide a description for that icon that can
   * be read by screen readers
   */
  iconDescription: PropTypes.string.isRequired,
  /**
   * The size of the button and the dropdown items
   */
  size: PropTypes.oneOf(['sm', 'md', 'default']).isRequired,
  /**
   * The kind of button to render
   */
  kind: PropTypes.oneOf(['primary', 'secondary', 'tertiary']).isRequired
};
var SplitMenuButton = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
  var label = _ref.label,
    iconDescription = _ref.iconDescription,
    renderIcon = _ref.renderIcon,
    onPrimaryActionClick = _ref.onPrimaryActionClick,
    onSecondaryActionClick = _ref.onSecondaryActionClick,
    size = _ref.size,
    testId = _ref.testId,
    kind = _ref.kind;
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button, {
    className: classnames("".concat(iotPrefix, "--menu-button__primary")),
    onClick: onPrimaryActionClick,
    testId: "".concat(testId, "-primary"),
    size: size,
    kind: kind
  }, label), /*#__PURE__*/React__default.createElement(Button, {
    ref: ref,
    className: classnames("".concat(iotPrefix, "--menu-button__secondary"), "".concat(iotPrefix, "--menu-button__trigger")),
    hasIconOnly: true,
    iconDescription: iconDescription,
    renderIcon: renderIcon,
    onClick: onSecondaryActionClick,
    testId: "".concat(testId, "-secondary"),
    size: size,
    kind: kind
  }));
});
SplitMenuButton.propTypes = propTypes;
SplitMenuButton.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "SplitMenuButton",
  "props": {
    "testId": {
      "description": "",
      "type": {
        "name": "string"
      },
      "required": true
    },
    "label": {
      "description": "The label on a single menu button",
      "type": {
        "name": "string"
      },
      "required": true
    },
    "onSecondaryActionClick": {
      "description": "These are passed from the MenuButton to open to the menu.",
      "type": {
        "name": "func"
      },
      "required": true
    },
    "onPrimaryActionClick": {
      "description": "This is passed from the MenuButton to trigger the primary action\non this split button.",
      "type": {
        "name": "func"
      },
      "required": true
    },
    "renderIcon": {
      "description": "Optional prop to change the closed state icon on the button\nCan be a React component class",
      "type": {
        "name": "union",
        "value": [{
          "name": "func"
        }, {
          "name": "object"
        }]
      },
      "required": true
    },
    "iconDescription": {
      "description": "If specifying the `renderIcon` prop, provide a description for that icon that can\nbe read by screen readers",
      "type": {
        "name": "string"
      },
      "required": true
    },
    "size": {
      "description": "The size of the button and the dropdown items",
      "type": {
        "name": "enum",
        "value": [{
          "value": "'sm'",
          "computed": false
        }, {
          "value": "'md'",
          "computed": false
        }, {
          "value": "'default'",
          "computed": false
        }]
      },
      "required": true
    },
    "kind": {
      "description": "The kind of button to render",
      "type": {
        "name": "enum",
        "value": [{
          "value": "'primary'",
          "computed": false
        }, {
          "value": "'secondary'",
          "computed": false
        }, {
          "value": "'tertiary'",
          "computed": false
        }]
      },
      "required": true
    }
  }
};

export { SplitMenuButton };
