import _extends from '@babel/runtime/helpers/extends';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import 'core-js/modules/es.array.concat.js';
import React__default from 'react';
import PropTypes from 'prop-types';
import { Button as Button$2, Loading } from '@carbon/react';
import classnames from 'classnames';
import { settings } from '../../constants/Settings.js';
import deprecate from '../../internal/deprecate.js';

var _excluded = ["children", "loading", "disabled", "className", "onClick", "kind", "recommended", "hasIconOnly", "selected", "testID", "testId"];
var ButtonKinds = ['primary', 'secondary', 'tertiary', 'tertiary--light', 'ghost', 'danger', 'danger--primary', 'danger--ghost', 'danger--tertiary'];
var iotPrefix = settings.iotPrefix;
var propTypes = {
  /** Show loading spinner, only new prop */
  loading: PropTypes.bool,
  /** Disable the button will be auto disabled when loading */
  disabled: PropTypes.bool,
  /** Button label */
  children: PropTypes.node,
  /** click handler */
  onClick: PropTypes.func,
  // eslint-disable-line react/require-default-props
  className: PropTypes.string,
  /** primary, secondary, etc from carbon */
  kind: PropTypes.oneOf([].concat(ButtonKinds, ['icon-selection'])),
  /** display green border to denote a recommended button to select, to be used with kind: 'icon-selection' */
  recommended: PropTypes.bool,
  /** Specify if the button is an icon-only button */
  hasIconOnly: PropTypes.bool,
  /** Toggle selected styling for buttons of kind=icon-selection */
  selected: PropTypes.bool,
  // TODO: remove deprecated testID prop in v3
  // eslint-disable-next-line react/require-default-props
  testID: deprecate(PropTypes.string, "The 'testID' prop has been deprecated. Please use 'testId' instead."),
  /** Id that can be used for testing */
  testId: PropTypes.string
};
var defaultProps = {
  loading: false,
  disabled: false,
  className: null,
  kind: 'primary',
  children: null,
  recommended: false,
  hasIconOnly: false,
  selected: false,
  testId: 'Button'
};
var Button = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
  var children = props.children,
    loading = props.loading,
    disabled = props.disabled,
    className = props.className,
    onClick = props.onClick,
    kind = props.kind,
    recommended = props.recommended,
    hasIconOnly = props.hasIconOnly,
    selected = props.selected,
    testID = props.testID,
    testId = props.testId,
    other = _objectWithoutProperties(props, _excluded);
  return /*#__PURE__*/React__default.createElement(Button$2, _extends({}, other, {
    ref: ref
    // TODO: remove deprecated testID prop in v3
    ,
    "data-testid": testID || testId,
    kind: kind === 'icon-selection' ? 'ghost' : kind,
    hasIconOnly: kind === 'icon-selection' ? true : hasIconOnly,
    onClick: onClick,
    className: classnames(className, "".concat(iotPrefix, "--btn"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(iotPrefix, "--btn-icon-selection"), kind === 'icon-selection'), "".concat(iotPrefix, "--btn-icon-selection--recommended"), kind === 'icon-selection' && !disabled && recommended), "".concat(iotPrefix, "--btn-icon-selection--selected"), kind === 'icon-selection' && selected)),
    disabled: disabled || loading !== undefined && loading !== false
  }), loading ? /*#__PURE__*/React__default.createElement(Loading, {
    small: true,
    withOverlay: false
  }) : null, kind === 'icon-selection' && !disabled && recommended ? /*#__PURE__*/React__default.createElement("div", {
    className: "".concat(iotPrefix, "--btn-icon-selection--recommended_marker")
  }) : null, children);
});
Button.propTypes = propTypes;
Button.defaultProps = defaultProps;
Button.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "Button",
  "props": {
    "loading": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "Show loading spinner, only new prop",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "disabled": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "Disable the button will be auto disabled when loading",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "className": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "kind": {
      "defaultValue": {
        "value": "'primary'",
        "computed": false
      },
      "description": "primary, secondary, etc from carbon",
      "type": {
        "name": "enum",
        "value": [{
          "value": "'primary'",
          "computed": false
        }, {
          "value": "'secondary'",
          "computed": false
        }, {
          "value": "'tertiary'",
          "computed": false
        }, {
          "value": "'tertiary--light'",
          "computed": false
        }, {
          "value": "'ghost'",
          "computed": false
        }, {
          "value": "'danger'",
          "computed": false
        }, {
          "value": "'danger--primary'",
          "computed": false
        }, {
          "value": "'danger--ghost'",
          "computed": false
        }, {
          "value": "'danger--tertiary'",
          "computed": false
        }, {
          "value": "'icon-selection'",
          "computed": false
        }]
      },
      "required": false
    },
    "children": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "Button label",
      "type": {
        "name": "node"
      },
      "required": false
    },
    "recommended": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "display green border to denote a recommended button to select, to be used with kind: 'icon-selection'",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "hasIconOnly": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "Specify if the button is an icon-only button",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "selected": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "Toggle selected styling for buttons of kind=icon-selection",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "testId": {
      "defaultValue": {
        "value": "'Button'",
        "computed": false
      },
      "description": "Id that can be used for testing",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "onClick": {
      "description": "click handler",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "testID": {
      "description": "",
      "type": {
        "name": "custom",
        "raw": "deprecate(\n  PropTypes.string,\n  `The 'testID' prop has been deprecated. Please use 'testId' instead.`\n)"
      },
      "required": false
    }
  }
};
var Button$1 = Button;

export { Button$1 as default };
