import 'react';
import TableCell from './TableCell.mjs';
import Chevron from '../chevron/Chevron.mjs';
import '../common/theme.mjs';
import '../common/direction.mjs';
import '@transferwise/neptune-tokens';
import '../common/propsValues/control.mjs';
import '../common/propsValues/size.mjs';
import '../common/propsValues/typography.mjs';
import '../common/propsValues/width.mjs';
import '../common/propsValues/type.mjs';
import '../common/propsValues/dateMode.mjs';
import '../common/propsValues/monthFormat.mjs';
import { Position } from '../common/propsValues/position.mjs';
import '../common/propsValues/layouts.mjs';
import '../common/propsValues/status.mjs';
import '../common/propsValues/sentiment.mjs';
import '../common/propsValues/profileType.mjs';
import '../common/propsValues/variant.mjs';
import '../common/propsValues/scroll.mjs';
import '../common/propsValues/markdownNodeType.mjs';
import '../common/fileType.mjs';
import '@transferwise/formatting';
import '@transferwise/icons';
import { clsx } from 'clsx';
import 'react-intl';
import '../common/closeButton/CloseButton.messages.mjs';
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';

const TableRow = ({
  rowData,
  hasSeparator = false,
  children,
  onRowClick
}) => {
  return /*#__PURE__*/jsxs(Fragment, {
    children: [/*#__PURE__*/jsxs("tr", {
      className: 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__*/jsx(TableCell, {
          ...item
        }, itemIndex);
      }) : children, onRowClick && /*#__PURE__*/jsx(TableCell, {
        className: "np-table-cell--action",
        children: /*#__PURE__*/jsx("div", {
          "aria-hidden": "true",
          children: /*#__PURE__*/jsx(Chevron, {
            orientation: Position.RIGHT
          })
        })
      })]
    }), hasSeparator && /*#__PURE__*/jsx("tr", {
      "aria-hidden": "true",
      className: "np-table-row np-table-row--separator",
      "data-testid": "np-table-row--separator",
      children: /*#__PURE__*/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__*/jsx("div", {
          className: "np-table-cell-separator",
          "data-testid": "np-table-cell-separator"
        })
      })
    })]
  });
};

export { TableRow as default };
//# sourceMappingURL=TableRow.mjs.map
