@react-stately/virtualizer 4.1.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2019 Adobe
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -32,11 +32,15 @@ $parcel$export(module.exports, "Layout", () => $ac14d65a0ec196dd$export$c84671f4
32
32
  */ update(invalidationContext) {}
33
33
  getItemRect(key) {
34
34
  var _this_getLayoutInfo;
35
- return (_this_getLayoutInfo = this.getLayoutInfo(key)) === null || _this_getLayoutInfo === void 0 ? void 0 : _this_getLayoutInfo.rect;
35
+ var _this_getLayoutInfo_rect;
36
+ return (_this_getLayoutInfo_rect = (_this_getLayoutInfo = this.getLayoutInfo(key)) === null || _this_getLayoutInfo === void 0 ? void 0 : _this_getLayoutInfo.rect) !== null && _this_getLayoutInfo_rect !== void 0 ? _this_getLayoutInfo_rect : null;
36
37
  }
37
38
  getVisibleRect() {
38
39
  return this.virtualizer.visibleRect;
39
40
  }
41
+ constructor(){
42
+ /** The Virtualizer the layout is currently attached to. */ this.virtualizer = null;
43
+ }
40
44
  }
41
45
 
42
46
 
@@ -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,OAAO,mBAA2C,EAAE,CAAC;IA+BrD,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 update(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
+ {"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,OAAO,mBAA2C,EAAE,CAAC;IA+BrD,YAAY,GAAQ,EAAe;YAC1B;YAAA;QAAP,OAAO,CAAA,4BAAA,sBAAA,IAAI,CAAC,aAAa,CAAC,kBAAnB,0CAAA,oBAAyB,IAAI,cAA7B,sCAAA,2BAAiC;IAC1C;IAEA,iBAAuB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAE,WAAW;IACtC;;QA1DA,yDAAyD,QACzD,cAA0C;;AA0D5C","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> | null = null;\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 update(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 | null {\n return this.getLayoutInfo(key)?.rect ?? null;\n }\n\n getVisibleRect(): Rect {\n return this.virtualizer!.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"Layout.main.js.map"}
package/dist/Layout.mjs CHANGED
@@ -26,11 +26,15 @@
26
26
  */ update(invalidationContext) {}
27
27
  getItemRect(key) {
28
28
  var _this_getLayoutInfo;
29
- return (_this_getLayoutInfo = this.getLayoutInfo(key)) === null || _this_getLayoutInfo === void 0 ? void 0 : _this_getLayoutInfo.rect;
29
+ var _this_getLayoutInfo_rect;
30
+ return (_this_getLayoutInfo_rect = (_this_getLayoutInfo = this.getLayoutInfo(key)) === null || _this_getLayoutInfo === void 0 ? void 0 : _this_getLayoutInfo.rect) !== null && _this_getLayoutInfo_rect !== void 0 ? _this_getLayoutInfo_rect : null;
30
31
  }
31
32
  getVisibleRect() {
32
33
  return this.virtualizer.visibleRect;
33
34
  }
35
+ constructor(){
36
+ /** The Virtualizer the layout is currently attached to. */ this.virtualizer = null;
37
+ }
34
38
  }
35
39
 
36
40
 
@@ -26,11 +26,15 @@
26
26
  */ update(invalidationContext) {}
27
27
  getItemRect(key) {
28
28
  var _this_getLayoutInfo;
29
- return (_this_getLayoutInfo = this.getLayoutInfo(key)) === null || _this_getLayoutInfo === void 0 ? void 0 : _this_getLayoutInfo.rect;
29
+ var _this_getLayoutInfo_rect;
30
+ return (_this_getLayoutInfo_rect = (_this_getLayoutInfo = this.getLayoutInfo(key)) === null || _this_getLayoutInfo === void 0 ? void 0 : _this_getLayoutInfo.rect) !== null && _this_getLayoutInfo_rect !== void 0 ? _this_getLayoutInfo_rect : null;
30
31
  }
31
32
  getVisibleRect() {
32
33
  return this.virtualizer.visibleRect;
33
34
  }
35
+ constructor(){
36
+ /** The Virtualizer the layout is currently attached to. */ this.virtualizer = null;
37
+ }
34
38
  }
35
39
 
36
40
 
@@ -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,OAAO,mBAA2C,EAAE,CAAC;IA+BrD,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 update(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
+ {"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,OAAO,mBAA2C,EAAE,CAAC;IA+BrD,YAAY,GAAQ,EAAe;YAC1B;YAAA;QAAP,OAAO,CAAA,4BAAA,sBAAA,IAAI,CAAC,aAAa,CAAC,kBAAnB,0CAAA,oBAAyB,IAAI,cAA7B,sCAAA,2BAAiC;IAC1C;IAEA,iBAAuB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAE,WAAW;IACtC;;QA1DA,yDAAyD,QACzD,cAA0C;;AA0D5C","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> | null = null;\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 update(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 | null {\n return this.getLayoutInfo(key)?.rect ?? null;\n }\n\n getVisibleRect(): Rect {\n return this.virtualizer!.visibleRect;\n }\n}\n"],"names":[],"version":3,"file":"Layout.module.js.map"}
@@ -4,6 +4,7 @@ function $parcel$export(e, n, v, s) {
4
4
  }
5
5
 
6
6
  $parcel$export(module.exports, "ReusableView", () => $197a1781bd47f5b9$export$1a5223887c560441);
7
+ $parcel$export(module.exports, "RootView", () => $197a1781bd47f5b9$export$e21886a4eef6b29a);
7
8
  /*
8
9
  * Copyright 2020 Adobe. All rights reserved.
9
10
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -29,9 +30,7 @@ class $197a1781bd47f5b9$export$1a5223887c560441 {
29
30
  // The cells within a row are removed from their parent in order. If the row is reused, the cells
30
31
  // should be reused in the new row in the same order they were before.
31
32
  let reusable = this.reusableViews.get(reuseType);
32
- let view = (reusable === null || reusable === void 0 ? void 0 : reusable.length) > 0 ? reusable.shift() : new $197a1781bd47f5b9$export$1a5223887c560441(this.virtualizer);
33
- view.viewType = reuseType;
34
- view.parent = this;
33
+ let view = reusable && reusable.length > 0 ? reusable.shift() : new $197a1781bd47f5b9$export$7a41b6f219e61634(this.virtualizer, this, reuseType);
35
34
  return view;
36
35
  }
37
36
  reuseChild(child) {
@@ -43,12 +42,26 @@ class $197a1781bd47f5b9$export$1a5223887c560441 {
43
42
  }
44
43
  reusable.push(child);
45
44
  }
46
- constructor(virtualizer){
45
+ constructor(virtualizer, viewType){
47
46
  this.virtualizer = virtualizer;
48
47
  this.key = ++$197a1781bd47f5b9$var$KEY;
49
- this.parent = null;
48
+ this.viewType = viewType;
50
49
  this.children = new Set();
51
50
  this.reusableViews = new Map();
51
+ this.layoutInfo = null;
52
+ this.content = null;
53
+ this.rendered = null;
54
+ }
55
+ }
56
+ class $197a1781bd47f5b9$export$e21886a4eef6b29a extends $197a1781bd47f5b9$export$1a5223887c560441 {
57
+ constructor(virtualizer){
58
+ super(virtualizer, 'root');
59
+ }
60
+ }
61
+ class $197a1781bd47f5b9$export$7a41b6f219e61634 extends $197a1781bd47f5b9$export$1a5223887c560441 {
62
+ constructor(virtualizer, parent, viewType){
63
+ super(virtualizer, viewType);
64
+ this.parent = parent;
52
65
  }
53
66
  }
54
67
 
@@ -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,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
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAMD,IAAI,4BAAM;AAMH,MAAM;IA6BX;;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,YAAY,SAAS,MAAM,GAAG,IACrC,SAAS,KAAK,KACd,IAAI,0CAAgB,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE;QAEhD,OAAO;IACT;IAEA,WAAW,KAAsB,EAAE;QACjC,MAAM,eAAe;QACrB,IAAI,WAAW,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,QAAQ;QACpD,IAAI,CAAC,UAAU;YACb,WAAW,EAAE;YACb,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,QAAQ,EAAE;QACzC;QACA,SAAS,IAAI,CAAC;IAChB;IAzCA,YAAY,WAA8B,EAAE,QAAgB,CAAE;QAC5D,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE;QACb,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,QAAQ,GAAG,IAAI;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI;QACzB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,QAAQ,GAAG;IAClB;AAiCF;AAEO,MAAM,kDAAsC;IACjD,YAAY,WAA8B,CAAE;QAC1C,KAAK,CAAC,aAAa;IACrB;AACF;AAEO,MAAM,kDAAuC;IAGlD,YAAY,WAA8B,EAAE,MAA0B,EAAE,QAAgB,CAAE;QACxF,KAAK,CAAC,aAAa;QACnB,IAAI,CAAC,MAAM,GAAG;IAChB;AACF","sources":["packages/@react-stately/virtualizer/src/ReusableView.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {Virtualizer} from './Virtualizer';\n\nlet KEY = 0;\n\n/**\n * [Virtualizer]{@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 | null;\n\n rendered: V | null;\n\n viewType: string;\n key: Key;\n\n children: Set<ChildView<T, V>>;\n reusableViews: Map<string, ChildView<T, V>[]>;\n\n constructor(virtualizer: Virtualizer<T, V>, viewType: string) {\n this.virtualizer = virtualizer;\n this.key = ++KEY;\n this.viewType = viewType;\n this.children = new Set();\n this.reusableViews = new Map();\n this.layoutInfo = null;\n this.content = null;\n this.rendered = null;\n }\n\n /**\n * Prepares the view for reuse. Called just before the view is removed from the DOM.\n */\n prepareForReuse() {\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 && reusable.length > 0\n ? reusable.shift()!\n : new ChildView<T, V>(this.virtualizer, this, reuseType);\n\n return view;\n }\n\n reuseChild(child: ChildView<T, V>) {\n child.prepareForReuse();\n let reusable = this.reusableViews.get(child.viewType);\n if (!reusable) {\n reusable = [];\n this.reusableViews.set(child.viewType, reusable);\n }\n reusable.push(child);\n }\n}\n\nexport class RootView<T extends object, V> extends ReusableView<T, V> {\n constructor(virtualizer: Virtualizer<T, V>) {\n super(virtualizer, 'root');\n }\n}\n\nexport class ChildView<T extends object, V> extends ReusableView<T, V> {\n parent: ReusableView<T, V>;\n\n constructor(virtualizer: Virtualizer<T, V>, parent: ReusableView<T, V>, viewType: string) {\n super(virtualizer, viewType);\n this.parent = parent;\n }\n}\n"],"names":[],"version":3,"file":"ReusableView.main.js.map"}
@@ -23,9 +23,7 @@ class $ad1d98aa8f0c31b4$export$1a5223887c560441 {
23
23
  // The cells within a row are removed from their parent in order. If the row is reused, the cells
24
24
  // should be reused in the new row in the same order they were before.
25
25
  let reusable = this.reusableViews.get(reuseType);
26
- let view = (reusable === null || reusable === void 0 ? void 0 : reusable.length) > 0 ? reusable.shift() : new $ad1d98aa8f0c31b4$export$1a5223887c560441(this.virtualizer);
27
- view.viewType = reuseType;
28
- view.parent = this;
26
+ let view = reusable && reusable.length > 0 ? reusable.shift() : new $ad1d98aa8f0c31b4$export$7a41b6f219e61634(this.virtualizer, this, reuseType);
29
27
  return view;
30
28
  }
31
29
  reuseChild(child) {
@@ -37,15 +35,29 @@ class $ad1d98aa8f0c31b4$export$1a5223887c560441 {
37
35
  }
38
36
  reusable.push(child);
39
37
  }
40
- constructor(virtualizer){
38
+ constructor(virtualizer, viewType){
41
39
  this.virtualizer = virtualizer;
42
40
  this.key = ++$ad1d98aa8f0c31b4$var$KEY;
43
- this.parent = null;
41
+ this.viewType = viewType;
44
42
  this.children = new Set();
45
43
  this.reusableViews = new Map();
44
+ this.layoutInfo = null;
45
+ this.content = null;
46
+ this.rendered = null;
47
+ }
48
+ }
49
+ class $ad1d98aa8f0c31b4$export$e21886a4eef6b29a extends $ad1d98aa8f0c31b4$export$1a5223887c560441 {
50
+ constructor(virtualizer){
51
+ super(virtualizer, 'root');
52
+ }
53
+ }
54
+ class $ad1d98aa8f0c31b4$export$7a41b6f219e61634 extends $ad1d98aa8f0c31b4$export$1a5223887c560441 {
55
+ constructor(virtualizer, parent, viewType){
56
+ super(virtualizer, viewType);
57
+ this.parent = parent;
46
58
  }
47
59
  }
48
60
 
49
61
 
50
- export {$ad1d98aa8f0c31b4$export$1a5223887c560441 as ReusableView};
62
+ export {$ad1d98aa8f0c31b4$export$1a5223887c560441 as ReusableView, $ad1d98aa8f0c31b4$export$7a41b6f219e61634 as ChildView, $ad1d98aa8f0c31b4$export$e21886a4eef6b29a as RootView};
51
63
  //# sourceMappingURL=ReusableView.module.js.map
@@ -23,9 +23,7 @@ class $ad1d98aa8f0c31b4$export$1a5223887c560441 {
23
23
  // The cells within a row are removed from their parent in order. If the row is reused, the cells
24
24
  // should be reused in the new row in the same order they were before.
25
25
  let reusable = this.reusableViews.get(reuseType);
26
- let view = (reusable === null || reusable === void 0 ? void 0 : reusable.length) > 0 ? reusable.shift() : new $ad1d98aa8f0c31b4$export$1a5223887c560441(this.virtualizer);
27
- view.viewType = reuseType;
28
- view.parent = this;
26
+ let view = reusable && reusable.length > 0 ? reusable.shift() : new $ad1d98aa8f0c31b4$export$7a41b6f219e61634(this.virtualizer, this, reuseType);
29
27
  return view;
30
28
  }
31
29
  reuseChild(child) {
@@ -37,15 +35,29 @@ class $ad1d98aa8f0c31b4$export$1a5223887c560441 {
37
35
  }
38
36
  reusable.push(child);
39
37
  }
40
- constructor(virtualizer){
38
+ constructor(virtualizer, viewType){
41
39
  this.virtualizer = virtualizer;
42
40
  this.key = ++$ad1d98aa8f0c31b4$var$KEY;
43
- this.parent = null;
41
+ this.viewType = viewType;
44
42
  this.children = new Set();
45
43
  this.reusableViews = new Map();
44
+ this.layoutInfo = null;
45
+ this.content = null;
46
+ this.rendered = null;
47
+ }
48
+ }
49
+ class $ad1d98aa8f0c31b4$export$e21886a4eef6b29a extends $ad1d98aa8f0c31b4$export$1a5223887c560441 {
50
+ constructor(virtualizer){
51
+ super(virtualizer, 'root');
52
+ }
53
+ }
54
+ class $ad1d98aa8f0c31b4$export$7a41b6f219e61634 extends $ad1d98aa8f0c31b4$export$1a5223887c560441 {
55
+ constructor(virtualizer, parent, viewType){
56
+ super(virtualizer, viewType);
57
+ this.parent = parent;
46
58
  }
47
59
  }
48
60
 
49
61
 
50
- export {$ad1d98aa8f0c31b4$export$1a5223887c560441 as ReusableView};
62
+ export {$ad1d98aa8f0c31b4$export$1a5223887c560441 as ReusableView, $ad1d98aa8f0c31b4$export$7a41b6f219e61634 as ChildView, $ad1d98aa8f0c31b4$export$e21886a4eef6b29a as RootView};
51
63
  //# sourceMappingURL=ReusableView.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,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"}
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAMD,IAAI,4BAAM;AAMH,MAAM;IA6BX;;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,YAAY,SAAS,MAAM,GAAG,IACrC,SAAS,KAAK,KACd,IAAI,0CAAgB,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE;QAEhD,OAAO;IACT;IAEA,WAAW,KAAsB,EAAE;QACjC,MAAM,eAAe;QACrB,IAAI,WAAW,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,QAAQ;QACpD,IAAI,CAAC,UAAU;YACb,WAAW,EAAE;YACb,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,QAAQ,EAAE;QACzC;QACA,SAAS,IAAI,CAAC;IAChB;IAzCA,YAAY,WAA8B,EAAE,QAAgB,CAAE;QAC5D,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE;QACb,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,QAAQ,GAAG,IAAI;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI;QACzB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,QAAQ,GAAG;IAClB;AAiCF;AAEO,MAAM,kDAAsC;IACjD,YAAY,WAA8B,CAAE;QAC1C,KAAK,CAAC,aAAa;IACrB;AACF;AAEO,MAAM,kDAAuC;IAGlD,YAAY,WAA8B,EAAE,MAA0B,EAAE,QAAgB,CAAE;QACxF,KAAK,CAAC,aAAa;QACnB,IAAI,CAAC,MAAM,GAAG;IAChB;AACF","sources":["packages/@react-stately/virtualizer/src/ReusableView.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {Virtualizer} from './Virtualizer';\n\nlet KEY = 0;\n\n/**\n * [Virtualizer]{@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 | null;\n\n rendered: V | null;\n\n viewType: string;\n key: Key;\n\n children: Set<ChildView<T, V>>;\n reusableViews: Map<string, ChildView<T, V>[]>;\n\n constructor(virtualizer: Virtualizer<T, V>, viewType: string) {\n this.virtualizer = virtualizer;\n this.key = ++KEY;\n this.viewType = viewType;\n this.children = new Set();\n this.reusableViews = new Map();\n this.layoutInfo = null;\n this.content = null;\n this.rendered = null;\n }\n\n /**\n * Prepares the view for reuse. Called just before the view is removed from the DOM.\n */\n prepareForReuse() {\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 && reusable.length > 0\n ? reusable.shift()!\n : new ChildView<T, V>(this.virtualizer, this, reuseType);\n\n return view;\n }\n\n reuseChild(child: ChildView<T, V>) {\n child.prepareForReuse();\n let reusable = this.reusableViews.get(child.viewType);\n if (!reusable) {\n reusable = [];\n this.reusableViews.set(child.viewType, reusable);\n }\n reusable.push(child);\n }\n}\n\nexport class RootView<T extends object, V> extends ReusableView<T, V> {\n constructor(virtualizer: Virtualizer<T, V>) {\n super(virtualizer, 'root');\n }\n}\n\nexport class ChildView<T extends object, V> extends ReusableView<T, V> {\n parent: ReusableView<T, V>;\n\n constructor(virtualizer: Virtualizer<T, V>, parent: ReusableView<T, V>, viewType: string) {\n super(virtualizer, viewType);\n this.parent = parent;\n }\n}\n"],"names":[],"version":3,"file":"ReusableView.module.js.map"}
@@ -1,7 +1,7 @@
1
+ var $197a1781bd47f5b9$exports = require("./ReusableView.main.js");
1
2
  var $abed55ea619a7a17$exports = require("./utils.main.js");
2
3
  var $191a033606d4fda1$exports = require("./OverscanManager.main.js");
3
4
  var $41b7691783731623$exports = require("./Rect.main.js");
4
- var $197a1781bd47f5b9$exports = require("./ReusableView.main.js");
5
5
  var $064492b79924894c$exports = require("./Size.main.js");
6
6
 
7
7
 
@@ -32,7 +32,7 @@ class $e1bc15d49d21df0e$export$89be5a243e59c4b2 {
32
32
  // If not, check if the key is an ancestor of any of the persisted keys.
33
33
  for (let k of this.persistedKeys)while(k != null){
34
34
  let layoutInfo = this.layout.getLayoutInfo(k);
35
- if (!layoutInfo) break;
35
+ if (!layoutInfo || layoutInfo.parentKey == null) break;
36
36
  k = layoutInfo.parentKey;
37
37
  if (k === key) return true;
38
38
  }
@@ -49,12 +49,14 @@ class $e1bc15d49d21df0e$export$89be5a243e59c4b2 {
49
49
  return view;
50
50
  }
51
51
  _renderView(reusableView) {
52
- let { type: type, key: key, content: content } = reusableView.layoutInfo;
53
- reusableView.content = content || this.collection.getItem(key);
54
- reusableView.rendered = this._renderContent(type, reusableView.content);
52
+ if (reusableView.layoutInfo) {
53
+ let { type: type, key: key, content: content } = reusableView.layoutInfo;
54
+ reusableView.content = content || this.collection.getItem(key);
55
+ reusableView.rendered = this._renderContent(type, reusableView.content);
56
+ }
55
57
  }
56
58
  _renderContent(type, content) {
57
- let cached = this._renderedContent.get(content);
59
+ let cached = content != null ? this._renderedContent.get(content) : null;
58
60
  if (cached != null) return cached;
59
61
  let rendered = this.delegate.renderView(type, content);
60
62
  if (content) this._renderedContent.set(content, rendered);
@@ -124,7 +126,7 @@ class $e1bc15d49d21df0e$export$89be5a243e59c4b2 {
124
126
  view.layoutInfo = layoutInfo;
125
127
  let item = this.collection.getItem(layoutInfo.key);
126
128
  if (view.content !== item) {
127
- this._renderedContent.delete(view.content);
129
+ if (view.content != null) this._renderedContent.delete(view.content);
128
130
  this._renderView(view);
129
131
  }
130
132
  }
@@ -158,7 +160,7 @@ class $e1bc15d49d21df0e$export$89be5a243e59c4b2 {
158
160
  mutableThis.collection = opts.collection;
159
161
  needsLayout = true;
160
162
  }
161
- if (opts.layout !== this.layout) {
163
+ if (opts.layout !== this.layout || this.layout.virtualizer !== this) {
162
164
  if (this.layout) this.layout.virtualizer = null;
163
165
  opts.layout.virtualizer = this;
164
166
  mutableThis.layout = opts.layout;
@@ -215,16 +217,18 @@ class $e1bc15d49d21df0e$export$89be5a243e59c4b2 {
215
217
  itemSizeChanged: true
216
218
  });
217
219
  }
218
- constructor(delegate){
219
- this.delegate = delegate;
220
+ constructor(options){
221
+ this.delegate = options.delegate;
222
+ this.collection = options.collection;
223
+ this.layout = options.layout;
220
224
  this.contentSize = new (0, $064492b79924894c$exports.Size);
221
225
  this.visibleRect = new (0, $41b7691783731623$exports.Rect);
222
226
  this.persistedKeys = new Set();
223
227
  this._visibleViews = new Map();
224
228
  this._renderedContent = new WeakMap();
225
- this._rootView = new (0, $197a1781bd47f5b9$exports.ReusableView)(this);
229
+ this._rootView = new (0, $197a1781bd47f5b9$exports.RootView)(this);
226
230
  this._isScrolling = false;
227
- this._invalidationContext = null;
231
+ this._invalidationContext = {};
228
232
  this._overscanManager = new (0, $191a033606d4fda1$exports.OverscanManager)();
229
233
  }
230
234
  }