import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef, useContext } from 'react';
import { classes } from '../List.tokens.js';
import { ListContext } from '../List.context.js';
import { StyledListItem, CellItem } from './ListItem.styles.js';

var _excluded = ["children", "contentRight", "disabled", "onClick"];
var ListItem = /*#__PURE__*/forwardRef(function (_ref, outerRef) {
  var children = _ref.children,
    contentRight = _ref.contentRight,
    disabled = _ref.disabled,
    onClick = _ref.onClick,
    rest = _objectWithoutProperties(_ref, _excluded);
  var listContext = useContext(ListContext);
  var isDisabled = disabled || listContext.disabled;
  var handleClick = function handleClick(event) {
    if (isDisabled || !onClick) {
      return;
    }
    onClick(event);
  };
  return /*#__PURE__*/React__default.createElement(StyledListItem, _extends({
    ref: outerRef,
    className: isDisabled ? classes.disabledListItem : '',
    onClick: handleClick,
    tabIndex: isDisabled ? -1 : 0
  }, rest), /*#__PURE__*/React__default.createElement(CellItem, {
    contentRight: contentRight
  }, children));
});

export { ListItem };
//# sourceMappingURL=ListItem.js.map
