"use strict";

exports.__esModule = true;
exports.stringifyFieldName = exports.default = exports.TableRow = exports.Row = void 0;
var _react = _interopRequireWildcard(require("react"));
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _utils = require("../../utils");
var _DataCell = _interopRequireDefault(require("./DataCell"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var stringifyFieldName = exports.stringifyFieldName = function stringifyFieldName(name) {
  if (Array.isArray(name)) {
    return name.join("_");
  } else {
    return name && name.toString();
  }
};
var TableRow = exports.TableRow = _styledComponents.default.tr.withConfig({
  displayName: "Row__TableRow",
  componentId: "sc-fh6oyu-0"
})(["", " ", ""], (0, _utils.ifFlag)("bgColor", function (props) {
  return (0, _styledComponents.css)(["background-color:", ";"], props.bgColor);
}, (0, _styledComponents.css)(["transition:background-color 0.2s ease-in;&:hover{background-color:#f3f3f3;}"])), (0, _utils.ifFlag)("onClick", (0, _styledComponents.css)(["& td{cursor:pointer;}"])));

// Clicks on these elements will not be handled by the row onClick
var formTags = ["INPUT", "SELECT", "LABEL"];
var Row = exports.Row = function Row(_ref) {
  var columnDefs = _ref.columnDefs,
    row = _ref.row,
    rowId = _ref.rowId,
    selected = _ref.selected,
    rowOnClick = _ref.rowOnClick,
    bgColor = _ref.bgColor;
  var onClick = (0, _react.useCallback)(function (event) {
    if (formTags.indexOf(event.target.tagName) === -1) {
      /* istanbul ignore else */
      if (!event.target.dataset["rowId"]) {
        event.target.dataset["rowId"] = rowId;
      }
      rowOnClick(event);
    }
  }, [rowOnClick, rowId]);
  return /*#__PURE__*/_react.default.createElement(TableRow, {
    onClick: rowOnClick ? onClick : undefined,
    bgColor: bgColor
  }, columnDefs.map(function (columnDef) {
    return /*#__PURE__*/_react.default.createElement(_DataCell.default, {
      key: stringifyFieldName(columnDef.fieldName),
      rowId: rowId,
      row: row,
      columnDef: columnDef,
      selected: selected
    });
  }));
};
__signature__(Row, "useCallback{onClick}");
__signature__(Row, "useCallback{onClick}");
var _default = Row;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(stringifyFieldName, "stringifyFieldName", "/home/vsts/work/1/s/src/components/List/Row.js");
  reactHotLoader.register(TableRow, "TableRow", "/home/vsts/work/1/s/src/components/List/Row.js");
  reactHotLoader.register(formTags, "formTags", "/home/vsts/work/1/s/src/components/List/Row.js");
  reactHotLoader.register(Row, "Row", "/home/vsts/work/1/s/src/components/List/Row.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/List/Row.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(stringifyFieldName, "stringifyFieldName", "/home/vsts/work/1/s/src/components/List/Row.js");
  reactHotLoader.register(TableRow, "TableRow", "/home/vsts/work/1/s/src/components/List/Row.js");
  reactHotLoader.register(formTags, "formTags", "/home/vsts/work/1/s/src/components/List/Row.js");
  reactHotLoader.register(Row, "Row", "/home/vsts/work/1/s/src/components/List/Row.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/List/Row.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();