import React__default, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { Button } from '@carbon/react';
import { Tooltip } from '../../../Tooltip/index.js';
import { settings } from '../../../../constants/Settings.js';
import { RowActionErrorPropTypes } from '../../TablePropTypes.js';
import { WarningAlt } from '@carbon/icons-react';

var iotPrefix = settings.iotPrefix;
var propTypes = {
  /** I18N label for action failed */
  actionFailedText: PropTypes.string,
  /** I18N label for learn more */
  learnMoreText: PropTypes.string,
  /** I18N label for dismiss */
  dismissText: PropTypes.string,
  /** did an error occur */
  rowActionsError: RowActionErrorPropTypes,
  onClearError: PropTypes.func
};
var defaultProps = {
  actionFailedText: 'Action failed',
  learnMoreText: 'Learn more',
  dismissText: 'Dismiss',
  rowActionsError: null,
  onClearError: null
};
var RowActionsError = function RowActionsError(_ref) {
  var rowActionsError = _ref.rowActionsError,
    actionFailedText = _ref.actionFailedText,
    learnMoreText = _ref.learnMoreText,
    dismissText = _ref.dismissText,
    onClearError = _ref.onClearError;
  if (!rowActionsError) {
    return null;
  }
  var title = rowActionsError.title,
    message = rowActionsError.message,
    learnMoreURL = rowActionsError.learnMoreURL;
  return /*#__PURE__*/React__default.createElement(Fragment, null, /*#__PURE__*/React__default.createElement(Tooltip, {
    tabIndex: 0,
    triggerText: "",
    triggerId: "tooltip-error",
    tooltipId: "tooltip",
    renderIcon: /*#__PURE__*/React__default.forwardRef(function (props, ref) {
      return /*#__PURE__*/React__default.createElement(WarningAlt, {
        ref: ref
      });
    })
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "".concat(iotPrefix, "--row-actions-error--tooltip")
  }, /*#__PURE__*/React__default.createElement("p", {
    className: "".concat(iotPrefix, "--row-actions-error--title")
  }, title), message, /*#__PURE__*/React__default.createElement("div", {
    className: "".concat(iotPrefix, "--row-actions-error--footer")
  }, learnMoreURL ? /*#__PURE__*/React__default.createElement("a", {
    href: learnMoreURL,
    target: "_blank",
    rel: "noopener noreferrer"
  }, learnMoreText) : /*#__PURE__*/React__default.createElement("div", null), onClearError ? /*#__PURE__*/React__default.createElement(Button, {
    onClick: function onClick(evt) {
      onClearError(evt);
      evt.stopPropagation();
    }
  }, dismissText) : null))), /*#__PURE__*/React__default.createElement("span", {
    className: "".concat(iotPrefix, "--row-actions-error--span")
  }, actionFailedText));
};
RowActionsError.propTypes = propTypes;
RowActionsError.defaultProps = defaultProps;
RowActionsError.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "RowActionsError",
  "props": {
    "actionFailedText": {
      "defaultValue": {
        "value": "'Action failed'",
        "computed": false
      },
      "description": "I18N label for action failed",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "learnMoreText": {
      "defaultValue": {
        "value": "'Learn more'",
        "computed": false
      },
      "description": "I18N label for learn more",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "dismissText": {
      "defaultValue": {
        "value": "'Dismiss'",
        "computed": false
      },
      "description": "I18N label for dismiss",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "rowActionsError": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "did an error occur",
      "type": {
        "name": "custom",
        "raw": "RowActionErrorPropTypes"
      },
      "required": false
    },
    "onClearError": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "func"
      },
      "required": false
    }
  }
};
var RowActionsError$1 = RowActionsError;

export { RowActionsError$1 as default };
