import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["className", "children", "hovered", "sliceFrom", "sliceTo", "onClick", "onSelectionChange", "selected", "selectable"];
import React, { forwardRef, useCallback } from 'react';
import Cell from './Cell';
import Checkbox from '../checkbox';
import Row from './Row';
import cx from 'classnames';
import theme from './theme.css';
var BodyRow = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var className = _ref.className,
      children = _ref.children,
      hovered = _ref.hovered,
      sliceFrom = _ref.sliceFrom,
      sliceTo = _ref.sliceTo,
      onClick = _ref.onClick,
      onSelectionChange = _ref.onSelectionChange,
      selected = _ref.selected,
      selectable = _ref.selectable,
      others = _objectWithoutProperties(_ref, _excluded);

  var handleClick = useCallback(function (event) {
    onClick && onClick(event);
  }, [onClick]);
  var childrenArray = Array.isArray(children) ? children : [children];
  var childrenSliced = childrenArray.slice(sliceFrom, sliceTo);
  var classNames = cx(theme['body-row'], _defineProperty({}, theme['has-pointer-cursor'], onClick), className);
  return /*#__PURE__*/React.createElement(Row, _extends({
    backgroundColor: hovered ? 'neutral' : 'white',
    className: classNames,
    "data-teamleader-ui": "datagrid-body-row",
    onClick: handleClick,
    ref: ref
  }, others), selectable && /*#__PURE__*/React.createElement(Cell, {
    flex: "checkbox-width",
    onClick: function onClick(event) {
      return event.stopPropagation();
    },
    preventOverflow: false
  }, /*#__PURE__*/React.createElement(Checkbox, {
    checked: selected,
    onChange: onSelectionChange,
    size: "small"
  })), childrenSliced);
});
BodyRow.displayName = 'DataGrid.BodyRow';
export default BodyRow;