'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

require('react');
var TableCell = require('./TableCell.js');
var Chevron = require('../chevron/Chevron.js');
require('../common/theme.js');
require('../common/direction.js');
require('@transferwise/neptune-tokens');
require('../common/propsValues/control.js');
require('../common/propsValues/size.js');
require('../common/propsValues/typography.js');
require('../common/propsValues/width.js');
require('../common/propsValues/type.js');
require('../common/propsValues/dateMode.js');
require('../common/propsValues/monthFormat.js');
var position = require('../common/propsValues/position.js');
require('../common/propsValues/layouts.js');
require('../common/propsValues/status.js');
require('../common/propsValues/sentiment.js');
require('../common/propsValues/profileType.js');
require('../common/propsValues/variant.js');
require('../common/propsValues/scroll.js');
require('../common/propsValues/markdownNodeType.js');
require('../common/fileType.js');
require('@transferwise/formatting');
require('@transferwise/icons');
var clsx = require('clsx');
require('react-intl');
require('../common/closeButton/CloseButton.messages.js');
var jsxRuntime = require('react/jsx-runtime');

const TableRow = ({
  rowData,
  hasSeparator = false,
  children,
  onRowClick
}) => {
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
    children: [/*#__PURE__*/jsxRuntime.jsxs("tr", {
      className: clsx.clsx('np-table-row', {
        'np-table-row--clickable': !!onRowClick
      }),
      "data-testid": "np-table-row",
      role: onRowClick ? 'button' : undefined,
      tabIndex: 0,
      onClick: onRowClick && rowData ? () => onRowClick(rowData) : undefined,
      onKeyDown: ({
        key
      }) => {
        if (onRowClick && rowData && key === 'Enter') {
          onRowClick(rowData);
        }
      },
      children: [rowData?.cells ? rowData?.cells?.map((item, index) => {
        const itemIndex = item.cell?.text ? item.cell?.text.concat(index.toString()) : index;
        return /*#__PURE__*/jsxRuntime.jsx(TableCell.default, {
          ...item
        }, itemIndex);
      }) : children, onRowClick && /*#__PURE__*/jsxRuntime.jsx(TableCell.default, {
        className: "np-table-cell--action",
        children: /*#__PURE__*/jsxRuntime.jsx("div", {
          "aria-hidden": "true",
          children: /*#__PURE__*/jsxRuntime.jsx(Chevron.default, {
            orientation: position.Position.RIGHT
          })
        })
      })]
    }), hasSeparator && /*#__PURE__*/jsxRuntime.jsx("tr", {
      "aria-hidden": "true",
      className: "np-table-row np-table-row--separator",
      "data-testid": "np-table-row--separator",
      children: /*#__PURE__*/jsxRuntime.jsx("td", {
        className: "np-table-cell np-table-cell--cosmetic",
        colSpan: onRowClick ? Number(rowData?.cells?.length) + 1 : rowData?.cells?.length,
        "data-testid": "np-table-cell--cosmetic",
        children: /*#__PURE__*/jsxRuntime.jsx("div", {
          className: "np-table-cell-separator",
          "data-testid": "np-table-cell-separator"
        })
      })
    })]
  });
};

exports.default = TableRow;
//# sourceMappingURL=TableRow.js.map
