MeasureCell.js 944 B

1234567891011121314151617181920212223242526272829303132
  1. import * as React from 'react';
  2. import ResizeObserver from 'rc-resize-observer';
  3. import useLayoutEffect from "rc-util/es/hooks/useLayoutEffect";
  4. export default function MeasureCell(_ref) {
  5. var columnKey = _ref.columnKey,
  6. onColumnResize = _ref.onColumnResize,
  7. column = _ref.column;
  8. var cellRef = React.useRef();
  9. useLayoutEffect(function () {
  10. if (cellRef.current) {
  11. onColumnResize(columnKey, cellRef.current.offsetWidth);
  12. }
  13. }, []);
  14. return /*#__PURE__*/React.createElement(ResizeObserver, {
  15. data: columnKey
  16. }, /*#__PURE__*/React.createElement("td", {
  17. ref: cellRef,
  18. style: {
  19. paddingTop: 0,
  20. paddingBottom: 0,
  21. borderTop: 0,
  22. borderBottom: 0,
  23. height: 0
  24. }
  25. }, /*#__PURE__*/React.createElement("div", {
  26. style: {
  27. height: 0,
  28. overflow: 'hidden',
  29. fontWeight: 'bold'
  30. }
  31. }, (column === null || column === void 0 ? void 0 : column.title) || '\xa0')));
  32. }