@react-stately/virtualizer 3.7.2-nightly.4691 → 3.7.2-nightly.4694

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.
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAsBM,MAAe;IAIpB;;;;;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;;;;;GAKC,GACD,SAAS,mBAA2C,EAAE,CAAC;IA0BvD,YAAY,GAAQ,EAAQ;YACnB;QAAP,QAAO,sBAAA,IAAI,CAAC,aAAa,CAAC,kBAAnB,0CAAA,oBAAyB,IAAI;IACtC;IAEA,iBAAuB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW;IACrC;AACF","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 {Key, LayoutDelegate} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {Rect} from './Rect';\nimport {Size} from './Size';\nimport {Virtualizer} from './Virtualizer';\n\n/**\n * [Virtualizer]{@link Virtualizer} supports arbitrary layout objects, which compute what views are visible, and how\n * to position and style them. However, layouts do not create the views themselves directly. Instead,\n * layouts produce lightweight {@link LayoutInfo} objects which describe various properties of a view,\n * such as its position and size. The {@link Virtualizer} is then responsible for creating the actual\n * views as needed, based on this layout information.\n *\n * Every layout extends from the {@link Layout} abstract base class. Layouts must implement a minimum of the\n * two methods listed below. All other methods can be optionally overridden to implement custom behavior.\n *\n * @see {@link getVisibleLayoutInfos}\n * @see {@link getLayoutInfo}\n */\nexport abstract class Layout<T extends object, O = any> implements LayoutDelegate {\n /** The Virtualizer the layout is currently attached to. */\n virtualizer: Virtualizer<T, any, any>;\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 * This method allows the layout to perform any pre-computation\n * it needs to in order to prepare {@link LayoutInfo}s for retrieval.\n * Called by the virtualizer before {@link getVisibleLayoutInfos}\n * or {@link getLayoutInfo} are called.\n */\n validate(invalidationContext: InvalidationContext<O>) {} // eslint-disable-line @typescript-eslint/no-unused-vars\n\n /**\n * Returns an array of {@link 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 {@link 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 collectionView's size.\n */\n abstract getContentSize(): Size;\n\n /** \n * Updates the size of the given item.\n */\n updateItemSize?(key: Key, size: Size): boolean;\n\n getItemRect(key: Key): Rect {\n return this.getLayoutInfo(key)?.rect;\n }\n\n getVisibleRect(): Rect {\n return this.virtualizer.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"Layout.main.js.map"}
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAsBM,MAAe;IAIpB;;;;;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;;;;;GAKC,GACD,SAAS,mBAA2C,EAAE,CAAC;IA+BvD,YAAY,GAAQ,EAAQ;YACnB;QAAP,QAAO,sBAAA,IAAI,CAAC,aAAa,CAAC,kBAAnB,0CAAA,oBAAyB,IAAI;IACtC;IAEA,iBAAuB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW;IACrC;AACF","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} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {Rect} from './Rect';\nimport {Size} from './Size';\nimport {Virtualizer} from './Virtualizer';\n\n/**\n * [Virtualizer]{@link Virtualizer} supports arbitrary layout objects, which compute what views are visible, and how\n * to position and style them. However, layouts do not create the views themselves directly. Instead,\n * layouts produce lightweight {@link LayoutInfo} objects which describe various properties of a view,\n * such as its position and size. The {@link Virtualizer} is then responsible for creating the actual\n * views as needed, based on this layout information.\n *\n * Every layout extends from the {@link Layout} abstract base class. Layouts must implement a minimum of the\n * two methods listed below. All other methods can be optionally overridden to implement custom behavior.\n *\n * @see {@link getVisibleLayoutInfos}\n * @see {@link getLayoutInfo}\n */\nexport abstract class Layout<T extends object, O = any> implements LayoutDelegate {\n /** The Virtualizer the layout is currently attached to. */\n virtualizer: Virtualizer<T, any>;\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 * This method allows the layout to perform any pre-computation\n * it needs to in order to prepare {@link LayoutInfo}s for retrieval.\n * Called by the virtualizer before {@link getVisibleLayoutInfos}\n * or {@link getLayoutInfo} are called.\n */\n validate(invalidationContext: InvalidationContext<O>) {} // eslint-disable-line @typescript-eslint/no-unused-vars\n\n /**\n * Returns an array of {@link 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 {@link 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 collectionView's size.\n */\n abstract getContentSize(): Size;\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 getItemRect(key: Key): Rect {\n return this.getLayoutInfo(key)?.rect;\n }\n\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,GAsBM,MAAe;IAIpB;;;;;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;;;;;GAKC,GACD,SAAS,mBAA2C,EAAE,CAAC;IA0BvD,YAAY,GAAQ,EAAQ;YACnB;QAAP,QAAO,sBAAA,IAAI,CAAC,aAAa,CAAC,kBAAnB,0CAAA,oBAAyB,IAAI;IACtC;IAEA,iBAAuB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW;IACrC;AACF","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 {Key, LayoutDelegate} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {Rect} from './Rect';\nimport {Size} from './Size';\nimport {Virtualizer} from './Virtualizer';\n\n/**\n * [Virtualizer]{@link Virtualizer} supports arbitrary layout objects, which compute what views are visible, and how\n * to position and style them. However, layouts do not create the views themselves directly. Instead,\n * layouts produce lightweight {@link LayoutInfo} objects which describe various properties of a view,\n * such as its position and size. The {@link Virtualizer} is then responsible for creating the actual\n * views as needed, based on this layout information.\n *\n * Every layout extends from the {@link Layout} abstract base class. Layouts must implement a minimum of the\n * two methods listed below. All other methods can be optionally overridden to implement custom behavior.\n *\n * @see {@link getVisibleLayoutInfos}\n * @see {@link getLayoutInfo}\n */\nexport abstract class Layout<T extends object, O = any> implements LayoutDelegate {\n /** The Virtualizer the layout is currently attached to. */\n virtualizer: Virtualizer<T, any, any>;\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 * This method allows the layout to perform any pre-computation\n * it needs to in order to prepare {@link LayoutInfo}s for retrieval.\n * Called by the virtualizer before {@link getVisibleLayoutInfos}\n * or {@link getLayoutInfo} are called.\n */\n validate(invalidationContext: InvalidationContext<O>) {} // eslint-disable-line @typescript-eslint/no-unused-vars\n\n /**\n * Returns an array of {@link 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 {@link 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 collectionView's size.\n */\n abstract getContentSize(): Size;\n\n /** \n * Updates the size of the given item.\n */\n updateItemSize?(key: Key, size: Size): boolean;\n\n getItemRect(key: Key): Rect {\n return this.getLayoutInfo(key)?.rect;\n }\n\n getVisibleRect(): Rect {\n return this.virtualizer.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"Layout.module.js.map"}
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAsBM,MAAe;IAIpB;;;;;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;;;;;GAKC,GACD,SAAS,mBAA2C,EAAE,CAAC;IA+BvD,YAAY,GAAQ,EAAQ;YACnB;QAAP,QAAO,sBAAA,IAAI,CAAC,aAAa,CAAC,kBAAnB,0CAAA,oBAAyB,IAAI;IACtC;IAEA,iBAAuB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW;IACrC;AACF","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} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {Rect} from './Rect';\nimport {Size} from './Size';\nimport {Virtualizer} from './Virtualizer';\n\n/**\n * [Virtualizer]{@link Virtualizer} supports arbitrary layout objects, which compute what views are visible, and how\n * to position and style them. However, layouts do not create the views themselves directly. Instead,\n * layouts produce lightweight {@link LayoutInfo} objects which describe various properties of a view,\n * such as its position and size. The {@link Virtualizer} is then responsible for creating the actual\n * views as needed, based on this layout information.\n *\n * Every layout extends from the {@link Layout} abstract base class. Layouts must implement a minimum of the\n * two methods listed below. All other methods can be optionally overridden to implement custom behavior.\n *\n * @see {@link getVisibleLayoutInfos}\n * @see {@link getLayoutInfo}\n */\nexport abstract class Layout<T extends object, O = any> implements LayoutDelegate {\n /** The Virtualizer the layout is currently attached to. */\n virtualizer: Virtualizer<T, any>;\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 * This method allows the layout to perform any pre-computation\n * it needs to in order to prepare {@link LayoutInfo}s for retrieval.\n * Called by the virtualizer before {@link getVisibleLayoutInfos}\n * or {@link getLayoutInfo} are called.\n */\n validate(invalidationContext: InvalidationContext<O>) {} // eslint-disable-line @typescript-eslint/no-unused-vars\n\n /**\n * Returns an array of {@link 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 {@link 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 collectionView's size.\n */\n abstract getContentSize(): Size;\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 getItemRect(key: Key): Rect {\n return this.getLayoutInfo(key)?.rect;\n }\n\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,GAMD,IAAI,4BAAM;AAMH,MAAM;IA2BX;;GAEC,GACD,kBAAkB;QAChB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,UAAU,GAAG;IACpB;IAEA,gBAAgB,SAAiB,EAAE;QACjC,4FAA4F;QAC5F,oGAAoG;QACpG,iGAAiG;QACjG,sEAAsE;QACtE,IAAI,WAAW,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QACtC,IAAI,OAAO,CAAA,qBAAA,+BAAA,SAAU,MAAM,IAAG,IAC1B,SAAS,KAAK,KACd,IAAI,0CAAmB,IAAI,CAAC,WAAW;QAE3C,KAAK,QAAQ,GAAG;QAChB,KAAK,MAAM,GAAG,IAAI;QAClB,OAAO;IACT;IAEA,WAAW,KAAyB,EAAE;QACpC,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;IAxCA,YAAY,WAAuC,CAAE;QACnD,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,QAAQ,GAAG,IAAI;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI;IAC3B;AAmCF","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]{@link Virtualizer} creates instances of the [ReusableView]{@link 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, unknown>;\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;\n\n rendered: V;\n\n viewType: string;\n key: Key;\n\n parent: ReusableView<T, V> | null;\n children: Set<ReusableView<T, V>>;\n reusableViews: Map<string, ReusableView<T, V>[]>;\n\n constructor(virtualizer: Virtualizer<T, V, unknown>) {\n this.virtualizer = virtualizer;\n this.key = ++KEY;\n this.parent = null;\n this.children = new Set();\n this.reusableViews = new Map();\n }\n\n /**\n * Prepares the view for reuse. Called just before the view is removed from the DOM.\n */\n prepareForReuse() {\n this.content = null;\n this.rendered = null;\n this.layoutInfo = null;\n }\n\n getReusableView(reuseType: string) {\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?.length > 0\n ? reusable.shift()\n : new ReusableView<T, V>(this.virtualizer);\n\n view.viewType = reuseType;\n view.parent = this;\n return view;\n }\n\n reuseChild(child: ReusableView<T, V>) {\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"],"names":[],"version":3,"file":"ReusableView.main.js.map"}
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAMD,IAAI,4BAAM;AAMH,MAAM;IA2BX;;GAEC,GACD,kBAAkB;QAChB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,UAAU,GAAG;IACpB;IAEA,gBAAgB,SAAiB,EAAE;QACjC,4FAA4F;QAC5F,oGAAoG;QACpG,iGAAiG;QACjG,sEAAsE;QACtE,IAAI,WAAW,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QACtC,IAAI,OAAO,CAAA,qBAAA,+BAAA,SAAU,MAAM,IAAG,IAC1B,SAAS,KAAK,KACd,IAAI,0CAAmB,IAAI,CAAC,WAAW;QAE3C,KAAK,QAAQ,GAAG;QAChB,KAAK,MAAM,GAAG,IAAI;QAClB,OAAO;IACT;IAEA,WAAW,KAAyB,EAAE;QACpC,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;IAxCA,YAAY,WAA8B,CAAE;QAC1C,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,QAAQ,GAAG,IAAI;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI;IAC3B;AAmCF","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]{@link Virtualizer} creates instances of the [ReusableView]{@link 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;\n\n rendered: V;\n\n viewType: string;\n key: Key;\n\n parent: ReusableView<T, V> | null;\n children: Set<ReusableView<T, V>>;\n reusableViews: Map<string, ReusableView<T, V>[]>;\n\n constructor(virtualizer: Virtualizer<T, V>) {\n this.virtualizer = virtualizer;\n this.key = ++KEY;\n this.parent = null;\n this.children = new Set();\n this.reusableViews = new Map();\n }\n\n /**\n * Prepares the view for reuse. Called just before the view is removed from the DOM.\n */\n prepareForReuse() {\n this.content = null;\n this.rendered = null;\n this.layoutInfo = null;\n }\n\n getReusableView(reuseType: string) {\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?.length > 0\n ? reusable.shift()\n : new ReusableView<T, V>(this.virtualizer);\n\n view.viewType = reuseType;\n view.parent = this;\n return view;\n }\n\n reuseChild(child: ReusableView<T, V>) {\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"],"names":[],"version":3,"file":"ReusableView.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":"AAAA;;;;;;;;;;CAUC,GAMD,IAAI,4BAAM;AAMH,MAAM;IA2BX;;GAEC,GACD,kBAAkB;QAChB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,UAAU,GAAG;IACpB;IAEA,gBAAgB,SAAiB,EAAE;QACjC,4FAA4F;QAC5F,oGAAoG;QACpG,iGAAiG;QACjG,sEAAsE;QACtE,IAAI,WAAW,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QACtC,IAAI,OAAO,CAAA,qBAAA,+BAAA,SAAU,MAAM,IAAG,IAC1B,SAAS,KAAK,KACd,IAAI,0CAAmB,IAAI,CAAC,WAAW;QAE3C,KAAK,QAAQ,GAAG;QAChB,KAAK,MAAM,GAAG,IAAI;QAClB,OAAO;IACT;IAEA,WAAW,KAAyB,EAAE;QACpC,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;IAxCA,YAAY,WAAuC,CAAE;QACnD,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,QAAQ,GAAG,IAAI;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI;IAC3B;AAmCF","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]{@link Virtualizer} creates instances of the [ReusableView]{@link 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, unknown>;\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;\n\n rendered: V;\n\n viewType: string;\n key: Key;\n\n parent: ReusableView<T, V> | null;\n children: Set<ReusableView<T, V>>;\n reusableViews: Map<string, ReusableView<T, V>[]>;\n\n constructor(virtualizer: Virtualizer<T, V, unknown>) {\n this.virtualizer = virtualizer;\n this.key = ++KEY;\n this.parent = null;\n this.children = new Set();\n this.reusableViews = new Map();\n }\n\n /**\n * Prepares the view for reuse. Called just before the view is removed from the DOM.\n */\n prepareForReuse() {\n this.content = null;\n this.rendered = null;\n this.layoutInfo = null;\n }\n\n getReusableView(reuseType: string) {\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?.length > 0\n ? reusable.shift()\n : new ReusableView<T, V>(this.virtualizer);\n\n view.viewType = reuseType;\n view.parent = this;\n return view;\n }\n\n reuseChild(child: ReusableView<T, V>) {\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"],"names":[],"version":3,"file":"ReusableView.module.js.map"}
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAMD,IAAI,4BAAM;AAMH,MAAM;IA2BX;;GAEC,GACD,kBAAkB;QAChB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,UAAU,GAAG;IACpB;IAEA,gBAAgB,SAAiB,EAAE;QACjC,4FAA4F;QAC5F,oGAAoG;QACpG,iGAAiG;QACjG,sEAAsE;QACtE,IAAI,WAAW,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QACtC,IAAI,OAAO,CAAA,qBAAA,+BAAA,SAAU,MAAM,IAAG,IAC1B,SAAS,KAAK,KACd,IAAI,0CAAmB,IAAI,CAAC,WAAW;QAE3C,KAAK,QAAQ,GAAG;QAChB,KAAK,MAAM,GAAG,IAAI;QAClB,OAAO;IACT;IAEA,WAAW,KAAyB,EAAE;QACpC,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;IAxCA,YAAY,WAA8B,CAAE;QAC1C,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,QAAQ,GAAG,IAAI;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI;IAC3B;AAmCF","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]{@link Virtualizer} creates instances of the [ReusableView]{@link 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;\n\n rendered: V;\n\n viewType: string;\n key: Key;\n\n parent: ReusableView<T, V> | null;\n children: Set<ReusableView<T, V>>;\n reusableViews: Map<string, ReusableView<T, V>[]>;\n\n constructor(virtualizer: Virtualizer<T, V>) {\n this.virtualizer = virtualizer;\n this.key = ++KEY;\n this.parent = null;\n this.children = new Set();\n this.reusableViews = new Map();\n }\n\n /**\n * Prepares the view for reuse. Called just before the view is removed from the DOM.\n */\n prepareForReuse() {\n this.content = null;\n this.rendered = null;\n this.layoutInfo = null;\n }\n\n getReusableView(reuseType: string) {\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?.length > 0\n ? reusable.shift()\n : new ReusableView<T, V>(this.virtualizer);\n\n view.viewType = reuseType;\n view.parent = this;\n return view;\n }\n\n reuseChild(child: ReusableView<T, V>) {\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"],"names":[],"version":3,"file":"ReusableView.module.js.map"}
@@ -193,14 +193,10 @@ class $e1bc15d49d21df0e$export$89be5a243e59c4b2 {
193
193
  layoutOptions: this._invalidationContext.layoutOptions
194
194
  });
195
195
  else if (needsUpdate) this.updateSubviews();
196
- return this.getChildren(null);
196
+ return Array.from(this._rootView.children);
197
197
  }
198
- getChildren(key) {
199
- let parent = key == null ? this._rootView : this._visibleViews.get(key);
200
- let renderChildren = (parent, views)=>views.map((view)=>{
201
- return this.delegate.renderWrapper(parent, view, view.children ? Array.from(view.children) : [], (childViews)=>renderChildren(view, childViews));
202
- });
203
- return renderChildren(parent, Array.from(parent.children));
198
+ getVisibleView(key) {
199
+ return this._visibleViews.get(key);
204
200
  }
205
201
  invalidate(context) {
206
202
  this.delegate.invalidate(context);
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6BM,MAAM;IAsCX,iEAAiE,GACjE,eAAe,GAAQ,EAAE;QACvB,mEAAmE;QACnE,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC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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 {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 {ReusableView} from './ReusableView';\nimport {Size} from './Size';\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 {@link 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 {@link VirtualizerDelegate} object\n * to render elements for each layout info. The virtualizer manages a set of {@link 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, W> {\n /**\n * The virtualizer delegate. The delegate is used by the virtualizer\n * to create and configure views.\n */\n delegate: VirtualizerDelegate<T, V, W>;\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, ReusableView<T, V>>;\n private _renderedContent: WeakMap<T, V>;\n private _rootView: ReusableView<T, V>;\n private _isScrolling: boolean;\n private _invalidationContext: InvalidationContext | null;\n private _overscanManager: OverscanManager;\n\n constructor(delegate: VirtualizerDelegate<T, V, W>) {\n this.delegate = delegate;\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 ReusableView(this);\n this._isScrolling = false;\n this._invalidationContext = null;\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) {\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 getReusableView(layoutInfo: LayoutInfo): ReusableView<T, V> {\n let parentView = layoutInfo.parentKey != null ? this._visibleViews.get(layoutInfo.parentKey) : this._rootView;\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 let {type, key} = reusableView.layoutInfo;\n reusableView.content = this.collection.getItem(key);\n reusableView.rendered = this._renderContent(type, reusableView.content);\n }\n\n private _renderContent(type: string, content: T) {\n let cached = this._renderedContent.get(content);\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 // Validate the layout\n this.layout.validate(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<ReusableView<T, V>>();\n for (let [key, view] of this._visibleViews) {\n if (!visibleLayoutInfos.has(key)) {\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 this._renderedContent.delete(view.content);\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>): W[] {\n let mutableThis: Mutable<this> = this;\n let needsLayout = false;\n let offsetChanged = false;\n let sizeChanged = false;\n let itemSizeChanged = 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) {\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 needsLayout ||= itemSizeChanged || sizeChanged || offsetChanged;\n needsLayout ||= opts.invalidationContext.layoutOptions !== this._invalidationContext.layoutOptions;\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 layoutOptions: this._invalidationContext.layoutOptions\n });\n } else if (needsUpdate) {\n this.updateSubviews();\n }\n\n return this.getChildren(null);\n }\n\n getChildren(key: Key | null): W[] {\n let parent = key == null ? this._rootView : this._visibleViews.get(key);\n let renderChildren = (parent: ReusableView<T, V>, views: ReusableView<T, V>[]) => views.map(view => {\n return this.delegate.renderWrapper(\n parent,\n view,\n view.children ? Array.from(view.children) : [],\n childViews => renderChildren(view, childViews)\n );\n });\n\n return renderChildren(parent, Array.from(parent.children));\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":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;2BACZ;yBACA;6BACA;YACA,eAAe,IAAI,CAAC,oBAAoB,CAAC,aAAa;QACxD;aACK,IAAI,aACT,IAAI,CAAC,cAAc;QAGrB,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ;IAC3C;IAEA,eAAe,GAAQ,EAAkC;QACvD,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;IAChC;IAEA,WAAW,OAA4B,EAAE;QACvC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;IAC3B;IAEA,eAAe,GAAQ,EAAE,IAAU,EAAE;QACnC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,EAC7B;QAGF,IAAI,UAAU,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK;QAC9C,IAAI,SACF,IAAI,CAAC,UAAU,CAAC;YACd,iBAAiB;QACnB;IAEJ;IAnRA,YAAY,QAAmC,CAAE;QAC/C,IAAI,CAAC,QAAQ,GAAG;QAChB,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,sCAAW,EAAE,IAAI;QACtC,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,oBAAoB,GAAG;QAC5B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA,GAAA,yCAAc;IAC5C;AAyQF","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 {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 {ReusableView} from './ReusableView';\nimport {Size} from './Size';\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 {@link 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 {@link VirtualizerDelegate} object\n * to render elements for each layout info. The virtualizer manages a set of {@link 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, ReusableView<T, V>>;\n private _renderedContent: WeakMap<T, V>;\n private _rootView: ReusableView<T, V>;\n private _isScrolling: boolean;\n private _invalidationContext: InvalidationContext | null;\n private _overscanManager: OverscanManager;\n\n constructor(delegate: VirtualizerDelegate<T, V>) {\n this.delegate = delegate;\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 ReusableView(this);\n this._isScrolling = false;\n this._invalidationContext = null;\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) {\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 getReusableView(layoutInfo: LayoutInfo): ReusableView<T, V> {\n let parentView = layoutInfo.parentKey != null ? this._visibleViews.get(layoutInfo.parentKey) : this._rootView;\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 let {type, key} = reusableView.layoutInfo;\n reusableView.content = this.collection.getItem(key);\n reusableView.rendered = this._renderContent(type, reusableView.content);\n }\n\n private _renderContent(type: string, content: T) {\n let cached = this._renderedContent.get(content);\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 // Validate the layout\n this.layout.validate(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<ReusableView<T, V>>();\n for (let [key, view] of this._visibleViews) {\n if (!visibleLayoutInfos.has(key)) {\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 this._renderedContent.delete(view.content);\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 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) {\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 needsLayout ||= itemSizeChanged || sizeChanged || offsetChanged;\n needsLayout ||= opts.invalidationContext.layoutOptions !== this._invalidationContext.layoutOptions;\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 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"}
@@ -187,14 +187,10 @@ class $38b9490c1cca8fc4$export$89be5a243e59c4b2 {
187
187
  layoutOptions: this._invalidationContext.layoutOptions
188
188
  });
189
189
  else if (needsUpdate) this.updateSubviews();
190
- return this.getChildren(null);
190
+ return Array.from(this._rootView.children);
191
191
  }
192
- getChildren(key) {
193
- let parent = key == null ? this._rootView : this._visibleViews.get(key);
194
- let renderChildren = (parent, views)=>views.map((view)=>{
195
- return this.delegate.renderWrapper(parent, view, view.children ? Array.from(view.children) : [], (childViews)=>renderChildren(view, childViews));
196
- });
197
- return renderChildren(parent, Array.from(parent.children));
192
+ getVisibleView(key) {
193
+ return this._visibleViews.get(key);
198
194
  }
199
195
  invalidate(context) {
200
196
  this.delegate.invalidate(context);
@@ -187,14 +187,10 @@ class $38b9490c1cca8fc4$export$89be5a243e59c4b2 {
187
187
  layoutOptions: this._invalidationContext.layoutOptions
188
188
  });
189
189
  else if (needsUpdate) this.updateSubviews();
190
- return this.getChildren(null);
190
+ return Array.from(this._rootView.children);
191
191
  }
192
- getChildren(key) {
193
- let parent = key == null ? this._rootView : this._visibleViews.get(key);
194
- let renderChildren = (parent, views)=>views.map((view)=>{
195
- return this.delegate.renderWrapper(parent, view, view.children ? Array.from(view.children) : [], (childViews)=>renderChildren(view, childViews));
196
- });
197
- return renderChildren(parent, Array.from(parent.children));
192
+ getVisibleView(key) {
193
+ return this._visibleViews.get(key);
198
194
  }
199
195
  invalidate(context) {
200
196
  this.delegate.invalidate(context);
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6BM,MAAM;IAsCX,iEAAiE,GACjE,eAAe,GAAQ,EAAE;QACvB,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,YACH;YAGF,IAAI,WAAW,SAAS;YAExB,IAAI,MAAM,KACR,OAAO;QAEX;QAGF,OAAO;IACT;IAEQ,gBAAgB,UAAsB,EAAsB;QAClE,IAAI,aAAa,WAAW,SAAS,IAAI,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,SAAS,IAAI,IAAI,CAAC,SAAS;QA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AAI,CAAC,QAAQ,CAAC,UAAU,CAAC;IAC3B;IAEA,eAAe,GAAQ,EAAE,IAAU,EAAE;QACnC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,EAC7B;QAGF,IAAI,UAAU,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK;QAC9C,IAAI,SACF,IAAI,CAAC,UAAU,CAAC;YACd,iBAAiB;QACnB;IAEJ;IA7RA,YAAY,QAAsC,CAAE;QAClD,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA,GAAA,yCAAG;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA,GAAA,yCAAG;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,yCAAW,EAAE,IAAI;QACtC,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,oBAAoB,GAAG;QAC5B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA,GAAA,yCAAc;IAC5C;AAmRF","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 {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 {ReusableView} from './ReusableView';\nimport {Size} from './Size';\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 {@link 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 {@link VirtualizerDelegate} object\n * to render elements for each layout info. The virtualizer manages a set of {@link 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, W> {\n /**\n * The virtualizer delegate. The delegate is used by the virtualizer\n * to create and configure views.\n */\n delegate: VirtualizerDelegate<T, V, W>;\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, ReusableView<T, V>>;\n private _renderedContent: WeakMap<T, V>;\n private _rootView: ReusableView<T, V>;\n private _isScrolling: boolean;\n private _invalidationContext: InvalidationContext | null;\n private _overscanManager: OverscanManager;\n\n constructor(delegate: VirtualizerDelegate<T, V, W>) {\n this.delegate = delegate;\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 ReusableView(this);\n this._isScrolling = false;\n this._invalidationContext = null;\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) {\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 getReusableView(layoutInfo: LayoutInfo): ReusableView<T, V> {\n let parentView = layoutInfo.parentKey != null ? this._visibleViews.get(layoutInfo.parentKey) : this._rootView;\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 let {type, key} = reusableView.layoutInfo;\n reusableView.content = this.collection.getItem(key);\n reusableView.rendered = this._renderContent(type, reusableView.content);\n }\n\n private _renderContent(type: string, content: T) {\n let cached = this._renderedContent.get(content);\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 // Validate the layout\n this.layout.validate(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<ReusableView<T, V>>();\n for (let [key, view] of this._visibleViews) {\n if (!visibleLayoutInfos.has(key)) {\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 this._renderedContent.delete(view.content);\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>): W[] {\n let mutableThis: Mutable<this> = this;\n let needsLayout = false;\n let offsetChanged = false;\n let sizeChanged = false;\n let itemSizeChanged = 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) {\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 needsLayout ||= itemSizeChanged || sizeChanged || offsetChanged;\n needsLayout ||= opts.invalidationContext.layoutOptions !== this._invalidationContext.layoutOptions;\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 layoutOptions: this._invalidationContext.layoutOptions\n });\n } else if (needsUpdate) {\n this.updateSubviews();\n }\n\n return this.getChildren(null);\n }\n\n getChildren(key: Key | null): W[] {\n let parent = key == null ? this._rootView : this._visibleViews.get(key);\n let renderChildren = (parent: ReusableView<T, V>, views: ReusableView<T, V>[]) => views.map(view => {\n return this.delegate.renderWrapper(\n parent,\n view,\n view.children ? Array.from(view.children) : [],\n childViews => renderChildren(view, childViews)\n );\n });\n\n return renderChildren(parent, Array.from(parent.children));\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;;;;;AA6BM,MAAM;IAsCX,iEAAiE,GACjE,eAAe,GAAQ,EAAE;QACvB,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,YACH;YAGF,IAAI,WAAW,SAAS;YAExB,IAAI,MAAM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CAAC,cAAc,EAC7B;QAGF,IAAI,UAAU,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK;QAC9C,IAAI,SACF,IAAI,CAAC,UAAU,CAAC;YACd,iBAAiB;QACnB;IAEJ;IAnRA,YAAY,QAAmC,CAAE;QAC/C,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA,GAAA,yCAAG;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA,GAAA,yCAAG;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,yCAAW,EAAE,IAAI;QACtC,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,oBAAoB,GAAG;QAC5B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA,GAAA,yCAAc;IAC5C;AAyQF","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 {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 {ReusableView} from './ReusableView';\nimport {Size} from './Size';\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 {@link 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 {@link VirtualizerDelegate} object\n * to render elements for each layout info. The virtualizer manages a set of {@link 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, ReusableView<T, V>>;\n private _renderedContent: WeakMap<T, V>;\n private _rootView: ReusableView<T, V>;\n private _isScrolling: boolean;\n private _invalidationContext: InvalidationContext | null;\n private _overscanManager: OverscanManager;\n\n constructor(delegate: VirtualizerDelegate<T, V>) {\n this.delegate = delegate;\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 ReusableView(this);\n this._isScrolling = false;\n this._invalidationContext = null;\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) {\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 getReusableView(layoutInfo: LayoutInfo): ReusableView<T, V> {\n let parentView = layoutInfo.parentKey != null ? this._visibleViews.get(layoutInfo.parentKey) : this._rootView;\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 let {type, key} = reusableView.layoutInfo;\n reusableView.content = this.collection.getItem(key);\n reusableView.rendered = this._renderContent(type, reusableView.content);\n }\n\n private _renderContent(type: string, content: T) {\n let cached = this._renderedContent.get(content);\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 // Validate the layout\n this.layout.validate(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<ReusableView<T, V>>();\n for (let [key, view] of this._visibleViews) {\n if (!visibleLayoutInfos.has(key)) {\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 this._renderedContent.delete(view.content);\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 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) {\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 needsLayout ||= itemSizeChanged || sizeChanged || offsetChanged;\n needsLayout ||= opts.invalidationContext.layoutOptions !== this._invalidationContext.layoutOptions;\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 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"}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Key, Collection, LayoutDelegate } from "@react-types/shared";
1
+ import { Key, Collection, ItemDropTarget, LayoutDelegate } from "@react-types/shared";
2
2
  export class Point {
3
3
  /** The x-coordinate of the point. */
4
4
  x: number;
@@ -182,7 +182,7 @@ export class LayoutInfo {
182
182
  */
183
183
  export class ReusableView<T extends object, V> {
184
184
  /** The Virtualizer this view is a part of. */
185
- virtualizer: Virtualizer<T, V, unknown>;
185
+ virtualizer: Virtualizer<T, V>;
186
186
  /** The LayoutInfo this view is currently representing. */
187
187
  layoutInfo: LayoutInfo | null;
188
188
  /** The content currently being displayed by this view, set by the virtualizer. */
@@ -193,7 +193,7 @@ export class ReusableView<T extends object, V> {
193
193
  parent: ReusableView<T, V> | null;
194
194
  children: Set<ReusableView<T, V>>;
195
195
  reusableViews: Map<string, ReusableView<T, V>[]>;
196
- constructor(virtualizer: Virtualizer<T, V, unknown>);
196
+ constructor(virtualizer: Virtualizer<T, V>);
197
197
  /**
198
198
  * Prepares the view for reuse. Called just before the view is removed from the DOM.
199
199
  */
@@ -217,12 +217,12 @@ export class ReusableView<T extends object, V> {
217
217
  * to render elements for each layout info. The virtualizer manages a set of {@link ReusableView} objects,
218
218
  * which are reused as the user scrolls by swapping their content with cached elements returned by the delegate.
219
219
  */
220
- declare class Virtualizer<T extends object, V, W> {
220
+ declare class Virtualizer<T extends object, V> {
221
221
  /**
222
222
  * The virtualizer delegate. The delegate is used by the virtualizer
223
223
  * to create and configure views.
224
224
  */
225
- delegate: VirtualizerDelegate<T, V, W>;
225
+ delegate: VirtualizerDelegate<T, V>;
226
226
  /** The current content of the virtualizer. */
227
227
  readonly collection: Collection<T>;
228
228
  /** The layout object that determines the visible views. */
@@ -233,7 +233,7 @@ declare class Virtualizer<T extends object, V, W> {
233
233
  readonly visibleRect: Rect;
234
234
  /** The set of persisted keys that are always present in the DOM, even if not currently in view. */
235
235
  readonly persistedKeys: Set<Key>;
236
- constructor(delegate: VirtualizerDelegate<T, V, W>);
236
+ constructor(delegate: VirtualizerDelegate<T, V>);
237
237
  /** Returns whether the given key, or an ancestor, is persisted. */
238
238
  isPersistedKey(key: Key): boolean;
239
239
  /**
@@ -242,8 +242,8 @@ declare class Virtualizer<T extends object, V, W> {
242
242
  keyAtPoint(point: Point): Key | null;
243
243
  getVisibleLayoutInfos(): Map<any, any>;
244
244
  /** Performs layout and updates visible views as needed. */
245
- render(opts: VirtualizerRenderOptions<T>): W[];
246
- getChildren(key: Key | null): W[];
245
+ render(opts: VirtualizerRenderOptions<T>): ReusableView<T, V>[];
246
+ getVisibleView(key: Key): ReusableView<T, V> | undefined;
247
247
  invalidate(context: InvalidationContext): void;
248
248
  updateItemSize(key: Key, size: Size): void;
249
249
  }
@@ -262,7 +262,7 @@ declare class Virtualizer<T extends object, V, W> {
262
262
  */
263
263
  export abstract class Layout<T extends object, O = any> implements LayoutDelegate {
264
264
  /** The Virtualizer the layout is currently attached to. */
265
- virtualizer: Virtualizer<T, any, any>;
265
+ virtualizer: Virtualizer<T, any>;
266
266
  /**
267
267
  * Returns whether the layout should invalidate in response to
268
268
  * visible rectangle changes. By default, it only invalidates
@@ -297,6 +297,10 @@ export abstract class Layout<T extends object, O = any> implements LayoutDelegat
297
297
  * Updates the size of the given item.
298
298
  */
299
299
  updateItemSize?(key: Key, size: Size): boolean;
300
+ /**
301
+ * Returns a LayoutInfo for the given drop target.
302
+ */
303
+ getDropTargetLayoutInfo?(target: ItemDropTarget): LayoutInfo;
300
304
  getItemRect(key: Key): Rect;
301
305
  getVisibleRect(): Rect;
302
306
  }
@@ -307,10 +311,9 @@ export interface InvalidationContext<O = any> {
307
311
  itemSizeChanged?: boolean;
308
312
  layoutOptions?: O;
309
313
  }
310
- interface VirtualizerDelegate<T extends object, V, W> {
314
+ interface VirtualizerDelegate<T extends object, V> {
311
315
  setVisibleRect(rect: Rect): void;
312
316
  renderView(type: string, content: T): V;
313
- renderWrapper(parent: ReusableView<T, V> | null, reusableView: ReusableView<T, V>, children: ReusableView<T, V>[], renderChildren: (views: ReusableView<T, V>[]) => W[]): W;
314
317
  invalidate(ctx: InvalidationContext): void;
315
318
  }
316
319
  interface VirtualizerRenderOptions<T extends object, O = any> {
@@ -322,24 +325,23 @@ interface VirtualizerRenderOptions<T extends object, O = any> {
322
325
  isScrolling: boolean;
323
326
  layoutOptions?: O;
324
327
  }
325
- interface VirtualizerProps<T extends object, V, W, O> {
328
+ interface VirtualizerProps<T extends object, V, O> {
326
329
  renderView(type: string, content: T): V;
327
- renderWrapper(parent: ReusableView<T, V> | null, reusableView: ReusableView<T, V>, children: ReusableView<T, V>[], renderChildren: (views: ReusableView<T, V>[]) => W[]): W;
328
330
  layout: Layout<T>;
329
331
  collection: Collection<T>;
330
332
  onVisibleRectChange(rect: Rect): void;
331
333
  persistedKeys?: Set<Key>;
332
334
  layoutOptions?: O;
333
335
  }
334
- export interface VirtualizerState<T extends object, V, W> {
335
- visibleViews: W[];
336
+ export interface VirtualizerState<T extends object, V> {
337
+ visibleViews: ReusableView<T, V>[];
336
338
  setVisibleRect: (rect: Rect) => void;
337
339
  contentSize: Size;
338
- virtualizer: Virtualizer<T, V, W>;
340
+ virtualizer: Virtualizer<T, V>;
339
341
  isScrolling: boolean;
340
342
  startScrolling: () => void;
341
343
  endScrolling: () => void;
342
344
  }
343
- export function useVirtualizerState<T extends object, V, W, O = any>(opts: VirtualizerProps<T, V, W, O>): VirtualizerState<T, V, W>;
345
+ export function useVirtualizerState<T extends object, V, O = any>(opts: VirtualizerProps<T, V, O>): VirtualizerState<T, V>;
344
346
 
345
347
  //# sourceMappingURL=types.d.ts.map
@@ -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,MAAM,CAAC;gBAEH,KAAK,SAAI,EAAE,MAAM,SAAI;IAKjC;;OAEG;IACH,IAAI,IAAI,IAAI;IAIZ;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO;IAK5B;;OAEG;IACH,IAAI,IAAI,WAEP;CACF;AC3BD,yBAAyB,SAAS,GAAG,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC;AAE/E;;GAEG;AACH;IACE,yCAAyC;IACzC,CAAC,EAAE,MAAM,CAAC;IAEV,yCAAyC;IACzC,CAAC,EAAE,MAAM,CAAC;IAEV,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IAEd,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;gBAEH,CAAC,SAAI,EAAE,CAAC,SAAI,EAAE,KAAK,SAAI,EAAE,MAAM,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AAC,EAAE,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAqElI","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/utils.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/OverscanManager.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/ReusableView.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"}
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,MAAM,CAAC;gBAEH,KAAK,SAAI,EAAE,MAAM,SAAI;IAKjC;;OAEG;IACH,IAAI,IAAI,IAAI;IAIZ;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO;IAK5B;;OAEG;IACH,IAAI,IAAI,WAEP;CACF;AC3BD,yBAAyB,SAAS,GAAG,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC;AAE/E;;GAEG;AACH;IACE,yCAAyC;IACzC,CAAC,EAAE,MAAM,CAAC;IAEV,yCAAyC;IACzC,CAAC,EAAE,MAAM,CAAC;IAEV,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IAEd,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;gBAEH,CAAC,SAAI,EAAE,CAAC,SAAI,EAAE,KAAK,SAAI,EAAE,MAAM,SAAI;IAO/C;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,KAAK,CAEnB;IAED;;OAEG;IACH,IAAI,Q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CAAC,CAAC;IACzB,aAAa,CAAC,EAAE,CAAC,CAAA;CAClB;AAED,kCAAkC,CAAC,SAAS,MAAM,EAAE,CAAC;IACnD,YAAY,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACnC,cAAc,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACrC,WAAW,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,CAoEzH","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/utils.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/OverscanManager.ts","packages/@react-stately/virtualizer/src/packages/@react-stately/virtualizer/src/ReusableView.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"}
@@ -35,7 +35,6 @@ function $f02ef43b5e8eee9b$export$1505db82fe357e65(opts) {
35
35
  },
36
36
  // TODO: should changing these invalidate the entire cache?
37
37
  renderView: opts.renderView,
38
- renderWrapper: opts.renderWrapper,
39
38
  invalidate: setInvalidationContext
40
39
  }));
41
40
  // onVisibleRectChange must be called from an effect, not during render.
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAqCM,SAAS,0CAAqD,IAAkC;IACrG,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,qBAAO,EAAE,IAAI,CAAA,GAAA,8BAAG,EAAE,GAAG,GAAG,GAAG;IAC/D,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC3C,IAAI,CAAC,qBAAqB,uBAAuB,GAAG,CAAA,GAAA,qBAAO,EAAuB,CAAC;IACnF,IAAI,qBAAqB,CAAA,GAAA,mBAAK,EAAE;IAChC,IAAI,CAAC,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAE,IAAM,IAAI,CAAA,GAAA,qCAAU,EAAW;YAC1D,gBAAe,IAAI;gBACjB,eAAe;gBACf,mBAAmB,OAAO,GAAG;YAC/B;YACA,2DAA2D;YAC3D,YAAY,KAAK,UAAU;YAC3B,eAAe,KAAK,aAAa;YACjC,YAAY;QACd;IAEA,wEAAwE;IACxE,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,mBAAmB,OAAO,EAAE;YAC9B,mBAAmB,OAAO,GAAG;YAC7B,KAAK,mBAAmB,CAAC;QAC3B;IACF;IAEA,IAAI,4BAA4B,CAAA,GAAA,oBAAM,EAAE;QACtC,IAAI,KAAK,aAAa,IAAI,MACxB,OAAO;YAAC,GAAG,mBAAmB;YAAE,eAAe,KAAK,aAAa;QAAA;QAEnE,OAAO;IACT,GAAG;QAAC;QAAqB,KAAK,aAAa;KAAC;IAE5C,IAAI,eAAe,YAAY,MAAM,CAAC;QACpC,QAAQ,KAAK,MAAM;QACnB,YAAY,KAAK,UAAU;QAC3B,eAAe,KAAK,aAAa;QACjC,eAAe,KAAK,aAAa;qBACjC;QACA,qBAAqB;qBACrB;IACF;IAEA,IAAI,cAAc,YAAY,WAAW;IAEzC,IAAI,iBAAiB,CAAA,GAAA,wBAAU,EAAE;QAC/B,aAAa;IACf,GAAG,EAAE;IACL,IAAI,eAAe,CAAA,GAAA,wBAAU,EAAE;QAC7B,aAAa;IACf,GAAG,EAAE;IAEL,IAAI,QAAQ,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;yBACzB;0BACA;4BACA;yBACA;yBACA;4BACA;0BACA;QACF,CAAA,GAAI;QACF;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,OAAO;AACT","sources":["packages/@react-stately/virtualizer/src/useVirtualizerState.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 {Collection, Key} from '@react-types/shared';\nimport {InvalidationContext} from './types';\nimport {Layout} from './Layout';\nimport {Rect} from './Rect';\nimport {ReusableView} from './ReusableView';\nimport {Size} from './Size';\nimport {useCallback, useMemo, useRef, useState} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {Virtualizer} from './Virtualizer';\n\ninterface VirtualizerProps<T extends object, V, W, O> {\n renderView(type: string, content: T): V,\n renderWrapper(\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>,\n children: ReusableView<T, V>[],\n renderChildren: (views: ReusableView<T, V>[]) => W[]\n ): W,\n layout: Layout<T>,\n collection: Collection<T>,\n onVisibleRectChange(rect: Rect): void,\n persistedKeys?: Set<Key>,\n layoutOptions?: O\n}\n\nexport interface VirtualizerState<T extends object, V, W> {\n visibleViews: W[],\n setVisibleRect: (rect: Rect) => void,\n contentSize: Size,\n virtualizer: Virtualizer<T, V, W>,\n isScrolling: boolean,\n startScrolling: () => void,\n endScrolling: () => void\n}\n\nexport function useVirtualizerState<T extends object, V, W, O = any>(opts: VirtualizerProps<T, V, W, O>): VirtualizerState<T, V, W> {\n let [visibleRect, setVisibleRect] = useState(new Rect(0, 0, 0, 0));\n let [isScrolling, setScrolling] = useState(false);\n let [invalidationContext, setInvalidationContext] = useState<InvalidationContext>({});\n let visibleRectChanged = useRef(false);\n let [virtualizer] = useState(() => new Virtualizer<T, V, W>({\n setVisibleRect(rect) {\n setVisibleRect(rect);\n visibleRectChanged.current = true;\n },\n // TODO: should changing these invalidate the entire cache?\n renderView: opts.renderView,\n renderWrapper: opts.renderWrapper,\n invalidate: setInvalidationContext\n }));\n\n // onVisibleRectChange must be called from an effect, not during render.\n useLayoutEffect(() => {\n if (visibleRectChanged.current) {\n visibleRectChanged.current = false;\n opts.onVisibleRectChange(visibleRect);\n }\n });\n\n let mergedInvalidationContext = useMemo(() => {\n if (opts.layoutOptions != null) {\n return {...invalidationContext, layoutOptions: opts.layoutOptions};\n }\n return invalidationContext;\n }, [invalidationContext, opts.layoutOptions]);\n\n let visibleViews = virtualizer.render({\n layout: opts.layout,\n collection: opts.collection,\n persistedKeys: opts.persistedKeys,\n layoutOptions: opts.layoutOptions,\n visibleRect,\n invalidationContext: mergedInvalidationContext,\n isScrolling\n });\n\n let contentSize = virtualizer.contentSize;\n\n let startScrolling = useCallback(() => {\n setScrolling(true);\n }, []);\n let endScrolling = useCallback(() => {\n setScrolling(false);\n }, []);\n\n let state = useMemo(() => ({\n virtualizer,\n visibleViews,\n setVisibleRect,\n contentSize,\n isScrolling,\n startScrolling,\n endScrolling\n }), [\n virtualizer,\n visibleViews,\n setVisibleRect,\n contentSize,\n isScrolling,\n startScrolling,\n endScrolling\n ]);\n\n return state;\n}\n"],"names":[],"version":3,"file":"useVirtualizerState.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA+BM,SAAS,0CAAkD,IAA+B;IAC/F,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,qBAAO,EAAE,IAAI,CAAA,GAAA,8BAAG,EAAE,GAAG,GAAG,GAAG;IAC/D,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC3C,IAAI,CAAC,qBAAqB,uBAAuB,GAAG,CAAA,GAAA,qBAAO,EAAuB,CAAC;IACnF,IAAI,qBAAqB,CAAA,GAAA,mBAAK,EAAE;IAChC,IAAI,CAAC,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAE,IAAM,IAAI,CAAA,GAAA,qCAAU,EAAQ;YACvD,gBAAe,IAAI;gBACjB,eAAe;gBACf,mBAAmB,OAAO,GAAG;YAC/B;YACA,2DAA2D;YAC3D,YAAY,KAAK,UAAU;YAC3B,YAAY;QACd;IAEA,wEAAwE;IACxE,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,mBAAmB,OAAO,EAAE;YAC9B,mBAAmB,OAAO,GAAG;YAC7B,KAAK,mBAAmB,CAAC;QAC3B;IACF;IAEA,IAAI,4BAA4B,CAAA,GAAA,oBAAM,EAAE;QACtC,IAAI,KAAK,aAAa,IAAI,MACxB,OAAO;YAAC,GAAG,mBAAmB;YAAE,eAAe,KAAK,aAAa;QAAA;QAEnE,OAAO;IACT,GAAG;QAAC;QAAqB,KAAK,aAAa;KAAC;IAE5C,IAAI,eAAe,YAAY,MAAM,CAAC;QACpC,QAAQ,KAAK,MAAM;QACnB,YAAY,KAAK,UAAU;QAC3B,eAAe,KAAK,aAAa;QACjC,eAAe,KAAK,aAAa;qBACjC;QACA,qBAAqB;qBACrB;IACF;IAEA,IAAI,cAAc,YAAY,WAAW;IAEzC,IAAI,iBAAiB,CAAA,GAAA,wBAAU,EAAE;QAC/B,aAAa;IACf,GAAG,EAAE;IACL,IAAI,eAAe,CAAA,GAAA,wBAAU,EAAE;QAC7B,aAAa;IACf,GAAG,EAAE;IAEL,IAAI,QAAQ,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;yBACzB;0BACA;4BACA;yBACA;yBACA;4BACA;0BACA;QACF,CAAA,GAAI;QACF;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,OAAO;AACT","sources":["packages/@react-stately/virtualizer/src/useVirtualizerState.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 {Collection, Key} from '@react-types/shared';\nimport {InvalidationContext} from './types';\nimport {Layout} from './Layout';\nimport {Rect} from './Rect';\nimport {ReusableView} from './ReusableView';\nimport {Size} from './Size';\nimport {useCallback, useMemo, useRef, useState} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {Virtualizer} from './Virtualizer';\n\ninterface VirtualizerProps<T extends object, V, O> {\n renderView(type: string, content: T): V,\n layout: Layout<T>,\n collection: Collection<T>,\n onVisibleRectChange(rect: Rect): void,\n persistedKeys?: Set<Key>,\n layoutOptions?: O\n}\n\nexport interface VirtualizerState<T extends object, V> {\n visibleViews: ReusableView<T, V>[],\n setVisibleRect: (rect: Rect) => void,\n contentSize: Size,\n virtualizer: Virtualizer<T, V>,\n isScrolling: boolean,\n startScrolling: () => void,\n endScrolling: () => void\n}\n\nexport function useVirtualizerState<T extends object, V, O = any>(opts: VirtualizerProps<T, V, O>): VirtualizerState<T, V> {\n let [visibleRect, setVisibleRect] = useState(new Rect(0, 0, 0, 0));\n let [isScrolling, setScrolling] = useState(false);\n let [invalidationContext, setInvalidationContext] = useState<InvalidationContext>({});\n let visibleRectChanged = useRef(false);\n let [virtualizer] = useState(() => new Virtualizer<T, V>({\n setVisibleRect(rect) {\n setVisibleRect(rect);\n visibleRectChanged.current = true;\n },\n // TODO: should changing these invalidate the entire cache?\n renderView: opts.renderView,\n invalidate: setInvalidationContext\n }));\n\n // onVisibleRectChange must be called from an effect, not during render.\n useLayoutEffect(() => {\n if (visibleRectChanged.current) {\n visibleRectChanged.current = false;\n opts.onVisibleRectChange(visibleRect);\n }\n });\n\n let mergedInvalidationContext = useMemo(() => {\n if (opts.layoutOptions != null) {\n return {...invalidationContext, layoutOptions: opts.layoutOptions};\n }\n return invalidationContext;\n }, [invalidationContext, opts.layoutOptions]);\n\n let visibleViews = virtualizer.render({\n layout: opts.layout,\n collection: opts.collection,\n persistedKeys: opts.persistedKeys,\n layoutOptions: opts.layoutOptions,\n visibleRect,\n invalidationContext: mergedInvalidationContext,\n isScrolling\n });\n\n let contentSize = virtualizer.contentSize;\n\n let startScrolling = useCallback(() => {\n setScrolling(true);\n }, []);\n let endScrolling = useCallback(() => {\n setScrolling(false);\n }, []);\n\n let state = useMemo(() => ({\n virtualizer,\n visibleViews,\n setVisibleRect,\n contentSize,\n isScrolling,\n startScrolling,\n endScrolling\n }), [\n virtualizer,\n visibleViews,\n setVisibleRect,\n contentSize,\n isScrolling,\n startScrolling,\n endScrolling\n ]);\n\n return state;\n}\n"],"names":[],"version":3,"file":"useVirtualizerState.main.js.map"}
@@ -29,7 +29,6 @@ function $fc0b13b484ac1194$export$1505db82fe357e65(opts) {
29
29
  },
30
30
  // TODO: should changing these invalidate the entire cache?
31
31
  renderView: opts.renderView,
32
- renderWrapper: opts.renderWrapper,
33
32
  invalidate: setInvalidationContext
34
33
  }));
35
34
  // onVisibleRectChange must be called from an effect, not during render.
@@ -29,7 +29,6 @@ function $fc0b13b484ac1194$export$1505db82fe357e65(opts) {
29
29
  },
30
30
  // TODO: should changing these invalidate the entire cache?
31
31
  renderView: opts.renderView,
32
- renderWrapper: opts.renderWrapper,
33
32
  invalidate: setInvalidationContext
34
33
  }));
35
34
  // onVisibleRectChange must be called from an effect, not during render.
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAqCM,SAAS,0CAAqD,IAAkC;IACrG,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,eAAO,EAAE,IAAI,CAAA,GAAA,yCAAG,EAAE,GAAG,GAAG,GAAG;IAC/D,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IAC3C,IAAI,CAAC,qBAAqB,uBAAuB,GAAG,CAAA,GAAA,eAAO,EAAuB,CAAC;IACnF,IAAI,qBAAqB,CAAA,GAAA,aAAK,EAAE;IAChC,IAAI,CAAC,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE,IAAM,IAAI,CAAA,GAAA,yCAAU,EAAW;YAC1D,gBAAe,IAAI;gBACjB,eAAe;gBACf,mBAAmB,OAAO,GAAG;YAC/B;YACA,2DAA2D;YAC3D,YAAY,KAAK,UAAU;YAC3B,eAAe,KAAK,aAAa;YACjC,YAAY;QACd;IAEA,wEAAwE;IACxE,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,mBAAmB,OAAO,EAAE;YAC9B,mBAAmB,OAAO,GAAG;YAC7B,KAAK,mBAAmB,CAAC;QAC3B;IACF;IAEA,IAAI,4BAA4B,CAAA,GAAA,cAAM,EAAE;QACtC,IAAI,KAAK,aAAa,IAAI,MACxB,OAAO;YAAC,GAAG,mBAAmB;YAAE,eAAe,KAAK,aAAa;QAAA;QAEnE,OAAO;IACT,GAAG;QAAC;QAAqB,KAAK,aAAa;KAAC;IAE5C,IAAI,eAAe,YAAY,MAAM,CAAC;QACpC,QAAQ,KAAK,MAAM;QACnB,YAAY,KAAK,UAAU;QAC3B,eAAe,KAAK,aAAa;QACjC,eAAe,KAAK,aAAa;qBACjC;QACA,qBAAqB;qBACrB;IACF;IAEA,IAAI,cAAc,YAAY,WAAW;IAEzC,IAAI,iBAAiB,CAAA,GAAA,kBAAU,EAAE;QAC/B,aAAa;IACf,GAAG,EAAE;IACL,IAAI,eAAe,CAAA,GAAA,kBAAU,EAAE;QAC7B,aAAa;IACf,GAAG,EAAE;IAEL,IAAI,QAAQ,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;yBACzB;0BACA;4BACA;yBACA;yBACA;4BACA;0BACA;QACF,CAAA,GAAI;QACF;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,OAAO;AACT","sources":["packages/@react-stately/virtualizer/src/useVirtualizerState.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 {Collection, Key} from '@react-types/shared';\nimport {InvalidationContext} from './types';\nimport {Layout} from './Layout';\nimport {Rect} from './Rect';\nimport {ReusableView} from './ReusableView';\nimport {Size} from './Size';\nimport {useCallback, useMemo, useRef, useState} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {Virtualizer} from './Virtualizer';\n\ninterface VirtualizerProps<T extends object, V, W, O> {\n renderView(type: string, content: T): V,\n renderWrapper(\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>,\n children: ReusableView<T, V>[],\n renderChildren: (views: ReusableView<T, V>[]) => W[]\n ): W,\n layout: Layout<T>,\n collection: Collection<T>,\n onVisibleRectChange(rect: Rect): void,\n persistedKeys?: Set<Key>,\n layoutOptions?: O\n}\n\nexport interface VirtualizerState<T extends object, V, W> {\n visibleViews: W[],\n setVisibleRect: (rect: Rect) => void,\n contentSize: Size,\n virtualizer: Virtualizer<T, V, W>,\n isScrolling: boolean,\n startScrolling: () => void,\n endScrolling: () => void\n}\n\nexport function useVirtualizerState<T extends object, V, W, O = any>(opts: VirtualizerProps<T, V, W, O>): VirtualizerState<T, V, W> {\n let [visibleRect, setVisibleRect] = useState(new Rect(0, 0, 0, 0));\n let [isScrolling, setScrolling] = useState(false);\n let [invalidationContext, setInvalidationContext] = useState<InvalidationContext>({});\n let visibleRectChanged = useRef(false);\n let [virtualizer] = useState(() => new Virtualizer<T, V, W>({\n setVisibleRect(rect) {\n setVisibleRect(rect);\n visibleRectChanged.current = true;\n },\n // TODO: should changing these invalidate the entire cache?\n renderView: opts.renderView,\n renderWrapper: opts.renderWrapper,\n invalidate: setInvalidationContext\n }));\n\n // onVisibleRectChange must be called from an effect, not during render.\n useLayoutEffect(() => {\n if (visibleRectChanged.current) {\n visibleRectChanged.current = false;\n opts.onVisibleRectChange(visibleRect);\n }\n });\n\n let mergedInvalidationContext = useMemo(() => {\n if (opts.layoutOptions != null) {\n return {...invalidationContext, layoutOptions: opts.layoutOptions};\n }\n return invalidationContext;\n }, [invalidationContext, opts.layoutOptions]);\n\n let visibleViews = virtualizer.render({\n layout: opts.layout,\n collection: opts.collection,\n persistedKeys: opts.persistedKeys,\n layoutOptions: opts.layoutOptions,\n visibleRect,\n invalidationContext: mergedInvalidationContext,\n isScrolling\n });\n\n let contentSize = virtualizer.contentSize;\n\n let startScrolling = useCallback(() => {\n setScrolling(true);\n }, []);\n let endScrolling = useCallback(() => {\n setScrolling(false);\n }, []);\n\n let state = useMemo(() => ({\n virtualizer,\n visibleViews,\n setVisibleRect,\n contentSize,\n isScrolling,\n startScrolling,\n endScrolling\n }), [\n virtualizer,\n visibleViews,\n setVisibleRect,\n contentSize,\n isScrolling,\n startScrolling,\n endScrolling\n ]);\n\n return state;\n}\n"],"names":[],"version":3,"file":"useVirtualizerState.module.js.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AA+BM,SAAS,0CAAkD,IAA+B;IAC/F,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,eAAO,EAAE,IAAI,CAAA,GAAA,yCAAG,EAAE,GAAG,GAAG,GAAG;IAC/D,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IAC3C,IAAI,CAAC,qBAAqB,uBAAuB,GAAG,CAAA,GAAA,eAAO,EAAuB,CAAC;IACnF,IAAI,qBAAqB,CAAA,GAAA,aAAK,EAAE;IAChC,IAAI,CAAC,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE,IAAM,IAAI,CAAA,GAAA,yCAAU,EAAQ;YACvD,gBAAe,IAAI;gBACjB,eAAe;gBACf,mBAAmB,OAAO,GAAG;YAC/B;YACA,2DAA2D;YAC3D,YAAY,KAAK,UAAU;YAC3B,YAAY;QACd;IAEA,wEAAwE;IACxE,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,mBAAmB,OAAO,EAAE;YAC9B,mBAAmB,OAAO,GAAG;YAC7B,KAAK,mBAAmB,CAAC;QAC3B;IACF;IAEA,IAAI,4BAA4B,CAAA,GAAA,cAAM,EAAE;QACtC,IAAI,KAAK,aAAa,IAAI,MACxB,OAAO;YAAC,GAAG,mBAAmB;YAAE,eAAe,KAAK,aAAa;QAAA;QAEnE,OAAO;IACT,GAAG;QAAC;QAAqB,KAAK,aAAa;KAAC;IAE5C,IAAI,eAAe,YAAY,MAAM,CAAC;QACpC,QAAQ,KAAK,MAAM;QACnB,YAAY,KAAK,UAAU;QAC3B,eAAe,KAAK,aAAa;QACjC,eAAe,KAAK,aAAa;qBACjC;QACA,qBAAqB;qBACrB;IACF;IAEA,IAAI,cAAc,YAAY,WAAW;IAEzC,IAAI,iBAAiB,CAAA,GAAA,kBAAU,EAAE;QAC/B,aAAa;IACf,GAAG,EAAE;IACL,IAAI,eAAe,CAAA,GAAA,kBAAU,EAAE;QAC7B,aAAa;IACf,GAAG,EAAE;IAEL,IAAI,QAAQ,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;yBACzB;0BACA;4BACA;yBACA;yBACA;4BACA;0BACA;QACF,CAAA,GAAI;QACF;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,OAAO;AACT","sources":["packages/@react-stately/virtualizer/src/useVirtualizerState.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 {Collection, Key} from '@react-types/shared';\nimport {InvalidationContext} from './types';\nimport {Layout} from './Layout';\nimport {Rect} from './Rect';\nimport {ReusableView} from './ReusableView';\nimport {Size} from './Size';\nimport {useCallback, useMemo, useRef, useState} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {Virtualizer} from './Virtualizer';\n\ninterface VirtualizerProps<T extends object, V, O> {\n renderView(type: string, content: T): V,\n layout: Layout<T>,\n collection: Collection<T>,\n onVisibleRectChange(rect: Rect): void,\n persistedKeys?: Set<Key>,\n layoutOptions?: O\n}\n\nexport interface VirtualizerState<T extends object, V> {\n visibleViews: ReusableView<T, V>[],\n setVisibleRect: (rect: Rect) => void,\n contentSize: Size,\n virtualizer: Virtualizer<T, V>,\n isScrolling: boolean,\n startScrolling: () => void,\n endScrolling: () => void\n}\n\nexport function useVirtualizerState<T extends object, V, O = any>(opts: VirtualizerProps<T, V, O>): VirtualizerState<T, V> {\n let [visibleRect, setVisibleRect] = useState(new Rect(0, 0, 0, 0));\n let [isScrolling, setScrolling] = useState(false);\n let [invalidationContext, setInvalidationContext] = useState<InvalidationContext>({});\n let visibleRectChanged = useRef(false);\n let [virtualizer] = useState(() => new Virtualizer<T, V>({\n setVisibleRect(rect) {\n setVisibleRect(rect);\n visibleRectChanged.current = true;\n },\n // TODO: should changing these invalidate the entire cache?\n renderView: opts.renderView,\n invalidate: setInvalidationContext\n }));\n\n // onVisibleRectChange must be called from an effect, not during render.\n useLayoutEffect(() => {\n if (visibleRectChanged.current) {\n visibleRectChanged.current = false;\n opts.onVisibleRectChange(visibleRect);\n }\n });\n\n let mergedInvalidationContext = useMemo(() => {\n if (opts.layoutOptions != null) {\n return {...invalidationContext, layoutOptions: opts.layoutOptions};\n }\n return invalidationContext;\n }, [invalidationContext, opts.layoutOptions]);\n\n let visibleViews = virtualizer.render({\n layout: opts.layout,\n collection: opts.collection,\n persistedKeys: opts.persistedKeys,\n layoutOptions: opts.layoutOptions,\n visibleRect,\n invalidationContext: mergedInvalidationContext,\n isScrolling\n });\n\n let contentSize = virtualizer.contentSize;\n\n let startScrolling = useCallback(() => {\n setScrolling(true);\n }, []);\n let endScrolling = useCallback(() => {\n setScrolling(false);\n }, []);\n\n let state = useMemo(() => ({\n virtualizer,\n visibleViews,\n setVisibleRect,\n contentSize,\n isScrolling,\n startScrolling,\n endScrolling\n }), [\n virtualizer,\n visibleViews,\n setVisibleRect,\n contentSize,\n isScrolling,\n startScrolling,\n endScrolling\n ]);\n\n return state;\n}\n"],"names":[],"version":3,"file":"useVirtualizerState.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/virtualizer",
3
- "version": "3.7.2-nightly.4691+fabca84b9",
3
+ "version": "3.7.2-nightly.4694+b46d23b99",
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.0.0-nightly.2979+fabca84b9",
26
- "@react-types/shared": "3.0.0-nightly.2979+fabca84b9",
25
+ "@react-aria/utils": "3.0.0-nightly.2982+b46d23b99",
26
+ "@react-types/shared": "3.0.0-nightly.2982+b46d23b99",
27
27
  "@swc/helpers": "^0.5.0"
28
28
  },
29
29
  "peerDependencies": {
@@ -32,5 +32,5 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "fabca84b95c9c61f9062d5f1e66ebe2c920a2a5d"
35
+ "gitHead": "b46d23b9919eaec8ab1f621b52beced82e88b6ca"
36
36
  }
package/src/Layout.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
 
13
13
  import {InvalidationContext} from './types';
14
- import {Key, LayoutDelegate} from '@react-types/shared';
14
+ import {ItemDropTarget, Key, LayoutDelegate} from '@react-types/shared';
15
15
  import {LayoutInfo} from './LayoutInfo';
16
16
  import {Rect} from './Rect';
17
17
  import {Size} from './Size';
@@ -32,7 +32,7 @@ import {Virtualizer} from './Virtualizer';
32
32
  */
33
33
  export abstract class Layout<T extends object, O = any> implements LayoutDelegate {
34
34
  /** The Virtualizer the layout is currently attached to. */
35
- virtualizer: Virtualizer<T, any, any>;
35
+ virtualizer: Virtualizer<T, any>;
36
36
 
37
37
  /**
38
38
  * Returns whether the layout should invalidate in response to
@@ -78,6 +78,11 @@ export abstract class Layout<T extends object, O = any> implements LayoutDelegat
78
78
  */
79
79
  updateItemSize?(key: Key, size: Size): boolean;
80
80
 
81
+ /**
82
+ * Returns a LayoutInfo for the given drop target.
83
+ */
84
+ getDropTargetLayoutInfo?(target: ItemDropTarget): LayoutInfo;
85
+
81
86
  getItemRect(key: Key): Rect {
82
87
  return this.getLayoutInfo(key)?.rect;
83
88
  }
@@ -22,7 +22,7 @@ let KEY = 0;
22
22
  */
23
23
  export class ReusableView<T extends object, V> {
24
24
  /** The Virtualizer this view is a part of. */
25
- virtualizer: Virtualizer<T, V, unknown>;
25
+ virtualizer: Virtualizer<T, V>;
26
26
 
27
27
  /** The LayoutInfo this view is currently representing. */
28
28
  layoutInfo: LayoutInfo | null;
@@ -39,7 +39,7 @@ export class ReusableView<T extends object, V> {
39
39
  children: Set<ReusableView<T, V>>;
40
40
  reusableViews: Map<string, ReusableView<T, V>[]>;
41
41
 
42
- constructor(virtualizer: Virtualizer<T, V, unknown>) {
42
+ constructor(virtualizer: Virtualizer<T, V>) {
43
43
  this.virtualizer = virtualizer;
44
44
  this.key = ++KEY;
45
45
  this.parent = null;
@@ -37,12 +37,12 @@ import {Size} from './Size';
37
37
  * to render elements for each layout info. The virtualizer manages a set of {@link ReusableView} objects,
38
38
  * which are reused as the user scrolls by swapping their content with cached elements returned by the delegate.
39
39
  */
40
- export class Virtualizer<T extends object, V, W> {
40
+ export class Virtualizer<T extends object, V> {
41
41
  /**
42
42
  * The virtualizer delegate. The delegate is used by the virtualizer
43
43
  * to create and configure views.
44
44
  */
45
- delegate: VirtualizerDelegate<T, V, W>;
45
+ delegate: VirtualizerDelegate<T, V>;
46
46
 
47
47
  /** The current content of the virtualizer. */
48
48
  readonly collection: Collection<T>;
@@ -62,7 +62,7 @@ export class Virtualizer<T extends object, V, W> {
62
62
  private _invalidationContext: InvalidationContext | null;
63
63
  private _overscanManager: OverscanManager;
64
64
 
65
- constructor(delegate: VirtualizerDelegate<T, V, W>) {
65
+ constructor(delegate: VirtualizerDelegate<T, V>) {
66
66
  this.delegate = delegate;
67
67
  this.contentSize = new Size;
68
68
  this.visibleRect = new Rect;
@@ -242,7 +242,7 @@ export class Virtualizer<T extends object, V, W> {
242
242
  }
243
243
 
244
244
  /** Performs layout and updates visible views as needed. */
245
- render(opts: VirtualizerRenderOptions<T>): W[] {
245
+ render(opts: VirtualizerRenderOptions<T>): ReusableView<T, V>[] {
246
246
  let mutableThis: Mutable<this> = this;
247
247
  let needsLayout = false;
248
248
  let offsetChanged = false;
@@ -315,21 +315,11 @@ export class Virtualizer<T extends object, V, W> {
315
315
  this.updateSubviews();
316
316
  }
317
317
 
318
- return this.getChildren(null);
318
+ return Array.from(this._rootView.children);
319
319
  }
320
320
 
321
- getChildren(key: Key | null): W[] {
322
- let parent = key == null ? this._rootView : this._visibleViews.get(key);
323
- let renderChildren = (parent: ReusableView<T, V>, views: ReusableView<T, V>[]) => views.map(view => {
324
- return this.delegate.renderWrapper(
325
- parent,
326
- view,
327
- view.children ? Array.from(view.children) : [],
328
- childViews => renderChildren(view, childViews)
329
- );
330
- });
331
-
332
- return renderChildren(parent, Array.from(parent.children));
321
+ getVisibleView(key: Key): ReusableView<T, V> | undefined {
322
+ return this._visibleViews.get(key);
333
323
  }
334
324
 
335
325
  invalidate(context: InvalidationContext) {
package/src/types.ts CHANGED
@@ -13,7 +13,6 @@
13
13
  import {Collection, Key} from '@react-types/shared';
14
14
  import {Layout} from './Layout';
15
15
  import {Rect} from './Rect';
16
- import {ReusableView} from './ReusableView';
17
16
 
18
17
  export interface InvalidationContext<O = any> {
19
18
  contentChanged?: boolean,
@@ -23,15 +22,9 @@ export interface InvalidationContext<O = any> {
23
22
  layoutOptions?: O
24
23
  }
25
24
 
26
- export interface VirtualizerDelegate<T extends object, V, W> {
25
+ export interface VirtualizerDelegate<T extends object, V> {
27
26
  setVisibleRect(rect: Rect): void,
28
27
  renderView(type: string, content: T): V,
29
- renderWrapper(
30
- parent: ReusableView<T, V> | null,
31
- reusableView: ReusableView<T, V>,
32
- children: ReusableView<T, V>[],
33
- renderChildren: (views: ReusableView<T, V>[]) => W[]
34
- ): W,
35
28
  invalidate(ctx: InvalidationContext): void
36
29
  }
37
30
 
@@ -20,14 +20,8 @@ import {useCallback, useMemo, useRef, useState} from 'react';
20
20
  import {useLayoutEffect} from '@react-aria/utils';
21
21
  import {Virtualizer} from './Virtualizer';
22
22
 
23
- interface VirtualizerProps<T extends object, V, W, O> {
23
+ interface VirtualizerProps<T extends object, V, O> {
24
24
  renderView(type: string, content: T): V,
25
- renderWrapper(
26
- parent: ReusableView<T, V> | null,
27
- reusableView: ReusableView<T, V>,
28
- children: ReusableView<T, V>[],
29
- renderChildren: (views: ReusableView<T, V>[]) => W[]
30
- ): W,
31
25
  layout: Layout<T>,
32
26
  collection: Collection<T>,
33
27
  onVisibleRectChange(rect: Rect): void,
@@ -35,29 +29,28 @@ interface VirtualizerProps<T extends object, V, W, O> {
35
29
  layoutOptions?: O
36
30
  }
37
31
 
38
- export interface VirtualizerState<T extends object, V, W> {
39
- visibleViews: W[],
32
+ export interface VirtualizerState<T extends object, V> {
33
+ visibleViews: ReusableView<T, V>[],
40
34
  setVisibleRect: (rect: Rect) => void,
41
35
  contentSize: Size,
42
- virtualizer: Virtualizer<T, V, W>,
36
+ virtualizer: Virtualizer<T, V>,
43
37
  isScrolling: boolean,
44
38
  startScrolling: () => void,
45
39
  endScrolling: () => void
46
40
  }
47
41
 
48
- export function useVirtualizerState<T extends object, V, W, O = any>(opts: VirtualizerProps<T, V, W, O>): VirtualizerState<T, V, W> {
42
+ export function useVirtualizerState<T extends object, V, O = any>(opts: VirtualizerProps<T, V, O>): VirtualizerState<T, V> {
49
43
  let [visibleRect, setVisibleRect] = useState(new Rect(0, 0, 0, 0));
50
44
  let [isScrolling, setScrolling] = useState(false);
51
45
  let [invalidationContext, setInvalidationContext] = useState<InvalidationContext>({});
52
46
  let visibleRectChanged = useRef(false);
53
- let [virtualizer] = useState(() => new Virtualizer<T, V, W>({
47
+ let [virtualizer] = useState(() => new Virtualizer<T, V>({
54
48
  setVisibleRect(rect) {
55
49
  setVisibleRect(rect);
56
50
  visibleRectChanged.current = true;
57
51
  },
58
52
  // TODO: should changing these invalidate the entire cache?
59
53
  renderView: opts.renderView,
60
- renderWrapper: opts.renderWrapper,
61
54
  invalidate: setInvalidationContext
62
55
  }));
63
56