import React__default, { useState, useRef, useEffect } from 'react';
import { resizeObserver } from '@zenview/micro-utils';

function TableLayout({
  className = '',
  children,
  cutNum = 0,
  x = 1200
}) {
  const [height, setHeight] = useState(500);
  const domRef = useRef(null);
  useEffect(() => {
    const set = () => {
      var _domRef$current;
      const rect = (_domRef$current = domRef.current) === null || _domRef$current === void 0 ? void 0 : _domRef$current.getBoundingClientRect();
      if (rect) {
        setHeight(rect.height - cutNum);
      }
    };
    set();
    const dom = domRef.current;
    resizeObserver.createResizeObserver(dom, set);
    return () => {
      resizeObserver.unResizeObserver(dom);
    };
  }, [cutNum]);
  return /*#__PURE__*/React__default.createElement("div", {
    ref: domRef,
    className: `table-layout ${className}`
  }, /*#__PURE__*/React__default.cloneElement(children, {
    scroll: {
      x,
      y: height
    }
  }));
}

export { TableLayout as default };
//# sourceMappingURL=index.js.map
