@fluentui/react-virtualizer 9.0.0-alpha.12 → 9.0.0-alpha.14

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 (84) hide show
  1. package/.swcrc +30 -0
  2. package/CHANGELOG.json +49 -1
  3. package/CHANGELOG.md +23 -2
  4. package/dist/index.d.ts +90 -27
  5. package/lib/Hooks.js.map +1 -1
  6. package/lib/Virtualizer.js.map +1 -1
  7. package/lib/VirtualizerScrollView.js +2 -0
  8. package/lib/VirtualizerScrollView.js.map +1 -0
  9. package/lib/components/Virtualizer/Virtualizer.js.map +1 -1
  10. package/lib/components/Virtualizer/Virtualizer.types.js +1 -1
  11. package/lib/components/Virtualizer/Virtualizer.types.js.map +1 -1
  12. package/lib/components/Virtualizer/index.js.map +1 -1
  13. package/lib/components/Virtualizer/renderVirtualizer.js +1 -9
  14. package/lib/components/Virtualizer/renderVirtualizer.js.map +1 -1
  15. package/lib/components/Virtualizer/useVirtualizer.js +13 -11
  16. package/lib/components/Virtualizer/useVirtualizer.js.map +1 -1
  17. package/lib/components/Virtualizer/useVirtualizerStyles.js.map +1 -1
  18. package/lib/components/VirtualizerScrollView/VirtualizerScrollView.js +14 -0
  19. package/lib/components/VirtualizerScrollView/VirtualizerScrollView.js.map +1 -0
  20. package/lib/components/VirtualizerScrollView/VirtualizerScrollView.types.js +2 -0
  21. package/lib/components/VirtualizerScrollView/VirtualizerScrollView.types.js.map +1 -0
  22. package/lib/components/VirtualizerScrollView/index.js +6 -0
  23. package/lib/components/VirtualizerScrollView/index.js.map +1 -0
  24. package/lib/components/VirtualizerScrollView/renderVirtualizerScrollView.js +11 -0
  25. package/lib/components/VirtualizerScrollView/renderVirtualizerScrollView.js.map +1 -0
  26. package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js +38 -0
  27. package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -0
  28. package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.js +46 -0
  29. package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.js.map +1 -0
  30. package/lib/hooks/index.js +1 -0
  31. package/lib/hooks/index.js.map +1 -1
  32. package/lib/hooks/useIntersectionObserver.js +2 -10
  33. package/lib/hooks/useIntersectionObserver.js.map +1 -1
  34. package/lib/hooks/useVirtualizerMeasure.js +76 -0
  35. package/lib/hooks/useVirtualizerMeasure.js.map +1 -0
  36. package/lib/hooks/useVirtualizerMeasure.types.js +2 -0
  37. package/lib/hooks/useVirtualizerMeasure.types.js.map +1 -0
  38. package/lib/index.js +2 -1
  39. package/lib/index.js.map +1 -1
  40. package/lib/utilities/debounce.js +20 -0
  41. package/lib/utilities/debounce.js.map +1 -0
  42. package/lib-commonjs/Hooks.js +5 -4
  43. package/lib-commonjs/Hooks.js.map +1 -1
  44. package/lib-commonjs/Virtualizer.js +5 -4
  45. package/lib-commonjs/Virtualizer.js.map +1 -1
  46. package/lib-commonjs/VirtualizerScrollView.js +9 -0
  47. package/lib-commonjs/VirtualizerScrollView.js.map +1 -0
  48. package/lib-commonjs/components/Virtualizer/Virtualizer.js +14 -17
  49. package/lib-commonjs/components/Virtualizer/Virtualizer.js.map +1 -1
  50. package/lib-commonjs/components/Virtualizer/Virtualizer.types.js +5 -2
  51. package/lib-commonjs/components/Virtualizer/Virtualizer.types.js.map +1 -1
  52. package/lib-commonjs/components/Virtualizer/index.js +9 -8
  53. package/lib-commonjs/components/Virtualizer/index.js.map +1 -1
  54. package/lib-commonjs/components/Virtualizer/renderVirtualizer.js +13 -21
  55. package/lib-commonjs/components/Virtualizer/renderVirtualizer.js.map +1 -1
  56. package/lib-commonjs/components/Virtualizer/useVirtualizer.js +358 -361
  57. package/lib-commonjs/components/Virtualizer/useVirtualizer.js.map +1 -1
  58. package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.js +112 -107
  59. package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.js.map +1 -1
  60. package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.js +21 -0
  61. package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.js.map +1 -0
  62. package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.types.js +7 -0
  63. package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.types.js.map +1 -0
  64. package/lib-commonjs/components/VirtualizerScrollView/index.js +13 -0
  65. package/lib-commonjs/components/VirtualizerScrollView/index.js.map +1 -0
  66. package/lib-commonjs/components/VirtualizerScrollView/renderVirtualizerScrollView.js +18 -0
  67. package/lib-commonjs/components/VirtualizerScrollView/renderVirtualizerScrollView.js.map +1 -0
  68. package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js +43 -0
  69. package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -0
  70. package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.js +69 -0
  71. package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.js.map +1 -0
  72. package/lib-commonjs/hooks/index.js +6 -4
  73. package/lib-commonjs/hooks/index.js.map +1 -1
  74. package/lib-commonjs/hooks/useIntersectionObserver.js +41 -54
  75. package/lib-commonjs/hooks/useIntersectionObserver.js.map +1 -1
  76. package/lib-commonjs/hooks/useVirtualizerMeasure.js +75 -0
  77. package/lib-commonjs/hooks/useVirtualizerMeasure.js.map +1 -0
  78. package/lib-commonjs/hooks/useVirtualizerMeasure.types.js +7 -0
  79. package/lib-commonjs/hooks/useVirtualizerMeasure.types.js.map +1 -0
  80. package/lib-commonjs/index.js +25 -40
  81. package/lib-commonjs/index.js.map +1 -1
  82. package/lib-commonjs/utilities/debounce.js +29 -0
  83. package/lib-commonjs/utilities/debounce.js.map +1 -0
  84. package/package.json +7 -5
package/.swcrc ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/swcrc",
3
+ "exclude": [
4
+ "/testing",
5
+ "/**/*.cy.ts",
6
+ "/**/*.cy.tsx",
7
+ "/**/*.spec.ts",
8
+ "/**/*.spec.tsx",
9
+ "/**/*.test.ts",
10
+ "/**/*.test.tsx"
11
+ ],
12
+ "jsc": {
13
+ "parser": {
14
+ "syntax": "typescript",
15
+ "tsx": true,
16
+ "decorators": false,
17
+ "dynamicImport": false
18
+ },
19
+ "externalHelpers": true,
20
+ "transform": {
21
+ "react": {
22
+ "runtime": "classic",
23
+ "useSpread": true
24
+ }
25
+ },
26
+ "target": "es2019"
27
+ },
28
+ "minify": false,
29
+ "sourceMaps": true
30
+ }
package/CHANGELOG.json CHANGED
@@ -2,7 +2,55 @@
2
2
  "name": "@fluentui/react-virtualizer",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 16 Mar 2023 14:33:33 GMT",
5
+ "date": "Fri, 24 Mar 2023 10:15:03 GMT",
6
+ "tag": "@fluentui/react-virtualizer_v9.0.0-alpha.14",
7
+ "version": "9.0.0-alpha.14",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "mifraser@microsoft.com",
12
+ "package": "@fluentui/react-virtualizer",
13
+ "commit": "19801e7edc22f433eeace3cf636f4722ea02a36b",
14
+ "comment": "[feat] Add static measurement hooks and embedded scroll option"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Tue, 21 Mar 2023 21:23:16 GMT",
21
+ "tag": "@fluentui/react-virtualizer_v9.0.0-alpha.13",
22
+ "version": "9.0.0-alpha.13",
23
+ "comments": {
24
+ "prerelease": [
25
+ {
26
+ "author": "tristan.watanabe@gmail.com",
27
+ "package": "@fluentui/react-virtualizer",
28
+ "commit": "2fac1a139149bd13b76b1306207bc988dca9c72c",
29
+ "comment": "chore: migrate to swc transpilation approach."
30
+ },
31
+ {
32
+ "author": "tristan.watanabe@gmail.com",
33
+ "package": "@fluentui/react-virtualizer",
34
+ "commit": "ead1c6d4c2ac3f3596b62b8cbc07b0a03041f11f",
35
+ "comment": "fix: add node field to package.json exports map."
36
+ },
37
+ {
38
+ "author": "beachball",
39
+ "package": "@fluentui/react-virtualizer",
40
+ "comment": "Bump @fluentui/react-utilities to v9.7.2",
41
+ "commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
42
+ },
43
+ {
44
+ "author": "beachball",
45
+ "package": "@fluentui/react-virtualizer",
46
+ "comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.20",
47
+ "commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
48
+ }
49
+ ]
50
+ }
51
+ },
52
+ {
53
+ "date": "Thu, 16 Mar 2023 14:36:59 GMT",
6
54
  "tag": "@fluentui/react-virtualizer_v9.0.0-alpha.12",
7
55
  "version": "9.0.0-alpha.12",
8
56
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,33 @@
1
1
  # Change Log - @fluentui/react-virtualizer
2
2
 
3
- This log was last generated on Thu, 16 Mar 2023 14:33:33 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 24 Mar 2023 10:15:03 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.0-alpha.14](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.14)
8
+
9
+ Fri, 24 Mar 2023 10:15:03 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.13..@fluentui/react-virtualizer_v9.0.0-alpha.14)
11
+
12
+ ### Changes
13
+
14
+ - [feat] Add static measurement hooks and embedded scroll option ([PR #26985](https://github.com/microsoft/fluentui/pull/26985) by mifraser@microsoft.com)
15
+
16
+ ## [9.0.0-alpha.13](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.13)
17
+
18
+ Tue, 21 Mar 2023 21:23:16 GMT
19
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.12..@fluentui/react-virtualizer_v9.0.0-alpha.13)
20
+
21
+ ### Changes
22
+
23
+ - chore: migrate to swc transpilation approach. ([PR #27250](https://github.com/microsoft/fluentui/pull/27250) by tristan.watanabe@gmail.com)
24
+ - fix: add node field to package.json exports map. ([PR #27154](https://github.com/microsoft/fluentui/pull/27154) by tristan.watanabe@gmail.com)
25
+ - Bump @fluentui/react-utilities to v9.7.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
26
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.20 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
27
+
7
28
  ## [9.0.0-alpha.12](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.12)
8
29
 
9
- Thu, 16 Mar 2023 14:33:33 GMT
30
+ Thu, 16 Mar 2023 14:36:59 GMT
10
31
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.11..@fluentui/react-virtualizer_v9.0.0-alpha.12)
11
32
 
12
33
  ### Changes
package/dist/index.d.ts CHANGED
@@ -1,15 +1,17 @@
1
- import type { ComponentProps } from '@fluentui/react-utilities';
2
- import type { ComponentState } from '@fluentui/react-utilities';
1
+ import { ComponentProps } from '@fluentui/react-utilities';
2
+ import { ComponentState } from '@fluentui/react-utilities';
3
3
  import type { Dispatch } from 'react';
4
4
  import type { FC } from 'react';
5
5
  import type { MutableRefObject } from 'react';
6
6
  import * as React_2 from 'react';
7
7
  import type { SetStateAction } from 'react';
8
- import type { Slot } from '@fluentui/react-utilities';
8
+ import { Slot } from '@fluentui/react-utilities';
9
9
  import type { SlotClassNames } from '@fluentui/react-utilities';
10
10
 
11
11
  export declare const renderVirtualizer_unstable: (state: VirtualizerState) => JSX.Element;
12
12
 
13
+ export declare const renderVirtualizerScrollView_unstable: (state: VirtualizerScrollViewState) => JSX.Element;
14
+
13
15
  /**
14
16
  * React hook that allows easy usage of the browser API IntersectionObserver within React
15
17
  * @param callback - A function called when the percentage of the target element is visible crosses a threshold.
@@ -25,8 +27,25 @@ export declare const useIntersectionObserver: (callback: IntersectionObserverCal
25
27
  observer: MutableRefObject<IntersectionObserver | undefined>;
26
28
  };
27
29
 
30
+ /**
31
+ * React hook that measures virtualized space based on a static size to ensure optimized virtualization length.
32
+ */
33
+ export declare const useStaticVirtualizerMeasure: (virtualizerProps: VirtualizerMeasureProps) => {
34
+ virtualizerLength: number;
35
+ bufferItems: number;
36
+ bufferSize: number;
37
+ scrollRef: (instance: HTMLElement | HTMLDivElement | null) => void;
38
+ };
39
+
28
40
  export declare function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState;
29
41
 
42
+ export declare function useVirtualizerScrollView_unstable(props: VirtualizerScrollViewProps): VirtualizerScrollViewState;
43
+
44
+ /**
45
+ * Apply styling to the Virtualizer states
46
+ */
47
+ export declare const useVirtualizerScrollViewStyles_unstable: (state: VirtualizerScrollViewState) => VirtualizerScrollViewState;
48
+
30
49
  /**
31
50
  * Apply styling to the Virtualizer states
32
51
  */
@@ -43,7 +62,7 @@ export declare type VirtualizerChildRenderFunction = (index: number) => React_2.
43
62
 
44
63
  export declare const virtualizerClassNames: SlotClassNames<VirtualizerSlots>;
45
64
 
46
- export declare type VirtualizerProps = ComponentProps<Partial<VirtualizerSlots>> & {
65
+ declare type VirtualizerConfigProps = {
47
66
  /**
48
67
  * Child render function.
49
68
  * Iteratively called to return current virtualizer DOM children.
@@ -87,9 +106,8 @@ export declare type VirtualizerProps = ComponentProps<Partial<VirtualizerSlots>>
87
106
  bufferSize?: number;
88
107
  /**
89
108
  * Enables users to override the intersectionObserverRoot.
90
- * @default null
91
109
  */
92
- intersectionObserverRoot?: React_2.MutableRefObject<HTMLElement | null>;
110
+ scrollViewRef?: React_2.MutableRefObject<HTMLElement | null>;
93
111
  /**
94
112
  * The scroll direction
95
113
  * @default vertical
@@ -115,26 +133,7 @@ export declare type VirtualizerProps = ComponentProps<Partial<VirtualizerSlots>>
115
133
  onCalculateIndex?: (newIndex: number) => number;
116
134
  };
117
135
 
118
- export declare type VirtualizerSlots = {
119
- /**
120
- * The intersection observed 'before' element will detect when scrolling towards the beginning.
121
- */
122
- before: NonNullable<Slot<'div', 'td'>>;
123
- /**
124
- * A block place holding whitespace at the beginning of current DOM children.
125
- */
126
- beforeContainer: NonNullable<Slot<'div', 'tr'>>;
127
- /**
128
- * The intersection observed 'after' element will detect when scrolling towards the end.
129
- */
130
- after: NonNullable<Slot<'div', 'td'>>;
131
- /**
132
- * A block place holding whitespace after the end of current DOM children.
133
- */
134
- afterContainer: NonNullable<Slot<'div', 'tr'>>;
135
- };
136
-
137
- export declare type VirtualizerState = ComponentState<VirtualizerSlots> & {
136
+ declare type VirtualizerConfigState = {
138
137
  /**
139
138
  * The current virtualized array of children to show in the DOM.
140
139
  */
@@ -165,9 +164,73 @@ export declare type VirtualizerState = ComponentState<VirtualizerSlots> & {
165
164
  */
166
165
  reversed?: boolean;
167
166
  /**
168
- * Tells the virtualizer how much
167
+ * Pixel size of intersection observers and how much they 'cross over' into the bufferItems index.
168
+ * Minimum 1px.
169
169
  */
170
170
  bufferSize: number;
171
171
  };
172
172
 
173
+ declare type VirtualizerMeasureProps = {
174
+ defaultItemSize: number;
175
+ direction?: 'vertical' | 'horizontal';
176
+ };
177
+
178
+ export declare type VirtualizerProps = ComponentProps<Partial<VirtualizerSlots>> & VirtualizerConfigProps;
179
+
180
+ /**
181
+ * Virtualizer ScrollView
182
+ */
183
+ export declare const VirtualizerScrollView: React_2.FC<VirtualizerScrollViewProps>;
184
+
185
+ export declare const virtualizerScrollViewClassNames: SlotClassNames<VirtualizerScrollViewSlots>;
186
+
187
+ export declare type VirtualizerScrollViewProps = ComponentProps<Partial<VirtualizerScrollViewSlots>> & Partial<Omit<VirtualizerConfigProps, 'itemSize' | 'numItems' | 'getItemSize' | 'children'>> & {
188
+ /**
189
+ * Virtualizer item size in pixels - static.
190
+ * Axis: 'vertical' = Height
191
+ * Axis: 'horizontal' = Width
192
+ */
193
+ itemSize: number;
194
+ /**
195
+ * The total number of items to be virtualized.
196
+ */
197
+ numItems: number;
198
+ /**
199
+ * Child render function.
200
+ * Iteratively called to return current virtualizer DOM children.
201
+ * Will act as a row or column indexer depending on Virtualizer settings.
202
+ */
203
+ children: VirtualizerChildRenderFunction;
204
+ };
205
+
206
+ export declare type VirtualizerScrollViewSlots = VirtualizerSlots & {
207
+ /**
208
+ * The root container that provides embedded scrolling.
209
+ */
210
+ container: NonNullable<Slot<'div'>>;
211
+ };
212
+
213
+ export declare type VirtualizerScrollViewState = ComponentState<VirtualizerScrollViewSlots> & VirtualizerConfigState;
214
+
215
+ export declare type VirtualizerSlots = {
216
+ /**
217
+ * The intersection observed 'before' element will detect when scrolling towards the beginning.
218
+ */
219
+ before: NonNullable<Slot<'div', 'td'>>;
220
+ /**
221
+ * A block place holding whitespace at the beginning of current DOM children.
222
+ */
223
+ beforeContainer: NonNullable<Slot<'div', 'tr'>>;
224
+ /**
225
+ * The intersection observed 'after' element will detect when scrolling towards the end.
226
+ */
227
+ after: NonNullable<Slot<'div', 'td'>>;
228
+ /**
229
+ * A block place holding whitespace after the end of current DOM children.
230
+ */
231
+ afterContainer: NonNullable<Slot<'div', 'tr'>>;
232
+ };
233
+
234
+ export declare type VirtualizerState = ComponentState<VirtualizerSlots> & VirtualizerConfigState;
235
+
173
236
  export { }
package/lib/Hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Hooks.js","sourceRoot":"../src/","sources":["packages/react-components/react-virtualizer/src/Hooks.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC","sourcesContent":["export * from './hooks/index';\n"]}
1
+ {"version":3,"names":[],"sources":["../src/Hooks.ts"],"sourcesContent":["export * from './hooks/index';\n"],"mappings":"AAAA,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Virtualizer.js","sourceRoot":"../src/","sources":["packages/react-components/react-virtualizer/src/Virtualizer.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC","sourcesContent":["export * from './components/Virtualizer/index';\n"]}
1
+ {"version":3,"names":[],"sources":["../src/Virtualizer.ts"],"sourcesContent":["export * from './components/Virtualizer/index';\n"],"mappings":"AAAA,cAAc"}
@@ -0,0 +1,2 @@
1
+ export * from './components/VirtualizerScrollView/index';
2
+ //# sourceMappingURL=VirtualizerScrollView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../src/VirtualizerScrollView.ts"],"sourcesContent":["export * from './components/VirtualizerScrollView/index';\n"],"mappings":"AAAA,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"names":["useVirtualizerStyles_unstable","useVirtualizer_unstable","renderVirtualizer_unstable","Virtualizer","props","state","displayName"],"sources":["../src/packages/react-components/react-virtualizer/src/components/Virtualizer/Virtualizer.ts"],"sourcesContent":["import type { VirtualizerProps } from './Virtualizer.types';\nimport { useVirtualizerStyles_unstable } from './useVirtualizerStyles';\nimport { useVirtualizer_unstable } from './useVirtualizer';\nimport { renderVirtualizer_unstable } from './renderVirtualizer';\nimport type { FC } from 'react';\n\n/**\n * Virtualizer pseudo-component, this functional wrapper\n * provides a simple interface for reducing the total number\n * of elements rendered at one time in large lists.\n */\nexport const Virtualizer: FC<VirtualizerProps> = (props: VirtualizerProps) => {\n const state = useVirtualizer_unstable(props);\n useVirtualizerStyles_unstable(state);\n\n return renderVirtualizer_unstable(state);\n};\n\nVirtualizer.displayName = 'Virtualizer';\n"],"mappings":"AACA,SAASA,6BAA6B,QAAQ,wBAAwB;AACtE,SAASC,uBAAuB,QAAQ,kBAAkB;AAC1D,SAASC,0BAA0B,QAAQ,qBAAqB;AAGhE;;;;;AAKA,OAAO,MAAMC,WAAW,GAA0BC,KAAuB,IAAI;EAC3E,MAAMC,KAAK,GAAGJ,uBAAuB,CAACG,KAAK,CAAC;EAC5CJ,6BAA6B,CAACK,KAAK,CAAC;EAEpC,OAAOH,0BAA0B,CAACG,KAAK,CAAC;AAC1C,CAAC;AAEDF,WAAW,CAACG,WAAW,GAAG,aAAa"}
1
+ {"version":3,"names":["useVirtualizerStyles_unstable","useVirtualizer_unstable","renderVirtualizer_unstable","Virtualizer","props","state","displayName"],"sources":["../../../src/components/Virtualizer/Virtualizer.ts"],"sourcesContent":["import type { VirtualizerProps } from './Virtualizer.types';\nimport { useVirtualizerStyles_unstable } from './useVirtualizerStyles';\nimport { useVirtualizer_unstable } from './useVirtualizer';\nimport { renderVirtualizer_unstable } from './renderVirtualizer';\nimport type { FC } from 'react';\n\n/**\n * Virtualizer pseudo-component, this functional wrapper\n * provides a simple interface for reducing the total number\n * of elements rendered at one time in large lists.\n */\nexport const Virtualizer: FC<VirtualizerProps> = (props: VirtualizerProps) => {\n const state = useVirtualizer_unstable(props);\n useVirtualizerStyles_unstable(state);\n\n return renderVirtualizer_unstable(state);\n};\n\nVirtualizer.displayName = 'Virtualizer';\n"],"mappings":"AACA,SAASA,6BAA6B,QAAQ;AAC9C,SAASC,uBAAuB,QAAQ;AACxC,SAASC,0BAA0B,QAAQ;AAG3C;;;;;AAKA,OAAO,MAAMC,WAAA,GAAqCC,KAAA,IAA4B;EAC5E,MAAMC,KAAA,GAAQJ,uBAAA,CAAwBG,KAAA;EACtCJ,6BAAA,CAA8BK,KAAA;EAE9B,OAAOH,0BAAA,CAA2BG,KAAA;AACpC;AAEAF,WAAA,CAAYG,WAAW,GAAG"}
@@ -1,2 +1,2 @@
1
- export {};
1
+ import * as React from 'react';
2
2
  //# sourceMappingURL=Virtualizer.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Virtualizer.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-virtualizer/src/components/Virtualizer/Virtualizer.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type VirtualizerSlots = {\n /**\n * The intersection observed 'before' element will detect when scrolling towards the beginning.\n */\n before: NonNullable<Slot<'div', 'td'>>;\n /**\n * A block place holding whitespace at the beginning of current DOM children.\n */\n beforeContainer: NonNullable<Slot<'div', 'tr'>>;\n /**\n * The intersection observed 'after' element will detect when scrolling towards the end.\n */\n after: NonNullable<Slot<'div', 'td'>>;\n /**\n * A block place holding whitespace after the end of current DOM children.\n */\n afterContainer: NonNullable<Slot<'div', 'tr'>>;\n};\n\nexport type VirtualizerState = ComponentState<VirtualizerSlots> & {\n /**\n * The current virtualized array of children to show in the DOM.\n */\n virtualizedChildren: React.ReactNode[];\n /**\n * The current start index for the virtualizer, all previous index's will be removed from DOM.\n */\n virtualizerStartIndex: number;\n /**\n * Current buffer height required at beginning of array.\n */\n afterBufferHeight: number;\n /**\n * Current buffer height required at end of array.\n */\n beforeBufferHeight: number;\n /**\n * The total current height of the scrollView/child content.\n */\n totalVirtualizerHeight: number;\n /**\n * The scroll direction\n * @default vertical\n */\n axis?: 'vertical' | 'horizontal';\n /**\n * Tells the virtualizer to measure in the reverse direction (for column-reverse order etc.)\n */\n reversed?: boolean;\n /**\n * Tells the virtualizer how much\n */\n bufferSize: number;\n};\n\n// Virtualizer render function to procedurally generate children elements as rows or columns via index.\n// Q: Use generic typing and passing through object data or a simple index system?\nexport type VirtualizerChildRenderFunction = (index: number) => React.ReactNode;\n\nexport type VirtualizerProps = ComponentProps<Partial<VirtualizerSlots>> & {\n /**\n * Child render function.\n * Iteratively called to return current virtualizer DOM children.\n * Will act as a row or column indexer depending on Virtualizer settings.\n * Can be used dynamically.\n */\n children: VirtualizerChildRenderFunction;\n\n /**\n * Default cell size to use if no custom callback provided.\n * If implementing `getItemSize` this should be the initial and ideally minimum cell size.\n */\n itemSize: number;\n\n /**\n * The total number of items to be virtualized.\n */\n numItems: number;\n\n /**\n * Number of children to render in the DOM during virtualization.\n * Constraints:\n * - Large enough that the items rendered in DOM cover the viewport\n * and intersection observer buffers (buffersize) at both ends.\n */\n virtualizerLength: number;\n\n /**\n * Defaults to 1/4th of virtualizerLength.\n * Controls the number of elements rendered before the current index entering the virtualized viewport.\n * Constraints:\n * - Large enough to cover bufferSize (prevents buffers intersecting into the viewport during rest state).\n * - Small enough that the end buffer and end index (start index + virtualizerLength) is not within viewport at rest.\n */\n bufferItems?: number;\n\n /**\n * Defaults to half of bufferItems size (in pixels).\n * The length (in pixels) before the end/start DOM index where the virtualizer recalculation will be triggered.\n * Increasing this reduces whitespace on ultra-fast scroll, as additional elements\n * are buffered to appear while virtualization recalculates.\n * Constraints:\n * - At least 1px - although this will only trigger the recalculation after bookends (whitespace) enter viewport.\n * - BufferSize must be smaller than bufferItems pixel size, as it prevents bookends entering viewport at rest.\n */\n bufferSize?: number;\n\n /**\n * Enables users to override the intersectionObserverRoot.\n * @default null\n */\n intersectionObserverRoot?: React.MutableRefObject<HTMLElement | null>;\n\n /**\n * The scroll direction\n * @default vertical\n */\n axis?: 'vertical' | 'horizontal';\n\n /**\n * Tells the virtualizer to measure in the reverse direction (for column-reverse order etc.)\n * This value should be flipped in RTL implementation (TBD whether automate RTL).\n */\n reversed?: boolean;\n\n /**\n * Callback for acquiring size of individual items\n * @param index - the index of the requested size's child\n */\n getItemSize?: (index: number) => number;\n\n /**\n * Notify users of index changes\n */\n onUpdateIndex?: (index: number, prevIndex: number) => void;\n\n /**\n * Allow users to intervene in index calculation changes\n */\n onCalculateIndex?: (newIndex: number) => number;\n};\n"]}
1
+ {"version":3,"names":["React"],"sources":["../../../src/components/Virtualizer/Virtualizer.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type VirtualizerSlots = {\n /**\n * The intersection observed 'before' element will detect when scrolling towards the beginning.\n */\n before: NonNullable<Slot<'div', 'td'>>;\n /**\n * A block place holding whitespace at the beginning of current DOM children.\n */\n beforeContainer: NonNullable<Slot<'div', 'tr'>>;\n /**\n * The intersection observed 'after' element will detect when scrolling towards the end.\n */\n after: NonNullable<Slot<'div', 'td'>>;\n /**\n * A block place holding whitespace after the end of current DOM children.\n */\n afterContainer: NonNullable<Slot<'div', 'tr'>>;\n};\n\nexport type VirtualizerConfigState = {\n /**\n * The current virtualized array of children to show in the DOM.\n */\n virtualizedChildren: React.ReactNode[];\n /**\n * The current start index for the virtualizer, all previous index's will be removed from DOM.\n */\n virtualizerStartIndex: number;\n /**\n * Current buffer height required at beginning of array.\n */\n afterBufferHeight: number;\n /**\n * Current buffer height required at end of array.\n */\n beforeBufferHeight: number;\n /**\n * The total current height of the scrollView/child content.\n */\n totalVirtualizerHeight: number;\n /**\n * The scroll direction\n * @default vertical\n */\n axis?: 'vertical' | 'horizontal';\n /**\n * Tells the virtualizer to measure in the reverse direction (for column-reverse order etc.)\n */\n reversed?: boolean;\n /**\n * Pixel size of intersection observers and how much they 'cross over' into the bufferItems index.\n * Minimum 1px.\n */\n bufferSize: number;\n};\n\nexport type VirtualizerState = ComponentState<VirtualizerSlots> & VirtualizerConfigState;\n\n// Virtualizer render function to procedurally generate children elements as rows or columns via index.\n// Q: Use generic typing and passing through object data or a simple index system?\nexport type VirtualizerChildRenderFunction = (index: number) => React.ReactNode;\n\nexport type VirtualizerConfigProps = {\n /**\n * Child render function.\n * Iteratively called to return current virtualizer DOM children.\n * Will act as a row or column indexer depending on Virtualizer settings.\n * Can be used dynamically.\n */\n children: VirtualizerChildRenderFunction;\n\n /**\n * Default cell size to use if no custom callback provided.\n * If implementing `getItemSize` this should be the initial and ideally minimum cell size.\n */\n itemSize: number;\n\n /**\n * The total number of items to be virtualized.\n */\n numItems: number;\n\n /**\n * Number of children to render in the DOM during virtualization.\n * Constraints:\n * - Large enough that the items rendered in DOM cover the viewport\n * and intersection observer buffers (buffersize) at both ends.\n */\n virtualizerLength: number;\n\n /**\n * Defaults to 1/4th of virtualizerLength.\n * Controls the number of elements rendered before the current index entering the virtualized viewport.\n * Constraints:\n * - Large enough to cover bufferSize (prevents buffers intersecting into the viewport during rest state).\n * - Small enough that the end buffer and end index (start index + virtualizerLength) is not within viewport at rest.\n */\n bufferItems?: number;\n\n /**\n * Defaults to half of bufferItems size (in pixels).\n * The length (in pixels) before the end/start DOM index where the virtualizer recalculation will be triggered.\n * Increasing this reduces whitespace on ultra-fast scroll, as additional elements\n * are buffered to appear while virtualization recalculates.\n * Constraints:\n * - At least 1px - although this will only trigger the recalculation after bookends (whitespace) enter viewport.\n * - BufferSize must be smaller than bufferItems pixel size, as it prevents bookends entering viewport at rest.\n */\n bufferSize?: number;\n\n /**\n * Enables users to override the intersectionObserverRoot.\n */\n scrollViewRef?: React.MutableRefObject<HTMLElement | null>;\n\n /**\n * The scroll direction\n * @default vertical\n */\n axis?: 'vertical' | 'horizontal';\n\n /**\n * Tells the virtualizer to measure in the reverse direction (for column-reverse order etc.)\n * This value should be flipped in RTL implementation (TBD whether automate RTL).\n */\n reversed?: boolean;\n\n /**\n * Callback for acquiring size of individual items\n * @param index - the index of the requested size's child\n */\n getItemSize?: (index: number) => number;\n\n /**\n * Notify users of index changes\n */\n onUpdateIndex?: (index: number, prevIndex: number) => void;\n\n /**\n * Allow users to intervene in index calculation changes\n */\n onCalculateIndex?: (newIndex: number) => number;\n};\n\nexport type VirtualizerProps = ComponentProps<Partial<VirtualizerSlots>> & VirtualizerConfigProps;\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-virtualizer/src/components/Virtualizer/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './Virtualizer';\nexport * from './Virtualizer.types';\nexport * from './useVirtualizer';\nexport * from './renderVirtualizer';\nexport * from './useVirtualizerStyles';\n"]}
1
+ {"version":3,"names":[],"sources":["../../../src/components/Virtualizer/index.ts"],"sourcesContent":["export * from './Virtualizer';\nexport * from './Virtualizer.types';\nexport * from './useVirtualizer';\nexport * from './renderVirtualizer';\nexport * from './useVirtualizerStyles';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
@@ -5,14 +5,6 @@ export const renderVirtualizer_unstable = state => {
5
5
  slots,
6
6
  slotProps
7
7
  } = getSlots(state);
8
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(slots.beforeContainer, {
9
- ...slotProps.beforeContainer
10
- }, /*#__PURE__*/React.createElement(slots.before, {
11
- ...slotProps.before
12
- })), state.virtualizedChildren, /*#__PURE__*/React.createElement(slots.afterContainer, {
13
- ...slotProps.afterContainer
14
- }, /*#__PURE__*/React.createElement(slots.after, {
15
- ...slotProps.after
16
- })));
8
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(slots.beforeContainer, slotProps.beforeContainer, /*#__PURE__*/React.createElement(slots.before, slotProps.before)), state.virtualizedChildren, /*#__PURE__*/React.createElement(slots.afterContainer, slotProps.afterContainer, /*#__PURE__*/React.createElement(slots.after, slotProps.after)));
17
9
  };
18
10
  //# sourceMappingURL=renderVirtualizer.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","getSlots","renderVirtualizer_unstable","state","slots","slotProps","createElement","Fragment","beforeContainer","before","virtualizedChildren","afterContainer","after"],"sources":["../src/packages/react-components/react-virtualizer/src/components/Virtualizer/renderVirtualizer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { VirtualizerSlots, VirtualizerState } from './Virtualizer.types';\n\nexport const renderVirtualizer_unstable = (state: VirtualizerState) => {\n const { slots, slotProps } = getSlots<VirtualizerSlots>(state);\n\n return (\n <React.Fragment>\n {/* The 'before' bookend to hold items in place and detect scroll previous */}\n <slots.beforeContainer {...slotProps.beforeContainer}>\n <slots.before {...slotProps.before} />\n </slots.beforeContainer>\n {/* The reduced list of non-virtualized children to be rendered */}\n {state.virtualizedChildren}\n {/* The 'after' bookend to hold items in place and detect scroll next */}\n <slots.afterContainer {...slotProps.afterContainer}>\n <slots.after {...slotProps.after} />\n </slots.afterContainer>\n </React.Fragment>\n );\n};\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,QAAQ,QAAQ,2BAA2B;AAGpD,OAAO,MAAMC,0BAA0B,GAAIC,KAAuB,IAAI;EACpE,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGJ,QAAQ,CAAmBE,KAAK,CAAC;EAE9D,oBACEH,KAAA,CAAAM,aAAA,CAACN,KAAK,CAACO,QAAQ,qBAEbP,KAAA,CAAAM,aAAA,CAACF,KAAK,CAACI,eAAe;IAAA,GAAKH,SAAS,CAACG;EAAe,gBAClDR,KAAA,CAAAM,aAAA,CAACF,KAAK,CAACK,MAAM;IAAA,GAAKJ,SAAS,CAACI;EAAM,EAAI,CAChB,EAEvBN,KAAK,CAACO,mBAAmB,eAE1BV,KAAA,CAAAM,aAAA,CAACF,KAAK,CAACO,cAAc;IAAA,GAAKN,SAAS,CAACM;EAAc,gBAChDX,KAAA,CAAAM,aAAA,CAACF,KAAK,CAACQ,KAAK;IAAA,GAAKP,SAAS,CAACO;EAAK,EAAI,CACf,CACR;AAErB,CAAC"}
1
+ {"version":3,"names":["React","getSlots","renderVirtualizer_unstable","state","slots","slotProps","createElement","Fragment","beforeContainer","before","virtualizedChildren","afterContainer","after"],"sources":["../../../src/components/Virtualizer/renderVirtualizer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { VirtualizerSlots, VirtualizerState } from './Virtualizer.types';\n\nexport const renderVirtualizer_unstable = (state: VirtualizerState) => {\n const { slots, slotProps } = getSlots<VirtualizerSlots>(state);\n\n return (\n <React.Fragment>\n {/* The 'before' bookend to hold items in place and detect scroll previous */}\n <slots.beforeContainer {...slotProps.beforeContainer}>\n <slots.before {...slotProps.before} />\n </slots.beforeContainer>\n {/* The reduced list of non-virtualized children to be rendered */}\n {state.virtualizedChildren}\n {/* The 'after' bookend to hold items in place and detect scroll next */}\n <slots.afterContainer {...slotProps.afterContainer}>\n <slots.after {...slotProps.after} />\n </slots.afterContainer>\n </React.Fragment>\n );\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,QAAQ,QAAQ;AAGzB,OAAO,MAAMC,0BAAA,GAA8BC,KAAA,IAA4B;EACrE,MAAM;IAAEC,KAAA;IAAOC;EAAS,CAAE,GAAGJ,QAAA,CAA2BE,KAAA;EAExD,oBACEH,KAAA,CAAAM,aAAA,CAACN,KAAA,CAAMO,QAAQ,qBAEbP,KAAA,CAAAM,aAAA,CAACF,KAAA,CAAMI,eAAe,EAAKH,SAAA,CAAUG,eAAe,eAClDR,KAAA,CAAAM,aAAA,CAACF,KAAA,CAAMK,MAAM,EAAKJ,SAAA,CAAUI,MAAM,IAGnCN,KAAA,CAAMO,mBAAmB,eAE1BV,KAAA,CAAAM,aAAA,CAACF,KAAA,CAAMO,cAAc,EAAKN,SAAA,CAAUM,cAAc,eAChDX,KAAA,CAAAM,aAAA,CAACF,KAAA,CAAMQ,KAAK,EAAKP,SAAA,CAAUO,KAAK;AAIxC"}
@@ -11,7 +11,7 @@ export function useVirtualizer_unstable(props) {
11
11
  getItemSize,
12
12
  bufferItems = Math.round(virtualizerLength / 4.0),
13
13
  bufferSize = Math.floor(bufferItems / 2.0) * itemSize,
14
- intersectionObserverRoot,
14
+ scrollViewRef,
15
15
  axis = 'vertical',
16
16
  reversed = false,
17
17
  onUpdateIndex,
@@ -65,8 +65,7 @@ export function useVirtualizer_unstable(props) {
65
65
  const {
66
66
  setObserverList
67
67
  } = useIntersectionObserver((entries, observer) => {
68
- /* Sanity check - do we even need virtualization? */
69
- if (virtualizerLength > numItems) {
68
+ /* Sanity check - do we even need virtualization? */if (virtualizerLength > numItems) {
70
69
  if (virtualizerStartIndex !== 0) {
71
70
  batchUpdateNewIndex(0);
72
71
  }
@@ -146,7 +145,7 @@ export function useVirtualizer_unstable(props) {
146
145
  });
147
146
  }
148
147
  }, {
149
- root: intersectionObserverRoot ? intersectionObserverRoot === null || intersectionObserverRoot === void 0 ? void 0 : intersectionObserverRoot.current : null,
148
+ root: scrollViewRef ? scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current : null,
150
149
  rootMargin: '0px',
151
150
  threshold: 0
152
151
  });
@@ -173,8 +172,7 @@ export function useVirtualizer_unstable(props) {
173
172
  }
174
173
  };
175
174
  const getIndexFromSizeArray = scrollPos => {
176
- /* Quick searches our progressive height array */
177
- if (scrollPos === 0 || childProgressiveSizes.current.length === 0 || scrollPos <= childProgressiveSizes.current[0]) {
175
+ /* Quick searches our progressive height array */if (scrollPos === 0 || childProgressiveSizes.current.length === 0 || scrollPos <= childProgressiveSizes.current[0]) {
178
176
  // Check start
179
177
  return 0;
180
178
  }
@@ -221,10 +219,9 @@ export function useVirtualizer_unstable(props) {
221
219
  // Time for custom size calcs
222
220
  return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex];
223
221
  };
224
- const updateChildRows = newIndex => {
222
+ const updateChildRows = useCallback(newIndex => {
225
223
  if (numItems === 0) {
226
- /* Nothing to virtualize */
227
- return [];
224
+ /* Nothing to virtualize */return [];
228
225
  }
229
226
  if (childArray.current.length !== numItems) {
230
227
  childArray.current = new Array(virtualizerLength);
@@ -234,7 +231,7 @@ export function useVirtualizer_unstable(props) {
234
231
  for (let i = actualIndex; i < end; i++) {
235
232
  childArray.current[i - actualIndex] = renderChild(i);
236
233
  }
237
- };
234
+ }, [numItems, renderChild, virtualizerLength]);
238
235
  const setBeforeRef = useCallback(element => {
239
236
  if (!element || beforeElementRef.current === element) {
240
237
  return;
@@ -309,13 +306,18 @@ export function useVirtualizer_unstable(props) {
309
306
  forceUpdate();
310
307
  }
311
308
  // eslint-disable-next-line react-hooks/exhaustive-deps
312
- }, [renderChild]);
309
+ }, [renderChild, updateChildRows]);
313
310
  // Ensure we have run through and updated the whole size list array at least once.
314
311
  initializeSizeArray();
315
312
  if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {
316
313
  // Child length mismatch, repopulate size arrays.
317
314
  populateSizeArrays();
318
315
  }
316
+ // Ensure we recalc if virtualizer length changes
317
+ const maxCompare = Math.min(virtualizerLength, numItems);
318
+ if (childArray.current.length !== maxCompare && virtualizerStartIndex + childArray.current.length < numItems) {
319
+ updateChildRows(virtualizerStartIndex);
320
+ }
319
321
  const isFullyInitialized = hasInitialized.current && virtualizerStartIndex >= 0;
320
322
  return {
321
323
  components: {
@@ -1 +1 @@
1
- {"version":3,"names":["useIntersectionObserver","useEffect","useRef","useState","useCallback","useReducer","resolveShorthand","flushSync","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","intersectionObserverRoot","axis","reversed","onUpdateIndex","onCalculateIndex","virtualizerStartIndex","setVirtualizerStartIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","horizontal","populateSizeArrays","current","length","index","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","entries","observer","measurementPos","bufferCount","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","target","calculateAfter","calculateTotalSize","abs","boundingClientRect","bottom","top","right","left","calculateBefore","max","startIndex","getIndexFromScrollPosition","bufferedIndex","maxIndex","newStartIndex","min","root","rootMargin","threshold","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","lastItemIndex","remainingItems","newIndex","actualIndex","end","i","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","required","defaultProps","ref","role","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight"],"sources":["../src/packages/react-components/react-virtualizer/src/components/Virtualizer/useVirtualizer.ts"],"sourcesContent":["import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport type { ReactNode } from 'react';\nimport { useEffect, useRef, useState, useCallback, useReducer } from 'react';\n\nimport type { VirtualizerProps, VirtualizerState } from './Virtualizer.types';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n const {\n itemSize,\n numItems,\n virtualizerLength,\n children: renderChild,\n getItemSize,\n bufferItems = Math.round(virtualizerLength / 4.0),\n bufferSize = Math.floor(bufferItems / 2.0) * itemSize,\n intersectionObserverRoot,\n axis = 'vertical',\n reversed = false,\n onUpdateIndex,\n onCalculateIndex,\n } = props;\n\n // Tracks the initial item to start virtualizer at, -1 implies first render cycle\n const [virtualizerStartIndex, setVirtualizerStartIndex] = useState<number>(-1);\n\n // Store ref to before padding element\n const beforeElementRef = useRef<Element | null>(null);\n\n // Store ref to before padding element\n const afterElementRef = useRef<Element | null>(null);\n\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */\n const childProgressiveSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n // The internal tracking REF for child array (updates often).\n const childArray = useRef<ReactNode[]>(new Array(virtualizerLength));\n\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(() => ({}), {})[1];\n\n const horizontal = axis === 'horizontal';\n\n const populateSizeArrays = () => {\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array<number>(numItems);\n }\n\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array<number>(numItems);\n }\n\n for (let index = 0; index < numItems; index++) {\n childSizes.current[index] = getItemSize(index);\n\n if (index === 0) {\n childProgressiveSizes.current[index] = childSizes.current[index];\n } else {\n childProgressiveSizes.current[index] = childProgressiveSizes.current[index - 1] + childSizes.current[index];\n }\n }\n };\n\n const batchUpdateNewIndex = (index: number) => {\n // Local updates\n onUpdateIndex?.(index, virtualizerStartIndex);\n updateChildRows(index);\n updateCurrentItemSizes(index);\n\n // State setters\n setVirtualizerStartIndex(index);\n };\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (virtualizerStartIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n\n /* IO initiates this function when needed (bookend entering view) */\n let measurementPos = 0;\n let bufferCount = bufferItems;\n\n // Grab latest entry that is intersecting\n const latestEntry =\n entries.length === 1\n ? entries[0]\n : entries\n .sort((entry1, entry2) => entry2.time - entry1.time)\n .find(entry => {\n return entry.intersectionRatio > 0;\n });\n\n if (!latestEntry) {\n // If we don't find an intersecting area, ignore for now.\n return;\n }\n\n if (latestEntry.target === afterElementRef.current) {\n // We need to inverse the buffer count\n bufferCount = virtualizerLength - bufferItems;\n measurementPos = reversed ? calculateAfter() : calculateTotalSize() - calculateAfter();\n if (!horizontal) {\n if (reversed) {\n // Scrolling 'up' and hit the after element below\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' and hit the after element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (reversed) {\n // Scrolling 'left' and hit the after element\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'right' and hit the after element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n measurementPos = reversed ? calculateTotalSize() - calculateBefore() : calculateBefore();\n if (!horizontal) {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' in reverse order and hit the before element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'left' and hit before element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n }\n\n if (reversed) {\n // We're reversed, up is down, left is right, invert the scroll measure.\n measurementPos = Math.max(calculateTotalSize() - Math.abs(measurementPos), 0);\n }\n\n // For now lets use hardcoded size to assess current element to paginate on\n const startIndex = getIndexFromScrollPosition(measurementPos);\n let bufferedIndex = Math.max(startIndex - bufferCount, 0);\n\n if (onCalculateIndex) {\n // User has chance to intervene/customize prior to render\n // They may want to normalize this value.\n bufferedIndex = onCalculateIndex(bufferedIndex);\n }\n\n // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n\n if (virtualizerStartIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n // due to virtualizerStartIndex invalidation.\n flushSync(() => {\n batchUpdateNewIndex(newStartIndex);\n });\n }\n },\n {\n root: intersectionObserverRoot ? intersectionObserverRoot?.current : null,\n rootMargin: '0px',\n threshold: 0,\n },\n );\n\n const findIndexRecursive = (scrollPos: number, lowIndex: number, highIndex: number): number => {\n if (lowIndex > highIndex) {\n // We shouldn't get here - but no-op the index if we do.\n return virtualizerStartIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */\n return midpoint;\n }\n\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n\n const getIndexFromSizeArray = (scrollPos: number): number => {\n /* Quick searches our progressive height array */\n if (\n scrollPos === 0 ||\n childProgressiveSizes.current.length === 0 ||\n scrollPos <= childProgressiveSizes.current[0]\n ) {\n // Check start\n return 0;\n }\n\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n\n const getIndexFromScrollPosition = (scrollPos: number) => {\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n\n return getIndexFromSizeArray(scrollPos);\n };\n\n const calculateTotalSize = () => {\n if (!getItemSize) {\n return itemSize * numItems;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n };\n\n const calculateBefore = () => {\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return virtualizerStartIndex * itemSize;\n }\n\n if (virtualizerStartIndex <= 0) {\n return 0;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[virtualizerStartIndex - 1];\n };\n\n const calculateAfter = () => {\n if (numItems === 0) {\n return 0;\n }\n\n const lastItemIndex = Math.min(virtualizerStartIndex + virtualizerLength, numItems - 1);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex - 1;\n return remainingItems * itemSize;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex];\n };\n\n const updateChildRows = (newIndex: number) => {\n if (numItems === 0) {\n /* Nothing to virtualize */\n\n return [];\n }\n\n if (childArray.current.length !== numItems) {\n childArray.current = new Array(virtualizerLength);\n }\n const actualIndex = Math.max(newIndex, 0);\n const end = Math.min(actualIndex + virtualizerLength, numItems);\n\n for (let i = actualIndex; i < end; i++) {\n childArray.current[i - actualIndex] = renderChild(i);\n }\n };\n\n const setBeforeRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n\n newList.push(beforeElementRef.current);\n\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n\n // Ensure we update array if before element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const setAfterRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n\n newList.push(afterElementRef.current);\n\n // Ensure we update array if after element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const updateCurrentItemSizes = (newIndex: number) => {\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n\n let didUpdate = false;\n for (let i = startIndex; i < endIndex; i++) {\n const newSize = getItemSize(i);\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n\n if (didUpdate) {\n // Update our progressive size array\n for (let i = startIndex; i < numItems; i++) {\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n };\n\n // Initialize the size array before first render.\n const hasInitialized = useRef<boolean>(false);\n const initializeSizeArray = () => {\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(() => {\n if (virtualizerStartIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // If the user passes in an updated renderChild function - update current children\n useEffect(() => {\n if (virtualizerStartIndex >= 0) {\n updateChildRows(virtualizerStartIndex);\n forceUpdate();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild]);\n\n // Ensure we have run through and updated the whole size list array at least once.\n initializeSizeArray();\n\n if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {\n // Child length mismatch, repopulate size arrays.\n populateSizeArrays();\n }\n\n const isFullyInitialized = hasInitialized.current && virtualizerStartIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div',\n },\n virtualizedChildren: childArray.current,\n before: resolveShorthand(props.before, {\n required: true,\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n }),\n after: resolveShorthand(props.after, {\n required: true,\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n }),\n beforeContainer: resolveShorthand(props.beforeContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n afterContainer: resolveShorthand(props.afterContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex,\n axis,\n bufferSize,\n reversed,\n };\n}\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ,qCAAqC;AAE7E,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,UAAU,QAAQ,OAAO;AAG5E,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,SAAS,QAAQ,WAAW;AAErC,OAAM,SAAUC,uBAAuBA,CAACC,KAAuB;EAC7D,MAAM;IACJC,QAAQ;IACRC,QAAQ;IACRC,iBAAiB;IACjBC,QAAQ,EAAEC,WAAW;IACrBC,WAAW;IACXC,WAAW,GAAGC,IAAI,CAACC,KAAK,CAACN,iBAAiB,GAAG,GAAG,CAAC;IACjDO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ZC,eAAe,EAAE,KAAK;MACtBC,cAAc,EAAE;KACjB;IACDC,mBAAmB,EAAE7E,UAAU,CAACI,OAAO;IACvCqE,MAAM,EAAEpG,gBAAgB,CAACG,KAAK,CAACiG,MAAM,EAAE;MACrCK,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZC,GAAG,EAAEpB,YAAY;QACjBqB,IAAI,EAAE;;KAET,CAAC;IACFP,KAAK,EAAErG,gBAAgB,CAACG,KAAK,CAACkG,KAAK,EAAE;MACnCI,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZC,GAAG,EAAEhB,WAAW;QAChBiB,IAAI,EAAE;;KAET,CAAC;IACFN,eAAe,EAAEtG,gBAAgB,CAACG,KAAK,CAACmG,eAAe,EAAE;MACvDG,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZE,IAAI,EAAE;;KAET,CAAC;IACFL,cAAc,EAAEvG,gBAAgB,CAACG,KAAK,CAACoG,cAAc,EAAE;MACrDE,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZE,IAAI,EAAE;;KAET,CAAC;IACFC,kBAAkB,EAAEX,kBAAkB,GAAGvC,eAAe,EAAE,GAAG,CAAC;IAC9DmD,iBAAiB,EAAEZ,kBAAkB,GAAG/C,cAAc,EAAE,GAAG,CAAC;IAC5D4D,sBAAsB,EAAEb,kBAAkB,GAAG9C,kBAAkB,EAAE,GAAG9C,iBAAiB,GAAGF,QAAQ;IAChGgB,qBAAqB;IACrBJ,IAAI;IACJH,UAAU;IACVI;GACD;AACH"}
1
+ {"version":3,"names":["useIntersectionObserver","useEffect","useRef","useState","useCallback","useReducer","resolveShorthand","flushSync","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","scrollViewRef","axis","reversed","onUpdateIndex","onCalculateIndex","virtualizerStartIndex","setVirtualizerStartIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","horizontal","populateSizeArrays","current","length","index","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","entries","observer","measurementPos","bufferCount","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","target","calculateAfter","calculateTotalSize","abs","boundingClientRect","bottom","top","right","left","calculateBefore","max","startIndex","getIndexFromScrollPosition","bufferedIndex","maxIndex","newStartIndex","min","root","rootMargin","threshold","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","lastItemIndex","remainingItems","newIndex","actualIndex","end","i","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","required","defaultProps","ref","role","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight"],"sources":["../../../src/components/Virtualizer/useVirtualizer.ts"],"sourcesContent":["import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport type { ReactNode } from 'react';\nimport { useEffect, useRef, useState, useCallback, useReducer } from 'react';\n\nimport type { VirtualizerProps, VirtualizerState } from './Virtualizer.types';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n const {\n itemSize,\n numItems,\n virtualizerLength,\n children: renderChild,\n getItemSize,\n bufferItems = Math.round(virtualizerLength / 4.0),\n bufferSize = Math.floor(bufferItems / 2.0) * itemSize,\n scrollViewRef,\n axis = 'vertical',\n reversed = false,\n onUpdateIndex,\n onCalculateIndex,\n } = props;\n\n // Tracks the initial item to start virtualizer at, -1 implies first render cycle\n const [virtualizerStartIndex, setVirtualizerStartIndex] = useState<number>(-1);\n\n // Store ref to before padding element\n const beforeElementRef = useRef<Element | null>(null);\n\n // Store ref to before padding element\n const afterElementRef = useRef<Element | null>(null);\n\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */\n const childProgressiveSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n // The internal tracking REF for child array (updates often).\n const childArray = useRef<ReactNode[]>(new Array(virtualizerLength));\n\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(() => ({}), {})[1];\n\n const horizontal = axis === 'horizontal';\n\n const populateSizeArrays = () => {\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array<number>(numItems);\n }\n\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array<number>(numItems);\n }\n\n for (let index = 0; index < numItems; index++) {\n childSizes.current[index] = getItemSize(index);\n\n if (index === 0) {\n childProgressiveSizes.current[index] = childSizes.current[index];\n } else {\n childProgressiveSizes.current[index] = childProgressiveSizes.current[index - 1] + childSizes.current[index];\n }\n }\n };\n\n const batchUpdateNewIndex = (index: number) => {\n // Local updates\n onUpdateIndex?.(index, virtualizerStartIndex);\n updateChildRows(index);\n updateCurrentItemSizes(index);\n\n // State setters\n setVirtualizerStartIndex(index);\n };\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (virtualizerStartIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n\n /* IO initiates this function when needed (bookend entering view) */\n let measurementPos = 0;\n let bufferCount = bufferItems;\n\n // Grab latest entry that is intersecting\n const latestEntry =\n entries.length === 1\n ? entries[0]\n : entries\n .sort((entry1, entry2) => entry2.time - entry1.time)\n .find(entry => {\n return entry.intersectionRatio > 0;\n });\n\n if (!latestEntry) {\n // If we don't find an intersecting area, ignore for now.\n return;\n }\n\n if (latestEntry.target === afterElementRef.current) {\n // We need to inverse the buffer count\n bufferCount = virtualizerLength - bufferItems;\n measurementPos = reversed ? calculateAfter() : calculateTotalSize() - calculateAfter();\n if (!horizontal) {\n if (reversed) {\n // Scrolling 'up' and hit the after element below\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' and hit the after element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (reversed) {\n // Scrolling 'left' and hit the after element\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'right' and hit the after element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n measurementPos = reversed ? calculateTotalSize() - calculateBefore() : calculateBefore();\n if (!horizontal) {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' in reverse order and hit the before element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'left' and hit before element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n }\n\n if (reversed) {\n // We're reversed, up is down, left is right, invert the scroll measure.\n measurementPos = Math.max(calculateTotalSize() - Math.abs(measurementPos), 0);\n }\n\n // For now lets use hardcoded size to assess current element to paginate on\n const startIndex = getIndexFromScrollPosition(measurementPos);\n let bufferedIndex = Math.max(startIndex - bufferCount, 0);\n\n if (onCalculateIndex) {\n // User has chance to intervene/customize prior to render\n // They may want to normalize this value.\n bufferedIndex = onCalculateIndex(bufferedIndex);\n }\n\n // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n\n if (virtualizerStartIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n // due to virtualizerStartIndex invalidation.\n flushSync(() => {\n batchUpdateNewIndex(newStartIndex);\n });\n }\n },\n {\n root: scrollViewRef ? scrollViewRef?.current : null,\n rootMargin: '0px',\n threshold: 0,\n },\n );\n\n const findIndexRecursive = (scrollPos: number, lowIndex: number, highIndex: number): number => {\n if (lowIndex > highIndex) {\n // We shouldn't get here - but no-op the index if we do.\n return virtualizerStartIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */\n return midpoint;\n }\n\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n\n const getIndexFromSizeArray = (scrollPos: number): number => {\n /* Quick searches our progressive height array */\n if (\n scrollPos === 0 ||\n childProgressiveSizes.current.length === 0 ||\n scrollPos <= childProgressiveSizes.current[0]\n ) {\n // Check start\n return 0;\n }\n\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n\n const getIndexFromScrollPosition = (scrollPos: number) => {\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n\n return getIndexFromSizeArray(scrollPos);\n };\n\n const calculateTotalSize = () => {\n if (!getItemSize) {\n return itemSize * numItems;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n };\n\n const calculateBefore = () => {\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return virtualizerStartIndex * itemSize;\n }\n\n if (virtualizerStartIndex <= 0) {\n return 0;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[virtualizerStartIndex - 1];\n };\n\n const calculateAfter = () => {\n if (numItems === 0) {\n return 0;\n }\n\n const lastItemIndex = Math.min(virtualizerStartIndex + virtualizerLength, numItems - 1);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex - 1;\n return remainingItems * itemSize;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex];\n };\n\n const updateChildRows = useCallback(\n (newIndex: number) => {\n if (numItems === 0) {\n /* Nothing to virtualize */\n\n return [];\n }\n\n if (childArray.current.length !== numItems) {\n childArray.current = new Array(virtualizerLength);\n }\n const actualIndex = Math.max(newIndex, 0);\n const end = Math.min(actualIndex + virtualizerLength, numItems);\n\n for (let i = actualIndex; i < end; i++) {\n childArray.current[i - actualIndex] = renderChild(i);\n }\n },\n [numItems, renderChild, virtualizerLength],\n );\n\n const setBeforeRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n\n newList.push(beforeElementRef.current);\n\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n\n // Ensure we update array if before element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const setAfterRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n\n newList.push(afterElementRef.current);\n\n // Ensure we update array if after element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const updateCurrentItemSizes = (newIndex: number) => {\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n\n let didUpdate = false;\n for (let i = startIndex; i < endIndex; i++) {\n const newSize = getItemSize(i);\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n\n if (didUpdate) {\n // Update our progressive size array\n for (let i = startIndex; i < numItems; i++) {\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n };\n\n // Initialize the size array before first render.\n const hasInitialized = useRef<boolean>(false);\n const initializeSizeArray = () => {\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(() => {\n if (virtualizerStartIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // If the user passes in an updated renderChild function - update current children\n useEffect(() => {\n if (virtualizerStartIndex >= 0) {\n updateChildRows(virtualizerStartIndex);\n forceUpdate();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild, updateChildRows]);\n\n // Ensure we have run through and updated the whole size list array at least once.\n initializeSizeArray();\n\n if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {\n // Child length mismatch, repopulate size arrays.\n populateSizeArrays();\n }\n\n // Ensure we recalc if virtualizer length changes\n const maxCompare = Math.min(virtualizerLength, numItems);\n if (childArray.current.length !== maxCompare && virtualizerStartIndex + childArray.current.length < numItems) {\n updateChildRows(virtualizerStartIndex);\n }\n\n const isFullyInitialized = hasInitialized.current && virtualizerStartIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div',\n },\n virtualizedChildren: childArray.current,\n before: resolveShorthand(props.before, {\n required: true,\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n }),\n after: resolveShorthand(props.after, {\n required: true,\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n }),\n beforeContainer: resolveShorthand(props.beforeContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n afterContainer: resolveShorthand(props.afterContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex,\n axis,\n bufferSize,\n reversed,\n };\n}\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ;AAExC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,UAAU,QAAQ;AAGrE,SAASC,gBAAgB,QAAQ;AACjC,SAASC,SAAS,QAAQ;AAE1B,OAAO,SAASC,wBAAwBC,KAAuB,EAAoB;EACjF,MAAM;IACJC,QAAA;IACAC,QAAA;IACAC,iBAAA;IACAC,QAAA,EAAUC,WAAA;IACVC,WAAA;IACAC,WAAA,GAAcC,IAAA,CAAKC,KAAK,CAACN,iBAAA,GAAoB;IAC7CO,UAAA,GAAaF,IAAA,CAAKG,KAAK,CAACJ,WAAA,GAAc,OAAON,QAAA;IAC7CW,aAAA;IACAC,IAAA,GAAO;IACPC,QAAA,GAAW,KAAK;IAChBC,aAAA;IACAC;EAAgB,CACjB,GAAGhB,KAAA;EAEJ;EACA,MAAM,CAACiB,qBAAA,EAAuBC,wBAAA,CAAyB,GAAGxB,QAAA,CAAiB,CAAC;EAE5E;EACA,MAAMyB,gBAAA,GAAmB1B,MAAA,CAAuB,IAAI;EAEpD;EACA,MAAM2B,eAAA,GAAkB3B,MAAA,CAAuB,IAAI;EAEnD;EACA,MAAM4B,UAAA,GAAa5B,MAAA,CAAiB,IAAI6B,KAAA,CAAchB,WAAA,GAAcJ,QA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