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 { EmptyStatePropTypes } from '../TablePropTypes.js';
import deprecate from '../../../internal/deprecate.js';

var iotPrefix = settings.iotPrefix;
var propTypes = {
  /** The unique id of the table */
  id: PropTypes.string,
  /** Empty state to render, either a custom element or an object */
  emptyState: EmptyStatePropTypes.isRequired,
  totalColumns: PropTypes.number.isRequired,
  isFiltered: PropTypes.bool.isRequired,
  onEmptyStateAction: PropTypes.func,
  // 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,
  /** icon to display while no data in table */
  emptyStateIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOf(['error', 'error404', 'empty', 'not-authorized', 'no-result', 'success', ''])])
};
var defaultProps = {
  id: 'EmptyTable',
  onEmptyStateAction: null,
  testId: '',
  emptyStateIcon: ''
};
var EmptyTable = function EmptyTable(_ref) {
  var id = _ref.id,
    totalColumns = _ref.totalColumns,
    isFiltered = _ref.isFiltered,
    emptyState = _ref.emptyState,
    onEmptyStateAction = _ref.onEmptyStateAction,
    _ref$emptyState = _ref.emptyState,
    messageWithFilters = _ref$emptyState.messageWithFilters,
    message = _ref$emptyState.message,
    buttonLabel = _ref$emptyState.buttonLabel,
    buttonLabelWithFilters = _ref$emptyState.buttonLabelWithFilters,
    messageBody = _ref$emptyState.messageBody,
    messageWithFiltersBody = _ref$emptyState.messageWithFiltersBody,
    testID = _ref.testID,
    testId = _ref.testId,
    emptyStateIcon = _ref.emptyStateIcon;
  return /*#__PURE__*/React__default.createElement(TableBody, {
    id: "".concat(id, "-empty-table")
    // TODO: remove deprecated 'testID' in v3
    ,
    "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.isValidElement(emptyState) ? emptyState : /*#__PURE__*/React__default.createElement("div", {
    className: "empty-table-cell--default"
  }, isFiltered ? /*#__PURE__*/React__default.createElement(EmptyState, {
    icon: "no-result",
    title: messageWithFilters,
    body: messageWithFiltersBody || '',
    action: onEmptyStateAction ? {
      label: buttonLabelWithFilters,
      onClick: onEmptyStateAction,
      kind: 'secondary'
    } : null
  }) : /*#__PURE__*/React__default.createElement(EmptyState, {
    icon: emptyStateIcon !== '' ? emptyStateIcon : 'empty',
    title: message,
    body: messageBody || '',
    action: onEmptyStateAction ? {
      label: buttonLabel,
      onClick: onEmptyStateAction
    } : null
  })))));
};
EmptyTable.propTypes = propTypes;
EmptyTable.defaultProps = defaultProps;
EmptyTable.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "EmptyTable",
  "props": {
    "id": {
      "defaultValue": {
        "value": "'EmptyTable'",
        "computed": false
      },
      "description": "The unique id of the table",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "onEmptyStateAction": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "testId": {
      "defaultValue": {
        "value": "''",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "emptyStateIcon": {
      "defaultValue": {
        "value": "''",
        "computed": false
      },
      "description": "icon to display while no data in table",
      "type": {
        "name": "union",
        "value": [{
          "name": "func"
        }, {
          "name": "enum",
          "value": [{
            "value": "'error'",
            "computed": false
          }, {
            "value": "'error404'",
            "computed": false
          }, {
            "value": "'empty'",
            "computed": false
          }, {
            "value": "'not-authorized'",
            "computed": false
          }, {
            "value": "'no-result'",
            "computed": false
          }, {
            "value": "'success'",
            "computed": false
          }, {
            "value": "''",
            "computed": false
          }]
        }]
      },
      "required": false
    },
    "emptyState": {
      "description": "Empty state to render, either a custom element or an object",
      "type": {
        "name": "custom",
        "raw": "EmptyStatePropTypes.isRequired"
      },
      "required": false
    },
    "totalColumns": {
      "description": "",
      "type": {
        "name": "number"
      },
      "required": true
    },
    "isFiltered": {
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": true
    },
    "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 EmptyTable$1 = EmptyTable;

export { EmptyTable$1 as default };
