react-window 1.8.10 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +9 -161
  2. package/dist/react-window.cjs +22 -0
  3. package/dist/react-window.d.ts +217 -0
  4. package/dist/react-window.js +812 -0
  5. package/docs/assets/index-DlGpNu0r.css +1 -0
  6. package/docs/assets/index-fVOw1dKb.js +67 -0
  7. package/docs/data/addresses.json +7954 -0
  8. package/docs/data/contacts.json +4202 -0
  9. package/docs/data/names.json +1002 -0
  10. package/docs/favicon.svg +16 -0
  11. package/docs/generated/README.md +1 -0
  12. package/docs/generated/code-snippets/CellComponent.json +4 -0
  13. package/docs/generated/code-snippets/FixedHeightList.json +4 -0
  14. package/docs/generated/code-snippets/FixedHeightRowComponent.json +4 -0
  15. package/docs/generated/code-snippets/FlexboxLayout.json +4 -0
  16. package/docs/generated/code-snippets/Grid.json +4 -0
  17. package/docs/generated/code-snippets/ListVariableRowHeights.json +4 -0
  18. package/docs/generated/code-snippets/columnWidth.json +4 -0
  19. package/docs/generated/code-snippets/gridRefClickEventHandler.json +3 -0
  20. package/docs/generated/code-snippets/listRefClickEventHandler.json +3 -0
  21. package/docs/generated/code-snippets/rowHeight.json +4 -0
  22. package/docs/generated/code-snippets/useGridRef.json +4 -0
  23. package/docs/generated/code-snippets/useGridRefImport.json +3 -0
  24. package/docs/generated/code-snippets/useListRef.json +4 -0
  25. package/docs/generated/code-snippets/useListRefImport.json +3 -0
  26. package/docs/generated/js-docs/Grid.json +314 -0
  27. package/docs/generated/js-docs/List.json +266 -0
  28. package/docs/index.html +30 -0
  29. package/docs/og.html +42 -0
  30. package/docs/og.png +0 -0
  31. package/docs/stats.html +4949 -0
  32. package/docs/svgs/checkbox-checked.svg +1 -0
  33. package/docs/svgs/checkbox-indeterminate.svg +1 -0
  34. package/docs/svgs/checkbox-unchecked.svg +1 -0
  35. package/docs/svgs/github.svg +3 -0
  36. package/docs/svgs/npm.svg +1 -0
  37. package/docs/svgs/radio-checked.svg +1 -0
  38. package/docs/svgs/radio-unchecked.svg +1 -0
  39. package/package.json +70 -90
  40. package/LICENSE.md +0 -21
  41. package/dist/index-dev.umd.js +0 -2
  42. package/dist/index-dev.umd.js.map +0 -1
  43. package/dist/index-prod.umd.js +0 -2
  44. package/dist/index-prod.umd.js.map +0 -1
  45. package/dist/index.cjs.js +0 -2087
  46. package/dist/index.cjs.js.flow +0 -3
  47. package/dist/index.cjs.js.map +0 -1
  48. package/dist/index.esm.js +0 -2076
  49. package/dist/index.esm.js.flow +0 -3
  50. package/dist/index.esm.js.map +0 -1
  51. package/src/FixedSizeGrid.js +0 -244
  52. package/src/FixedSizeList.js +0 -137
  53. package/src/VariableSizeGrid.js +0 -507
  54. package/src/VariableSizeList.js +0 -317
  55. package/src/areEqual.js +0 -18
  56. package/src/createGridComponent.js +0 -919
  57. package/src/createListComponent.js +0 -745
  58. package/src/domHelpers.js +0 -72
  59. package/src/index.js +0 -9
  60. package/src/shallowDiffers.js +0 -17
  61. package/src/shouldComponentUpdate.js +0 -16
  62. package/src/timer.js +0 -37
package/dist/index.cjs.js DELETED
@@ -1,2087 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var _extends = _interopDefault(require('@babel/runtime/helpers/extends'));
8
- var _assertThisInitialized = _interopDefault(require('@babel/runtime/helpers/assertThisInitialized'));
9
- var _inheritsLoose = _interopDefault(require('@babel/runtime/helpers/inheritsLoose'));
10
- var memoizeOne = _interopDefault(require('memoize-one'));
11
- var react = require('react');
12
- var _objectWithoutPropertiesLoose = _interopDefault(require('@babel/runtime/helpers/objectWithoutPropertiesLoose'));
13
-
14
- // Animation frame based implementation of setTimeout.
15
- // Inspired by Joe Lambert, https://gist.github.com/joelambert/1002116#file-requesttimeout-js
16
- var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
17
- var now = hasNativePerformanceNow ? function () {
18
- return performance.now();
19
- } : function () {
20
- return Date.now();
21
- };
22
- function cancelTimeout(timeoutID) {
23
- cancelAnimationFrame(timeoutID.id);
24
- }
25
- function requestTimeout(callback, delay) {
26
- var start = now();
27
-
28
- function tick() {
29
- if (now() - start >= delay) {
30
- callback.call(null);
31
- } else {
32
- timeoutID.id = requestAnimationFrame(tick);
33
- }
34
- }
35
-
36
- var timeoutID = {
37
- id: requestAnimationFrame(tick)
38
- };
39
- return timeoutID;
40
- }
41
-
42
- var size = -1; // This utility copied from "dom-helpers" package.
43
-
44
- function getScrollbarSize(recalculate) {
45
- if (recalculate === void 0) {
46
- recalculate = false;
47
- }
48
-
49
- if (size === -1 || recalculate) {
50
- var div = document.createElement('div');
51
- var style = div.style;
52
- style.width = '50px';
53
- style.height = '50px';
54
- style.overflow = 'scroll';
55
- document.body.appendChild(div);
56
- size = div.offsetWidth - div.clientWidth;
57
- document.body.removeChild(div);
58
- }
59
-
60
- return size;
61
- }
62
- var cachedRTLResult = null; // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
63
- // Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).
64
- // Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.
65
- // The safest way to check this is to intentionally set a negative offset,
66
- // and then verify that the subsequent "scroll" event matches the negative offset.
67
- // If it does not match, then we can assume a non-standard RTL scroll implementation.
68
-
69
- function getRTLOffsetType(recalculate) {
70
- if (recalculate === void 0) {
71
- recalculate = false;
72
- }
73
-
74
- if (cachedRTLResult === null || recalculate) {
75
- var outerDiv = document.createElement('div');
76
- var outerStyle = outerDiv.style;
77
- outerStyle.width = '50px';
78
- outerStyle.height = '50px';
79
- outerStyle.overflow = 'scroll';
80
- outerStyle.direction = 'rtl';
81
- var innerDiv = document.createElement('div');
82
- var innerStyle = innerDiv.style;
83
- innerStyle.width = '100px';
84
- innerStyle.height = '100px';
85
- outerDiv.appendChild(innerDiv);
86
- document.body.appendChild(outerDiv);
87
-
88
- if (outerDiv.scrollLeft > 0) {
89
- cachedRTLResult = 'positive-descending';
90
- } else {
91
- outerDiv.scrollLeft = 1;
92
-
93
- if (outerDiv.scrollLeft === 0) {
94
- cachedRTLResult = 'negative';
95
- } else {
96
- cachedRTLResult = 'positive-ascending';
97
- }
98
- }
99
-
100
- document.body.removeChild(outerDiv);
101
- return cachedRTLResult;
102
- }
103
-
104
- return cachedRTLResult;
105
- }
106
-
107
- var IS_SCROLLING_DEBOUNCE_INTERVAL = 150;
108
-
109
- var defaultItemKey = function defaultItemKey(_ref) {
110
- var columnIndex = _ref.columnIndex,
111
- data = _ref.data,
112
- rowIndex = _ref.rowIndex;
113
- return rowIndex + ":" + columnIndex;
114
- }; // In DEV mode, this Set helps us only log a warning once per component instance.
115
- // This avoids spamming the console every time a render happens.
116
-
117
-
118
- var devWarningsOverscanCount = null;
119
- var devWarningsOverscanRowsColumnsCount = null;
120
- var devWarningsTagName = null;
121
-
122
- if (process.env.NODE_ENV !== 'production') {
123
- if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
124
- devWarningsOverscanCount = /*#__PURE__*/new WeakSet();
125
- devWarningsOverscanRowsColumnsCount = /*#__PURE__*/new WeakSet();
126
- devWarningsTagName = /*#__PURE__*/new WeakSet();
127
- }
128
- }
129
-
130
- function createGridComponent(_ref2) {
131
- var _class;
132
-
133
- var getColumnOffset = _ref2.getColumnOffset,
134
- getColumnStartIndexForOffset = _ref2.getColumnStartIndexForOffset,
135
- getColumnStopIndexForStartIndex = _ref2.getColumnStopIndexForStartIndex,
136
- getColumnWidth = _ref2.getColumnWidth,
137
- getEstimatedTotalHeight = _ref2.getEstimatedTotalHeight,
138
- getEstimatedTotalWidth = _ref2.getEstimatedTotalWidth,
139
- getOffsetForColumnAndAlignment = _ref2.getOffsetForColumnAndAlignment,
140
- getOffsetForRowAndAlignment = _ref2.getOffsetForRowAndAlignment,
141
- getRowHeight = _ref2.getRowHeight,
142
- getRowOffset = _ref2.getRowOffset,
143
- getRowStartIndexForOffset = _ref2.getRowStartIndexForOffset,
144
- getRowStopIndexForStartIndex = _ref2.getRowStopIndexForStartIndex,
145
- initInstanceProps = _ref2.initInstanceProps,
146
- shouldResetStyleCacheOnItemSizeChange = _ref2.shouldResetStyleCacheOnItemSizeChange,
147
- validateProps = _ref2.validateProps;
148
- return _class = /*#__PURE__*/function (_PureComponent) {
149
- _inheritsLoose(Grid, _PureComponent);
150
-
151
- // Always use explicit constructor for React components.
152
- // It produces less code after transpilation. (#26)
153
- // eslint-disable-next-line no-useless-constructor
154
- function Grid(props) {
155
- var _this;
156
-
157
- _this = _PureComponent.call(this, props) || this;
158
- _this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_this));
159
- _this._resetIsScrollingTimeoutId = null;
160
- _this._outerRef = void 0;
161
- _this.state = {
162
- instance: _assertThisInitialized(_this),
163
- isScrolling: false,
164
- horizontalScrollDirection: 'forward',
165
- scrollLeft: typeof _this.props.initialScrollLeft === 'number' ? _this.props.initialScrollLeft : 0,
166
- scrollTop: typeof _this.props.initialScrollTop === 'number' ? _this.props.initialScrollTop : 0,
167
- scrollUpdateWasRequested: false,
168
- verticalScrollDirection: 'forward'
169
- };
170
- _this._callOnItemsRendered = void 0;
171
- _this._callOnItemsRendered = memoizeOne(function (overscanColumnStartIndex, overscanColumnStopIndex, overscanRowStartIndex, overscanRowStopIndex, visibleColumnStartIndex, visibleColumnStopIndex, visibleRowStartIndex, visibleRowStopIndex) {
172
- return _this.props.onItemsRendered({
173
- overscanColumnStartIndex: overscanColumnStartIndex,
174
- overscanColumnStopIndex: overscanColumnStopIndex,
175
- overscanRowStartIndex: overscanRowStartIndex,
176
- overscanRowStopIndex: overscanRowStopIndex,
177
- visibleColumnStartIndex: visibleColumnStartIndex,
178
- visibleColumnStopIndex: visibleColumnStopIndex,
179
- visibleRowStartIndex: visibleRowStartIndex,
180
- visibleRowStopIndex: visibleRowStopIndex
181
- });
182
- });
183
- _this._callOnScroll = void 0;
184
- _this._callOnScroll = memoizeOne(function (scrollLeft, scrollTop, horizontalScrollDirection, verticalScrollDirection, scrollUpdateWasRequested) {
185
- return _this.props.onScroll({
186
- horizontalScrollDirection: horizontalScrollDirection,
187
- scrollLeft: scrollLeft,
188
- scrollTop: scrollTop,
189
- verticalScrollDirection: verticalScrollDirection,
190
- scrollUpdateWasRequested: scrollUpdateWasRequested
191
- });
192
- });
193
- _this._getItemStyle = void 0;
194
-
195
- _this._getItemStyle = function (rowIndex, columnIndex) {
196
- var _this$props = _this.props,
197
- columnWidth = _this$props.columnWidth,
198
- direction = _this$props.direction,
199
- rowHeight = _this$props.rowHeight;
200
-
201
- var itemStyleCache = _this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && columnWidth, shouldResetStyleCacheOnItemSizeChange && direction, shouldResetStyleCacheOnItemSizeChange && rowHeight);
202
-
203
- var key = rowIndex + ":" + columnIndex;
204
- var style;
205
-
206
- if (itemStyleCache.hasOwnProperty(key)) {
207
- style = itemStyleCache[key];
208
- } else {
209
- var _offset = getColumnOffset(_this.props, columnIndex, _this._instanceProps);
210
-
211
- var isRtl = direction === 'rtl';
212
- itemStyleCache[key] = style = {
213
- position: 'absolute',
214
- left: isRtl ? undefined : _offset,
215
- right: isRtl ? _offset : undefined,
216
- top: getRowOffset(_this.props, rowIndex, _this._instanceProps),
217
- height: getRowHeight(_this.props, rowIndex, _this._instanceProps),
218
- width: getColumnWidth(_this.props, columnIndex, _this._instanceProps)
219
- };
220
- }
221
-
222
- return style;
223
- };
224
-
225
- _this._getItemStyleCache = void 0;
226
- _this._getItemStyleCache = memoizeOne(function (_, __, ___) {
227
- return {};
228
- });
229
-
230
- _this._onScroll = function (event) {
231
- var _event$currentTarget = event.currentTarget,
232
- clientHeight = _event$currentTarget.clientHeight,
233
- clientWidth = _event$currentTarget.clientWidth,
234
- scrollLeft = _event$currentTarget.scrollLeft,
235
- scrollTop = _event$currentTarget.scrollTop,
236
- scrollHeight = _event$currentTarget.scrollHeight,
237
- scrollWidth = _event$currentTarget.scrollWidth;
238
-
239
- _this.setState(function (prevState) {
240
- if (prevState.scrollLeft === scrollLeft && prevState.scrollTop === scrollTop) {
241
- // Scroll position may have been updated by cDM/cDU,
242
- // In which case we don't need to trigger another render,
243
- // And we don't want to update state.isScrolling.
244
- return null;
245
- }
246
-
247
- var direction = _this.props.direction; // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
248
- // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
249
- // It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
250
- // So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
251
-
252
- var calculatedScrollLeft = scrollLeft;
253
-
254
- if (direction === 'rtl') {
255
- switch (getRTLOffsetType()) {
256
- case 'negative':
257
- calculatedScrollLeft = -scrollLeft;
258
- break;
259
-
260
- case 'positive-descending':
261
- calculatedScrollLeft = scrollWidth - clientWidth - scrollLeft;
262
- break;
263
- }
264
- } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
265
-
266
-
267
- calculatedScrollLeft = Math.max(0, Math.min(calculatedScrollLeft, scrollWidth - clientWidth));
268
- var calculatedScrollTop = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
269
- return {
270
- isScrolling: true,
271
- horizontalScrollDirection: prevState.scrollLeft < scrollLeft ? 'forward' : 'backward',
272
- scrollLeft: calculatedScrollLeft,
273
- scrollTop: calculatedScrollTop,
274
- verticalScrollDirection: prevState.scrollTop < scrollTop ? 'forward' : 'backward',
275
- scrollUpdateWasRequested: false
276
- };
277
- }, _this._resetIsScrollingDebounced);
278
- };
279
-
280
- _this._outerRefSetter = function (ref) {
281
- var outerRef = _this.props.outerRef;
282
- _this._outerRef = ref;
283
-
284
- if (typeof outerRef === 'function') {
285
- outerRef(ref);
286
- } else if (outerRef != null && typeof outerRef === 'object' && outerRef.hasOwnProperty('current')) {
287
- outerRef.current = ref;
288
- }
289
- };
290
-
291
- _this._resetIsScrollingDebounced = function () {
292
- if (_this._resetIsScrollingTimeoutId !== null) {
293
- cancelTimeout(_this._resetIsScrollingTimeoutId);
294
- }
295
-
296
- _this._resetIsScrollingTimeoutId = requestTimeout(_this._resetIsScrolling, IS_SCROLLING_DEBOUNCE_INTERVAL);
297
- };
298
-
299
- _this._resetIsScrolling = function () {
300
- _this._resetIsScrollingTimeoutId = null;
301
-
302
- _this.setState({
303
- isScrolling: false
304
- }, function () {
305
- // Clear style cache after state update has been committed.
306
- // This way we don't break pure sCU for items that don't use isScrolling param.
307
- _this._getItemStyleCache(-1);
308
- });
309
- };
310
-
311
- return _this;
312
- }
313
-
314
- Grid.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
315
- validateSharedProps(nextProps, prevState);
316
- validateProps(nextProps);
317
- return null;
318
- };
319
-
320
- var _proto = Grid.prototype;
321
-
322
- _proto.scrollTo = function scrollTo(_ref3) {
323
- var scrollLeft = _ref3.scrollLeft,
324
- scrollTop = _ref3.scrollTop;
325
-
326
- if (scrollLeft !== undefined) {
327
- scrollLeft = Math.max(0, scrollLeft);
328
- }
329
-
330
- if (scrollTop !== undefined) {
331
- scrollTop = Math.max(0, scrollTop);
332
- }
333
-
334
- this.setState(function (prevState) {
335
- if (scrollLeft === undefined) {
336
- scrollLeft = prevState.scrollLeft;
337
- }
338
-
339
- if (scrollTop === undefined) {
340
- scrollTop = prevState.scrollTop;
341
- }
342
-
343
- if (prevState.scrollLeft === scrollLeft && prevState.scrollTop === scrollTop) {
344
- return null;
345
- }
346
-
347
- return {
348
- horizontalScrollDirection: prevState.scrollLeft < scrollLeft ? 'forward' : 'backward',
349
- scrollLeft: scrollLeft,
350
- scrollTop: scrollTop,
351
- scrollUpdateWasRequested: true,
352
- verticalScrollDirection: prevState.scrollTop < scrollTop ? 'forward' : 'backward'
353
- };
354
- }, this._resetIsScrollingDebounced);
355
- };
356
-
357
- _proto.scrollToItem = function scrollToItem(_ref4) {
358
- var _ref4$align = _ref4.align,
359
- align = _ref4$align === void 0 ? 'auto' : _ref4$align,
360
- columnIndex = _ref4.columnIndex,
361
- rowIndex = _ref4.rowIndex;
362
- var _this$props2 = this.props,
363
- columnCount = _this$props2.columnCount,
364
- height = _this$props2.height,
365
- rowCount = _this$props2.rowCount,
366
- width = _this$props2.width;
367
- var _this$state = this.state,
368
- scrollLeft = _this$state.scrollLeft,
369
- scrollTop = _this$state.scrollTop;
370
- var scrollbarSize = getScrollbarSize();
371
-
372
- if (columnIndex !== undefined) {
373
- columnIndex = Math.max(0, Math.min(columnIndex, columnCount - 1));
374
- }
375
-
376
- if (rowIndex !== undefined) {
377
- rowIndex = Math.max(0, Math.min(rowIndex, rowCount - 1));
378
- }
379
-
380
- var estimatedTotalHeight = getEstimatedTotalHeight(this.props, this._instanceProps);
381
- var estimatedTotalWidth = getEstimatedTotalWidth(this.props, this._instanceProps); // The scrollbar size should be considered when scrolling an item into view,
382
- // to ensure it's fully visible.
383
- // But we only need to account for its size when it's actually visible.
384
-
385
- var horizontalScrollbarSize = estimatedTotalWidth > width ? scrollbarSize : 0;
386
- var verticalScrollbarSize = estimatedTotalHeight > height ? scrollbarSize : 0;
387
- this.scrollTo({
388
- scrollLeft: columnIndex !== undefined ? getOffsetForColumnAndAlignment(this.props, columnIndex, align, scrollLeft, this._instanceProps, verticalScrollbarSize) : scrollLeft,
389
- scrollTop: rowIndex !== undefined ? getOffsetForRowAndAlignment(this.props, rowIndex, align, scrollTop, this._instanceProps, horizontalScrollbarSize) : scrollTop
390
- });
391
- };
392
-
393
- _proto.componentDidMount = function componentDidMount() {
394
- var _this$props3 = this.props,
395
- initialScrollLeft = _this$props3.initialScrollLeft,
396
- initialScrollTop = _this$props3.initialScrollTop;
397
-
398
- if (this._outerRef != null) {
399
- var outerRef = this._outerRef;
400
-
401
- if (typeof initialScrollLeft === 'number') {
402
- outerRef.scrollLeft = initialScrollLeft;
403
- }
404
-
405
- if (typeof initialScrollTop === 'number') {
406
- outerRef.scrollTop = initialScrollTop;
407
- }
408
- }
409
-
410
- this._callPropsCallbacks();
411
- };
412
-
413
- _proto.componentDidUpdate = function componentDidUpdate() {
414
- var direction = this.props.direction;
415
- var _this$state2 = this.state,
416
- scrollLeft = _this$state2.scrollLeft,
417
- scrollTop = _this$state2.scrollTop,
418
- scrollUpdateWasRequested = _this$state2.scrollUpdateWasRequested;
419
-
420
- if (scrollUpdateWasRequested && this._outerRef != null) {
421
- // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
422
- // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
423
- // So we need to determine which browser behavior we're dealing with, and mimic it.
424
- var outerRef = this._outerRef;
425
-
426
- if (direction === 'rtl') {
427
- switch (getRTLOffsetType()) {
428
- case 'negative':
429
- outerRef.scrollLeft = -scrollLeft;
430
- break;
431
-
432
- case 'positive-ascending':
433
- outerRef.scrollLeft = scrollLeft;
434
- break;
435
-
436
- default:
437
- var clientWidth = outerRef.clientWidth,
438
- scrollWidth = outerRef.scrollWidth;
439
- outerRef.scrollLeft = scrollWidth - clientWidth - scrollLeft;
440
- break;
441
- }
442
- } else {
443
- outerRef.scrollLeft = Math.max(0, scrollLeft);
444
- }
445
-
446
- outerRef.scrollTop = Math.max(0, scrollTop);
447
- }
448
-
449
- this._callPropsCallbacks();
450
- };
451
-
452
- _proto.componentWillUnmount = function componentWillUnmount() {
453
- if (this._resetIsScrollingTimeoutId !== null) {
454
- cancelTimeout(this._resetIsScrollingTimeoutId);
455
- }
456
- };
457
-
458
- _proto.render = function render() {
459
- var _this$props4 = this.props,
460
- children = _this$props4.children,
461
- className = _this$props4.className,
462
- columnCount = _this$props4.columnCount,
463
- direction = _this$props4.direction,
464
- height = _this$props4.height,
465
- innerRef = _this$props4.innerRef,
466
- innerElementType = _this$props4.innerElementType,
467
- innerTagName = _this$props4.innerTagName,
468
- itemData = _this$props4.itemData,
469
- _this$props4$itemKey = _this$props4.itemKey,
470
- itemKey = _this$props4$itemKey === void 0 ? defaultItemKey : _this$props4$itemKey,
471
- outerElementType = _this$props4.outerElementType,
472
- outerTagName = _this$props4.outerTagName,
473
- rowCount = _this$props4.rowCount,
474
- style = _this$props4.style,
475
- useIsScrolling = _this$props4.useIsScrolling,
476
- width = _this$props4.width;
477
- var isScrolling = this.state.isScrolling;
478
-
479
- var _this$_getHorizontalR = this._getHorizontalRangeToRender(),
480
- columnStartIndex = _this$_getHorizontalR[0],
481
- columnStopIndex = _this$_getHorizontalR[1];
482
-
483
- var _this$_getVerticalRan = this._getVerticalRangeToRender(),
484
- rowStartIndex = _this$_getVerticalRan[0],
485
- rowStopIndex = _this$_getVerticalRan[1];
486
-
487
- var items = [];
488
-
489
- if (columnCount > 0 && rowCount) {
490
- for (var _rowIndex = rowStartIndex; _rowIndex <= rowStopIndex; _rowIndex++) {
491
- for (var _columnIndex = columnStartIndex; _columnIndex <= columnStopIndex; _columnIndex++) {
492
- items.push(react.createElement(children, {
493
- columnIndex: _columnIndex,
494
- data: itemData,
495
- isScrolling: useIsScrolling ? isScrolling : undefined,
496
- key: itemKey({
497
- columnIndex: _columnIndex,
498
- data: itemData,
499
- rowIndex: _rowIndex
500
- }),
501
- rowIndex: _rowIndex,
502
- style: this._getItemStyle(_rowIndex, _columnIndex)
503
- }));
504
- }
505
- }
506
- } // Read this value AFTER items have been created,
507
- // So their actual sizes (if variable) are taken into consideration.
508
-
509
-
510
- var estimatedTotalHeight = getEstimatedTotalHeight(this.props, this._instanceProps);
511
- var estimatedTotalWidth = getEstimatedTotalWidth(this.props, this._instanceProps);
512
- return react.createElement(outerElementType || outerTagName || 'div', {
513
- className: className,
514
- onScroll: this._onScroll,
515
- ref: this._outerRefSetter,
516
- style: _extends({
517
- position: 'relative',
518
- height: height,
519
- width: width,
520
- overflow: 'auto',
521
- WebkitOverflowScrolling: 'touch',
522
- willChange: 'transform',
523
- direction: direction
524
- }, style)
525
- }, react.createElement(innerElementType || innerTagName || 'div', {
526
- children: items,
527
- ref: innerRef,
528
- style: {
529
- height: estimatedTotalHeight,
530
- pointerEvents: isScrolling ? 'none' : undefined,
531
- width: estimatedTotalWidth
532
- }
533
- }));
534
- };
535
-
536
- _proto._callPropsCallbacks = function _callPropsCallbacks() {
537
- var _this$props5 = this.props,
538
- columnCount = _this$props5.columnCount,
539
- onItemsRendered = _this$props5.onItemsRendered,
540
- onScroll = _this$props5.onScroll,
541
- rowCount = _this$props5.rowCount;
542
-
543
- if (typeof onItemsRendered === 'function') {
544
- if (columnCount > 0 && rowCount > 0) {
545
- var _this$_getHorizontalR2 = this._getHorizontalRangeToRender(),
546
- _overscanColumnStartIndex = _this$_getHorizontalR2[0],
547
- _overscanColumnStopIndex = _this$_getHorizontalR2[1],
548
- _visibleColumnStartIndex = _this$_getHorizontalR2[2],
549
- _visibleColumnStopIndex = _this$_getHorizontalR2[3];
550
-
551
- var _this$_getVerticalRan2 = this._getVerticalRangeToRender(),
552
- _overscanRowStartIndex = _this$_getVerticalRan2[0],
553
- _overscanRowStopIndex = _this$_getVerticalRan2[1],
554
- _visibleRowStartIndex = _this$_getVerticalRan2[2],
555
- _visibleRowStopIndex = _this$_getVerticalRan2[3];
556
-
557
- this._callOnItemsRendered(_overscanColumnStartIndex, _overscanColumnStopIndex, _overscanRowStartIndex, _overscanRowStopIndex, _visibleColumnStartIndex, _visibleColumnStopIndex, _visibleRowStartIndex, _visibleRowStopIndex);
558
- }
559
- }
560
-
561
- if (typeof onScroll === 'function') {
562
- var _this$state3 = this.state,
563
- _horizontalScrollDirection = _this$state3.horizontalScrollDirection,
564
- _scrollLeft = _this$state3.scrollLeft,
565
- _scrollTop = _this$state3.scrollTop,
566
- _scrollUpdateWasRequested = _this$state3.scrollUpdateWasRequested,
567
- _verticalScrollDirection = _this$state3.verticalScrollDirection;
568
-
569
- this._callOnScroll(_scrollLeft, _scrollTop, _horizontalScrollDirection, _verticalScrollDirection, _scrollUpdateWasRequested);
570
- }
571
- } // Lazily create and cache item styles while scrolling,
572
- // So that pure component sCU will prevent re-renders.
573
- // We maintain this cache, and pass a style prop rather than index,
574
- // So that List can clear cached styles and force item re-render if necessary.
575
- ;
576
-
577
- _proto._getHorizontalRangeToRender = function _getHorizontalRangeToRender() {
578
- var _this$props6 = this.props,
579
- columnCount = _this$props6.columnCount,
580
- overscanColumnCount = _this$props6.overscanColumnCount,
581
- overscanColumnsCount = _this$props6.overscanColumnsCount,
582
- overscanCount = _this$props6.overscanCount,
583
- rowCount = _this$props6.rowCount;
584
- var _this$state4 = this.state,
585
- horizontalScrollDirection = _this$state4.horizontalScrollDirection,
586
- isScrolling = _this$state4.isScrolling,
587
- scrollLeft = _this$state4.scrollLeft;
588
- var overscanCountResolved = overscanColumnCount || overscanColumnsCount || overscanCount || 1;
589
-
590
- if (columnCount === 0 || rowCount === 0) {
591
- return [0, 0, 0, 0];
592
- }
593
-
594
- var startIndex = getColumnStartIndexForOffset(this.props, scrollLeft, this._instanceProps);
595
- var stopIndex = getColumnStopIndexForStartIndex(this.props, startIndex, scrollLeft, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
596
- // If there isn't at least one extra item, tab loops back around.
597
-
598
- var overscanBackward = !isScrolling || horizontalScrollDirection === 'backward' ? Math.max(1, overscanCountResolved) : 1;
599
- var overscanForward = !isScrolling || horizontalScrollDirection === 'forward' ? Math.max(1, overscanCountResolved) : 1;
600
- return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(columnCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
601
- };
602
-
603
- _proto._getVerticalRangeToRender = function _getVerticalRangeToRender() {
604
- var _this$props7 = this.props,
605
- columnCount = _this$props7.columnCount,
606
- overscanCount = _this$props7.overscanCount,
607
- overscanRowCount = _this$props7.overscanRowCount,
608
- overscanRowsCount = _this$props7.overscanRowsCount,
609
- rowCount = _this$props7.rowCount;
610
- var _this$state5 = this.state,
611
- isScrolling = _this$state5.isScrolling,
612
- verticalScrollDirection = _this$state5.verticalScrollDirection,
613
- scrollTop = _this$state5.scrollTop;
614
- var overscanCountResolved = overscanRowCount || overscanRowsCount || overscanCount || 1;
615
-
616
- if (columnCount === 0 || rowCount === 0) {
617
- return [0, 0, 0, 0];
618
- }
619
-
620
- var startIndex = getRowStartIndexForOffset(this.props, scrollTop, this._instanceProps);
621
- var stopIndex = getRowStopIndexForStartIndex(this.props, startIndex, scrollTop, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
622
- // If there isn't at least one extra item, tab loops back around.
623
-
624
- var overscanBackward = !isScrolling || verticalScrollDirection === 'backward' ? Math.max(1, overscanCountResolved) : 1;
625
- var overscanForward = !isScrolling || verticalScrollDirection === 'forward' ? Math.max(1, overscanCountResolved) : 1;
626
- return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(rowCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
627
- };
628
-
629
- return Grid;
630
- }(react.PureComponent), _class.defaultProps = {
631
- direction: 'ltr',
632
- itemData: undefined,
633
- useIsScrolling: false
634
- }, _class;
635
- }
636
-
637
- var validateSharedProps = function validateSharedProps(_ref5, _ref6) {
638
- var children = _ref5.children,
639
- direction = _ref5.direction,
640
- height = _ref5.height,
641
- innerTagName = _ref5.innerTagName,
642
- outerTagName = _ref5.outerTagName,
643
- overscanColumnsCount = _ref5.overscanColumnsCount,
644
- overscanCount = _ref5.overscanCount,
645
- overscanRowsCount = _ref5.overscanRowsCount,
646
- width = _ref5.width;
647
- var instance = _ref6.instance;
648
-
649
- if (process.env.NODE_ENV !== 'production') {
650
- if (typeof overscanCount === 'number') {
651
- if (devWarningsOverscanCount && !devWarningsOverscanCount.has(instance)) {
652
- devWarningsOverscanCount.add(instance);
653
- console.warn('The overscanCount prop has been deprecated. ' + 'Please use the overscanColumnCount and overscanRowCount props instead.');
654
- }
655
- }
656
-
657
- if (typeof overscanColumnsCount === 'number' || typeof overscanRowsCount === 'number') {
658
- if (devWarningsOverscanRowsColumnsCount && !devWarningsOverscanRowsColumnsCount.has(instance)) {
659
- devWarningsOverscanRowsColumnsCount.add(instance);
660
- console.warn('The overscanColumnsCount and overscanRowsCount props have been deprecated. ' + 'Please use the overscanColumnCount and overscanRowCount props instead.');
661
- }
662
- }
663
-
664
- if (innerTagName != null || outerTagName != null) {
665
- if (devWarningsTagName && !devWarningsTagName.has(instance)) {
666
- devWarningsTagName.add(instance);
667
- console.warn('The innerTagName and outerTagName props have been deprecated. ' + 'Please use the innerElementType and outerElementType props instead.');
668
- }
669
- }
670
-
671
- if (children == null) {
672
- throw Error('An invalid "children" prop has been specified. ' + 'Value should be a React component. ' + ("\"" + (children === null ? 'null' : typeof children) + "\" was specified."));
673
- }
674
-
675
- switch (direction) {
676
- case 'ltr':
677
- case 'rtl':
678
- // Valid values
679
- break;
680
-
681
- default:
682
- throw Error('An invalid "direction" prop has been specified. ' + 'Value should be either "ltr" or "rtl". ' + ("\"" + direction + "\" was specified."));
683
- }
684
-
685
- if (typeof width !== 'number') {
686
- throw Error('An invalid "width" prop has been specified. ' + 'Grids must specify a number for width. ' + ("\"" + (width === null ? 'null' : typeof width) + "\" was specified."));
687
- }
688
-
689
- if (typeof height !== 'number') {
690
- throw Error('An invalid "height" prop has been specified. ' + 'Grids must specify a number for height. ' + ("\"" + (height === null ? 'null' : typeof height) + "\" was specified."));
691
- }
692
- }
693
- };
694
-
695
- var DEFAULT_ESTIMATED_ITEM_SIZE = 50;
696
-
697
- var getEstimatedTotalHeight = function getEstimatedTotalHeight(_ref, _ref2) {
698
- var rowCount = _ref.rowCount;
699
- var rowMetadataMap = _ref2.rowMetadataMap,
700
- estimatedRowHeight = _ref2.estimatedRowHeight,
701
- lastMeasuredRowIndex = _ref2.lastMeasuredRowIndex;
702
- var totalSizeOfMeasuredRows = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
703
- // https://github.com/bvaughn/react-window/pull/138
704
-
705
- if (lastMeasuredRowIndex >= rowCount) {
706
- lastMeasuredRowIndex = rowCount - 1;
707
- }
708
-
709
- if (lastMeasuredRowIndex >= 0) {
710
- var itemMetadata = rowMetadataMap[lastMeasuredRowIndex];
711
- totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
712
- }
713
-
714
- var numUnmeasuredItems = rowCount - lastMeasuredRowIndex - 1;
715
- var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedRowHeight;
716
- return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
717
- };
718
-
719
- var getEstimatedTotalWidth = function getEstimatedTotalWidth(_ref3, _ref4) {
720
- var columnCount = _ref3.columnCount;
721
- var columnMetadataMap = _ref4.columnMetadataMap,
722
- estimatedColumnWidth = _ref4.estimatedColumnWidth,
723
- lastMeasuredColumnIndex = _ref4.lastMeasuredColumnIndex;
724
- var totalSizeOfMeasuredRows = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
725
- // https://github.com/bvaughn/react-window/pull/138
726
-
727
- if (lastMeasuredColumnIndex >= columnCount) {
728
- lastMeasuredColumnIndex = columnCount - 1;
729
- }
730
-
731
- if (lastMeasuredColumnIndex >= 0) {
732
- var itemMetadata = columnMetadataMap[lastMeasuredColumnIndex];
733
- totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
734
- }
735
-
736
- var numUnmeasuredItems = columnCount - lastMeasuredColumnIndex - 1;
737
- var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedColumnWidth;
738
- return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
739
- };
740
-
741
- var getItemMetadata = function getItemMetadata(itemType, props, index, instanceProps) {
742
- var itemMetadataMap, itemSize, lastMeasuredIndex;
743
-
744
- if (itemType === 'column') {
745
- itemMetadataMap = instanceProps.columnMetadataMap;
746
- itemSize = props.columnWidth;
747
- lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
748
- } else {
749
- itemMetadataMap = instanceProps.rowMetadataMap;
750
- itemSize = props.rowHeight;
751
- lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
752
- }
753
-
754
- if (index > lastMeasuredIndex) {
755
- var offset = 0;
756
-
757
- if (lastMeasuredIndex >= 0) {
758
- var itemMetadata = itemMetadataMap[lastMeasuredIndex];
759
- offset = itemMetadata.offset + itemMetadata.size;
760
- }
761
-
762
- for (var i = lastMeasuredIndex + 1; i <= index; i++) {
763
- var size = itemSize(i);
764
- itemMetadataMap[i] = {
765
- offset: offset,
766
- size: size
767
- };
768
- offset += size;
769
- }
770
-
771
- if (itemType === 'column') {
772
- instanceProps.lastMeasuredColumnIndex = index;
773
- } else {
774
- instanceProps.lastMeasuredRowIndex = index;
775
- }
776
- }
777
-
778
- return itemMetadataMap[index];
779
- };
780
-
781
- var findNearestItem = function findNearestItem(itemType, props, instanceProps, offset) {
782
- var itemMetadataMap, lastMeasuredIndex;
783
-
784
- if (itemType === 'column') {
785
- itemMetadataMap = instanceProps.columnMetadataMap;
786
- lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
787
- } else {
788
- itemMetadataMap = instanceProps.rowMetadataMap;
789
- lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
790
- }
791
-
792
- var lastMeasuredItemOffset = lastMeasuredIndex > 0 ? itemMetadataMap[lastMeasuredIndex].offset : 0;
793
-
794
- if (lastMeasuredItemOffset >= offset) {
795
- // If we've already measured items within this range just use a binary search as it's faster.
796
- return findNearestItemBinarySearch(itemType, props, instanceProps, lastMeasuredIndex, 0, offset);
797
- } else {
798
- // If we haven't yet measured this high, fallback to an exponential search with an inner binary search.
799
- // The exponential search avoids pre-computing sizes for the full set of items as a binary search would.
800
- // The overall complexity for this approach is O(log n).
801
- return findNearestItemExponentialSearch(itemType, props, instanceProps, Math.max(0, lastMeasuredIndex), offset);
802
- }
803
- };
804
-
805
- var findNearestItemBinarySearch = function findNearestItemBinarySearch(itemType, props, instanceProps, high, low, offset) {
806
- while (low <= high) {
807
- var middle = low + Math.floor((high - low) / 2);
808
- var currentOffset = getItemMetadata(itemType, props, middle, instanceProps).offset;
809
-
810
- if (currentOffset === offset) {
811
- return middle;
812
- } else if (currentOffset < offset) {
813
- low = middle + 1;
814
- } else if (currentOffset > offset) {
815
- high = middle - 1;
816
- }
817
- }
818
-
819
- if (low > 0) {
820
- return low - 1;
821
- } else {
822
- return 0;
823
- }
824
- };
825
-
826
- var findNearestItemExponentialSearch = function findNearestItemExponentialSearch(itemType, props, instanceProps, index, offset) {
827
- var itemCount = itemType === 'column' ? props.columnCount : props.rowCount;
828
- var interval = 1;
829
-
830
- while (index < itemCount && getItemMetadata(itemType, props, index, instanceProps).offset < offset) {
831
- index += interval;
832
- interval *= 2;
833
- }
834
-
835
- return findNearestItemBinarySearch(itemType, props, instanceProps, Math.min(index, itemCount - 1), Math.floor(index / 2), offset);
836
- };
837
-
838
- var getOffsetForIndexAndAlignment = function getOffsetForIndexAndAlignment(itemType, props, index, align, scrollOffset, instanceProps, scrollbarSize) {
839
- var size = itemType === 'column' ? props.width : props.height;
840
- var itemMetadata = getItemMetadata(itemType, props, index, instanceProps); // Get estimated total size after ItemMetadata is computed,
841
- // To ensure it reflects actual measurements instead of just estimates.
842
-
843
- var estimatedTotalSize = itemType === 'column' ? getEstimatedTotalWidth(props, instanceProps) : getEstimatedTotalHeight(props, instanceProps);
844
- var maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
845
- var minOffset = Math.max(0, itemMetadata.offset - size + scrollbarSize + itemMetadata.size);
846
-
847
- if (align === 'smart') {
848
- if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
849
- align = 'auto';
850
- } else {
851
- align = 'center';
852
- }
853
- }
854
-
855
- switch (align) {
856
- case 'start':
857
- return maxOffset;
858
-
859
- case 'end':
860
- return minOffset;
861
-
862
- case 'center':
863
- return Math.round(minOffset + (maxOffset - minOffset) / 2);
864
-
865
- case 'auto':
866
- default:
867
- if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
868
- return scrollOffset;
869
- } else if (minOffset > maxOffset) {
870
- // Because we only take into account the scrollbar size when calculating minOffset
871
- // this value can be larger than maxOffset when at the end of the list
872
- return minOffset;
873
- } else if (scrollOffset < minOffset) {
874
- return minOffset;
875
- } else {
876
- return maxOffset;
877
- }
878
-
879
- }
880
- };
881
-
882
- var VariableSizeGrid = /*#__PURE__*/createGridComponent({
883
- getColumnOffset: function getColumnOffset(props, index, instanceProps) {
884
- return getItemMetadata('column', props, index, instanceProps).offset;
885
- },
886
- getColumnStartIndexForOffset: function getColumnStartIndexForOffset(props, scrollLeft, instanceProps) {
887
- return findNearestItem('column', props, instanceProps, scrollLeft);
888
- },
889
- getColumnStopIndexForStartIndex: function getColumnStopIndexForStartIndex(props, startIndex, scrollLeft, instanceProps) {
890
- var columnCount = props.columnCount,
891
- width = props.width;
892
- var itemMetadata = getItemMetadata('column', props, startIndex, instanceProps);
893
- var maxOffset = scrollLeft + width;
894
- var offset = itemMetadata.offset + itemMetadata.size;
895
- var stopIndex = startIndex;
896
-
897
- while (stopIndex < columnCount - 1 && offset < maxOffset) {
898
- stopIndex++;
899
- offset += getItemMetadata('column', props, stopIndex, instanceProps).size;
900
- }
901
-
902
- return stopIndex;
903
- },
904
- getColumnWidth: function getColumnWidth(props, index, instanceProps) {
905
- return instanceProps.columnMetadataMap[index].size;
906
- },
907
- getEstimatedTotalHeight: getEstimatedTotalHeight,
908
- getEstimatedTotalWidth: getEstimatedTotalWidth,
909
- getOffsetForColumnAndAlignment: function getOffsetForColumnAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
910
- return getOffsetForIndexAndAlignment('column', props, index, align, scrollOffset, instanceProps, scrollbarSize);
911
- },
912
- getOffsetForRowAndAlignment: function getOffsetForRowAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
913
- return getOffsetForIndexAndAlignment('row', props, index, align, scrollOffset, instanceProps, scrollbarSize);
914
- },
915
- getRowOffset: function getRowOffset(props, index, instanceProps) {
916
- return getItemMetadata('row', props, index, instanceProps).offset;
917
- },
918
- getRowHeight: function getRowHeight(props, index, instanceProps) {
919
- return instanceProps.rowMetadataMap[index].size;
920
- },
921
- getRowStartIndexForOffset: function getRowStartIndexForOffset(props, scrollTop, instanceProps) {
922
- return findNearestItem('row', props, instanceProps, scrollTop);
923
- },
924
- getRowStopIndexForStartIndex: function getRowStopIndexForStartIndex(props, startIndex, scrollTop, instanceProps) {
925
- var rowCount = props.rowCount,
926
- height = props.height;
927
- var itemMetadata = getItemMetadata('row', props, startIndex, instanceProps);
928
- var maxOffset = scrollTop + height;
929
- var offset = itemMetadata.offset + itemMetadata.size;
930
- var stopIndex = startIndex;
931
-
932
- while (stopIndex < rowCount - 1 && offset < maxOffset) {
933
- stopIndex++;
934
- offset += getItemMetadata('row', props, stopIndex, instanceProps).size;
935
- }
936
-
937
- return stopIndex;
938
- },
939
- initInstanceProps: function initInstanceProps(props, instance) {
940
- var _ref5 = props,
941
- estimatedColumnWidth = _ref5.estimatedColumnWidth,
942
- estimatedRowHeight = _ref5.estimatedRowHeight;
943
- var instanceProps = {
944
- columnMetadataMap: {},
945
- estimatedColumnWidth: estimatedColumnWidth || DEFAULT_ESTIMATED_ITEM_SIZE,
946
- estimatedRowHeight: estimatedRowHeight || DEFAULT_ESTIMATED_ITEM_SIZE,
947
- lastMeasuredColumnIndex: -1,
948
- lastMeasuredRowIndex: -1,
949
- rowMetadataMap: {}
950
- };
951
-
952
- instance.resetAfterColumnIndex = function (columnIndex, shouldForceUpdate) {
953
- if (shouldForceUpdate === void 0) {
954
- shouldForceUpdate = true;
955
- }
956
-
957
- instance.resetAfterIndices({
958
- columnIndex: columnIndex,
959
- shouldForceUpdate: shouldForceUpdate
960
- });
961
- };
962
-
963
- instance.resetAfterRowIndex = function (rowIndex, shouldForceUpdate) {
964
- if (shouldForceUpdate === void 0) {
965
- shouldForceUpdate = true;
966
- }
967
-
968
- instance.resetAfterIndices({
969
- rowIndex: rowIndex,
970
- shouldForceUpdate: shouldForceUpdate
971
- });
972
- };
973
-
974
- instance.resetAfterIndices = function (_ref6) {
975
- var columnIndex = _ref6.columnIndex,
976
- rowIndex = _ref6.rowIndex,
977
- _ref6$shouldForceUpda = _ref6.shouldForceUpdate,
978
- shouldForceUpdate = _ref6$shouldForceUpda === void 0 ? true : _ref6$shouldForceUpda;
979
-
980
- if (typeof columnIndex === 'number') {
981
- instanceProps.lastMeasuredColumnIndex = Math.min(instanceProps.lastMeasuredColumnIndex, columnIndex - 1);
982
- }
983
-
984
- if (typeof rowIndex === 'number') {
985
- instanceProps.lastMeasuredRowIndex = Math.min(instanceProps.lastMeasuredRowIndex, rowIndex - 1);
986
- } // We could potentially optimize further by only evicting styles after this index,
987
- // But since styles are only cached while scrolling is in progress-
988
- // It seems an unnecessary optimization.
989
- // It's unlikely that resetAfterIndex() will be called while a user is scrolling.
990
-
991
-
992
- instance._getItemStyleCache(-1);
993
-
994
- if (shouldForceUpdate) {
995
- instance.forceUpdate();
996
- }
997
- };
998
-
999
- return instanceProps;
1000
- },
1001
- shouldResetStyleCacheOnItemSizeChange: false,
1002
- validateProps: function validateProps(_ref7) {
1003
- var columnWidth = _ref7.columnWidth,
1004
- rowHeight = _ref7.rowHeight;
1005
-
1006
- if (process.env.NODE_ENV !== 'production') {
1007
- if (typeof columnWidth !== 'function') {
1008
- throw Error('An invalid "columnWidth" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (columnWidth === null ? 'null' : typeof columnWidth) + "\" was specified."));
1009
- } else if (typeof rowHeight !== 'function') {
1010
- throw Error('An invalid "rowHeight" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (rowHeight === null ? 'null' : typeof rowHeight) + "\" was specified."));
1011
- }
1012
- }
1013
- }
1014
- });
1015
-
1016
- var IS_SCROLLING_DEBOUNCE_INTERVAL$1 = 150;
1017
-
1018
- var defaultItemKey$1 = function defaultItemKey(index, data) {
1019
- return index;
1020
- }; // In DEV mode, this Set helps us only log a warning once per component instance.
1021
- // This avoids spamming the console every time a render happens.
1022
-
1023
-
1024
- var devWarningsDirection = null;
1025
- var devWarningsTagName$1 = null;
1026
-
1027
- if (process.env.NODE_ENV !== 'production') {
1028
- if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
1029
- devWarningsDirection = /*#__PURE__*/new WeakSet();
1030
- devWarningsTagName$1 = /*#__PURE__*/new WeakSet();
1031
- }
1032
- }
1033
-
1034
- function createListComponent(_ref) {
1035
- var _class;
1036
-
1037
- var getItemOffset = _ref.getItemOffset,
1038
- getEstimatedTotalSize = _ref.getEstimatedTotalSize,
1039
- getItemSize = _ref.getItemSize,
1040
- getOffsetForIndexAndAlignment = _ref.getOffsetForIndexAndAlignment,
1041
- getStartIndexForOffset = _ref.getStartIndexForOffset,
1042
- getStopIndexForStartIndex = _ref.getStopIndexForStartIndex,
1043
- initInstanceProps = _ref.initInstanceProps,
1044
- shouldResetStyleCacheOnItemSizeChange = _ref.shouldResetStyleCacheOnItemSizeChange,
1045
- validateProps = _ref.validateProps;
1046
- return _class = /*#__PURE__*/function (_PureComponent) {
1047
- _inheritsLoose(List, _PureComponent);
1048
-
1049
- // Always use explicit constructor for React components.
1050
- // It produces less code after transpilation. (#26)
1051
- // eslint-disable-next-line no-useless-constructor
1052
- function List(props) {
1053
- var _this;
1054
-
1055
- _this = _PureComponent.call(this, props) || this;
1056
- _this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_this));
1057
- _this._outerRef = void 0;
1058
- _this._resetIsScrollingTimeoutId = null;
1059
- _this.state = {
1060
- instance: _assertThisInitialized(_this),
1061
- isScrolling: false,
1062
- scrollDirection: 'forward',
1063
- scrollOffset: typeof _this.props.initialScrollOffset === 'number' ? _this.props.initialScrollOffset : 0,
1064
- scrollUpdateWasRequested: false
1065
- };
1066
- _this._callOnItemsRendered = void 0;
1067
- _this._callOnItemsRendered = memoizeOne(function (overscanStartIndex, overscanStopIndex, visibleStartIndex, visibleStopIndex) {
1068
- return _this.props.onItemsRendered({
1069
- overscanStartIndex: overscanStartIndex,
1070
- overscanStopIndex: overscanStopIndex,
1071
- visibleStartIndex: visibleStartIndex,
1072
- visibleStopIndex: visibleStopIndex
1073
- });
1074
- });
1075
- _this._callOnScroll = void 0;
1076
- _this._callOnScroll = memoizeOne(function (scrollDirection, scrollOffset, scrollUpdateWasRequested) {
1077
- return _this.props.onScroll({
1078
- scrollDirection: scrollDirection,
1079
- scrollOffset: scrollOffset,
1080
- scrollUpdateWasRequested: scrollUpdateWasRequested
1081
- });
1082
- });
1083
- _this._getItemStyle = void 0;
1084
-
1085
- _this._getItemStyle = function (index) {
1086
- var _this$props = _this.props,
1087
- direction = _this$props.direction,
1088
- itemSize = _this$props.itemSize,
1089
- layout = _this$props.layout;
1090
-
1091
- var itemStyleCache = _this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && itemSize, shouldResetStyleCacheOnItemSizeChange && layout, shouldResetStyleCacheOnItemSizeChange && direction);
1092
-
1093
- var style;
1094
-
1095
- if (itemStyleCache.hasOwnProperty(index)) {
1096
- style = itemStyleCache[index];
1097
- } else {
1098
- var _offset = getItemOffset(_this.props, index, _this._instanceProps);
1099
-
1100
- var size = getItemSize(_this.props, index, _this._instanceProps); // TODO Deprecate direction "horizontal"
1101
-
1102
- var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
1103
- var isRtl = direction === 'rtl';
1104
- var offsetHorizontal = isHorizontal ? _offset : 0;
1105
- itemStyleCache[index] = style = {
1106
- position: 'absolute',
1107
- left: isRtl ? undefined : offsetHorizontal,
1108
- right: isRtl ? offsetHorizontal : undefined,
1109
- top: !isHorizontal ? _offset : 0,
1110
- height: !isHorizontal ? size : '100%',
1111
- width: isHorizontal ? size : '100%'
1112
- };
1113
- }
1114
-
1115
- return style;
1116
- };
1117
-
1118
- _this._getItemStyleCache = void 0;
1119
- _this._getItemStyleCache = memoizeOne(function (_, __, ___) {
1120
- return {};
1121
- });
1122
-
1123
- _this._onScrollHorizontal = function (event) {
1124
- var _event$currentTarget = event.currentTarget,
1125
- clientWidth = _event$currentTarget.clientWidth,
1126
- scrollLeft = _event$currentTarget.scrollLeft,
1127
- scrollWidth = _event$currentTarget.scrollWidth;
1128
-
1129
- _this.setState(function (prevState) {
1130
- if (prevState.scrollOffset === scrollLeft) {
1131
- // Scroll position may have been updated by cDM/cDU,
1132
- // In which case we don't need to trigger another render,
1133
- // And we don't want to update state.isScrolling.
1134
- return null;
1135
- }
1136
-
1137
- var direction = _this.props.direction;
1138
- var scrollOffset = scrollLeft;
1139
-
1140
- if (direction === 'rtl') {
1141
- // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
1142
- // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
1143
- // It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
1144
- // So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
1145
- switch (getRTLOffsetType()) {
1146
- case 'negative':
1147
- scrollOffset = -scrollLeft;
1148
- break;
1149
-
1150
- case 'positive-descending':
1151
- scrollOffset = scrollWidth - clientWidth - scrollLeft;
1152
- break;
1153
- }
1154
- } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
1155
-
1156
-
1157
- scrollOffset = Math.max(0, Math.min(scrollOffset, scrollWidth - clientWidth));
1158
- return {
1159
- isScrolling: true,
1160
- scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
1161
- scrollOffset: scrollOffset,
1162
- scrollUpdateWasRequested: false
1163
- };
1164
- }, _this._resetIsScrollingDebounced);
1165
- };
1166
-
1167
- _this._onScrollVertical = function (event) {
1168
- var _event$currentTarget2 = event.currentTarget,
1169
- clientHeight = _event$currentTarget2.clientHeight,
1170
- scrollHeight = _event$currentTarget2.scrollHeight,
1171
- scrollTop = _event$currentTarget2.scrollTop;
1172
-
1173
- _this.setState(function (prevState) {
1174
- if (prevState.scrollOffset === scrollTop) {
1175
- // Scroll position may have been updated by cDM/cDU,
1176
- // In which case we don't need to trigger another render,
1177
- // And we don't want to update state.isScrolling.
1178
- return null;
1179
- } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
1180
-
1181
-
1182
- var scrollOffset = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
1183
- return {
1184
- isScrolling: true,
1185
- scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
1186
- scrollOffset: scrollOffset,
1187
- scrollUpdateWasRequested: false
1188
- };
1189
- }, _this._resetIsScrollingDebounced);
1190
- };
1191
-
1192
- _this._outerRefSetter = function (ref) {
1193
- var outerRef = _this.props.outerRef;
1194
- _this._outerRef = ref;
1195
-
1196
- if (typeof outerRef === 'function') {
1197
- outerRef(ref);
1198
- } else if (outerRef != null && typeof outerRef === 'object' && outerRef.hasOwnProperty('current')) {
1199
- outerRef.current = ref;
1200
- }
1201
- };
1202
-
1203
- _this._resetIsScrollingDebounced = function () {
1204
- if (_this._resetIsScrollingTimeoutId !== null) {
1205
- cancelTimeout(_this._resetIsScrollingTimeoutId);
1206
- }
1207
-
1208
- _this._resetIsScrollingTimeoutId = requestTimeout(_this._resetIsScrolling, IS_SCROLLING_DEBOUNCE_INTERVAL$1);
1209
- };
1210
-
1211
- _this._resetIsScrolling = function () {
1212
- _this._resetIsScrollingTimeoutId = null;
1213
-
1214
- _this.setState({
1215
- isScrolling: false
1216
- }, function () {
1217
- // Clear style cache after state update has been committed.
1218
- // This way we don't break pure sCU for items that don't use isScrolling param.
1219
- _this._getItemStyleCache(-1, null);
1220
- });
1221
- };
1222
-
1223
- return _this;
1224
- }
1225
-
1226
- List.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
1227
- validateSharedProps$1(nextProps, prevState);
1228
- validateProps(nextProps);
1229
- return null;
1230
- };
1231
-
1232
- var _proto = List.prototype;
1233
-
1234
- _proto.scrollTo = function scrollTo(scrollOffset) {
1235
- scrollOffset = Math.max(0, scrollOffset);
1236
- this.setState(function (prevState) {
1237
- if (prevState.scrollOffset === scrollOffset) {
1238
- return null;
1239
- }
1240
-
1241
- return {
1242
- scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
1243
- scrollOffset: scrollOffset,
1244
- scrollUpdateWasRequested: true
1245
- };
1246
- }, this._resetIsScrollingDebounced);
1247
- };
1248
-
1249
- _proto.scrollToItem = function scrollToItem(index, align) {
1250
- if (align === void 0) {
1251
- align = 'auto';
1252
- }
1253
-
1254
- var _this$props2 = this.props,
1255
- itemCount = _this$props2.itemCount,
1256
- layout = _this$props2.layout;
1257
- var scrollOffset = this.state.scrollOffset;
1258
- index = Math.max(0, Math.min(index, itemCount - 1)); // The scrollbar size should be considered when scrolling an item into view, to ensure it's fully visible.
1259
- // But we only need to account for its size when it's actually visible.
1260
- // This is an edge case for lists; normally they only scroll in the dominant direction.
1261
-
1262
- var scrollbarSize = 0;
1263
-
1264
- if (this._outerRef) {
1265
- var outerRef = this._outerRef;
1266
-
1267
- if (layout === 'vertical') {
1268
- scrollbarSize = outerRef.scrollWidth > outerRef.clientWidth ? getScrollbarSize() : 0;
1269
- } else {
1270
- scrollbarSize = outerRef.scrollHeight > outerRef.clientHeight ? getScrollbarSize() : 0;
1271
- }
1272
- }
1273
-
1274
- this.scrollTo(getOffsetForIndexAndAlignment(this.props, index, align, scrollOffset, this._instanceProps, scrollbarSize));
1275
- };
1276
-
1277
- _proto.componentDidMount = function componentDidMount() {
1278
- var _this$props3 = this.props,
1279
- direction = _this$props3.direction,
1280
- initialScrollOffset = _this$props3.initialScrollOffset,
1281
- layout = _this$props3.layout;
1282
-
1283
- if (typeof initialScrollOffset === 'number' && this._outerRef != null) {
1284
- var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
1285
-
1286
- if (direction === 'horizontal' || layout === 'horizontal') {
1287
- outerRef.scrollLeft = initialScrollOffset;
1288
- } else {
1289
- outerRef.scrollTop = initialScrollOffset;
1290
- }
1291
- }
1292
-
1293
- this._callPropsCallbacks();
1294
- };
1295
-
1296
- _proto.componentDidUpdate = function componentDidUpdate() {
1297
- var _this$props4 = this.props,
1298
- direction = _this$props4.direction,
1299
- layout = _this$props4.layout;
1300
- var _this$state = this.state,
1301
- scrollOffset = _this$state.scrollOffset,
1302
- scrollUpdateWasRequested = _this$state.scrollUpdateWasRequested;
1303
-
1304
- if (scrollUpdateWasRequested && this._outerRef != null) {
1305
- var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
1306
-
1307
- if (direction === 'horizontal' || layout === 'horizontal') {
1308
- if (direction === 'rtl') {
1309
- // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
1310
- // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
1311
- // So we need to determine which browser behavior we're dealing with, and mimic it.
1312
- switch (getRTLOffsetType()) {
1313
- case 'negative':
1314
- outerRef.scrollLeft = -scrollOffset;
1315
- break;
1316
-
1317
- case 'positive-ascending':
1318
- outerRef.scrollLeft = scrollOffset;
1319
- break;
1320
-
1321
- default:
1322
- var clientWidth = outerRef.clientWidth,
1323
- scrollWidth = outerRef.scrollWidth;
1324
- outerRef.scrollLeft = scrollWidth - clientWidth - scrollOffset;
1325
- break;
1326
- }
1327
- } else {
1328
- outerRef.scrollLeft = scrollOffset;
1329
- }
1330
- } else {
1331
- outerRef.scrollTop = scrollOffset;
1332
- }
1333
- }
1334
-
1335
- this._callPropsCallbacks();
1336
- };
1337
-
1338
- _proto.componentWillUnmount = function componentWillUnmount() {
1339
- if (this._resetIsScrollingTimeoutId !== null) {
1340
- cancelTimeout(this._resetIsScrollingTimeoutId);
1341
- }
1342
- };
1343
-
1344
- _proto.render = function render() {
1345
- var _this$props5 = this.props,
1346
- children = _this$props5.children,
1347
- className = _this$props5.className,
1348
- direction = _this$props5.direction,
1349
- height = _this$props5.height,
1350
- innerRef = _this$props5.innerRef,
1351
- innerElementType = _this$props5.innerElementType,
1352
- innerTagName = _this$props5.innerTagName,
1353
- itemCount = _this$props5.itemCount,
1354
- itemData = _this$props5.itemData,
1355
- _this$props5$itemKey = _this$props5.itemKey,
1356
- itemKey = _this$props5$itemKey === void 0 ? defaultItemKey$1 : _this$props5$itemKey,
1357
- layout = _this$props5.layout,
1358
- outerElementType = _this$props5.outerElementType,
1359
- outerTagName = _this$props5.outerTagName,
1360
- style = _this$props5.style,
1361
- useIsScrolling = _this$props5.useIsScrolling,
1362
- width = _this$props5.width;
1363
- var isScrolling = this.state.isScrolling; // TODO Deprecate direction "horizontal"
1364
-
1365
- var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
1366
- var onScroll = isHorizontal ? this._onScrollHorizontal : this._onScrollVertical;
1367
-
1368
- var _this$_getRangeToRend = this._getRangeToRender(),
1369
- startIndex = _this$_getRangeToRend[0],
1370
- stopIndex = _this$_getRangeToRend[1];
1371
-
1372
- var items = [];
1373
-
1374
- if (itemCount > 0) {
1375
- for (var _index = startIndex; _index <= stopIndex; _index++) {
1376
- items.push(react.createElement(children, {
1377
- data: itemData,
1378
- key: itemKey(_index, itemData),
1379
- index: _index,
1380
- isScrolling: useIsScrolling ? isScrolling : undefined,
1381
- style: this._getItemStyle(_index)
1382
- }));
1383
- }
1384
- } // Read this value AFTER items have been created,
1385
- // So their actual sizes (if variable) are taken into consideration.
1386
-
1387
-
1388
- var estimatedTotalSize = getEstimatedTotalSize(this.props, this._instanceProps);
1389
- return react.createElement(outerElementType || outerTagName || 'div', {
1390
- className: className,
1391
- onScroll: onScroll,
1392
- ref: this._outerRefSetter,
1393
- style: _extends({
1394
- position: 'relative',
1395
- height: height,
1396
- width: width,
1397
- overflow: 'auto',
1398
- WebkitOverflowScrolling: 'touch',
1399
- willChange: 'transform',
1400
- direction: direction
1401
- }, style)
1402
- }, react.createElement(innerElementType || innerTagName || 'div', {
1403
- children: items,
1404
- ref: innerRef,
1405
- style: {
1406
- height: isHorizontal ? '100%' : estimatedTotalSize,
1407
- pointerEvents: isScrolling ? 'none' : undefined,
1408
- width: isHorizontal ? estimatedTotalSize : '100%'
1409
- }
1410
- }));
1411
- };
1412
-
1413
- _proto._callPropsCallbacks = function _callPropsCallbacks() {
1414
- if (typeof this.props.onItemsRendered === 'function') {
1415
- var itemCount = this.props.itemCount;
1416
-
1417
- if (itemCount > 0) {
1418
- var _this$_getRangeToRend2 = this._getRangeToRender(),
1419
- _overscanStartIndex = _this$_getRangeToRend2[0],
1420
- _overscanStopIndex = _this$_getRangeToRend2[1],
1421
- _visibleStartIndex = _this$_getRangeToRend2[2],
1422
- _visibleStopIndex = _this$_getRangeToRend2[3];
1423
-
1424
- this._callOnItemsRendered(_overscanStartIndex, _overscanStopIndex, _visibleStartIndex, _visibleStopIndex);
1425
- }
1426
- }
1427
-
1428
- if (typeof this.props.onScroll === 'function') {
1429
- var _this$state2 = this.state,
1430
- _scrollDirection = _this$state2.scrollDirection,
1431
- _scrollOffset = _this$state2.scrollOffset,
1432
- _scrollUpdateWasRequested = _this$state2.scrollUpdateWasRequested;
1433
-
1434
- this._callOnScroll(_scrollDirection, _scrollOffset, _scrollUpdateWasRequested);
1435
- }
1436
- } // Lazily create and cache item styles while scrolling,
1437
- // So that pure component sCU will prevent re-renders.
1438
- // We maintain this cache, and pass a style prop rather than index,
1439
- // So that List can clear cached styles and force item re-render if necessary.
1440
- ;
1441
-
1442
- _proto._getRangeToRender = function _getRangeToRender() {
1443
- var _this$props6 = this.props,
1444
- itemCount = _this$props6.itemCount,
1445
- overscanCount = _this$props6.overscanCount;
1446
- var _this$state3 = this.state,
1447
- isScrolling = _this$state3.isScrolling,
1448
- scrollDirection = _this$state3.scrollDirection,
1449
- scrollOffset = _this$state3.scrollOffset;
1450
-
1451
- if (itemCount === 0) {
1452
- return [0, 0, 0, 0];
1453
- }
1454
-
1455
- var startIndex = getStartIndexForOffset(this.props, scrollOffset, this._instanceProps);
1456
- var stopIndex = getStopIndexForStartIndex(this.props, startIndex, scrollOffset, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
1457
- // If there isn't at least one extra item, tab loops back around.
1458
-
1459
- var overscanBackward = !isScrolling || scrollDirection === 'backward' ? Math.max(1, overscanCount) : 1;
1460
- var overscanForward = !isScrolling || scrollDirection === 'forward' ? Math.max(1, overscanCount) : 1;
1461
- return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(itemCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
1462
- };
1463
-
1464
- return List;
1465
- }(react.PureComponent), _class.defaultProps = {
1466
- direction: 'ltr',
1467
- itemData: undefined,
1468
- layout: 'vertical',
1469
- overscanCount: 2,
1470
- useIsScrolling: false
1471
- }, _class;
1472
- } // NOTE: I considered further wrapping individual items with a pure ListItem component.
1473
- // This would avoid ever calling the render function for the same index more than once,
1474
- // But it would also add the overhead of a lot of components/fibers.
1475
- // I assume people already do this (render function returning a class component),
1476
- // So my doing it would just unnecessarily double the wrappers.
1477
-
1478
- var validateSharedProps$1 = function validateSharedProps(_ref2, _ref3) {
1479
- var children = _ref2.children,
1480
- direction = _ref2.direction,
1481
- height = _ref2.height,
1482
- layout = _ref2.layout,
1483
- innerTagName = _ref2.innerTagName,
1484
- outerTagName = _ref2.outerTagName,
1485
- width = _ref2.width;
1486
- var instance = _ref3.instance;
1487
-
1488
- if (process.env.NODE_ENV !== 'production') {
1489
- if (innerTagName != null || outerTagName != null) {
1490
- if (devWarningsTagName$1 && !devWarningsTagName$1.has(instance)) {
1491
- devWarningsTagName$1.add(instance);
1492
- console.warn('The innerTagName and outerTagName props have been deprecated. ' + 'Please use the innerElementType and outerElementType props instead.');
1493
- }
1494
- } // TODO Deprecate direction "horizontal"
1495
-
1496
-
1497
- var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
1498
-
1499
- switch (direction) {
1500
- case 'horizontal':
1501
- case 'vertical':
1502
- if (devWarningsDirection && !devWarningsDirection.has(instance)) {
1503
- devWarningsDirection.add(instance);
1504
- console.warn('The direction prop should be either "ltr" (default) or "rtl". ' + 'Please use the layout prop to specify "vertical" (default) or "horizontal" orientation.');
1505
- }
1506
-
1507
- break;
1508
-
1509
- case 'ltr':
1510
- case 'rtl':
1511
- // Valid values
1512
- break;
1513
-
1514
- default:
1515
- throw Error('An invalid "direction" prop has been specified. ' + 'Value should be either "ltr" or "rtl". ' + ("\"" + direction + "\" was specified."));
1516
- }
1517
-
1518
- switch (layout) {
1519
- case 'horizontal':
1520
- case 'vertical':
1521
- // Valid values
1522
- break;
1523
-
1524
- default:
1525
- throw Error('An invalid "layout" prop has been specified. ' + 'Value should be either "horizontal" or "vertical". ' + ("\"" + layout + "\" was specified."));
1526
- }
1527
-
1528
- if (children == null) {
1529
- throw Error('An invalid "children" prop has been specified. ' + 'Value should be a React component. ' + ("\"" + (children === null ? 'null' : typeof children) + "\" was specified."));
1530
- }
1531
-
1532
- if (isHorizontal && typeof width !== 'number') {
1533
- throw Error('An invalid "width" prop has been specified. ' + 'Horizontal lists must specify a number for width. ' + ("\"" + (width === null ? 'null' : typeof width) + "\" was specified."));
1534
- } else if (!isHorizontal && typeof height !== 'number') {
1535
- throw Error('An invalid "height" prop has been specified. ' + 'Vertical lists must specify a number for height. ' + ("\"" + (height === null ? 'null' : typeof height) + "\" was specified."));
1536
- }
1537
- }
1538
- };
1539
-
1540
- var DEFAULT_ESTIMATED_ITEM_SIZE$1 = 50;
1541
-
1542
- var getItemMetadata$1 = function getItemMetadata(props, index, instanceProps) {
1543
- var _ref = props,
1544
- itemSize = _ref.itemSize;
1545
- var itemMetadataMap = instanceProps.itemMetadataMap,
1546
- lastMeasuredIndex = instanceProps.lastMeasuredIndex;
1547
-
1548
- if (index > lastMeasuredIndex) {
1549
- var offset = 0;
1550
-
1551
- if (lastMeasuredIndex >= 0) {
1552
- var itemMetadata = itemMetadataMap[lastMeasuredIndex];
1553
- offset = itemMetadata.offset + itemMetadata.size;
1554
- }
1555
-
1556
- for (var i = lastMeasuredIndex + 1; i <= index; i++) {
1557
- var size = itemSize(i);
1558
- itemMetadataMap[i] = {
1559
- offset: offset,
1560
- size: size
1561
- };
1562
- offset += size;
1563
- }
1564
-
1565
- instanceProps.lastMeasuredIndex = index;
1566
- }
1567
-
1568
- return itemMetadataMap[index];
1569
- };
1570
-
1571
- var findNearestItem$1 = function findNearestItem(props, instanceProps, offset) {
1572
- var itemMetadataMap = instanceProps.itemMetadataMap,
1573
- lastMeasuredIndex = instanceProps.lastMeasuredIndex;
1574
- var lastMeasuredItemOffset = lastMeasuredIndex > 0 ? itemMetadataMap[lastMeasuredIndex].offset : 0;
1575
-
1576
- if (lastMeasuredItemOffset >= offset) {
1577
- // If we've already measured items within this range just use a binary search as it's faster.
1578
- return findNearestItemBinarySearch$1(props, instanceProps, lastMeasuredIndex, 0, offset);
1579
- } else {
1580
- // If we haven't yet measured this high, fallback to an exponential search with an inner binary search.
1581
- // The exponential search avoids pre-computing sizes for the full set of items as a binary search would.
1582
- // The overall complexity for this approach is O(log n).
1583
- return findNearestItemExponentialSearch$1(props, instanceProps, Math.max(0, lastMeasuredIndex), offset);
1584
- }
1585
- };
1586
-
1587
- var findNearestItemBinarySearch$1 = function findNearestItemBinarySearch(props, instanceProps, high, low, offset) {
1588
- while (low <= high) {
1589
- var middle = low + Math.floor((high - low) / 2);
1590
- var currentOffset = getItemMetadata$1(props, middle, instanceProps).offset;
1591
-
1592
- if (currentOffset === offset) {
1593
- return middle;
1594
- } else if (currentOffset < offset) {
1595
- low = middle + 1;
1596
- } else if (currentOffset > offset) {
1597
- high = middle - 1;
1598
- }
1599
- }
1600
-
1601
- if (low > 0) {
1602
- return low - 1;
1603
- } else {
1604
- return 0;
1605
- }
1606
- };
1607
-
1608
- var findNearestItemExponentialSearch$1 = function findNearestItemExponentialSearch(props, instanceProps, index, offset) {
1609
- var itemCount = props.itemCount;
1610
- var interval = 1;
1611
-
1612
- while (index < itemCount && getItemMetadata$1(props, index, instanceProps).offset < offset) {
1613
- index += interval;
1614
- interval *= 2;
1615
- }
1616
-
1617
- return findNearestItemBinarySearch$1(props, instanceProps, Math.min(index, itemCount - 1), Math.floor(index / 2), offset);
1618
- };
1619
-
1620
- var getEstimatedTotalSize = function getEstimatedTotalSize(_ref2, _ref3) {
1621
- var itemCount = _ref2.itemCount;
1622
- var itemMetadataMap = _ref3.itemMetadataMap,
1623
- estimatedItemSize = _ref3.estimatedItemSize,
1624
- lastMeasuredIndex = _ref3.lastMeasuredIndex;
1625
- var totalSizeOfMeasuredItems = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
1626
- // https://github.com/bvaughn/react-window/pull/138
1627
-
1628
- if (lastMeasuredIndex >= itemCount) {
1629
- lastMeasuredIndex = itemCount - 1;
1630
- }
1631
-
1632
- if (lastMeasuredIndex >= 0) {
1633
- var itemMetadata = itemMetadataMap[lastMeasuredIndex];
1634
- totalSizeOfMeasuredItems = itemMetadata.offset + itemMetadata.size;
1635
- }
1636
-
1637
- var numUnmeasuredItems = itemCount - lastMeasuredIndex - 1;
1638
- var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedItemSize;
1639
- return totalSizeOfMeasuredItems + totalSizeOfUnmeasuredItems;
1640
- };
1641
-
1642
- var VariableSizeList = /*#__PURE__*/createListComponent({
1643
- getItemOffset: function getItemOffset(props, index, instanceProps) {
1644
- return getItemMetadata$1(props, index, instanceProps).offset;
1645
- },
1646
- getItemSize: function getItemSize(props, index, instanceProps) {
1647
- return instanceProps.itemMetadataMap[index].size;
1648
- },
1649
- getEstimatedTotalSize: getEstimatedTotalSize,
1650
- getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
1651
- var direction = props.direction,
1652
- height = props.height,
1653
- layout = props.layout,
1654
- width = props.width; // TODO Deprecate direction "horizontal"
1655
-
1656
- var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
1657
- var size = isHorizontal ? width : height;
1658
- var itemMetadata = getItemMetadata$1(props, index, instanceProps); // Get estimated total size after ItemMetadata is computed,
1659
- // To ensure it reflects actual measurements instead of just estimates.
1660
-
1661
- var estimatedTotalSize = getEstimatedTotalSize(props, instanceProps);
1662
- var maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
1663
- var minOffset = Math.max(0, itemMetadata.offset - size + itemMetadata.size + scrollbarSize);
1664
-
1665
- if (align === 'smart') {
1666
- if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
1667
- align = 'auto';
1668
- } else {
1669
- align = 'center';
1670
- }
1671
- }
1672
-
1673
- switch (align) {
1674
- case 'start':
1675
- return maxOffset;
1676
-
1677
- case 'end':
1678
- return minOffset;
1679
-
1680
- case 'center':
1681
- return Math.round(minOffset + (maxOffset - minOffset) / 2);
1682
-
1683
- case 'auto':
1684
- default:
1685
- if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
1686
- return scrollOffset;
1687
- } else if (scrollOffset < minOffset) {
1688
- return minOffset;
1689
- } else {
1690
- return maxOffset;
1691
- }
1692
-
1693
- }
1694
- },
1695
- getStartIndexForOffset: function getStartIndexForOffset(props, offset, instanceProps) {
1696
- return findNearestItem$1(props, instanceProps, offset);
1697
- },
1698
- getStopIndexForStartIndex: function getStopIndexForStartIndex(props, startIndex, scrollOffset, instanceProps) {
1699
- var direction = props.direction,
1700
- height = props.height,
1701
- itemCount = props.itemCount,
1702
- layout = props.layout,
1703
- width = props.width; // TODO Deprecate direction "horizontal"
1704
-
1705
- var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
1706
- var size = isHorizontal ? width : height;
1707
- var itemMetadata = getItemMetadata$1(props, startIndex, instanceProps);
1708
- var maxOffset = scrollOffset + size;
1709
- var offset = itemMetadata.offset + itemMetadata.size;
1710
- var stopIndex = startIndex;
1711
-
1712
- while (stopIndex < itemCount - 1 && offset < maxOffset) {
1713
- stopIndex++;
1714
- offset += getItemMetadata$1(props, stopIndex, instanceProps).size;
1715
- }
1716
-
1717
- return stopIndex;
1718
- },
1719
- initInstanceProps: function initInstanceProps(props, instance) {
1720
- var _ref4 = props,
1721
- estimatedItemSize = _ref4.estimatedItemSize;
1722
- var instanceProps = {
1723
- itemMetadataMap: {},
1724
- estimatedItemSize: estimatedItemSize || DEFAULT_ESTIMATED_ITEM_SIZE$1,
1725
- lastMeasuredIndex: -1
1726
- };
1727
-
1728
- instance.resetAfterIndex = function (index, shouldForceUpdate) {
1729
- if (shouldForceUpdate === void 0) {
1730
- shouldForceUpdate = true;
1731
- }
1732
-
1733
- instanceProps.lastMeasuredIndex = Math.min(instanceProps.lastMeasuredIndex, index - 1); // We could potentially optimize further by only evicting styles after this index,
1734
- // But since styles are only cached while scrolling is in progress-
1735
- // It seems an unnecessary optimization.
1736
- // It's unlikely that resetAfterIndex() will be called while a user is scrolling.
1737
-
1738
- instance._getItemStyleCache(-1);
1739
-
1740
- if (shouldForceUpdate) {
1741
- instance.forceUpdate();
1742
- }
1743
- };
1744
-
1745
- return instanceProps;
1746
- },
1747
- shouldResetStyleCacheOnItemSizeChange: false,
1748
- validateProps: function validateProps(_ref5) {
1749
- var itemSize = _ref5.itemSize;
1750
-
1751
- if (process.env.NODE_ENV !== 'production') {
1752
- if (typeof itemSize !== 'function') {
1753
- throw Error('An invalid "itemSize" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (itemSize === null ? 'null' : typeof itemSize) + "\" was specified."));
1754
- }
1755
- }
1756
- }
1757
- });
1758
-
1759
- var FixedSizeGrid = /*#__PURE__*/createGridComponent({
1760
- getColumnOffset: function getColumnOffset(_ref, index) {
1761
- var columnWidth = _ref.columnWidth;
1762
- return index * columnWidth;
1763
- },
1764
- getColumnWidth: function getColumnWidth(_ref2, index) {
1765
- var columnWidth = _ref2.columnWidth;
1766
- return columnWidth;
1767
- },
1768
- getRowOffset: function getRowOffset(_ref3, index) {
1769
- var rowHeight = _ref3.rowHeight;
1770
- return index * rowHeight;
1771
- },
1772
- getRowHeight: function getRowHeight(_ref4, index) {
1773
- var rowHeight = _ref4.rowHeight;
1774
- return rowHeight;
1775
- },
1776
- getEstimatedTotalHeight: function getEstimatedTotalHeight(_ref5) {
1777
- var rowCount = _ref5.rowCount,
1778
- rowHeight = _ref5.rowHeight;
1779
- return rowHeight * rowCount;
1780
- },
1781
- getEstimatedTotalWidth: function getEstimatedTotalWidth(_ref6) {
1782
- var columnCount = _ref6.columnCount,
1783
- columnWidth = _ref6.columnWidth;
1784
- return columnWidth * columnCount;
1785
- },
1786
- getOffsetForColumnAndAlignment: function getOffsetForColumnAndAlignment(_ref7, columnIndex, align, scrollLeft, instanceProps, scrollbarSize) {
1787
- var columnCount = _ref7.columnCount,
1788
- columnWidth = _ref7.columnWidth,
1789
- width = _ref7.width;
1790
- var lastColumnOffset = Math.max(0, columnCount * columnWidth - width);
1791
- var maxOffset = Math.min(lastColumnOffset, columnIndex * columnWidth);
1792
- var minOffset = Math.max(0, columnIndex * columnWidth - width + scrollbarSize + columnWidth);
1793
-
1794
- if (align === 'smart') {
1795
- if (scrollLeft >= minOffset - width && scrollLeft <= maxOffset + width) {
1796
- align = 'auto';
1797
- } else {
1798
- align = 'center';
1799
- }
1800
- }
1801
-
1802
- switch (align) {
1803
- case 'start':
1804
- return maxOffset;
1805
-
1806
- case 'end':
1807
- return minOffset;
1808
-
1809
- case 'center':
1810
- // "Centered" offset is usually the average of the min and max.
1811
- // But near the edges of the list, this doesn't hold true.
1812
- var middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2);
1813
-
1814
- if (middleOffset < Math.ceil(width / 2)) {
1815
- return 0; // near the beginning
1816
- } else if (middleOffset > lastColumnOffset + Math.floor(width / 2)) {
1817
- return lastColumnOffset; // near the end
1818
- } else {
1819
- return middleOffset;
1820
- }
1821
-
1822
- case 'auto':
1823
- default:
1824
- if (scrollLeft >= minOffset && scrollLeft <= maxOffset) {
1825
- return scrollLeft;
1826
- } else if (minOffset > maxOffset) {
1827
- // Because we only take into account the scrollbar size when calculating minOffset
1828
- // this value can be larger than maxOffset when at the end of the list
1829
- return minOffset;
1830
- } else if (scrollLeft < minOffset) {
1831
- return minOffset;
1832
- } else {
1833
- return maxOffset;
1834
- }
1835
-
1836
- }
1837
- },
1838
- getOffsetForRowAndAlignment: function getOffsetForRowAndAlignment(_ref8, rowIndex, align, scrollTop, instanceProps, scrollbarSize) {
1839
- var rowHeight = _ref8.rowHeight,
1840
- height = _ref8.height,
1841
- rowCount = _ref8.rowCount;
1842
- var lastRowOffset = Math.max(0, rowCount * rowHeight - height);
1843
- var maxOffset = Math.min(lastRowOffset, rowIndex * rowHeight);
1844
- var minOffset = Math.max(0, rowIndex * rowHeight - height + scrollbarSize + rowHeight);
1845
-
1846
- if (align === 'smart') {
1847
- if (scrollTop >= minOffset - height && scrollTop <= maxOffset + height) {
1848
- align = 'auto';
1849
- } else {
1850
- align = 'center';
1851
- }
1852
- }
1853
-
1854
- switch (align) {
1855
- case 'start':
1856
- return maxOffset;
1857
-
1858
- case 'end':
1859
- return minOffset;
1860
-
1861
- case 'center':
1862
- // "Centered" offset is usually the average of the min and max.
1863
- // But near the edges of the list, this doesn't hold true.
1864
- var middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2);
1865
-
1866
- if (middleOffset < Math.ceil(height / 2)) {
1867
- return 0; // near the beginning
1868
- } else if (middleOffset > lastRowOffset + Math.floor(height / 2)) {
1869
- return lastRowOffset; // near the end
1870
- } else {
1871
- return middleOffset;
1872
- }
1873
-
1874
- case 'auto':
1875
- default:
1876
- if (scrollTop >= minOffset && scrollTop <= maxOffset) {
1877
- return scrollTop;
1878
- } else if (minOffset > maxOffset) {
1879
- // Because we only take into account the scrollbar size when calculating minOffset
1880
- // this value can be larger than maxOffset when at the end of the list
1881
- return minOffset;
1882
- } else if (scrollTop < minOffset) {
1883
- return minOffset;
1884
- } else {
1885
- return maxOffset;
1886
- }
1887
-
1888
- }
1889
- },
1890
- getColumnStartIndexForOffset: function getColumnStartIndexForOffset(_ref9, scrollLeft) {
1891
- var columnWidth = _ref9.columnWidth,
1892
- columnCount = _ref9.columnCount;
1893
- return Math.max(0, Math.min(columnCount - 1, Math.floor(scrollLeft / columnWidth)));
1894
- },
1895
- getColumnStopIndexForStartIndex: function getColumnStopIndexForStartIndex(_ref10, startIndex, scrollLeft) {
1896
- var columnWidth = _ref10.columnWidth,
1897
- columnCount = _ref10.columnCount,
1898
- width = _ref10.width;
1899
- var left = startIndex * columnWidth;
1900
- var numVisibleColumns = Math.ceil((width + scrollLeft - left) / columnWidth);
1901
- return Math.max(0, Math.min(columnCount - 1, startIndex + numVisibleColumns - 1 // -1 is because stop index is inclusive
1902
- ));
1903
- },
1904
- getRowStartIndexForOffset: function getRowStartIndexForOffset(_ref11, scrollTop) {
1905
- var rowHeight = _ref11.rowHeight,
1906
- rowCount = _ref11.rowCount;
1907
- return Math.max(0, Math.min(rowCount - 1, Math.floor(scrollTop / rowHeight)));
1908
- },
1909
- getRowStopIndexForStartIndex: function getRowStopIndexForStartIndex(_ref12, startIndex, scrollTop) {
1910
- var rowHeight = _ref12.rowHeight,
1911
- rowCount = _ref12.rowCount,
1912
- height = _ref12.height;
1913
- var top = startIndex * rowHeight;
1914
- var numVisibleRows = Math.ceil((height + scrollTop - top) / rowHeight);
1915
- return Math.max(0, Math.min(rowCount - 1, startIndex + numVisibleRows - 1 // -1 is because stop index is inclusive
1916
- ));
1917
- },
1918
- initInstanceProps: function initInstanceProps(props) {// Noop
1919
- },
1920
- shouldResetStyleCacheOnItemSizeChange: true,
1921
- validateProps: function validateProps(_ref13) {
1922
- var columnWidth = _ref13.columnWidth,
1923
- rowHeight = _ref13.rowHeight;
1924
-
1925
- if (process.env.NODE_ENV !== 'production') {
1926
- if (typeof columnWidth !== 'number') {
1927
- throw Error('An invalid "columnWidth" prop has been specified. ' + 'Value should be a number. ' + ("\"" + (columnWidth === null ? 'null' : typeof columnWidth) + "\" was specified."));
1928
- }
1929
-
1930
- if (typeof rowHeight !== 'number') {
1931
- throw Error('An invalid "rowHeight" prop has been specified. ' + 'Value should be a number. ' + ("\"" + (rowHeight === null ? 'null' : typeof rowHeight) + "\" was specified."));
1932
- }
1933
- }
1934
- }
1935
- });
1936
-
1937
- var FixedSizeList = /*#__PURE__*/createListComponent({
1938
- getItemOffset: function getItemOffset(_ref, index) {
1939
- var itemSize = _ref.itemSize;
1940
- return index * itemSize;
1941
- },
1942
- getItemSize: function getItemSize(_ref2, index) {
1943
- var itemSize = _ref2.itemSize;
1944
- return itemSize;
1945
- },
1946
- getEstimatedTotalSize: function getEstimatedTotalSize(_ref3) {
1947
- var itemCount = _ref3.itemCount,
1948
- itemSize = _ref3.itemSize;
1949
- return itemSize * itemCount;
1950
- },
1951
- getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(_ref4, index, align, scrollOffset, instanceProps, scrollbarSize) {
1952
- var direction = _ref4.direction,
1953
- height = _ref4.height,
1954
- itemCount = _ref4.itemCount,
1955
- itemSize = _ref4.itemSize,
1956
- layout = _ref4.layout,
1957
- width = _ref4.width;
1958
- // TODO Deprecate direction "horizontal"
1959
- var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
1960
- var size = isHorizontal ? width : height;
1961
- var lastItemOffset = Math.max(0, itemCount * itemSize - size);
1962
- var maxOffset = Math.min(lastItemOffset, index * itemSize);
1963
- var minOffset = Math.max(0, index * itemSize - size + itemSize + scrollbarSize);
1964
-
1965
- if (align === 'smart') {
1966
- if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
1967
- align = 'auto';
1968
- } else {
1969
- align = 'center';
1970
- }
1971
- }
1972
-
1973
- switch (align) {
1974
- case 'start':
1975
- return maxOffset;
1976
-
1977
- case 'end':
1978
- return minOffset;
1979
-
1980
- case 'center':
1981
- {
1982
- // "Centered" offset is usually the average of the min and max.
1983
- // But near the edges of the list, this doesn't hold true.
1984
- var middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2);
1985
-
1986
- if (middleOffset < Math.ceil(size / 2)) {
1987
- return 0; // near the beginning
1988
- } else if (middleOffset > lastItemOffset + Math.floor(size / 2)) {
1989
- return lastItemOffset; // near the end
1990
- } else {
1991
- return middleOffset;
1992
- }
1993
- }
1994
-
1995
- case 'auto':
1996
- default:
1997
- if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
1998
- return scrollOffset;
1999
- } else if (scrollOffset < minOffset) {
2000
- return minOffset;
2001
- } else {
2002
- return maxOffset;
2003
- }
2004
-
2005
- }
2006
- },
2007
- getStartIndexForOffset: function getStartIndexForOffset(_ref5, offset) {
2008
- var itemCount = _ref5.itemCount,
2009
- itemSize = _ref5.itemSize;
2010
- return Math.max(0, Math.min(itemCount - 1, Math.floor(offset / itemSize)));
2011
- },
2012
- getStopIndexForStartIndex: function getStopIndexForStartIndex(_ref6, startIndex, scrollOffset) {
2013
- var direction = _ref6.direction,
2014
- height = _ref6.height,
2015
- itemCount = _ref6.itemCount,
2016
- itemSize = _ref6.itemSize,
2017
- layout = _ref6.layout,
2018
- width = _ref6.width;
2019
- // TODO Deprecate direction "horizontal"
2020
- var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
2021
- var offset = startIndex * itemSize;
2022
- var size = isHorizontal ? width : height;
2023
- var numVisibleItems = Math.ceil((size + scrollOffset - offset) / itemSize);
2024
- return Math.max(0, Math.min(itemCount - 1, startIndex + numVisibleItems - 1 // -1 is because stop index is inclusive
2025
- ));
2026
- },
2027
- initInstanceProps: function initInstanceProps(props) {// Noop
2028
- },
2029
- shouldResetStyleCacheOnItemSizeChange: true,
2030
- validateProps: function validateProps(_ref7) {
2031
- var itemSize = _ref7.itemSize;
2032
-
2033
- if (process.env.NODE_ENV !== 'production') {
2034
- if (typeof itemSize !== 'number') {
2035
- throw Error('An invalid "itemSize" prop has been specified. ' + 'Value should be a number. ' + ("\"" + (itemSize === null ? 'null' : typeof itemSize) + "\" was specified."));
2036
- }
2037
- }
2038
- }
2039
- });
2040
-
2041
- // Pulled from react-compat
2042
- // https://github.com/developit/preact-compat/blob/7c5de00e7c85e2ffd011bf3af02899b63f699d3a/src/index.js#L349
2043
- function shallowDiffers(prev, next) {
2044
- for (var attribute in prev) {
2045
- if (!(attribute in next)) {
2046
- return true;
2047
- }
2048
- }
2049
-
2050
- for (var _attribute in next) {
2051
- if (prev[_attribute] !== next[_attribute]) {
2052
- return true;
2053
- }
2054
- }
2055
-
2056
- return false;
2057
- }
2058
-
2059
- var _excluded = ["style"],
2060
- _excluded2 = ["style"];
2061
- // It knows to compare individual style props and ignore the wrapper object.
2062
- // See https://reactjs.org/docs/react-api.html#reactmemo
2063
-
2064
- function areEqual(prevProps, nextProps) {
2065
- var prevStyle = prevProps.style,
2066
- prevRest = _objectWithoutPropertiesLoose(prevProps, _excluded);
2067
-
2068
- var nextStyle = nextProps.style,
2069
- nextRest = _objectWithoutPropertiesLoose(nextProps, _excluded2);
2070
-
2071
- return !shallowDiffers(prevStyle, nextStyle) && !shallowDiffers(prevRest, nextRest);
2072
- }
2073
-
2074
- // It knows to compare individual style props and ignore the wrapper object.
2075
- // See https://reactjs.org/docs/react-component.html#shouldcomponentupdate
2076
-
2077
- function shouldComponentUpdate(nextProps, nextState) {
2078
- return !areEqual(this.props, nextProps) || shallowDiffers(this.state, nextState);
2079
- }
2080
-
2081
- exports.FixedSizeGrid = FixedSizeGrid;
2082
- exports.FixedSizeList = FixedSizeList;
2083
- exports.VariableSizeGrid = VariableSizeGrid;
2084
- exports.VariableSizeList = VariableSizeList;
2085
- exports.areEqual = areEqual;
2086
- exports.shouldComponentUpdate = shouldComponentUpdate;
2087
- //# sourceMappingURL=index.cjs.js.map