@fluentui/react-virtualizer 9.0.0-alpha.27 → 9.0.0-alpha.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,52 @@
2
2
  "name": "@fluentui/react-virtualizer",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 11 Jul 2023 18:44:11 GMT",
5
+ "date": "Thu, 20 Jul 2023 18:24:27 GMT",
6
+ "tag": "@fluentui/react-virtualizer_v9.0.0-alpha.29",
7
+ "version": "9.0.0-alpha.29",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "beachball",
12
+ "package": "@fluentui/react-virtualizer",
13
+ "comment": "Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.12",
14
+ "commit": "5a4b16715e8e929f11d8113f710e578ca73acaa6"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Mon, 17 Jul 2023 21:27:36 GMT",
21
+ "tag": "@fluentui/react-virtualizer_v9.0.0-alpha.28",
22
+ "version": "9.0.0-alpha.28",
23
+ "comments": {
24
+ "prerelease": [
25
+ {
26
+ "author": "mifraser@microsoft.com",
27
+ "package": "@fluentui/react-virtualizer",
28
+ "commit": "2971c4f9e3273db1e46e14c424ec32db0f67f8d5",
29
+ "comment": "Feat: Add imperative ref access to both virtualizer length and current index"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Thu, 13 Jul 2023 21:25:48 GMT",
36
+ "tag": "@fluentui/react-virtualizer_v9.0.0-alpha.27",
37
+ "version": "9.0.0-alpha.27",
38
+ "comments": {
39
+ "none": [
40
+ {
41
+ "author": "martinhochel@microsoft.com",
42
+ "package": "@fluentui/react-virtualizer",
43
+ "commit": "8a9e1018f2abb2c7608c49d32acf44e93c43cba6",
44
+ "comment": "chore: update devDependencies to use * for inner workspace dependencies"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Tue, 11 Jul 2023 18:46:36 GMT",
6
51
  "tag": "@fluentui/react-virtualizer_v9.0.0-alpha.27",
7
52
  "version": "9.0.0-alpha.27",
8
53
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,30 @@
1
1
  # Change Log - @fluentui/react-virtualizer
2
2
 
3
- This log was last generated on Tue, 11 Jul 2023 18:44:11 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 20 Jul 2023 18:24:27 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.0-alpha.29](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.29)
8
+
9
+ Thu, 20 Jul 2023 18:24:27 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.28..@fluentui/react-virtualizer_v9.0.0-alpha.29)
11
+
12
+ ### Changes
13
+
14
+ - Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.12 ([PR #26826](https://github.com/microsoft/fluentui/pull/26826) by beachball)
15
+
16
+ ## [9.0.0-alpha.28](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.28)
17
+
18
+ Mon, 17 Jul 2023 21:27:36 GMT
19
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.27..@fluentui/react-virtualizer_v9.0.0-alpha.28)
20
+
21
+ ### Changes
22
+
23
+ - Feat: Add imperative ref access to both virtualizer length and current index ([PR #28450](https://github.com/microsoft/fluentui/pull/28450) by mifraser@microsoft.com)
24
+
7
25
  ## [9.0.0-alpha.27](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.27)
8
26
 
9
- Tue, 11 Jul 2023 18:44:11 GMT
27
+ Tue, 11 Jul 2023 18:46:36 GMT
10
28
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.26..@fluentui/react-virtualizer_v9.0.0-alpha.27)
11
29
 
12
30
  ### Changes
package/dist/index.d.ts CHANGED
@@ -25,6 +25,8 @@ export declare interface ResizeCallbackWithRef {
25
25
 
26
26
  export declare type ScrollToInterface = {
27
27
  scrollTo: (index: number, behavior?: ScrollBehavior, callback?: (index: number) => void) => void;
28
+ virtualizerLength: RefObject<number>;
29
+ currentIndex: RefObject<number> | undefined;
28
30
  };
29
31
 
30
32
  export declare const scrollToItemDynamic: (params: ScrollToItemDynamicParams) => void;
@@ -252,6 +254,7 @@ export declare type VirtualizerDataRef = {
252
254
  progressiveSizes: RefObject<number[]>;
253
255
  nodeSizes: RefObject<number[]>;
254
256
  setFlaggedIndex: (index: number | null) => void;
257
+ currentIndex: RefObject<number>;
255
258
  };
256
259
 
257
260
  export declare type VirtualizerMeasureDynamicProps = {
@@ -1 +1 @@
1
- {"version":3,"sources":["Virtualizer.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { VirtualizerContextProps } from '../../Utilities';\nimport type { RefObject, MutableRefObject } from 'react';\n\nexport type VirtualizerSlots = {\n /**\n * The intersection observed 'before' element will detect when scrolling towards the beginning.\n */\n before: NonNullable<Slot<'div', 'td'>>;\n /**\n * A block place holding whitespace at the beginning of current DOM children.\n */\n beforeContainer: NonNullable<Slot<'div', 'tr'>>;\n /**\n * The intersection observed 'after' element will detect when scrolling towards the end.\n */\n after: NonNullable<Slot<'div', 'td'>>;\n /**\n * A block place holding whitespace after the end of current DOM children.\n */\n afterContainer: NonNullable<Slot<'div', 'tr'>>;\n};\n\nexport type VirtualizerConfigState = {\n /**\n * The current virtualized array of children to show in the DOM.\n */\n virtualizedChildren: React.ReactNode[];\n /**\n * The current start index for the virtualizer, all previous index's will be removed from DOM.\n */\n virtualizerStartIndex: number;\n /**\n * Current buffer height required at beginning of array.\n */\n afterBufferHeight: number;\n /**\n * Current buffer height required at end of array.\n */\n beforeBufferHeight: number;\n /**\n * The total current height of the scrollView/child content.\n */\n totalVirtualizerHeight: number;\n /**\n * The scroll direction\n * @default vertical\n */\n axis?: 'vertical' | 'horizontal';\n /**\n * Tells the virtualizer to measure in the reverse direction (for column-reverse order etc.)\n */\n reversed?: boolean;\n /**\n * Pixel size of intersection observers and how much they 'cross over' into the bufferItems index.\n * Minimum 1px.\n */\n bufferSize: number;\n};\n\nexport type VirtualizerState = ComponentState<VirtualizerSlots> & VirtualizerConfigState;\n\n// Virtualizer render function to procedurally generate children elements as rows or columns via index.\n// Q: Use generic typing and passing through object data or a simple index system?\nexport type VirtualizerChildRenderFunction = (index: number, isScrolling: boolean) => React.ReactNode;\n\nexport type VirtualizerDataRef = {\n progressiveSizes: RefObject<number[]>;\n nodeSizes: RefObject<number[]>;\n setFlaggedIndex: (index: number | null) => void;\n};\n\nexport type VirtualizerConfigProps = {\n /**\n * Child render function.\n * Iteratively called to return current virtualizer DOM children.\n * Will act as a row or column indexer depending on Virtualizer settings.\n * Can be used dynamically.\n */\n children: VirtualizerChildRenderFunction;\n\n /**\n * Default cell size to use if no custom callback provided.\n * If implementing `getItemSize` this should be the initial and ideally minimum cell size.\n */\n itemSize: number;\n\n /**\n * The total number of items to be virtualized.\n */\n numItems: number;\n\n /**\n * Number of children to render in the DOM during virtualization.\n * Constraints:\n * - Large enough that the items rendered in DOM cover the viewport\n * and intersection observer buffers (buffersize) at both ends.\n */\n virtualizerLength: number;\n\n /**\n * Defaults to 1/4th of virtualizerLength.\n * Controls the number of elements rendered before the current index entering the virtualized viewport.\n * Constraints:\n * - Large enough to cover bufferSize (prevents buffers intersecting into the viewport during rest state).\n * - Small enough that the end buffer and end index (start index + virtualizerLength) is not within viewport at rest.\n */\n bufferItems?: number;\n\n /**\n * Defaults to half of bufferItems size (in pixels).\n * The length (in pixels) before the end/start DOM index where the virtualizer recalculation will be triggered.\n * Increasing this reduces whitespace on ultra-fast scroll, as additional elements\n * are buffered to appear while virtualization recalculates.\n * Constraints:\n * - At least 1px - although this will only trigger the recalculation after bookends (whitespace) enter viewport.\n * - BufferSize must be smaller than bufferItems pixel size, as it prevents bookends entering viewport at rest.\n */\n bufferSize?: number;\n\n /**\n * Enables users to override the intersectionObserverRoot.\n */\n scrollViewRef?: React.MutableRefObject<HTMLElement | null>;\n\n /**\n * The scroll direction\n * @default vertical\n */\n axis?: 'vertical' | 'horizontal';\n\n /**\n * Tells the virtualizer to measure in the reverse direction (for column-reverse order etc.)\n * This value should be flipped in RTL implementation (TBD whether automate RTL).\n */\n reversed?: boolean;\n\n /**\n * Callback for acquiring size of individual items\n * @param index - the index of the requested size's child\n */\n getItemSize?: (index: number) => number;\n\n /**\n * Virtualizer context can be passed as a prop for extended class use\n */\n virtualizerContext?: VirtualizerContextProps;\n\n /**\n * Callback for notifying when a flagged index has been rendered\n */\n onRenderedFlaggedIndex?: (index: number) => void;\n\n /*\n * Callback for notifying when a flagged index has been rendered\n */\n flaggedIndex?: MutableRefObject<number | null>;\n\n /**\n * Imperative ref contains our scrollTo index functionality for user control.\n */\n imperativeVirtualizerRef?: RefObject<VirtualizerDataRef>;\n};\n\nexport type VirtualizerProps = ComponentProps<Partial<VirtualizerSlots>> & VirtualizerConfigProps;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
1
+ {"version":3,"sources":["Virtualizer.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { VirtualizerContextProps } from '../../Utilities';\nimport type { RefObject, MutableRefObject } from 'react';\n\nexport type VirtualizerSlots = {\n /**\n * The intersection observed 'before' element will detect when scrolling towards the beginning.\n */\n before: NonNullable<Slot<'div', 'td'>>;\n /**\n * A block place holding whitespace at the beginning of current DOM children.\n */\n beforeContainer: NonNullable<Slot<'div', 'tr'>>;\n /**\n * The intersection observed 'after' element will detect when scrolling towards the end.\n */\n after: NonNullable<Slot<'div', 'td'>>;\n /**\n * A block place holding whitespace after the end of current DOM children.\n */\n afterContainer: NonNullable<Slot<'div', 'tr'>>;\n};\n\nexport type VirtualizerConfigState = {\n /**\n * The current virtualized array of children to show in the DOM.\n */\n virtualizedChildren: React.ReactNode[];\n /**\n * The current start index for the virtualizer, all previous index's will be removed from DOM.\n */\n virtualizerStartIndex: number;\n /**\n * Current buffer height required at beginning of array.\n */\n afterBufferHeight: number;\n /**\n * Current buffer height required at end of array.\n */\n beforeBufferHeight: number;\n /**\n * The total current height of the scrollView/child content.\n */\n totalVirtualizerHeight: number;\n /**\n * The scroll direction\n * @default vertical\n */\n axis?: 'vertical' | 'horizontal';\n /**\n * Tells the virtualizer to measure in the reverse direction (for column-reverse order etc.)\n */\n reversed?: boolean;\n /**\n * Pixel size of intersection observers and how much they 'cross over' into the bufferItems index.\n * Minimum 1px.\n */\n bufferSize: number;\n};\n\nexport type VirtualizerState = ComponentState<VirtualizerSlots> & VirtualizerConfigState;\n\n// Virtualizer render function to procedurally generate children elements as rows or columns via index.\n// Q: Use generic typing and passing through object data or a simple index system?\nexport type VirtualizerChildRenderFunction = (index: number, isScrolling: boolean) => React.ReactNode;\n\nexport type VirtualizerDataRef = {\n progressiveSizes: RefObject<number[]>;\n nodeSizes: RefObject<number[]>;\n setFlaggedIndex: (index: number | null) => void;\n currentIndex: RefObject<number>;\n};\n\nexport type VirtualizerConfigProps = {\n /**\n * Child render function.\n * Iteratively called to return current virtualizer DOM children.\n * Will act as a row or column indexer depending on Virtualizer settings.\n * Can be used dynamically.\n */\n children: VirtualizerChildRenderFunction;\n\n /**\n * Default cell size to use if no custom callback provided.\n * If implementing `getItemSize` this should be the initial and ideally minimum cell size.\n */\n itemSize: number;\n\n /**\n * The total number of items to be virtualized.\n */\n numItems: number;\n\n /**\n * Number of children to render in the DOM during virtualization.\n * Constraints:\n * - Large enough that the items rendered in DOM cover the viewport\n * and intersection observer buffers (buffersize) at both ends.\n */\n virtualizerLength: number;\n\n /**\n * Defaults to 1/4th of virtualizerLength.\n * Controls the number of elements rendered before the current index entering the virtualized viewport.\n * Constraints:\n * - Large enough to cover bufferSize (prevents buffers intersecting into the viewport during rest state).\n * - Small enough that the end buffer and end index (start index + virtualizerLength) is not within viewport at rest.\n */\n bufferItems?: number;\n\n /**\n * Defaults to half of bufferItems size (in pixels).\n * The length (in pixels) before the end/start DOM index where the virtualizer recalculation will be triggered.\n * Increasing this reduces whitespace on ultra-fast scroll, as additional elements\n * are buffered to appear while virtualization recalculates.\n * Constraints:\n * - At least 1px - although this will only trigger the recalculation after bookends (whitespace) enter viewport.\n * - BufferSize must be smaller than bufferItems pixel size, as it prevents bookends entering viewport at rest.\n */\n bufferSize?: number;\n\n /**\n * Enables users to override the intersectionObserverRoot.\n */\n scrollViewRef?: React.MutableRefObject<HTMLElement | null>;\n\n /**\n * The scroll direction\n * @default vertical\n */\n axis?: 'vertical' | 'horizontal';\n\n /**\n * Tells the virtualizer to measure in the reverse direction (for column-reverse order etc.)\n * This value should be flipped in RTL implementation (TBD whether automate RTL).\n */\n reversed?: boolean;\n\n /**\n * Callback for acquiring size of individual items\n * @param index - the index of the requested size's child\n */\n getItemSize?: (index: number) => number;\n\n /**\n * Virtualizer context can be passed as a prop for extended class use\n */\n virtualizerContext?: VirtualizerContextProps;\n\n /**\n * Callback for notifying when a flagged index has been rendered\n */\n onRenderedFlaggedIndex?: (index: number) => void;\n\n /*\n * Callback for notifying when a flagged index has been rendered\n */\n flaggedIndex?: MutableRefObject<number | null>;\n\n /**\n * Imperative ref contains our scrollTo index functionality for user control.\n */\n imperativeVirtualizerRef?: RefObject<VirtualizerDataRef>;\n};\n\nexport type VirtualizerProps = ComponentProps<Partial<VirtualizerSlots>> & VirtualizerConfigProps;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -7,6 +7,11 @@ import { renderVirtualizerChildPlaceholder } from './renderVirtualizer';
7
7
  export function useVirtualizer_unstable(props) {
8
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;
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
+ // We use this ref as a constant source to access the virtualizer's state imperatively
11
+ const actualIndexRef = useRef(_virtualizerContext.contextIndex);
12
+ if (actualIndexRef.current !== _virtualizerContext.contextIndex) {
13
+ actualIndexRef.current = _virtualizerContext.contextIndex;
14
+ }
10
15
  const flaggedIndex = useRef(null);
11
16
  const actualIndex = _virtualizerContext.contextIndex;
12
17
  const setActualIndex = _virtualizerContext.setContextIndex;
@@ -75,6 +80,9 @@ export function useVirtualizer_unstable(props) {
75
80
  // Local updates
76
81
  updateChildRows(index);
77
82
  updateCurrentItemSizes(index);
83
+ // Set before 'setActualIndex' call
84
+ // If it changes before render, or injected via context, re-render will update ref.
85
+ actualIndexRef.current = index;
78
86
  // State setters
79
87
  setActualIndex(index);
80
88
  };
@@ -328,7 +336,8 @@ export function useVirtualizer_unstable(props) {
328
336
  return {
329
337
  progressiveSizes: childProgressiveSizes,
330
338
  nodeSizes: childSizes,
331
- setFlaggedIndex: (index)=>flaggedIndex.current = index
339
+ setFlaggedIndex: (index)=>flaggedIndex.current = index,
340
+ currentIndex: actualIndexRef
332
341
  };
333
342
  }, [
334
343
  childProgressiveSizes,
@@ -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 { resolveShorthand } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { renderVirtualizerChildPlaceholder } from './renderVirtualizer';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n const {\n itemSize,\n numItems,\n virtualizerLength,\n children: renderChild,\n getItemSize,\n bufferItems = Math.round(virtualizerLength / 4.0),\n bufferSize = Math.floor(bufferItems / 2.0) * itemSize,\n scrollViewRef,\n axis = 'vertical',\n reversed = false,\n 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 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 scrollTimer = useRef<ReturnType<typeof setTimeout> | null>();\n const scrollCounter = useRef<number>(0);\n\n const initializeScrollingTimer = () => {\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 if (scrollTimer.current) {\n clearTimeout(scrollTimer.current);\n }\n scrollTimer.current = setTimeout(() => {\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n };\n\n useEffect(() => {\n initializeScrollingTimer();\n }, [actualIndex]);\n\n const batchUpdateNewIndex = (index: number) => {\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\n // State setters\n setActualIndex(index);\n };\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (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] = renderVirtualizerChildPlaceholder(renderChild(i, isScrolling), i);\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 };\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: resolveShorthand(props.before, {\n required: true,\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n }),\n after: resolveShorthand(props.after, {\n required: true,\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n }),\n beforeContainer: resolveShorthand(props.beforeContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n afterContainer: resolveShorthand(props.afterContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed,\n };\n}\n"],"names":["useEffect","useRef","useCallback","useReducer","useImperativeHandle","useState","useIntersectionObserver","resolveShorthand","flushSync","useVirtualizerContextState_unstable","renderVirtualizerChildPlaceholder","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","scrollViewRef","axis","reversed","virtualizerContext","onRenderedFlaggedIndex","imperativeVirtualizerRef","_virtualizerContext","flaggedIndex","actualIndex","contextIndex","setActualIndex","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","horizontal","populateSizeArrays","current","length","index","isScrolling","setIsScrolling","scrollTimer","scrollCounter","initializeScrollingTimer","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","clearTimeout","setTimeout","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","required","defaultProps","ref","role","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"mappings":"AAGA,SAASA,SAAS,EAAEC,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAEC,mBAAmB,EAAEC,QAAQ,QAAQ,QAAQ;AAClG,SAASC,uBAAuB,QAAQ,sCAAsC;AAC9E,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,mCAAmC,QAAQ,kBAAkB;AACtE,SAASC,iCAAiC,QAAQ,sBAAsB;AAExE,OAAO,SAASC,wBAAwBC,KAAuB,EAAoB;IACjF,MAAM,EACJC,SAAQ,EACRC,SAAQ,EACRC,kBAAiB,EACjBC,UAAUC,YAAW,EACrBC,YAAW,EACXC,aAAcC,KAAKC,KAAK,CAACN,oBAAoB,KAAI,EACjDO,YAAaF,KAAKG,KAAK,CAACJ,cAAc,OAAON,SAAQ,EACrDW,cAAa,EACbC,MAAO,WAAU,EACjBC,UAAW,KAAK,CAA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aAAawB,WAAWO,OAAO,CAACC,MAAM,IAAIhC,aAAa0B,sBAAsBK,OAAO,CAACC,MAAM,AAAD,GAAI;QAChH,iDAAiD;QACjDF;IACF,CAAC;IAED,iDAAiD;IACjD,MAAMiF,aAAazG,KAAKqE,GAAG,CAAC1E,mBAAmBD;IAC/C,IAAI2B,WAAWI,OAAO,CAACC,MAAM,KAAK+E,cAAc7F,cAAcS,WAAWI,OAAO,CAACC,MAAM,GAAGhC,UAAU;QAClG4C,gBAAgB1B;IAClB,CAAC;IAED,MAAM8F,qBAAqBN,eAAe3E,OAAO,IAAIb,eAAe;IACpE,OAAO;QACL+F,YAAY;YACVC,QAAQ;YACRC,OAAO;YACPC,iBAAiB;YACjBC,gBAAgB;QAClB;QACAC,qBAAqB3F,WAAWI,OAAO;QACvCmF,QAAQzH,iBAAiBK,MAAMoH,MAAM,EAAE;YACrCK,UAAU,IAAI;YACdC,cAAc;gBACZC,KAAKxB;gBACLyB,MAAM;YACR;QACF;QACAP,OAAO1H,iBAAiBK,MAAMqH,KAAK,EAAE;YACnCI,UAAU,IAAI;YACdC,cAAc;gBACZC,KAAKpB;gBACLqB,MAAM;YACR;QACF;QACAN,iBAAiB3H,iBAAiBK,MAAMsH,eAAe,EAAE;YACvDG,UAAU,IAAI;YACdC,cAAc;gBACZE,MAAM;YACR;QACF;QACAL,gBAAgB5H,iBAAiBK,MAAMuH,cAAc,EAAE;YACrDE,UAAU,IAAI;YACdC,cAAc;gBACZE,MAAM;YACR;QACF;QACAC,oBAAoBX,qBAAqB5C,oBAAoB,CAAC;QAC9DwD,mBAAmBZ,qBAAqBpD,mBAAmB,CAAC;QAC5DiE,wBAAwBb,qBAAqBnD,uBAAuB5D,oBAAoBF,QAAQ;QAChG+H,uBAAuB5G;QACvBP;QACAH;QACAI;IACF;AACF,CAAC"}
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 { resolveShorthand } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { renderVirtualizerChildPlaceholder } from './renderVirtualizer';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n const {\n itemSize,\n numItems,\n virtualizerLength,\n children: renderChild,\n getItemSize,\n bufferItems = Math.round(virtualizerLength / 4.0),\n bufferSize = Math.floor(bufferItems / 2.0) * itemSize,\n scrollViewRef,\n axis = 'vertical',\n reversed = false,\n 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 scrollTimer = useRef<ReturnType<typeof setTimeout> | null>();\n const scrollCounter = useRef<number>(0);\n\n const initializeScrollingTimer = () => {\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 if (scrollTimer.current) {\n clearTimeout(scrollTimer.current);\n }\n scrollTimer.current = setTimeout(() => {\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n };\n\n useEffect(() => {\n initializeScrollingTimer();\n }, [actualIndex]);\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 (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] = renderVirtualizerChildPlaceholder(renderChild(i, isScrolling), i);\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: resolveShorthand(props.before, {\n required: true,\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n }),\n after: resolveShorthand(props.after, {\n required: true,\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n }),\n beforeContainer: resolveShorthand(props.beforeContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n afterContainer: resolveShorthand(props.afterContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed,\n };\n}\n"],"names":["useEffect","useRef","useCallback","useReducer","useImperativeHandle","useState","useIntersectionObserver","resolveShorthand","flushSync","useVirtualizerContextState_unstable","renderVirtualizerChildPlaceholder","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","scrollTimer","scrollCounter","initializeScrollingTimer","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","clearTimeout","setTimeout","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","required","defaultProps","ref","role","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"mappings":"AAGA,SAASA,SAAS,EAAEC,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAEC,mBAAmB,EAAEC,QAAQ,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,OAAO;QACvCgG,QAAQ1H,iBAAiBK,MAAMqH,MAAM,EAAE;YACrCK,UAAU,IAAI;YACdC,cAAc;gBACZC,KAAKxB;gBACLyB,MAAM;YACR;QACF;QACAP,OAAO3H,iBAAiBK,MAAMsH,KAAK,EAAE;YACnCI,UAAU,IAAI;YACdC,cAAc;gBACZC,KAAKpB;gBACLqB,MAAM;YACR;QACF;QACAN,iBAAiB5H,iBAAiBK,MAAMuH,eAAe,EAAE;YACvDG,UAAU,IAAI;YACdC,cAAc;gBACZE,MAAM;YACR;QACF;QACAL,gBAAgB7H,iBAAiBK,MAAMwH,cAAc,EAAE;YACrDE,UAAU,IAAI;YACdC,cAAc;gBACZE,MAAM;YACR;QACF;QACAC,oBAAoBX,qBAAqB5C,oBAAoB,CAAC;QAC9DwD,mBAAmBZ,qBAAqBpD,mBAAmB,CAAC;QAC5DiE,wBAAwBb,qBAAqBnD,uBAAuB7D,oBAAoBF,QAAQ;QAChGgI,uBAAuB1G;QACvBV;QACAH;QACAI;IACF;AACF,CAAC"}
@@ -11,10 +11,16 @@ export function useVirtualizerScrollView_unstable(props) {
11
11
  defaultItemSize: props.itemSize,
12
12
  direction: (_props_axis = props.axis) !== null && _props_axis !== void 0 ? _props_axis : 'vertical'
13
13
  });
14
+ // Store the virtualizer length as a ref for imperative ref access
15
+ const virtualizerLengthRef = React.useRef(virtualizerLength);
16
+ if (virtualizerLengthRef.current !== virtualizerLength) {
17
+ virtualizerLengthRef.current = virtualizerLength;
18
+ }
14
19
  const scrollViewRef = useMergedRefs(React.useRef(null), scrollRef);
15
20
  const imperativeVirtualizerRef = React.useRef(null);
16
21
  const scrollCallbackRef = React.useRef(null);
17
22
  useImperativeHandle(imperativeRef, ()=>{
23
+ var _imperativeVirtualizerRef_current;
18
24
  return {
19
25
  scrollTo (index, behavior = 'auto', callback) {
20
26
  var _imperativeVirtualizerRef_current;
@@ -29,7 +35,9 @@ export function useVirtualizerScrollView_unstable(props) {
29
35
  reversed,
30
36
  behavior
31
37
  });
32
- }
38
+ },
39
+ currentIndex: (_imperativeVirtualizerRef_current = imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.currentIndex,
40
+ virtualizerLength: virtualizerLengthRef
33
41
  };
34
42
  }, [
35
43
  axis,
@@ -1 +1 @@
1
- {"version":3,"sources":["useVirtualizerScrollView.ts"],"sourcesContent":["import * as React from 'react';\nimport { resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';\nimport { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';\nimport type { VirtualizerScrollViewProps, VirtualizerScrollViewState } from './VirtualizerScrollView.types';\nimport { useStaticVirtualizerMeasure } from '../../Hooks';\nimport { useImperativeHandle } from 'react';\nimport { scrollToItemStatic } from '../../Utilities';\nimport type { VirtualizerDataRef } from '../Virtualizer/Virtualizer.types';\n\nexport function useVirtualizerScrollView_unstable(props: VirtualizerScrollViewProps): VirtualizerScrollViewState {\n const { imperativeRef, itemSize, numItems, axis = 'vertical', reversed } = props;\n const { virtualizerLength, bufferItems, bufferSize, scrollRef } = useStaticVirtualizerMeasure({\n defaultItemSize: props.itemSize,\n direction: props.axis ?? 'vertical',\n });\n\n const scrollViewRef = useMergedRefs(React.useRef<HTMLDivElement>(null), scrollRef) as React.RefObject<HTMLDivElement>;\n const imperativeVirtualizerRef = React.useRef<VirtualizerDataRef | null>(null);\n const scrollCallbackRef = React.useRef<null | ((index: number) => void)>(null);\n\n useImperativeHandle(\n imperativeRef,\n () => {\n return {\n scrollTo(index: number, behavior = 'auto', callback: ((index: number) => void) | undefined) {\n scrollCallbackRef.current = callback ?? null;\n imperativeVirtualizerRef.current?.setFlaggedIndex(index);\n scrollToItemStatic({\n index,\n itemSize,\n totalItems: numItems,\n scrollViewRef,\n axis,\n reversed,\n behavior,\n });\n },\n };\n },\n [axis, scrollViewRef, itemSize, numItems, reversed],\n );\n\n const handleRenderedIndex = (index: number) => {\n if (scrollCallbackRef.current) {\n scrollCallbackRef.current(index);\n }\n };\n\n const virtualizerState = useVirtualizer_unstable({\n ...props,\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollViewRef,\n onRenderedFlaggedIndex: handleRenderedIndex,\n imperativeVirtualizerRef,\n });\n\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div',\n },\n container: resolveShorthand(props.container, {\n required: true,\n defaultProps: {\n ref: scrollViewRef as React.RefObject<HTMLDivElement>,\n },\n }),\n };\n}\n"],"names":["React","resolveShorthand","useMergedRefs","useVirtualizer_unstable","useStaticVirtualizerMeasure","useImperativeHandle","scrollToItemStatic","useVirtualizerScrollView_unstable","props","imperativeRef","itemSize","numItems","axis","reversed","virtualizerLength","bufferItems","bufferSize","scrollRef","defaultItemSize","direction","scrollViewRef","useRef","imperativeVirtualizerRef","scrollCallbackRef","scrollTo","index","behavior","callback","current","setFlaggedIndex","totalItems","handleRenderedIndex","virtualizerState","onRenderedFlaggedIndex","components","container","required","defaultProps","ref"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,4BAA4B;AAC5E,SAASC,uBAAuB,QAAQ,gCAAgC;AAExE,SAASC,2BAA2B,QAAQ,cAAc;AAC1D,SAASC,mBAAmB,QAAQ,QAAQ;AAC5C,SAASC,kBAAkB,QAAQ,kBAAkB;AAGrD,OAAO,SAASC,kCAAkCC,KAAiC,EAA8B;IAC/G,MAAM,EAAEC,cAAa,EAAEC,SAAQ,EAAEC,SAAQ,EAAEC,MAAO,WAAU,EAAEC,SAAQ,EAAE,GAAGL;QAG9DA;IAFb,MAAM,EAAEM,kBAAiB,EAAEC,YAAW,EAAEC,WAAU,EAAEC,UAAS,EAAE,GAAGb,4BAA4B;QAC5Fc,iBAAiBV,MAAME,QAAQ;QAC/BS,WAAWX,CAAAA,cAAAA,MAAMI,IAAI,cAAVJ,yBAAAA,cAAc,UAAU;IACrC;IAEA,MAAMY,gBAAgBlB,cAAcF,MAAMqB,MAAM,CAAiB,IAAI,GAAGJ;IACxE,MAAMK,2BAA2BtB,MAAMqB,MAAM,CAA4B,IAAI;IAC7E,MAAME,oBAAoBvB,MAAMqB,MAAM,CAAmC,IAAI;IAE7EhB,oBACEI,eACA,IAAM;QACJ,OAAO;YACLe,UAASC,KAAa,EAAEC,WAAW,MAAM,EAAEC,QAA+C,EAAE;oBAE1FL;gBADAC,kBAAkBK,OAAO,GAAGD,qBAAAA,sBAAAA,WAAY,IAAI;gBAC5CL,CAAAA,oCAAAA,yBAAyBM,OAAO,cAAhCN,+CAAAA,KAAAA,IAAAA,kCAAkCO,gBAAgBJ;gBAClDnB,mBAAmB;oBACjBmB;oBACAf;oBACAoB,YAAYnB;oBACZS;oBACAR;oBACAC;oBACAa;gBACF;YACF;QACF;IACF,GACA;QAACd;QAAMQ;QAAeV;QAAUC;QAAUE;KAAS;IAGrD,MAAMkB,sBAAsB,CAACN,QAAkB;QAC7C,IAAIF,kBAAkBK,OAAO,EAAE;YAC7BL,kBAAkBK,OAAO,CAACH;QAC5B,CAAC;IACH;IAEA,MAAMO,mBAAmB7B,wBAAwB;QAC/C,GAAGK,KAAK;QACRM;QACAC;QACAC;QACAI;QACAa,wBAAwBF;QACxBT;IACF;IAEA,OAAO;QACL,GAAGU,gBAAgB;QACnBE,YAAY;YACV,GAAGF,iBAAiBE,UAAU;YAC9BC,WAAW;QACb;QACAA,WAAWlC,iBAAiBO,MAAM2B,SAAS,EAAE;YAC3CC,UAAU,IAAI;YACdC,cAAc;gBACZC,KAAKlB;YACP;QACF;IACF;AACF,CAAC"}
1
+ {"version":3,"sources":["useVirtualizerScrollView.ts"],"sourcesContent":["import * as React from 'react';\nimport { resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';\nimport { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';\nimport type { VirtualizerScrollViewProps, VirtualizerScrollViewState } from './VirtualizerScrollView.types';\nimport { useStaticVirtualizerMeasure } from '../../Hooks';\nimport { useImperativeHandle } from 'react';\nimport { scrollToItemStatic } from '../../Utilities';\nimport type { VirtualizerDataRef } from '../Virtualizer/Virtualizer.types';\n\nexport function useVirtualizerScrollView_unstable(props: VirtualizerScrollViewProps): VirtualizerScrollViewState {\n const { imperativeRef, itemSize, numItems, axis = 'vertical', reversed } = props;\n const { virtualizerLength, bufferItems, bufferSize, scrollRef } = useStaticVirtualizerMeasure({\n defaultItemSize: props.itemSize,\n direction: props.axis ?? 'vertical',\n });\n\n // Store the virtualizer length as a ref for imperative ref access\n const virtualizerLengthRef = React.useRef<number>(virtualizerLength);\n if (virtualizerLengthRef.current !== virtualizerLength) {\n virtualizerLengthRef.current = virtualizerLength;\n }\n const scrollViewRef = useMergedRefs(React.useRef<HTMLDivElement>(null), scrollRef) as React.RefObject<HTMLDivElement>;\n const imperativeVirtualizerRef = React.useRef<VirtualizerDataRef | null>(null);\n const scrollCallbackRef = React.useRef<null | ((index: number) => void)>(null);\n\n useImperativeHandle(\n imperativeRef,\n () => {\n return {\n scrollTo(index: number, behavior = 'auto', callback: ((index: number) => void) | undefined) {\n scrollCallbackRef.current = callback ?? null;\n imperativeVirtualizerRef.current?.setFlaggedIndex(index);\n scrollToItemStatic({\n index,\n itemSize,\n totalItems: numItems,\n scrollViewRef,\n axis,\n reversed,\n behavior,\n });\n },\n currentIndex: imperativeVirtualizerRef.current?.currentIndex,\n virtualizerLength: virtualizerLengthRef,\n };\n },\n [axis, scrollViewRef, itemSize, numItems, reversed],\n );\n\n const handleRenderedIndex = (index: number) => {\n if (scrollCallbackRef.current) {\n scrollCallbackRef.current(index);\n }\n };\n\n const virtualizerState = useVirtualizer_unstable({\n ...props,\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollViewRef,\n onRenderedFlaggedIndex: handleRenderedIndex,\n imperativeVirtualizerRef,\n });\n\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div',\n },\n container: resolveShorthand(props.container, {\n required: true,\n defaultProps: {\n ref: scrollViewRef as React.RefObject<HTMLDivElement>,\n },\n }),\n };\n}\n"],"names":["React","resolveShorthand","useMergedRefs","useVirtualizer_unstable","useStaticVirtualizerMeasure","useImperativeHandle","scrollToItemStatic","useVirtualizerScrollView_unstable","props","imperativeRef","itemSize","numItems","axis","reversed","virtualizerLength","bufferItems","bufferSize","scrollRef","defaultItemSize","direction","virtualizerLengthRef","useRef","current","scrollViewRef","imperativeVirtualizerRef","scrollCallbackRef","scrollTo","index","behavior","callback","setFlaggedIndex","totalItems","currentIndex","handleRenderedIndex","virtualizerState","onRenderedFlaggedIndex","components","container","required","defaultProps","ref"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,4BAA4B;AAC5E,SAASC,uBAAuB,QAAQ,gCAAgC;AAExE,SAASC,2BAA2B,QAAQ,cAAc;AAC1D,SAASC,mBAAmB,QAAQ,QAAQ;AAC5C,SAASC,kBAAkB,QAAQ,kBAAkB;AAGrD,OAAO,SAASC,kCAAkCC,KAAiC,EAA8B;IAC/G,MAAM,EAAEC,cAAa,EAAEC,SAAQ,EAAEC,SAAQ,EAAEC,MAAO,WAAU,EAAEC,SAAQ,EAAE,GAAGL;QAG9DA;IAFb,MAAM,EAAEM,kBAAiB,EAAEC,YAAW,EAAEC,WAAU,EAAEC,UAAS,EAAE,GAAGb,4BAA4B;QAC5Fc,iBAAiBV,MAAME,QAAQ;QAC/BS,WAAWX,CAAAA,cAAAA,MAAMI,IAAI,cAAVJ,yBAAAA,cAAc,UAAU;IACrC;IAEA,kEAAkE;IAClE,MAAMY,uBAAuBpB,MAAMqB,MAAM,CAASP;IAClD,IAAIM,qBAAqBE,OAAO,KAAKR,mBAAmB;QACtDM,qBAAqBE,OAAO,GAAGR;IACjC,CAAC;IACD,MAAMS,gBAAgBrB,cAAcF,MAAMqB,MAAM,CAAiB,IAAI,GAAGJ;IACxE,MAAMO,2BAA2BxB,MAAMqB,MAAM,CAA4B,IAAI;IAC7E,MAAMI,oBAAoBzB,MAAMqB,MAAM,CAAmC,IAAI;IAE7EhB,oBACEI,eACA,IAAM;YAeYe;QAdhB,OAAO;YACLE,UAASC,KAAa,EAAEC,WAAW,MAAM,EAAEC,QAA+C,EAAE;oBAE1FL;gBADAC,kBAAkBH,OAAO,GAAGO,qBAAAA,sBAAAA,WAAY,IAAI;gBAC5CL,CAAAA,oCAAAA,yBAAyBF,OAAO,cAAhCE,+CAAAA,KAAAA,IAAAA,kCAAkCM,gBAAgBH;gBAClDrB,mBAAmB;oBACjBqB;oBACAjB;oBACAqB,YAAYpB;oBACZY;oBACAX;oBACAC;oBACAe;gBACF;YACF;YACAI,cAAcR,CAAAA,oCAAAA,yBAAyBF,OAAO,cAAhCE,+CAAAA,KAAAA,IAAAA,kCAAkCQ,YAAY;YAC5DlB,mBAAmBM;QACrB;IACF,GACA;QAACR;QAAMW;QAAeb;QAAUC;QAAUE;KAAS;IAGrD,MAAMoB,sBAAsB,CAACN,QAAkB;QAC7C,IAAIF,kBAAkBH,OAAO,EAAE;YAC7BG,kBAAkBH,OAAO,CAACK;QAC5B,CAAC;IACH;IAEA,MAAMO,mBAAmB/B,wBAAwB;QAC/C,GAAGK,KAAK;QACRM;QACAC;QACAC;QACAO;QACAY,wBAAwBF;QACxBT;IACF;IAEA,OAAO;QACL,GAAGU,gBAAgB;QACnBE,YAAY;YACV,GAAGF,iBAAiBE,UAAU;YAC9BC,WAAW;QACb;QACAA,WAAWpC,iBAAiBO,MAAM6B,SAAS,EAAE;YAC3CC,UAAU,IAAI;YACdC,cAAc;gBACZC,KAAKjB;YACP;QACF;IACF;AACF,CAAC"}
@@ -15,10 +15,16 @@ export function useVirtualizerScrollViewDynamic_unstable(props) {
15
15
  currentIndex: (_contextState_contextIndex = contextState === null || contextState === void 0 ? void 0 : contextState.contextIndex) !== null && _contextState_contextIndex !== void 0 ? _contextState_contextIndex : 0,
16
16
  numItems: props.numItems
17
17
  });
18
+ // Store the virtualizer length as a ref for imperative ref access
19
+ const virtualizerLengthRef = React.useRef(virtualizerLength);
20
+ if (virtualizerLengthRef.current !== virtualizerLength) {
21
+ virtualizerLengthRef.current = virtualizerLength;
22
+ }
18
23
  const scrollViewRef = useMergedRefs(React.useRef(null), scrollRef);
19
24
  const scrollCallbackRef = React.useRef(null);
20
25
  const _imperativeVirtualizerRef = useMergedRefs(React.useRef(null), imperativeVirtualizerRef);
21
26
  useImperativeHandle(imperativeRef, ()=>{
27
+ var _imperativeVirtualizerRef_current;
22
28
  return {
23
29
  scrollTo (index, behavior = 'auto', callback) {
24
30
  scrollCallbackRef.current = callback !== null && callback !== void 0 ? callback : null;
@@ -37,7 +43,9 @@ export function useVirtualizerScrollViewDynamic_unstable(props) {
37
43
  behavior
38
44
  });
39
45
  }
40
- }
46
+ },
47
+ currentIndex: (_imperativeVirtualizerRef_current = _imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.currentIndex,
48
+ virtualizerLength: virtualizerLengthRef
41
49
  };
42
50
  }, [
43
51
  axis,
@@ -1 +1 @@
1
- {"version":3,"sources":["useVirtualizerScrollViewDynamic.ts"],"sourcesContent":["import * as React from 'react';\nimport { resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';\nimport { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';\nimport type {\n VirtualizerScrollViewDynamicProps,\n VirtualizerScrollViewDynamicState,\n} from './VirtualizerScrollViewDynamic.types';\nimport { useDynamicVirtualizerMeasure } from '../../Hooks';\nimport { useVirtualizerContextState_unstable, scrollToItemDynamic } from '../../Utilities';\nimport type { VirtualizerDataRef } from '../Virtualizer/Virtualizer.types';\nimport { useImperativeHandle } from 'react';\n\nexport function useVirtualizerScrollViewDynamic_unstable(\n props: VirtualizerScrollViewDynamicProps,\n): VirtualizerScrollViewDynamicState {\n const contextState = useVirtualizerContextState_unstable(props.virtualizerContext);\n const { imperativeRef, axis = 'vertical', reversed, imperativeVirtualizerRef } = props;\n\n const { virtualizerLength, bufferItems, bufferSize, scrollRef } = useDynamicVirtualizerMeasure({\n defaultItemSize: props.itemSize,\n direction: props.axis ?? 'vertical',\n getItemSize: props.getItemSize,\n currentIndex: contextState?.contextIndex ?? 0,\n numItems: props.numItems,\n });\n\n const scrollViewRef = useMergedRefs(React.useRef<HTMLDivElement>(null), scrollRef) as React.RefObject<HTMLDivElement>;\n const scrollCallbackRef = React.useRef<null | ((index: number) => void)>(null);\n\n const _imperativeVirtualizerRef = useMergedRefs(React.useRef<VirtualizerDataRef>(null), imperativeVirtualizerRef);\n\n useImperativeHandle(\n imperativeRef,\n () => {\n return {\n scrollTo(index: number, behavior = 'auto', callback: undefined | ((index: number) => void)) {\n scrollCallbackRef.current = callback ?? null;\n if (_imperativeVirtualizerRef.current) {\n const progressiveSizes = _imperativeVirtualizerRef.current.progressiveSizes.current;\n const totalSize =\n progressiveSizes && progressiveSizes?.length > 0\n ? progressiveSizes[Math.max(progressiveSizes.length - 1, 0)]\n : 0;\n\n _imperativeVirtualizerRef.current.setFlaggedIndex(index);\n scrollToItemDynamic({\n index,\n itemSizes: _imperativeVirtualizerRef.current?.nodeSizes,\n totalSize,\n scrollViewRef,\n axis,\n reversed,\n behavior,\n });\n }\n },\n };\n },\n [axis, scrollViewRef, reversed, _imperativeVirtualizerRef],\n );\n\n const handleRenderedIndex = (index: number) => {\n if (scrollCallbackRef.current) {\n scrollCallbackRef.current(index);\n }\n };\n\n const virtualizerState = useVirtualizer_unstable({\n ...props,\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollViewRef,\n virtualizerContext: contextState,\n imperativeVirtualizerRef: _imperativeVirtualizerRef,\n onRenderedFlaggedIndex: handleRenderedIndex,\n });\n\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div',\n },\n container: resolveShorthand(props.container, {\n required: true,\n defaultProps: {\n ref: scrollViewRef,\n },\n }),\n };\n}\n"],"names":["React","resolveShorthand","useMergedRefs","useVirtualizer_unstable","useDynamicVirtualizerMeasure","useVirtualizerContextState_unstable","scrollToItemDynamic","useImperativeHandle","useVirtualizerScrollViewDynamic_unstable","props","contextState","virtualizerContext","imperativeRef","axis","reversed","imperativeVirtualizerRef","virtualizerLength","bufferItems","bufferSize","scrollRef","defaultItemSize","itemSize","direction","getItemSize","currentIndex","contextIndex","numItems","scrollViewRef","useRef","scrollCallbackRef","_imperativeVirtualizerRef","scrollTo","index","behavior","callback","current","progressiveSizes","totalSize","length","Math","max","setFlaggedIndex","itemSizes","nodeSizes","handleRenderedIndex","virtualizerState","onRenderedFlaggedIndex","components","container","required","defaultProps","ref"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,4BAA4B;AAC5E,SAASC,uBAAuB,QAAQ,gCAAgC;AAKxE,SAASC,4BAA4B,QAAQ,cAAc;AAC3D,SAASC,mCAAmC,EAAEC,mBAAmB,QAAQ,kBAAkB;AAE3F,SAASC,mBAAmB,QAAQ,QAAQ;AAE5C,OAAO,SAASC,yCACdC,KAAwC,EACL;IACnC,MAAMC,eAAeL,oCAAoCI,MAAME,kBAAkB;IACjF,MAAM,EAAEC,cAAa,EAAEC,MAAO,WAAU,EAAEC,SAAQ,EAAEC,yBAAwB,EAAE,GAAGN;QAIpEA,aAEGC;IAJhB,MAAM,EAAEM,kBAAiB,EAAEC,YAAW,EAAEC,WAAU,EAAEC,UAAS,EAAE,GAAGf,6BAA6B;QAC7FgB,iBAAiBX,MAAMY,QAAQ;QAC/BC,WAAWb,CAAAA,cAAAA,MAAMI,IAAI,cAAVJ,yBAAAA,cAAc,UAAU;QACnCc,aAAad,MAAMc,WAAW;QAC9BC,cAAcd,CAAAA,6BAAAA,yBAAAA,0BAAAA,KAAAA,IAAAA,aAAce,YAAY,cAA1Bf,wCAAAA,6BAA8B,CAAC;QAC7CgB,UAAUjB,MAAMiB,QAAQ;IAC1B;IAEA,MAAMC,gBAAgBzB,cAAcF,MAAM4B,MAAM,CAAiB,IAAI,GAAGT;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uC,SAAS,EAAE;YAC3CC,UAAU,IAAI;YACdC,cAAc;gBACZC,KAAKxB;YACP;QACF;IACF;AACF,CAAC"}
1
+ {"version":3,"sources":["useVirtualizerScrollViewDynamic.ts"],"sourcesContent":["import * as React from 'react';\nimport { resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';\nimport { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';\nimport type {\n VirtualizerScrollViewDynamicProps,\n VirtualizerScrollViewDynamicState,\n} from './VirtualizerScrollViewDynamic.types';\nimport { useDynamicVirtualizerMeasure } from '../../Hooks';\nimport { useVirtualizerContextState_unstable, scrollToItemDynamic } from '../../Utilities';\nimport type { VirtualizerDataRef } from '../Virtualizer/Virtualizer.types';\nimport { useImperativeHandle } from 'react';\n\nexport function useVirtualizerScrollViewDynamic_unstable(\n props: VirtualizerScrollViewDynamicProps,\n): VirtualizerScrollViewDynamicState {\n const contextState = useVirtualizerContextState_unstable(props.virtualizerContext);\n const { imperativeRef, axis = 'vertical', reversed, imperativeVirtualizerRef } = props;\n\n const { virtualizerLength, bufferItems, bufferSize, scrollRef } = useDynamicVirtualizerMeasure({\n defaultItemSize: props.itemSize,\n direction: props.axis ?? 'vertical',\n getItemSize: props.getItemSize,\n currentIndex: contextState?.contextIndex ?? 0,\n numItems: props.numItems,\n });\n\n // Store the virtualizer length as a ref for imperative ref access\n const virtualizerLengthRef = React.useRef<number>(virtualizerLength);\n if (virtualizerLengthRef.current !== virtualizerLength) {\n virtualizerLengthRef.current = virtualizerLength;\n }\n const scrollViewRef = useMergedRefs(React.useRef<HTMLDivElement>(null), scrollRef) as React.RefObject<HTMLDivElement>;\n const scrollCallbackRef = React.useRef<null | ((index: number) => void)>(null);\n\n const _imperativeVirtualizerRef = useMergedRefs(React.useRef<VirtualizerDataRef>(null), imperativeVirtualizerRef);\n\n useImperativeHandle(\n imperativeRef,\n () => {\n return {\n scrollTo(index: number, behavior = 'auto', callback: undefined | ((index: number) => void)) {\n scrollCallbackRef.current = callback ?? null;\n if (_imperativeVirtualizerRef.current) {\n const progressiveSizes = _imperativeVirtualizerRef.current.progressiveSizes.current;\n const totalSize =\n progressiveSizes && progressiveSizes?.length > 0\n ? progressiveSizes[Math.max(progressiveSizes.length - 1, 0)]\n : 0;\n\n _imperativeVirtualizerRef.current.setFlaggedIndex(index);\n scrollToItemDynamic({\n index,\n itemSizes: _imperativeVirtualizerRef.current?.nodeSizes,\n totalSize,\n scrollViewRef,\n axis,\n reversed,\n behavior,\n });\n }\n },\n currentIndex: _imperativeVirtualizerRef.current?.currentIndex,\n virtualizerLength: virtualizerLengthRef,\n };\n },\n [axis, scrollViewRef, reversed, _imperativeVirtualizerRef],\n );\n\n const handleRenderedIndex = (index: number) => {\n if (scrollCallbackRef.current) {\n scrollCallbackRef.current(index);\n }\n };\n\n const virtualizerState = useVirtualizer_unstable({\n ...props,\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollViewRef,\n virtualizerContext: contextState,\n imperativeVirtualizerRef: _imperativeVirtualizerRef,\n onRenderedFlaggedIndex: handleRenderedIndex,\n });\n\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div',\n },\n container: resolveShorthand(props.container, {\n required: true,\n defaultProps: {\n ref: scrollViewRef,\n },\n }),\n };\n}\n"],"names":["React","resolveShorthand","useMergedRefs","useVirtualizer_unstable","useDynamicVirtualizerMeasure","useVirtualizerContextState_unstable","scrollToItemDynamic","useImperativeHandle","useVirtualizerScrollViewDynamic_unstable","props","contextState","virtualizerContext","imperativeRef","axis","reversed","imperativeVirtualizerRef","virtualizerLength","bufferItems","bufferSize","scrollRef","defaultItemSize","itemSize","direction","getItemSize","currentIndex","contextIndex","numItems","virtualizerLengthRef","useRef","current","scrollViewRef","scrollCallbackRef","_imperativeVirtualizerRef","scrollTo","index","behavior","callback","progressiveSizes","totalSize","length","Math","max","setFlaggedIndex","itemSizes","nodeSizes","handleRenderedIndex","virtualizerState","onRenderedFlaggedIndex","components","container","required","defaultProps","ref"],"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 -1 +1 @@
1
- {"version":3,"sources":["imperativeScrolling.types.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nexport type ScrollToItemStaticParams = {\n index: number;\n itemSize: number;\n totalItems: number;\n scrollViewRef: RefObject<HTMLDivElement>;\n axis?: 'horizontal' | 'vertical';\n reversed?: boolean;\n behavior?: ScrollBehavior;\n};\n\nexport type ScrollToItemDynamicParams = {\n index: number;\n itemSizes: RefObject<number[]>;\n totalSize: number;\n scrollViewRef: RefObject<HTMLDivElement>;\n axis?: 'horizontal' | 'vertical';\n reversed?: boolean;\n behavior?: ScrollBehavior;\n};\n\nexport type ScrollToInterface = {\n scrollTo: (index: number, behavior?: ScrollBehavior, callback?: (index: number) => void) => void;\n};\n"],"names":[],"mappings":"AAAA,WAwBE"}
1
+ {"version":3,"sources":["imperativeScrolling.types.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nexport type ScrollToItemStaticParams = {\n index: number;\n itemSize: number;\n totalItems: number;\n scrollViewRef: RefObject<HTMLDivElement>;\n axis?: 'horizontal' | 'vertical';\n reversed?: boolean;\n behavior?: ScrollBehavior;\n};\n\nexport type ScrollToItemDynamicParams = {\n index: number;\n itemSizes: RefObject<number[]>;\n totalSize: number;\n scrollViewRef: RefObject<HTMLDivElement>;\n axis?: 'horizontal' | 'vertical';\n reversed?: boolean;\n behavior?: ScrollBehavior;\n};\n\nexport type ScrollToInterface = {\n scrollTo: (index: number, behavior?: ScrollBehavior, callback?: (index: number) => void) => void;\n virtualizerLength: RefObject<number>;\n currentIndex: RefObject<number> | undefined;\n};\n"],"names":[],"mappings":"AAAA,WA0BE"}
@@ -15,6 +15,11 @@ const _renderVirtualizer = require("./renderVirtualizer");
15
15
  function useVirtualizer_unstable(props) {
16
16
  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;
17
17
  /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/ const _virtualizerContext = (0, _utilities.useVirtualizerContextState_unstable)(virtualizerContext);
18
+ // We use this ref as a constant source to access the virtualizer's state imperatively
19
+ const actualIndexRef = (0, _react.useRef)(_virtualizerContext.contextIndex);
20
+ if (actualIndexRef.current !== _virtualizerContext.contextIndex) {
21
+ actualIndexRef.current = _virtualizerContext.contextIndex;
22
+ }
18
23
  const flaggedIndex = (0, _react.useRef)(null);
19
24
  const actualIndex = _virtualizerContext.contextIndex;
20
25
  const setActualIndex = _virtualizerContext.setContextIndex;
@@ -83,6 +88,9 @@ function useVirtualizer_unstable(props) {
83
88
  // Local updates
84
89
  updateChildRows(index);
85
90
  updateCurrentItemSizes(index);
91
+ // Set before 'setActualIndex' call
92
+ // If it changes before render, or injected via context, re-render will update ref.
93
+ actualIndexRef.current = index;
86
94
  // State setters
87
95
  setActualIndex(index);
88
96
  };
@@ -336,7 +344,8 @@ function useVirtualizer_unstable(props) {
336
344
  return {
337
345
  progressiveSizes: childProgressiveSizes,
338
346
  nodeSizes: childSizes,
339
- setFlaggedIndex: (index)=>flaggedIndex.current = index
347
+ setFlaggedIndex: (index)=>flaggedIndex.current = index,
348
+ currentIndex: actualIndexRef
340
349
  };
341
350
  }, [
342
351
  childProgressiveSizes,
@@ -1 +1 @@
1
- {"version":3,"sources":["useVirtualizer.js"],"sourcesContent":["import { useEffect, useRef, useCallback, useReducer, useImperativeHandle, useState } from 'react';\nimport { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { renderVirtualizerChildPlaceholder } from './renderVirtualizer';\nexport function useVirtualizer_unstable(props) {\n 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;\n /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/ const _virtualizerContext = useVirtualizerContextState_unstable(virtualizerContext);\n const flaggedIndex = useRef(null);\n const actualIndex = _virtualizerContext.contextIndex;\n const setActualIndex = _virtualizerContext.setContextIndex;\n // Store ref to before padding element\n const beforeElementRef = useRef(null);\n // Store ref to before padding element\n const afterElementRef = useRef(null);\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef(new Array(getItemSize ? numItems : 0));\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */ const childProgressiveSizes = useRef(new Array(getItemSize ? numItems : 0));\n // The internal tracking REF for child array (updates often).\n const childArray = useRef(new Array(virtualizerLength));\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(()=>({}), {})[1];\n const horizontal = axis === 'horizontal';\n const populateSizeArrays = ()=>{\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array(numItems);\n }\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array(numItems);\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 const [isScrolling, setIsScrolling] = useState(false);\n const scrollTimer = useRef();\n const scrollCounter = useRef(0);\n const initializeScrollingTimer = ()=>{\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 */ const INIT_SCROLL_FLAG_REQ = 10;\n const INIT_SCROLL_FLAG_DELAY = 100;\n scrollCounter.current++;\n if (scrollCounter.current >= INIT_SCROLL_FLAG_REQ) {\n setIsScrolling(true);\n }\n if (scrollTimer.current) {\n clearTimeout(scrollTimer.current);\n }\n scrollTimer.current = setTimeout(()=>{\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n };\n useEffect(()=>{\n initializeScrollingTimer();\n }, [\n actualIndex\n ]);\n const batchUpdateNewIndex = (index)=>{\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\n // State setters\n setActualIndex(index);\n };\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver((entries, observer)=>{\n /* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {\n if (actualIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n /* IO initiates this function when needed (bookend entering view) */ let measurementPos = 0;\n let bufferCount = bufferItems;\n // Grab latest entry that is intersecting\n const latestEntry = entries.length === 1 ? entries[0] : entries.sort((entry1, entry2)=>entry2.time - entry1.time).find((entry)=>{\n return entry.intersectionRatio > 0;\n });\n if (!latestEntry) {\n // If we don't find an intersecting area, ignore for now.\n return;\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 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 // 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 // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n if (actualIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n flushSync(()=>{\n batchUpdateNewIndex(newStartIndex);\n });\n }\n }, {\n root: scrollViewRef ? scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current : null,\n rootMargin: '0px',\n threshold: 0\n });\n const findIndexRecursive = (scrollPos, lowIndex, highIndex)=>{\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. */ return midpoint;\n }\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n const getIndexFromSizeArray = (scrollPos)=>{\n /* Quick searches our progressive height array */ if (scrollPos === 0 || childProgressiveSizes.current.length === 0 || scrollPos <= childProgressiveSizes.current[0]) {\n // Check start\n return 0;\n }\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n const getIndexFromScrollPosition = (scrollPos)=>{\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n return getIndexFromSizeArray(scrollPos);\n };\n const calculateTotalSize = useCallback(()=>{\n if (!getItemSize) {\n return itemSize * numItems;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n }, [\n getItemSize,\n itemSize,\n numItems\n ]);\n const calculateBefore = useCallback(()=>{\n const currentIndex = Math.min(actualIndex, numItems - 1);\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return currentIndex * itemSize;\n }\n if (currentIndex <= 0) {\n return 0;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[currentIndex - 1];\n }, [\n actualIndex,\n getItemSize,\n itemSize,\n numItems\n ]);\n const calculateAfter = useCallback(()=>{\n if (numItems === 0 || actualIndex + virtualizerLength >= numItems) {\n return 0;\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 // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];\n }, [\n actualIndex,\n getItemSize,\n itemSize,\n numItems,\n virtualizerLength\n ]);\n const updateChildRows = useCallback((newIndex)=>{\n if (numItems === 0) {\n /* Nothing to virtualize */ return;\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 */ 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] = renderVirtualizerChildPlaceholder(renderChild(i, isScrolling), i);\n }\n }, [\n isScrolling,\n numItems,\n renderChild,\n virtualizerLength\n ]);\n const setBeforeRef = useCallback((element)=>{\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n newList.push(beforeElementRef.current);\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n // Ensure we update array if before element changed\n setObserverList(newList);\n }, [\n setObserverList\n ]);\n const setAfterRef = useCallback((element)=>{\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n newList.push(afterElementRef.current);\n // Ensure we update array if after element changed\n setObserverList(newList);\n }, [\n setObserverList\n ]);\n const updateCurrentItemSizes = (newIndex)=>{\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 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 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 // Initialize the size array before first render.\n const hasInitialized = useRef(false);\n const initializeSizeArray = ()=>{\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n useImperativeHandle(imperativeVirtualizerRef, ()=>{\n return {\n progressiveSizes: childProgressiveSizes,\n nodeSizes: childSizes,\n setFlaggedIndex: (index)=>flaggedIndex.current = index\n };\n }, [\n childProgressiveSizes,\n childSizes\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 // 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 }, [\n renderChild,\n updateChildRows\n ]);\n useEffect(()=>{\n // Ensure we repopulate if getItemSize callback changes\n populateSizeArrays();\n // We only run this effect on getItemSize change (recalc dynamic sizes)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\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 }, [\n actualIndex,\n onRenderedFlaggedIndex,\n virtualizerLength\n ]);\n // Ensure we have run through and updated the whole size list array at least once.\n initializeSizeArray();\n if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {\n // Child length mismatch, repopulate size arrays.\n populateSizeArrays();\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 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: resolveShorthand(props.before, {\n required: true,\n defaultProps: {\n ref: setBeforeRef,\n role: 'none'\n }\n }),\n after: resolveShorthand(props.after, {\n required: true,\n defaultProps: {\n ref: setAfterRef,\n role: 'none'\n }\n }),\n beforeContainer: resolveShorthand(props.beforeContainer, {\n required: true,\n defaultProps: {\n role: 'none'\n }\n }),\n afterContainer: resolveShorthand(props.afterContainer, {\n required: true,\n defaultProps: {\n role: 'none'\n }\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed\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","flaggedIndex","useRef","actualIndex","contextIndex","setActualIndex","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","useReducer","horizontal","populateSizeArrays","current","length","index","isScrolling","setIsScrolling","useState","scrollTimer","scrollCounter","initializeScrollingTimer","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","clearTimeout","setTimeout","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","useCallback","currentIndex","lastItemIndex","remainingItems","newIndex","_actualIndex","end","i","renderVirtualizerChildPlaceholder","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","useImperativeHandle","progressiveSizes","nodeSizes","setFlaggedIndex","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","resolveShorthand","required","defaultProps","ref","role","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"mappings":";;;;+BAMgBA;;aAAAA;;uBAN0E;yCAClD;gCACP;0BACP;2BAC0B;mCACF;AAC3C,SAASA,wBAAwBC,KAAK,EAAE;IAC3C,MAAM,EAAEC,SAAQ,EAAGC,SAAQ,EAAGC,kBAAiB,EAAGC,UAAUC,YAAW,EAAGC,YAAW,EAAGC,aAAaC,KAAKC,KAAK,CAACN,oBAAoB,KAAI,EAAGO,YAAYF,KAAKG,KAAK,CAACJ,cAAc,OAAON,SAAQ,EAAGW,cAAa,EAAGC,MAAM,WAAU,EAAGC,UAAU,KAAK,CAAA,EAAGC,mBAAkB,EAAGC,uBAAsB,EAAGC,yBAAwB,EAAG,GAAGjB;IACnU,iHAAiH,GAAG,MAAMkB,sBAAsBC,IAAAA,8CAAmC,EAACJ;IACpL,MAAMK,eAAeC,IAAAA,aAAM,EAAC,IAAI;IAChC,MAAMC,cAAcJ,oBAAoBK,YAAY;IACpD,MAAMC,iBAAiBN,oBAAoBO,eAAe;IAC1D,sCAAsC;IACtC,MAAMC,mBAAmBL,IAAAA,aAAM,EAAC,IAAI;IACpC,sCAAsC;IACtC,MAAMM,kBAAkBN,IAAAA,aAAM,EAAC,IAAI;IACnC,oGAAoG;IACpG,MAAMO,aAAaP,IAAAA,aAAM,EAAC,IAAIQ,MAAMvB,cAAcJ,WAAW,CAAC;IAC9D;kEAC8D,GAAG,MAAM4B,wBAAwBT,IAAAA,aAAM,EAAC,IAAIQ,MAAMvB,cAAcJ,WAAW,CAAC;IAC1I,6DAA6D;IAC7D,MAAM6B,aAAaV,IAAAA,aAAM,EAAC,IA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BAAqBP,eAAejF,OAAO,IAAId,eAAe;IACpE,OAAO;QACHuG,YAAY;YACRC,QAAQ;YACRC,OAAO;YACPC,iBAAiB;YACjBC,gBAAgB;QACpB;QACAC,qBAAqBnG,WAAWK,OAAO;QACvC0F,QAAQK,IAAAA,gCAAgB,EAACnI,MAAM8H,MAAM,EAAE;YACnCM,UAAU,IAAI;YACdC,cAAc;gBACVC,KAAK1B;gBACL2B,MAAM;YACV;QACJ;QACAR,OAAOI,IAAAA,gCAAgB,EAACnI,MAAM+H,KAAK,EAAE;YACjCK,UAAU,IAAI;YACdC,cAAc;gBACVC,KAAKtB;gBACLuB,MAAM;YACV;QACJ;QACAP,iBAAiBG,IAAAA,gCAAgB,EAACnI,MAAMgI,eAAe,EAAE;YACrDI,UAAU,IAAI;YACdC,cAAc;gBACVE,MAAM;YACV;QACJ;QACAN,gBAAgBE,IAAAA,gCAAgB,EAACnI,MAAMiI,cAAc,EAAE;YACnDG,UAAU,IAAI;YACdC,cAAc;gBACVE,MAAM;YACV;QACJ;QACAC,oBAAoBZ,qBAAqBhD,oBAAoB,CAAC;QAC9D6D,mBAAmBb,qBAAqBxD,mBAAmB,CAAC;QAC5DsE,wBAAwBd,qBAAqBvD,uBAAuBlE,oBAAoBF,QAAQ;QAChG0I,uBAAuBrH;QACvBT;QACAH;QACAI;IACJ;AACJ"}
1
+ {"version":3,"sources":["useVirtualizer.js"],"sourcesContent":["import { useEffect, useRef, useCallback, useReducer, useImperativeHandle, useState } from 'react';\nimport { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { renderVirtualizerChildPlaceholder } from './renderVirtualizer';\nexport function useVirtualizer_unstable(props) {\n 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;\n /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/ const _virtualizerContext = useVirtualizerContextState_unstable(virtualizerContext);\n // We use this ref as a constant source to access the virtualizer's state imperatively\n const actualIndexRef = useRef(_virtualizerContext.contextIndex);\n if (actualIndexRef.current !== _virtualizerContext.contextIndex) {\n actualIndexRef.current = _virtualizerContext.contextIndex;\n }\n const flaggedIndex = useRef(null);\n const actualIndex = _virtualizerContext.contextIndex;\n const setActualIndex = _virtualizerContext.setContextIndex;\n // Store ref to before padding element\n const beforeElementRef = useRef(null);\n // Store ref to before padding element\n const afterElementRef = useRef(null);\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef(new Array(getItemSize ? numItems : 0));\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */ const childProgressiveSizes = useRef(new Array(getItemSize ? numItems : 0));\n // The internal tracking REF for child array (updates often).\n const childArray = useRef(new Array(virtualizerLength));\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(()=>({}), {})[1];\n const horizontal = axis === 'horizontal';\n const populateSizeArrays = ()=>{\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array(numItems);\n }\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array(numItems);\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 const [isScrolling, setIsScrolling] = useState(false);\n const scrollTimer = useRef();\n const scrollCounter = useRef(0);\n const initializeScrollingTimer = ()=>{\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 */ const INIT_SCROLL_FLAG_REQ = 10;\n const INIT_SCROLL_FLAG_DELAY = 100;\n scrollCounter.current++;\n if (scrollCounter.current >= INIT_SCROLL_FLAG_REQ) {\n setIsScrolling(true);\n }\n if (scrollTimer.current) {\n clearTimeout(scrollTimer.current);\n }\n scrollTimer.current = setTimeout(()=>{\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n };\n useEffect(()=>{\n initializeScrollingTimer();\n }, [\n actualIndex\n ]);\n const batchUpdateNewIndex = (index)=>{\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\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 // State setters\n setActualIndex(index);\n };\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver((entries, observer)=>{\n /* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {\n if (actualIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n /* IO initiates this function when needed (bookend entering view) */ let measurementPos = 0;\n let bufferCount = bufferItems;\n // Grab latest entry that is intersecting\n const latestEntry = entries.length === 1 ? entries[0] : entries.sort((entry1, entry2)=>entry2.time - entry1.time).find((entry)=>{\n return entry.intersectionRatio > 0;\n });\n if (!latestEntry) {\n // If we don't find an intersecting area, ignore for now.\n return;\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 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 // 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 // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n if (actualIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n flushSync(()=>{\n batchUpdateNewIndex(newStartIndex);\n });\n }\n }, {\n root: scrollViewRef ? scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current : null,\n rootMargin: '0px',\n threshold: 0\n });\n const findIndexRecursive = (scrollPos, lowIndex, highIndex)=>{\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. */ return midpoint;\n }\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n const getIndexFromSizeArray = (scrollPos)=>{\n /* Quick searches our progressive height array */ if (scrollPos === 0 || childProgressiveSizes.current.length === 0 || scrollPos <= childProgressiveSizes.current[0]) {\n // Check start\n return 0;\n }\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n const getIndexFromScrollPosition = (scrollPos)=>{\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n return getIndexFromSizeArray(scrollPos);\n };\n const calculateTotalSize = useCallback(()=>{\n if (!getItemSize) {\n return itemSize * numItems;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n }, [\n getItemSize,\n itemSize,\n numItems\n ]);\n const calculateBefore = useCallback(()=>{\n const currentIndex = Math.min(actualIndex, numItems - 1);\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return currentIndex * itemSize;\n }\n if (currentIndex <= 0) {\n return 0;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[currentIndex - 1];\n }, [\n actualIndex,\n getItemSize,\n itemSize,\n numItems\n ]);\n const calculateAfter = useCallback(()=>{\n if (numItems === 0 || actualIndex + virtualizerLength >= numItems) {\n return 0;\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 // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];\n }, [\n actualIndex,\n getItemSize,\n itemSize,\n numItems,\n virtualizerLength\n ]);\n const updateChildRows = useCallback((newIndex)=>{\n if (numItems === 0) {\n /* Nothing to virtualize */ return;\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 */ 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] = renderVirtualizerChildPlaceholder(renderChild(i, isScrolling), i);\n }\n }, [\n isScrolling,\n numItems,\n renderChild,\n virtualizerLength\n ]);\n const setBeforeRef = useCallback((element)=>{\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n newList.push(beforeElementRef.current);\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n // Ensure we update array if before element changed\n setObserverList(newList);\n }, [\n setObserverList\n ]);\n const setAfterRef = useCallback((element)=>{\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n newList.push(afterElementRef.current);\n // Ensure we update array if after element changed\n setObserverList(newList);\n }, [\n setObserverList\n ]);\n const updateCurrentItemSizes = (newIndex)=>{\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 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 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 // Initialize the size array before first render.\n const hasInitialized = useRef(false);\n const initializeSizeArray = ()=>{\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n useImperativeHandle(imperativeVirtualizerRef, ()=>{\n return {\n progressiveSizes: childProgressiveSizes,\n nodeSizes: childSizes,\n setFlaggedIndex: (index)=>flaggedIndex.current = index,\n currentIndex: actualIndexRef\n };\n }, [\n childProgressiveSizes,\n childSizes\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 // 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 }, [\n renderChild,\n updateChildRows\n ]);\n useEffect(()=>{\n // Ensure we repopulate if getItemSize callback changes\n populateSizeArrays();\n // We only run this effect on getItemSize change (recalc dynamic sizes)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\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 }, [\n actualIndex,\n onRenderedFlaggedIndex,\n virtualizerLength\n ]);\n // Ensure we have run through and updated the whole size list array at least once.\n initializeSizeArray();\n if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {\n // Child length mismatch, repopulate size arrays.\n populateSizeArrays();\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 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: resolveShorthand(props.before, {\n required: true,\n defaultProps: {\n ref: setBeforeRef,\n role: 'none'\n }\n }),\n after: resolveShorthand(props.after, {\n required: true,\n defaultProps: {\n ref: setAfterRef,\n role: 'none'\n }\n }),\n beforeContainer: resolveShorthand(props.beforeContainer, {\n required: true,\n defaultProps: {\n role: 'none'\n }\n }),\n afterContainer: resolveShorthand(props.afterContainer, {\n required: true,\n defaultProps: {\n role: 'none'\n }\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed\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","scrollTimer","scrollCounter","initializeScrollingTimer","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","clearTimeout","setTimeout","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","useCallback","currentIndex","lastItemIndex","remainingItems","newIndex","_actualIndex","end","i","renderVirtualizerChildPlaceholder","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","useImperativeHandle","progressiveSizes","nodeSizes","setFlaggedIndex","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","resolveShorthand","required","defaultProps","ref","role","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"mappings":";;;;+BAMgBA;;aAAAA;;uBAN0E;yCAClD;gCACP;0BACP;2BAC0B;mCACF;AAC3C,SAASA,wBAAwBC,KAAK,EAAE;IAC3C,MAAM,EAAEC,SAAQ,EAAGC,SAAQ,EAAGC,kBAAiB,EAAGC,UAAUC,YAAW,EAAGC,YAAW,EAAGC,aAAaC,KAAKC,KAAK,CAACN,oBAAoB,KAAI,EAAGO,YAAYF,KAAKG,KAAK,CAACJ,cAAc,OAAON,SAAQ,EAAGW,cAAa,EAAGC,MAAM,WAAU,EAAGC,UAAU,KAAK,CAAA,EAAGC,mBAAkB,EAAGC,uBAAsB,EAAGC,yBAAwB,EAAG,GAAGjB;IACnU,iHAAiH,GAAG,MAAMkB,sBAAsBC,IAAAA,8CAAmC,EAACJ;IACpL,sFAAsF;IACtF,MAAMK,iBAAiBC,IAAAA,aAAM,EAACH,oBAAoBI,YAAY;IAC9D,IAAIF,eAAeG,OAAO,KAAKL,oBAAoBI,YAAY,EAAE;QAC7DF,eAAeG,OAAO,GAAGL,oBAAoBI,YAAY;IAC7D,CAAC;IACD,MAAME,eAAeH,IAAAA,aAAM,EAAC,IAAI;IAChC,MAAMI,cAAcP,oBAAoBI,YAAY;IACpD,MAAMI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qBvD,uBAAuBnE,oBAAoBF,QAAQ;QAChG2I,uBAAuBnH;QACvBZ;QACAH;QACAI;IACJ;AACJ"}
@@ -19,10 +19,16 @@ function useVirtualizerScrollView_unstable(props) {
19
19
  defaultItemSize: props.itemSize,
20
20
  direction: (_props_axis = props.axis) !== null && _props_axis !== void 0 ? _props_axis : 'vertical'
21
21
  });
22
+ // Store the virtualizer length as a ref for imperative ref access
23
+ const virtualizerLengthRef = _react.useRef(virtualizerLength);
24
+ if (virtualizerLengthRef.current !== virtualizerLength) {
25
+ virtualizerLengthRef.current = virtualizerLength;
26
+ }
22
27
  const scrollViewRef = (0, _reactUtilities.useMergedRefs)(_react.useRef(null), scrollRef);
23
28
  const imperativeVirtualizerRef = _react.useRef(null);
24
29
  const scrollCallbackRef = _react.useRef(null);
25
30
  (0, _react.useImperativeHandle)(imperativeRef, ()=>{
31
+ var _imperativeVirtualizerRef_current;
26
32
  return {
27
33
  scrollTo (index, behavior = 'auto', callback) {
28
34
  var _imperativeVirtualizerRef_current;
@@ -37,7 +43,9 @@ function useVirtualizerScrollView_unstable(props) {
37
43
  reversed,
38
44
  behavior
39
45
  });
40
- }
46
+ },
47
+ currentIndex: (_imperativeVirtualizerRef_current = imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.currentIndex,
48
+ virtualizerLength: virtualizerLengthRef
41
49
  };
42
50
  }, [
43
51
  axis,
@@ -1 +1 @@
1
- {"version":3,"sources":["useVirtualizerScrollView.js"],"sourcesContent":["import * as React from 'react';\nimport { resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';\nimport { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';\nimport { useStaticVirtualizerMeasure } from '../../Hooks';\nimport { useImperativeHandle } from 'react';\nimport { scrollToItemStatic } from '../../Utilities';\nexport function useVirtualizerScrollView_unstable(props) {\n const { imperativeRef , itemSize , numItems , axis ='vertical' , reversed } = props;\n var _props_axis;\n const { virtualizerLength , bufferItems , bufferSize , scrollRef } = useStaticVirtualizerMeasure({\n defaultItemSize: props.itemSize,\n direction: (_props_axis = props.axis) !== null && _props_axis !== void 0 ? _props_axis : 'vertical'\n });\n const scrollViewRef = useMergedRefs(React.useRef(null), scrollRef);\n const imperativeVirtualizerRef = React.useRef(null);\n const scrollCallbackRef = React.useRef(null);\n useImperativeHandle(imperativeRef, ()=>{\n return {\n scrollTo (index, behavior = 'auto', callback) {\n var _imperativeVirtualizerRef_current;\n scrollCallbackRef.current = callback !== null && callback !== void 0 ? callback : null;\n (_imperativeVirtualizerRef_current = imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.setFlaggedIndex(index);\n scrollToItemStatic({\n index,\n itemSize,\n totalItems: numItems,\n scrollViewRef,\n axis,\n reversed,\n behavior\n });\n }\n };\n }, [\n axis,\n scrollViewRef,\n itemSize,\n numItems,\n reversed\n ]);\n const handleRenderedIndex = (index)=>{\n if (scrollCallbackRef.current) {\n scrollCallbackRef.current(index);\n }\n };\n const virtualizerState = useVirtualizer_unstable({\n ...props,\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollViewRef,\n onRenderedFlaggedIndex: handleRenderedIndex,\n imperativeVirtualizerRef\n });\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div'\n },\n container: resolveShorthand(props.container, {\n required: true,\n defaultProps: {\n ref: scrollViewRef\n }\n })\n };\n}\n"],"names":["useVirtualizerScrollView_unstable","props","imperativeRef","itemSize","numItems","axis","reversed","_props_axis","virtualizerLength","bufferItems","bufferSize","scrollRef","useStaticVirtualizerMeasure","defaultItemSize","direction","scrollViewRef","useMergedRefs","React","useRef","imperativeVirtualizerRef","scrollCallbackRef","useImperativeHandle","scrollTo","index","behavior","callback","_imperativeVirtualizerRef_current","current","setFlaggedIndex","scrollToItemStatic","totalItems","handleRenderedIndex","virtualizerState","useVirtualizer_unstable","onRenderedFlaggedIndex","components","container","resolveShor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AkBO,OAAO,CAACJ;QAC9B,CAAC;IACL;IACA,MAAMS,mBAAmBC,IAAAA,uCAAuB,EAAC;QAC7C,GAAGhC,KAAK;QACRO;QACAC;QACAC;QACAK;QACAmB,wBAAwBH;QACxBZ;IACJ;IACA,OAAO;QACH,GAAGa,gBAAgB;QACnBG,YAAY;YACR,GAAGH,iBAAiBG,UAAU;YAC9BC,WAAW;QACf;QACAA,WAAWC,IAAAA,gCAAgB,EAACpC,MAAMmC,SAAS,EAAE;YACzCE,UAAU,IAAI;YACdC,cAAc;gBACVC,KAAKzB;YACT;QACJ;IACJ;AACJ"}
1
+ {"version":3,"sources":["useVirtualizerScrollView.js"],"sourcesContent":["import * as React from 'react';\nimport { resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';\nimport { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';\nimport { useStaticVirtualizerMeasure } from '../../Hooks';\nimport { useImperativeHandle } from 'react';\nimport { scrollToItemStatic } from '../../Utilities';\nexport function useVirtualizerScrollView_unstable(props) {\n const { imperativeRef , itemSize , numItems , axis ='vertical' , reversed } = props;\n var _props_axis;\n const { virtualizerLength , bufferItems , bufferSize , scrollRef } = useStaticVirtualizerMeasure({\n defaultItemSize: props.itemSize,\n direction: (_props_axis = props.axis) !== null && _props_axis !== void 0 ? _props_axis : 'vertical'\n });\n // Store the virtualizer length as a ref for imperative ref access\n const virtualizerLengthRef = React.useRef(virtualizerLength);\n if (virtualizerLengthRef.current !== virtualizerLength) {\n virtualizerLengthRef.current = virtualizerLength;\n }\n const scrollViewRef = useMergedRefs(React.useRef(null), scrollRef);\n const imperativeVirtualizerRef = React.useRef(null);\n const scrollCallbackRef = React.useRef(null);\n useImperativeHandle(imperativeRef, ()=>{\n var _imperativeVirtualizerRef_current;\n return {\n scrollTo (index, behavior = 'auto', callback) {\n var _imperativeVirtualizerRef_current;\n scrollCallbackRef.current = callback !== null && callback !== void 0 ? callback : null;\n (_imperativeVirtualizerRef_current = imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.setFlaggedIndex(index);\n scrollToItemStatic({\n index,\n itemSize,\n totalItems: numItems,\n scrollViewRef,\n axis,\n reversed,\n behavior\n });\n },\n currentIndex: (_imperativeVirtualizerRef_current = imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.currentIndex,\n virtualizerLength: virtualizerLengthRef\n };\n }, [\n axis,\n scrollViewRef,\n itemSize,\n numItems,\n reversed\n ]);\n const handleRenderedIndex = (index)=>{\n if (scrollCallbackRef.current) {\n scrollCallbackRef.current(index);\n }\n };\n const virtualizerState = useVirtualizer_unstable({\n ...props,\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollViewRef,\n onRenderedFlaggedIndex: handleRenderedIndex,\n imperativeVirtualizerRef\n });\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div'\n },\n container: resolveShorthand(props.container, {\n required: true,\n defaultProps: {\n ref: scrollViewRef\n }\n })\n };\n}\n"],"names":["useVirtualizerScrollView_unstable","props","imperativeRef","itemSize","numItems","axis","reversed","_props_axis","virtualizerLength","bufferItems","bufferSize","scrollRef","useStaticVirtualizerMeasure","defaultItemSize","direction","virtualizerLengthRef","React","useRef","current","scrollViewRef","useMergedRefs","imperativeVirtualizerRef","scrollCallbackRef","useImperativeHandle","_imperativeVirtualizerRef_current","scrollTo","index","behavior","callback","setFlaggedIndex","scrollToItemStatic","totalItems","currentIndex","handleRenderedIndex","virtualizerState","useVirtualizer_unstable","onRenderedFlaggedIndex","components","container","resolveShorthand","required","defaultProps","ref"],"mappings":";;;;+BAMgBA;;aAAAA;;;6DANO;gCACyB;gCACR;uBACI;2BAET;AAC5B,SAASA,kCAAkCC,KAAK,EAAE;IACrD,MAAM,EAAEC,cAAa,EAAGC,SAAQ,EAAGC,SAAQ,EAAGC,MAAM,WAAU,EAAGC,SAAQ,EAAG,GAAGL;IAC/E,IAA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D,MAAM2B,sBAAsB,CAACP,QAAQ;QACjC,IAAIJ,kBAAkBJ,OAAO,EAAE;YAC3BI,kBAAkBJ,OAAO,CAACQ;QAC9B,CAAC;IACL;IACA,MAAMQ,mBAAmBC,IAAAA,uCAAuB,EAAC;QAC7C,GAAGlC,KAAK;QACRO;QACAC;QACAC;QACAS;QACAiB,wBAAwBH;QACxBZ;IACJ;IACA,OAAO;QACH,GAAGa,gBAAgB;QACnBG,YAAY;YACR,GAAGH,iBAAiBG,UAAU;YAC9BC,WAAW;QACf;QACAA,WAAWC,IAAAA,gCAAgB,EAACtC,MAAMqC,SAAS,EAAE;YACzCE,UAAU,IAAI;YACdC,cAAc;gBACVC,KAAKvB;YACT;QACJ;IACJ;AACJ"}
@@ -23,10 +23,16 @@ function useVirtualizerScrollViewDynamic_unstable(props) {
23
23
  currentIndex: (_contextState_contextIndex = contextState === null || contextState === void 0 ? void 0 : contextState.contextIndex) !== null && _contextState_contextIndex !== void 0 ? _contextState_contextIndex : 0,
24
24
  numItems: props.numItems
25
25
  });
26
+ // Store the virtualizer length as a ref for imperative ref access
27
+ const virtualizerLengthRef = _react.useRef(virtualizerLength);
28
+ if (virtualizerLengthRef.current !== virtualizerLength) {
29
+ virtualizerLengthRef.current = virtualizerLength;
30
+ }
26
31
  const scrollViewRef = (0, _reactUtilities.useMergedRefs)(_react.useRef(null), scrollRef);
27
32
  const scrollCallbackRef = _react.useRef(null);
28
33
  const _imperativeVirtualizerRef = (0, _reactUtilities.useMergedRefs)(_react.useRef(null), imperativeVirtualizerRef);
29
34
  (0, _react.useImperativeHandle)(imperativeRef, ()=>{
35
+ var _imperativeVirtualizerRef_current;
30
36
  return {
31
37
  scrollTo (index, behavior = 'auto', callback) {
32
38
  scrollCallbackRef.current = callback !== null && callback !== void 0 ? callback : null;
@@ -45,7 +51,9 @@ function useVirtualizerScrollViewDynamic_unstable(props) {
45
51
  behavior
46
52
  });
47
53
  }
48
- }
54
+ },
55
+ currentIndex: (_imperativeVirtualizerRef_current = _imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.currentIndex,
56
+ virtualizerLength: virtualizerLengthRef
49
57
  };
50
58
  }, [
51
59
  axis,
@@ -1 +1 @@
1
- {"version":3,"sources":["useVirtualizerScrollViewDynamic.js"],"sourcesContent":["import * as React from 'react';\nimport { resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';\nimport { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';\nimport { useDynamicVirtualizerMeasure } from '../../Hooks';\nimport { useVirtualizerContextState_unstable, scrollToItemDynamic } from '../../Utilities';\nimport { useImperativeHandle } from 'react';\nexport function useVirtualizerScrollViewDynamic_unstable(props) {\n const contextState = useVirtualizerContextState_unstable(props.virtualizerContext);\n const { imperativeRef , axis ='vertical' , reversed , imperativeVirtualizerRef } = props;\n var _props_axis, _contextState_contextIndex;\n const { virtualizerLength , bufferItems , bufferSize , scrollRef } = useDynamicVirtualizerMeasure({\n defaultItemSize: props.itemSize,\n direction: (_props_axis = props.axis) !== null && _props_axis !== void 0 ? _props_axis : 'vertical',\n getItemSize: props.getItemSize,\n currentIndex: (_contextState_contextIndex = contextState === null || contextState === void 0 ? void 0 : contextState.contextIndex) !== null && _contextState_contextIndex !== void 0 ? _contextState_contextIndex : 0,\n numItems: props.numItems\n });\n const scrollViewRef = useMergedRefs(React.useRef(null), scrollRef);\n const scrollCallbackRef = React.useRef(null);\n const _imperativeVirtualizerRef = useMergedRefs(React.useRef(null), imperativeVirtualizerRef);\n useImperativeHandle(imperativeRef, ()=>{\n return {\n scrollTo (index, behavior = 'auto', callback) {\n scrollCallbackRef.current = callback !== null && callback !== void 0 ? callback : null;\n if (_imperativeVirtualizerRef.current) {\n var _imperativeVirtualizerRef_current;\n const progressiveSizes = _imperativeVirtualizerRef.current.progressiveSizes.current;\n const totalSize = progressiveSizes && (progressiveSizes === null || progressiveSizes === void 0 ? void 0 : progressiveSizes.length) > 0 ? progressiveSizes[Math.max(progressiveSizes.length - 1, 0)] : 0;\n _imperativeVirtualizerRef.current.setFlaggedIndex(index);\n scrollToItemDynamic({\n index,\n itemSizes: (_imperativeVirtualizerRef_current = _imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.nodeSizes,\n totalSize,\n scrollViewRef,\n axis,\n reversed,\n behavior\n });\n }\n }\n };\n }, [\n axis,\n scrollViewRef,\n reversed,\n _imperativeVirtualizerRef\n ]);\n const handleRenderedIndex = (index)=>{\n if (scrollCallbackRef.current) {\n scrollCallbackRef.current(index);\n }\n };\n const virtualizerState = useVirtualizer_unstable({\n ...props,\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollViewRef,\n virtualizerContext: contextState,\n imperativeVirtualizerRef: _imperativeVirtualizerRef,\n onRenderedFlaggedIndex: handleRenderedIndex\n });\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div'\n },\n container: resolveShorthand(props.container, {\n required: true,\n defaultProps: {\n ref: scrollViewRef\n }\n })\n };\n}\n"],"names":["useVirtualizerScrollViewDynamic_unstable","props","contextState","useVirtualizerContextState_unstable","virtualizerContext","imperativeRef","axis","reversed","imperativeVirtualizerRef","_props_axis","_contextState_contextIndex","virtualizerLength","bufferItems","bufferSize","scrollRef","useDynamicVirtualizerMeasure","defaultItemSize","itemSize","direction","getItemSize","currentIndex","contextIndex","numItems","scrollViewRef","useMergedRefs","React","useRef","scrollCallbackRef","_imperativeVirtualizerRef","useImperativeHandle","scrollTo","index","behavior","callback","current","_imperativeVirtualizerRef_current","progressiveSizes","totalSize","length","Math","max","setFlaggedIndex","scrollToItemDynamic","itemSizes","nodeSizes","handleRenderedIndex","virtualizerState","useVirtualizer_unstable","onRenderedFlaggedIndex","components","container","resolveShorthand","required","defaultProps","ref"],"mappings":";;;;+BAMgBA;;aAAAA;;;6DANO;gCACyB;gCACR;uBACK;2BAC4B;AAElE,SAASA,yCAAyCC,KAAK,EA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qBAAqB,KAAK,IAAI,KAAK,IAAIA,iBAAiBE,MAAM,AAAD,IAAK,IAAIF,gBAAgB,CAACG,KAAKC,GAAG,CAACJ,iBAAiBE,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC;oBACxMV,0BAA0BM,OAAO,CAACO,eAAe,CAACV;oBAClDW,IAAAA,8BAAmB,EAAC;wBAChBX;wBACAY,WAAW,AAACR,CAAAA,oCAAoCP,0BAA0BM,OAAO,AAAD,MAAO,IAAI,IAAIC,sCAAsC,KAAK,IAAI,KAAK,IAAIA,kCAAkCS,SAAS;wBAClMP;wBACAd;wBACAjB;wBACAC;wBACAyB;oBACJ;gBACJ,CAAC;YACL;QACJ;IACJ,GAAG;QACC1B;QACAiB;QACAhB;QACAqB;KACH;IACD,MAAMiB,sBAAsB,CAACd,QAAQ;QACjC,IAAIJ,kBAAkBO,OAAO,EAAE;YAC3BP,kBAAkBO,OAAO,CAACH;QAC9B,CAAC;IACL;IACA,MAAMe,mBAAmBC,IAAAA,uCAAuB,EAAC;QAC7C,GAAG9C,KAAK;QACRU;QACAC;QACAC;QACAU;QACAnB,oBAAoBF;QACpBM,0BAA0BoB;QAC1BoB,wBAAwBH;IAC5B;IACA,OAAO;QACH,GAAGC,gBAAgB;QACnBG,YAAY;YACR,GAAGH,iBAAiBG,UAAU;YAC9BC,WAAW;QACf;QACAA,WAAWC,IAAAA,gCAAgB,EAAClD,MAAMiD,SAAS,EAAE;YACzCE,UAAU,IAAI;YACdC,cAAc;gBACVC,KAAK/B;YACT;QACJ;IACJ;AACJ"}
1
+ {"version":3,"sources":["useVirtualizerScrollViewDynamic.js"],"sourcesContent":["import * as React from 'react';\nimport { resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';\nimport { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';\nimport { useDynamicVirtualizerMeasure } from '../../Hooks';\nimport { useVirtualizerContextState_unstable, scrollToItemDynamic } from '../../Utilities';\nimport { useImperativeHandle } from 'react';\nexport function useVirtualizerScrollViewDynamic_unstable(props) {\n const contextState = useVirtualizerContextState_unstable(props.virtualizerContext);\n const { imperativeRef , axis ='vertical' , reversed , imperativeVirtualizerRef } = props;\n var _props_axis, _contextState_contextIndex;\n const { virtualizerLength , bufferItems , bufferSize , scrollRef } = useDynamicVirtualizerMeasure({\n defaultItemSize: props.itemSize,\n direction: (_props_axis = props.axis) !== null && _props_axis !== void 0 ? _props_axis : 'vertical',\n getItemSize: props.getItemSize,\n currentIndex: (_contextState_contextIndex = contextState === null || contextState === void 0 ? void 0 : contextState.contextIndex) !== null && _contextState_contextIndex !== void 0 ? _contextState_contextIndex : 0,\n numItems: props.numItems\n });\n // Store the virtualizer length as a ref for imperative ref access\n const virtualizerLengthRef = React.useRef(virtualizerLength);\n if (virtualizerLengthRef.current !== virtualizerLength) {\n virtualizerLengthRef.current = virtualizerLength;\n }\n const scrollViewRef = useMergedRefs(React.useRef(null), scrollRef);\n const scrollCallbackRef = React.useRef(null);\n const _imperativeVirtualizerRef = useMergedRefs(React.useRef(null), imperativeVirtualizerRef);\n useImperativeHandle(imperativeRef, ()=>{\n var _imperativeVirtualizerRef_current;\n return {\n scrollTo (index, behavior = 'auto', callback) {\n scrollCallbackRef.current = callback !== null && callback !== void 0 ? callback : null;\n if (_imperativeVirtualizerRef.current) {\n var _imperativeVirtualizerRef_current;\n const progressiveSizes = _imperativeVirtualizerRef.current.progressiveSizes.current;\n const totalSize = progressiveSizes && (progressiveSizes === null || progressiveSizes === void 0 ? void 0 : progressiveSizes.length) > 0 ? progressiveSizes[Math.max(progressiveSizes.length - 1, 0)] : 0;\n _imperativeVirtualizerRef.current.setFlaggedIndex(index);\n scrollToItemDynamic({\n index,\n itemSizes: (_imperativeVirtualizerRef_current = _imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.nodeSizes,\n totalSize,\n scrollViewRef,\n axis,\n reversed,\n behavior\n });\n }\n },\n currentIndex: (_imperativeVirtualizerRef_current = _imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.currentIndex,\n virtualizerLength: virtualizerLengthRef\n };\n }, [\n axis,\n scrollViewRef,\n reversed,\n _imperativeVirtualizerRef\n ]);\n const handleRenderedIndex = (index)=>{\n if (scrollCallbackRef.current) {\n scrollCallbackRef.current(index);\n }\n };\n const virtualizerState = useVirtualizer_unstable({\n ...props,\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollViewRef,\n virtualizerContext: contextState,\n imperativeVirtualizerRef: _imperativeVirtualizerRef,\n onRenderedFlaggedIndex: handleRenderedIndex\n });\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div'\n },\n container: resolveShorthand(props.container, {\n required: true,\n defaultProps: {\n ref: scrollViewRef\n }\n })\n };\n}\n"],"names":["useVirtualizerScrollViewDynamic_unstable","props","contextState","useVirtualizerContextState_unstable","virtualizerContext","imperativeRef","axis","reversed","imperativeVirtualizerRef","_props_axis","_contextState_contextIndex","virtualizerLength","bufferItems","bufferSize","scrollRef","useDynamicVirtualizerMeasure","defaultItemSize","itemSize","direction","getItemSize","currentIndex","contextIndex","numItems","virtualizerLengthRef","React","useRef","current","scrollViewRef","useMergedRefs","scrollCallbackRef","_imperativeVirtualizerRef","useImperativeHandle","_imperativeVirtualizerRef_current","scrollTo","index","behavior","callback","progressiveSizes","totalSize","length","Math","max","setFlaggedIndex","scrollToItemDynamic","itemSizes","nodeSizes","handleRenderedIndex","virtualizerState","useVirtualizer_unstable","onRenderedFlaggedIndex","components","container","resolveShorthand","required","defaultProps","ref"],"mappings":";;;;+BAMgBA;;aAAAA;;;6DANO;gCACyB;gCACR;uBACK;2BAC4B;AAElE,SAASA,yCAAyCC,KAAK,EAAE;IAC5D,MAAMC,eAAeC,IAAAA,8CAAmC,EAACF,MAAMG,kBAAkB;IACjF,MAAM,EAAEC,cAAa,EAAGC,MAAM,WAAU,EAAGC,SAAQ,EAAGC,yBAAw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3
+ "version": "9.0.0-alpha.29",
4
4
  "description": "Generic and composable virtualizer framework built on browser intersection observer",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -27,12 +27,12 @@
27
27
  "devDependencies": {
28
28
  "@fluentui/eslint-plugin": "*",
29
29
  "@fluentui/react-conformance": "*",
30
- "@fluentui/react-conformance-griffel": "9.0.0",
30
+ "@fluentui/react-conformance-griffel": "*",
31
31
  "@fluentui/scripts-api-extractor": "*",
32
32
  "@fluentui/scripts-tasks": "*"
33
33
  },
34
34
  "dependencies": {
35
- "@fluentui/react-jsx-runtime": "9.0.0-alpha.11",
35
+ "@fluentui/react-jsx-runtime": "9.0.0-alpha.12",
36
36
  "@fluentui/react-utilities": "^9.10.1",
37
37
  "@griffel/react": "^1.5.7",
38
38
  "@swc/helpers": "^0.4.14"