@fluentui/react-virtualizer 9.0.0-alpha.84 → 9.0.0-alpha.86

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 (53) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/dist/index.d.ts +78 -5
  3. package/lib/components/Virtualizer/Virtualizer.types.js.map +1 -1
  4. package/lib/components/Virtualizer/useVirtualizer.js +208 -143
  5. package/lib/components/Virtualizer/useVirtualizer.js.map +1 -1
  6. package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js +3 -3
  7. package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -1
  8. package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -1
  9. package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +11 -9
  10. package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -1
  11. package/lib/hooks/hooks.types.js.map +1 -1
  12. package/lib/hooks/index.js +1 -0
  13. package/lib/hooks/index.js.map +1 -1
  14. package/lib/hooks/useDynamicVirtualizerMeasure.js +63 -45
  15. package/lib/hooks/useDynamicVirtualizerMeasure.js.map +1 -1
  16. package/lib/hooks/useMeasureList.js +14 -2
  17. package/lib/hooks/useMeasureList.js.map +1 -1
  18. package/lib/hooks/useResizeObserverRef.js +11 -1
  19. package/lib/hooks/useResizeObserverRef.js.map +1 -1
  20. package/lib/hooks/useVirtualizerMeasure.js +31 -15
  21. package/lib/hooks/useVirtualizerMeasure.js.map +1 -1
  22. package/lib/index.js +1 -1
  23. package/lib/index.js.map +1 -1
  24. package/lib/utilities/VirtualizerContext/VirtualizerContext.js +12 -14
  25. package/lib/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -1
  26. package/lib/utilities/VirtualizerContext/types.js +1 -3
  27. package/lib/utilities/VirtualizerContext/types.js.map +1 -1
  28. package/lib-commonjs/components/Virtualizer/Virtualizer.types.js.map +1 -1
  29. package/lib-commonjs/components/Virtualizer/useVirtualizer.js +206 -141
  30. package/lib-commonjs/components/Virtualizer/useVirtualizer.js.map +1 -1
  31. package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js +3 -3
  32. package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -1
  33. package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -1
  34. package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +11 -9
  35. package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -1
  36. package/lib-commonjs/hooks/hooks.types.js.map +1 -1
  37. package/lib-commonjs/hooks/index.js +1 -0
  38. package/lib-commonjs/hooks/index.js.map +1 -1
  39. package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js +62 -44
  40. package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js.map +1 -1
  41. package/lib-commonjs/hooks/useMeasureList.js +14 -2
  42. package/lib-commonjs/hooks/useMeasureList.js.map +1 -1
  43. package/lib-commonjs/hooks/useResizeObserverRef.js +11 -1
  44. package/lib-commonjs/hooks/useResizeObserverRef.js.map +1 -1
  45. package/lib-commonjs/hooks/useVirtualizerMeasure.js +31 -15
  46. package/lib-commonjs/hooks/useVirtualizerMeasure.js.map +1 -1
  47. package/lib-commonjs/index.js +3 -0
  48. package/lib-commonjs/index.js.map +1 -1
  49. package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js +11 -13
  50. package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -1
  51. package/lib-commonjs/utilities/VirtualizerContext/types.js +3 -3
  52. package/lib-commonjs/utilities/VirtualizerContext/types.js.map +1 -1
  53. package/package.json +4 -4
@@ -1,20 +1,26 @@
1
- import { useEffect, useRef, useCallback, useReducer, useImperativeHandle, useState } from 'react';
1
+ import { useEffect, useRef, useCallback, useImperativeHandle, useState, useReducer } from 'react';
2
2
  import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
3
- import { flushSync } from 'react-dom';
4
3
  import { useVirtualizerContextState_unstable } from '../../Utilities';
5
4
  import { slot, useTimeout } from '@fluentui/react-utilities';
5
+ import { flushSync } from 'react-dom';
6
6
  export function useVirtualizer_unstable(props) {
7
7
  'use no memo';
8
- const { itemSize, numItems, virtualizerLength, children: renderChild, getItemSize, bufferItems = Math.round(virtualizerLength / 4.0), bufferSize = Math.floor(bufferItems / 2.0) * itemSize, scrollViewRef, axis = 'vertical', reversed = false, virtualizerContext, onRenderedFlaggedIndex, imperativeVirtualizerRef } = props;
8
+ const { itemSize, numItems, virtualizerLength, children: renderChild, getItemSize, bufferItems = Math.round(virtualizerLength / 4.0), bufferSize = Math.floor(bufferItems / 2.0) * itemSize, axis = 'vertical', reversed = false, virtualizerContext, onRenderedFlaggedIndex, imperativeVirtualizerRef, containerSizeRef, scrollViewRef, enableScrollLoad } = props;
9
9
  /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/ const _virtualizerContext = useVirtualizerContextState_unstable(virtualizerContext);
10
10
  // We use this ref as a constant source to access the virtualizer's state imperatively
11
11
  const actualIndexRef = useRef(_virtualizerContext.contextIndex);
12
- if (actualIndexRef.current !== _virtualizerContext.contextIndex) {
13
- actualIndexRef.current = _virtualizerContext.contextIndex;
14
- }
15
12
  const flaggedIndex = useRef(null);
16
13
  const actualIndex = _virtualizerContext.contextIndex;
17
- const setActualIndex = _virtualizerContext.setContextIndex;
14
+ // Just in case our ref gets out of date vs the context during a re-render
15
+ if (_virtualizerContext.contextIndex !== actualIndexRef.current) {
16
+ actualIndexRef.current = _virtualizerContext.contextIndex;
17
+ }
18
+ const setActualIndex = useCallback((index)=>{
19
+ actualIndexRef.current = index;
20
+ _virtualizerContext.setContextIndex(index);
21
+ }, [
22
+ _virtualizerContext
23
+ ]);
18
24
  // Store ref to before padding element
19
25
  const beforeElementRef = useRef(null);
20
26
  // Store ref to before padding element
@@ -23,11 +29,11 @@ export function useVirtualizer_unstable(props) {
23
29
  const childSizes = useRef(new Array(getItemSize ? numItems : 0));
24
30
  /* We keep track of the progressive sizing/placement down the list,
25
31
  this helps us skip re-calculations unless children/size changes */ const childProgressiveSizes = useRef(new Array(getItemSize ? numItems : 0));
32
+ if (virtualizerContext === null || virtualizerContext === void 0 ? void 0 : virtualizerContext.childProgressiveSizes) {
33
+ virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;
34
+ }
26
35
  // The internal tracking REF for child array (updates often).
27
36
  const childArray = useRef(new Array(virtualizerLength));
28
- // We want to be methodical about updating the render with child reference array
29
- const forceUpdate = useReducer(()=>({}), {})[1];
30
- const horizontal = axis === 'horizontal';
31
37
  const populateSizeArrays = ()=>{
32
38
  if (!getItemSize) {
33
39
  // Static sizes, never mind!
@@ -38,6 +44,9 @@ export function useVirtualizer_unstable(props) {
38
44
  }
39
45
  if (numItems !== childProgressiveSizes.current.length) {
40
46
  childProgressiveSizes.current = new Array(numItems);
47
+ if (virtualizerContext === null || virtualizerContext === void 0 ? void 0 : virtualizerContext.childProgressiveSizes) {
48
+ virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;
49
+ }
41
50
  }
42
51
  for(let index = 0; index < numItems; index++){
43
52
  childSizes.current[index] = getItemSize(index);
@@ -52,6 +61,10 @@ export function useVirtualizer_unstable(props) {
52
61
  const [setScrollTimer, clearScrollTimer] = useTimeout();
53
62
  const scrollCounter = useRef(0);
54
63
  const initializeScrollingTimer = useCallback(()=>{
64
+ if (!enableScrollLoad) {
65
+ // Disabled by default for reduction of render callbacks
66
+ return;
67
+ }
55
68
  /*
56
69
  * This can be considered the 'velocity' required to start 'isScrolling'
57
70
  * INIT_SCROLL_FLAG_REQ: Number of renders required to activate isScrolling
@@ -70,7 +83,8 @@ export function useVirtualizer_unstable(props) {
70
83
  }, INIT_SCROLL_FLAG_DELAY);
71
84
  }, [
72
85
  clearScrollTimer,
73
- setScrollTimer
86
+ setScrollTimer,
87
+ enableScrollLoad
74
88
  ]);
75
89
  useEffect(()=>{
76
90
  initializeScrollingTimer();
@@ -78,98 +92,66 @@ export function useVirtualizer_unstable(props) {
78
92
  actualIndex,
79
93
  initializeScrollingTimer
80
94
  ]);
81
- const batchUpdateNewIndex = (index)=>{
82
- // Local updates
83
- updateChildRows(index);
84
- updateCurrentItemSizes(index);
85
- // Set before 'setActualIndex' call
86
- // If it changes before render, or injected via context, re-render will update ref.
87
- actualIndexRef.current = index;
88
- // State setters
89
- setActualIndex(index);
90
- };
91
- // Observe intersections of virtualized components
92
- const { setObserverList } = useIntersectionObserver(// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
93
- // eslint-disable-next-line no-restricted-globals
94
- (entries, observer)=>{
95
- /* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {
96
- if (actualIndex !== 0) {
97
- batchUpdateNewIndex(0);
98
- }
99
- // No-op
100
- return;
95
+ const updateChildRows = useCallback((newIndex)=>{
96
+ if (numItems === 0) {
97
+ /* Nothing to virtualize */ return;
101
98
  }
102
- /* IO initiates this function when needed (bookend entering view) */ let measurementPos = 0;
103
- let bufferCount = bufferItems;
104
- // Grab latest entry that is intersecting
105
- const latestEntry = entries.length === 1 ? entries[0] : entries.sort((entry1, entry2)=>entry2.time - entry1.time).find((entry)=>{
106
- return entry.intersectionRatio > 0;
107
- });
108
- if (!latestEntry) {
109
- // If we don't find an intersecting area, ignore for now.
99
+ /*
100
+ We reset the array every time to ensure children are re-rendered
101
+ This function should only be called when update is nessecary
102
+ */ childArray.current = new Array(virtualizerLength);
103
+ const _actualIndex = Math.max(newIndex, 0);
104
+ const end = Math.min(_actualIndex + virtualizerLength, numItems);
105
+ for(let i = _actualIndex; i < end; i++){
106
+ childArray.current[i - _actualIndex] = renderChild(i, isScrolling);
107
+ }
108
+ }, [
109
+ isScrolling,
110
+ numItems,
111
+ renderChild,
112
+ virtualizerLength
113
+ ]);
114
+ const updateCurrentItemSizes = useCallback((newIndex)=>{
115
+ if (!getItemSize) {
116
+ // Static sizes, not required.
110
117
  return;
111
118
  }
112
- if (latestEntry.target === afterElementRef.current) {
113
- // We need to inverse the buffer count
114
- bufferCount = virtualizerLength - bufferItems;
115
- measurementPos = reversed ? calculateAfter() : calculateTotalSize() - calculateAfter();
116
- if (!horizontal) {
117
- if (reversed) {
118
- // Scrolling 'up' and hit the after element below
119
- measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);
120
- } else if (latestEntry.boundingClientRect.top < 0) {
121
- // Scrolling 'down' and hit the after element above top: 0
122
- measurementPos -= latestEntry.boundingClientRect.top;
123
- }
124
- } else {
125
- if (reversed) {
126
- // Scrolling 'left' and hit the after element
127
- measurementPos -= Math.abs(latestEntry.boundingClientRect.right);
128
- } else if (latestEntry.boundingClientRect.left < 0) {
129
- // Scrolling 'right' and hit the after element
130
- measurementPos -= latestEntry.boundingClientRect.left;
131
- }
132
- }
133
- } else if (latestEntry.target === beforeElementRef.current) {
134
- measurementPos = reversed ? calculateTotalSize() - calculateBefore() : calculateBefore();
135
- if (!horizontal) {
136
- if (!reversed) {
137
- measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);
138
- } else if (latestEntry.boundingClientRect.top < 0) {
139
- // Scrolling 'down' in reverse order and hit the before element above top: 0
140
- measurementPos -= latestEntry.boundingClientRect.top;
141
- }
142
- } else {
143
- if (!reversed) {
144
- measurementPos -= Math.abs(latestEntry.boundingClientRect.right);
145
- } else if (latestEntry.boundingClientRect.left < 0) {
146
- // Scrolling 'left' and hit before element
147
- measurementPos -= latestEntry.boundingClientRect.left;
148
- }
119
+ // We should always call our size function on index change (only for the items that will be rendered)
120
+ // This ensures we request the latest data for incoming items in case sizing has changed.
121
+ const endIndex = Math.min(newIndex + virtualizerLength, numItems);
122
+ const startIndex = Math.max(newIndex, 0);
123
+ let didUpdate = false;
124
+ for(let i = startIndex; i < endIndex; i++){
125
+ const newSize = getItemSize(i);
126
+ if (newSize !== childSizes.current[i]) {
127
+ childSizes.current[i] = newSize;
128
+ didUpdate = true;
149
129
  }
150
130
  }
151
- if (reversed) {
152
- // We're reversed, up is down, left is right, invert the scroll measure.
153
- measurementPos = Math.max(calculateTotalSize() - Math.abs(measurementPos), 0);
154
- }
155
- // For now lets use hardcoded size to assess current element to paginate on
156
- const startIndex = getIndexFromScrollPosition(measurementPos);
157
- const bufferedIndex = Math.max(startIndex - bufferCount, 0);
158
- // Safety limits
159
- const maxIndex = Math.max(numItems - virtualizerLength, 0);
160
- const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);
161
- if (actualIndex !== newStartIndex) {
162
- // We flush sync this and perform an immediate state update
163
- flushSync(()=>{
164
- batchUpdateNewIndex(newStartIndex);
165
- });
131
+ if (didUpdate) {
132
+ // Update our progressive size array
133
+ for(let i = startIndex; i < numItems; i++){
134
+ const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;
135
+ childProgressiveSizes.current[i] = prevSize + childSizes.current[i];
136
+ }
166
137
  }
167
- }, {
168
- root: scrollViewRef ? scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current : null,
169
- rootMargin: '0px',
170
- threshold: 0
171
- });
172
- const findIndexRecursive = (scrollPos, lowIndex, highIndex)=>{
138
+ }, [
139
+ getItemSize,
140
+ numItems,
141
+ virtualizerLength
142
+ ]);
143
+ const batchUpdateNewIndex = useCallback((index)=>{
144
+ // Local updates
145
+ updateChildRows(index);
146
+ updateCurrentItemSizes(index);
147
+ // State setters
148
+ setActualIndex(index);
149
+ }, [
150
+ setActualIndex,
151
+ updateChildRows,
152
+ updateCurrentItemSizes
153
+ ]);
154
+ const findIndexRecursive = useCallback((scrollPos, lowIndex, highIndex)=>{
173
155
  if (lowIndex > highIndex) {
174
156
  // We shouldn't get here - but no-op the index if we do.
175
157
  return actualIndex;
@@ -189,8 +171,10 @@ export function useVirtualizer_unstable(props) {
189
171
  } else {
190
172
  return findIndexRecursive(scrollPos, midpoint + 1, highIndex);
191
173
  }
192
- };
193
- const getIndexFromSizeArray = (scrollPos)=>{
174
+ }, [
175
+ actualIndex
176
+ ]);
177
+ const getIndexFromSizeArray = useCallback((scrollPos)=>{
194
178
  /* Quick searches our progressive height array */ if (scrollPos === 0 || childProgressiveSizes.current.length === 0 || scrollPos <= childProgressiveSizes.current[0]) {
195
179
  // Check start
196
180
  return 0;
@@ -200,13 +184,19 @@ export function useVirtualizer_unstable(props) {
200
184
  return childProgressiveSizes.current.length - 1;
201
185
  }
202
186
  return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);
203
- };
204
- const getIndexFromScrollPosition = (scrollPos)=>{
187
+ }, [
188
+ findIndexRecursive
189
+ ]);
190
+ const getIndexFromScrollPosition = useCallback((scrollPos)=>{
205
191
  if (!getItemSize) {
206
192
  return Math.round(scrollPos / itemSize);
207
193
  }
208
194
  return getIndexFromSizeArray(scrollPos);
209
- };
195
+ }, [
196
+ getIndexFromSizeArray,
197
+ getItemSize,
198
+ itemSize
199
+ ]);
210
200
  const calculateTotalSize = useCallback(()=>{
211
201
  if (!getItemSize) {
212
202
  return itemSize * numItems;
@@ -254,25 +244,118 @@ export function useVirtualizer_unstable(props) {
254
244
  numItems,
255
245
  virtualizerLength
256
246
  ]);
257
- const updateChildRows = useCallback((newIndex)=>{
258
- if (numItems === 0) {
259
- /* Nothing to virtualize */ return;
247
+ // Observe intersections of virtualized components
248
+ const { setObserverList } = useIntersectionObserver(useCallback(// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
249
+ // eslint-disable-next-line no-restricted-globals
250
+ (entries, observer)=>{
251
+ /* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {
252
+ if (actualIndex !== 0) {
253
+ batchUpdateNewIndex(0);
254
+ }
255
+ // No-op
256
+ return;
260
257
  }
261
- /*
262
- We reset the array every time to ensure children are re-rendered
263
- This function should only be called when update is nessecary
264
- */ childArray.current = new Array(virtualizerLength);
265
- const _actualIndex = Math.max(newIndex, 0);
266
- const end = Math.min(_actualIndex + virtualizerLength, numItems);
267
- for(let i = _actualIndex; i < end; i++){
268
- childArray.current[i - _actualIndex] = renderChild(i, isScrolling);
258
+ // Grab latest entry that is intersecting
259
+ const latestEntry = entries.length === 1 ? entries[0] : entries.sort((entry1, entry2)=>entry2.time - entry1.time).find((entry)=>{
260
+ return entry.intersectionRatio > 0;
261
+ });
262
+ if (!latestEntry || !latestEntry.isIntersecting) {
263
+ // If we don't find an intersecting area, ignore for now.
264
+ return;
269
265
  }
266
+ // We have to be sure our item sizes are up to date with current indexed ref before calculation
267
+ // Check if we still need
268
+ updateCurrentItemSizes(actualIndexRef.current);
269
+ const calculateOverBuffer = ()=>{
270
+ /**
271
+ * We avoid using the scroll ref scrollTop, it may be incorrect
272
+ * as virtualization may exist within a scroll view with other elements
273
+ * The benefit of using IO is that we can detect relative scrolls,
274
+ * so any items can be placed around the virtualizer in the scroll view
275
+ */ let measurementPos = 0;
276
+ if (latestEntry.target === afterElementRef.current) {
277
+ // Get after buffers position
278
+ measurementPos = calculateTotalSize() - calculateAfter();
279
+ // Get exact intersection position based on overflow size (how far into IO did we scroll?)
280
+ const overflowAmount = axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;
281
+ // Add to original after position
282
+ measurementPos += overflowAmount;
283
+ // Ignore buffer size (IO offset)
284
+ measurementPos -= bufferSize;
285
+ var _containerSizeRef_current;
286
+ // we hit the after buffer and detected the end of view, we need to find the start index.
287
+ measurementPos -= (_containerSizeRef_current = containerSizeRef.current) !== null && _containerSizeRef_current !== void 0 ? _containerSizeRef_current : 0;
288
+ // Calculate how far past the window bounds we are (this will be zero if IO is within window)
289
+ const hOverflow = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;
290
+ const hOverflowReversed = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;
291
+ const wOverflow = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;
292
+ const wOverflowReversed = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;
293
+ const widthOverflow = reversed ? wOverflowReversed : wOverflow;
294
+ const heightOverflow = reversed ? hOverflowReversed : hOverflow;
295
+ const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;
296
+ if (reversed) {
297
+ measurementPos += additionalOverflow;
298
+ } else {
299
+ measurementPos -= additionalOverflow;
300
+ }
301
+ } else if (latestEntry.target === beforeElementRef.current) {
302
+ // Get before buffers position
303
+ measurementPos = calculateBefore();
304
+ // Get exact intersection position based on overflow size (how far into window did we scroll IO?)
305
+ const overflowAmount = axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;
306
+ // Minus from original before position
307
+ measurementPos -= overflowAmount;
308
+ // Ignore buffer size (IO offset)
309
+ measurementPos += bufferSize;
310
+ // Calculate how far past the window bounds we are (this will be zero if IO is within window)
311
+ const hOverflow = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;
312
+ const hOverflowReversed = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;
313
+ const wOverflow = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;
314
+ const wOverflowReversed = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;
315
+ const widthOverflow = reversed ? wOverflowReversed : wOverflow;
316
+ const heightOverflow = reversed ? hOverflowReversed : hOverflow;
317
+ const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;
318
+ if (reversed) {
319
+ measurementPos += additionalOverflow;
320
+ } else {
321
+ measurementPos -= additionalOverflow;
322
+ }
323
+ }
324
+ return measurementPos;
325
+ };
326
+ // Get exact relative 'scrollTop' via IO values
327
+ const measurementPos = calculateOverBuffer();
328
+ const maxIndex = Math.max(numItems - virtualizerLength, 0);
329
+ const startIndex = getIndexFromScrollPosition(measurementPos) - bufferItems;
330
+ // Safety limits
331
+ const newStartIndex = Math.min(Math.max(startIndex, 0), maxIndex);
332
+ flushSync(()=>{
333
+ _virtualizerContext.setContextPosition(measurementPos);
334
+ if (actualIndex !== newStartIndex) {
335
+ batchUpdateNewIndex(newStartIndex);
336
+ }
337
+ });
270
338
  }, [
271
- isScrolling,
339
+ _virtualizerContext,
340
+ actualIndex,
341
+ axis,
342
+ batchUpdateNewIndex,
343
+ bufferItems,
344
+ bufferSize,
345
+ calculateAfter,
346
+ calculateBefore,
347
+ calculateTotalSize,
348
+ containerSizeRef,
349
+ getIndexFromScrollPosition,
272
350
  numItems,
273
- renderChild,
351
+ reversed,
352
+ updateCurrentItemSizes,
274
353
  virtualizerLength
275
- ]);
354
+ ]), {
355
+ root: scrollViewRef ? scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current : null,
356
+ rootMargin: '0px',
357
+ threshold: 0
358
+ });
276
359
  const setBeforeRef = useCallback((element)=>{
277
360
  if (!element || beforeElementRef.current === element) {
278
361
  return;
@@ -303,31 +386,6 @@ export function useVirtualizer_unstable(props) {
303
386
  }, [
304
387
  setObserverList
305
388
  ]);
306
- const updateCurrentItemSizes = (newIndex)=>{
307
- if (!getItemSize) {
308
- // Static sizes, not required.
309
- return;
310
- }
311
- // We should always call our size function on index change (only for the items that will be rendered)
312
- // This ensures we request the latest data for incoming items in case sizing has changed.
313
- const endIndex = Math.min(newIndex + virtualizerLength, numItems);
314
- const startIndex = Math.max(newIndex, 0);
315
- let didUpdate = false;
316
- for(let i = startIndex; i < endIndex; i++){
317
- const newSize = getItemSize(i);
318
- if (newSize !== childSizes.current[i]) {
319
- childSizes.current[i] = newSize;
320
- didUpdate = true;
321
- }
322
- }
323
- if (didUpdate) {
324
- // Update our progressive size array
325
- for(let i = startIndex; i < numItems; i++){
326
- const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;
327
- childProgressiveSizes.current[i] = prevSize + childSizes.current[i];
328
- }
329
- }
330
- };
331
389
  // Initialize the size array before first render.
332
390
  const hasInitialized = useRef(false);
333
391
  const initializeSizeArray = ()=>{
@@ -355,16 +413,23 @@ export function useVirtualizer_unstable(props) {
355
413
  }
356
414
  // eslint-disable-next-line react-hooks/exhaustive-deps
357
415
  }, []);
416
+ /*
417
+ * forceUpdate:
418
+ * We only want to trigger this when scrollLoading is enabled and set to false,
419
+ * it will force re-render all children elements
420
+ */ const forceUpdate = useReducer(()=>({}), {})[1];
358
421
  // If the user passes in an updated renderChild function - update current children
359
422
  useEffect(()=>{
360
423
  if (actualIndex >= 0) {
361
424
  updateChildRows(actualIndex);
362
- forceUpdate();
425
+ if (enableScrollLoad && !isScrolling) {
426
+ forceUpdate();
427
+ }
363
428
  }
364
429
  // eslint-disable-next-line react-hooks/exhaustive-deps
365
430
  }, [
366
431
  renderChild,
367
- updateChildRows
432
+ isScrolling
368
433
  ]);
369
434
  useEffect(()=>{
370
435
  // Ensure we repopulate if getItemSize callback changes
@@ -1 +1 @@
1
- {"version":3,"sources":["useVirtualizer.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { VirtualizerProps, VirtualizerState } from './Virtualizer.types';\n\nimport { useEffect, useRef, useCallback, useReducer, useImperativeHandle, useState } from 'react';\nimport { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { flushSync } from 'react-dom';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { slot, useTimeout } from '@fluentui/react-utilities';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n 'use no memo';\n\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 virtualizerContext,\n onRenderedFlaggedIndex,\n imperativeVirtualizerRef,\n } = props;\n\n /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/\n const _virtualizerContext = useVirtualizerContextState_unstable(virtualizerContext);\n\n // We use this ref as a constant source to access the virtualizer's state imperatively\n const actualIndexRef = useRef<number>(_virtualizerContext.contextIndex);\n if (actualIndexRef.current !== _virtualizerContext.contextIndex) {\n actualIndexRef.current = _virtualizerContext.contextIndex;\n }\n const flaggedIndex = useRef<number | null>(null);\n\n const actualIndex = _virtualizerContext.contextIndex;\n const setActualIndex = _virtualizerContext.setContextIndex;\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 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 [isScrolling, setIsScrolling] = useState<boolean>(false);\n const [setScrollTimer, clearScrollTimer] = useTimeout();\n const scrollCounter = useRef<number>(0);\n\n const initializeScrollingTimer = useCallback(() => {\n /*\n * This can be considered the 'velocity' required to start 'isScrolling'\n * INIT_SCROLL_FLAG_REQ: Number of renders required to activate isScrolling\n * INIT_SCROLL_FLAG_DELAY: Amount of time (ms) before current number of renders is reset\n * - Maybe we should let users customize these in the future.\n */\n const INIT_SCROLL_FLAG_REQ = 10;\n const INIT_SCROLL_FLAG_DELAY = 100;\n\n scrollCounter.current++;\n if (scrollCounter.current >= INIT_SCROLL_FLAG_REQ) {\n setIsScrolling(true);\n }\n clearScrollTimer();\n setScrollTimer(() => {\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n }, [clearScrollTimer, setScrollTimer]);\n\n useEffect(() => {\n initializeScrollingTimer();\n }, [actualIndex, initializeScrollingTimer]);\n\n const batchUpdateNewIndex = (index: number) => {\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\n\n // Set before 'setActualIndex' call\n // If it changes before render, or injected via context, re-render will update ref.\n actualIndexRef.current = index;\n\n // State setters\n setActualIndex(index);\n };\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n // eslint-disable-next-line no-restricted-globals\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (actualIndex !== 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 const bufferedIndex = Math.max(startIndex - bufferCount, 0);\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 (actualIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\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 actualIndex;\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 = useCallback(() => {\n if (!getItemSize) {\n return itemSize * numItems;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n }, [getItemSize, itemSize, numItems]);\n\n const calculateBefore = useCallback(() => {\n const currentIndex = Math.min(actualIndex, numItems - 1);\n\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return currentIndex * itemSize;\n }\n\n if (currentIndex <= 0) {\n return 0;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[currentIndex - 1];\n }, [actualIndex, getItemSize, itemSize, numItems]);\n\n const calculateAfter = useCallback(() => {\n if (numItems === 0 || actualIndex + virtualizerLength >= numItems) {\n return 0;\n }\n\n const lastItemIndex = Math.min(actualIndex + virtualizerLength, numItems);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex;\n return remainingItems * itemSize;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];\n }, [actualIndex, getItemSize, itemSize, numItems, virtualizerLength]);\n\n const updateChildRows = useCallback(\n (newIndex: number) => {\n if (numItems === 0) {\n /* Nothing to virtualize */\n return;\n }\n\n /*\n We reset the array every time to ensure children are re-rendered\n This function should only be called when update is nessecary\n */\n childArray.current = new Array(virtualizerLength);\n const _actualIndex = Math.max(newIndex, 0);\n const end = Math.min(_actualIndex + virtualizerLength, numItems);\n for (let i = _actualIndex; i < end; i++) {\n childArray.current[i - _actualIndex] = renderChild(i, isScrolling);\n }\n },\n [isScrolling, 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 useImperativeHandle(\n imperativeVirtualizerRef,\n () => {\n return {\n progressiveSizes: childProgressiveSizes,\n nodeSizes: childSizes,\n setFlaggedIndex: (index: number | null) => (flaggedIndex.current = index),\n currentIndex: actualIndexRef,\n };\n },\n [childProgressiveSizes, childSizes],\n );\n\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(() => {\n if (actualIndex < 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 (actualIndex >= 0) {\n updateChildRows(actualIndex);\n forceUpdate();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild, updateChildRows]);\n\n useEffect(() => {\n // Ensure we repopulate if getItemSize callback changes\n populateSizeArrays();\n\n // We only run this effect on getItemSize change (recalc dynamic sizes)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getItemSize]);\n\n // Effect to check flag index on updates\n useEffect(() => {\n if (!onRenderedFlaggedIndex || flaggedIndex.current === null) {\n return;\n }\n if (actualIndex <= flaggedIndex.current && actualIndex + virtualizerLength >= flaggedIndex.current) {\n onRenderedFlaggedIndex(flaggedIndex.current);\n flaggedIndex.current = null;\n }\n }, [actualIndex, onRenderedFlaggedIndex, virtualizerLength]);\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 && actualIndex + childArray.current.length < numItems) {\n updateChildRows(actualIndex);\n }\n\n const isFullyInitialized = hasInitialized.current && actualIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div',\n },\n virtualizedChildren: childArray.current,\n before: slot.always(props.before, {\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n after: slot.always(props.after, {\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeContainer: slot.always(props.beforeContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n afterContainer: slot.always(props.afterContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed,\n childSizes,\n childProgressiveSizes,\n };\n}\n"],"names":["useEffect","useRef","useCallback","useReducer","useImperativeHandle","useState","useIntersectionObserver","flushSync","useVirtualizerContextState_unstable","slot","useTimeout","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","scrollViewRef","axis","reversed","virtualizerContext","onRenderedFlaggedIndex","imperativeVirtualizerRef","_virtualizerContext","actualIndexRef","contextIndex","current","flaggedIndex","actualIndex","setActualIndex","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","horizontal","populateSizeArrays","length","index","isScrolling","setIsScrolling","setScrollTimer","clearScrollTimer","scrollCounter","initializeScrollingTimer","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","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","currentIndex","lastItemIndex","remainingItems","newIndex","_actualIndex","end","i","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","progressiveSizes","nodeSizes","setFlaggedIndex","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","always","defaultProps","ref","role","elementType","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,SAAS,EAAEC,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAEC,mBAAmB,EAAEC,QAAQ,QAAQ,QAAQ;AAClG,SAASC,uBAAuB,QAAQ,sCAAsC;AAC9E,SAASC,S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"version":3,"sources":["useVirtualizer.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { VirtualizerProps, VirtualizerState } from './Virtualizer.types';\n\nimport { useEffect, useRef, useCallback, useImperativeHandle, useState, useReducer } from 'react';\nimport { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { slot, useTimeout } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n 'use no memo';\n\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 axis = 'vertical',\n reversed = false,\n virtualizerContext,\n onRenderedFlaggedIndex,\n imperativeVirtualizerRef,\n containerSizeRef,\n scrollViewRef,\n enableScrollLoad,\n } = props;\n\n /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/\n const _virtualizerContext = useVirtualizerContextState_unstable(virtualizerContext);\n\n // We use this ref as a constant source to access the virtualizer's state imperatively\n const actualIndexRef = useRef<number>(_virtualizerContext.contextIndex);\n const flaggedIndex = useRef<number | null>(null);\n\n const actualIndex = _virtualizerContext.contextIndex;\n // Just in case our ref gets out of date vs the context during a re-render\n if (_virtualizerContext.contextIndex !== actualIndexRef.current) {\n actualIndexRef.current = _virtualizerContext.contextIndex;\n }\n const setActualIndex = useCallback(\n (index: number) => {\n actualIndexRef.current = index;\n _virtualizerContext.setContextIndex(index);\n },\n [_virtualizerContext],\n );\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 if (virtualizerContext?.childProgressiveSizes) {\n virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;\n }\n\n // The internal tracking REF for child array (updates often).\n const childArray = useRef<ReactNode[]>(new Array(virtualizerLength));\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 if (virtualizerContext?.childProgressiveSizes) {\n virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;\n }\n }\n\n for (let index = 0; index < numItems; index++) {\n childSizes.current[index] = getItemSize(index);\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 [isScrolling, setIsScrolling] = useState<boolean>(false);\n const [setScrollTimer, clearScrollTimer] = useTimeout();\n const scrollCounter = useRef<number>(0);\n\n const initializeScrollingTimer = useCallback(() => {\n if (!enableScrollLoad) {\n // Disabled by default for reduction of render callbacks\n return;\n }\n /*\n * This can be considered the 'velocity' required to start 'isScrolling'\n * INIT_SCROLL_FLAG_REQ: Number of renders required to activate isScrolling\n * INIT_SCROLL_FLAG_DELAY: Amount of time (ms) before current number of renders is reset\n * - Maybe we should let users customize these in the future.\n */\n const INIT_SCROLL_FLAG_REQ = 10;\n const INIT_SCROLL_FLAG_DELAY = 100;\n\n scrollCounter.current++;\n if (scrollCounter.current >= INIT_SCROLL_FLAG_REQ) {\n setIsScrolling(true);\n }\n clearScrollTimer();\n setScrollTimer(() => {\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n }, [clearScrollTimer, setScrollTimer, enableScrollLoad]);\n\n useEffect(() => {\n initializeScrollingTimer();\n }, [actualIndex, initializeScrollingTimer]);\n\n const updateChildRows = useCallback(\n (newIndex: number) => {\n if (numItems === 0) {\n /* Nothing to virtualize */\n return;\n }\n\n /*\n We reset the array every time to ensure children are re-rendered\n This function should only be called when update is nessecary\n */\n childArray.current = new Array(virtualizerLength);\n const _actualIndex = Math.max(newIndex, 0);\n const end = Math.min(_actualIndex + virtualizerLength, numItems);\n for (let i = _actualIndex; i < end; i++) {\n childArray.current[i - _actualIndex] = renderChild(i, isScrolling);\n }\n },\n [isScrolling, numItems, renderChild, virtualizerLength],\n );\n\n const updateCurrentItemSizes = useCallback(\n (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 [getItemSize, numItems, virtualizerLength],\n );\n\n const batchUpdateNewIndex = useCallback(\n (index: number) => {\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\n\n // State setters\n setActualIndex(index);\n },\n [setActualIndex, updateChildRows, updateCurrentItemSizes],\n );\n\n const findIndexRecursive = useCallback(\n (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 actualIndex;\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 [actualIndex],\n );\n\n const getIndexFromSizeArray = useCallback(\n (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 [findIndexRecursive],\n );\n const getIndexFromScrollPosition = useCallback(\n (scrollPos: number) => {\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n\n return getIndexFromSizeArray(scrollPos);\n },\n [getIndexFromSizeArray, getItemSize, itemSize],\n );\n\n const calculateTotalSize = useCallback(() => {\n if (!getItemSize) {\n return itemSize * numItems;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n }, [getItemSize, itemSize, numItems]);\n\n const calculateBefore = useCallback(() => {\n const currentIndex = Math.min(actualIndex, numItems - 1);\n\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return currentIndex * itemSize;\n }\n\n if (currentIndex <= 0) {\n return 0;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[currentIndex - 1];\n }, [actualIndex, getItemSize, itemSize, numItems]);\n\n const calculateAfter = useCallback(() => {\n if (numItems === 0 || actualIndex + virtualizerLength >= numItems) {\n return 0;\n }\n\n const lastItemIndex = Math.min(actualIndex + virtualizerLength, numItems);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex;\n return remainingItems * itemSize;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];\n }, [actualIndex, getItemSize, itemSize, numItems, virtualizerLength]);\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n useCallback(\n // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n // eslint-disable-next-line no-restricted-globals\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (actualIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\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 || !latestEntry.isIntersecting) {\n // If we don't find an intersecting area, ignore for now.\n return;\n }\n\n // We have to be sure our item sizes are up to date with current indexed ref before calculation\n // Check if we still need\n updateCurrentItemSizes(actualIndexRef.current);\n\n const calculateOverBuffer = (): number => {\n /**\n * We avoid using the scroll ref scrollTop, it may be incorrect\n * as virtualization may exist within a scroll view with other elements\n * The benefit of using IO is that we can detect relative scrolls,\n * so any items can be placed around the virtualizer in the scroll view\n */\n let measurementPos = 0;\n if (latestEntry.target === afterElementRef.current) {\n // Get after buffers position\n measurementPos = calculateTotalSize() - calculateAfter();\n\n // Get exact intersection position based on overflow size (how far into IO did we scroll?)\n const overflowAmount =\n axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;\n // Add to original after position\n measurementPos += overflowAmount;\n // Ignore buffer size (IO offset)\n measurementPos -= bufferSize;\n // we hit the after buffer and detected the end of view, we need to find the start index.\n measurementPos -= containerSizeRef.current ?? 0;\n\n // Calculate how far past the window bounds we are (this will be zero if IO is within window)\n const hOverflow = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;\n const hOverflowReversed = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;\n const wOverflow = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;\n const wOverflowReversed = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;\n const widthOverflow = reversed ? wOverflowReversed : wOverflow;\n const heightOverflow = reversed ? hOverflowReversed : hOverflow;\n const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;\n\n if (reversed) {\n measurementPos += additionalOverflow;\n } else {\n measurementPos -= additionalOverflow;\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n // Get before buffers position\n measurementPos = calculateBefore();\n // Get exact intersection position based on overflow size (how far into window did we scroll IO?)\n const overflowAmount =\n axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;\n // Minus from original before position\n measurementPos -= overflowAmount;\n // Ignore buffer size (IO offset)\n measurementPos += bufferSize;\n\n // Calculate how far past the window bounds we are (this will be zero if IO is within window)\n const hOverflow = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;\n const hOverflowReversed = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;\n const wOverflow = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;\n const wOverflowReversed = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;\n const widthOverflow = reversed ? wOverflowReversed : wOverflow;\n const heightOverflow = reversed ? hOverflowReversed : hOverflow;\n const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;\n\n if (reversed) {\n measurementPos += additionalOverflow;\n } else {\n measurementPos -= additionalOverflow;\n }\n }\n\n return measurementPos;\n };\n\n // Get exact relative 'scrollTop' via IO values\n const measurementPos = calculateOverBuffer();\n\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n\n const startIndex = getIndexFromScrollPosition(measurementPos) - bufferItems;\n\n // Safety limits\n const newStartIndex = Math.min(Math.max(startIndex, 0), maxIndex);\n\n flushSync(() => {\n _virtualizerContext.setContextPosition(measurementPos);\n if (actualIndex !== newStartIndex) {\n batchUpdateNewIndex(newStartIndex);\n }\n });\n },\n [\n _virtualizerContext,\n actualIndex,\n axis,\n batchUpdateNewIndex,\n bufferItems,\n bufferSize,\n calculateAfter,\n calculateBefore,\n calculateTotalSize,\n containerSizeRef,\n getIndexFromScrollPosition,\n numItems,\n reversed,\n updateCurrentItemSizes,\n virtualizerLength,\n ],\n ),\n {\n root: scrollViewRef ? scrollViewRef?.current : null,\n rootMargin: '0px',\n threshold: 0,\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 // 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 useImperativeHandle(\n imperativeVirtualizerRef,\n () => {\n return {\n progressiveSizes: childProgressiveSizes,\n nodeSizes: childSizes,\n setFlaggedIndex: (index: number | null) => (flaggedIndex.current = index),\n currentIndex: actualIndexRef,\n };\n },\n [childProgressiveSizes, childSizes],\n );\n\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(() => {\n if (actualIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n /*\n * forceUpdate:\n * We only want to trigger this when scrollLoading is enabled and set to false,\n * it will force re-render all children elements\n */\n const forceUpdate = useReducer(() => ({}), {})[1];\n // If the user passes in an updated renderChild function - update current children\n useEffect(() => {\n if (actualIndex >= 0) {\n updateChildRows(actualIndex);\n if (enableScrollLoad && !isScrolling) {\n forceUpdate();\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild, isScrolling]);\n\n useEffect(() => {\n // Ensure we repopulate if getItemSize callback changes\n populateSizeArrays();\n\n // We only run this effect on getItemSize change (recalc dynamic sizes)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getItemSize]);\n\n // Effect to check flag index on updates\n useEffect(() => {\n if (!onRenderedFlaggedIndex || flaggedIndex.current === null) {\n return;\n }\n if (actualIndex <= flaggedIndex.current && actualIndex + virtualizerLength >= flaggedIndex.current) {\n onRenderedFlaggedIndex(flaggedIndex.current);\n flaggedIndex.current = null;\n }\n }, [actualIndex, onRenderedFlaggedIndex, virtualizerLength]);\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 && actualIndex + childArray.current.length < numItems) {\n updateChildRows(actualIndex);\n }\n\n const isFullyInitialized = hasInitialized.current && actualIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div',\n },\n virtualizedChildren: childArray.current,\n before: slot.always(props.before, {\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n after: slot.always(props.after, {\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeContainer: slot.always(props.beforeContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n afterContainer: slot.always(props.afterContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed,\n childSizes,\n childProgressiveSizes,\n };\n}\n"],"names":["useEffect","useRef","useCallback","useImperativeHandle","useState","useReducer","useIntersectionObserver","useVirtualizerContextState_unstable","slot","useTimeout","flushSync","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","axis","reversed","virtualizerContext","onRenderedFlaggedIndex","imperativeVirtualizerRef","containerSizeRef","scrollViewRef","enableScrollLoad","_virtualizerContext","actualIndexRef","contextIndex","flaggedIndex","actualIndex","current","setActualIndex","index","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","populateSizeArrays","length","isScrolling","setIsScrolling","setScrollTimer","clearScrollTimer","scrollCounter","initializeScrollingTimer","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","updateChildRows","newIndex","_actualIndex","max","end","min","i","updateCurrentItemSizes","endIndex","startIndex","didUpdate","newSize","prevSize","batchUpdateNewIndex","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","getIndexFromScrollPosition","calculateTotalSize","calculateBefore","currentIndex","calculateAfter","lastItemIndex","remainingItems","setObserverList","entries","observer","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","isIntersecting","calculateOverBuffer","measurementPos","target","overflowAmount","intersectionRect","height","width","hOverflow","boundingClientRect","top","hOverflowReversed","bottom","wOverflow","left","wOverflowReversed","right","widthOverflow","heightOverflow","additionalOverflow","maxIndex","newStartIndex","setContextPosition","root","rootMargin","threshold","setBeforeRef","element","newList","push","setAfterRef","hasInitialized","initializeSizeArray","progressiveSizes","nodeSizes","setFlaggedIndex","forceUpdate","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","always","defaultProps","ref","role","elementType","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,SAAS,EAAEC,MAAM,EAAEC,WAAW,EAAEC,mBAAmB,EAAEC,QAAQ,EAAEC,UAAU,QAAQ,QAAQ;AAClG,SAASC,uBAAuB,QAAQ,sCAAsC;AAC9E,SAASC,mCAAmC,QAAQ,kBAAkB;AACtE,SAASC,IAAI,EAAEC,UAAU,QAAQ,4BAA4B;AAC7D,SAASC,SAAS,QAAQ,YAAY;AAEtC,OAAO,SAASC,wBAAwBC,KAAuB;IAC7D;IAEA,MAAM,EACJC,QAAQ,EACRC,QAAQ,EACRC,iBAAiB,EACjBC,UAAUC,WAAW,EACrBC,W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