react-base-table
Advanced tools
Comparing version 1.10.2 to 1.10.3
@@ -5,2 +5,7 @@ # CHANGELOG | ||
## v1.10.3 (2020-06-30) | ||
- fix: horizontal scrollbar in flex mode with dynamic row height | ||
- chore: tweak row height measurement | ||
## v1.10.2 (2020-06-26) | ||
@@ -7,0 +12,0 @@ |
@@ -91,3 +91,4 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; | ||
_this._handleColumnSort = _this._handleColumnSort.bind(_assertThisInitialized(_this)); | ||
_this._handleRowHeightMeasured = _this._handleRowHeightMeasured.bind(_assertThisInitialized(_this)); | ||
_this._handleFrozenRowHeightChange = _this._handleFrozenRowHeightChange.bind(_assertThisInitialized(_this)); | ||
_this._handleRowHeightChange = _this._handleRowHeightChange.bind(_assertThisInitialized(_this)); | ||
_this._getLeftTableContainerStyle = memoize(getContainerStyle); | ||
@@ -103,4 +104,2 @@ _this._getRightTableContainerStyle = memoize(getContainerStyle); | ||
if (_this.props.estimatedRowHeight && fixed) { | ||
_this.resetColumnWidthCache(false); | ||
if (!_this.columnManager.hasLeftFrozenColumns()) { | ||
@@ -124,20 +123,13 @@ _this._leftRowHeightMap = {}; | ||
_this._updateRowHeights = debounce(function () { | ||
if (Object.keys(_this._rowHeightMapBuffer).some(function (key) { | ||
return _this._rowHeightMapBuffer[key] !== _this._rowHeightMap[key]; | ||
})) { | ||
_this._isResetting = true; | ||
_this._rowHeightMap = _objectSpread({}, _this._rowHeightMap, {}, _this._rowHeightMapBuffer); | ||
_this._isResetting = true; | ||
_this._rowHeightMap = _objectSpread({}, _this._rowHeightMap, {}, _this._rowHeightMapBuffer); | ||
_this.resetAfterRowIndex(_this._resetIndex, false); | ||
_this.resetAfterRowIndex(_this._resetIndex, false); | ||
_this._rowHeightMapBuffer = {}; | ||
_this._resetIndex = null; | ||
_this._rowHeightMapBuffer = {}; | ||
_this._resetIndex = null; | ||
_this.forceUpdateTable(); | ||
_this.forceUpdateTable(); | ||
_this._isResetting = false; | ||
} else { | ||
_this._rowHeightMapBuffer = {}; | ||
_this._resetIndex = null; | ||
} | ||
_this._isResetting = false; | ||
}, 0); | ||
@@ -249,2 +241,3 @@ _this._scroll = { | ||
if (!this.props.estimatedRowHeight) return; | ||
this.table && this.table.resetAfterRowIndex(rowIndex, shouldForceUpdate); | ||
@@ -255,29 +248,2 @@ this.leftTable && this.leftTable.resetAfterRowIndex(rowIndex, shouldForceUpdate); | ||
/** | ||
* Reset cached column width, should be used only in dynamic mode(estimatedRowHeight is provided) | ||
*/ | ||
; | ||
_proto.resetColumnWidthCache = function resetColumnWidthCache(shouldForceUpdate) { | ||
if (shouldForceUpdate === void 0) { | ||
shouldForceUpdate = true; | ||
} | ||
this.table && this.table.resetAfterColumnIndex(0, shouldForceUpdate); | ||
this.leftTable && this.leftTable.resetAfterColumnIndex(0, shouldForceUpdate); | ||
this.rightTable && this.rightTable.resetAfterColumnIndex(0, shouldForceUpdate); | ||
} | ||
/** | ||
* Reset cached row heights, should be used only in dynamic mode(estimatedRowHeight is provided) | ||
*/ | ||
; | ||
_proto.resetRowHeightCache = function resetRowHeightCache() { | ||
this._resetIndex = null; | ||
this._rowHeightMap = {}; | ||
this._rowHeightMapBuffer = {}; | ||
this._mainRowHeightMap = {}; | ||
this._leftRowHeightMap = {}; | ||
this._rightRowHeightMap = {}; | ||
} | ||
/** | ||
* Scroll to the specified offset. | ||
@@ -422,2 +388,3 @@ * Useful for animating position changes. | ||
var className = cn(this._prefixClass('row'), rowClass, (_cn = {}, _cn[this._prefixClass("row--depth-" + depth)] = !!expandColumnKey && rowIndex >= 0, _cn[this._prefixClass('row--expanded')] = !!expandColumnKey && this.getExpandedRowKeys().indexOf(rowKey) >= 0, _cn[this._prefixClass('row--hovered')] = !isScrolling && rowKey === this.state.hoveredRowKey, _cn[this._prefixClass('row--frozen')] = depth === 0 && rowIndex < 0, _cn[this._prefixClass('row--customized')] = rowRenderer, _cn)); | ||
var hasFrozenColumns = this.columnManager.hasFrozenColumns(); | ||
@@ -445,4 +412,4 @@ var rowProps = _objectSpread({}, extraProps, { | ||
// for fixed table, we need to sync the hover state across the inner tables | ||
onRowHover: this.columnManager.hasFrozenColumns() ? this._handleRowHover : null, | ||
onRowHeightMeasured: this._handleRowHeightMeasured | ||
onRowHover: hasFrozenColumns ? this._handleRowHover : null, | ||
onRowHeightChange: hasFrozenColumns ? this._handleFrozenRowHeightChange : this._handleRowHeightChange | ||
}); | ||
@@ -862,3 +829,4 @@ | ||
if (this._data !== _data) { | ||
this.resetRowHeightCache(); | ||
this._resetRowHeightCache(); | ||
this._data = _data; | ||
@@ -1147,7 +1115,2 @@ } // should be after `this._data` assigned | ||
}); | ||
if (this.props.estimatedRowHeight && this.props.fixed) { | ||
this.resetColumnWidthCache(); | ||
} | ||
var column = this.columnManager.getColumn(key); | ||
@@ -1205,24 +1168,35 @@ this.props.onColumnResize({ | ||
_proto._handleRowHeightMeasured = function _handleRowHeightMeasured(rowKey, size, rowIndex, frozen) { | ||
if (this._resetIndex === null) this._resetIndex = rowIndex;else if (this._resetIndex > rowIndex) this._resetIndex = rowIndex; | ||
_proto._handleFrozenRowHeightChange = function _handleFrozenRowHeightChange(rowKey, size, rowIndex, frozen) { | ||
if (!frozen) { | ||
this._mainRowHeightMap[rowKey] = size; | ||
} else if (frozen === FrozenDirection.RIGHT) { | ||
this._rightRowHeightMap[rowKey] = size; | ||
} else { | ||
this._leftRowHeightMap[rowKey] = size; | ||
} | ||
if (this.columnManager.hasFrozenColumns()) { | ||
if (!frozen) { | ||
this._mainRowHeightMap[rowKey] = size; | ||
} else if (frozen === FrozenDirection.RIGHT) { | ||
this._rightRowHeightMap[rowKey] = size; | ||
} else { | ||
this._leftRowHeightMap[rowKey] = size; | ||
} | ||
var height = Math.max(this._mainRowHeightMap[rowKey] || 0, this._leftRowHeightMap[rowKey] || 0, this._rightRowHeightMap[rowKey] || 0); | ||
this._rowHeightMapBuffer[rowKey] = Math.max(this._mainRowHeightMap[rowKey] || 0, this._leftRowHeightMap[rowKey] || 0, this._rightRowHeightMap[rowKey] || 0); | ||
} else { | ||
if (!this._rowHeightMap[rowKey] || this._rowHeightMap[rowKey] !== size) { | ||
this._rowHeightMapBuffer[rowKey] = size; | ||
} | ||
if (this._rowHeightMap[rowKey] !== height) { | ||
this._handleRowHeightChange(rowKey, height, rowIndex); | ||
} | ||
}; | ||
_proto._handleRowHeightChange = function _handleRowHeightChange(rowKey, size, rowIndex) { | ||
if (this._resetIndex === null) this._resetIndex = rowIndex;else if (this._resetIndex > rowIndex) this._resetIndex = rowIndex; | ||
this._rowHeightMapBuffer[rowKey] = size; | ||
this._updateRowHeights(); | ||
}; | ||
_proto._resetRowHeightCache = function _resetRowHeightCache() { | ||
if (!this.props.estimatedRowHeight) return; | ||
this._resetIndex = null; | ||
this._rowHeightMapBuffer = {}; | ||
this._rowHeightMap = {}; | ||
this._mainRowHeightMap = {}; | ||
this._leftRowHeightMap = {}; | ||
this._rightRowHeightMap = {}; | ||
}; | ||
return BaseTable; | ||
@@ -1229,0 +1203,0 @@ }(React.PureComponent); |
@@ -15,2 +15,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
import { FixedSizeGrid, VariableSizeGrid } from 'react-window'; | ||
import memoize from 'memoize-one'; | ||
import Header from './TableHeader'; | ||
@@ -36,2 +37,6 @@ /** | ||
_this._handleItemsRendered = _this._handleItemsRendered.bind(_assertThisInitialized(_this)); | ||
_this._resetColumnWidthCache = memoize(function (bodyWidth) { | ||
if (!_this.props.estimatedRowHeight) return; | ||
_this.bodyRef && _this.bodyRef.resetAfterColumnIndex(0, false); | ||
}); | ||
_this.renderRow = _this.renderRow.bind(_assertThisInitialized(_this)); | ||
@@ -52,11 +57,2 @@ return _this; | ||
_proto.resetAfterColumnIndex = function resetAfterColumnIndex(columnIndex, shouldForceUpdate) { | ||
if (columnIndex === void 0) { | ||
columnIndex = 0; | ||
} | ||
if (!this.props.estimatedRowHeight) return; | ||
this.bodyRef && this.bodyRef.resetAfterColumnIndex(columnIndex, shouldForceUpdate); | ||
}; | ||
_proto.forceUpdateTable = function forceUpdateTable() { | ||
@@ -156,2 +152,5 @@ this.headerRef && this.headerRef.forceUpdate(); | ||
var Grid = estimatedRowHeight ? VariableSizeGrid : FixedSizeGrid; | ||
this._resetColumnWidthCache(bodyWidth); | ||
return React.createElement("div", _extends({ | ||
@@ -158,0 +157,0 @@ role: "table", |
@@ -26,3 +26,2 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
_this._handleExpand = _this._handleExpand.bind(_assertThisInitialized(_this)); | ||
_this._measureHeight = _this._measureHeight.bind(_assertThisInitialized(_this)); | ||
return _this; | ||
@@ -34,6 +33,8 @@ } | ||
_proto.componentDidMount = function componentDidMount() { | ||
this.props.estimatedRowHeight && this.props.rowIndex >= 0 && this._measureHeight(); | ||
this.props.estimatedRowHeight && this.props.rowIndex >= 0 && this._measureHeight(true); | ||
}; | ||
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) { | ||
var _this2 = this; | ||
if (this.props.estimatedRowHeight && this.props.rowIndex >= 0 && // should not re-measure if it's updated after measured and reset | ||
@@ -43,3 +44,5 @@ !this.props.getIsResetting() && this.state.measured && prevState.measured) { | ||
measured: false | ||
}, this._measureHeight); | ||
}, function () { | ||
return _this2._measureHeight(); | ||
}); | ||
} | ||
@@ -69,4 +72,4 @@ }; | ||
onRowExpand = _this$props.onRowExpand, | ||
onRowHeightMeasured = _this$props.onRowHeightMeasured, | ||
rest = _objectWithoutPropertiesLoose(_this$props, ["isScrolling", "className", "style", "columns", "rowIndex", "rowData", "expandColumnKey", "depth", "rowEventHandlers", "estimatedRowHeight", "rowRenderer", "cellRenderer", "expandIconRenderer", "tagName", "rowKey", "getIsResetting", "onRowHover", "onRowExpand", "onRowHeightMeasured"]); | ||
onRowHeightChange = _this$props.onRowHeightChange, | ||
rest = _objectWithoutPropertiesLoose(_this$props, ["isScrolling", "className", "style", "columns", "rowIndex", "rowData", "expandColumnKey", "depth", "rowEventHandlers", "estimatedRowHeight", "rowRenderer", "cellRenderer", "expandIconRenderer", "tagName", "rowKey", "getIsResetting", "onRowHover", "onRowExpand", "onRowHeightChange"]); | ||
/* eslint-enable no-unused-vars */ | ||
@@ -141,16 +144,16 @@ | ||
_proto._measureHeight = function _measureHeight() { | ||
if (this.ref) { | ||
var _this$props3 = this.props, | ||
rowKey = _this$props3.rowKey, | ||
onRowHeightMeasured = _this$props3.onRowHeightMeasured, | ||
rowIndex = _this$props3.rowIndex, | ||
columns = _this$props3.columns; | ||
var height = this.ref.getBoundingClientRect().height; | ||
this.setState({ | ||
measured: true | ||
}, function () { | ||
onRowHeightMeasured(rowKey, height, rowIndex, columns[0] && !columns[0].__placeholder__ && columns[0].frozen); | ||
}); | ||
} | ||
_proto._measureHeight = function _measureHeight(initialMeasure) { | ||
if (!this.ref) return; | ||
var _this$props3 = this.props, | ||
style = _this$props3.style, | ||
rowKey = _this$props3.rowKey, | ||
onRowHeightChange = _this$props3.onRowHeightChange, | ||
rowIndex = _this$props3.rowIndex, | ||
columns = _this$props3.columns; | ||
var height = this.ref.getBoundingClientRect().height; | ||
this.setState({ | ||
measured: true | ||
}, function () { | ||
if (initialMeasure || height !== style.height) onRowHeightChange(rowKey, height, rowIndex, columns[0] && !columns[0].__placeholder__ && columns[0].frozen); | ||
}); | ||
}; | ||
@@ -239,3 +242,3 @@ | ||
onRowExpand: PropTypes.func, | ||
onRowHeightMeasured: PropTypes.func, | ||
onRowHeightChange: PropTypes.func, | ||
tagName: PropTypes.elementType | ||
@@ -242,0 +245,0 @@ }; |
@@ -131,3 +131,4 @@ "use strict"; | ||
_this._handleColumnSort = _this._handleColumnSort.bind((0, _assertThisInitialized2["default"])(_this)); | ||
_this._handleRowHeightMeasured = _this._handleRowHeightMeasured.bind((0, _assertThisInitialized2["default"])(_this)); | ||
_this._handleFrozenRowHeightChange = _this._handleFrozenRowHeightChange.bind((0, _assertThisInitialized2["default"])(_this)); | ||
_this._handleRowHeightChange = _this._handleRowHeightChange.bind((0, _assertThisInitialized2["default"])(_this)); | ||
_this._getLeftTableContainerStyle = (0, _memoizeOne["default"])(getContainerStyle); | ||
@@ -143,4 +144,2 @@ _this._getRightTableContainerStyle = (0, _memoizeOne["default"])(getContainerStyle); | ||
if (_this.props.estimatedRowHeight && fixed) { | ||
_this.resetColumnWidthCache(false); | ||
if (!_this.columnManager.hasLeftFrozenColumns()) { | ||
@@ -164,20 +163,13 @@ _this._leftRowHeightMap = {}; | ||
_this._updateRowHeights = (0, _utils.debounce)(function () { | ||
if (Object.keys(_this._rowHeightMapBuffer).some(function (key) { | ||
return _this._rowHeightMapBuffer[key] !== _this._rowHeightMap[key]; | ||
})) { | ||
_this._isResetting = true; | ||
_this._rowHeightMap = _objectSpread({}, _this._rowHeightMap, {}, _this._rowHeightMapBuffer); | ||
_this._isResetting = true; | ||
_this._rowHeightMap = _objectSpread({}, _this._rowHeightMap, {}, _this._rowHeightMapBuffer); | ||
_this.resetAfterRowIndex(_this._resetIndex, false); | ||
_this.resetAfterRowIndex(_this._resetIndex, false); | ||
_this._rowHeightMapBuffer = {}; | ||
_this._resetIndex = null; | ||
_this._rowHeightMapBuffer = {}; | ||
_this._resetIndex = null; | ||
_this.forceUpdateTable(); | ||
_this.forceUpdateTable(); | ||
_this._isResetting = false; | ||
} else { | ||
_this._rowHeightMapBuffer = {}; | ||
_this._resetIndex = null; | ||
} | ||
_this._isResetting = false; | ||
}, 0); | ||
@@ -290,2 +282,3 @@ _this._scroll = { | ||
var shouldForceUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
if (!this.props.estimatedRowHeight) return; | ||
this.table && this.table.resetAfterRowIndex(rowIndex, shouldForceUpdate); | ||
@@ -296,28 +289,2 @@ this.leftTable && this.leftTable.resetAfterRowIndex(rowIndex, shouldForceUpdate); | ||
/** | ||
* Reset cached column width, should be used only in dynamic mode(estimatedRowHeight is provided) | ||
*/ | ||
}, { | ||
key: "resetColumnWidthCache", | ||
value: function resetColumnWidthCache() { | ||
var shouldForceUpdate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; | ||
this.table && this.table.resetAfterColumnIndex(0, shouldForceUpdate); | ||
this.leftTable && this.leftTable.resetAfterColumnIndex(0, shouldForceUpdate); | ||
this.rightTable && this.rightTable.resetAfterColumnIndex(0, shouldForceUpdate); | ||
} | ||
/** | ||
* Reset cached row heights, should be used only in dynamic mode(estimatedRowHeight is provided) | ||
*/ | ||
}, { | ||
key: "resetRowHeightCache", | ||
value: function resetRowHeightCache() { | ||
this._resetIndex = null; | ||
this._rowHeightMap = {}; | ||
this._rowHeightMapBuffer = {}; | ||
this._mainRowHeightMap = {}; | ||
this._leftRowHeightMap = {}; | ||
this._rightRowHeightMap = {}; | ||
} | ||
/** | ||
* Scroll to the specified offset. | ||
@@ -463,2 +430,3 @@ * Useful for animating position changes. | ||
var className = (0, _classnames["default"])(this._prefixClass('row'), rowClass, (_cn = {}, (0, _defineProperty2["default"])(_cn, this._prefixClass("row--depth-".concat(depth)), !!expandColumnKey && rowIndex >= 0), (0, _defineProperty2["default"])(_cn, this._prefixClass('row--expanded'), !!expandColumnKey && this.getExpandedRowKeys().indexOf(rowKey) >= 0), (0, _defineProperty2["default"])(_cn, this._prefixClass('row--hovered'), !isScrolling && rowKey === this.state.hoveredRowKey), (0, _defineProperty2["default"])(_cn, this._prefixClass('row--frozen'), depth === 0 && rowIndex < 0), (0, _defineProperty2["default"])(_cn, this._prefixClass('row--customized'), rowRenderer), _cn)); | ||
var hasFrozenColumns = this.columnManager.hasFrozenColumns(); | ||
@@ -486,4 +454,4 @@ var rowProps = _objectSpread({}, extraProps, { | ||
// for fixed table, we need to sync the hover state across the inner tables | ||
onRowHover: this.columnManager.hasFrozenColumns() ? this._handleRowHover : null, | ||
onRowHeightMeasured: this._handleRowHeightMeasured | ||
onRowHover: hasFrozenColumns ? this._handleRowHover : null, | ||
onRowHeightChange: hasFrozenColumns ? this._handleFrozenRowHeightChange : this._handleRowHeightChange | ||
}); | ||
@@ -912,3 +880,4 @@ | ||
if (this._data !== _data) { | ||
this.resetRowHeightCache(); | ||
this._resetRowHeightCache(); | ||
this._data = _data; | ||
@@ -1221,7 +1190,2 @@ } // should be after `this._data` assigned | ||
}); | ||
if (this.props.estimatedRowHeight && this.props.fixed) { | ||
this.resetColumnWidthCache(); | ||
} | ||
var column = this.columnManager.getColumn(key); | ||
@@ -1282,24 +1246,37 @@ this.props.onColumnResize({ | ||
}, { | ||
key: "_handleRowHeightMeasured", | ||
value: function _handleRowHeightMeasured(rowKey, size, rowIndex, frozen) { | ||
if (this._resetIndex === null) this._resetIndex = rowIndex;else if (this._resetIndex > rowIndex) this._resetIndex = rowIndex; | ||
key: "_handleFrozenRowHeightChange", | ||
value: function _handleFrozenRowHeightChange(rowKey, size, rowIndex, frozen) { | ||
if (!frozen) { | ||
this._mainRowHeightMap[rowKey] = size; | ||
} else if (frozen === _Column.FrozenDirection.RIGHT) { | ||
this._rightRowHeightMap[rowKey] = size; | ||
} else { | ||
this._leftRowHeightMap[rowKey] = size; | ||
} | ||
if (this.columnManager.hasFrozenColumns()) { | ||
if (!frozen) { | ||
this._mainRowHeightMap[rowKey] = size; | ||
} else if (frozen === _Column.FrozenDirection.RIGHT) { | ||
this._rightRowHeightMap[rowKey] = size; | ||
} else { | ||
this._leftRowHeightMap[rowKey] = size; | ||
} | ||
var height = Math.max(this._mainRowHeightMap[rowKey] || 0, this._leftRowHeightMap[rowKey] || 0, this._rightRowHeightMap[rowKey] || 0); | ||
this._rowHeightMapBuffer[rowKey] = Math.max(this._mainRowHeightMap[rowKey] || 0, this._leftRowHeightMap[rowKey] || 0, this._rightRowHeightMap[rowKey] || 0); | ||
} else { | ||
if (!this._rowHeightMap[rowKey] || this._rowHeightMap[rowKey] !== size) { | ||
this._rowHeightMapBuffer[rowKey] = size; | ||
} | ||
if (this._rowHeightMap[rowKey] !== height) { | ||
this._handleRowHeightChange(rowKey, height, rowIndex); | ||
} | ||
} | ||
}, { | ||
key: "_handleRowHeightChange", | ||
value: function _handleRowHeightChange(rowKey, size, rowIndex) { | ||
if (this._resetIndex === null) this._resetIndex = rowIndex;else if (this._resetIndex > rowIndex) this._resetIndex = rowIndex; | ||
this._rowHeightMapBuffer[rowKey] = size; | ||
this._updateRowHeights(); | ||
} | ||
}, { | ||
key: "_resetRowHeightCache", | ||
value: function _resetRowHeightCache() { | ||
if (!this.props.estimatedRowHeight) return; | ||
this._resetIndex = null; | ||
this._rowHeightMapBuffer = {}; | ||
this._rowHeightMap = {}; | ||
this._mainRowHeightMap = {}; | ||
this._leftRowHeightMap = {}; | ||
this._rightRowHeightMap = {}; | ||
} | ||
}]); | ||
@@ -1306,0 +1283,0 @@ return BaseTable; |
@@ -36,2 +36,4 @@ "use strict"; | ||
var _memoizeOne = _interopRequireDefault(require("memoize-one")); | ||
var _TableHeader = _interopRequireDefault(require("./TableHeader")); | ||
@@ -62,2 +64,6 @@ | ||
_this._handleItemsRendered = _this._handleItemsRendered.bind((0, _assertThisInitialized2["default"])(_this)); | ||
_this._resetColumnWidthCache = (0, _memoizeOne["default"])(function (bodyWidth) { | ||
if (!_this.props.estimatedRowHeight) return; | ||
_this.bodyRef && _this.bodyRef.resetAfterColumnIndex(0, false); | ||
}); | ||
_this.renderRow = _this.renderRow.bind((0, _assertThisInitialized2["default"])(_this)); | ||
@@ -76,10 +82,2 @@ return _this; | ||
}, { | ||
key: "resetAfterColumnIndex", | ||
value: function resetAfterColumnIndex() { | ||
var columnIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
var shouldForceUpdate = arguments.length > 1 ? arguments[1] : undefined; | ||
if (!this.props.estimatedRowHeight) return; | ||
this.bodyRef && this.bodyRef.resetAfterColumnIndex(columnIndex, shouldForceUpdate); | ||
} | ||
}, { | ||
key: "forceUpdateTable", | ||
@@ -181,2 +179,5 @@ value: function forceUpdateTable() { | ||
var Grid = estimatedRowHeight ? _reactWindow.VariableSizeGrid : _reactWindow.FixedSizeGrid; | ||
this._resetColumnWidthCache(bodyWidth); | ||
return _react["default"].createElement("div", (0, _extends2["default"])({ | ||
@@ -183,0 +184,0 @@ role: "table", |
@@ -50,3 +50,2 @@ "use strict"; | ||
_this._handleExpand = _this._handleExpand.bind((0, _assertThisInitialized2["default"])(_this)); | ||
_this._measureHeight = _this._measureHeight.bind((0, _assertThisInitialized2["default"])(_this)); | ||
return _this; | ||
@@ -58,3 +57,3 @@ } | ||
value: function componentDidMount() { | ||
this.props.estimatedRowHeight && this.props.rowIndex >= 0 && this._measureHeight(); | ||
this.props.estimatedRowHeight && this.props.rowIndex >= 0 && this._measureHeight(true); | ||
} | ||
@@ -64,2 +63,4 @@ }, { | ||
value: function componentDidUpdate(prevProps, prevState) { | ||
var _this2 = this; | ||
if (this.props.estimatedRowHeight && this.props.rowIndex >= 0 && // should not re-measure if it's updated after measured and reset | ||
@@ -69,3 +70,5 @@ !this.props.getIsResetting() && this.state.measured && prevState.measured) { | ||
measured: false | ||
}, this._measureHeight); | ||
}, function () { | ||
return _this2._measureHeight(); | ||
}); | ||
} | ||
@@ -96,4 +99,4 @@ } | ||
onRowExpand = _this$props.onRowExpand, | ||
onRowHeightMeasured = _this$props.onRowHeightMeasured, | ||
rest = (0, _objectWithoutProperties2["default"])(_this$props, ["isScrolling", "className", "style", "columns", "rowIndex", "rowData", "expandColumnKey", "depth", "rowEventHandlers", "estimatedRowHeight", "rowRenderer", "cellRenderer", "expandIconRenderer", "tagName", "rowKey", "getIsResetting", "onRowHover", "onRowExpand", "onRowHeightMeasured"]); | ||
onRowHeightChange = _this$props.onRowHeightChange, | ||
rest = (0, _objectWithoutProperties2["default"])(_this$props, ["isScrolling", "className", "style", "columns", "rowIndex", "rowData", "expandColumnKey", "depth", "rowEventHandlers", "estimatedRowHeight", "rowRenderer", "cellRenderer", "expandIconRenderer", "tagName", "rowKey", "getIsResetting", "onRowHover", "onRowExpand", "onRowHeightChange"]); | ||
/* eslint-enable no-unused-vars */ | ||
@@ -169,16 +172,16 @@ | ||
key: "_measureHeight", | ||
value: function _measureHeight() { | ||
if (this.ref) { | ||
var _this$props3 = this.props, | ||
rowKey = _this$props3.rowKey, | ||
onRowHeightMeasured = _this$props3.onRowHeightMeasured, | ||
rowIndex = _this$props3.rowIndex, | ||
columns = _this$props3.columns; | ||
var height = this.ref.getBoundingClientRect().height; | ||
this.setState({ | ||
measured: true | ||
}, function () { | ||
onRowHeightMeasured(rowKey, height, rowIndex, columns[0] && !columns[0].__placeholder__ && columns[0].frozen); | ||
}); | ||
} | ||
value: function _measureHeight(initialMeasure) { | ||
if (!this.ref) return; | ||
var _this$props3 = this.props, | ||
style = _this$props3.style, | ||
rowKey = _this$props3.rowKey, | ||
onRowHeightChange = _this$props3.onRowHeightChange, | ||
rowIndex = _this$props3.rowIndex, | ||
columns = _this$props3.columns; | ||
var height = this.ref.getBoundingClientRect().height; | ||
this.setState({ | ||
measured: true | ||
}, function () { | ||
if (initialMeasure || height !== style.height) onRowHeightChange(rowKey, height, rowIndex, columns[0] && !columns[0].__placeholder__ && columns[0].frozen); | ||
}); | ||
} | ||
@@ -265,3 +268,3 @@ }, { | ||
onRowExpand: _propTypes["default"].func, | ||
onRowHeightMeasured: _propTypes["default"].func, | ||
onRowHeightChange: _propTypes["default"].func, | ||
tagName: _propTypes["default"].elementType | ||
@@ -268,0 +271,0 @@ }; |
{ | ||
"name": "react-base-table", | ||
"version": "1.10.2", | ||
"version": "1.10.3", | ||
"description": "a react table component to display large data set with high performance and flexibility", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
894820
6798