"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Table = Table;

var _jsxRuntime = require("react/jsx-runtime");

function Table(_ref) {
  var columns = _ref.columns,
      data = _ref.data,
      id = _ref.id,
      _ref$sticky = _ref.sticky,
      sticky = _ref$sticky === void 0 ? "false" : _ref$sticky;
  columns = columns.map(function (c) {
    if (typeof c === "string") {
      return {
        name: c
      };
    }

    return c;
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: "flex flex-col",
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "align-middle inline-block min-w-full",
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("table", {
        className: "min-w-full divide-y divide-gray-300 border-separate",
        style: {
          borderSpacing: "0px"
        },
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("thead", {
          className: sticky ? "sticky top-0 bg-white" : "",
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
            children: columns.map(function (column) {
              return /*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
                scope: "col",
                className: "px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider border-b border-gray-300 ".concat(column.className),
                children: column.name
              }, column.name);
            })
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)("tbody", {
          className: "bg-white divide-y divide-gray-300",
          style: {},
          children: data.map(function (row, idx) {
            return (
              /*#__PURE__*/
              // eslint-disable-next-line react/no-array-index-key
              (0, _jsxRuntime.jsx)("tr", {
                children: columns.map(function (column) {
                  return /*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
                    className: "px-4 py-3 border-b border-gray-300",
                    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
                      className: "text-sm text-gray-900",
                      children: row[column.name.toLowerCase()]
                    })
                  }, column.name);
                })
              }, "".concat(id, ".").concat(idx))
            );
          })
        })]
      })
    })
  });
}