UNPKG

1.84 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4var _typeof = require("@babel/runtime/helpers/typeof");
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.default = MeasureCell;
9var React = _interopRequireWildcard(require("react"));
10var _rcResizeObserver = _interopRequireDefault(require("rc-resize-observer"));
11function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
12function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13function MeasureCell(_ref) {
14 var columnKey = _ref.columnKey,
15 onColumnResize = _ref.onColumnResize;
16 var cellRef = React.useRef();
17 React.useEffect(function () {
18 if (cellRef.current) {
19 onColumnResize(columnKey, cellRef.current.offsetWidth);
20 }
21 }, []);
22 return /*#__PURE__*/React.createElement(_rcResizeObserver.default, {
23 data: columnKey
24 }, /*#__PURE__*/React.createElement("td", {
25 ref: cellRef,
26 style: {
27 padding: 0,
28 border: 0,
29 height: 0
30 }
31 }, /*#__PURE__*/React.createElement("div", {
32 style: {
33 height: 0,
34 overflow: 'hidden'
35 }
36 }, "\xA0")));
37}
\No newline at end of file