import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import 'core-js/modules/es.array.concat.js';
import 'core-js/modules/es.array.map.js';
import React__default from 'react';
import PropTypes from 'prop-types';
import { TableBody, TableRow, TableCell, SkeletonText } from '@carbon/react';
import classnames from 'classnames';
import { settings } from '../../../constants/Settings.js';
import deprecate from '../../../internal/deprecate.js';

var iotPrefix = settings.iotPrefix;
var propTypes = {
  hasRowSelection: PropTypes.oneOf(['multi', 'single', false]),
  hasRowExpansion: PropTypes.bool,
  hasRowNesting: PropTypes.bool,
  hasRowActions: PropTypes.bool,
  rowCount: PropTypes.number,
  /* used to show X number of loading skeletons when columns are unknown */
  columnCount: PropTypes.number,
  columns: PropTypes.arrayOf(PropTypes.shape({
    id: PropTypes.string.isRequired
  })),
  // 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,
  /** shows an additional column that can expand/shrink as the table is resized  */
  showExpanderColumn: PropTypes.bool
};
var defaultProps = {
  hasRowSelection: false,
  hasRowExpansion: false,
  hasRowActions: false,
  hasRowNesting: false,
  rowCount: 10,
  columnCount: 5,
  columns: [],
  testId: '',
  showExpanderColumn: false
};

/** This component is exactly like the DataTableSkeleton component from carbon, but it shows your headers while it loads */
var TableSkeletonWithHeaders = function TableSkeletonWithHeaders(_ref) {
  var hasRowSelection = _ref.hasRowSelection,
    hasRowExpansion = _ref.hasRowExpansion,
    hasRowActions = _ref.hasRowActions,
    hasRowNesting = _ref.hasRowNesting,
    columns = _ref.columns,
    rowCount = _ref.rowCount,
    columnCount = _ref.columnCount,
    testID = _ref.testID,
    testId = _ref.testId,
    showExpanderColumn = _ref.showExpanderColumn;
  var rows = _toConsumableArray(Array(rowCount > 0 ? rowCount - 1 : 0));
  var loadingColumns = columns.length ? columns : _toConsumableArray(Array(columnCount > 0 ? columnCount : 1)).map(function (c, i) {
    return {
      id: i
    };
  });
  return /*#__PURE__*/React__default.createElement(TableBody, {
    "data-testid": testID || testId
  }, /*#__PURE__*/React__default.createElement(TableRow, {
    className: classnames("".concat(iotPrefix, "--table-skeleton-with-headers--table-row"), _defineProperty({}, "".concat(iotPrefix, "--table-skeleton-with-headers--table-row--head"), !columns.length))
  }, hasRowSelection === 'multi' ? /*#__PURE__*/React__default.createElement(TableCell, null) : null, hasRowExpansion || hasRowNesting ? /*#__PURE__*/React__default.createElement(TableCell, null) : null, loadingColumns.map(function (column) {
    return /*#__PURE__*/React__default.createElement(TableCell, {
      key: "skeletonCol-".concat(column.id)
    }, /*#__PURE__*/React__default.createElement(SkeletonText, null));
  }), showExpanderColumn ? /*#__PURE__*/React__default.createElement(TableCell, {
    "data-testid": "".concat(testID || testId, "-expander-column")
  }) : null, hasRowActions ? /*#__PURE__*/React__default.createElement(TableCell, null) : null), rows.map(function (row, rowIndex) {
    return /*#__PURE__*/React__default.createElement(TableRow, {
      key: "skeletonRow-".concat(rowIndex),
      className: "".concat(iotPrefix, "--table-skeleton-with-headers--table-row")
    }, hasRowSelection === 'multi' ? /*#__PURE__*/React__default.createElement(TableCell, null) : null, hasRowExpansion || hasRowNesting ? /*#__PURE__*/React__default.createElement(TableCell, null) : null, loadingColumns.map(function (v, colIndex) {
      return /*#__PURE__*/React__default.createElement(TableCell, {
        key: "emptycell-".concat(colIndex)
      }, rowIndex === 0 && !columns.length ? /*#__PURE__*/React__default.createElement(SkeletonText, null) : null);
    }), showExpanderColumn ? /*#__PURE__*/React__default.createElement(TableCell, {
      "data-testid": "".concat(testID || testId, "-skeletonRow-").concat(rowIndex, "-expander-column")
    }) : null, hasRowActions ? /*#__PURE__*/React__default.createElement(TableCell, null) : null);
  }));
};
TableSkeletonWithHeaders.propTypes = propTypes;
TableSkeletonWithHeaders.defaultProps = defaultProps;
TableSkeletonWithHeaders.__docgenInfo = {
  "description": "This component is exactly like the DataTableSkeleton component from carbon, but it shows your headers while it loads",
  "methods": [],
  "displayName": "TableSkeletonWithHeaders",
  "props": {
    "hasRowSelection": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "enum",
        "value": [{
          "value": "'multi'",
          "computed": false
        }, {
          "value": "'single'",
          "computed": false
        }, {
          "value": "false",
          "computed": false
        }]
      },
      "required": false
    },
    "hasRowExpansion": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "hasRowActions": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "hasRowNesting": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "rowCount": {
      "defaultValue": {
        "value": "10",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "number"
      },
      "required": false
    },
    "columnCount": {
      "defaultValue": {
        "value": "5",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "number"
      },
      "required": false
    },
    "columns": {
      "defaultValue": {
        "value": "[]",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "arrayOf",
        "value": {
          "name": "shape",
          "value": {
            "id": {
              "name": "string",
              "required": true
            }
          }
        }
      },
      "required": false
    },
    "testId": {
      "defaultValue": {
        "value": "''",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "showExpanderColumn": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "shows an additional column that can expand/shrink as the table is resized",
      "type": {
        "name": "bool"
      },
      "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 TableSkeletonWithHeaders$1 = TableSkeletonWithHeaders;

export { TableSkeletonWithHeaders$1 as default };
