function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
/* eslint-disable css-modules/no-unused-class */
import React from 'react';
import classnames from 'classnames';
import style from './style.css';
import { propTypes } from './types';
const ErrorsTable = props => {
  const {
    columns = [],
    rows = [],
    ariaDescribedby
  } = props;
  const headerRow = columns.map((column, cIndex) => {
    const {
      title
    } = column;
    return /*#__PURE__*/React.createElement("th", {
      className: classnames(style[`header-${cIndex + 1}`]),
      key: `${title}-${cIndex + 1}`,
      role: "columnheader"
    }, /*#__PURE__*/React.createElement("div", null, title));
  });
  const headerView = [/*#__PURE__*/React.createElement("th", {
    className: classnames(style[`header-0`]),
    key: "header"
  }, /*#__PURE__*/React.createElement("div", null, " ", ''))].concat(headerRow);
  const bodyView = rows.map((row, index) => {
    const {
      fields = []
    } = row;
    const bodyRow = fields.map((field, fIndex) => {
      return /*#__PURE__*/React.createElement("td", {
        className: classnames(style.col, style[`col-${fIndex + 1}`]),
        key: `${field}-${fIndex}`
      }, field || '');
    });
    bodyRow.unshift(/*#__PURE__*/React.createElement("td", {
      className: classnames(style.col, style[`col-0`]),
      key: "header"
    }, index + 1));
    return /*#__PURE__*/React.createElement("tr", {
      key: `line-${index}`
    }, bodyRow);
  });
  return /*#__PURE__*/React.createElement("table", _extends({}, ariaDescribedby ? {
    'aria-describedby': ariaDescribedby
  } : {}, {
    className: style.table
  }), /*#__PURE__*/React.createElement("thead", {
    className: style.thead
  }, /*#__PURE__*/React.createElement("tr", null, headerView)), /*#__PURE__*/React.createElement("tbody", null, bodyView));
};
ErrorsTable.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
export default ErrorsTable;
//# sourceMappingURL=index.js.map