@react-stately/virtualizer 3.7.2-nightly.4649 → 3.7.2-nightly.4656

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/Layout.main.js +2 -41
  2. package/dist/Layout.main.js.map +1 -1
  3. package/dist/Layout.mjs +2 -41
  4. package/dist/Layout.module.js +2 -41
  5. package/dist/Layout.module.js.map +1 -1
  6. package/dist/LayoutInfo.main.js.map +1 -1
  7. package/dist/LayoutInfo.module.js.map +1 -1
  8. package/dist/OverscanManager.main.js +8 -43
  9. package/dist/OverscanManager.main.js.map +1 -1
  10. package/dist/OverscanManager.mjs +8 -43
  11. package/dist/OverscanManager.module.js +8 -43
  12. package/dist/OverscanManager.module.js.map +1 -1
  13. package/dist/ReusableView.main.js +23 -0
  14. package/dist/ReusableView.main.js.map +1 -1
  15. package/dist/ReusableView.mjs +23 -0
  16. package/dist/ReusableView.module.js +23 -0
  17. package/dist/ReusableView.module.js.map +1 -1
  18. package/dist/Virtualizer.main.js +123 -710
  19. package/dist/Virtualizer.main.js.map +1 -1
  20. package/dist/Virtualizer.mjs +124 -711
  21. package/dist/Virtualizer.module.js +124 -711
  22. package/dist/Virtualizer.module.js.map +1 -1
  23. package/dist/types.d.ts +64 -225
  24. package/dist/types.d.ts.map +1 -1
  25. package/dist/useVirtualizerState.main.js +39 -40
  26. package/dist/useVirtualizerState.main.js.map +1 -1
  27. package/dist/useVirtualizerState.mjs +40 -41
  28. package/dist/useVirtualizerState.module.js +40 -41
  29. package/dist/useVirtualizerState.module.js.map +1 -1
  30. package/dist/utils.main.js +1 -27
  31. package/dist/utils.main.js.map +1 -1
  32. package/dist/utils.mjs +2 -26
  33. package/dist/utils.module.js +2 -26
  34. package/dist/utils.module.js.map +1 -1
  35. package/package.json +4 -4
  36. package/src/Layout.ts +10 -55
  37. package/src/LayoutInfo.ts +2 -2
  38. package/src/OverscanManager.ts +10 -47
  39. package/src/ReusableView.ts +36 -7
  40. package/src/Virtualizer.ts +163 -1058
  41. package/src/types.ts +16 -38
  42. package/src/useVirtualizerState.ts +40 -39
  43. package/src/utils.ts +0 -52
  44. package/dist/Transaction.main.js +0 -32
  45. package/dist/Transaction.main.js.map +0 -1
  46. package/dist/Transaction.mjs +0 -27
  47. package/dist/Transaction.module.js +0 -27
  48. package/dist/Transaction.module.js.map +0 -1
  49. package/dist/tween.main.js +0 -67
  50. package/dist/tween.main.js.map +0 -1
  51. package/dist/tween.mjs +0 -61
  52. package/dist/tween.module.js +0 -61
  53. package/dist/tween.module.js.map +0 -1
  54. package/src/Transaction.ts +0 -28
  55. package/src/tween.ts +0 -83
@@ -17,9 +17,32 @@ class $ad1d98aa8f0c31b4$export$1a5223887c560441 {
17
17
  this.rendered = null;
18
18
  this.layoutInfo = null;
19
19
  }
20
+ getReusableView(reuseType) {
21
+ // Reusable view queue should be FIFO so that DOM order remains consistent during scrolling.
22
+ // For example, cells within a row should remain in the same order even if the row changes contents.
23
+ // The cells within a row are removed from their parent in order. If the row is reused, the cells
24
+ // should be reused in the new row in the same order they were before.
25
+ let reusable = this.reusableViews.get(reuseType);
26
+ let view = (reusable === 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;
29
+ return view;
30
+ }
31
+ reuseChild(child) {
32
+ child.prepareForReuse();
33
+ let reusable = this.reusableViews.get(child.viewType);
34
+ if (!reusable) {
35
+ reusable = [];
36
+ this.reusableViews.set(child.viewType, reusable);
37
+ }
38
+ reusable.push(child);
39
+ }
20
40
  constructor(virtualizer){
21
41
  this.virtualizer = virtualizer;
22
42
  this.key = ++$ad1d98aa8f0c31b4$var$KEY;
43
+ this.parent = null;
44
+ this.children = new Set();
45
+ this.reusableViews = new Map();
23
46
  }
24
47
  }
25
48
 
@@ -17,9 +17,32 @@ class $ad1d98aa8f0c31b4$export$1a5223887c560441 {
17
17
  this.rendered = null;
18
18
  this.layoutInfo = null;
19
19
  }
20
+ getReusableView(reuseType) {
21
+ // Reusable view queue should be FIFO so that DOM order remains consistent during scrolling.
22
+ // For example, cells within a row should remain in the same order even if the row changes contents.
23
+ // The cells within a row are removed from their parent in order. If the row is reused, the cells
24
+ // should be reused in the new row in the same order they were before.
25
+ let reusable = this.reusableViews.get(reuseType);
26
+ let view = (reusable === 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;
29
+ return view;
30
+ }
31
+ reuseChild(child) {
32
+ child.prepareForReuse();
33
+ let reusable = this.reusableViews.get(child.viewType);
34
+ if (!reusable) {
35
+ reusable = [];
36
+ this.reusableViews.set(child.viewType, reusable);
37
+ }
38
+ reusable.push(child);
39
+ }
20
40
  constructor(virtualizer){
21
41
  this.virtualizer = virtualizer;
22
42
  this.key = ++$ad1d98aa8f0c31b4$var$KEY;
43
+ this.parent = null;
44
+ this.children = new Set();
45
+ this.reusableViews = new Map();
23
46
  }
24
47
  }
25
48
 
@@ -1 +1 @@
1
- {"mappings":"AAAA;;;;;;;;;;CAUC,GAMD,IAAI,4BAAM;AASH,MAAM;IAoBX;;GAEC,GACD,kBAAkB;QAChB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,UAAU,GAAG;IACpB;IAZA,YAAY,WAAuC,CAAE;QACnD,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,GAAG,GAAG,EAAE;IACf;AAUF","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 * [CollectionView]{@link CollectionView} creates instances of the [ReusableView]{@link ReusableView} class to\n * represent views currently being displayed. ReusableViews manage a DOM node, handle\n * applying {@link LayoutInfo} objects to the view, and render content\n * as needed. Subclasses must implement the {@link render} method at a\n * minimum. Other methods can be overridden to customize behavior.\n */\nexport class ReusableView<T extends object, V> {\n /** The CollectionVirtualizer 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 collection view. */\n content: T;\n\n rendered: V;\n\n viewType: string;\n key: Key;\n\n constructor(virtualizer: Virtualizer<T, V, unknown>) {\n this.virtualizer = virtualizer;\n this.key = ++KEY;\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"],"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,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"}