@react-stately/virtualizer 4.4.6 → 4.5.1

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 (71) hide show
  1. package/dist/import.mjs +2 -14
  2. package/dist/main.js +8 -20
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +2 -14
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +2 -0
  7. package/package.json +27 -20
  8. package/src/index.ts +14 -11
  9. package/dist/Layout.main.js +0 -54
  10. package/dist/Layout.main.js.map +0 -1
  11. package/dist/Layout.mjs +0 -49
  12. package/dist/Layout.module.js +0 -49
  13. package/dist/Layout.module.js.map +0 -1
  14. package/dist/LayoutInfo.main.js +0 -52
  15. package/dist/LayoutInfo.main.js.map +0 -1
  16. package/dist/LayoutInfo.mjs +0 -47
  17. package/dist/LayoutInfo.module.js +0 -47
  18. package/dist/LayoutInfo.module.js.map +0 -1
  19. package/dist/OverscanManager.main.js +0 -52
  20. package/dist/OverscanManager.main.js.map +0 -1
  21. package/dist/OverscanManager.mjs +0 -47
  22. package/dist/OverscanManager.module.js +0 -47
  23. package/dist/OverscanManager.module.js.map +0 -1
  24. package/dist/Point.main.js +0 -40
  25. package/dist/Point.main.js.map +0 -1
  26. package/dist/Point.mjs +0 -35
  27. package/dist/Point.module.js +0 -35
  28. package/dist/Point.module.js.map +0 -1
  29. package/dist/Rect.main.js +0 -131
  30. package/dist/Rect.main.js.map +0 -1
  31. package/dist/Rect.mjs +0 -126
  32. package/dist/Rect.module.js +0 -126
  33. package/dist/Rect.module.js.map +0 -1
  34. package/dist/ReusableView.main.js +0 -69
  35. package/dist/ReusableView.main.js.map +0 -1
  36. package/dist/ReusableView.mjs +0 -63
  37. package/dist/ReusableView.module.js +0 -63
  38. package/dist/ReusableView.module.js.map +0 -1
  39. package/dist/Size.main.js +0 -40
  40. package/dist/Size.main.js.map +0 -1
  41. package/dist/Size.mjs +0 -35
  42. package/dist/Size.module.js +0 -35
  43. package/dist/Size.module.js.map +0 -1
  44. package/dist/Virtualizer.main.js +0 -239
  45. package/dist/Virtualizer.main.js.map +0 -1
  46. package/dist/Virtualizer.mjs +0 -234
  47. package/dist/Virtualizer.module.js +0 -234
  48. package/dist/Virtualizer.module.js.map +0 -1
  49. package/dist/types.d.ts +0 -368
  50. package/dist/types.d.ts.map +0 -1
  51. package/dist/useVirtualizerState.main.js +0 -101
  52. package/dist/useVirtualizerState.main.js.map +0 -1
  53. package/dist/useVirtualizerState.mjs +0 -92
  54. package/dist/useVirtualizerState.module.js +0 -92
  55. package/dist/useVirtualizerState.module.js.map +0 -1
  56. package/dist/utils.main.js +0 -27
  57. package/dist/utils.main.js.map +0 -1
  58. package/dist/utils.mjs +0 -22
  59. package/dist/utils.module.js +0 -22
  60. package/dist/utils.module.js.map +0 -1
  61. package/src/Layout.ts +0 -101
  62. package/src/LayoutInfo.ts +0 -118
  63. package/src/OverscanManager.ts +0 -56
  64. package/src/Point.ts +0 -45
  65. package/src/Rect.ts +0 -193
  66. package/src/ReusableView.ts +0 -98
  67. package/src/Size.ts +0 -43
  68. package/src/Virtualizer.ts +0 -363
  69. package/src/types.ts +0 -44
  70. package/src/useVirtualizerState.ts +0 -120
  71. package/src/utils.ts +0 -30
@@ -1 +0,0 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAUM,MAAM;IAoBX;;GAEC,GACD,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK;IAC5B;IAEA;;GAEC,GACD,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM;IAC7B;IAEA;;GAEC,GACD,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM;IACjC;IAEA;;GAEC,GACD,IAAI,UAAiB;QACnB,OAAO,IAAI,CAAA,GAAA,yCAAI,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC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AI,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC;QAChC,IAAI,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC;QAChC,OAAO,IAAI,0CACT,GACA,GACA,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI,GAClC,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI;IAEtC;IAEA;;GAEC,GACD,OAAa;QACX,OAAO,IAAI,0CAAK,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM;IACzD;IA9JA,YAAY,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAE;QAC/C,IAAI,CAAC,CAAC,GAAG;QACT,IAAI,CAAC,CAAC,GAAG;QACT,IAAI,CAAC,KAAK,GAAG;QACb,IAAI,CAAC,MAAM,GAAG;IAChB;AA0JF","sources":["packages/@react-stately/virtualizer/src/Rect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Point} from './Point';\nimport {Size} from './Size';\n\nexport type RectCorner = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';\n\n/**\n * Represents a rectangle.\n */\nexport class Rect {\n /** The x-coordinate of the rectangle. */\n x: number;\n\n /** The y-coordinate of the rectangle. */\n y: number;\n\n /** The width of the rectangle. */\n width: number;\n\n /** The height of the rectangle. */\n height: number;\n\n constructor(x = 0, y = 0, width = 0, height = 0) {\n this.x = x;\n this.y = y;\n this.width = width;\n this.height = height;\n }\n\n /**\n * The maximum x-coordinate in the rectangle.\n */\n get maxX(): number {\n return this.x + this.width;\n }\n\n /**\n * The maximum y-coordinate in the rectangle.\n */\n get maxY(): number {\n return this.y + this.height;\n }\n\n /**\n * The area of the rectangle.\n */\n get area(): number {\n return this.width * this.height;\n }\n\n /**\n * The top left corner of the rectangle.\n */\n get topLeft(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * The top right corner of the rectangle.\n */\n get topRight(): Point {\n return new Point(this.maxX, this.y);\n }\n\n /**\n * The bottom left corner of the rectangle.\n */\n get bottomLeft(): Point {\n return new Point(this.x, this.maxY);\n }\n\n /**\n * The bottom right corner of the rectangle.\n */\n get bottomRight(): Point {\n return new Point(this.maxX, this.maxY);\n }\n\n /**\n * Returns whether this rectangle intersects another rectangle.\n * @param rect - The rectangle to check.\n */\n intersects(rect: Rect): boolean {\n let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;\n return (isTestEnv || this.area > 0 && rect.area > 0)\n && this.x <= rect.x + rect.width\n && rect.x <= this.x + this.width\n && this.y <= rect.y + rect.height\n && rect.y <= this.y + this.height;\n }\n\n /**\n * Returns whether this rectangle fully contains another rectangle.\n * @param rect - The rectangle to check.\n */\n containsRect(rect: Rect): boolean {\n return this.x <= rect.x\n && this.y <= rect.y\n && this.maxX >= rect.maxX\n && this.maxY >= rect.maxY;\n }\n\n /**\n * Returns whether the rectangle contains the given point.\n * @param point - The point to check.\n */\n containsPoint(point: Point): boolean {\n return this.x <= point.x\n && this.y <= point.y\n && this.maxX >= point.x\n && this.maxY >= point.y;\n }\n\n /**\n * Returns the first corner of this rectangle (from top to bottom, left to right)\n * that is contained in the given rectangle, or null of the rectangles do not intersect.\n * @param rect - The rectangle to check.\n */\n getCornerInRect(rect: Rect): RectCorner | null {\n for (let key of ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']) {\n if (rect.containsPoint(this[key])) {\n return key as RectCorner;\n }\n }\n\n return null;\n }\n\n equals(rect: Rect): boolean {\n return rect.x === this.x\n && rect.y === this.y\n && rect.width === this.width\n && rect.height === this.height;\n }\n\n pointEquals(point: Point | Rect): boolean {\n return this.x === point.x\n && this.y === point.y;\n }\n\n sizeEquals(size: Size | Rect): boolean {\n return this.width === size.width\n && this.height === size.height;\n }\n\n /**\n * Returns the union of this Rect and another.\n */\n union(other: Rect): Rect {\n let x = Math.min(this.x, other.x);\n let y = Math.min(this.y, other.y);\n let width = Math.max(this.maxX, other.maxX) - x;\n let height = Math.max(this.maxY, other.maxY) - y;\n return new Rect(x, y, width, height);\n }\n\n /**\n * Returns the intersection of this Rect with another.\n * If the rectangles do not intersect, an all zero Rect is returned.\n */\n intersection(other: Rect): Rect {\n if (!this.intersects(other)) {\n return new Rect(0, 0, 0, 0);\n }\n\n let x = Math.max(this.x, other.x);\n let y = Math.max(this.y, other.y);\n return new Rect(\n x,\n y,\n Math.min(this.maxX, other.maxX) - x,\n Math.min(this.maxY, other.maxY) - y\n );\n }\n\n /**\n * Returns a copy of this rectangle.\n */\n copy(): Rect {\n return new Rect(this.x, this.y, this.width, this.height);\n }\n}\n"],"names":[],"version":3,"file":"Rect.module.js.map"}
@@ -1,69 +0,0 @@
1
-
2
- function $parcel$export(e, n, v, s) {
3
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
- }
5
-
6
- $parcel$export(module.exports, "ReusableView", () => $197a1781bd47f5b9$export$1a5223887c560441);
7
- $parcel$export(module.exports, "RootView", () => $197a1781bd47f5b9$export$e21886a4eef6b29a);
8
- /*
9
- * Copyright 2020 Adobe. All rights reserved.
10
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License. You may obtain a copy
12
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software distributed under
15
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
- * OF ANY KIND, either express or implied. See the License for the specific language
17
- * governing permissions and limitations under the License.
18
- */ let $197a1781bd47f5b9$var$KEY = 0;
19
- class $197a1781bd47f5b9$export$1a5223887c560441 {
20
- /**
21
- * Prepares the view for reuse. Called just before the view is removed from the DOM.
22
- */ prepareForReuse() {
23
- this.content = null;
24
- this.rendered = null;
25
- this.layoutInfo = null;
26
- }
27
- getReusableView(reuseType) {
28
- // Reusable view queue should be FIFO so that DOM order remains consistent during scrolling.
29
- // For example, cells within a row should remain in the same order even if the row changes contents.
30
- // The cells within a row are removed from their parent in order. If the row is reused, the cells
31
- // should be reused in the new row in the same order they were before.
32
- let reusable = this.reusableViews.get(reuseType);
33
- let view = reusable && reusable.length > 0 ? reusable.shift() : new $197a1781bd47f5b9$export$7a41b6f219e61634(this.virtualizer, this, reuseType);
34
- return view;
35
- }
36
- reuseChild(child) {
37
- child.prepareForReuse();
38
- let reusable = this.reusableViews.get(child.viewType);
39
- if (!reusable) {
40
- reusable = [];
41
- this.reusableViews.set(child.viewType, reusable);
42
- }
43
- reusable.push(child);
44
- }
45
- constructor(virtualizer, viewType){
46
- this.virtualizer = virtualizer;
47
- this.key = ++$197a1781bd47f5b9$var$KEY;
48
- this.viewType = viewType;
49
- this.children = new Set();
50
- this.reusableViews = new Map();
51
- this.layoutInfo = null;
52
- this.content = null;
53
- this.rendered = null;
54
- }
55
- }
56
- class $197a1781bd47f5b9$export$e21886a4eef6b29a extends $197a1781bd47f5b9$export$1a5223887c560441 {
57
- constructor(virtualizer){
58
- super(virtualizer, 'root');
59
- }
60
- }
61
- class $197a1781bd47f5b9$export$7a41b6f219e61634 extends $197a1781bd47f5b9$export$1a5223887c560441 {
62
- constructor(virtualizer, parent, viewType){
63
- super(virtualizer, viewType);
64
- this.parent = parent;
65
- }
66
- }
67
-
68
-
69
- //# sourceMappingURL=ReusableView.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;AAAA;;;;;;;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react-stately/virtualizer/src/ReusableView.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {Virtualizer} from './Virtualizer';\n\nlet KEY = 0;\n\n/**\n * `Virtualizer` creates instances of the `ReusableView` class to\n * represent views currently being displayed.\n */\nexport class ReusableView<T extends object, V> {\n /** The Virtualizer this view is a part of. */\n virtualizer: Virtualizer<T, V>;\n\n /** The LayoutInfo this view is currently representing. */\n layoutInfo: LayoutInfo | null;\n\n /** The content currently being displayed by this view, set by the virtualizer. */\n content: T | null;\n\n rendered: V | null;\n\n viewType: string;\n key: Key;\n\n children: Set<ChildView<T, V>>;\n reusableViews: Map<string, ChildView<T, V>[]>;\n\n constructor(virtualizer: Virtualizer<T, V>, viewType: string) {\n this.virtualizer = virtualizer;\n this.key = ++KEY;\n this.viewType = viewType;\n this.children = new Set();\n this.reusableViews = new Map();\n this.layoutInfo = null;\n this.content = null;\n this.rendered = null;\n }\n\n /**\n * Prepares the view for reuse. Called just before the view is removed from the DOM.\n */\n prepareForReuse(): void {\n this.content = null;\n this.rendered = null;\n this.layoutInfo = null;\n }\n\n getReusableView(reuseType: string): ChildView<T, V> {\n // Reusable view queue should be FIFO so that DOM order remains consistent during scrolling.\n // For example, cells within a row should remain in the same order even if the row changes contents.\n // The cells within a row are removed from their parent in order. If the row is reused, the cells\n // should be reused in the new row in the same order they were before.\n let reusable = this.reusableViews.get(reuseType);\n let view = reusable && reusable.length > 0\n ? reusable.shift()!\n : new ChildView<T, V>(this.virtualizer, this, reuseType);\n\n return view;\n }\n\n reuseChild(child: ChildView<T, V>): void {\n child.prepareForReuse();\n let reusable = this.reusableViews.get(child.viewType);\n if (!reusable) {\n reusable = [];\n this.reusableViews.set(child.viewType, reusable);\n }\n reusable.push(child);\n }\n}\n\nexport class RootView<T extends object, V> extends ReusableView<T, V> {\n constructor(virtualizer: Virtualizer<T, V>) {\n super(virtualizer, 'root');\n }\n}\n\nexport class ChildView<T extends object, V> extends ReusableView<T, V> {\n parent: ReusableView<T, V>;\n\n constructor(virtualizer: Virtualizer<T, V>, parent: ReusableView<T, V>, viewType: string) {\n super(virtualizer, viewType);\n this.parent = parent;\n }\n}\n"],"names":[],"version":3,"file":"ReusableView.main.js.map"}
@@ -1,63 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */ let $ad1d98aa8f0c31b4$var$KEY = 0;
12
- class $ad1d98aa8f0c31b4$export$1a5223887c560441 {
13
- /**
14
- * Prepares the view for reuse. Called just before the view is removed from the DOM.
15
- */ prepareForReuse() {
16
- this.content = null;
17
- this.rendered = null;
18
- this.layoutInfo = null;
19
- }
20
- getReusableView(reuseType) {
21
- // Reusable view queue should be FIFO so that DOM order remains consistent during scrolling.
22
- // For example, cells within a row should remain in the same order even if the row changes contents.
23
- // The cells within a row are removed from their parent in order. If the row is reused, the cells
24
- // should be reused in the new row in the same order they were before.
25
- let reusable = this.reusableViews.get(reuseType);
26
- let view = reusable && reusable.length > 0 ? reusable.shift() : new $ad1d98aa8f0c31b4$export$7a41b6f219e61634(this.virtualizer, this, reuseType);
27
- return view;
28
- }
29
- reuseChild(child) {
30
- child.prepareForReuse();
31
- let reusable = this.reusableViews.get(child.viewType);
32
- if (!reusable) {
33
- reusable = [];
34
- this.reusableViews.set(child.viewType, reusable);
35
- }
36
- reusable.push(child);
37
- }
38
- constructor(virtualizer, viewType){
39
- this.virtualizer = virtualizer;
40
- this.key = ++$ad1d98aa8f0c31b4$var$KEY;
41
- this.viewType = viewType;
42
- this.children = new Set();
43
- this.reusableViews = new Map();
44
- this.layoutInfo = null;
45
- this.content = null;
46
- this.rendered = null;
47
- }
48
- }
49
- class $ad1d98aa8f0c31b4$export$e21886a4eef6b29a extends $ad1d98aa8f0c31b4$export$1a5223887c560441 {
50
- constructor(virtualizer){
51
- super(virtualizer, 'root');
52
- }
53
- }
54
- class $ad1d98aa8f0c31b4$export$7a41b6f219e61634 extends $ad1d98aa8f0c31b4$export$1a5223887c560441 {
55
- constructor(virtualizer, parent, viewType){
56
- super(virtualizer, viewType);
57
- this.parent = parent;
58
- }
59
- }
60
-
61
-
62
- export {$ad1d98aa8f0c31b4$export$1a5223887c560441 as ReusableView, $ad1d98aa8f0c31b4$export$7a41b6f219e61634 as ChildView, $ad1d98aa8f0c31b4$export$e21886a4eef6b29a as RootView};
63
- //# sourceMappingURL=ReusableView.module.js.map
@@ -1,63 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */ let $ad1d98aa8f0c31b4$var$KEY = 0;
12
- class $ad1d98aa8f0c31b4$export$1a5223887c560441 {
13
- /**
14
- * Prepares the view for reuse. Called just before the view is removed from the DOM.
15
- */ prepareForReuse() {
16
- this.content = null;
17
- this.rendered = null;
18
- this.layoutInfo = null;
19
- }
20
- getReusableView(reuseType) {
21
- // Reusable view queue should be FIFO so that DOM order remains consistent during scrolling.
22
- // For example, cells within a row should remain in the same order even if the row changes contents.
23
- // The cells within a row are removed from their parent in order. If the row is reused, the cells
24
- // should be reused in the new row in the same order they were before.
25
- let reusable = this.reusableViews.get(reuseType);
26
- let view = reusable && reusable.length > 0 ? reusable.shift() : new $ad1d98aa8f0c31b4$export$7a41b6f219e61634(this.virtualizer, this, reuseType);
27
- return view;
28
- }
29
- reuseChild(child) {
30
- child.prepareForReuse();
31
- let reusable = this.reusableViews.get(child.viewType);
32
- if (!reusable) {
33
- reusable = [];
34
- this.reusableViews.set(child.viewType, reusable);
35
- }
36
- reusable.push(child);
37
- }
38
- constructor(virtualizer, viewType){
39
- this.virtualizer = virtualizer;
40
- this.key = ++$ad1d98aa8f0c31b4$var$KEY;
41
- this.viewType = viewType;
42
- this.children = new Set();
43
- this.reusableViews = new Map();
44
- this.layoutInfo = null;
45
- this.content = null;
46
- this.rendered = null;
47
- }
48
- }
49
- class $ad1d98aa8f0c31b4$export$e21886a4eef6b29a extends $ad1d98aa8f0c31b4$export$1a5223887c560441 {
50
- constructor(virtualizer){
51
- super(virtualizer, 'root');
52
- }
53
- }
54
- class $ad1d98aa8f0c31b4$export$7a41b6f219e61634 extends $ad1d98aa8f0c31b4$export$1a5223887c560441 {
55
- constructor(virtualizer, parent, viewType){
56
- super(virtualizer, viewType);
57
- this.parent = parent;
58
- }
59
- }
60
-
61
-
62
- export {$ad1d98aa8f0c31b4$export$1a5223887c560441 as ReusableView, $ad1d98aa8f0c31b4$export$7a41b6f219e61634 as ChildView, $ad1d98aa8f0c31b4$export$e21886a4eef6b29a as RootView};
63
- //# sourceMappingURL=ReusableView.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":"AAAA;;;;;;;;;;CAUC,GAMD,IAAI,4BAAM;AAMH,MAAM;IA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* Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {Virtualizer} from './Virtualizer';\n\nlet KEY = 0;\n\n/**\n * `Virtualizer` creates instances of the `ReusableView` class to\n * represent views currently being displayed.\n */\nexport class ReusableView<T extends object, V> {\n /** The Virtualizer this view is a part of. */\n virtualizer: Virtualizer<T, V>;\n\n /** The LayoutInfo this view is currently representing. */\n layoutInfo: LayoutInfo | null;\n\n /** The content currently being displayed by this view, set by the virtualizer. */\n content: T | null;\n\n rendered: V | null;\n\n viewType: string;\n key: Key;\n\n children: Set<ChildView<T, V>>;\n reusableViews: Map<string, ChildView<T, V>[]>;\n\n constructor(virtualizer: Virtualizer<T, V>, viewType: string) {\n this.virtualizer = virtualizer;\n this.key = ++KEY;\n this.viewType = viewType;\n this.children = new Set();\n this.reusableViews = new Map();\n this.layoutInfo = null;\n this.content = null;\n this.rendered = null;\n }\n\n /**\n * Prepares the view for reuse. Called just before the view is removed from the DOM.\n */\n prepareForReuse(): void {\n this.content = null;\n this.rendered = null;\n this.layoutInfo = null;\n }\n\n getReusableView(reuseType: string): ChildView<T, V> {\n // Reusable view queue should be FIFO so that DOM order remains consistent during scrolling.\n // For example, cells within a row should remain in the same order even if the row changes contents.\n // The cells within a row are removed from their parent in order. If the row is reused, the cells\n // should be reused in the new row in the same order they were before.\n let reusable = this.reusableViews.get(reuseType);\n let view = reusable && reusable.length > 0\n ? reusable.shift()!\n : new ChildView<T, V>(this.virtualizer, this, reuseType);\n\n return view;\n }\n\n reuseChild(child: ChildView<T, V>): void {\n child.prepareForReuse();\n let reusable = this.reusableViews.get(child.viewType);\n if (!reusable) {\n reusable = [];\n this.reusableViews.set(child.viewType, reusable);\n }\n reusable.push(child);\n }\n}\n\nexport class RootView<T extends object, V> extends ReusableView<T, V> {\n constructor(virtualizer: Virtualizer<T, V>) {\n super(virtualizer, 'root');\n }\n}\n\nexport class ChildView<T extends object, V> extends ReusableView<T, V> {\n parent: ReusableView<T, V>;\n\n constructor(virtualizer: Virtualizer<T, V>, parent: ReusableView<T, V>, viewType: string) {\n super(virtualizer, viewType);\n this.parent = parent;\n }\n}\n"],"names":[],"version":3,"file":"ReusableView.module.js.map"}
package/dist/Size.main.js DELETED
@@ -1,40 +0,0 @@
1
-
2
- function $parcel$export(e, n, v, s) {
3
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
- }
5
-
6
- $parcel$export(module.exports, "Size", () => $064492b79924894c$export$cb6da89c6af1a8ec);
7
- /*
8
- * Copyright 2020 Adobe. All rights reserved.
9
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License. You may obtain a copy
11
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software distributed under
14
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- * OF ANY KIND, either express or implied. See the License for the specific language
16
- * governing permissions and limitations under the License.
17
- */ class $064492b79924894c$export$cb6da89c6af1a8ec {
18
- /**
19
- * Returns a copy of this size.
20
- */ copy() {
21
- return new $064492b79924894c$export$cb6da89c6af1a8ec(this.width, this.height);
22
- }
23
- /**
24
- * Returns whether this size is equal to another one.
25
- */ equals(other) {
26
- return this.width === other.width && this.height === other.height;
27
- }
28
- /**
29
- * The total area of the Size.
30
- */ get area() {
31
- return this.width * this.height;
32
- }
33
- constructor(width = 0, height = 0){
34
- this.width = Math.max(width, 0);
35
- this.height = Math.max(height, 0);
36
- }
37
- }
38
-
39
-
40
- //# sourceMappingURL=Size.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAEM,MAAM;IASX;;GAEC,GACD,OAAa;QACX,OAAO,IAAI,0CAAK,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM;IACzC;IAEA;;GAEC,GACD,OAAO,KAAW,EAAW;QAC3B,OAAO,IAAI,CAAC,KAAK,KAAK,MAAM,KAAK,IAC1B,IAAI,CAAC,MAAM,KAAK,MAAM,MAAM;IACrC;IAEA;;GAEC,GACD,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM;IACjC;IAzBA,YAAY,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAE;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,OAAO;QAC7B,IAAI,CAAC,MAAM,GAAG,KAAK,GAAG,CAAC,QAAQ;IACjC;AAuBF","sources":["packages/@react-stately/virtualizer/src/Size.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport class Size {\n width: number;\n height: number;\n\n constructor(width = 0, height = 0) {\n this.width = Math.max(width, 0);\n this.height = Math.max(height, 0);\n }\n\n /**\n * Returns a copy of this size.\n */\n copy(): Size {\n return new Size(this.width, this.height);\n }\n\n /**\n * Returns whether this size is equal to another one.\n */\n equals(other: Size): boolean {\n return this.width === other.width\n && this.height === other.height;\n }\n\n /**\n * The total area of the Size.\n */\n get area(): number {\n return this.width * this.height;\n }\n}\n"],"names":[],"version":3,"file":"Size.main.js.map"}
package/dist/Size.mjs DELETED
@@ -1,35 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */ class $ee1bfa90a957fb8a$export$cb6da89c6af1a8ec {
12
- /**
13
- * Returns a copy of this size.
14
- */ copy() {
15
- return new $ee1bfa90a957fb8a$export$cb6da89c6af1a8ec(this.width, this.height);
16
- }
17
- /**
18
- * Returns whether this size is equal to another one.
19
- */ equals(other) {
20
- return this.width === other.width && this.height === other.height;
21
- }
22
- /**
23
- * The total area of the Size.
24
- */ get area() {
25
- return this.width * this.height;
26
- }
27
- constructor(width = 0, height = 0){
28
- this.width = Math.max(width, 0);
29
- this.height = Math.max(height, 0);
30
- }
31
- }
32
-
33
-
34
- export {$ee1bfa90a957fb8a$export$cb6da89c6af1a8ec as Size};
35
- //# sourceMappingURL=Size.module.js.map
@@ -1,35 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */ class $ee1bfa90a957fb8a$export$cb6da89c6af1a8ec {
12
- /**
13
- * Returns a copy of this size.
14
- */ copy() {
15
- return new $ee1bfa90a957fb8a$export$cb6da89c6af1a8ec(this.width, this.height);
16
- }
17
- /**
18
- * Returns whether this size is equal to another one.
19
- */ equals(other) {
20
- return this.width === other.width && this.height === other.height;
21
- }
22
- /**
23
- * The total area of the Size.
24
- */ get area() {
25
- return this.width * this.height;
26
- }
27
- constructor(width = 0, height = 0){
28
- this.width = Math.max(width, 0);
29
- this.height = Math.max(height, 0);
30
- }
31
- }
32
-
33
-
34
- export {$ee1bfa90a957fb8a$export$cb6da89c6af1a8ec as Size};
35
- //# sourceMappingURL=Size.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":"AAAA;;;;;;;;;;CAUC,GAEM,MAAM;IASX;;GAEC,GACD,OAAa;QACX,OAAO,IAAI,0CAAK,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM;IACzC;IAEA;;GAEC,GACD,OAAO,KAAW,EAAW;QAC3B,OAAO,IAAI,CAAC,KAAK,KAAK,MAAM,KAAK,IAC1B,IAAI,CAAC,MAAM,KAAK,MAAM,MAAM;IACrC;IAEA;;GAEC,GACD,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM;IACjC;IAzBA,YAAY,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAE;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,OAAO;QAC7B,IAAI,CAAC,MAAM,GAAG,KAAK,GAAG,CAAC,QAAQ;IACjC;AAuBF","sources":["packages/@react-stately/virtualizer/src/Size.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport class Size {\n width: number;\n height: number;\n\n constructor(width = 0, height = 0) {\n this.width = Math.max(width, 0);\n this.height = Math.max(height, 0);\n }\n\n /**\n * Returns a copy of this size.\n */\n copy(): Size {\n return new Size(this.width, this.height);\n }\n\n /**\n * Returns whether this size is equal to another one.\n */\n equals(other: Size): boolean {\n return this.width === other.width\n && this.height === other.height;\n }\n\n /**\n * The total area of the Size.\n */\n get area(): number {\n return this.width * this.height;\n }\n}\n"],"names":[],"version":3,"file":"Size.module.js.map"}
@@ -1,239 +0,0 @@
1
- var $197a1781bd47f5b9$exports = require("./ReusableView.main.js");
2
- var $abed55ea619a7a17$exports = require("./utils.main.js");
3
- var $191a033606d4fda1$exports = require("./OverscanManager.main.js");
4
- var $41b7691783731623$exports = require("./Rect.main.js");
5
- var $064492b79924894c$exports = require("./Size.main.js");
6
-
7
-
8
- function $parcel$export(e, n, v, s) {
9
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
- }
11
-
12
- $parcel$export(module.exports, "Virtualizer", () => $e1bc15d49d21df0e$export$89be5a243e59c4b2);
13
- /*
14
- * Copyright 2020 Adobe. All rights reserved.
15
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
- * you may not use this file except in compliance with the License. You may obtain a copy
17
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software distributed under
20
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
- * OF ANY KIND, either express or implied. See the License for the specific language
22
- * governing permissions and limitations under the License.
23
- */
24
-
25
-
26
-
27
-
28
- class $e1bc15d49d21df0e$export$89be5a243e59c4b2 {
29
- /** Returns whether the given key, or an ancestor, is persisted. */ isPersistedKey(key) {
30
- // Quick check if the key is directly in the set of persisted keys.
31
- if (this.persistedKeys.has(key)) return true;
32
- // If not, check if the key is an ancestor of any of the persisted keys.
33
- for (let k of this.persistedKeys)while(k != null){
34
- let layoutInfo = this.layout.getLayoutInfo(k);
35
- if (!layoutInfo || layoutInfo.parentKey == null) break;
36
- k = layoutInfo.parentKey;
37
- if (k === key) return true;
38
- }
39
- return false;
40
- }
41
- getParentView(layoutInfo) {
42
- return layoutInfo.parentKey != null ? this._visibleViews.get(layoutInfo.parentKey) : this._rootView;
43
- }
44
- getReusableView(layoutInfo) {
45
- let parentView = this.getParentView(layoutInfo);
46
- let view = parentView.getReusableView(layoutInfo.type);
47
- view.layoutInfo = layoutInfo;
48
- this._renderView(view);
49
- return view;
50
- }
51
- _renderView(reusableView) {
52
- if (reusableView.layoutInfo) {
53
- let { type: type, key: key, content: content } = reusableView.layoutInfo;
54
- reusableView.content = content || this.collection.getItem(key);
55
- reusableView.rendered = this._renderContent(type, reusableView.content);
56
- }
57
- }
58
- _renderContent(type, content) {
59
- let cached = content != null ? this._renderedContent.get(content) : null;
60
- if (cached != null) return cached;
61
- let rendered = this.delegate.renderView(type, content);
62
- if (content) this._renderedContent.set(content, rendered);
63
- return rendered;
64
- }
65
- /**
66
- * Returns the key for the item view currently at the given point.
67
- */ keyAtPoint(point) {
68
- let rect = new (0, $41b7691783731623$exports.Rect)(point.x, point.y, 1, 1);
69
- let layoutInfos = rect.area === 0 ? [] : this.layout.getVisibleLayoutInfos(rect);
70
- // Layout may return multiple layout infos in the case of
71
- // persisted keys, so find the first one that actually intersects.
72
- for (let layoutInfo of layoutInfos){
73
- if (layoutInfo.rect.intersects(rect)) return layoutInfo.key;
74
- }
75
- return null;
76
- }
77
- relayout(context = {}) {
78
- // Update the layout
79
- this.layout.update(context);
80
- this.contentSize = this.layout.getContentSize();
81
- // Constrain scroll position.
82
- // If the content changed, scroll to the top.
83
- let visibleRect = this.visibleRect;
84
- let contentOffsetX = context.contentChanged ? 0 : visibleRect.x;
85
- let contentOffsetY = context.contentChanged ? 0 : visibleRect.y;
86
- contentOffsetX = Math.max(0, Math.min(this.contentSize.width - visibleRect.width, contentOffsetX));
87
- contentOffsetY = Math.max(0, Math.min(this.contentSize.height - visibleRect.height, contentOffsetY));
88
- if (contentOffsetX !== visibleRect.x || contentOffsetY !== visibleRect.y) {
89
- // If the offset changed, trigger a new re-render.
90
- let rect = new (0, $41b7691783731623$exports.Rect)(contentOffsetX, contentOffsetY, visibleRect.width, visibleRect.height);
91
- this.delegate.setVisibleRect(rect);
92
- } else this.updateSubviews();
93
- }
94
- getVisibleLayoutInfos() {
95
- let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;
96
- let isClientWidthMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientWidth');
97
- let isClientHeightMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientHeight');
98
- let rect;
99
- if (isTestEnv && !(isClientWidthMocked && isClientHeightMocked)) rect = new (0, $41b7691783731623$exports.Rect)(0, 0, this.contentSize.width, this.contentSize.height);
100
- else rect = this._overscanManager.getOverscannedRect();
101
- let layoutInfos = this.layout.getVisibleLayoutInfos(rect);
102
- let map = new Map;
103
- for (let layoutInfo of layoutInfos)map.set(layoutInfo.key, layoutInfo);
104
- return map;
105
- }
106
- updateSubviews() {
107
- let visibleLayoutInfos = this.getVisibleLayoutInfos();
108
- let removed = new Set();
109
- for (let [key, view] of this._visibleViews){
110
- let layoutInfo = visibleLayoutInfos.get(key);
111
- // If a view's parent changed, treat it as a delete and re-create in the new parent.
112
- if (!layoutInfo || view.parent !== this.getParentView(layoutInfo)) {
113
- this._visibleViews.delete(key);
114
- view.parent.reuseChild(view);
115
- removed.add(view); // Defer removing in case we reuse this view.
116
- }
117
- }
118
- for (let [key, layoutInfo] of visibleLayoutInfos){
119
- let view = this._visibleViews.get(key);
120
- if (!view) {
121
- view = this.getReusableView(layoutInfo);
122
- view.parent.children.add(view);
123
- this._visibleViews.set(key, view);
124
- removed.delete(view);
125
- } else {
126
- view.layoutInfo = layoutInfo;
127
- let item = this.collection.getItem(layoutInfo.key);
128
- if (view.content !== item) {
129
- if (view.content != null) this._renderedContent.delete(view.content);
130
- this._renderView(view);
131
- }
132
- }
133
- }
134
- // The remaining views in `removed` were not reused to render new items.
135
- // They should be removed from the DOM. We also clear the reusable view queue
136
- // here since there's no point holding onto views that have been removed.
137
- // Doing so hurts performance in the future when reusing elements due to FIFO order.
138
- for (let view of removed){
139
- view.parent.children.delete(view);
140
- view.parent.reusableViews.clear();
141
- }
142
- // Reordering DOM nodes is costly, so we defer this until scrolling stops.
143
- // DOM order does not affect visual order (due to absolute positioning),
144
- // but does matter for assistive technology users.
145
- if (!this._isScrolling) // Layout infos must be in topological order (parents before children).
146
- for (let key of visibleLayoutInfos.keys()){
147
- let view = this._visibleViews.get(key);
148
- view.parent.children.delete(view);
149
- view.parent.children.add(view);
150
- }
151
- }
152
- /** Performs layout and updates visible views as needed. */ render(opts) {
153
- let mutableThis = this;
154
- let needsLayout = false;
155
- let offsetChanged = false;
156
- let sizeChanged = false;
157
- let itemSizeChanged = false;
158
- let layoutOptionsChanged = false;
159
- let needsUpdate = false;
160
- if (opts.collection !== this.collection) {
161
- mutableThis.collection = opts.collection;
162
- needsLayout = true;
163
- }
164
- if (opts.layout !== this.layout || this.layout.virtualizer !== this) {
165
- if (this.layout) this.layout.virtualizer = null;
166
- opts.layout.virtualizer = this;
167
- mutableThis.layout = opts.layout;
168
- needsLayout = true;
169
- }
170
- if (opts.persistedKeys && !(0, $abed55ea619a7a17$exports.isSetEqual)(opts.persistedKeys, this.persistedKeys)) {
171
- mutableThis.persistedKeys = opts.persistedKeys;
172
- needsUpdate = true;
173
- }
174
- if (!this.visibleRect.equals(opts.visibleRect)) {
175
- this._overscanManager.setVisibleRect(opts.visibleRect);
176
- let shouldInvalidate = this.layout.shouldInvalidate(opts.visibleRect, this.visibleRect);
177
- if (shouldInvalidate) {
178
- offsetChanged = !opts.visibleRect.pointEquals(this.visibleRect);
179
- sizeChanged = !opts.visibleRect.sizeEquals(this.visibleRect);
180
- needsLayout = true;
181
- } else needsUpdate = true;
182
- mutableThis.visibleRect = opts.visibleRect;
183
- }
184
- if (opts.invalidationContext !== this._invalidationContext) {
185
- if (opts.invalidationContext) {
186
- sizeChanged || (sizeChanged = opts.invalidationContext.sizeChanged || false);
187
- offsetChanged || (offsetChanged = opts.invalidationContext.offsetChanged || false);
188
- itemSizeChanged || (itemSizeChanged = opts.invalidationContext.itemSizeChanged || false);
189
- layoutOptionsChanged || (layoutOptionsChanged = opts.invalidationContext.layoutOptions != null && this._invalidationContext.layoutOptions != null && opts.invalidationContext.layoutOptions !== this._invalidationContext.layoutOptions && this.layout.shouldInvalidateLayoutOptions(opts.invalidationContext.layoutOptions, this._invalidationContext.layoutOptions));
190
- needsLayout || (needsLayout = itemSizeChanged || sizeChanged || offsetChanged || layoutOptionsChanged);
191
- }
192
- this._invalidationContext = opts.invalidationContext;
193
- }
194
- if (opts.isScrolling !== this._isScrolling) {
195
- this._isScrolling = opts.isScrolling;
196
- if (!opts.isScrolling) // Update to fix the DOM order after scrolling.
197
- needsUpdate = true;
198
- }
199
- if (needsLayout) this.relayout({
200
- offsetChanged: offsetChanged,
201
- sizeChanged: sizeChanged,
202
- itemSizeChanged: itemSizeChanged,
203
- layoutOptionsChanged: layoutOptionsChanged,
204
- layoutOptions: this._invalidationContext.layoutOptions
205
- });
206
- else if (needsUpdate) this.updateSubviews();
207
- return Array.from(this._rootView.children);
208
- }
209
- getVisibleView(key) {
210
- return this._visibleViews.get(key);
211
- }
212
- invalidate(context) {
213
- this.delegate.invalidate(context);
214
- }
215
- updateItemSize(key, size) {
216
- if (!this.layout.updateItemSize) return;
217
- let changed = this.layout.updateItemSize(key, size);
218
- if (changed) this.invalidate({
219
- itemSizeChanged: true
220
- });
221
- }
222
- constructor(options){
223
- this.delegate = options.delegate;
224
- this.collection = options.collection;
225
- this.layout = options.layout;
226
- this.contentSize = new (0, $064492b79924894c$exports.Size);
227
- this.visibleRect = new (0, $41b7691783731623$exports.Rect);
228
- this.persistedKeys = new Set();
229
- this._visibleViews = new Map();
230
- this._renderedContent = new WeakMap();
231
- this._rootView = new (0, $197a1781bd47f5b9$exports.RootView)(this);
232
- this._isScrolling = false;
233
- this._invalidationContext = {};
234
- this._overscanManager = new (0, $191a033606d4fda1$exports.OverscanManager)();
235
- }
236
- }
237
-
238
-
239
- //# sourceMappingURL=Virtualizer.main.js.map