@react-stately/virtualizer 4.3.1 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Layout.main.js.map +1 -1
- package/dist/Layout.module.js.map +1 -1
- package/dist/OverscanManager.main.js.map +1 -1
- package/dist/OverscanManager.module.js.map +1 -1
- package/dist/Rect.main.js +1 -1
- package/dist/Rect.main.js.map +1 -1
- package/dist/Rect.mjs +1 -1
- package/dist/Rect.module.js +1 -1
- package/dist/Rect.module.js.map +1 -1
- package/dist/ReusableView.main.js.map +1 -1
- package/dist/ReusableView.module.js.map +1 -1
- package/dist/Size.main.js.map +1 -1
- package/dist/Size.module.js.map +1 -1
- package/dist/Virtualizer.main.js +2 -2
- package/dist/Virtualizer.main.js.map +1 -1
- package/dist/Virtualizer.mjs +2 -2
- package/dist/Virtualizer.module.js +2 -2
- package/dist/Virtualizer.module.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/Layout.ts +2 -2
- package/src/OverscanManager.ts +2 -2
- package/src/Rect.ts +7 -5
- package/src/ReusableView.ts +3 -3
- package/src/Size.ts +1 -1
- package/src/Virtualizer.ts +6 -7
package/dist/Layout.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAmBM,MAAe;IAuBpB;;;;;GAKC,GACD,iBAAiB,OAAa,EAAE,OAAa,EAAW;QACtD,+CAA+C;QAC/C,OAAO,QAAQ,KAAK,KAAK,QAAQ,KAAK,IAC/B,QAAQ,MAAM,KAAK,QAAQ,MAAM;IAC1C;IAEA;;;;GAIC,GACD,8BAA8B,UAAa,EAAE,UAAa,EAAW;QACnE,OAAO,eAAe;IACxB;IAEA;;;;;GAKC,GACD,OAAO,mBAA2C,
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAmBM,MAAe;IAuBpB;;;;;GAKC,GACD,iBAAiB,OAAa,EAAE,OAAa,EAAW;QACtD,+CAA+C;QAC/C,OAAO,QAAQ,KAAK,KAAK,QAAQ,KAAK,IAC/B,QAAQ,MAAM,KAAK,QAAQ,MAAM;IAC1C;IAEA;;;;GAIC,GACD,8BAA8B,UAAa,EAAE,UAAa,EAAW;QACnE,OAAO,eAAe;IACxB;IAEA;;;;;GAKC,GACD,OAAO,mBAA2C,EAAQ,CAAC;IAY3D,aAAa,GACb,YAAY,GAAQ,EAAe;YAC1B;YAAA;QAAP,OAAO,CAAA,4BAAA,sBAAA,IAAI,CAAC,aAAa,CAAC,kBAAnB,0CAAA,oBAAyB,IAAI,cAA7B,sCAAA,2BAAiC;IAC1C;IAEA,aAAa,GACb,iBAAuB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAE,WAAW;IACtC;;QArEA,yDAAyD,QACzD,cAA0C;;AAqE5C","sources":["packages/@react-stately/virtualizer/src/Layout.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 {InvalidationContext} from './types';\nimport {ItemDropTarget, Key, LayoutDelegate, Node} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {Rect} from './Rect';\nimport {Size} from './Size';\nimport {Virtualizer} from './Virtualizer';\n\n/**\n * Virtualizer supports arbitrary layout objects, which compute what items are visible, and how\n * to position and style them. However, layouts do not render items directly. Instead,\n * layouts produce lightweight LayoutInfo objects which describe various properties of an item,\n * such as its position and size. The Virtualizer is then responsible for creating the actual\n * views as needed, based on this layout information.\n *\n * Every layout extends from the Layout abstract base class. Layouts must implement the `getVisibleLayoutInfos`,\n * `getLayoutInfo`, and `getContentSize` methods. All other methods can be optionally overridden to implement custom behavior.\n */\nexport abstract class Layout<T extends object = Node<any>, O = any> implements LayoutDelegate {\n /** The Virtualizer the layout is currently attached to. */\n virtualizer: Virtualizer<T, any> | null = null;\n\n /**\n * Returns an array of `LayoutInfo` objects which are inside the given rectangle.\n * Should be implemented by subclasses.\n * @param rect The rectangle that should contain the returned LayoutInfo objects.\n */\n abstract getVisibleLayoutInfos(rect: Rect): LayoutInfo[];\n\n /**\n * Returns a `LayoutInfo` for the given key.\n * Should be implemented by subclasses.\n * @param key The key of the LayoutInfo to retrieve.\n */\n abstract getLayoutInfo(key: Key): LayoutInfo | null;\n\n /**\n * Returns size of the content. By default, it returns virtualizer's size.\n */\n abstract getContentSize(): Size; \n\n /**\n * Returns whether the layout should invalidate in response to\n * visible rectangle changes. By default, it only invalidates\n * when the virtualizer's size changes. Return true always\n * to make the layout invalidate while scrolling (e.g. sticky headers).\n */\n shouldInvalidate(newRect: Rect, oldRect: Rect): boolean {\n // By default, invalidate when the size changes\n return newRect.width !== oldRect.width\n || newRect.height !== oldRect.height;\n }\n\n /**\n * Returns whether the layout should invalidate when the layout options change.\n * By default it invalidates when the object identity changes. Override this\n * method to optimize layout updates based on specific option changes.\n */\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return newOptions !== oldOptions;\n }\n\n /**\n * This method allows the layout to perform any pre-computation\n * it needs to in order to prepare LayoutInfos for retrieval.\n * Called by the virtualizer before `getVisibleLayoutInfos`\n * or `getLayoutInfo` are called.\n */\n update(invalidationContext: InvalidationContext<O>): void {} // eslint-disable-line @typescript-eslint/no-unused-vars\n\n /**\n * Updates the size of the given item.\n */\n updateItemSize?(key: Key, size: Size): boolean;\n\n /**\n * Returns a `LayoutInfo` for the given drop target.\n */\n getDropTargetLayoutInfo?(target: ItemDropTarget): LayoutInfo;\n\n /** @private */\n getItemRect(key: Key): Rect | null {\n return this.getLayoutInfo(key)?.rect ?? null;\n }\n\n /** @private */\n getVisibleRect(): Rect {\n return this.virtualizer!.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"Layout.main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAmBM,MAAe;IAuBpB;;;;;GAKC,GACD,iBAAiB,OAAa,EAAE,OAAa,EAAW;QACtD,+CAA+C;QAC/C,OAAO,QAAQ,KAAK,KAAK,QAAQ,KAAK,IAC/B,QAAQ,MAAM,KAAK,QAAQ,MAAM;IAC1C;IAEA;;;;GAIC,GACD,8BAA8B,UAAa,EAAE,UAAa,EAAW;QACnE,OAAO,eAAe;IACxB;IAEA;;;;;GAKC,GACD,OAAO,mBAA2C,
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAmBM,MAAe;IAuBpB;;;;;GAKC,GACD,iBAAiB,OAAa,EAAE,OAAa,EAAW;QACtD,+CAA+C;QAC/C,OAAO,QAAQ,KAAK,KAAK,QAAQ,KAAK,IAC/B,QAAQ,MAAM,KAAK,QAAQ,MAAM;IAC1C;IAEA;;;;GAIC,GACD,8BAA8B,UAAa,EAAE,UAAa,EAAW;QACnE,OAAO,eAAe;IACxB;IAEA;;;;;GAKC,GACD,OAAO,mBAA2C,EAAQ,CAAC;IAY3D,aAAa,GACb,YAAY,GAAQ,EAAe;YAC1B;YAAA;QAAP,OAAO,CAAA,4BAAA,sBAAA,IAAI,CAAC,aAAa,CAAC,kBAAnB,0CAAA,oBAAyB,IAAI,cAA7B,sCAAA,2BAAiC;IAC1C;IAEA,aAAa,GACb,iBAAuB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAE,WAAW;IACtC;;QArEA,yDAAyD,QACzD,cAA0C;;AAqE5C","sources":["packages/@react-stately/virtualizer/src/Layout.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 {InvalidationContext} from './types';\nimport {ItemDropTarget, Key, LayoutDelegate, Node} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {Rect} from './Rect';\nimport {Size} from './Size';\nimport {Virtualizer} from './Virtualizer';\n\n/**\n * Virtualizer supports arbitrary layout objects, which compute what items are visible, and how\n * to position and style them. However, layouts do not render items directly. Instead,\n * layouts produce lightweight LayoutInfo objects which describe various properties of an item,\n * such as its position and size. The Virtualizer is then responsible for creating the actual\n * views as needed, based on this layout information.\n *\n * Every layout extends from the Layout abstract base class. Layouts must implement the `getVisibleLayoutInfos`,\n * `getLayoutInfo`, and `getContentSize` methods. All other methods can be optionally overridden to implement custom behavior.\n */\nexport abstract class Layout<T extends object = Node<any>, O = any> implements LayoutDelegate {\n /** The Virtualizer the layout is currently attached to. */\n virtualizer: Virtualizer<T, any> | null = null;\n\n /**\n * Returns an array of `LayoutInfo` objects which are inside the given rectangle.\n * Should be implemented by subclasses.\n * @param rect The rectangle that should contain the returned LayoutInfo objects.\n */\n abstract getVisibleLayoutInfos(rect: Rect): LayoutInfo[];\n\n /**\n * Returns a `LayoutInfo` for the given key.\n * Should be implemented by subclasses.\n * @param key The key of the LayoutInfo to retrieve.\n */\n abstract getLayoutInfo(key: Key): LayoutInfo | null;\n\n /**\n * Returns size of the content. By default, it returns virtualizer's size.\n */\n abstract getContentSize(): Size; \n\n /**\n * Returns whether the layout should invalidate in response to\n * visible rectangle changes. By default, it only invalidates\n * when the virtualizer's size changes. Return true always\n * to make the layout invalidate while scrolling (e.g. sticky headers).\n */\n shouldInvalidate(newRect: Rect, oldRect: Rect): boolean {\n // By default, invalidate when the size changes\n return newRect.width !== oldRect.width\n || newRect.height !== oldRect.height;\n }\n\n /**\n * Returns whether the layout should invalidate when the layout options change.\n * By default it invalidates when the object identity changes. Override this\n * method to optimize layout updates based on specific option changes.\n */\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return newOptions !== oldOptions;\n }\n\n /**\n * This method allows the layout to perform any pre-computation\n * it needs to in order to prepare LayoutInfos for retrieval.\n * Called by the virtualizer before `getVisibleLayoutInfos`\n * or `getLayoutInfo` are called.\n */\n update(invalidationContext: InvalidationContext<O>): void {} // eslint-disable-line @typescript-eslint/no-unused-vars\n\n /**\n * Updates the size of the given item.\n */\n updateItemSize?(key: Key, size: Size): boolean;\n\n /**\n * Returns a `LayoutInfo` for the given drop target.\n */\n getDropTargetLayoutInfo?(target: ItemDropTarget): LayoutInfo;\n\n /** @private */\n getItemRect(key: Key): Rect | null {\n return this.getLayoutInfo(key)?.rect ?? null;\n }\n\n /** @private */\n getVisibleRect(): Rect {\n return this.virtualizer!.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"Layout.module.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAKM,MAAM;IAKX,eAAe,IAAU,
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAKM,MAAM;IAKX,eAAe,IAAU,EAAQ;QAC/B,IAAI,OAAO,YAAY,GAAG,KAAK,IAAI,CAAC,SAAS;QAC7C,IAAI,OAAO,KAAK;YACd,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,OAAO,GAC1C,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,AAAC,CAAA,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,AAAD,IAAK;YAGpD,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,OAAO,GAC1C,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,AAAC,CAAA,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,AAAD,IAAK;QAEtD;QAEA,IAAI,CAAC,SAAS,GAAG,YAAY,GAAG;QAChC,IAAI,CAAC,WAAW,GAAG;IACrB;IAEA,qBAA2B;QACzB,IAAI,cAAc,IAAI,CAAC,WAAW,CAAC,IAAI;QAEvC,IAAI,YAAY,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG;QAC1C,YAAY,MAAM,IAAI;QACtB,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,GACpB,YAAY,CAAC,IAAI;QAGnB,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,GAAG;YACzB,IAAI,YAAY,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG;YACzC,YAAY,KAAK,IAAI;YACrB,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,GACpB,YAAY,CAAC,IAAI;QAErB;QAEA,OAAO;IACT;;aAtCQ,YAAY;aACZ,WAAW,IAAI,CAAA,GAAA,+BAAI,EAAE,GAAG;aACxB,cAAc,IAAI,CAAA,GAAA,8BAAG;;AAqC/B","sources":["packages/@react-stately/virtualizer/src/OverscanManager.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 {Rect} from './Rect';\n\nexport class OverscanManager {\n private startTime = 0;\n private velocity = new Point(0, 0);\n private visibleRect = new Rect();\n\n setVisibleRect(rect: Rect): void {\n let time = performance.now() - this.startTime;\n if (time < 500) {\n if (rect.x !== this.visibleRect.x && time > 0) {\n this.velocity.x = (rect.x - this.visibleRect.x) / time;\n }\n\n if (rect.y !== this.visibleRect.y && time > 0) {\n this.velocity.y = (rect.y - this.visibleRect.y) / time;\n }\n }\n\n this.startTime = performance.now();\n this.visibleRect = rect;\n }\n\n getOverscannedRect(): Rect {\n let overscanned = this.visibleRect.copy();\n\n let overscanY = this.visibleRect.height / 3;\n overscanned.height += overscanY;\n if (this.velocity.y < 0) {\n overscanned.y -= overscanY;\n }\n\n if (this.velocity.x !== 0) {\n let overscanX = this.visibleRect.width / 3;\n overscanned.width += overscanX;\n if (this.velocity.x < 0) {\n overscanned.x -= overscanX;\n }\n }\n\n return overscanned;\n }\n}\n"],"names":[],"version":3,"file":"OverscanManager.main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAKM,MAAM;IAKX,eAAe,IAAU,
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAKM,MAAM;IAKX,eAAe,IAAU,EAAQ;QAC/B,IAAI,OAAO,YAAY,GAAG,KAAK,IAAI,CAAC,SAAS;QAC7C,IAAI,OAAO,KAAK;YACd,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,OAAO,GAC1C,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,AAAC,CAAA,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,AAAD,IAAK;YAGpD,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,OAAO,GAC1C,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,AAAC,CAAA,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,AAAD,IAAK;QAEtD;QAEA,IAAI,CAAC,SAAS,GAAG,YAAY,GAAG;QAChC,IAAI,CAAC,WAAW,GAAG;IACrB;IAEA,qBAA2B;QACzB,IAAI,cAAc,IAAI,CAAC,WAAW,CAAC,IAAI;QAEvC,IAAI,YAAY,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG;QAC1C,YAAY,MAAM,IAAI;QACtB,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,GACpB,YAAY,CAAC,IAAI;QAGnB,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,GAAG;YACzB,IAAI,YAAY,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG;YACzC,YAAY,KAAK,IAAI;YACrB,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,GACpB,YAAY,CAAC,IAAI;QAErB;QAEA,OAAO;IACT;;aAtCQ,YAAY;aACZ,WAAW,IAAI,CAAA,GAAA,yCAAI,EAAE,GAAG;aACxB,cAAc,IAAI,CAAA,GAAA,yCAAG;;AAqC/B","sources":["packages/@react-stately/virtualizer/src/OverscanManager.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 {Rect} from './Rect';\n\nexport class OverscanManager {\n private startTime = 0;\n private velocity = new Point(0, 0);\n private visibleRect = new Rect();\n\n setVisibleRect(rect: Rect): void {\n let time = performance.now() - this.startTime;\n if (time < 500) {\n if (rect.x !== this.visibleRect.x && time > 0) {\n this.velocity.x = (rect.x - this.visibleRect.x) / time;\n }\n\n if (rect.y !== this.visibleRect.y && time > 0) {\n this.velocity.y = (rect.y - this.visibleRect.y) / time;\n }\n }\n\n this.startTime = performance.now();\n this.visibleRect = rect;\n }\n\n getOverscannedRect(): Rect {\n let overscanned = this.visibleRect.copy();\n\n let overscanY = this.visibleRect.height / 3;\n overscanned.height += overscanY;\n if (this.velocity.y < 0) {\n overscanned.y -= overscanY;\n }\n\n if (this.velocity.x !== 0) {\n let overscanX = this.visibleRect.width / 3;\n overscanned.width += overscanX;\n if (this.velocity.x < 0) {\n overscanned.x -= overscanX;\n }\n }\n\n return overscanned;\n }\n}\n"],"names":[],"version":3,"file":"OverscanManager.module.js.map"}
|
package/dist/Rect.main.js
CHANGED
|
@@ -57,7 +57,7 @@ class $41b7691783731623$export$c79fc6492f3af13d {
|
|
|
57
57
|
* Returns whether this rectangle intersects another rectangle.
|
|
58
58
|
* @param rect - The rectangle to check.
|
|
59
59
|
*/ intersects(rect) {
|
|
60
|
-
return this.x <= rect.x + rect.width && rect.x <= this.x + this.width && this.y <= rect.y + rect.height && rect.y <= this.y + this.height;
|
|
60
|
+
return this.area > 0 && rect.area > 0 && this.x <= rect.x + rect.width && rect.x <= this.x + this.width && this.y <= rect.y + rect.height && rect.y <= this.y + this.height;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Returns whether this rectangle fully contains another rectangle.
|
package/dist/Rect.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,+BAAI,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACjC;IAEA;;GAEC,GACD,I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AK,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC;QAChC,IAAI,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI;QAC9C,IAAI,SAAS,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI;QAC/C,OAAO,IAAI,0CAAK,GAAG,GAAG,OAAO;IAC/B;IAEA;;;GAGC,GACD,aAAa,KAAW,EAAQ;QAC9B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QACnB,OAAO,IAAI,0CAAK,GAAG,GAAG,GAAG;QAG3B,IAAI,IAAI,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 return this.area > 0 \n && 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.main.js.map"}
|
package/dist/Rect.mjs
CHANGED
|
@@ -51,7 +51,7 @@ class $60423f92c7f9ad87$export$c79fc6492f3af13d {
|
|
|
51
51
|
* Returns whether this rectangle intersects another rectangle.
|
|
52
52
|
* @param rect - The rectangle to check.
|
|
53
53
|
*/ intersects(rect) {
|
|
54
|
-
return this.x <= rect.x + rect.width && rect.x <= this.x + this.width && this.y <= rect.y + rect.height && rect.y <= this.y + this.height;
|
|
54
|
+
return this.area > 0 && rect.area > 0 && this.x <= rect.x + rect.width && rect.x <= this.x + this.width && this.y <= rect.y + rect.height && rect.y <= this.y + this.height;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Returns whether this rectangle fully contains another rectangle.
|
package/dist/Rect.module.js
CHANGED
|
@@ -51,7 +51,7 @@ class $60423f92c7f9ad87$export$c79fc6492f3af13d {
|
|
|
51
51
|
* Returns whether this rectangle intersects another rectangle.
|
|
52
52
|
* @param rect - The rectangle to check.
|
|
53
53
|
*/ intersects(rect) {
|
|
54
|
-
return this.x <= rect.x + rect.width && rect.x <= this.x + this.width && this.y <= rect.y + rect.height && rect.y <= this.y + this.height;
|
|
54
|
+
return this.area > 0 && rect.area > 0 && this.x <= rect.x + rect.width && rect.x <= this.x + this.width && this.y <= rect.y + rect.height && rect.y <= this.y + this.height;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Returns whether this rectangle fully contains another rectangle.
|
package/dist/Rect.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,C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I,CAAC,CAAC,EAAE,MAAM,CAAC;QAChC,IAAI,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC;QAChC,IAAI,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI;QAC9C,IAAI,SAAS,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI;QAC/C,OAAO,IAAI,0CAAK,GAAG,GAAG,OAAO;IAC/B;IAEA;;;GAGC,GACD,aAAa,KAAW,EAAQ;QAC9B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QACnB,OAAO,IAAI,0CAAK,GAAG,GAAG,GAAG;QAG3B,IAAI,IAAI,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 return this.area > 0 \n && 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 +1 @@
|
|
|
1
|
-
{"mappings":";;;;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AAY,WAA8B,EAAE,MAA0B,EAAE,QAAgB,CAAE;QACxF,KAAK,CAAC,aAAa;QACnB,IAAI,CAAC,MAAM,GAAG;IAChB;AACF","sources":["packages/@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 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAMD,IAAI,4BAAM;AAMH,MAAM;IA6BX;;GAEC,GACD,
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAMD,IAAI,4BAAM;AAMH,MAAM;IA6BX;;GAEC,GACD,kBAAwB;QACtB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,UAAU,GAAG;IACpB;IAEA,gBAAgB,SAAiB,EAAmB;QAClD,4FAA4F;QAC5F,oGAAoG;QACpG,iGAAiG;QACjG,sEAAsE;QACtE,IAAI,WAAW,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QACtC,IAAI,OAAO,YAAY,SAAS,MAAM,GAAG,IACrC,SAAS,KAAK,KACd,IAAI,0CAAgB,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE;QAEhD,OAAO;IACT;IAEA,WAAW,KAAsB,EAAQ;QACvC,MAAM,eAAe;QACrB,IAAI,WAAW,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,QAAQ;QACpD,IAAI,CAAC,UAAU;YACb,WAAW,EAAE;YACb,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,QAAQ,EAAE;QACzC;QACA,SAAS,IAAI,CAAC;IAChB;IAzCA,YAAY,WAA8B,EAAE,QAAgB,CAAE;QAC5D,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE;QACb,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,QAAQ,GAAG,IAAI;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI;QACzB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,QAAQ,GAAG;IAClB;AAiCF;AAEO,MAAM,kDAAsC;IACjD,YAAY,WAA8B,CAAE;QAC1C,KAAK,CAAC,aAAa;IACrB;AACF;AAEO,MAAM,kDAAuC;IAGlD,YAAY,WAA8B,EAAE,MAA0B,EAAE,QAAgB,CAAE;QACxF,KAAK,CAAC,aAAa;QACnB,IAAI,CAAC,MAAM,GAAG;IAChB;AACF","sources":["packages/@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.module.js.map"}
|
package/dist/Size.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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;QACb,IAAI,CAAC,MAAM,GAAG;IAChB;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 = width;\n this.height = height;\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.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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;QACb,IAAI,CAAC,MAAM,GAAG;IAChB;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 = width;\n this.height = height;\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"}
|
package/dist/Virtualizer.main.js
CHANGED
|
@@ -92,13 +92,13 @@ class $e1bc15d49d21df0e$export$89be5a243e59c4b2 {
|
|
|
92
92
|
} else this.updateSubviews();
|
|
93
93
|
}
|
|
94
94
|
getVisibleLayoutInfos() {
|
|
95
|
-
let isTestEnv =
|
|
95
|
+
let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;
|
|
96
96
|
let isClientWidthMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientWidth');
|
|
97
97
|
let isClientHeightMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientHeight');
|
|
98
98
|
let rect;
|
|
99
99
|
if (isTestEnv && !(isClientWidthMocked && isClientHeightMocked)) rect = new (0, $41b7691783731623$exports.Rect)(0, 0, this.contentSize.width, this.contentSize.height);
|
|
100
100
|
else rect = this._overscanManager.getOverscannedRect();
|
|
101
|
-
let layoutInfos =
|
|
101
|
+
let layoutInfos = this.layout.getVisibleLayoutInfos(rect);
|
|
102
102
|
let map = new Map;
|
|
103
103
|
for (let layoutInfo of layoutInfos)map.set(layoutInfo.key, layoutInfo);
|
|
104
104
|
return map;
|
|
@@ -1 +1 @@
|
|
|
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AAI,CAAC,MAAM,GAAG,QAAQ,MAAM;QAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA,GAAA,8BAAG;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA,GAAA,8BAAG;QAC1B,IAAI,CAAC,aAAa,GAAG,IAAI;QACzB,IAAI,CAAC,aAAa,GAAG,IAAI;QACzB,IAAI,CAAC,gBAAgB,GAAG,IAAI;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA,GAAA,kCAAO,EAAE,IAAI;QAClC,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,oBAAoB,GAAG,CAAC;QAC7B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA,GAAA,yCAAc;IAC5C;AAwRF","sources":["packages/@react-stately/virtualizer/src/Virtualizer.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 {ChildView, ReusableView, RootView} from './ReusableView';\nimport {Collection, Key} from '@react-types/shared';\nimport {InvalidationContext, Mutable, VirtualizerDelegate, VirtualizerRenderOptions} from './types';\nimport {isSetEqual} from './utils';\nimport {Layout} from './Layout';\nimport {LayoutInfo} from './LayoutInfo';\nimport {OverscanManager} from './OverscanManager';\nimport {Point} from './Point';\nimport {Rect} from './Rect';\nimport {Size} from './Size';\n\ninterface VirtualizerOptions<T extends object, V> {\n delegate: VirtualizerDelegate<T, V>,\n collection: Collection<T>,\n layout: Layout<T>\n}\n\n/**\n * The Virtualizer class renders a scrollable collection of data using customizable layouts.\n * It supports very large collections by only rendering visible views to the DOM, reusing\n * them as you scroll. Virtualizer can present any type of view, including non-item views\n * such as section headers and footers.\n *\n * Virtualizer uses `Layout` objects to compute what views should be visible, and how\n * to position and style them. This means that virtualizer can have its items arranged in\n * a stack, a grid, a circle, or any other layout you can think of. The layout can be changed\n * dynamically at runtime as well.\n *\n * Layouts produce information on what views should appear in the virtualizer, but do not create\n * the views themselves directly. It is the responsibility of the `VirtualizerDelegate` object\n * to render elements for each layout info. The virtualizer manages a set of `ReusableView` objects,\n * which are reused as the user scrolls by swapping their content with cached elements returned by the delegate.\n */\nexport class Virtualizer<T extends object, V> {\n /**\n * The virtualizer delegate. The delegate is used by the virtualizer\n * to create and configure views.\n */\n delegate: VirtualizerDelegate<T, V>;\n\n /** The current content of the virtualizer. */\n readonly collection: Collection<T>;\n /** The layout object that determines the visible views. */\n readonly layout: Layout<T>;\n /** The size of the scrollable content. */\n readonly contentSize: Size;\n /** The currently visible rectangle. */\n readonly visibleRect: Rect;\n /** The set of persisted keys that are always present in the DOM, even if not currently in view. */\n readonly persistedKeys: Set<Key>;\n\n private _visibleViews: Map<Key, ChildView<T, V>>;\n private _renderedContent: WeakMap<T, V>;\n private _rootView: RootView<T, V>;\n private _isScrolling: boolean;\n private _invalidationContext: InvalidationContext;\n private _overscanManager: OverscanManager;\n\n constructor(options: VirtualizerOptions<T, V>) {\n this.delegate = options.delegate;\n this.collection = options.collection;\n this.layout = options.layout;\n this.contentSize = new Size;\n this.visibleRect = new Rect;\n this.persistedKeys = new Set();\n this._visibleViews = new Map();\n this._renderedContent = new WeakMap();\n this._rootView = new RootView(this);\n this._isScrolling = false;\n this._invalidationContext = {};\n this._overscanManager = new OverscanManager();\n }\n\n /** Returns whether the given key, or an ancestor, is persisted. */\n isPersistedKey(key: Key) {\n // Quick check if the key is directly in the set of persisted keys.\n if (this.persistedKeys.has(key)) {\n return true;\n }\n\n // If not, check if the key is an ancestor of any of the persisted keys.\n for (let k of this.persistedKeys) {\n while (k != null) {\n let layoutInfo = this.layout.getLayoutInfo(k);\n if (!layoutInfo || layoutInfo.parentKey == null) {\n break;\n }\n\n k = layoutInfo.parentKey;\n\n if (k === key) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n private getParentView(layoutInfo: LayoutInfo): ReusableView<T, V> | undefined {\n return layoutInfo.parentKey != null ? this._visibleViews.get(layoutInfo.parentKey) : this._rootView;\n }\n\n private getReusableView(layoutInfo: LayoutInfo): ChildView<T, V> {\n let parentView = this.getParentView(layoutInfo)!;\n let view = parentView.getReusableView(layoutInfo.type);\n view.layoutInfo = layoutInfo;\n this._renderView(view);\n return view;\n }\n\n private _renderView(reusableView: ReusableView<T, V>) {\n if (reusableView.layoutInfo) {\n let {type, key, content} = reusableView.layoutInfo;\n reusableView.content = content || this.collection.getItem(key);\n reusableView.rendered = this._renderContent(type, reusableView.content);\n }\n }\n\n private _renderContent(type: string, content: T | null) {\n let cached = content != null ? this._renderedContent.get(content) : null;\n if (cached != null) {\n return cached;\n }\n\n let rendered = this.delegate.renderView(type, content);\n if (content) {\n this._renderedContent.set(content, rendered);\n }\n return rendered;\n }\n\n /**\n * Returns the key for the item view currently at the given point.\n */\n keyAtPoint(point: Point): Key | null {\n let rect = new Rect(point.x, point.y, 1, 1);\n let layoutInfos = rect.area === 0 ? [] : this.layout.getVisibleLayoutInfos(rect);\n\n // Layout may return multiple layout infos in the case of\n // persisted keys, so find the first one that actually intersects.\n for (let layoutInfo of layoutInfos) {\n if (layoutInfo.rect.intersects(rect)) {\n return layoutInfo.key;\n }\n }\n\n return null;\n }\n\n private relayout(context: InvalidationContext = {}) {\n // Update the layout\n this.layout.update(context);\n (this as Mutable<this>).contentSize = this.layout.getContentSize();\n\n // Constrain scroll position.\n // If the content changed, scroll to the top.\n let visibleRect = this.visibleRect;\n let contentOffsetX = context.contentChanged ? 0 : visibleRect.x;\n let contentOffsetY = context.contentChanged ? 0 : visibleRect.y;\n contentOffsetX = Math.max(0, Math.min(this.contentSize.width - visibleRect.width, contentOffsetX));\n contentOffsetY = Math.max(0, Math.min(this.contentSize.height - visibleRect.height, contentOffsetY));\n\n if (contentOffsetX !== visibleRect.x || contentOffsetY !== visibleRect.y) {\n // If the offset changed, trigger a new re-render.\n let rect = new Rect(contentOffsetX, contentOffsetY, visibleRect.width, visibleRect.height);\n this.delegate.setVisibleRect(rect);\n } else {\n this.updateSubviews();\n }\n }\n\n getVisibleLayoutInfos() {\n let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;\n let isClientWidthMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientWidth');\n let isClientHeightMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientHeight');\n\n let rect: Rect;\n if (isTestEnv && !(isClientWidthMocked && isClientHeightMocked)) {\n rect = new Rect(0, 0, this.contentSize.width, this.contentSize.height);\n } else {\n rect = this._overscanManager.getOverscannedRect();\n }\n\n let layoutInfos = rect.area === 0 ? [] : this.layout.getVisibleLayoutInfos(rect);\n let map = new Map;\n for (let layoutInfo of layoutInfos) {\n map.set(layoutInfo.key, layoutInfo);\n }\n\n return map;\n }\n\n private updateSubviews() {\n let visibleLayoutInfos = this.getVisibleLayoutInfos();\n\n let removed = new Set<ChildView<T, V>>();\n for (let [key, view] of this._visibleViews) {\n let layoutInfo = visibleLayoutInfos.get(key);\n // If a view's parent changed, treat it as a delete and re-create in the new parent.\n if (!layoutInfo || view.parent !== this.getParentView(layoutInfo)) {\n this._visibleViews.delete(key);\n view.parent.reuseChild(view);\n removed.add(view); // Defer removing in case we reuse this view.\n }\n }\n\n for (let [key, layoutInfo] of visibleLayoutInfos) {\n let view = this._visibleViews.get(key);\n if (!view) {\n view = this.getReusableView(layoutInfo);\n view.parent.children.add(view);\n this._visibleViews.set(key, view);\n removed.delete(view);\n } else {\n view.layoutInfo = layoutInfo;\n\n let item = this.collection.getItem(layoutInfo.key);\n if (view.content !== item) {\n if (view.content != null) {\n this._renderedContent.delete(view.content);\n }\n this._renderView(view);\n }\n }\n }\n\n // The remaining views in `removed` were not reused to render new items.\n // They should be removed from the DOM. We also clear the reusable view queue\n // here since there's no point holding onto views that have been removed.\n // Doing so hurts performance in the future when reusing elements due to FIFO order.\n for (let view of removed) {\n view.parent.children.delete(view);\n view.parent.reusableViews.clear();\n }\n\n // Reordering DOM nodes is costly, so we defer this until scrolling stops.\n // DOM order does not affect visual order (due to absolute positioning),\n // but does matter for assistive technology users.\n if (!this._isScrolling) {\n // Layout infos must be in topological order (parents before children).\n for (let key of visibleLayoutInfos.keys()) {\n let view = this._visibleViews.get(key)!;\n view.parent.children.delete(view);\n view.parent.children.add(view);\n }\n }\n }\n\n /** Performs layout and updates visible views as needed. */\n render(opts: VirtualizerRenderOptions<T>): ReusableView<T, V>[] {\n let mutableThis: Mutable<this> = this;\n let needsLayout = false;\n let offsetChanged = false;\n let sizeChanged = false;\n let itemSizeChanged = false;\n let layoutOptionsChanged = false;\n let needsUpdate = false;\n\n if (opts.collection !== this.collection) {\n mutableThis.collection = opts.collection;\n needsLayout = true;\n }\n\n if (opts.layout !== this.layout || this.layout.virtualizer !== this) {\n if (this.layout) {\n this.layout.virtualizer = null;\n }\n\n opts.layout.virtualizer = this;\n mutableThis.layout = opts.layout;\n needsLayout = true;\n }\n\n if (opts.persistedKeys && !isSetEqual(opts.persistedKeys, this.persistedKeys)) {\n mutableThis.persistedKeys = opts.persistedKeys;\n needsUpdate = true;\n }\n\n if (!this.visibleRect.equals(opts.visibleRect)) {\n this._overscanManager.setVisibleRect(opts.visibleRect);\n let shouldInvalidate = this.layout.shouldInvalidate(opts.visibleRect, this.visibleRect);\n\n if (shouldInvalidate) {\n offsetChanged = !opts.visibleRect.pointEquals(this.visibleRect);\n sizeChanged = !opts.visibleRect.sizeEquals(this.visibleRect);\n needsLayout = true;\n } else {\n needsUpdate = true;\n }\n\n mutableThis.visibleRect = opts.visibleRect;\n }\n\n if (opts.invalidationContext !== this._invalidationContext) {\n if (opts.invalidationContext) {\n sizeChanged ||= opts.invalidationContext.sizeChanged || false;\n offsetChanged ||= opts.invalidationContext.offsetChanged || false;\n itemSizeChanged ||= opts.invalidationContext.itemSizeChanged || false;\n layoutOptionsChanged ||= opts.invalidationContext.layoutOptions != null\n && this._invalidationContext.layoutOptions != null\n && opts.invalidationContext.layoutOptions !== this._invalidationContext.layoutOptions \n && this.layout.shouldInvalidateLayoutOptions(opts.invalidationContext.layoutOptions, this._invalidationContext.layoutOptions);\n needsLayout ||= itemSizeChanged || sizeChanged || offsetChanged || layoutOptionsChanged;\n }\n this._invalidationContext = opts.invalidationContext;\n }\n\n if (opts.isScrolling !== this._isScrolling) {\n this._isScrolling = opts.isScrolling;\n if (!opts.isScrolling) {\n // Update to fix the DOM order after scrolling.\n needsUpdate = true;\n }\n }\n\n if (needsLayout) {\n this.relayout({\n offsetChanged,\n sizeChanged,\n itemSizeChanged,\n layoutOptionsChanged,\n layoutOptions: this._invalidationContext.layoutOptions\n });\n } else if (needsUpdate) {\n this.updateSubviews();\n }\n\n return Array.from(this._rootView.children);\n }\n\n getVisibleView(key: Key): ReusableView<T, V> | undefined {\n return this._visibleViews.get(key);\n }\n\n invalidate(context: InvalidationContext) {\n this.delegate.invalidate(context);\n }\n\n updateItemSize(key: Key, size: Size) {\n if (!this.layout.updateItemSize) {\n return;\n }\n\n let changed = this.layout.updateItemSize(key, size);\n if (changed) {\n this.invalidate({\n itemSizeChanged: true\n });\n }\n }\n}\n"],"names":[],"version":3,"file":"Virtualizer.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAmCM,MAAM;IAwCX,iEAAiE,GACjE,eAAe,GAAQ,EAAW;QAChC,mEAAmE;QACnE,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MACzB,OAAO;QAGT,wEAAwE;QACxE,KAAK,IAAI,KAAK,IAAI,CAAC,aAAa,CAC9B,MAAO,KAAK,KAAM;YAChB,IAAI,aAAa,IAAI,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G,IAAI;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA,GAAA,kCAAO,EAAE,IAAI;QAClC,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,oBAAoB,GAAG,CAAC;QAC7B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA,GAAA,yCAAc;IAC5C;AAuRF","sources":["packages/@react-stately/virtualizer/src/Virtualizer.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 {ChildView, ReusableView, RootView} from './ReusableView';\nimport {Collection, Key} from '@react-types/shared';\nimport {InvalidationContext, Mutable, VirtualizerDelegate, VirtualizerRenderOptions} from './types';\nimport {isSetEqual} from './utils';\nimport {Layout} from './Layout';\nimport {LayoutInfo} from './LayoutInfo';\nimport {OverscanManager} from './OverscanManager';\nimport {Point} from './Point';\nimport {Rect} from './Rect';\nimport {Size} from './Size';\n\ninterface VirtualizerOptions<T extends object, V> {\n delegate: VirtualizerDelegate<T, V>,\n collection: Collection<T>,\n layout: Layout<T>\n}\n\n/**\n * The Virtualizer class renders a scrollable collection of data using customizable layouts.\n * It supports very large collections by only rendering visible views to the DOM, reusing\n * them as you scroll. Virtualizer can present any type of view, including non-item views\n * such as section headers and footers.\n *\n * Virtualizer uses `Layout` objects to compute what views should be visible, and how\n * to position and style them. This means that virtualizer can have its items arranged in\n * a stack, a grid, a circle, or any other layout you can think of. The layout can be changed\n * dynamically at runtime as well.\n *\n * Layouts produce information on what views should appear in the virtualizer, but do not create\n * the views themselves directly. It is the responsibility of the `VirtualizerDelegate` object\n * to render elements for each layout info. The virtualizer manages a set of `ReusableView` objects,\n * which are reused as the user scrolls by swapping their content with cached elements returned by the delegate.\n */\nexport class Virtualizer<T extends object, V> {\n /**\n * The virtualizer delegate. The delegate is used by the virtualizer\n * to create and configure views.\n */\n delegate: VirtualizerDelegate<T, V>;\n\n /** The current content of the virtualizer. */\n readonly collection: Collection<T>;\n /** The layout object that determines the visible views. */\n readonly layout: Layout<T>;\n /** The size of the scrollable content. */\n readonly contentSize: Size;\n /** The currently visible rectangle. */\n readonly visibleRect: Rect;\n /** The set of persisted keys that are always present in the DOM, even if not currently in view. */\n readonly persistedKeys: Set<Key>;\n\n private _visibleViews: Map<Key, ChildView<T, V>>;\n private _renderedContent: WeakMap<T, V>;\n private _rootView: RootView<T, V>;\n private _isScrolling: boolean;\n private _invalidationContext: InvalidationContext;\n private _overscanManager: OverscanManager;\n\n constructor(options: VirtualizerOptions<T, V>) {\n this.delegate = options.delegate;\n this.collection = options.collection;\n this.layout = options.layout;\n this.contentSize = new Size;\n this.visibleRect = new Rect;\n this.persistedKeys = new Set();\n this._visibleViews = new Map();\n this._renderedContent = new WeakMap();\n this._rootView = new RootView(this);\n this._isScrolling = false;\n this._invalidationContext = {};\n this._overscanManager = new OverscanManager();\n }\n\n /** Returns whether the given key, or an ancestor, is persisted. */\n isPersistedKey(key: Key): boolean {\n // Quick check if the key is directly in the set of persisted keys.\n if (this.persistedKeys.has(key)) {\n return true;\n }\n\n // If not, check if the key is an ancestor of any of the persisted keys.\n for (let k of this.persistedKeys) {\n while (k != null) {\n let layoutInfo = this.layout.getLayoutInfo(k);\n if (!layoutInfo || layoutInfo.parentKey == null) {\n break;\n }\n\n k = layoutInfo.parentKey;\n\n if (k === key) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n private getParentView(layoutInfo: LayoutInfo): ReusableView<T, V> | undefined {\n return layoutInfo.parentKey != null ? this._visibleViews.get(layoutInfo.parentKey) : this._rootView;\n }\n\n private getReusableView(layoutInfo: LayoutInfo): ChildView<T, V> {\n let parentView = this.getParentView(layoutInfo)!;\n let view = parentView.getReusableView(layoutInfo.type);\n view.layoutInfo = layoutInfo;\n this._renderView(view);\n return view;\n }\n\n private _renderView(reusableView: ReusableView<T, V>) {\n if (reusableView.layoutInfo) {\n let {type, key, content} = reusableView.layoutInfo;\n reusableView.content = content || this.collection.getItem(key);\n reusableView.rendered = this._renderContent(type, reusableView.content);\n }\n }\n\n private _renderContent(type: string, content: T | null) {\n let cached = content != null ? this._renderedContent.get(content) : null;\n if (cached != null) {\n return cached;\n }\n\n let rendered = this.delegate.renderView(type, content);\n if (content) {\n this._renderedContent.set(content, rendered);\n }\n return rendered;\n }\n\n /**\n * Returns the key for the item view currently at the given point.\n */\n keyAtPoint(point: Point): Key | null {\n let rect = new Rect(point.x, point.y, 1, 1);\n let layoutInfos = rect.area === 0 ? [] : this.layout.getVisibleLayoutInfos(rect);\n\n // Layout may return multiple layout infos in the case of\n // persisted keys, so find the first one that actually intersects.\n for (let layoutInfo of layoutInfos) {\n if (layoutInfo.rect.intersects(rect)) {\n return layoutInfo.key;\n }\n }\n\n return null;\n }\n\n private relayout(context: InvalidationContext = {}) {\n // Update the layout\n this.layout.update(context);\n (this as Mutable<this>).contentSize = this.layout.getContentSize();\n\n // Constrain scroll position.\n // If the content changed, scroll to the top.\n let visibleRect = this.visibleRect;\n let contentOffsetX = context.contentChanged ? 0 : visibleRect.x;\n let contentOffsetY = context.contentChanged ? 0 : visibleRect.y;\n contentOffsetX = Math.max(0, Math.min(this.contentSize.width - visibleRect.width, contentOffsetX));\n contentOffsetY = Math.max(0, Math.min(this.contentSize.height - visibleRect.height, contentOffsetY));\n\n if (contentOffsetX !== visibleRect.x || contentOffsetY !== visibleRect.y) {\n // If the offset changed, trigger a new re-render.\n let rect = new Rect(contentOffsetX, contentOffsetY, visibleRect.width, visibleRect.height);\n this.delegate.setVisibleRect(rect);\n } else {\n this.updateSubviews();\n }\n }\n\n getVisibleLayoutInfos(): Map<Key, LayoutInfo> {\n let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;\n let isClientWidthMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientWidth');\n let isClientHeightMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientHeight');\n\n let rect: Rect;\n if (isTestEnv && !(isClientWidthMocked && isClientHeightMocked)) {\n rect = new Rect(0, 0, this.contentSize.width, this.contentSize.height);\n } else {\n rect = this._overscanManager.getOverscannedRect();\n }\n let layoutInfos = this.layout.getVisibleLayoutInfos(rect);\n let map = new Map;\n for (let layoutInfo of layoutInfos) {\n map.set(layoutInfo.key, layoutInfo);\n }\n\n return map;\n }\n\n private updateSubviews() {\n let visibleLayoutInfos = this.getVisibleLayoutInfos();\n\n let removed = new Set<ChildView<T, V>>();\n for (let [key, view] of this._visibleViews) {\n let layoutInfo = visibleLayoutInfos.get(key);\n // If a view's parent changed, treat it as a delete and re-create in the new parent.\n if (!layoutInfo || view.parent !== this.getParentView(layoutInfo)) {\n this._visibleViews.delete(key);\n view.parent.reuseChild(view);\n removed.add(view); // Defer removing in case we reuse this view.\n }\n }\n\n for (let [key, layoutInfo] of visibleLayoutInfos) {\n let view = this._visibleViews.get(key);\n if (!view) {\n view = this.getReusableView(layoutInfo);\n view.parent.children.add(view);\n this._visibleViews.set(key, view);\n removed.delete(view);\n } else {\n view.layoutInfo = layoutInfo;\n\n let item = this.collection.getItem(layoutInfo.key);\n if (view.content !== item) {\n if (view.content != null) {\n this._renderedContent.delete(view.content);\n }\n this._renderView(view);\n }\n }\n }\n\n // The remaining views in `removed` were not reused to render new items.\n // They should be removed from the DOM. We also clear the reusable view queue\n // here since there's no point holding onto views that have been removed.\n // Doing so hurts performance in the future when reusing elements due to FIFO order.\n for (let view of removed) {\n view.parent.children.delete(view);\n view.parent.reusableViews.clear();\n }\n\n // Reordering DOM nodes is costly, so we defer this until scrolling stops.\n // DOM order does not affect visual order (due to absolute positioning),\n // but does matter for assistive technology users.\n if (!this._isScrolling) {\n // Layout infos must be in topological order (parents before children).\n for (let key of visibleLayoutInfos.keys()) {\n let view = this._visibleViews.get(key)!;\n view.parent.children.delete(view);\n view.parent.children.add(view);\n }\n }\n }\n\n /** Performs layout and updates visible views as needed. */\n render(opts: VirtualizerRenderOptions<T>): ReusableView<T, V>[] {\n let mutableThis: Mutable<this> = this;\n let needsLayout = false;\n let offsetChanged = false;\n let sizeChanged = false;\n let itemSizeChanged = false;\n let layoutOptionsChanged = false;\n let needsUpdate = false;\n\n if (opts.collection !== this.collection) {\n mutableThis.collection = opts.collection;\n needsLayout = true;\n }\n\n if (opts.layout !== this.layout || this.layout.virtualizer !== this) {\n if (this.layout) {\n this.layout.virtualizer = null;\n }\n\n opts.layout.virtualizer = this;\n mutableThis.layout = opts.layout;\n needsLayout = true;\n }\n\n if (opts.persistedKeys && !isSetEqual(opts.persistedKeys, this.persistedKeys)) {\n mutableThis.persistedKeys = opts.persistedKeys;\n needsUpdate = true;\n }\n\n if (!this.visibleRect.equals(opts.visibleRect)) {\n this._overscanManager.setVisibleRect(opts.visibleRect);\n let shouldInvalidate = this.layout.shouldInvalidate(opts.visibleRect, this.visibleRect);\n\n if (shouldInvalidate) {\n offsetChanged = !opts.visibleRect.pointEquals(this.visibleRect);\n sizeChanged = !opts.visibleRect.sizeEquals(this.visibleRect);\n needsLayout = true;\n } else {\n needsUpdate = true;\n }\n\n mutableThis.visibleRect = opts.visibleRect;\n }\n\n if (opts.invalidationContext !== this._invalidationContext) {\n if (opts.invalidationContext) {\n sizeChanged ||= opts.invalidationContext.sizeChanged || false;\n offsetChanged ||= opts.invalidationContext.offsetChanged || false;\n itemSizeChanged ||= opts.invalidationContext.itemSizeChanged || false;\n layoutOptionsChanged ||= opts.invalidationContext.layoutOptions != null\n && this._invalidationContext.layoutOptions != null\n && opts.invalidationContext.layoutOptions !== this._invalidationContext.layoutOptions\n && this.layout.shouldInvalidateLayoutOptions(opts.invalidationContext.layoutOptions, this._invalidationContext.layoutOptions);\n needsLayout ||= itemSizeChanged || sizeChanged || offsetChanged || layoutOptionsChanged;\n }\n this._invalidationContext = opts.invalidationContext;\n }\n\n if (opts.isScrolling !== this._isScrolling) {\n this._isScrolling = opts.isScrolling;\n if (!opts.isScrolling) {\n // Update to fix the DOM order after scrolling.\n needsUpdate = true;\n }\n }\n\n if (needsLayout) {\n this.relayout({\n offsetChanged,\n sizeChanged,\n itemSizeChanged,\n layoutOptionsChanged,\n layoutOptions: this._invalidationContext.layoutOptions\n });\n } else if (needsUpdate) {\n this.updateSubviews();\n }\n\n return Array.from(this._rootView.children);\n }\n\n getVisibleView(key: Key): ReusableView<T, V> | undefined {\n return this._visibleViews.get(key);\n }\n\n invalidate(context: InvalidationContext): void {\n this.delegate.invalidate(context);\n }\n\n updateItemSize(key: Key, size: Size): void {\n if (!this.layout.updateItemSize) {\n return;\n }\n\n let changed = this.layout.updateItemSize(key, size);\n if (changed) {\n this.invalidate({\n itemSizeChanged: true\n });\n }\n }\n}\n"],"names":[],"version":3,"file":"Virtualizer.main.js.map"}
|
package/dist/Virtualizer.mjs
CHANGED
|
@@ -86,13 +86,13 @@ class $38b9490c1cca8fc4$export$89be5a243e59c4b2 {
|
|
|
86
86
|
} else this.updateSubviews();
|
|
87
87
|
}
|
|
88
88
|
getVisibleLayoutInfos() {
|
|
89
|
-
let isTestEnv =
|
|
89
|
+
let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;
|
|
90
90
|
let isClientWidthMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientWidth');
|
|
91
91
|
let isClientHeightMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientHeight');
|
|
92
92
|
let rect;
|
|
93
93
|
if (isTestEnv && !(isClientWidthMocked && isClientHeightMocked)) rect = new (0, $60423f92c7f9ad87$export$c79fc6492f3af13d)(0, 0, this.contentSize.width, this.contentSize.height);
|
|
94
94
|
else rect = this._overscanManager.getOverscannedRect();
|
|
95
|
-
let layoutInfos =
|
|
95
|
+
let layoutInfos = this.layout.getVisibleLayoutInfos(rect);
|
|
96
96
|
let map = new Map;
|
|
97
97
|
for (let layoutInfo of layoutInfos)map.set(layoutInfo.key, layoutInfo);
|
|
98
98
|
return map;
|
|
@@ -86,13 +86,13 @@ class $38b9490c1cca8fc4$export$89be5a243e59c4b2 {
|
|
|
86
86
|
} else this.updateSubviews();
|
|
87
87
|
}
|
|
88
88
|
getVisibleLayoutInfos() {
|
|
89
|
-
let isTestEnv =
|
|
89
|
+
let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;
|
|
90
90
|
let isClientWidthMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientWidth');
|
|
91
91
|
let isClientHeightMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientHeight');
|
|
92
92
|
let rect;
|
|
93
93
|
if (isTestEnv && !(isClientWidthMocked && isClientHeightMocked)) rect = new (0, $60423f92c7f9ad87$export$c79fc6492f3af13d)(0, 0, this.contentSize.width, this.contentSize.height);
|
|
94
94
|
else rect = this._overscanManager.getOverscannedRect();
|
|
95
|
-
let layoutInfos =
|
|
95
|
+
let layoutInfos = this.layout.getVisibleLayoutInfos(rect);
|
|
96
96
|
let map = new Map;
|
|
97
97
|
for (let layoutInfo of layoutInfos)map.set(layoutInfo.key, layoutInfo);
|
|
98
98
|
return map;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAmCM,MAAM;IAwCX,iEAAiE,GACjE,eAAe,GAAQ,EAAE;QACvB,mEAAmE;QACnE,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MACzB,OAAO;QAGT,wEAAwE;QACxE,KAAK,IAA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,IAAI;QACzB,IAAI,CAAC,gBAAgB,GAAG,IAAI;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA,GAAA,yCAAO,EAAE,IAAI;QAClC,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,oBAAoB,GAAG,CAAC;QAC7B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA,GAAA,yCAAc;IAC5C;AAwRF","sources":["packages/@react-stately/virtualizer/src/Virtualizer.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 {ChildView, ReusableView, RootView} from './ReusableView';\nimport {Collection, Key} from '@react-types/shared';\nimport {InvalidationContext, Mutable, VirtualizerDelegate, VirtualizerRenderOptions} from './types';\nimport {isSetEqual} from './utils';\nimport {Layout} from './Layout';\nimport {LayoutInfo} from './LayoutInfo';\nimport {OverscanManager} from './OverscanManager';\nimport {Point} from './Point';\nimport {Rect} from './Rect';\nimport {Size} from './Size';\n\ninterface VirtualizerOptions<T extends object, V> {\n delegate: VirtualizerDelegate<T, V>,\n collection: Collection<T>,\n layout: Layout<T>\n}\n\n/**\n * The Virtualizer class renders a scrollable collection of data using customizable layouts.\n * It supports very large collections by only rendering visible views to the DOM, reusing\n * them as you scroll. Virtualizer can present any type of view, including non-item views\n * such as section headers and footers.\n *\n * Virtualizer uses `Layout` objects to compute what views should be visible, and how\n * to position and style them. This means that virtualizer can have its items arranged in\n * a stack, a grid, a circle, or any other layout you can think of. The layout can be changed\n * dynamically at runtime as well.\n *\n * Layouts produce information on what views should appear in the virtualizer, but do not create\n * the views themselves directly. It is the responsibility of the `VirtualizerDelegate` object\n * to render elements for each layout info. The virtualizer manages a set of `ReusableView` objects,\n * which are reused as the user scrolls by swapping their content with cached elements returned by the delegate.\n */\nexport class Virtualizer<T extends object, V> {\n /**\n * The virtualizer delegate. The delegate is used by the virtualizer\n * to create and configure views.\n */\n delegate: VirtualizerDelegate<T, V>;\n\n /** The current content of the virtualizer. */\n readonly collection: Collection<T>;\n /** The layout object that determines the visible views. */\n readonly layout: Layout<T>;\n /** The size of the scrollable content. */\n readonly contentSize: Size;\n /** The currently visible rectangle. */\n readonly visibleRect: Rect;\n /** The set of persisted keys that are always present in the DOM, even if not currently in view. */\n readonly persistedKeys: Set<Key>;\n\n private _visibleViews: Map<Key, ChildView<T, V>>;\n private _renderedContent: WeakMap<T, V>;\n private _rootView: RootView<T, V>;\n private _isScrolling: boolean;\n private _invalidationContext: InvalidationContext;\n private _overscanManager: OverscanManager;\n\n constructor(options: VirtualizerOptions<T, V>) {\n this.delegate = options.delegate;\n this.collection = options.collection;\n this.layout = options.layout;\n this.contentSize = new Size;\n this.visibleRect = new Rect;\n this.persistedKeys = new Set();\n this._visibleViews = new Map();\n this._renderedContent = new WeakMap();\n this._rootView = new RootView(this);\n this._isScrolling = false;\n this._invalidationContext = {};\n this._overscanManager = new OverscanManager();\n }\n\n /** Returns whether the given key, or an ancestor, is persisted. */\n isPersistedKey(key: Key) {\n // Quick check if the key is directly in the set of persisted keys.\n if (this.persistedKeys.has(key)) {\n return true;\n }\n\n // If not, check if the key is an ancestor of any of the persisted keys.\n for (let k of this.persistedKeys) {\n while (k != null) {\n let layoutInfo = this.layout.getLayoutInfo(k);\n if (!layoutInfo || layoutInfo.parentKey == null) {\n break;\n }\n\n k = layoutInfo.parentKey;\n\n if (k === key) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n private getParentView(layoutInfo: LayoutInfo): ReusableView<T, V> | undefined {\n return layoutInfo.parentKey != null ? this._visibleViews.get(layoutInfo.parentKey) : this._rootView;\n }\n\n private getReusableView(layoutInfo: LayoutInfo): ChildView<T, V> {\n let parentView = this.getParentView(layoutInfo)!;\n let view = parentView.getReusableView(layoutInfo.type);\n view.layoutInfo = layoutInfo;\n this._renderView(view);\n return view;\n }\n\n private _renderView(reusableView: ReusableView<T, V>) {\n if (reusableView.layoutInfo) {\n let {type, key, content} = reusableView.layoutInfo;\n reusableView.content = content || this.collection.getItem(key);\n reusableView.rendered = this._renderContent(type, reusableView.content);\n }\n }\n\n private _renderContent(type: string, content: T | null) {\n let cached = content != null ? this._renderedContent.get(content) : null;\n if (cached != null) {\n return cached;\n }\n\n let rendered = this.delegate.renderView(type, content);\n if (content) {\n this._renderedContent.set(content, rendered);\n }\n return rendered;\n }\n\n /**\n * Returns the key for the item view currently at the given point.\n */\n keyAtPoint(point: Point): Key | null {\n let rect = new Rect(point.x, point.y, 1, 1);\n let layoutInfos = rect.area === 0 ? [] : this.layout.getVisibleLayoutInfos(rect);\n\n // Layout may return multiple layout infos in the case of\n // persisted keys, so find the first one that actually intersects.\n for (let layoutInfo of layoutInfos) {\n if (layoutInfo.rect.intersects(rect)) {\n return layoutInfo.key;\n }\n }\n\n return null;\n }\n\n private relayout(context: InvalidationContext = {}) {\n // Update the layout\n this.layout.update(context);\n (this as Mutable<this>).contentSize = this.layout.getContentSize();\n\n // Constrain scroll position.\n // If the content changed, scroll to the top.\n let visibleRect = this.visibleRect;\n let contentOffsetX = context.contentChanged ? 0 : visibleRect.x;\n let contentOffsetY = context.contentChanged ? 0 : visibleRect.y;\n contentOffsetX = Math.max(0, Math.min(this.contentSize.width - visibleRect.width, contentOffsetX));\n contentOffsetY = Math.max(0, Math.min(this.contentSize.height - visibleRect.height, contentOffsetY));\n\n if (contentOffsetX !== visibleRect.x || contentOffsetY !== visibleRect.y) {\n // If the offset changed, trigger a new re-render.\n let rect = new Rect(contentOffsetX, contentOffsetY, visibleRect.width, visibleRect.height);\n this.delegate.setVisibleRect(rect);\n } else {\n this.updateSubviews();\n }\n }\n\n getVisibleLayoutInfos() {\n let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;\n let isClientWidthMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientWidth');\n let isClientHeightMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientHeight');\n\n let rect: Rect;\n if (isTestEnv && !(isClientWidthMocked && isClientHeightMocked)) {\n rect = new Rect(0, 0, this.contentSize.width, this.contentSize.height);\n } else {\n rect = this._overscanManager.getOverscannedRect();\n }\n\n let layoutInfos = rect.area === 0 ? [] : this.layout.getVisibleLayoutInfos(rect);\n let map = new Map;\n for (let layoutInfo of layoutInfos) {\n map.set(layoutInfo.key, layoutInfo);\n }\n\n return map;\n }\n\n private updateSubviews() {\n let visibleLayoutInfos = this.getVisibleLayoutInfos();\n\n let removed = new Set<ChildView<T, V>>();\n for (let [key, view] of this._visibleViews) {\n let layoutInfo = visibleLayoutInfos.get(key);\n // If a view's parent changed, treat it as a delete and re-create in the new parent.\n if (!layoutInfo || view.parent !== this.getParentView(layoutInfo)) {\n this._visibleViews.delete(key);\n view.parent.reuseChild(view);\n removed.add(view); // Defer removing in case we reuse this view.\n }\n }\n\n for (let [key, layoutInfo] of visibleLayoutInfos) {\n let view = this._visibleViews.get(key);\n if (!view) {\n view = this.getReusableView(layoutInfo);\n view.parent.children.add(view);\n this._visibleViews.set(key, view);\n removed.delete(view);\n } else {\n view.layoutInfo = layoutInfo;\n\n let item = this.collection.getItem(layoutInfo.key);\n if (view.content !== item) {\n if (view.content != null) {\n this._renderedContent.delete(view.content);\n }\n this._renderView(view);\n }\n }\n }\n\n // The remaining views in `removed` were not reused to render new items.\n // They should be removed from the DOM. We also clear the reusable view queue\n // here since there's no point holding onto views that have been removed.\n // Doing so hurts performance in the future when reusing elements due to FIFO order.\n for (let view of removed) {\n view.parent.children.delete(view);\n view.parent.reusableViews.clear();\n }\n\n // Reordering DOM nodes is costly, so we defer this until scrolling stops.\n // DOM order does not affect visual order (due to absolute positioning),\n // but does matter for assistive technology users.\n if (!this._isScrolling) {\n // Layout infos must be in topological order (parents before children).\n for (let key of visibleLayoutInfos.keys()) {\n let view = this._visibleViews.get(key)!;\n view.parent.children.delete(view);\n view.parent.children.add(view);\n }\n }\n }\n\n /** Performs layout and updates visible views as needed. */\n render(opts: VirtualizerRenderOptions<T>): ReusableView<T, V>[] {\n let mutableThis: Mutable<this> = this;\n let needsLayout = false;\n let offsetChanged = false;\n let sizeChanged = false;\n let itemSizeChanged = false;\n let layoutOptionsChanged = false;\n let needsUpdate = false;\n\n if (opts.collection !== this.collection) {\n mutableThis.collection = opts.collection;\n needsLayout = true;\n }\n\n if (opts.layout !== this.layout || this.layout.virtualizer !== this) {\n if (this.layout) {\n this.layout.virtualizer = null;\n }\n\n opts.layout.virtualizer = this;\n mutableThis.layout = opts.layout;\n needsLayout = true;\n }\n\n if (opts.persistedKeys && !isSetEqual(opts.persistedKeys, this.persistedKeys)) {\n mutableThis.persistedKeys = opts.persistedKeys;\n needsUpdate = true;\n }\n\n if (!this.visibleRect.equals(opts.visibleRect)) {\n this._overscanManager.setVisibleRect(opts.visibleRect);\n let shouldInvalidate = this.layout.shouldInvalidate(opts.visibleRect, this.visibleRect);\n\n if (shouldInvalidate) {\n offsetChanged = !opts.visibleRect.pointEquals(this.visibleRect);\n sizeChanged = !opts.visibleRect.sizeEquals(this.visibleRect);\n needsLayout = true;\n } else {\n needsUpdate = true;\n }\n\n mutableThis.visibleRect = opts.visibleRect;\n }\n\n if (opts.invalidationContext !== this._invalidationContext) {\n if (opts.invalidationContext) {\n sizeChanged ||= opts.invalidationContext.sizeChanged || false;\n offsetChanged ||= opts.invalidationContext.offsetChanged || false;\n itemSizeChanged ||= opts.invalidationContext.itemSizeChanged || false;\n layoutOptionsChanged ||= opts.invalidationContext.layoutOptions != null\n && this._invalidationContext.layoutOptions != null\n && opts.invalidationContext.layoutOptions !== this._invalidationContext.layoutOptions \n && this.layout.shouldInvalidateLayoutOptions(opts.invalidationContext.layoutOptions, this._invalidationContext.layoutOptions);\n needsLayout ||= itemSizeChanged || sizeChanged || offsetChanged || layoutOptionsChanged;\n }\n this._invalidationContext = opts.invalidationContext;\n }\n\n if (opts.isScrolling !== this._isScrolling) {\n this._isScrolling = opts.isScrolling;\n if (!opts.isScrolling) {\n // Update to fix the DOM order after scrolling.\n needsUpdate = true;\n }\n }\n\n if (needsLayout) {\n this.relayout({\n offsetChanged,\n sizeChanged,\n itemSizeChanged,\n layoutOptionsChanged,\n layoutOptions: this._invalidationContext.layoutOptions\n });\n } else if (needsUpdate) {\n this.updateSubviews();\n }\n\n return Array.from(this._rootView.children);\n }\n\n getVisibleView(key: Key): ReusableView<T, V> | undefined {\n return this._visibleViews.get(key);\n }\n\n invalidate(context: InvalidationContext) {\n this.delegate.invalidate(context);\n }\n\n updateItemSize(key: Key, size: Size) {\n if (!this.layout.updateItemSize) {\n return;\n }\n\n let changed = this.layout.updateItemSize(key, size);\n if (changed) {\n this.invalidate({\n itemSizeChanged: true\n });\n }\n }\n}\n"],"names":[],"version":3,"file":"Virtualizer.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAmCM,MAAM;IAwCX,iEAAiE,GACjE,eAAe,GAAQ,EAAW;QAChC,mEAAmE;QACnE,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MACzB,OAAO;QAGT,wEAAwE;QACxE,KAAK,IAAI,KAAK,IAAI,CAAC,aAAa,CAC9B,MAAO,KAAK,KAAM;YAChB,IAAI,aAAa,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;YAC3C,IAAI,CAAC,cAAc,WAAW,SAAS,IAAI,MACzC;YAGF,IAAI,WAAW,SAAS;YAExB,IAAI,MAAM,KACR,OAAO;QAEX;QAGF,OAAO;IACT;IAEQ,cAAc,UAAsB,EAAkC;QAC5E,OAAO,WAAW,SAAS,IAAI,OAAO,IA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["packages/@react-stately/virtualizer/src/Virtualizer.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 {ChildView, ReusableView, RootView} from './ReusableView';\nimport {Collection, Key} from '@react-types/shared';\nimport {InvalidationContext, Mutable, VirtualizerDelegate, VirtualizerRenderOptions} from './types';\nimport {isSetEqual} from './utils';\nimport {Layout} from './Layout';\nimport {LayoutInfo} from './LayoutInfo';\nimport {OverscanManager} from './OverscanManager';\nimport {Point} from './Point';\nimport {Rect} from './Rect';\nimport {Size} from './Size';\n\ninterface VirtualizerOptions<T extends object, V> {\n delegate: VirtualizerDelegate<T, V>,\n collection: Collection<T>,\n layout: Layout<T>\n}\n\n/**\n * The Virtualizer class renders a scrollable collection of data using customizable layouts.\n * It supports very large collections by only rendering visible views to the DOM, reusing\n * them as you scroll. Virtualizer can present any type of view, including non-item views\n * such as section headers and footers.\n *\n * Virtualizer uses `Layout` objects to compute what views should be visible, and how\n * to position and style them. This means that virtualizer can have its items arranged in\n * a stack, a grid, a circle, or any other layout you can think of. The layout can be changed\n * dynamically at runtime as well.\n *\n * Layouts produce information on what views should appear in the virtualizer, but do not create\n * the views themselves directly. It is the responsibility of the `VirtualizerDelegate` object\n * to render elements for each layout info. The virtualizer manages a set of `ReusableView` objects,\n * which are reused as the user scrolls by swapping their content with cached elements returned by the delegate.\n */\nexport class Virtualizer<T extends object, V> {\n /**\n * The virtualizer delegate. The delegate is used by the virtualizer\n * to create and configure views.\n */\n delegate: VirtualizerDelegate<T, V>;\n\n /** The current content of the virtualizer. */\n readonly collection: Collection<T>;\n /** The layout object that determines the visible views. */\n readonly layout: Layout<T>;\n /** The size of the scrollable content. */\n readonly contentSize: Size;\n /** The currently visible rectangle. */\n readonly visibleRect: Rect;\n /** The set of persisted keys that are always present in the DOM, even if not currently in view. */\n readonly persistedKeys: Set<Key>;\n\n private _visibleViews: Map<Key, ChildView<T, V>>;\n private _renderedContent: WeakMap<T, V>;\n private _rootView: RootView<T, V>;\n private _isScrolling: boolean;\n private _invalidationContext: InvalidationContext;\n private _overscanManager: OverscanManager;\n\n constructor(options: VirtualizerOptions<T, V>) {\n this.delegate = options.delegate;\n this.collection = options.collection;\n this.layout = options.layout;\n this.contentSize = new Size;\n this.visibleRect = new Rect;\n this.persistedKeys = new Set();\n this._visibleViews = new Map();\n this._renderedContent = new WeakMap();\n this._rootView = new RootView(this);\n this._isScrolling = false;\n this._invalidationContext = {};\n this._overscanManager = new OverscanManager();\n }\n\n /** Returns whether the given key, or an ancestor, is persisted. */\n isPersistedKey(key: Key): boolean {\n // Quick check if the key is directly in the set of persisted keys.\n if (this.persistedKeys.has(key)) {\n return true;\n }\n\n // If not, check if the key is an ancestor of any of the persisted keys.\n for (let k of this.persistedKeys) {\n while (k != null) {\n let layoutInfo = this.layout.getLayoutInfo(k);\n if (!layoutInfo || layoutInfo.parentKey == null) {\n break;\n }\n\n k = layoutInfo.parentKey;\n\n if (k === key) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n private getParentView(layoutInfo: LayoutInfo): ReusableView<T, V> | undefined {\n return layoutInfo.parentKey != null ? this._visibleViews.get(layoutInfo.parentKey) : this._rootView;\n }\n\n private getReusableView(layoutInfo: LayoutInfo): ChildView<T, V> {\n let parentView = this.getParentView(layoutInfo)!;\n let view = parentView.getReusableView(layoutInfo.type);\n view.layoutInfo = layoutInfo;\n this._renderView(view);\n return view;\n }\n\n private _renderView(reusableView: ReusableView<T, V>) {\n if (reusableView.layoutInfo) {\n let {type, key, content} = reusableView.layoutInfo;\n reusableView.content = content || this.collection.getItem(key);\n reusableView.rendered = this._renderContent(type, reusableView.content);\n }\n }\n\n private _renderContent(type: string, content: T | null) {\n let cached = content != null ? this._renderedContent.get(content) : null;\n if (cached != null) {\n return cached;\n }\n\n let rendered = this.delegate.renderView(type, content);\n if (content) {\n this._renderedContent.set(content, rendered);\n }\n return rendered;\n }\n\n /**\n * Returns the key for the item view currently at the given point.\n */\n keyAtPoint(point: Point): Key | null {\n let rect = new Rect(point.x, point.y, 1, 1);\n let layoutInfos = rect.area === 0 ? [] : this.layout.getVisibleLayoutInfos(rect);\n\n // Layout may return multiple layout infos in the case of\n // persisted keys, so find the first one that actually intersects.\n for (let layoutInfo of layoutInfos) {\n if (layoutInfo.rect.intersects(rect)) {\n return layoutInfo.key;\n }\n }\n\n return null;\n }\n\n private relayout(context: InvalidationContext = {}) {\n // Update the layout\n this.layout.update(context);\n (this as Mutable<this>).contentSize = this.layout.getContentSize();\n\n // Constrain scroll position.\n // If the content changed, scroll to the top.\n let visibleRect = this.visibleRect;\n let contentOffsetX = context.contentChanged ? 0 : visibleRect.x;\n let contentOffsetY = context.contentChanged ? 0 : visibleRect.y;\n contentOffsetX = Math.max(0, Math.min(this.contentSize.width - visibleRect.width, contentOffsetX));\n contentOffsetY = Math.max(0, Math.min(this.contentSize.height - visibleRect.height, contentOffsetY));\n\n if (contentOffsetX !== visibleRect.x || contentOffsetY !== visibleRect.y) {\n // If the offset changed, trigger a new re-render.\n let rect = new Rect(contentOffsetX, contentOffsetY, visibleRect.width, visibleRect.height);\n this.delegate.setVisibleRect(rect);\n } else {\n this.updateSubviews();\n }\n }\n\n getVisibleLayoutInfos(): Map<Key, LayoutInfo> {\n let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;\n let isClientWidthMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientWidth');\n let isClientHeightMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientHeight');\n\n let rect: Rect;\n if (isTestEnv && !(isClientWidthMocked && isClientHeightMocked)) {\n rect = new Rect(0, 0, this.contentSize.width, this.contentSize.height);\n } else {\n rect = this._overscanManager.getOverscannedRect();\n }\n let layoutInfos = this.layout.getVisibleLayoutInfos(rect);\n let map = new Map;\n for (let layoutInfo of layoutInfos) {\n map.set(layoutInfo.key, layoutInfo);\n }\n\n return map;\n }\n\n private updateSubviews() {\n let visibleLayoutInfos = this.getVisibleLayoutInfos();\n\n let removed = new Set<ChildView<T, V>>();\n for (let [key, view] of this._visibleViews) {\n let layoutInfo = visibleLayoutInfos.get(key);\n // If a view's parent changed, treat it as a delete and re-create in the new parent.\n if (!layoutInfo || view.parent !== this.getParentView(layoutInfo)) {\n this._visibleViews.delete(key);\n view.parent.reuseChild(view);\n removed.add(view); // Defer removing in case we reuse this view.\n }\n }\n\n for (let [key, layoutInfo] of visibleLayoutInfos) {\n let view = this._visibleViews.get(key);\n if (!view) {\n view = this.getReusableView(layoutInfo);\n view.parent.children.add(view);\n this._visibleViews.set(key, view);\n removed.delete(view);\n } else {\n view.layoutInfo = layoutInfo;\n\n let item = this.collection.getItem(layoutInfo.key);\n if (view.content !== item) {\n if (view.content != null) {\n this._renderedContent.delete(view.content);\n }\n this._renderView(view);\n }\n }\n }\n\n // The remaining views in `removed` were not reused to render new items.\n // They should be removed from the DOM. We also clear the reusable view queue\n // here since there's no point holding onto views that have been removed.\n // Doing so hurts performance in the future when reusing elements due to FIFO order.\n for (let view of removed) {\n view.parent.children.delete(view);\n view.parent.reusableViews.clear();\n }\n\n // Reordering DOM nodes is costly, so we defer this until scrolling stops.\n // DOM order does not affect visual order (due to absolute positioning),\n // but does matter for assistive technology users.\n if (!this._isScrolling) {\n // Layout infos must be in topological order (parents before children).\n for (let key of visibleLayoutInfos.keys()) {\n let view = this._visibleViews.get(key)!;\n view.parent.children.delete(view);\n view.parent.children.add(view);\n }\n }\n }\n\n /** Performs layout and updates visible views as needed. */\n render(opts: VirtualizerRenderOptions<T>): ReusableView<T, V>[] {\n let mutableThis: Mutable<this> = this;\n let needsLayout = false;\n let offsetChanged = false;\n let sizeChanged = false;\n let itemSizeChanged = false;\n let layoutOptionsChanged = false;\n let needsUpdate = false;\n\n if (opts.collection !== this.collection) {\n mutableThis.collection = opts.collection;\n needsLayout = true;\n }\n\n if (opts.layout !== this.layout || this.layout.virtualizer !== this) {\n if (this.layout) {\n this.layout.virtualizer = null;\n }\n\n opts.layout.virtualizer = this;\n mutableThis.layout = opts.layout;\n needsLayout = true;\n }\n\n if (opts.persistedKeys && !isSetEqual(opts.persistedKeys, this.persistedKeys)) {\n mutableThis.persistedKeys = opts.persistedKeys;\n needsUpdate = true;\n }\n\n if (!this.visibleRect.equals(opts.visibleRect)) {\n this._overscanManager.setVisibleRect(opts.visibleRect);\n let shouldInvalidate = this.layout.shouldInvalidate(opts.visibleRect, this.visibleRect);\n\n if (shouldInvalidate) {\n offsetChanged = !opts.visibleRect.pointEquals(this.visibleRect);\n sizeChanged = !opts.visibleRect.sizeEquals(this.visibleRect);\n needsLayout = true;\n } else {\n needsUpdate = true;\n }\n\n mutableThis.visibleRect = opts.visibleRect;\n }\n\n if (opts.invalidationContext !== this._invalidationContext) {\n if (opts.invalidationContext) {\n sizeChanged ||= opts.invalidationContext.sizeChanged || false;\n offsetChanged ||= opts.invalidationContext.offsetChanged || false;\n itemSizeChanged ||= opts.invalidationContext.itemSizeChanged || false;\n layoutOptionsChanged ||= opts.invalidationContext.layoutOptions != null\n && this._invalidationContext.layoutOptions != null\n && opts.invalidationContext.layoutOptions !== this._invalidationContext.layoutOptions\n && this.layout.shouldInvalidateLayoutOptions(opts.invalidationContext.layoutOptions, this._invalidationContext.layoutOptions);\n needsLayout ||= itemSizeChanged || sizeChanged || offsetChanged || layoutOptionsChanged;\n }\n this._invalidationContext = opts.invalidationContext;\n }\n\n if (opts.isScrolling !== this._isScrolling) {\n this._isScrolling = opts.isScrolling;\n if (!opts.isScrolling) {\n // Update to fix the DOM order after scrolling.\n needsUpdate = true;\n }\n }\n\n if (needsLayout) {\n this.relayout({\n offsetChanged,\n sizeChanged,\n itemSizeChanged,\n layoutOptionsChanged,\n layoutOptions: this._invalidationContext.layoutOptions\n });\n } else if (needsUpdate) {\n this.updateSubviews();\n }\n\n return Array.from(this._rootView.children);\n }\n\n getVisibleView(key: Key): ReusableView<T, V> | undefined {\n return this._visibleViews.get(key);\n }\n\n invalidate(context: InvalidationContext): void {\n this.delegate.invalidate(context);\n }\n\n updateItemSize(key: Key, size: Size): void {\n if (!this.layout.updateItemSize) {\n return;\n }\n\n let changed = this.layout.updateItemSize(key, size);\n if (changed) {\n this.invalidate({\n itemSizeChanged: true\n });\n }\n }\n}\n"],"names":[],"version":3,"file":"Virtualizer.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -255,7 +255,7 @@ declare class Virtualizer<T extends object, V> {
|
|
|
255
255
|
* Returns the key for the item view currently at the given point.
|
|
256
256
|
*/
|
|
257
257
|
keyAtPoint(point: Point): Key | null;
|
|
258
|
-
getVisibleLayoutInfos(): Map<
|
|
258
|
+
getVisibleLayoutInfos(): Map<Key, LayoutInfo>;
|
|
259
259
|
/** Performs layout and updates visible views as needed. */
|
|
260
260
|
render(opts: VirtualizerRenderOptions<T>): ReusableView<T, V>[];
|
|
261
261
|
getVisibleView(key: Key): ReusableView<T, V> | undefined;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";AAYA;IACE,qCAAqC;IACrC,CAAC,EAAE,MAAM,CAAC;IAEV,qCAAqC;IACrC,CAAC,EAAE,MAAM,CAAC;gBAEE,CAAC,SAAI,EAAE,CAAC,SAAI;IAKxB;;OAEG;IACH,IAAI,IAAI,KAAK;IAIb;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAI7B;;OAEG;IACH,QAAQ,IAAI,OAAO;CAGpB;AChCD;IACE,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MA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EAAE,IAAI,CAAC;IAClB,WAAW,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,IAAI,CAAA;CACzB;AAED,oCAAoC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAwEzH","sources":["packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/Point.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/Size.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/Rect.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/LayoutInfo.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/ReusableView.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/utils.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/OverscanManager.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/Virtualizer.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/Layout.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/types.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/useVirtualizerState.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/index.ts","packages/@react-stately/virtualizer/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,"/*\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 type {InvalidationContext} from './types';\nexport type {VirtualizerState} from './useVirtualizerState';\nexport type {RectCorner} from './Rect';\n\nexport {Layout} from './Layout';\nexport {LayoutInfo} from './LayoutInfo';\nexport {Point} from './Point';\nexport {Rect} from './Rect';\nexport {Size} from './Size';\nexport {ReusableView} from './ReusableView';\nexport {useVirtualizerState} from './useVirtualizerState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/virtualizer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/utils": "^3.
|
|
26
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@react-aria/utils": "^3.29.0",
|
|
26
|
+
"@react-types/shared": "^3.29.1",
|
|
27
27
|
"@swc/helpers": "^0.5.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "9c77d4e8267ed39469c65f65da94ece7be509874"
|
|
37
37
|
}
|
package/src/Layout.ts
CHANGED
|
@@ -77,9 +77,9 @@ export abstract class Layout<T extends object = Node<any>, O = any> implements L
|
|
|
77
77
|
* Called by the virtualizer before `getVisibleLayoutInfos`
|
|
78
78
|
* or `getLayoutInfo` are called.
|
|
79
79
|
*/
|
|
80
|
-
update(invalidationContext: InvalidationContext<O>) {} // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
80
|
+
update(invalidationContext: InvalidationContext<O>): void {} // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
81
81
|
|
|
82
|
-
/**
|
|
82
|
+
/**
|
|
83
83
|
* Updates the size of the given item.
|
|
84
84
|
*/
|
|
85
85
|
updateItemSize?(key: Key, size: Size): boolean;
|
package/src/OverscanManager.ts
CHANGED
|
@@ -18,7 +18,7 @@ export class OverscanManager {
|
|
|
18
18
|
private velocity = new Point(0, 0);
|
|
19
19
|
private visibleRect = new Rect();
|
|
20
20
|
|
|
21
|
-
setVisibleRect(rect: Rect) {
|
|
21
|
+
setVisibleRect(rect: Rect): void {
|
|
22
22
|
let time = performance.now() - this.startTime;
|
|
23
23
|
if (time < 500) {
|
|
24
24
|
if (rect.x !== this.visibleRect.x && time > 0) {
|
|
@@ -34,7 +34,7 @@ export class OverscanManager {
|
|
|
34
34
|
this.visibleRect = rect;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
getOverscannedRect() {
|
|
37
|
+
getOverscannedRect(): Rect {
|
|
38
38
|
let overscanned = this.visibleRect.copy();
|
|
39
39
|
|
|
40
40
|
let overscanY = this.visibleRect.height / 3;
|
package/src/Rect.ts
CHANGED
|
@@ -92,7 +92,9 @@ export class Rect {
|
|
|
92
92
|
* @param rect - The rectangle to check.
|
|
93
93
|
*/
|
|
94
94
|
intersects(rect: Rect): boolean {
|
|
95
|
-
return this.
|
|
95
|
+
return this.area > 0
|
|
96
|
+
&& rect.area > 0
|
|
97
|
+
&& this.x <= rect.x + rect.width
|
|
96
98
|
&& rect.x <= this.x + this.width
|
|
97
99
|
&& this.y <= rect.y + rect.height
|
|
98
100
|
&& rect.y <= this.y + this.height;
|
|
@@ -135,19 +137,19 @@ export class Rect {
|
|
|
135
137
|
return null;
|
|
136
138
|
}
|
|
137
139
|
|
|
138
|
-
equals(rect: Rect) {
|
|
140
|
+
equals(rect: Rect): boolean {
|
|
139
141
|
return rect.x === this.x
|
|
140
142
|
&& rect.y === this.y
|
|
141
143
|
&& rect.width === this.width
|
|
142
144
|
&& rect.height === this.height;
|
|
143
145
|
}
|
|
144
146
|
|
|
145
|
-
pointEquals(point: Point | Rect) {
|
|
147
|
+
pointEquals(point: Point | Rect): boolean {
|
|
146
148
|
return this.x === point.x
|
|
147
149
|
&& this.y === point.y;
|
|
148
150
|
}
|
|
149
151
|
|
|
150
|
-
sizeEquals(size: Size | Rect) {
|
|
152
|
+
sizeEquals(size: Size | Rect): boolean {
|
|
151
153
|
return this.width === size.width
|
|
152
154
|
&& this.height === size.height;
|
|
153
155
|
}
|
|
@@ -155,7 +157,7 @@ export class Rect {
|
|
|
155
157
|
/**
|
|
156
158
|
* Returns the union of this Rect and another.
|
|
157
159
|
*/
|
|
158
|
-
union(other: Rect) {
|
|
160
|
+
union(other: Rect): Rect {
|
|
159
161
|
let x = Math.min(this.x, other.x);
|
|
160
162
|
let y = Math.min(this.y, other.y);
|
|
161
163
|
let width = Math.max(this.maxX, other.maxX) - x;
|
package/src/ReusableView.ts
CHANGED
|
@@ -52,13 +52,13 @@ export class ReusableView<T extends object, V> {
|
|
|
52
52
|
/**
|
|
53
53
|
* Prepares the view for reuse. Called just before the view is removed from the DOM.
|
|
54
54
|
*/
|
|
55
|
-
prepareForReuse() {
|
|
55
|
+
prepareForReuse(): void {
|
|
56
56
|
this.content = null;
|
|
57
57
|
this.rendered = null;
|
|
58
58
|
this.layoutInfo = null;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
getReusableView(reuseType: string) {
|
|
61
|
+
getReusableView(reuseType: string): ChildView<T, V> {
|
|
62
62
|
// Reusable view queue should be FIFO so that DOM order remains consistent during scrolling.
|
|
63
63
|
// For example, cells within a row should remain in the same order even if the row changes contents.
|
|
64
64
|
// The cells within a row are removed from their parent in order. If the row is reused, the cells
|
|
@@ -71,7 +71,7 @@ export class ReusableView<T extends object, V> {
|
|
|
71
71
|
return view;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
reuseChild(child: ChildView<T, V>) {
|
|
74
|
+
reuseChild(child: ChildView<T, V>): void {
|
|
75
75
|
child.prepareForReuse();
|
|
76
76
|
let reusable = this.reusableViews.get(child.viewType);
|
|
77
77
|
if (!reusable) {
|
package/src/Size.ts
CHANGED
package/src/Virtualizer.ts
CHANGED
|
@@ -84,7 +84,7 @@ export class Virtualizer<T extends object, V> {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/** Returns whether the given key, or an ancestor, is persisted. */
|
|
87
|
-
isPersistedKey(key: Key) {
|
|
87
|
+
isPersistedKey(key: Key): boolean {
|
|
88
88
|
// Quick check if the key is directly in the set of persisted keys.
|
|
89
89
|
if (this.persistedKeys.has(key)) {
|
|
90
90
|
return true;
|
|
@@ -182,7 +182,7 @@ export class Virtualizer<T extends object, V> {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
getVisibleLayoutInfos() {
|
|
185
|
+
getVisibleLayoutInfos(): Map<Key, LayoutInfo> {
|
|
186
186
|
let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;
|
|
187
187
|
let isClientWidthMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientWidth');
|
|
188
188
|
let isClientHeightMocked = isTestEnv && typeof HTMLElement !== 'undefined' && Object.getOwnPropertyNames(HTMLElement.prototype).includes('clientHeight');
|
|
@@ -193,8 +193,7 @@ export class Virtualizer<T extends object, V> {
|
|
|
193
193
|
} else {
|
|
194
194
|
rect = this._overscanManager.getOverscannedRect();
|
|
195
195
|
}
|
|
196
|
-
|
|
197
|
-
let layoutInfos = rect.area === 0 ? [] : this.layout.getVisibleLayoutInfos(rect);
|
|
196
|
+
let layoutInfos = this.layout.getVisibleLayoutInfos(rect);
|
|
198
197
|
let map = new Map;
|
|
199
198
|
for (let layoutInfo of layoutInfos) {
|
|
200
199
|
map.set(layoutInfo.key, layoutInfo);
|
|
@@ -311,7 +310,7 @@ export class Virtualizer<T extends object, V> {
|
|
|
311
310
|
itemSizeChanged ||= opts.invalidationContext.itemSizeChanged || false;
|
|
312
311
|
layoutOptionsChanged ||= opts.invalidationContext.layoutOptions != null
|
|
313
312
|
&& this._invalidationContext.layoutOptions != null
|
|
314
|
-
&& opts.invalidationContext.layoutOptions !== this._invalidationContext.layoutOptions
|
|
313
|
+
&& opts.invalidationContext.layoutOptions !== this._invalidationContext.layoutOptions
|
|
315
314
|
&& this.layout.shouldInvalidateLayoutOptions(opts.invalidationContext.layoutOptions, this._invalidationContext.layoutOptions);
|
|
316
315
|
needsLayout ||= itemSizeChanged || sizeChanged || offsetChanged || layoutOptionsChanged;
|
|
317
316
|
}
|
|
@@ -345,11 +344,11 @@ export class Virtualizer<T extends object, V> {
|
|
|
345
344
|
return this._visibleViews.get(key);
|
|
346
345
|
}
|
|
347
346
|
|
|
348
|
-
invalidate(context: InvalidationContext) {
|
|
347
|
+
invalidate(context: InvalidationContext): void {
|
|
349
348
|
this.delegate.invalidate(context);
|
|
350
349
|
}
|
|
351
350
|
|
|
352
|
-
updateItemSize(key: Key, size: Size) {
|
|
351
|
+
updateItemSize(key: Key, size: Size): void {
|
|
353
352
|
if (!this.layout.updateItemSize) {
|
|
354
353
|
return;
|
|
355
354
|
}
|