function ArrowKeyStepper(props, context) { _classCallCheck(this, ArrowKeyStepper); var _this = _possibleConstructorReturn(this, (ArrowKeyStepper.__proto__ || Object.getPrototypeOf(ArrowKeyStepper)).call(this, props, context)); _this.state = { scrollToColumn: props.scrollToColumn, scrollToRow: props.scrollToRow }; _this._columnStartIndex = 0; _this._columnStopIndex = 0; _this._rowStartIndex = 0; _this._rowStopIndex = 0; _this._onKeyDown = _this._onKeyDown.bind(_this); _this._onSectionRendered = _this._onSectionRendered.bind(_this); return _this; }
n/a
function AutoSizer(props) { _classCallCheck(this, AutoSizer); var _this = _possibleConstructorReturn(this, (AutoSizer.__proto__ || Object.getPrototypeOf(AutoSizer)).call(this, props)); _this.state = { height: 0, width: 0 }; _this._onResize = _this._onResize.bind(_this); _this._setRef = _this._setRef.bind(_this); return _this; }
n/a
function CellMeasurer(props, context) { _classCallCheck(this, CellMeasurer); var _this = _possibleConstructorReturn(this, (CellMeasurer.__proto__ || Object.getPrototypeOf(CellMeasurer)).call(this, props, context)); _this._measure = _this._measure.bind(_this); return _this; }
n/a
function CellMeasurerCache() { var _this = this; var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, CellMeasurerCache); this.columnWidth = function (_ref) { var index = _ref.index; var key = _this._keyMapper(0, index); return _this._columnWidthCache.hasOwnProperty(key) ? _this._columnWidthCache[key] : _this._defaultWidth; }; this.rowHeight = function (_ref2) { var index = _ref2.index; var key = _this._keyMapper(index, 0); return _this._rowHeightCache.hasOwnProperty(key) ? _this._rowHeightCache[key] : _this._defaultHeight; }; var defaultHeight = params.defaultHeight, defaultWidth = params.defaultWidth, fixedHeight = params.fixedHeight, fixedWidth = params.fixedWidth, keyMapper = params.keyMapper, minHeight = params.minHeight, minWidth = params.minWidth; this._hasFixedHeight = fixedHeight === true; this._hasFixedWidth = fixedWidth === true; this._minHeight = minHeight || 0; this._minWidth = minWidth || 0; this._keyMapper = keyMapper || defaultKeyMapper; this._defaultHeight = Math.max(this._minHeight, typeof defaultHeight === 'number' ? defaultHeight : DEFAULT_HEIGHT); this._defaultWidth = Math.max(this._minWidth, typeof defaultWidth === 'number' ? defaultWidth : DEFAULT_WIDTH); if (process.env.NODE_ENV !== 'production') { if (this._hasFixedHeight === false && this._hasFixedWidth === false) { console.warn('CellMeasurerCache should only measure a cell\'s width or height. ' + 'You have configured CellMeasurerCache to measure both. ' + 'This will result in poor performance.'); } if (this._hasFixedHeight === false && this._defaultHeight === 0) { console.warn('Fixed height CellMeasurerCache should specify a :defaultHeight greater than 0. ' + 'Failing to do so will lead to unnecessary layout and poor performance.'); } if (this._hasFixedWidth === false && this._defaultWidth === 0) { console.warn('Fixed width CellMeasurerCache should specify a :defaultWidth greater than 0. ' + 'Failing to do so will lead to unnecessary layout and poor performance.'); } } this._columnCount = 0; this._rowCount = 0; this._cellHeightCache = {}; this._cellWidthCache = {}; this._columnWidthCache = {}; this._rowHeightCache = {}; }
...
var secondProps = cellRendererCalls[2];
expect(cellRendererCalls.length).toEqual(3);
expect(firstProps.style).not.toBe(secondProps.style);
});
it('should only cache styles when a :deferredMeasurementCache is provided if the cell has already been measured', function
() {
var cache = new _CellMeasurer.CellMeasurerCache({
fixedWidth: true
});
cache.set(0, 0, 100, 100);
cache.set(1, 1, 100, 100);
var grid = (0, _TestUtils.render)(getMarkup({
columnCount: 2,
...
function Collection(props, context) { _classCallCheck(this, Collection); var _this = _possibleConstructorReturn(this, (Collection.__proto__ || Object.getPrototypeOf(Collection)).call(this, props, context )); _this._cellMetadata = []; _this._lastRenderedCellIndices = []; // Cell cache during scroll (for perforamnce) _this._cellCache = []; _this._isScrollingChange = _this._isScrollingChange.bind(_this); _this._setCollectionViewRef = _this._setCollectionViewRef.bind(_this); return _this; }
n/a
function Column() { _classCallCheck(this, Column); return _possibleConstructorReturn(this, (Column.__proto__ || Object.getPrototypeOf(Column)).apply(this, arguments)); }
n/a
function ColumnSizer(props, context) { _classCallCheck(this, ColumnSizer); var _this = _possibleConstructorReturn(this, (ColumnSizer.__proto__ || Object.getPrototypeOf(ColumnSizer)).call(this, props, context )); _this._registerChild = _this._registerChild.bind(_this); return _this; }
n/a
function Grid(props, context) { _classCallCheck(this, Grid); var _this = _possibleConstructorReturn(this, (Grid.__proto__ || Object.getPrototypeOf(Grid)).call(this, props, context)); _this.state = { isScrolling: false, scrollDirectionHorizontal: _defaultOverscanIndicesGetter.SCROLL_DIRECTION_FORWARD, scrollDirectionVertical: _defaultOverscanIndicesGetter.SCROLL_DIRECTION_FORWARD, scrollLeft: 0, scrollTop: 0 }; // Invokes onSectionRendered callback only when start/stop row or column indices change _this._onGridRenderedMemoizer = (0, _createCallbackMemoizer2.default)(); _this._onScrollMemoizer = (0, _createCallbackMemoizer2.default)(false); // Bind functions to instance so they don't lose context when passed around _this._debounceScrollEndedCallback = _this._debounceScrollEndedCallback.bind(_this); _this._invokeOnGridRenderedHelper = _this._invokeOnGridRenderedHelper.bind(_this); _this._onScroll = _this._onScroll.bind(_this); _this._setScrollingContainerRef = _this._setScrollingContainerRef.bind(_this); _this._columnWidthGetter = _this._wrapSizeGetter(props.columnWidth); _this._rowHeightGetter = _this._wrapSizeGetter(props.rowHeight); _this._deferredInvalidateColumnIndex = null; _this._deferredInvalidateRowIndex = null; _this._recomputeScrollLeftFlag = false; _this._recomputeScrollTopFlag = false; var deferredMeasurementCache = props.deferredMeasurementCache; var deferredMode = typeof deferredMeasurementCache !== 'undefined'; _this._columnSizeAndPositionManager = new _ScalingCellSizeAndPositionManager2.default({ batchAllCells: deferredMode && !deferredMeasurementCache.hasFixedHeight(), cellCount: props.columnCount, cellSizeGetter: function cellSizeGetter(params) { return _this._columnWidthGetter(params); }, estimatedCellSize: _this._getEstimatedColumnSize(props) }); _this._rowSizeAndPositionManager = new _ScalingCellSizeAndPositionManager2.default({ batchAllCells: deferredMode && !deferredMeasurementCache.hasFixedWidth(), cellCount: props.rowCount, cellSizeGetter: function cellSizeGetter(params) { return _this._rowHeightGetter(params); }, estimatedCellSize: _this._getEstimatedRowSize(props) }); // See defaultCellRangeRenderer() for more information on the usage of these caches _this._cellCache = {}; _this._styleCache = {}; return _this; }
n/a
function InfiniteLoader(props, context) { _classCallCheck(this, InfiniteLoader); var _this = _possibleConstructorReturn(this, (InfiniteLoader.__proto__ || Object.getPrototypeOf(InfiniteLoader)).call(this, props , context)); _this._loadMoreRowsMemoizer = (0, _createCallbackMemoizer2.default)(); _this._onRowsRendered = _this._onRowsRendered.bind(_this); _this._registerChild = _this._registerChild.bind(_this); return _this; }
n/a
function List(props, context) { _classCallCheck(this, List); var _this = _possibleConstructorReturn(this, (List.__proto__ || Object.getPrototypeOf(List)).call(this, props, context)); _this._cellRenderer = _this._cellRenderer.bind(_this); _this._onScroll = _this._onScroll.bind(_this); _this._onSectionRendered = _this._onSectionRendered.bind(_this); _this._setRef = _this._setRef.bind(_this); return _this; }
n/a
function Masonry(props, context) { _classCallCheck(this, Masonry); var _this = _possibleConstructorReturn(this, (Masonry.__proto__ || Object.getPrototypeOf(Masonry)).call(this, props, context)); _this._invalidateOnUpdateStartIndex = null; _this._invalidateOnUpdateStopIndex = null; _this._positionCache = new _PositionCache2.default(); _this._startIndex = null; _this._startIndexMemoized = null; _this._stopIndex = null; _this._stopIndexMemoized = null; _this.state = { isScrolling: false, scrollTop: 0 }; _this._debounceResetIsScrollingCallback = _this._debounceResetIsScrollingCallback.bind(_this); _this._setScrollingContainerRef = _this._setScrollingContainerRef.bind(_this); _this._onScroll = _this._onScroll.bind(_this); return _this; }
n/a
function MultiGrid(props, context) { _classCallCheck(this, MultiGrid); var _this = _possibleConstructorReturn(this, (MultiGrid.__proto__ || Object.getPrototypeOf(MultiGrid)).call(this, props, context )); _this.state = { scrollLeft: 0, scrollTop: 0 }; _this._deferredInvalidateColumnIndex = null; _this._deferredInvalidateRowIndex = null; _this._bottomLeftGridRef = _this._bottomLeftGridRef.bind(_this); _this._bottomRightGridRef = _this._bottomRightGridRef.bind(_this); _this._cellRendererBottomLeftGrid = _this._cellRendererBottomLeftGrid.bind(_this); _this._cellRendererBottomRightGrid = _this._cellRendererBottomRightGrid.bind(_this); _this._cellRendererTopRightGrid = _this._cellRendererTopRightGrid.bind(_this); _this._columnWidthRightGrid = _this._columnWidthRightGrid.bind(_this); _this._onScroll = _this._onScroll.bind(_this); _this._rowHeightBottomGrid = _this._rowHeightBottomGrid.bind(_this); _this._topLeftGridRef = _this._topLeftGridRef.bind(_this); _this._topRightGridRef = _this._topRightGridRef.bind(_this); return _this; }
n/a
function ScrollSync(props, context) { _classCallCheck(this, ScrollSync); var _this = _possibleConstructorReturn(this, (ScrollSync.__proto__ || Object.getPrototypeOf(ScrollSync)).call(this, props, context )); _this.state = { clientHeight: 0, clientWidth: 0, scrollHeight: 0, scrollLeft: 0, scrollTop: 0, scrollWidth: 0 }; _this._onScroll = _this._onScroll.bind(_this); return _this; }
n/a
function SortIndicator(_ref) { var sortDirection = _ref.sortDirection; var classNames = (0, _classnames2.default)('ReactVirtualized__Table__sortableHeaderIcon', { 'ReactVirtualized__Table__sortableHeaderIcon--ASC': sortDirection === _SortDirection2.default.ASC, 'ReactVirtualized__Table__sortableHeaderIcon--DESC': sortDirection === _SortDirection2.default.DESC }); return _react2.default.createElement( 'svg', { className: classNames, width: 18, height: 18, viewBox: '0 0 24 24' }, sortDirection === _SortDirection2.default.ASC ? _react2.default.createElement('path', { d: 'M7 14l5-5 5 5z' }) : _react2.default .createElement('path', { d: 'M7 10l5 5 5-5z' }), _react2.default.createElement('path', { d: 'M0 0h24v24H0z', fill: 'none' }) ); }
n/a
function Table(props) { _classCallCheck(this, Table); var _this = _possibleConstructorReturn(this, (Table.__proto__ || Object.getPrototypeOf(Table)).call(this, props)); _this.state = { scrollbarWidth: 0 }; _this._createColumn = _this._createColumn.bind(_this); _this._createRow = _this._createRow.bind(_this); _this._onScroll = _this._onScroll.bind(_this); _this._onSectionRendered = _this._onSectionRendered.bind(_this); _this._setRef = _this._setRef.bind(_this); return _this; }
n/a
function WindowScroller(props) { _classCallCheck(this, WindowScroller); // Handle server-side rendering case var _this = _possibleConstructorReturn(this, (WindowScroller.__proto__ || Object.getPrototypeOf(WindowScroller)).call(this, props )); var _ref = typeof window !== 'undefined' ? (0, _dimensions.getDimensions)(props.scrollElement || window) : { width: 0, height: 0 }, width = _ref.width, height = _ref.height; _this.state = { height: height, width: width, isScrolling: false, scrollLeft: 0, scrollTop: 0 }; _this._onResize = _this._onResize.bind(_this); _this.__handleWindowScrollEvent = _this.__handleWindowScrollEvent.bind(_this); _this.__resetIsScrolling = _this.__resetIsScrolling.bind(_this); return _this; }
n/a
function defaultOverscanIndicesGetter(_ref) { var direction = _ref.direction, cellCount = _ref.cellCount, overscanCellsCount = _ref.overscanCellsCount, scrollDirection = _ref.scrollDirection, startIndex = _ref.startIndex, stopIndex = _ref.stopIndex; var overscanStartIndex = void 0; var overscanStopIndex = void 0; // Make sure we render at least 1 cell extra before and after (except near boundaries) // This is necessary in order to support keyboard navigation (TAB/SHIFT+TAB) in some cases // For more info see issues #625 overscanCellsCount = Math.max(1, overscanCellsCount); switch (scrollDirection) { case SCROLL_DIRECTION_FORWARD: overscanStartIndex = startIndex - 1; overscanStopIndex = stopIndex + overscanCellsCount; break; case SCROLL_DIRECTION_BACKWARD: overscanStartIndex = startIndex - overscanCellsCount; overscanStopIndex = stopIndex + 1; break; } return { overscanStartIndex: Math.max(0, overscanStartIndex), overscanStopIndex: Math.min(cellCount - 1, overscanStopIndex) }; }
n/a
function createCellPositioner(_ref) { var cellMeasurerCache = _ref.cellMeasurerCache, columnCount = _ref.columnCount, columnWidth = _ref.columnWidth, _ref$spacer = _ref.spacer, spacer = _ref$spacer === undefined ? 0 : _ref$spacer; var columnHeights = void 0; initOrResetDerivedValues(); function cellPositioner(index) { // Find the shortest column and use it. var columnIndex = 0; for (var i = 1; i < columnHeights.length; i++) { if (columnHeights[i] < columnHeights[columnIndex]) { columnIndex = i; } } var left = columnIndex * (columnWidth + spacer); var top = columnHeights[columnIndex] || 0; columnHeights[columnIndex] = top + cellMeasurerCache.getHeight(index) + spacer; return { left: left, top: top }; } function initOrResetDerivedValues() { // Track the height of each column. // Layout algorithm below always inserts into the shortest column. columnHeights = []; for (var i = 0; i < columnCount; i++) { columnHeights[i] = 0; } } function reset(params) { columnCount = params.columnCount; columnWidth = params.columnWidth; spacer = params.spacer; initOrResetDerivedValues(); } cellPositioner.reset = reset; return cellPositioner; }
n/a
function defaultCellRangeRenderer(_ref) { var cellCache = _ref.cellCache, cellRenderer = _ref.cellRenderer, columnSizeAndPositionManager = _ref.columnSizeAndPositionManager, columnStartIndex = _ref.columnStartIndex, columnStopIndex = _ref.columnStopIndex, deferredMeasurementCache = _ref.deferredMeasurementCache, horizontalOffsetAdjustment = _ref.horizontalOffsetAdjustment, isScrolling = _ref.isScrolling, parent = _ref.parent, rowSizeAndPositionManager = _ref.rowSizeAndPositionManager, rowStartIndex = _ref.rowStartIndex, rowStopIndex = _ref.rowStopIndex, scrollLeft = _ref.scrollLeft, scrollTop = _ref.scrollTop, styleCache = _ref.styleCache, verticalOffsetAdjustment = _ref.verticalOffsetAdjustment, visibleColumnIndices = _ref.visibleColumnIndices, visibleRowIndices = _ref.visibleRowIndices; var deferredMode = typeof deferredMeasurementCache !== 'undefined'; var renderedCells = []; // Browsers have native size limits for elements (eg Chrome 33M pixels, IE 1.5M pixes). // User cannot scroll beyond these size limitations. // In order to work around this, ScalingCellSizeAndPositionManager compresses offsets. // We should never cache styles for compressed offsets though as this can lead to bugs. // See issue #576 for more. var areOffsetsAdjusted = columnSizeAndPositionManager.areOffsetsAdjusted() || rowSizeAndPositionManager.areOffsetsAdjusted(); var canCacheStyle = !isScrolling || !areOffsetsAdjusted; for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { var rowDatum = rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); for (var columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) { var columnDatum = columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex); var isVisible = columnIndex >= visibleColumnIndices.start && columnIndex <= visibleColumnIndices.stop && rowIndex >= visibleRowIndices .start && rowIndex <= visibleRowIndices.stop; var key = rowIndex + '-' + columnIndex; var style = void 0; // Cache style objects so shallow-compare doesn't re-render unnecessarily. if (canCacheStyle && styleCache[key]) { style = styleCache[key]; } else { // In deferred mode, cells will be initially rendered before we know their size. // Don't interfere with CellMeasurer's measurements by setting an invalid size. if (deferredMode && !deferredMeasurementCache.has(rowIndex, columnIndex)) { // Position not-yet-measured cells at top/left 0,0, // And give them width/height of 'auto' so they can grow larger than the parent Grid if necessary. // Positioning them further to the right/bottom influences their measured size. style = { height: 'auto', left: 0, position: 'absolute', top: 0, width: 'auto' }; } else { style = { height: rowDatum.size, left: columnDatum.offset + horizontalOffsetAdjustment, position: 'absolute', top: rowDatum.offset + verticalOffsetAdjustment, width: columnDatum.size }; styleCache[key] = style; } } var cellRendererParams = { columnIndex: columnIndex, isScrolling: isScrolling, isVisible: isVisible, key: key, parent: parent, rowIndex: rowIndex, style: style }; var renderedCell = void 0; // Avoid re-creating cells while scrolling. // This can lead to the same cell being created many times and can cause performance issues for "heavy" cells. // If a scroll is in progress- cache and reuse cells. // This cache will be thrown away once scrolling completes. // However if we are scaling scroll positions and sizes, we should also avoid caching. // This is because the offset changes slightly as scroll position changes and caching lead ...
n/a
function defaultOverscanIndicesGetter(_ref) { var direction = _ref.direction, cellCount = _ref.cellCount, overscanCellsCount = _ref.overscanCellsCount, scrollDirection = _ref.scrollDirection, startIndex = _ref.startIndex, stopIndex = _ref.stopIndex; var overscanStartIndex = void 0; var overscanStopIndex = void 0; switch (scrollDirection) { case SCROLL_DIRECTION_FORWARD: overscanStartIndex = startIndex; overscanStopIndex = stopIndex + overscanCellsCount; break; case SCROLL_DIRECTION_BACKWARD: overscanStartIndex = startIndex - overscanCellsCount; overscanStopIndex = stopIndex; break; } return { overscanStartIndex: Math.max(0, overscanStartIndex), overscanStopIndex: Math.min(cellCount - 1, overscanStopIndex) }; }
n/a
function defaultCellDataGetter(_ref) { var columnData = _ref.columnData, dataKey = _ref.dataKey, rowData = _ref.rowData; if (typeof rowData.get === 'function') { return rowData.get(dataKey); } else { return rowData[dataKey]; } }
n/a
function defaultCellRenderer(_ref) { var cellData = _ref.cellData, columnData = _ref.columnData, dataKey = _ref.dataKey, rowData = _ref.rowData, rowIndex = _ref.rowIndex; if (cellData == null) { return ''; } else { return String(cellData); } }
n/a
function defaultHeaderRenderer(_ref) { var columnData = _ref.columnData, dataKey = _ref.dataKey, disableSort = _ref.disableSort, label = _ref.label, sortBy = _ref.sortBy, sortDirection = _ref.sortDirection; var showSortIndicator = sortBy === dataKey; var children = [_react2.default.createElement( 'span', { className: 'ReactVirtualized__Table__headerTruncatedText', key: 'label', title: label }, label )]; if (showSortIndicator) { children.push(_react2.default.createElement(_SortIndicator2.default, { key: 'SortIndicator', sortDirection: sortDirection })); } return children; }
n/a
function defaultHeaderRowRenderer(_ref) { var className = _ref.className, columns = _ref.columns, style = _ref.style; return _react2.default.createElement( 'div', { className: className, role: 'row', style: style }, columns ); }
n/a
function defaultRowRenderer(_ref) { var className = _ref.className, columns = _ref.columns, index = _ref.index, isScrolling = _ref.isScrolling, key = _ref.key, onRowClick = _ref.onRowClick, onRowDoubleClick = _ref.onRowDoubleClick, onRowMouseOver = _ref.onRowMouseOver, onRowMouseOut = _ref.onRowMouseOut, rowData = _ref.rowData, style = _ref.style; var a11yProps = {}; if (onRowClick || onRowDoubleClick || onRowMouseOver || onRowMouseOut) { a11yProps['aria-label'] = 'row'; a11yProps.tabIndex = 0; if (onRowClick) { a11yProps.onClick = function (event) { return onRowClick({ event: event, index: index, rowData: rowData }); }; } if (onRowDoubleClick) { a11yProps.onDoubleClick = function (event) { return onRowDoubleClick({ event: event, index: index, rowData: rowData }); }; } if (onRowMouseOut) { a11yProps.onMouseOut = function (event) { return onRowMouseOut({ event: event, index: index, rowData: rowData }); }; } if (onRowMouseOver) { a11yProps.onMouseOver = function (event) { return onRowMouseOver({ event: event, index: index, rowData: rowData }); }; } } return _react2.default.createElement( 'div', _extends({}, a11yProps, { className: className, key: key, role: 'row', style: style }), columns ); }
n/a