@react-stately/layout 3.9.1-nightly.3608 → 3.9.1-nightly.3611
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.
- package/dist/main.js +204 -43
- package/dist/main.js.map +1 -1
- package/dist/module.js +204 -43
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +28 -8
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/ListLayout.ts +96 -15
- package/src/TableLayout.ts +168 -38
package/dist/main.js
CHANGED
|
@@ -32,9 +32,27 @@ $parcel$export(module.exports, "TableLayout", () => $67c493497dcda343$export$624
|
|
|
32
32
|
const $fe69e47e38ed0ac4$var$DEFAULT_HEIGHT = 48;
|
|
33
33
|
class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $cMJQZ$reactstatelyvirtualizer.Layout) {
|
|
34
34
|
getLayoutInfo(key) {
|
|
35
|
-
|
|
35
|
+
let res = this.layoutInfos.get(key);
|
|
36
|
+
// If the layout info wasn't found, it might be outside the bounds of the area that we've
|
|
37
|
+
// computed layout for so far. This can happen when accessing a random key, e.g pressing Home/End.
|
|
38
|
+
// Compute the full layout and try again.
|
|
39
|
+
if (!res && this.validRect.area < this.contentSize.area && this.lastCollection) {
|
|
40
|
+
this.lastValidRect = this.validRect;
|
|
41
|
+
this.validRect = new (0, $cMJQZ$reactstatelyvirtualizer.Rect)(0, 0, Infinity, Infinity);
|
|
42
|
+
this.rootNodes = this.buildCollection();
|
|
43
|
+
this.validRect = new (0, $cMJQZ$reactstatelyvirtualizer.Rect)(0, 0, this.contentSize.width, this.contentSize.height);
|
|
44
|
+
res = this.layoutInfos.get(key);
|
|
45
|
+
}
|
|
46
|
+
return res;
|
|
36
47
|
}
|
|
37
48
|
getVisibleLayoutInfos(rect) {
|
|
49
|
+
// If layout hasn't yet been done for the requested rect, union the
|
|
50
|
+
// new rect with the existing valid rect, and recompute.
|
|
51
|
+
if (!this.validRect.containsRect(rect) && this.lastCollection) {
|
|
52
|
+
this.lastValidRect = this.validRect;
|
|
53
|
+
this.validRect = this.validRect.union(rect);
|
|
54
|
+
this.rootNodes = this.buildCollection();
|
|
55
|
+
}
|
|
38
56
|
let res = [];
|
|
39
57
|
let addNodes = (nodes)=>{
|
|
40
58
|
for (let node of nodes)if (this.isVisible(node, rect)) {
|
|
@@ -49,14 +67,23 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $cMJQZ$reactstatelyv
|
|
|
49
67
|
isVisible(node, rect) {
|
|
50
68
|
return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || this.virtualizer.isPersistedKey(node.layoutInfo.key);
|
|
51
69
|
}
|
|
52
|
-
|
|
70
|
+
shouldInvalidateEverything(invalidationContext) {
|
|
53
71
|
// Invalidate cache if the size of the collection changed.
|
|
54
72
|
// In this case, we need to recalculate the entire layout.
|
|
55
|
-
|
|
73
|
+
return invalidationContext.sizeChanged;
|
|
74
|
+
}
|
|
75
|
+
validate(invalidationContext) {
|
|
56
76
|
this.collection = this.virtualizer.collection;
|
|
77
|
+
// Reset valid rect if we will have to invalidate everything.
|
|
78
|
+
// Otherwise we can reuse cached layout infos outside the current visible rect.
|
|
79
|
+
this.invalidateEverything = this.shouldInvalidateEverything(invalidationContext);
|
|
80
|
+
if (this.invalidateEverything) {
|
|
81
|
+
this.lastValidRect = this.validRect;
|
|
82
|
+
this.validRect = this.virtualizer.getVisibleRect();
|
|
83
|
+
}
|
|
57
84
|
this.rootNodes = this.buildCollection();
|
|
58
85
|
// Remove deleted layout nodes
|
|
59
|
-
if (this.lastCollection) {
|
|
86
|
+
if (this.lastCollection && this.collection !== this.lastCollection) {
|
|
60
87
|
for (let key of this.lastCollection.getKeys())if (!this.collection.getItem(key)) {
|
|
61
88
|
let layoutNode = this.layoutNodes.get(key);
|
|
62
89
|
if (layoutNode) {
|
|
@@ -69,14 +96,28 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $cMJQZ$reactstatelyv
|
|
|
69
96
|
}
|
|
70
97
|
this.lastWidth = this.virtualizer.visibleRect.width;
|
|
71
98
|
this.lastCollection = this.collection;
|
|
99
|
+
this.invalidateEverything = false;
|
|
72
100
|
}
|
|
73
101
|
buildCollection() {
|
|
74
102
|
let y = this.padding;
|
|
103
|
+
let skipped = 0;
|
|
75
104
|
let nodes = [];
|
|
76
105
|
for (let node of this.collection){
|
|
106
|
+
var _rowHeight;
|
|
107
|
+
let rowHeight = (_rowHeight = this.rowHeight) !== null && _rowHeight !== void 0 ? _rowHeight : this.estimatedRowHeight;
|
|
108
|
+
// Skip rows before the valid rectangle unless they are already cached.
|
|
109
|
+
if (node.type === "item" && y + rowHeight < this.validRect.y && !this.isValid(node, y)) {
|
|
110
|
+
y += rowHeight;
|
|
111
|
+
skipped++;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
77
114
|
let layoutNode = this.buildChild(node, 0, y);
|
|
78
115
|
y = layoutNode.layoutInfo.rect.maxY;
|
|
79
116
|
nodes.push(layoutNode);
|
|
117
|
+
if (node.type === "item" && y > this.validRect.maxY) {
|
|
118
|
+
y += (this.collection.size - (nodes.length + skipped)) * rowHeight;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
80
121
|
}
|
|
81
122
|
if (this.isLoading) {
|
|
82
123
|
var _loaderHeight;
|
|
@@ -101,9 +142,12 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $cMJQZ$reactstatelyv
|
|
|
101
142
|
this.contentSize = new (0, $cMJQZ$reactstatelyvirtualizer.Size)(this.virtualizer.visibleRect.width, y + this.padding);
|
|
102
143
|
return nodes;
|
|
103
144
|
}
|
|
104
|
-
|
|
145
|
+
isValid(node, y) {
|
|
105
146
|
let cached = this.layoutNodes.get(node.key);
|
|
106
|
-
|
|
147
|
+
return !this.invalidateEverything && cached && cached.node === node && y === (cached.header || cached.layoutInfo).rect.y && cached.layoutInfo.rect.intersects(this.lastValidRect) && cached.validRect.containsRect(cached.layoutInfo.rect.intersection(this.validRect));
|
|
148
|
+
}
|
|
149
|
+
buildChild(node, x, y) {
|
|
150
|
+
if (this.isValid(node, y)) return this.layoutNodes.get(node.key);
|
|
107
151
|
let layoutNode = this.buildNode(node, x, y);
|
|
108
152
|
layoutNode.node = node;
|
|
109
153
|
var _parentKey;
|
|
@@ -150,17 +194,34 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $cMJQZ$reactstatelyv
|
|
|
150
194
|
let rect = new (0, $cMJQZ$reactstatelyvirtualizer.Rect)(0, y, width, 0);
|
|
151
195
|
let layoutInfo = new (0, $cMJQZ$reactstatelyvirtualizer.LayoutInfo)(node.type, node.key, rect);
|
|
152
196
|
let startY = y;
|
|
197
|
+
let skipped = 0;
|
|
153
198
|
let children = [];
|
|
154
199
|
for (let child of node.childNodes){
|
|
200
|
+
var _rowHeight;
|
|
201
|
+
let rowHeight = (_rowHeight = this.rowHeight) !== null && _rowHeight !== void 0 ? _rowHeight : this.estimatedRowHeight;
|
|
202
|
+
// Skip rows before the valid rectangle unless they are already cached.
|
|
203
|
+
if (y + rowHeight < this.validRect.y && !this.isValid(node, y)) {
|
|
204
|
+
y += rowHeight;
|
|
205
|
+
skipped++;
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
155
208
|
let layoutNode = this.buildChild(child, x, y);
|
|
156
209
|
y = layoutNode.layoutInfo.rect.maxY;
|
|
157
210
|
children.push(layoutNode);
|
|
211
|
+
if (y > this.validRect.maxY) {
|
|
212
|
+
// Estimate the remaining height for rows that we don't need to layout right now.
|
|
213
|
+
y += ([
|
|
214
|
+
...node.childNodes
|
|
215
|
+
].length - (children.length + skipped)) * rowHeight;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
158
218
|
}
|
|
159
219
|
rect.height = y - startY;
|
|
160
220
|
return {
|
|
161
221
|
header: header,
|
|
162
222
|
layoutInfo: layoutInfo,
|
|
163
|
-
children: children
|
|
223
|
+
children: children,
|
|
224
|
+
validRect: layoutInfo.rect.intersection(this.validRect)
|
|
164
225
|
};
|
|
165
226
|
}
|
|
166
227
|
buildItem(node, x, y) {
|
|
@@ -174,10 +235,8 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $cMJQZ$reactstatelyv
|
|
|
174
235
|
// or the content of the item changed.
|
|
175
236
|
let previousLayoutNode = this.layoutNodes.get(node.key);
|
|
176
237
|
if (previousLayoutNode) {
|
|
177
|
-
let curNode = this.collection.getItem(node.key);
|
|
178
|
-
let lastNode = this.lastCollection ? this.lastCollection.getItem(node.key) : null;
|
|
179
238
|
rectHeight = previousLayoutNode.layoutInfo.rect.height;
|
|
180
|
-
isEstimated = width !== this.lastWidth ||
|
|
239
|
+
isEstimated = width !== this.lastWidth || node !== previousLayoutNode.node || previousLayoutNode.layoutInfo.estimatedSize;
|
|
181
240
|
} else {
|
|
182
241
|
rectHeight = this.estimatedRowHeight;
|
|
183
242
|
isEstimated = true;
|
|
@@ -191,7 +250,8 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $cMJQZ$reactstatelyv
|
|
|
191
250
|
layoutInfo.allowOverflow = true;
|
|
192
251
|
layoutInfo.estimatedSize = isEstimated;
|
|
193
252
|
return {
|
|
194
|
-
layoutInfo: layoutInfo
|
|
253
|
+
layoutInfo: layoutInfo,
|
|
254
|
+
validRect: layoutInfo.rect
|
|
195
255
|
};
|
|
196
256
|
}
|
|
197
257
|
updateItemSize(key, size) {
|
|
@@ -218,8 +278,8 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $cMJQZ$reactstatelyv
|
|
|
218
278
|
updateLayoutNode(key, oldLayoutInfo, newLayoutInfo) {
|
|
219
279
|
let n = this.layoutNodes.get(key);
|
|
220
280
|
if (n) {
|
|
221
|
-
// Invalidate by
|
|
222
|
-
n.
|
|
281
|
+
// Invalidate by reseting validRect.
|
|
282
|
+
n.validRect = new (0, $cMJQZ$reactstatelyvirtualizer.Rect)();
|
|
223
283
|
// Replace layout info in LayoutNode
|
|
224
284
|
if (n.header === oldLayoutInfo) n.header = newLayoutInfo;
|
|
225
285
|
else if (n.layoutInfo === oldLayoutInfo) n.layoutInfo = newLayoutInfo;
|
|
@@ -368,6 +428,9 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $cMJQZ$reactstatelyv
|
|
|
368
428
|
this.lastWidth = 0;
|
|
369
429
|
this.lastCollection = null;
|
|
370
430
|
this.allowDisabledKeyFocus = options.allowDisabledKeyFocus;
|
|
431
|
+
this.lastValidRect = new (0, $cMJQZ$reactstatelyvirtualizer.Rect)();
|
|
432
|
+
this.validRect = new (0, $cMJQZ$reactstatelyvirtualizer.Rect)();
|
|
433
|
+
this.contentSize = new (0, $cMJQZ$reactstatelyvirtualizer.Size)();
|
|
371
434
|
}
|
|
372
435
|
}
|
|
373
436
|
|
|
@@ -386,17 +449,71 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $cMJQZ$reactstatelyv
|
|
|
386
449
|
|
|
387
450
|
|
|
388
451
|
class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$export$cacbb3924155d68e) {
|
|
389
|
-
|
|
452
|
+
shouldInvalidateEverything(invalidationContext) {
|
|
390
453
|
// If columns changed, clear layout cache.
|
|
391
|
-
|
|
392
|
-
|
|
454
|
+
return super.shouldInvalidateEverything(invalidationContext) || !this.lastCollection || this.collection.columns.length !== this.lastCollection.columns.length || this.collection.columns.some((c, i)=>c.key !== this.lastCollection.columns[i].key || c.props.width !== this.lastCollection.columns[i].props.width || c.props.minWidth !== this.lastCollection.columns[i].props.minWidth || c.props.maxWidth !== this.lastCollection.columns[i].props.maxWidth);
|
|
455
|
+
}
|
|
456
|
+
getResizerPosition() {
|
|
457
|
+
var ref;
|
|
458
|
+
return (ref = this.getLayoutInfo(this.resizingColumn)) === null || ref === void 0 ? void 0 : ref.rect.maxX;
|
|
459
|
+
}
|
|
460
|
+
getColumnWidth(key) {
|
|
461
|
+
var ref;
|
|
462
|
+
return (ref = this.columnLayout.getColumnWidth(key)) !== null && ref !== void 0 ? ref : 0;
|
|
463
|
+
}
|
|
464
|
+
getColumnMinWidth(key) {
|
|
465
|
+
let column = this.collection.columns.find((col)=>col.key === key);
|
|
466
|
+
if (!column) return 0;
|
|
467
|
+
return this.columnLayout.getColumnMinWidth(key);
|
|
468
|
+
}
|
|
469
|
+
getColumnMaxWidth(key) {
|
|
470
|
+
let column = this.collection.columns.find((col)=>col.key === key);
|
|
471
|
+
if (!column) return 0;
|
|
472
|
+
return this.columnLayout.getColumnMaxWidth(key);
|
|
473
|
+
}
|
|
474
|
+
// outside, where this is called, should call props.onColumnResizeStart...
|
|
475
|
+
onColumnResizeStart(key) {
|
|
476
|
+
this.resizingColumn = key;
|
|
477
|
+
}
|
|
478
|
+
// only way to call props.onColumnResize with the new size outside of Layout is to send the result back
|
|
479
|
+
onColumnResize(key, width) {
|
|
480
|
+
let newControlled = new Map(Array.from(this.controlledColumns).map(([key, entry])=>[
|
|
481
|
+
key,
|
|
482
|
+
entry.props.width
|
|
483
|
+
]));
|
|
484
|
+
let newSizes = this.columnLayout.resizeColumnWidth(this.virtualizer.visibleRect.width, this.collection, newControlled, this.uncontrolledWidths, key, width);
|
|
485
|
+
let map = new Map(Array.from(this.uncontrolledColumns).map(([key])=>[
|
|
486
|
+
key,
|
|
487
|
+
newSizes.get(key)
|
|
488
|
+
]));
|
|
489
|
+
map.set(key, width);
|
|
490
|
+
this.uncontrolledWidths = map;
|
|
491
|
+
// relayoutNow still uses setState, should happen at the same time the parent
|
|
492
|
+
// component's state is processed as a result of props.onColumnResize
|
|
493
|
+
if (this.uncontrolledWidths.size > 0) this.virtualizer.relayoutNow({
|
|
494
|
+
sizeChanged: true
|
|
495
|
+
});
|
|
496
|
+
return newSizes;
|
|
497
|
+
}
|
|
498
|
+
onColumnResizeEnd() {
|
|
499
|
+
this.resizingColumn = null;
|
|
500
|
+
}
|
|
501
|
+
buildCollection() {
|
|
393
502
|
// Track whether we were previously loading. This is used to adjust the animations of async loading vs inserts.
|
|
394
503
|
let loadingState = this.collection.body.props.loadingState;
|
|
395
504
|
this.wasLoading = this.isLoading;
|
|
396
505
|
this.isLoading = loadingState === "loading" || loadingState === "loadingMore";
|
|
506
|
+
this.stickyColumnIndices = [];
|
|
507
|
+
for (let column of this.collection.columns)// The selection cell and any other sticky columns always need to be visible.
|
|
508
|
+
// In addition, row headers need to be in the DOM for accessibility labeling.
|
|
509
|
+
if (column.props.isSelectionCell || this.collection.rowHeaderColumnKeys.has(column.key)) this.stickyColumnIndices.push(column.index);
|
|
510
|
+
let [controlledColumns, uncontrolledColumns] = this.columnLayout.splitColumnsIntoControlledAndUncontrolled(this.collection.columns);
|
|
511
|
+
this.controlledColumns = controlledColumns;
|
|
512
|
+
this.uncontrolledColumns = uncontrolledColumns;
|
|
513
|
+
let colWidths = this.columnLayout.recombineColumns(this.collection.columns, this.uncontrolledWidths, uncontrolledColumns, controlledColumns);
|
|
514
|
+
this.columnWidths = this.columnLayout.buildColumnWidths(this.virtualizer.visibleRect.width, this.collection, colWidths);
|
|
397
515
|
let header = this.buildHeader();
|
|
398
516
|
let body = this.buildBody(0);
|
|
399
|
-
this.stickyColumnIndices = this.collection.columns.filter((c)=>c.props.isSelectionCell || this.collection.rowHeaderColumnKeys.has(c.key)).map((c)=>c.index);
|
|
400
517
|
this.lastPersistedKeys = null;
|
|
401
518
|
body.layoutInfo.rect.width = Math.max(header.layoutInfo.rect.width, body.layoutInfo.rect.width);
|
|
402
519
|
this.contentSize = new (0, $cMJQZ$reactstatelyvirtualizer.Size)(body.layoutInfo.rect.width, body.layoutInfo.rect.maxY);
|
|
@@ -423,7 +540,8 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
423
540
|
this.layoutInfos.set("header", layoutInfo);
|
|
424
541
|
return {
|
|
425
542
|
layoutInfo: layoutInfo,
|
|
426
|
-
children: children
|
|
543
|
+
children: children,
|
|
544
|
+
validRect: layoutInfo.rect
|
|
427
545
|
};
|
|
428
546
|
}
|
|
429
547
|
buildHeaderRow(headerRow, x, y) {
|
|
@@ -444,7 +562,8 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
444
562
|
rect.width = x;
|
|
445
563
|
return {
|
|
446
564
|
layoutInfo: row,
|
|
447
|
-
children: columns
|
|
565
|
+
children: columns,
|
|
566
|
+
validRect: rect
|
|
448
567
|
};
|
|
449
568
|
}
|
|
450
569
|
setChildHeights(children, height) {
|
|
@@ -456,7 +575,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
456
575
|
}
|
|
457
576
|
}
|
|
458
577
|
// used to get the column widths when rendering to the DOM
|
|
459
|
-
|
|
578
|
+
getRenderedColumnWidth(node) {
|
|
460
579
|
var _colspan;
|
|
461
580
|
let colspan = (_colspan = node.colspan) !== null && _colspan !== void 0 ? _colspan : 1;
|
|
462
581
|
var _colIndex;
|
|
@@ -464,7 +583,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
464
583
|
let width = 0;
|
|
465
584
|
for(let i = colIndex; i < colIndex + colspan; i++){
|
|
466
585
|
let column = this.collection.columns[i];
|
|
467
|
-
if ((column === null || column === void 0 ? void 0 : column.key) != null) width += this.
|
|
586
|
+
if ((column === null || column === void 0 ? void 0 : column.key) != null) width += this.columnWidths.get(column.key);
|
|
468
587
|
}
|
|
469
588
|
return width;
|
|
470
589
|
}
|
|
@@ -477,10 +596,8 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
477
596
|
// or the content of the item changed.
|
|
478
597
|
let previousLayoutNode = this.layoutNodes.get(node.key);
|
|
479
598
|
if (previousLayoutNode) {
|
|
480
|
-
let curNode = this.collection.getItem(node.key);
|
|
481
|
-
let lastNode = this.lastCollection ? this.lastCollection.getItem(node.key) : null;
|
|
482
599
|
height = previousLayoutNode.layoutInfo.rect.height;
|
|
483
|
-
isEstimated =
|
|
600
|
+
isEstimated = node !== previousLayoutNode.node || width !== previousLayoutNode.layoutInfo.rect.width || previousLayoutNode.layoutInfo.estimatedSize;
|
|
484
601
|
} else {
|
|
485
602
|
height = estimatedHeight;
|
|
486
603
|
isEstimated = true;
|
|
@@ -493,7 +610,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
493
610
|
}
|
|
494
611
|
buildColumn(node, x, y) {
|
|
495
612
|
var ref;
|
|
496
|
-
let width = this.
|
|
613
|
+
let width = this.getRenderedColumnWidth(node);
|
|
497
614
|
let { height: height , isEstimated: isEstimated } = this.getEstimatedHeight(node, width, this.headingHeight, this.estimatedHeadingHeight);
|
|
498
615
|
let rect = new (0, $cMJQZ$reactstatelyvirtualizer.Rect)(x, y, width, height);
|
|
499
616
|
let layoutInfo = new (0, $cMJQZ$reactstatelyvirtualizer.LayoutInfo)(node.type, node.key, rect);
|
|
@@ -501,21 +618,36 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
501
618
|
layoutInfo.zIndex = layoutInfo.isSticky ? 2 : 1;
|
|
502
619
|
layoutInfo.estimatedSize = isEstimated;
|
|
503
620
|
return {
|
|
504
|
-
layoutInfo: layoutInfo
|
|
621
|
+
layoutInfo: layoutInfo,
|
|
622
|
+
validRect: layoutInfo.rect
|
|
505
623
|
};
|
|
506
624
|
}
|
|
507
625
|
buildBody(y) {
|
|
508
626
|
let rect = new (0, $cMJQZ$reactstatelyvirtualizer.Rect)(0, y, 0, 0);
|
|
509
627
|
let layoutInfo = new (0, $cMJQZ$reactstatelyvirtualizer.LayoutInfo)("rowgroup", "body", rect);
|
|
510
628
|
let startY = y;
|
|
629
|
+
let skipped = 0;
|
|
511
630
|
let width = 0;
|
|
512
631
|
let children = [];
|
|
513
632
|
for (let node of this.collection.body.childNodes){
|
|
633
|
+
var _rowHeight;
|
|
634
|
+
let rowHeight = ((_rowHeight = this.rowHeight) !== null && _rowHeight !== void 0 ? _rowHeight : this.estimatedRowHeight) + 1;
|
|
635
|
+
// Skip rows before the valid rectangle unless they are already cached.
|
|
636
|
+
if (y + rowHeight < this.validRect.y && !this.isValid(node, y)) {
|
|
637
|
+
y += rowHeight;
|
|
638
|
+
skipped++;
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
514
641
|
let layoutNode = this.buildChild(node, 0, y);
|
|
515
642
|
layoutNode.layoutInfo.parentKey = "body";
|
|
516
643
|
y = layoutNode.layoutInfo.rect.maxY;
|
|
517
644
|
width = Math.max(width, layoutNode.layoutInfo.rect.width);
|
|
518
645
|
children.push(layoutNode);
|
|
646
|
+
if (y > this.validRect.maxY) {
|
|
647
|
+
// Estimate the remaining height for rows that we don't need to layout right now.
|
|
648
|
+
y += (this.collection.size - (skipped + children.length)) * rowHeight;
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
519
651
|
}
|
|
520
652
|
if (this.isLoading) {
|
|
521
653
|
// Add some margin around the loader to ensure that scrollbars don't flicker in and out.
|
|
@@ -525,7 +657,8 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
525
657
|
loader.isSticky = !this.disableSticky && children.length === 0;
|
|
526
658
|
this.layoutInfos.set("loader", loader);
|
|
527
659
|
children.push({
|
|
528
|
-
layoutInfo: loader
|
|
660
|
+
layoutInfo: loader,
|
|
661
|
+
validRect: loader.rect
|
|
529
662
|
});
|
|
530
663
|
y = loader.rect.maxY;
|
|
531
664
|
width = Math.max(width, rect1.width);
|
|
@@ -536,7 +669,8 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
536
669
|
empty.isSticky = !this.disableSticky;
|
|
537
670
|
this.layoutInfos.set("empty", empty);
|
|
538
671
|
children.push({
|
|
539
|
-
layoutInfo: empty
|
|
672
|
+
layoutInfo: empty,
|
|
673
|
+
validRect: empty.rect
|
|
540
674
|
});
|
|
541
675
|
y = empty.rect.maxY;
|
|
542
676
|
width = Math.max(width, rect2.width);
|
|
@@ -546,7 +680,8 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
546
680
|
this.layoutInfos.set("body", layoutInfo);
|
|
547
681
|
return {
|
|
548
682
|
layoutInfo: layoutInfo,
|
|
549
|
-
children: children
|
|
683
|
+
children: children,
|
|
684
|
+
validRect: layoutInfo.rect.intersection(this.validRect)
|
|
550
685
|
};
|
|
551
686
|
}
|
|
552
687
|
buildNode(node, x, y) {
|
|
@@ -569,23 +704,32 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
569
704
|
let layoutInfo = new (0, $cMJQZ$reactstatelyvirtualizer.LayoutInfo)("row", node.key, rect);
|
|
570
705
|
let children = [];
|
|
571
706
|
let height = 0;
|
|
572
|
-
for (let child of node.childNodes){
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
707
|
+
for (let child of node.childNodes)if (x > this.validRect.maxX) {
|
|
708
|
+
// Adjust existing cached layoutInfo to ensure that it is out of view.
|
|
709
|
+
// This can happen due to column resizing.
|
|
710
|
+
let layoutNode = this.layoutNodes.get(child.key);
|
|
711
|
+
if (layoutNode) {
|
|
712
|
+
layoutNode.layoutInfo.rect.x = x;
|
|
713
|
+
x += layoutNode.layoutInfo.rect.width;
|
|
714
|
+
}
|
|
715
|
+
} else {
|
|
716
|
+
let layoutNode1 = this.buildChild(child, x, y);
|
|
717
|
+
x = layoutNode1.layoutInfo.rect.maxX;
|
|
718
|
+
height = Math.max(height, layoutNode1.layoutInfo.rect.height);
|
|
719
|
+
children.push(layoutNode1);
|
|
577
720
|
}
|
|
578
721
|
this.setChildHeights(children, height);
|
|
579
|
-
rect.width =
|
|
722
|
+
rect.width = this.layoutInfos.get("header").rect.width;
|
|
580
723
|
rect.height = height + 1; // +1 for bottom border
|
|
581
724
|
return {
|
|
582
725
|
layoutInfo: layoutInfo,
|
|
583
|
-
children: children
|
|
726
|
+
children: children,
|
|
727
|
+
validRect: rect.intersection(this.validRect)
|
|
584
728
|
};
|
|
585
729
|
}
|
|
586
730
|
buildCell(node, x, y) {
|
|
587
731
|
var ref;
|
|
588
|
-
let width = this.
|
|
732
|
+
let width = this.getRenderedColumnWidth(node);
|
|
589
733
|
let { height: height , isEstimated: isEstimated } = this.getEstimatedHeight(node, width, this.rowHeight, this.estimatedRowHeight);
|
|
590
734
|
let rect = new (0, $cMJQZ$reactstatelyvirtualizer.Rect)(x, y, width, height);
|
|
591
735
|
let layoutInfo = new (0, $cMJQZ$reactstatelyvirtualizer.LayoutInfo)(node.type, node.key, rect);
|
|
@@ -593,10 +737,18 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
593
737
|
layoutInfo.zIndex = layoutInfo.isSticky ? 2 : 1;
|
|
594
738
|
layoutInfo.estimatedSize = isEstimated;
|
|
595
739
|
return {
|
|
596
|
-
layoutInfo: layoutInfo
|
|
740
|
+
layoutInfo: layoutInfo,
|
|
741
|
+
validRect: rect
|
|
597
742
|
};
|
|
598
743
|
}
|
|
599
744
|
getVisibleLayoutInfos(rect) {
|
|
745
|
+
// If layout hasn't yet been done for the requested rect, union the
|
|
746
|
+
// new rect with the existing valid rect, and recompute.
|
|
747
|
+
if (!this.validRect.containsRect(rect) && this.lastCollection) {
|
|
748
|
+
this.lastValidRect = this.validRect;
|
|
749
|
+
this.validRect = this.validRect.union(rect);
|
|
750
|
+
this.rootNodes = this.buildCollection();
|
|
751
|
+
}
|
|
600
752
|
let res = [];
|
|
601
753
|
this.buildPersistedIndices();
|
|
602
754
|
for (let node of this.rootNodes){
|
|
@@ -623,8 +775,10 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
623
775
|
let persistIndex = 0;
|
|
624
776
|
while(persistedRowIndices && persistIndex < persistedRowIndices.length && persistedRowIndices[persistIndex] < firstVisibleRow){
|
|
625
777
|
let idx = persistedRowIndices[persistIndex];
|
|
626
|
-
|
|
627
|
-
|
|
778
|
+
if (idx < node.children.length) {
|
|
779
|
+
res.push(node.children[idx].layoutInfo);
|
|
780
|
+
this.addVisibleLayoutInfos(res, node.children[idx], rect);
|
|
781
|
+
}
|
|
628
782
|
persistIndex++;
|
|
629
783
|
}
|
|
630
784
|
for(let i = firstVisibleRow; i <= lastVisibleRow; i++){
|
|
@@ -636,7 +790,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
636
790
|
// Add persisted rows after the visible rows.
|
|
637
791
|
while(persistedRowIndices && persistIndex < persistedRowIndices.length){
|
|
638
792
|
let idx1 = persistedRowIndices[persistIndex++];
|
|
639
|
-
res.push(node.children[idx1].layoutInfo);
|
|
793
|
+
if (idx1 < node.children.length) res.push(node.children[idx1].layoutInfo);
|
|
640
794
|
}
|
|
641
795
|
break;
|
|
642
796
|
}
|
|
@@ -650,7 +804,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
650
804
|
let persistedCellIndices = this.persistedIndices.get(node.layoutInfo.key) || this.stickyColumnIndices;
|
|
651
805
|
while(stickyIndex < persistedCellIndices.length && persistedCellIndices[stickyIndex] < firstVisibleCell){
|
|
652
806
|
let idx2 = persistedCellIndices[stickyIndex];
|
|
653
|
-
res.push(node.children[idx2].layoutInfo);
|
|
807
|
+
if (idx2 < node.children.length) res.push(node.children[idx2].layoutInfo);
|
|
654
808
|
stickyIndex++;
|
|
655
809
|
}
|
|
656
810
|
for(let i1 = firstVisibleCell; i1 <= lastVisibleCell; i1++){
|
|
@@ -661,7 +815,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
661
815
|
// Add any remaining sticky cells after the visible cells.
|
|
662
816
|
while(stickyIndex < persistedCellIndices.length){
|
|
663
817
|
let idx3 = persistedCellIndices[stickyIndex++];
|
|
664
|
-
res.push(node.children[idx3].layoutInfo);
|
|
818
|
+
if (idx3 < node.children.length) res.push(node.children[idx3].layoutInfo);
|
|
665
819
|
}
|
|
666
820
|
break;
|
|
667
821
|
}
|
|
@@ -728,12 +882,19 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
728
882
|
}
|
|
729
883
|
constructor(options){
|
|
730
884
|
super(options);
|
|
885
|
+
(0, $67c493497dcda343$import$d76420afe0f7f8c4$2e2bcd8739ae039)(this, "columnWidths", new Map());
|
|
731
886
|
(0, $67c493497dcda343$import$d76420afe0f7f8c4$2e2bcd8739ae039)(this, "wasLoading", false);
|
|
732
887
|
(0, $67c493497dcda343$import$d76420afe0f7f8c4$2e2bcd8739ae039)(this, "isLoading", false);
|
|
733
888
|
(0, $67c493497dcda343$import$d76420afe0f7f8c4$2e2bcd8739ae039)(this, "lastPersistedKeys", null);
|
|
734
889
|
(0, $67c493497dcda343$import$d76420afe0f7f8c4$2e2bcd8739ae039)(this, "persistedIndices", new Map());
|
|
890
|
+
this.collection = options.initialCollection;
|
|
735
891
|
this.stickyColumnIndices = [];
|
|
736
892
|
this.disableSticky = this.checkChrome105();
|
|
893
|
+
this.columnLayout = options.columnLayout;
|
|
894
|
+
let [controlledColumns, uncontrolledColumns] = this.columnLayout.splitColumnsIntoControlledAndUncontrolled(this.collection.columns);
|
|
895
|
+
this.controlledColumns = controlledColumns;
|
|
896
|
+
this.uncontrolledColumns = uncontrolledColumns;
|
|
897
|
+
this.uncontrolledWidths = this.columnLayout.getInitialUncontrolledWidths(uncontrolledColumns);
|
|
737
898
|
}
|
|
738
899
|
}
|
|
739
900
|
|