"use strict";

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

var _react = _interopRequireDefault(require("react"));

var _materialTable = _interopRequireDefault(require("material-table"));

var _TableIcons = require("./TableIcons");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// TODO: abstract into component that manages focus: https://www.w3.org/TR/wai-aria-practices-1.1/#grid
var EditableTable = function EditableTable(_ref) {
  var title = _ref.title,
      data = _ref.data,
      columns = _ref.columns,
      onRowUpdate = _ref.onRowUpdate,
      onRowDelete = _ref.onRowDelete,
      _ref$selectable = _ref.selectable,
      selectable = _ref$selectable === void 0 ? false : _ref$selectable;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: "oec-editable-table"
  }, /*#__PURE__*/_react.default.createElement(_materialTable.default, {
    icons: _TableIcons.TABLE_ICONS,
    title: title,
    data: data,
    columns: columns,
    editable: {
      onRowUpdate: onRowUpdate,
      onRowDelete: onRowDelete
    },
    options: {
      rowStyle: {
        fontFamily: _TableIcons.OEC_FONT_FAMILY
      },
      headerStyle: {
        fontFamily: _TableIcons.OEC_FONT_FAMILY,
        whiteSpace: 'nowrap'
      },
      showTitle: false,
      paging: false,
      search: false,
      toolbar: false,
      selection: selectable
    }
  }));
};

exports.EditableTable = EditableTable;