@fluentui/react-virtualizer 9.0.0-alpha.83 → 9.0.0-alpha.85

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
@@ -10,21 +10,27 @@ Object.defineProperty(exports, "useVirtualizer_unstable", {
10
10
  });
11
11
  const _react = require("react");
12
12
  const _useIntersectionObserver = require("../../hooks/useIntersectionObserver");
13
- const _reactdom = require("react-dom");
14
13
  const _Utilities = require("../../Utilities");
15
14
  const _reactutilities = require("@fluentui/react-utilities");
15
+ const _reactdom = require("react-dom");
16
16
  function useVirtualizer_unstable(props) {
17
17
  'use no memo';
18
- 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;
18
+ 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;
19
19
  /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/ const _virtualizerContext = (0, _Utilities.useVirtualizerContextState_unstable)(virtualizerContext);
20
20
  // We use this ref as a constant source to access the virtualizer's state imperatively
21
21
  const actualIndexRef = (0, _react.useRef)(_virtualizerContext.contextIndex);
22
- if (actualIndexRef.current !== _virtualizerContext.contextIndex) {
23
- actualIndexRef.current = _virtualizerContext.contextIndex;
24
- }
25
22
  const flaggedIndex = (0, _react.useRef)(null);
26
23
  const actualIndex = _virtualizerContext.contextIndex;
27
- const setActualIndex = _virtualizerContext.setContextIndex;
24
+ // Just in case our ref gets out of date vs the context during a re-render
25
+ if (_virtualizerContext.contextIndex !== actualIndexRef.current) {
26
+ actualIndexRef.current = _virtualizerContext.contextIndex;
27
+ }
28
+ const setActualIndex = (0, _react.useCallback)((index)=>{
29
+ actualIndexRef.current = index;
30
+ _virtualizerContext.setContextIndex(index);
31
+ }, [
32
+ _virtualizerContext
33
+ ]);
28
34
  // Store ref to before padding element
29
35
  const beforeElementRef = (0, _react.useRef)(null);
30
36
  // Store ref to before padding element
@@ -33,11 +39,11 @@ function useVirtualizer_unstable(props) {
33
39
  const childSizes = (0, _react.useRef)(new Array(getItemSize ? numItems : 0));
34
40
  /* We keep track of the progressive sizing/placement down the list,
35
41
  this helps us skip re-calculations unless children/size changes */ const childProgressiveSizes = (0, _react.useRef)(new Array(getItemSize ? numItems : 0));
42
+ if (virtualizerContext === null || virtualizerContext === void 0 ? void 0 : virtualizerContext.childProgressiveSizes) {
43
+ virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;
44
+ }
36
45
  // The internal tracking REF for child array (updates often).
37
46
  const childArray = (0, _react.useRef)(new Array(virtualizerLength));
38
- // We want to be methodical about updating the render with child reference array
39
- const forceUpdate = (0, _react.useReducer)(()=>({}), {})[1];
40
- const horizontal = axis === 'horizontal';
41
47
  const populateSizeArrays = ()=>{
42
48
  if (!getItemSize) {
43
49
  // Static sizes, never mind!
@@ -48,6 +54,9 @@ function useVirtualizer_unstable(props) {
48
54
  }
49
55
  if (numItems !== childProgressiveSizes.current.length) {
50
56
  childProgressiveSizes.current = new Array(numItems);
57
+ if (virtualizerContext === null || virtualizerContext === void 0 ? void 0 : virtualizerContext.childProgressiveSizes) {
58
+ virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;
59
+ }
51
60
  }
52
61
  for(let index = 0; index < numItems; index++){
53
62
  childSizes.current[index] = getItemSize(index);
@@ -62,6 +71,10 @@ function useVirtualizer_unstable(props) {
62
71
  const [setScrollTimer, clearScrollTimer] = (0, _reactutilities.useTimeout)();
63
72
  const scrollCounter = (0, _react.useRef)(0);
64
73
  const initializeScrollingTimer = (0, _react.useCallback)(()=>{
74
+ if (!enableScrollLoad) {
75
+ // Disabled by default for reduction of render callbacks
76
+ return;
77
+ }
65
78
  /*
66
79
  * This can be considered the 'velocity' required to start 'isScrolling'
67
80
  * INIT_SCROLL_FLAG_REQ: Number of renders required to activate isScrolling
@@ -80,7 +93,8 @@ function useVirtualizer_unstable(props) {
80
93
  }, INIT_SCROLL_FLAG_DELAY);
81
94
  }, [
82
95
  clearScrollTimer,
83
- setScrollTimer
96
+ setScrollTimer,
97
+ enableScrollLoad
84
98
  ]);
85
99
  (0, _react.useEffect)(()=>{
86
100
  initializeScrollingTimer();
@@ -88,97 +102,66 @@ function useVirtualizer_unstable(props) {
88
102
  actualIndex,
89
103
  initializeScrollingTimer
90
104
  ]);
91
- const batchUpdateNewIndex = (index)=>{
92
- // Local updates
93
- updateChildRows(index);
94
- updateCurrentItemSizes(index);
95
- // Set before 'setActualIndex' call
96
- // If it changes before render, or injected via context, re-render will update ref.
97
- actualIndexRef.current = index;
98
- // State setters
99
- setActualIndex(index);
100
- };
101
- // Observe intersections of virtualized components
102
- const { setObserverList } = (0, _useIntersectionObserver.useIntersectionObserver)(// eslint-disable-next-line no-restricted-globals
103
- (entries, observer)=>{
104
- /* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {
105
- if (actualIndex !== 0) {
106
- batchUpdateNewIndex(0);
107
- }
108
- // No-op
109
- return;
105
+ const updateChildRows = (0, _react.useCallback)((newIndex)=>{
106
+ if (numItems === 0) {
107
+ /* Nothing to virtualize */ return;
110
108
  }
111
- /* IO initiates this function when needed (bookend entering view) */ let measurementPos = 0;
112
- let bufferCount = bufferItems;
113
- // Grab latest entry that is intersecting
114
- const latestEntry = entries.length === 1 ? entries[0] : entries.sort((entry1, entry2)=>entry2.time - entry1.time).find((entry)=>{
115
- return entry.intersectionRatio > 0;
116
- });
117
- if (!latestEntry) {
118
- // If we don't find an intersecting area, ignore for now.
109
+ /*
110
+ We reset the array every time to ensure children are re-rendered
111
+ This function should only be called when update is nessecary
112
+ */ childArray.current = new Array(virtualizerLength);
113
+ const _actualIndex = Math.max(newIndex, 0);
114
+ const end = Math.min(_actualIndex + virtualizerLength, numItems);
115
+ for(let i = _actualIndex; i < end; i++){
116
+ childArray.current[i - _actualIndex] = renderChild(i, isScrolling);
117
+ }
118
+ }, [
119
+ isScrolling,
120
+ numItems,
121
+ renderChild,
122
+ virtualizerLength
123
+ ]);
124
+ const updateCurrentItemSizes = (0, _react.useCallback)((newIndex)=>{
125
+ if (!getItemSize) {
126
+ // Static sizes, not required.
119
127
  return;
120
128
  }
121
- if (latestEntry.target === afterElementRef.current) {
122
- // We need to inverse the buffer count
123
- bufferCount = virtualizerLength - bufferItems;
124
- measurementPos = reversed ? calculateAfter() : calculateTotalSize() - calculateAfter();
125
- if (!horizontal) {
126
- if (reversed) {
127
- // Scrolling 'up' and hit the after element below
128
- measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);
129
- } else if (latestEntry.boundingClientRect.top < 0) {
130
- // Scrolling 'down' and hit the after element above top: 0
131
- measurementPos -= latestEntry.boundingClientRect.top;
132
- }
133
- } else {
134
- if (reversed) {
135
- // Scrolling 'left' and hit the after element
136
- measurementPos -= Math.abs(latestEntry.boundingClientRect.right);
137
- } else if (latestEntry.boundingClientRect.left < 0) {
138
- // Scrolling 'right' and hit the after element
139
- measurementPos -= latestEntry.boundingClientRect.left;
140
- }
141
- }
142
- } else if (latestEntry.target === beforeElementRef.current) {
143
- measurementPos = reversed ? calculateTotalSize() - calculateBefore() : calculateBefore();
144
- if (!horizontal) {
145
- if (!reversed) {
146
- measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);
147
- } else if (latestEntry.boundingClientRect.top < 0) {
148
- // Scrolling 'down' in reverse order and hit the before element above top: 0
149
- measurementPos -= latestEntry.boundingClientRect.top;
150
- }
151
- } else {
152
- if (!reversed) {
153
- measurementPos -= Math.abs(latestEntry.boundingClientRect.right);
154
- } else if (latestEntry.boundingClientRect.left < 0) {
155
- // Scrolling 'left' and hit before element
156
- measurementPos -= latestEntry.boundingClientRect.left;
157
- }
129
+ // We should always call our size function on index change (only for the items that will be rendered)
130
+ // This ensures we request the latest data for incoming items in case sizing has changed.
131
+ const endIndex = Math.min(newIndex + virtualizerLength, numItems);
132
+ const startIndex = Math.max(newIndex, 0);
133
+ let didUpdate = false;
134
+ for(let i = startIndex; i < endIndex; i++){
135
+ const newSize = getItemSize(i);
136
+ if (newSize !== childSizes.current[i]) {
137
+ childSizes.current[i] = newSize;
138
+ didUpdate = true;
158
139
  }
159
140
  }
160
- if (reversed) {
161
- // We're reversed, up is down, left is right, invert the scroll measure.
162
- measurementPos = Math.max(calculateTotalSize() - Math.abs(measurementPos), 0);
163
- }
164
- // For now lets use hardcoded size to assess current element to paginate on
165
- const startIndex = getIndexFromScrollPosition(measurementPos);
166
- const bufferedIndex = Math.max(startIndex - bufferCount, 0);
167
- // Safety limits
168
- const maxIndex = Math.max(numItems - virtualizerLength, 0);
169
- const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);
170
- if (actualIndex !== newStartIndex) {
171
- // We flush sync this and perform an immediate state update
172
- (0, _reactdom.flushSync)(()=>{
173
- batchUpdateNewIndex(newStartIndex);
174
- });
141
+ if (didUpdate) {
142
+ // Update our progressive size array
143
+ for(let i = startIndex; i < numItems; i++){
144
+ const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;
145
+ childProgressiveSizes.current[i] = prevSize + childSizes.current[i];
146
+ }
175
147
  }
176
- }, {
177
- root: scrollViewRef ? scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current : null,
178
- rootMargin: '0px',
179
- threshold: 0
180
- });
181
- const findIndexRecursive = (scrollPos, lowIndex, highIndex)=>{
148
+ }, [
149
+ getItemSize,
150
+ numItems,
151
+ virtualizerLength
152
+ ]);
153
+ const batchUpdateNewIndex = (0, _react.useCallback)((index)=>{
154
+ // Local updates
155
+ updateChildRows(index);
156
+ updateCurrentItemSizes(index);
157
+ // State setters
158
+ setActualIndex(index);
159
+ }, [
160
+ setActualIndex,
161
+ updateChildRows,
162
+ updateCurrentItemSizes
163
+ ]);
164
+ const findIndexRecursive = (0, _react.useCallback)((scrollPos, lowIndex, highIndex)=>{
182
165
  if (lowIndex > highIndex) {
183
166
  // We shouldn't get here - but no-op the index if we do.
184
167
  return actualIndex;
@@ -198,8 +181,10 @@ function useVirtualizer_unstable(props) {
198
181
  } else {
199
182
  return findIndexRecursive(scrollPos, midpoint + 1, highIndex);
200
183
  }
201
- };
202
- const getIndexFromSizeArray = (scrollPos)=>{
184
+ }, [
185
+ actualIndex
186
+ ]);
187
+ const getIndexFromSizeArray = (0, _react.useCallback)((scrollPos)=>{
203
188
  /* Quick searches our progressive height array */ if (scrollPos === 0 || childProgressiveSizes.current.length === 0 || scrollPos <= childProgressiveSizes.current[0]) {
204
189
  // Check start
205
190
  return 0;
@@ -209,13 +194,19 @@ function useVirtualizer_unstable(props) {
209
194
  return childProgressiveSizes.current.length - 1;
210
195
  }
211
196
  return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);
212
- };
213
- const getIndexFromScrollPosition = (scrollPos)=>{
197
+ }, [
198
+ findIndexRecursive
199
+ ]);
200
+ const getIndexFromScrollPosition = (0, _react.useCallback)((scrollPos)=>{
214
201
  if (!getItemSize) {
215
202
  return Math.round(scrollPos / itemSize);
216
203
  }
217
204
  return getIndexFromSizeArray(scrollPos);
218
- };
205
+ }, [
206
+ getIndexFromSizeArray,
207
+ getItemSize,
208
+ itemSize
209
+ ]);
219
210
  const calculateTotalSize = (0, _react.useCallback)(()=>{
220
211
  if (!getItemSize) {
221
212
  return itemSize * numItems;
@@ -263,25 +254,117 @@ function useVirtualizer_unstable(props) {
263
254
  numItems,
264
255
  virtualizerLength
265
256
  ]);
266
- const updateChildRows = (0, _react.useCallback)((newIndex)=>{
267
- if (numItems === 0) {
268
- /* Nothing to virtualize */ return;
257
+ // Observe intersections of virtualized components
258
+ const { setObserverList } = (0, _useIntersectionObserver.useIntersectionObserver)((0, _react.useCallback)(// eslint-disable-next-line no-restricted-globals
259
+ (entries, observer)=>{
260
+ /* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {
261
+ if (actualIndex !== 0) {
262
+ batchUpdateNewIndex(0);
263
+ }
264
+ // No-op
265
+ return;
269
266
  }
270
- /*
271
- We reset the array every time to ensure children are re-rendered
272
- This function should only be called when update is nessecary
273
- */ childArray.current = new Array(virtualizerLength);
274
- const _actualIndex = Math.max(newIndex, 0);
275
- const end = Math.min(_actualIndex + virtualizerLength, numItems);
276
- for(let i = _actualIndex; i < end; i++){
277
- childArray.current[i - _actualIndex] = renderChild(i, isScrolling);
267
+ // Grab latest entry that is intersecting
268
+ const latestEntry = entries.length === 1 ? entries[0] : entries.sort((entry1, entry2)=>entry2.time - entry1.time).find((entry)=>{
269
+ return entry.intersectionRatio > 0;
270
+ });
271
+ if (!latestEntry || !latestEntry.isIntersecting) {
272
+ // If we don't find an intersecting area, ignore for now.
273
+ return;
278
274
  }
275
+ // We have to be sure our item sizes are up to date with current indexed ref before calculation
276
+ // Check if we still need
277
+ updateCurrentItemSizes(actualIndexRef.current);
278
+ const calculateOverBuffer = ()=>{
279
+ /**
280
+ * We avoid using the scroll ref scrollTop, it may be incorrect
281
+ * as virtualization may exist within a scroll view with other elements
282
+ * The benefit of using IO is that we can detect relative scrolls,
283
+ * so any items can be placed around the virtualizer in the scroll view
284
+ */ let measurementPos = 0;
285
+ if (latestEntry.target === afterElementRef.current) {
286
+ // Get after buffers position
287
+ measurementPos = calculateTotalSize() - calculateAfter();
288
+ // Get exact intersection position based on overflow size (how far into IO did we scroll?)
289
+ const overflowAmount = axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;
290
+ // Add to original after position
291
+ measurementPos += overflowAmount;
292
+ // Ignore buffer size (IO offset)
293
+ measurementPos -= bufferSize;
294
+ var _containerSizeRef_current;
295
+ // we hit the after buffer and detected the end of view, we need to find the start index.
296
+ measurementPos -= (_containerSizeRef_current = containerSizeRef.current) !== null && _containerSizeRef_current !== void 0 ? _containerSizeRef_current : 0;
297
+ // Calculate how far past the window bounds we are (this will be zero if IO is within window)
298
+ const hOverflow = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;
299
+ const hOverflowReversed = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;
300
+ const wOverflow = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;
301
+ const wOverflowReversed = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;
302
+ const widthOverflow = reversed ? wOverflowReversed : wOverflow;
303
+ const heightOverflow = reversed ? hOverflowReversed : hOverflow;
304
+ const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;
305
+ if (reversed) {
306
+ measurementPos += additionalOverflow;
307
+ } else {
308
+ measurementPos -= additionalOverflow;
309
+ }
310
+ } else if (latestEntry.target === beforeElementRef.current) {
311
+ // Get before buffers position
312
+ measurementPos = calculateBefore();
313
+ // Get exact intersection position based on overflow size (how far into window did we scroll IO?)
314
+ const overflowAmount = axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;
315
+ // Minus from original before position
316
+ measurementPos -= overflowAmount;
317
+ // Ignore buffer size (IO offset)
318
+ measurementPos += bufferSize;
319
+ // Calculate how far past the window bounds we are (this will be zero if IO is within window)
320
+ const hOverflow = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;
321
+ const hOverflowReversed = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;
322
+ const wOverflow = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;
323
+ const wOverflowReversed = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;
324
+ const widthOverflow = reversed ? wOverflowReversed : wOverflow;
325
+ const heightOverflow = reversed ? hOverflowReversed : hOverflow;
326
+ const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;
327
+ if (reversed) {
328
+ measurementPos += additionalOverflow;
329
+ } else {
330
+ measurementPos -= additionalOverflow;
331
+ }
332
+ }
333
+ return measurementPos;
334
+ };
335
+ // Get exact relative 'scrollTop' via IO values
336
+ const measurementPos = calculateOverBuffer();
337
+ const maxIndex = Math.max(numItems - virtualizerLength, 0);
338
+ const startIndex = getIndexFromScrollPosition(measurementPos) - bufferItems;
339
+ // Safety limits
340
+ const newStartIndex = Math.min(Math.max(startIndex, 0), maxIndex);
341
+ (0, _reactdom.flushSync)(()=>{
342
+ _virtualizerContext.setContextPosition(measurementPos);
343
+ if (actualIndex !== newStartIndex) {
344
+ batchUpdateNewIndex(newStartIndex);
345
+ }
346
+ });
279
347
  }, [
280
- isScrolling,
348
+ _virtualizerContext,
349
+ actualIndex,
350
+ axis,
351
+ batchUpdateNewIndex,
352
+ bufferItems,
353
+ bufferSize,
354
+ calculateAfter,
355
+ calculateBefore,
356
+ calculateTotalSize,
357
+ containerSizeRef,
358
+ getIndexFromScrollPosition,
281
359
  numItems,
282
- renderChild,
360
+ reversed,
361
+ updateCurrentItemSizes,
283
362
  virtualizerLength
284
- ]);
363
+ ]), {
364
+ root: scrollViewRef ? scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current : null,
365
+ rootMargin: '0px',
366
+ threshold: 0
367
+ });
285
368
  const setBeforeRef = (0, _react.useCallback)((element)=>{
286
369
  if (!element || beforeElementRef.current === element) {
287
370
  return;
@@ -312,31 +395,6 @@ function useVirtualizer_unstable(props) {
312
395
  }, [
313
396
  setObserverList
314
397
  ]);
315
- const updateCurrentItemSizes = (newIndex)=>{
316
- if (!getItemSize) {
317
- // Static sizes, not required.
318
- return;
319
- }
320
- // We should always call our size function on index change (only for the items that will be rendered)
321
- // This ensures we request the latest data for incoming items in case sizing has changed.
322
- const endIndex = Math.min(newIndex + virtualizerLength, numItems);
323
- const startIndex = Math.max(newIndex, 0);
324
- let didUpdate = false;
325
- for(let i = startIndex; i < endIndex; i++){
326
- const newSize = getItemSize(i);
327
- if (newSize !== childSizes.current[i]) {
328
- childSizes.current[i] = newSize;
329
- didUpdate = true;
330
- }
331
- }
332
- if (didUpdate) {
333
- // Update our progressive size array
334
- for(let i = startIndex; i < numItems; i++){
335
- const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;
336
- childProgressiveSizes.current[i] = prevSize + childSizes.current[i];
337
- }
338
- }
339
- };
340
398
  // Initialize the size array before first render.
341
399
  const hasInitialized = (0, _react.useRef)(false);
342
400
  const initializeSizeArray = ()=>{
@@ -364,16 +422,23 @@ function useVirtualizer_unstable(props) {
364
422
  }
365
423
  // eslint-disable-next-line react-hooks/exhaustive-deps
366
424
  }, []);
425
+ /*
426
+ * forceUpdate:
427
+ * We only want to trigger this when scrollLoading is enabled and set to false,
428
+ * it will force re-render all children elements
429
+ */ const forceUpdate = (0, _react.useReducer)(()=>({}), {})[1];
367
430
  // If the user passes in an updated renderChild function - update current children
368
431
  (0, _react.useEffect)(()=>{
369
432
  if (actualIndex >= 0) {
370
433
  updateChildRows(actualIndex);
371
- forceUpdate();
434
+ if (enableScrollLoad && !isScrolling) {
435
+ forceUpdate();
436
+ }
372
437
  }
373
438
  // eslint-disable-next-line react-hooks/exhaustive-deps
374
439
  }, [
375
440
  renderChild,
376
- updateChildRows
441
+ isScrolling
377
442
  ]);
378
443
  (0, _react.useEffect)(()=>{
379
444
  // 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":["useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","scrollViewRef","axis","reversed","virtualizerContext","onRenderedFlaggedIndex","imperativeVirtualizerRef","_virtualizerContext","useVirtualizerContextState_unstable","actualIndexRef","useRef","contextIndex","current","flaggedIndex","actualIndex","setActualIndex","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","useReducer","horizontal","populateSizeArrays","length","index","isScrolling","setIsScrolling","useState","setScrollTimer","clearScrollTimer","useTimeout","scrollCounter","initializeScrollingTimer","useCallback","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","useEffect","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","useIntersectionObserver","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","flushSync","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","useImperativeHandle","progressiveSizes","nodeSizes","setFlaggedIndex","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","slot","always","defaultProps","ref","role","elementType","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BASgBA;;;eAAAA;;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,eAAe,EAAE;YAClDK,cAAc;gBACZE,MAAM;YACR;YACAC,aAAa;QACf;QACAP,gBAAgBE,oBAAAA,CAAKC,MAAM,CAACpI,MAAMiI,cAAc,EAAE;YAChDI,cAAc;gBACZE,MAAM;YACR;YACAC,aAAa;QACf;QACAC,oBAAoBb,qBAAqB9C,oBAAoB;QAC7D4D,mBAAmBd,qBAAqBtD,mBAAmB;QAC3DqE,wBAAwBf,qBAAqBrD,uBAAuBpE,oBAAoBF;QACxF2I,uBAAuBnH;QACvBZ;QACAH;QACAI;QACAgB;QACAE;IACF;AACF"}
1
+ {"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":["useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","axis","reversed","virtualizerContext","onRenderedFlaggedIndex","imperativeVirtualizerRef","containerSizeRef","scrollViewRef","enableScrollLoad","_virtualizerContext","useVirtualizerContextState_unstable","actualIndexRef","useRef","contextIndex","flaggedIndex","actualIndex","current","setActualIndex","useCallback","index","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","populateSizeArrays","length","isScrolling","setIsScrolling","useState","setScrollTimer","clearScrollTimer","useTimeout","scrollCounter","initializeScrollingTimer","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","useEffect","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","useIntersectionObserver","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","flushSync","setContextPosition","root","rootMargin","threshold","setBeforeRef","element","newList","push","setAfterRef","hasInitialized","initializeSizeArray","useImperativeHandle","progressiveSizes","nodeSizes","setFlaggedIndex","forceUpdate","useReducer","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","slot","always","defaultProps","ref","role","elementType","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";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