@react-stately/virtualizer 3.2.3-nightly.3402 → 3.2.3-nightly.3412
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 +31 -30
- package/dist/main.js.map +1 -1
- package/dist/module.js +31 -30
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +5 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/Virtualizer.ts +38 -38
- package/src/utils.ts +19 -0
package/dist/main.js
CHANGED
|
@@ -330,6 +330,14 @@ function $abed55ea619a7a17$export$6897c284b6f9f4dc(object) {
|
|
|
330
330
|
for(let key in object)res[object[key]] = key;
|
|
331
331
|
return res;
|
|
332
332
|
}
|
|
333
|
+
function $abed55ea619a7a17$export$a8d0d0c8d1c5df64(a, b) {
|
|
334
|
+
if (a === b) return true;
|
|
335
|
+
if (a.size !== b.size) return false;
|
|
336
|
+
for (let key of a){
|
|
337
|
+
if (!b.has(key)) return false;
|
|
338
|
+
}
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
333
341
|
|
|
334
342
|
|
|
335
343
|
|
|
@@ -486,23 +494,27 @@ class $e1bc15d49d21df0e$export$89be5a243e59c4b2 {
|
|
|
486
494
|
*/ getItem(key) {
|
|
487
495
|
return this._collection ? this._collection.getItem(key) : null;
|
|
488
496
|
}
|
|
489
|
-
/**
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (this._persistedKeys.size !== persistedKeys.size) setsNotEqual = true;
|
|
495
|
-
else {
|
|
496
|
-
for (var existingKey of this._persistedKeys)if (!persistedKeys.has(existingKey)) {
|
|
497
|
-
setsNotEqual = true;
|
|
498
|
-
break;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
if (setsNotEqual) {
|
|
497
|
+
/** The set of persisted keys are always present in the DOM, even if not currently in view. */ get persistedKeys() {
|
|
498
|
+
return this._persistedKeys;
|
|
499
|
+
}
|
|
500
|
+
/** The set of persisted keys are always present in the DOM, even if not currently in view. */ set persistedKeys(persistedKeys) {
|
|
501
|
+
if (!$abed55ea619a7a17$export$a8d0d0c8d1c5df64(persistedKeys, this._persistedKeys)) {
|
|
502
502
|
this._persistedKeys = persistedKeys;
|
|
503
503
|
this.updateSubviews();
|
|
504
504
|
}
|
|
505
505
|
}
|
|
506
|
+
/** Returns whether the given key, or an ancestor, is persisted. */ isPersistedKey(key) {
|
|
507
|
+
// Quick check if the key is directly in the set of persisted keys.
|
|
508
|
+
if (this._persistedKeys.has(key)) return true;
|
|
509
|
+
// If not, check if the key is an ancestor of any of the persisted keys.
|
|
510
|
+
for (let k of this._persistedKeys)while(k != null){
|
|
511
|
+
let layoutInfo = this.layout.getLayoutInfo(k);
|
|
512
|
+
if (!layoutInfo) break;
|
|
513
|
+
k = layoutInfo.parentKey;
|
|
514
|
+
if (k === key) return true;
|
|
515
|
+
}
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
506
518
|
/**
|
|
507
519
|
* Get the collection view's layout.
|
|
508
520
|
*/ get layout() {
|
|
@@ -611,9 +623,12 @@ class $e1bc15d49d21df0e$export$89be5a243e59c4b2 {
|
|
|
611
623
|
*/ keyAtPoint(point) {
|
|
612
624
|
let rect = new $41b7691783731623$export$c79fc6492f3af13d(point.x, point.y, 1, 1);
|
|
613
625
|
let layoutInfos = this.layout.getVisibleLayoutInfos(rect);
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
626
|
+
// Layout may return multiple layout infos in the case of
|
|
627
|
+
// persisted keys, so find the first one that actually intersects.
|
|
628
|
+
for (let layoutInfo of layoutInfos){
|
|
629
|
+
if (layoutInfo.rect.intersects(rect)) return layoutInfo.key;
|
|
630
|
+
}
|
|
631
|
+
return null;
|
|
617
632
|
}
|
|
618
633
|
/**
|
|
619
634
|
* Cleanup for when the Virtualizer will be unmounted.
|
|
@@ -800,20 +815,6 @@ class $e1bc15d49d21df0e$export$89be5a243e59c4b2 {
|
|
|
800
815
|
}
|
|
801
816
|
return map;
|
|
802
817
|
}
|
|
803
|
-
isPersistedKey(node) {
|
|
804
|
-
let keyFound = this._persistedKeys.has(node.layoutInfo.key);
|
|
805
|
-
// for components like Table, where we have rows with cells as children,
|
|
806
|
-
// if the key isn't found at the top level (row in this example), check
|
|
807
|
-
// the children of this node to see if a child is persisted. If a child
|
|
808
|
-
// of this node is a persisted key we consider this node as "persistable."
|
|
809
|
-
if (!keyFound && node.children && node.node.type !== 'section') {
|
|
810
|
-
for (let child of node.children)if (this._persistedKeys.has(child.layoutInfo.key)) {
|
|
811
|
-
keyFound = true;
|
|
812
|
-
break;
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
return keyFound;
|
|
816
|
-
}
|
|
817
818
|
updateSubviews(forceUpdate = false) {
|
|
818
819
|
if (!this._collection) return;
|
|
819
820
|
let visibleLayoutInfos = this.getVisibleLayoutInfos();
|