import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["scrollable", "children", "handleShowScrollShadow"];
import React, { forwardRef } from 'react';
import { Box } from '../../index';
var Body = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var scrollable = _ref.scrollable,
      children = _ref.children,
      handleShowScrollShadow = _ref.handleShowScrollShadow,
      rest = _objectWithoutProperties(_ref, _excluded);

  if (!scrollable) {
    return /*#__PURE__*/React.createElement("div", {
      ref: ref
    }, children);
  }

  var handleWrapperScroll = function handleWrapperScroll(event) {
    if (!event.target) {
      return;
    }

    var element = event.target;
    handleShowScrollShadow && handleShowScrollShadow(element.scrollHeight - element.scrollTop === element.clientHeight);
  };

  return /*#__PURE__*/React.createElement(Box, _extends({
    display: "flex",
    flexDirection: "column",
    overflowY: "auto"
  }, rest, {
    ref: ref,
    onScroll: handleWrapperScroll
  }), children);
});
Body.displayName = 'Body';
export default Body;