@react-stately/layout 3.5.0 → 3.5.1-nightly.3287
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 +304 -5
- package/dist/main.js.map +1 -1
- package/dist/module.js +300 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +32 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +2 -2
package/dist/main.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
var $cMJQZ$reactstatelyvirtualizer = require("@react-stately/virtualizer");
|
|
2
2
|
|
|
3
|
-
function $parcel$export(e, n, v, s) {
|
|
4
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
5
|
-
}
|
|
6
3
|
function $parcel$exportWildcard(dest, source) {
|
|
7
4
|
Object.keys(source).forEach(function(key) {
|
|
8
5
|
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
@@ -19,8 +16,9 @@ function $parcel$exportWildcard(dest, source) {
|
|
|
19
16
|
|
|
20
17
|
return dest;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
function $parcel$export(e, n, v, s) {
|
|
20
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
21
|
+
}
|
|
24
22
|
var $fe69e47e38ed0ac4$exports = {};
|
|
25
23
|
|
|
26
24
|
$parcel$export($fe69e47e38ed0ac4$exports, "ListLayout", () => $fe69e47e38ed0ac4$export$cacbb3924155d68e);
|
|
@@ -361,6 +359,305 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends $cMJQZ$reactstatelyvirtu
|
|
|
361
359
|
}
|
|
362
360
|
|
|
363
361
|
|
|
362
|
+
var $67c493497dcda343$exports = {};
|
|
363
|
+
|
|
364
|
+
$parcel$export($67c493497dcda343$exports, "TableLayout", () => $67c493497dcda343$export$62444c3c724b1b20);
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
class $67c493497dcda343$export$62444c3c724b1b20 extends $fe69e47e38ed0ac4$export$cacbb3924155d68e {
|
|
368
|
+
buildCollection() {
|
|
369
|
+
// If columns changed, clear layout cache.
|
|
370
|
+
if (!this.lastCollection || this.collection.columns.length !== this.lastCollection.columns.length || this.collection.columns.some((c, i)=>c.key !== this.lastCollection.columns[i].key
|
|
371
|
+
)) // Invalidate everything in this layout pass. Will be reset in ListLayout on the next pass.
|
|
372
|
+
this.invalidateEverything = true;
|
|
373
|
+
// Track whether we were previously loading. This is used to adjust the animations of async loading vs inserts.
|
|
374
|
+
let loadingState = this.collection.body.props.loadingState;
|
|
375
|
+
this.wasLoading = this.isLoading;
|
|
376
|
+
this.isLoading = loadingState === 'loading' || loadingState === 'loadingMore';
|
|
377
|
+
let header = this.buildHeader();
|
|
378
|
+
let body = this.buildBody(0);
|
|
379
|
+
this.stickyColumnIndices = this.collection.columns.filter((c)=>c.props.isSelectionCell || this.collection.rowHeaderColumnKeys.has(c.key)
|
|
380
|
+
).map((c)=>c.index
|
|
381
|
+
);
|
|
382
|
+
body.layoutInfo.rect.width = Math.max(header.layoutInfo.rect.width, body.layoutInfo.rect.width);
|
|
383
|
+
this.contentSize = new $cMJQZ$reactstatelyvirtualizer.Size(body.layoutInfo.rect.width, body.layoutInfo.rect.maxY);
|
|
384
|
+
return [
|
|
385
|
+
header,
|
|
386
|
+
body
|
|
387
|
+
];
|
|
388
|
+
}
|
|
389
|
+
buildHeader() {
|
|
390
|
+
let rect = new $cMJQZ$reactstatelyvirtualizer.Rect(0, 0, 0, 0);
|
|
391
|
+
let layoutInfo = new $cMJQZ$reactstatelyvirtualizer.LayoutInfo('header', 'header', rect);
|
|
392
|
+
let y = 0;
|
|
393
|
+
let width = 0;
|
|
394
|
+
let children = [];
|
|
395
|
+
for (let headerRow of this.collection.headerRows){
|
|
396
|
+
let layoutNode = this.buildChild(headerRow, 0, y);
|
|
397
|
+
layoutNode.layoutInfo.parentKey = 'header';
|
|
398
|
+
y = layoutNode.layoutInfo.rect.maxY;
|
|
399
|
+
width = Math.max(width, layoutNode.layoutInfo.rect.width);
|
|
400
|
+
children.push(layoutNode);
|
|
401
|
+
}
|
|
402
|
+
rect.width = width;
|
|
403
|
+
rect.height = y;
|
|
404
|
+
this.layoutInfos.set('header', layoutInfo);
|
|
405
|
+
return {
|
|
406
|
+
layoutInfo: layoutInfo,
|
|
407
|
+
children: children
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
buildHeaderRow(headerRow, x, y) {
|
|
411
|
+
let rect = new $cMJQZ$reactstatelyvirtualizer.Rect(0, y, 0, 0);
|
|
412
|
+
let row = new $cMJQZ$reactstatelyvirtualizer.LayoutInfo('headerrow', headerRow.key, rect);
|
|
413
|
+
let height = 0;
|
|
414
|
+
let columns = [];
|
|
415
|
+
for (let cell of headerRow.childNodes){
|
|
416
|
+
let layoutNode = this.buildChild(cell, x, y);
|
|
417
|
+
layoutNode.layoutInfo.parentKey = row.key;
|
|
418
|
+
x = layoutNode.layoutInfo.rect.maxX;
|
|
419
|
+
height = Math.max(height, layoutNode.layoutInfo.rect.height);
|
|
420
|
+
columns.push(layoutNode);
|
|
421
|
+
}
|
|
422
|
+
this.setChildHeights(columns, height);
|
|
423
|
+
rect.height = height;
|
|
424
|
+
rect.width = x;
|
|
425
|
+
return {
|
|
426
|
+
layoutInfo: row,
|
|
427
|
+
children: columns
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
setChildHeights(children, height) {
|
|
431
|
+
for (let child of children)if (child.layoutInfo.rect.height !== height) {
|
|
432
|
+
// Need to copy the layout info before we mutate it.
|
|
433
|
+
child.layoutInfo = child.layoutInfo.copy();
|
|
434
|
+
this.layoutInfos.set(child.layoutInfo.key, child.layoutInfo);
|
|
435
|
+
child.layoutInfo.rect.height = height;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
// used to get the column widths when rendering to the DOM
|
|
439
|
+
getColumnWidth_(node) {
|
|
440
|
+
var _colspan;
|
|
441
|
+
let colspan = (_colspan = node.colspan) !== null && _colspan !== void 0 ? _colspan : 1;
|
|
442
|
+
let width = 0;
|
|
443
|
+
for(let i = node.index; i < node.index + colspan; i++){
|
|
444
|
+
let column = this.collection.columns[i];
|
|
445
|
+
width += this.getColumnWidth(column.key);
|
|
446
|
+
}
|
|
447
|
+
return width;
|
|
448
|
+
}
|
|
449
|
+
getEstimatedHeight(node, width, height, estimatedHeight) {
|
|
450
|
+
let isEstimated = false;
|
|
451
|
+
// If no explicit height is available, use an estimated height.
|
|
452
|
+
if (height == null) {
|
|
453
|
+
// If a previous version of this layout info exists, reuse its height.
|
|
454
|
+
// Mark as estimated if the size of the overall collection view changed,
|
|
455
|
+
// or the content of the item changed.
|
|
456
|
+
let previousLayoutNode = this.layoutNodes.get(node.key);
|
|
457
|
+
if (previousLayoutNode) {
|
|
458
|
+
let curNode = this.collection.getItem(node.key);
|
|
459
|
+
let lastNode = this.lastCollection ? this.lastCollection.getItem(node.key) : null;
|
|
460
|
+
height = previousLayoutNode.layoutInfo.rect.height;
|
|
461
|
+
isEstimated = curNode !== lastNode || width !== previousLayoutNode.layoutInfo.rect.width || previousLayoutNode.layoutInfo.estimatedSize;
|
|
462
|
+
} else {
|
|
463
|
+
height = estimatedHeight;
|
|
464
|
+
isEstimated = true;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return {
|
|
468
|
+
height: height,
|
|
469
|
+
isEstimated: isEstimated
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
buildColumn(node, x, y) {
|
|
473
|
+
var ref;
|
|
474
|
+
let width = this.getColumnWidth_(node);
|
|
475
|
+
let { height: height , isEstimated: isEstimated } = this.getEstimatedHeight(node, width, this.headingHeight, this.estimatedHeadingHeight);
|
|
476
|
+
let rect = new $cMJQZ$reactstatelyvirtualizer.Rect(x, y, width, height);
|
|
477
|
+
let layoutInfo = new $cMJQZ$reactstatelyvirtualizer.LayoutInfo(node.type, node.key, rect);
|
|
478
|
+
layoutInfo.isSticky = (ref = node.props) === null || ref === void 0 ? void 0 : ref.isSelectionCell;
|
|
479
|
+
layoutInfo.zIndex = layoutInfo.isSticky ? 2 : 1;
|
|
480
|
+
layoutInfo.estimatedSize = isEstimated;
|
|
481
|
+
return {
|
|
482
|
+
layoutInfo: layoutInfo
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
buildBody(y) {
|
|
486
|
+
let rect = new $cMJQZ$reactstatelyvirtualizer.Rect(0, y, 0, 0);
|
|
487
|
+
let layoutInfo = new $cMJQZ$reactstatelyvirtualizer.LayoutInfo('rowgroup', 'body', rect);
|
|
488
|
+
let startY = y;
|
|
489
|
+
let width = 0;
|
|
490
|
+
let children = [];
|
|
491
|
+
for (let node of this.collection.body.childNodes){
|
|
492
|
+
let layoutNode = this.buildChild(node, 0, y);
|
|
493
|
+
layoutNode.layoutInfo.parentKey = 'body';
|
|
494
|
+
y = layoutNode.layoutInfo.rect.maxY;
|
|
495
|
+
width = Math.max(width, layoutNode.layoutInfo.rect.width);
|
|
496
|
+
children.push(layoutNode);
|
|
497
|
+
}
|
|
498
|
+
if (this.isLoading) {
|
|
499
|
+
let rect = new $cMJQZ$reactstatelyvirtualizer.Rect(0, y, width || this.virtualizer.visibleRect.width, children.length === 0 ? this.virtualizer.visibleRect.height : 60);
|
|
500
|
+
let loader = new $cMJQZ$reactstatelyvirtualizer.LayoutInfo('loader', 'loader', rect);
|
|
501
|
+
loader.parentKey = 'body';
|
|
502
|
+
loader.isSticky = children.length === 0;
|
|
503
|
+
this.layoutInfos.set('loader', loader);
|
|
504
|
+
children.push({
|
|
505
|
+
layoutInfo: loader
|
|
506
|
+
});
|
|
507
|
+
y = loader.rect.maxY;
|
|
508
|
+
width = Math.max(width, rect.width);
|
|
509
|
+
} else if (children.length === 0) {
|
|
510
|
+
let rect = new $cMJQZ$reactstatelyvirtualizer.Rect(0, y, this.virtualizer.visibleRect.width, this.virtualizer.visibleRect.height);
|
|
511
|
+
let empty = new $cMJQZ$reactstatelyvirtualizer.LayoutInfo('empty', 'empty', rect);
|
|
512
|
+
empty.parentKey = 'body';
|
|
513
|
+
empty.isSticky = true;
|
|
514
|
+
this.layoutInfos.set('empty', empty);
|
|
515
|
+
children.push({
|
|
516
|
+
layoutInfo: empty
|
|
517
|
+
});
|
|
518
|
+
y = empty.rect.maxY;
|
|
519
|
+
width = Math.max(width, rect.width);
|
|
520
|
+
}
|
|
521
|
+
rect.width = width;
|
|
522
|
+
rect.height = y - startY;
|
|
523
|
+
this.layoutInfos.set('body', layoutInfo);
|
|
524
|
+
return {
|
|
525
|
+
layoutInfo: layoutInfo,
|
|
526
|
+
children: children
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
buildNode(node, x, y) {
|
|
530
|
+
switch(node.type){
|
|
531
|
+
case 'headerrow':
|
|
532
|
+
return this.buildHeaderRow(node, x, y);
|
|
533
|
+
case 'item':
|
|
534
|
+
return this.buildRow(node, x, y);
|
|
535
|
+
case 'column':
|
|
536
|
+
case 'placeholder':
|
|
537
|
+
return this.buildColumn(node, x, y);
|
|
538
|
+
case 'cell':
|
|
539
|
+
return this.buildCell(node, x, y);
|
|
540
|
+
default:
|
|
541
|
+
throw new Error('Unknown node type ' + node.type);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
buildRow(node, x, y) {
|
|
545
|
+
let rect = new $cMJQZ$reactstatelyvirtualizer.Rect(x, y, 0, 0);
|
|
546
|
+
let layoutInfo = new $cMJQZ$reactstatelyvirtualizer.LayoutInfo('row', node.key, rect);
|
|
547
|
+
let children = [];
|
|
548
|
+
let height = 0;
|
|
549
|
+
for (let child of node.childNodes){
|
|
550
|
+
let layoutNode = this.buildChild(child, x, y);
|
|
551
|
+
x = layoutNode.layoutInfo.rect.maxX;
|
|
552
|
+
height = Math.max(height, layoutNode.layoutInfo.rect.height);
|
|
553
|
+
children.push(layoutNode);
|
|
554
|
+
}
|
|
555
|
+
this.setChildHeights(children, height);
|
|
556
|
+
rect.width = x;
|
|
557
|
+
rect.height = height + 1; // +1 for bottom border
|
|
558
|
+
return {
|
|
559
|
+
layoutInfo: layoutInfo,
|
|
560
|
+
children: children
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
buildCell(node, x, y) {
|
|
564
|
+
var ref;
|
|
565
|
+
let width = this.getColumnWidth_(node);
|
|
566
|
+
let { height: height , isEstimated: isEstimated } = this.getEstimatedHeight(node, width, this.rowHeight, this.estimatedRowHeight);
|
|
567
|
+
let rect = new $cMJQZ$reactstatelyvirtualizer.Rect(x, y, width, height);
|
|
568
|
+
let layoutInfo = new $cMJQZ$reactstatelyvirtualizer.LayoutInfo(node.type, node.key, rect);
|
|
569
|
+
layoutInfo.isSticky = (ref = node.props) === null || ref === void 0 ? void 0 : ref.isSelectionCell;
|
|
570
|
+
layoutInfo.zIndex = layoutInfo.isSticky ? 2 : 1;
|
|
571
|
+
layoutInfo.estimatedSize = isEstimated;
|
|
572
|
+
return {
|
|
573
|
+
layoutInfo: layoutInfo
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
getVisibleLayoutInfos(rect) {
|
|
577
|
+
let res = [];
|
|
578
|
+
for (let node of this.rootNodes){
|
|
579
|
+
res.push(node.layoutInfo);
|
|
580
|
+
this.addVisibleLayoutInfos(res, node, rect);
|
|
581
|
+
}
|
|
582
|
+
return res;
|
|
583
|
+
}
|
|
584
|
+
addVisibleLayoutInfos(res, node, rect) {
|
|
585
|
+
if (!node.children || node.children.length === 0) return;
|
|
586
|
+
switch(node.layoutInfo.type){
|
|
587
|
+
case 'header':
|
|
588
|
+
for (let child of node.children){
|
|
589
|
+
res.push(child.layoutInfo);
|
|
590
|
+
this.addVisibleLayoutInfos(res, child, rect);
|
|
591
|
+
}
|
|
592
|
+
break;
|
|
593
|
+
case 'rowgroup':
|
|
594
|
+
{
|
|
595
|
+
let firstVisibleRow = this.binarySearch(node.children, rect.topLeft, 'y');
|
|
596
|
+
let lastVisibleRow = this.binarySearch(node.children, rect.bottomRight, 'y');
|
|
597
|
+
for(let i = firstVisibleRow; i <= lastVisibleRow; i++){
|
|
598
|
+
res.push(node.children[i].layoutInfo);
|
|
599
|
+
this.addVisibleLayoutInfos(res, node.children[i], rect);
|
|
600
|
+
}
|
|
601
|
+
break;
|
|
602
|
+
}
|
|
603
|
+
case 'headerrow':
|
|
604
|
+
case 'row':
|
|
605
|
+
{
|
|
606
|
+
let firstVisibleCell = this.binarySearch(node.children, rect.topLeft, 'x');
|
|
607
|
+
let lastVisibleCell = this.binarySearch(node.children, rect.topRight, 'x');
|
|
608
|
+
let stickyIndex = 0;
|
|
609
|
+
for(let i = firstVisibleCell; i <= lastVisibleCell; i++){
|
|
610
|
+
// Sticky columns and row headers are always in the DOM. Interleave these
|
|
611
|
+
// with the visible range so that they are in the right order.
|
|
612
|
+
if (stickyIndex < this.stickyColumnIndices.length) {
|
|
613
|
+
let idx = this.stickyColumnIndices[stickyIndex];
|
|
614
|
+
while(idx < i){
|
|
615
|
+
res.push(node.children[idx].layoutInfo);
|
|
616
|
+
idx = this.stickyColumnIndices[stickyIndex++];
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
res.push(node.children[i].layoutInfo);
|
|
620
|
+
}
|
|
621
|
+
while(stickyIndex < this.stickyColumnIndices.length){
|
|
622
|
+
let idx = this.stickyColumnIndices[stickyIndex++];
|
|
623
|
+
res.push(node.children[idx].layoutInfo);
|
|
624
|
+
}
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
default:
|
|
628
|
+
throw new Error('Unknown node type ' + node.layoutInfo.type);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
binarySearch(items, point, axis) {
|
|
632
|
+
let low = 0;
|
|
633
|
+
let high = items.length - 1;
|
|
634
|
+
while(low <= high){
|
|
635
|
+
let mid = low + high >> 1;
|
|
636
|
+
let item = items[mid];
|
|
637
|
+
if (axis === 'x' && item.layoutInfo.rect.maxX < point.x || axis === 'y' && item.layoutInfo.rect.maxY < point.y) low = mid + 1;
|
|
638
|
+
else if (axis === 'x' && item.layoutInfo.rect.x > point.x || axis === 'y' && item.layoutInfo.rect.y > point.y) high = mid - 1;
|
|
639
|
+
else return mid;
|
|
640
|
+
}
|
|
641
|
+
return Math.max(0, Math.min(items.length - 1, low));
|
|
642
|
+
}
|
|
643
|
+
getInitialLayoutInfo(layoutInfo) {
|
|
644
|
+
let res = super.getInitialLayoutInfo(layoutInfo);
|
|
645
|
+
// If this insert was the result of async loading, remove the zoom effect and just keep the fade in.
|
|
646
|
+
if (this.wasLoading) res.transform = null;
|
|
647
|
+
return res;
|
|
648
|
+
}
|
|
649
|
+
constructor(options){
|
|
650
|
+
super(options);
|
|
651
|
+
this.wasLoading = false;
|
|
652
|
+
this.isLoading = false;
|
|
653
|
+
this.stickyColumnIndices = [];
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
var $8cf5b1c755e3d109$exports = {};
|
|
659
|
+
|
|
660
|
+
$parcel$export($8cf5b1c755e3d109$exports, "TableLayout_DEPRECATED", () => $8cf5b1c755e3d109$export$7e9c3f5c8fff54f);
|
|
364
661
|
|
|
365
662
|
|
|
366
663
|
class $8cf5b1c755e3d109$export$7e9c3f5c8fff54f extends $fe69e47e38ed0ac4$export$cacbb3924155d68e {
|
|
@@ -693,6 +990,8 @@ class $8cf5b1c755e3d109$export$7e9c3f5c8fff54f extends $fe69e47e38ed0ac4$export$
|
|
|
693
990
|
|
|
694
991
|
|
|
695
992
|
$parcel$exportWildcard(module.exports, $fe69e47e38ed0ac4$exports);
|
|
993
|
+
$parcel$exportWildcard(module.exports, $67c493497dcda343$exports);
|
|
994
|
+
$parcel$exportWildcard(module.exports, $8cf5b1c755e3d109$exports);
|
|
696
995
|
|
|
697
996
|
|
|
698
997
|
//# sourceMappingURL=main.js.map
|