import React__default from 'react';
import PropTypes from 'prop-types';
import { TableBody, TableRow, TableCell } from '@carbon/react';
import EmptyState from '../../EmptyState/EmptyState.js';
import { settings } from '../../../constants/Settings.js';
import deprecate from '../../../internal/deprecate.js';

var iotPrefix = settings.iotPrefix;
var propTypes = {
  /** The unique id of the table */
  id: PropTypes.string,
  // TODO: remove deprecated 'testID' in v3
  // eslint-disable-next-line react/require-default-props
  testID: deprecate(PropTypes.string, "The 'testID' prop has been deprecated. Please use 'testId' instead."),
  testId: PropTypes.string,
  /** set of internationalized labels */
  i18n: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.element])).isRequired,
  totalColumns: PropTypes.number.isRequired,
  /** Empty error state to render */
  errorState: PropTypes.element,
  error: PropTypes.string,
  onErrorStateAction: PropTypes.func
};
var defaultProps = {
  id: 'ErrorTable',
  testId: 'ErrorTable',
  error: null,
  errorState: null,
  onErrorStateAction: null
};
var ErrorTable = function ErrorTable(_ref) {
  var id = _ref.id,
    testID = _ref.testID,
    testId = _ref.testId,
    i18n = _ref.i18n,
    totalColumns = _ref.totalColumns,
    error = _ref.error,
    errorState = _ref.errorState,
    onErrorStateAction = _ref.onErrorStateAction;
  return /*#__PURE__*/React__default.createElement(TableBody, {
    id: id,
    "data-testid": testID || testId
  }, /*#__PURE__*/React__default.createElement(TableRow, {
    className: "".concat(iotPrefix, "--empty-table--table-row")
  }, /*#__PURE__*/React__default.createElement(TableCell, {
    colSpan: totalColumns
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "empty-table-cell--default"
  }, /*#__PURE__*/React__default.isValidElement(errorState) ? errorState : /*#__PURE__*/React__default.createElement(EmptyState, {
    icon: "error",
    title: i18n.tableErrorStateTitle,
    body: error || '',
    action: onErrorStateAction ? {
      label: i18n.buttonLabelOnTableError,
      onClick: onErrorStateAction,
      kind: 'secondary'
    } : null
  })))));
};
ErrorTable.propTypes = propTypes;
ErrorTable.defaultProps = defaultProps;
ErrorTable.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "ErrorTable",
  "props": {
    "id": {
      "defaultValue": {
        "value": "'ErrorTable'",
        "computed": false
      },
      "description": "The unique id of the table",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "testId": {
      "defaultValue": {
        "value": "'ErrorTable'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "error": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "errorState": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "Empty error state to render",
      "type": {
        "name": "element"
      },
      "required": false
    },
    "onErrorStateAction": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "",
      "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
    },
    "i18n": {
      "description": "set of internationalized labels",
      "type": {
        "name": "objectOf",
        "value": {
          "name": "union",
          "value": [{
            "name": "string"
          }, {
            "name": "func"
          }, {
            "name": "element"
          }]
        }
      },
      "required": true
    },
    "totalColumns": {
      "description": "",
      "type": {
        "name": "number"
      },
      "required": true
    }
  }
};
var ErrorTable$1 = ErrorTable;

export { ErrorTable$1 as default };
