@fluentui/react-virtualizer 9.0.0-alpha.22 → 9.0.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.json +40 -1
  2. package/CHANGELOG.md +15 -2
  3. package/dist/index.d.ts +59 -7
  4. package/lib/components/Virtualizer/Virtualizer.types.js.map +1 -1
  5. package/lib/components/Virtualizer/renderVirtualizer.js.map +1 -1
  6. package/lib/components/Virtualizer/useVirtualizer.js +83 -13
  7. package/lib/components/Virtualizer/useVirtualizer.js.map +1 -1
  8. package/lib/components/VirtualizerScrollView/VirtualizerScrollView.js.map +1 -1
  9. package/lib/components/VirtualizerScrollView/VirtualizerScrollView.types.js.map +1 -1
  10. package/lib/components/VirtualizerScrollView/renderVirtualizerScrollView.js.map +1 -1
  11. package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js +39 -3
  12. package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -1
  13. package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js.map +1 -1
  14. package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -1
  15. package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +43 -5
  16. package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -1
  17. package/lib/hooks/useResizeObserverRef.js +2 -0
  18. package/lib/hooks/useResizeObserverRef.js.map +1 -1
  19. package/lib/index.js +1 -1
  20. package/lib/index.js.map +1 -1
  21. package/lib/utilities/ImperativeScrolling/imperativeScrolling.js +32 -0
  22. package/lib/utilities/ImperativeScrolling/imperativeScrolling.js.map +1 -0
  23. package/lib/utilities/ImperativeScrolling/imperativeScrolling.types.js +1 -0
  24. package/lib/utilities/ImperativeScrolling/imperativeScrolling.types.js.map +1 -0
  25. package/lib/utilities/ImperativeScrolling/imperativeScrollingDynamic.js +45 -0
  26. package/lib/utilities/ImperativeScrolling/imperativeScrollingDynamic.js.map +1 -0
  27. package/lib/utilities/ImperativeScrolling/index.js +3 -0
  28. package/lib/utilities/ImperativeScrolling/index.js.map +1 -0
  29. package/lib/utilities/index.js +1 -0
  30. package/lib/utilities/index.js.map +1 -1
  31. package/lib-commonjs/components/Virtualizer/useVirtualizer.js +83 -13
  32. package/lib-commonjs/components/Virtualizer/useVirtualizer.js.map +1 -1
  33. package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js +38 -3
  34. package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -1
  35. package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +41 -4
  36. package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -1
  37. package/lib-commonjs/hooks/useResizeObserverRef.js +2 -0
  38. package/lib-commonjs/hooks/useResizeObserverRef.js.map +1 -1
  39. package/lib-commonjs/index.js +2 -0
  40. package/lib-commonjs/index.js.map +1 -1
  41. package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.js +40 -0
  42. package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.js.map +1 -0
  43. package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.types.js +4 -0
  44. package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.types.js.map +1 -0
  45. package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrollingDynamic.js +53 -0
  46. package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrollingDynamic.js.map +1 -0
  47. package/lib-commonjs/utilities/ImperativeScrolling/index.js +8 -0
  48. package/lib-commonjs/utilities/ImperativeScrolling/index.js.map +1 -0
  49. package/lib-commonjs/utilities/index.js +1 -0
  50. package/lib-commonjs/utilities/index.js.map +1 -1
  51. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["useVirtualizer.js"],"sourcesContent":["import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { useEffect, useRef, useCallback, useReducer } from 'react';\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 } = 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 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 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 = ()=>{\n if (!getItemSize) {\n return itemSize * numItems;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n };\n const calculateBefore = ()=>{\n const currentIndex = Math.min(actualIndex, numItems);\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 const calculateAfter = ()=>{\n if (numItems === 0) {\n return 0;\n }\n const lastItemIndex = Math.min(actualIndex + virtualizerLength, numItems - 1);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex - 1;\n return remainingItems * itemSize;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex];\n };\n const updateChildRows = useCallback((newIndex)=>{\n if (numItems === 0) {\n /* Nothing to virtualize */ return [];\n }\n if (childArray.current.length !== numItems) {\n childArray.current = new Array(virtualizerLength);\n }\n const _actualIndex = Math.max(newIndex, 0);\n const end = Math.min(_actualIndex + virtualizerLength, numItems);\n for(let i = _actualIndex; i < end; i++){\n childArray.current[i - _actualIndex] = renderVirtualizerChildPlaceholder(renderChild(i), i);\n }\n }, [\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 // 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 // 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","_virtualizerContext","useVirtualizerContextState_unstable","actualIndex","contextIndex","setActualIndex","setContextIndex","beforeElementRef","useRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","useReducer","horizontal","populateSizeArrays","current","length","index","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","useIntersectionObserver","entries","observer","measurementPos","bufferCount","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","target","calculateAfter","calculateTotalSize","abs","boundingClientRect","bottom","top","right","left","calculateBefore","max","startIndex","getIndexFromScrollPosition","bufferedIndex","maxIndex","newStartIndex","min","flushSync","root","rootMargin","threshold","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","currentIndex","lastItemIndex","remainingItems","useCallback","newIndex","_actualIndex","end","i","renderVirtualizerChildPlaceholder","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","useEffect","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","resolveShorthand","required","defaultProps","ref","role","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"mappings":";;;;+BAMgBA;;aAAAA;;yCANwB;uBACmB;gCAC1B;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,EAAG,GAAGf;IAC/Q,iHAAiH,GAAG,MAAMgB,sBAAsBC,IAAAA,8CAAmC,EAACF;IACpL,MAAMG,cAAcF,oBAAoBG,YAAY;IACpD,MAAMC,iBAAiBJ,oBAAoBK,eAAe;IAC1D,sCAAsC;IACtC,MAAMC,mBAAmBC,IAAAA,aAAM,EAAC,IAAI;IACpC,sCAAsC;IACtC,MAAMC,kBAAkBD,IAAAA,aAAM,EAAC,IAAI;IACnC,oGAAoG;IACpG,MAAME,aAAaF,IAAAA,aAAM,EAAC,IAAIG,MAAMpB,cAAcJ,WAAW,CAAC;IAC9D;kEAC8D,GAAG,MAAMyB,wBAAwBJ,IAAAA,aAAM,EAAC,IAAIG,MAAMpB,cAAcJ,WAAW,C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O,CAACC,MAAM,GAAGhC,UAAU;QAChGmC,gBAAgBnB;IACpB,CAAC;IACD,MAAMyF,qBAAqBJ,eAAetE,OAAO,IAAIf,eAAe;IACpE,OAAO;QACH0F,YAAY;YACRC,QAAQ;YACRC,OAAO;YACPC,iBAAiB;YACjBC,gBAAgB;QACpB;QACAC,qBAAqBrF,WAAWK,OAAO;QACvC4E,QAAQK,IAAAA,gCAAgB,EAAClH,MAAM6G,MAAM,EAAE;YACnCM,UAAU,IAAI;YACdC,cAAc;gBACVC,KAAKvB;gBACLwB,MAAM;YACV;QACJ;QACAR,OAAOI,IAAAA,gCAAgB,EAAClH,MAAM8G,KAAK,EAAE;YACjCK,UAAU,IAAI;YACdC,cAAc;gBACVC,KAAKnB;gBACLoB,MAAM;YACV;QACJ;QACAP,iBAAiBG,IAAAA,gCAAgB,EAAClH,MAAM+G,eAAe,EAAE;YACrDI,UAAU,IAAI;YACdC,cAAc;gBACVE,MAAM;YACV;QACJ;QACAN,gBAAgBE,IAAAA,gCAAgB,EAAClH,MAAMgH,cAAc,EAAE;YACnDG,UAAU,IAAI;YACdC,cAAc;gBACVE,MAAM;YACV;QACJ;QACAC,oBAAoBZ,qBAAqB7C,oBAAoB,CAAC;QAC9D0D,mBAAmBb,qBAAqBrD,mBAAmB,CAAC;QAC5DmE,wBAAwBd,qBAAqBpD,uBAAuBpD,oBAAoBF,QAAQ;QAChGyH,uBAAuBxG;QACvBL;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 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);\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) {\n return 0;\n }\n const lastItemIndex = Math.min(actualIndex + virtualizerLength, numItems - 1);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex - 1;\n return remainingItems * itemSize;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex];\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,MA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MAAMsG,qBAAqBP,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"}
@@ -11,19 +11,54 @@ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
11
  const _reactUtilities = require("@fluentui/react-utilities");
12
12
  const _useVirtualizer = require("../Virtualizer/useVirtualizer");
13
13
  const _hooks = require("../../Hooks");
14
+ const _utilities = require("../../Utilities");
14
15
  function useVirtualizerScrollView_unstable(props) {
16
+ const { imperativeRef , itemSize , numItems , axis ='vertical' , reversed } = props;
15
17
  var _props_axis;
16
18
  const { virtualizerLength , bufferItems , bufferSize , scrollRef } = (0, _hooks.useStaticVirtualizerMeasure)({
17
19
  defaultItemSize: props.itemSize,
18
20
  direction: (_props_axis = props.axis) !== null && _props_axis !== void 0 ? _props_axis : 'vertical'
19
21
  });
20
- const iScrollRef = (0, _reactUtilities.useMergedRefs)(_react.useRef(null), scrollRef);
22
+ const scrollViewRef = (0, _reactUtilities.useMergedRefs)(_react.useRef(null), scrollRef);
23
+ const imperativeVirtualizerRef = _react.useRef(null);
24
+ const scrollCallbackRef = _react.useRef(null);
25
+ (0, _react.useImperativeHandle)(imperativeRef, ()=>{
26
+ return {
27
+ scrollTo (index, behavior = 'auto', callback) {
28
+ var _imperativeVirtualizerRef_current;
29
+ scrollCallbackRef.current = callback !== null && callback !== void 0 ? callback : null;
30
+ (_imperativeVirtualizerRef_current = imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.setFlaggedIndex(index);
31
+ (0, _utilities.scrollToItemStatic)({
32
+ index,
33
+ itemSize,
34
+ totalItems: numItems,
35
+ scrollViewRef,
36
+ axis,
37
+ reversed,
38
+ behavior
39
+ });
40
+ }
41
+ };
42
+ }, [
43
+ axis,
44
+ scrollViewRef,
45
+ itemSize,
46
+ numItems,
47
+ reversed
48
+ ]);
49
+ const handleRenderedIndex = (index)=>{
50
+ if (scrollCallbackRef.current) {
51
+ scrollCallbackRef.current(index);
52
+ }
53
+ };
21
54
  const virtualizerState = (0, _useVirtualizer.useVirtualizer_unstable)({
22
55
  ...props,
23
56
  virtualizerLength,
24
57
  bufferItems,
25
58
  bufferSize,
26
- scrollViewRef: iScrollRef
59
+ scrollViewRef,
60
+ onRenderedFlaggedIndex: handleRenderedIndex,
61
+ imperativeVirtualizerRef
27
62
  });
28
63
  return {
29
64
  ...virtualizerState,
@@ -34,7 +69,7 @@ function useVirtualizerScrollView_unstable(props) {
34
69
  container: (0, _reactUtilities.resolveShorthand)(props.container, {
35
70
  required: true,
36
71
  defaultProps: {
37
- ref: iScrollRef
72
+ ref: scrollViewRef
38
73
  }
39
74
  })
40
75
  };
@@ -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';\nexport function useVirtualizerScrollView_unstable(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 iScrollRef = useMergedRefs(React.useRef(null), scrollRef);\n const virtualizerState = useVirtualizer_unstable({\n ...props,\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollViewRef: iScrollRef\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: iScrollRef\n }\n })\n };\n}\n"],"names":["useVirtualizerScrollView_unstable","props","_props_axis","virtualizerLength","bufferItems","bufferSize","scrollRef","useStaticVirtualizerMeasure","defaultItemSize","itemSize","direction","axis","iScrollRef","useMergedRefs","React","useRef","virtualizerState","useVirtualizer_unstable","scrollViewRef","components","container","resolveShorthand","required","defaultProps","ref"],"mappings":";;;;+BAIgBA;;aAAAA;;;6DAJO;gCACyB;gCACR;uBACI;AACrC,SAASA,kCAAkCC,KAAK,EAAE;IACrD,IAAIC;IACJ,MAAM,EAAEC,kBAAiB,EAAGC,YAAW,EAAGC,WAAU,EAAGC,UAAS,EAAG,GAAGC,IAAAA,kCAA2B,EAAC;QAC9FC,iBAAiBP,MAAMQ,QAAQ;QAC/BC,WAAW,AAACR,CAAAA,cAAcD,MAAMU,IAAI,AAAD,MAAO,IAAI,IAAIT,gBAAgB,KAAK,IAAIA,cAAc,UAAU;IACvG;IACA,MAAMU,aAAaC,IAAAA,6BAAa,EAACC,OAAMC,MAAM,CAAC,IAAI,GAAGT;IACrD,MAAMU,mBAAmBC,IAAAA,uCAAuB,EAAC;QAC7C,GAAGhB,KAAK;QACRE;QACAC;QACAC;QACAa,eAAeN;IACnB;IACA,OAAO;QACH,GAAGI,gBAAgB;QACnBG,YAAY;YACR,GAAGH,iBAAiBG,UAAU;YAC9BC,WAAW;QACf;QACAA,WAAWC,IAAAA,gCAAgB,EAACpB,MAAMmB,SAAS,EAAE;YACzCE,UAAU,IAAI;YACdC,cAAc;gBACVC,KAAKZ;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 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","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,IAAIM;IACJ,MAAM,EAAEC,kBAAiB,EAAGC,YAAW,EAAGC,WAAU,EAAGC,UAAS,EAAG,GAAGC,IAAAA,kCAA2B,EAAC;QAC9FC,iBAAiBZ,MAAME,QAAQ;QAC/BW,WAAW,AAACP,CAAAA,cAAcN,MAAMI,IAAI,AAAD,MAAO,IAAI,IAAIE,gBAAgB,KAAK,IAAIA,cAAc,UAAU;IACvG;IACA,MAAMQ,gBAAgBC,IAAAA,6BAAa,EAACC,OAAMC,MAAM,CAAC,IAAI,GAAGP;IACxD,MAAMQ,2BAA2BF,OAAMC,MAAM,CAAC,IAAI;IAClD,MAAME,oBAAoBH,OAAMC,MAAM,CAAC,IAAI;IAC3CG,IAAAA,0BAAmB,EAACnB,eAAe,IAAI;QACnC,OAAO;YACHoB,UAAUC,KAAK,EAAEC,WAAW,MAAM,EAAEC,QAAQ,EAAE;gBAC1C,IAAIC;gBACJN,kBAAkBO,OAAO,GAAGF,aAAa,IAAI,IAAIA,aAAa,KAAK,IAAIA,WAAW,IAAI;gBACrFC,CAAAA,oCAAoCP,yBAAyBQ,OAAO,AAAD,MAAO,IAAI,IAAID,sCAAsC,KAAK,IAAI,KAAK,IAAIA,kCAAkCE,eAAe,CAACL,MAAM;gBACnMM,IAAAA,6BAAkB,EAAC;oBACfN;oBACApB;oBACA2B,YAAY1B;oBACZW;oBACAV;oBACAC;oBACAkB;gBACJ;YACJ;QACJ;IACJ,GAAG;QACCnB;QACAU;QACAZ;QACAC;QACAE;KACH;IACD,MAAMyB,sBAAsB,CAACR,QAAQ;QACjC,IAAIH,kBAAkBO,OAAO,EAAE;YAC3BP,kBAAkBO,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"}
@@ -14,6 +14,7 @@ const _hooks = require("../../Hooks");
14
14
  const _utilities = require("../../Utilities");
15
15
  function useVirtualizerScrollViewDynamic_unstable(props) {
16
16
  const contextState = (0, _utilities.useVirtualizerContextState_unstable)(props.virtualizerContext);
17
+ const { imperativeRef , axis ='vertical' , reversed , imperativeVirtualizerRef } = props;
17
18
  var _props_axis, _contextState_contextIndex;
18
19
  const { virtualizerLength , bufferItems , bufferSize , scrollRef } = (0, _hooks.useDynamicVirtualizerMeasure)({
19
20
  defaultItemSize: props.itemSize,
@@ -22,14 +23,50 @@ function useVirtualizerScrollViewDynamic_unstable(props) {
22
23
  currentIndex: (_contextState_contextIndex = contextState === null || contextState === void 0 ? void 0 : contextState.contextIndex) !== null && _contextState_contextIndex !== void 0 ? _contextState_contextIndex : 0,
23
24
  numItems: props.numItems
24
25
  });
25
- const iScrollRef = (0, _reactUtilities.useMergedRefs)(_react.useRef(null), scrollRef);
26
+ const scrollViewRef = (0, _reactUtilities.useMergedRefs)(_react.useRef(null), scrollRef);
27
+ const scrollCallbackRef = _react.useRef(null);
28
+ const _imperativeVirtualizerRef = (0, _reactUtilities.useMergedRefs)(_react.useRef(null), imperativeVirtualizerRef);
29
+ (0, _react.useImperativeHandle)(imperativeRef, ()=>{
30
+ return {
31
+ scrollTo (index, behavior = 'auto', callback) {
32
+ scrollCallbackRef.current = callback !== null && callback !== void 0 ? callback : null;
33
+ if (_imperativeVirtualizerRef.current) {
34
+ var _imperativeVirtualizerRef_current;
35
+ const progressiveSizes = _imperativeVirtualizerRef.current.progressiveSizes.current;
36
+ const totalSize = progressiveSizes && (progressiveSizes === null || progressiveSizes === void 0 ? void 0 : progressiveSizes.length) > 0 ? progressiveSizes[Math.max(progressiveSizes.length - 1, 0)] : 0;
37
+ _imperativeVirtualizerRef.current.setFlaggedIndex(index);
38
+ (0, _utilities.scrollToItemDynamic)({
39
+ index,
40
+ itemSizes: (_imperativeVirtualizerRef_current = _imperativeVirtualizerRef.current) === null || _imperativeVirtualizerRef_current === void 0 ? void 0 : _imperativeVirtualizerRef_current.nodeSizes,
41
+ totalSize,
42
+ scrollViewRef,
43
+ axis,
44
+ reversed,
45
+ behavior
46
+ });
47
+ }
48
+ }
49
+ };
50
+ }, [
51
+ axis,
52
+ scrollViewRef,
53
+ reversed,
54
+ _imperativeVirtualizerRef
55
+ ]);
56
+ const handleRenderedIndex = (index)=>{
57
+ if (scrollCallbackRef.current) {
58
+ scrollCallbackRef.current(index);
59
+ }
60
+ };
26
61
  const virtualizerState = (0, _useVirtualizer.useVirtualizer_unstable)({
27
62
  ...props,
28
63
  virtualizerLength,
29
64
  bufferItems,
30
65
  bufferSize,
31
- scrollViewRef: iScrollRef,
32
- virtualizerContext: contextState
66
+ scrollViewRef,
67
+ virtualizerContext: contextState,
68
+ imperativeVirtualizerRef: _imperativeVirtualizerRef,
69
+ onRenderedFlaggedIndex: handleRenderedIndex
33
70
  });
34
71
  return {
35
72
  ...virtualizerState,
@@ -40,7 +77,7 @@ function useVirtualizerScrollViewDynamic_unstable(props) {
40
77
  container: (0, _reactUtilities.resolveShorthand)(props.container, {
41
78
  required: true,
42
79
  defaultProps: {
43
- ref: iScrollRef
80
+ ref: scrollViewRef
44
81
  }
45
82
  })
46
83
  };
@@ -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 } from '../../Utilities';\nexport function useVirtualizerScrollViewDynamic_unstable(props) {\n const contextState = useVirtualizerContextState_unstable(props.virtualizerContext);\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 iScrollRef = useMergedRefs(React.useRef(null), scrollRef);\n const virtualizerState = useVirtualizer_unstable({\n ...props,\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollViewRef: iScrollRef,\n virtualizerContext: contextState\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: iScrollRef\n }\n })\n };\n}\n"],"names":["useVirtualizerScrollViewDynamic_unstable","props","contextState","useVirtualizerContextState_unstable","virtualizerContext","_props_axis","_contextState_contextIndex","virtualizerLength","bufferItems","bufferSize","scrollRef","useDynamicVirtualizerMeasure","defaultItemSize","itemSize","direction","axis","getItemSize","currentIndex","contextIndex","numItems","iScrollRef","useMergedRefs","React","useRef","virtualizerState","useVirtualizer_unstable","scrollViewRef","components","container","resolveShorthand","required","defaultProps","ref"],"mappings":";;;;+BAKgBA;;aAAAA;;;6DALO;gCACyB;gCACR;uBACK;2BACO;AAC7C,SAASA,yCAAyCC,KAAK,EAAE;IAC5D,MAAMC,eAAeC,IAAAA,8CAAmC,EAACF,MAAMG,kBAAkB;IACjF,IAAIC,aAAaC;IACjB,MAAM,EAAEC,kBAAiB,EAAGC,YAAW,EAAGC,WAAU,EAAGC,UAAS,EAAG,GAAGC,IAAAA,mCAA4B,EAAC;QAC/FC,iBAAiBX,MAAMY,QAAQ;QAC/BC,WAAW,AAACT,CAAAA,cAAcJ,MAAMc,IAAI,AAAD,MAAO,IAAI,IAAIV,gBAAgB,KAAK,IAAIA,cAAc,UAAU;QACnGW,aAAaf,MAAMe,WAAW;QAC9BC,cAAc,AAACX,CAAAA,6BAA6BJ,iBAAiB,IAAI,IAAIA,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAagB,YAAY,AAAD,MAAO,IAAI,IAAIZ,+BAA+B,KAAK,IAAIA,6BAA6B,CAAC;QACrNa,UAAUlB,MAAMkB,QAAQ;IAC5B;IACA,MAAMC,aAAaC,IAAAA,6BAAa,EAACC,OAAMC,MAAM,CAAC,IAAI,GAAGb;IACrD,MAAMc,mBAAmBC,IAAAA,uCAAuB,EAAC;QAC7C,GAAGxB,KAAK;QACRM;QACAC;QACAC;QACAiB,eAAeN;QACfhB,oBAAoBF;IACxB;IACA,OAAO;QACH,GAAGsB,gBAAgB;QACnBG,YAAY;YACR,GAAGH,iBAAiBG,UAAU;YAC9BC,WAAW;QACf;QACAA,WAAWC,IAAAA,gCAAgB,EAAC5B,MAAM2B,SAAS,EAAE;YACzCE,UAAU,IAAI;YACdC,cAAc;gBACVC,KAAKZ;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 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","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AMC,mBAAmBR,0BAA0BM,OAAO,CAACE,gBAAgB,CAACF,OAAO;oBACnF,MAAMG,YAAYD,oBAAoB,AAACA,CAAAA,qBAAqB,IAAI,IAAIA,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"}
@@ -20,6 +20,7 @@ const useResizeObserverRef_unstable = (resizeCallback)=>{
20
20
  const [resizeObserver, setResizeObserver] = _react.useState(()=>(0, _reactUtilities.canUseDOM)() ? new ResizeObserver(handleResize) : undefined);
21
21
  _react.useEffect(()=>{
22
22
  // Update our state when resizeCallback changes
23
+ container.current = null;
23
24
  resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
24
25
  setResizeObserver((0, _reactUtilities.canUseDOM)() ? new ResizeObserver(handleResize) : undefined);
25
26
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -28,6 +29,7 @@ const useResizeObserverRef_unstable = (resizeCallback)=>{
28
29
  ]);
29
30
  _react.useEffect(()=>{
30
31
  return ()=>{
32
+ container.current = null;
31
33
  resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
32
34
  };
33
35
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1 +1 @@
1
- {"version":3,"sources":["useResizeObserverRef.js"],"sourcesContent":["import * as React from 'react';\nimport { debounce } from '../utilities/debounce';\nimport { canUseDOM } from '@fluentui/react-utilities';\n/**\n * useResizeObserverRef_unstable simplifies resize observer connection and ensures debounce/cleanup\n */ export const useResizeObserverRef_unstable = (resizeCallback)=>{\n const container = React.useRef(null);\n // the handler for resize observer\n const handleResize = debounce((entries, observer)=>{\n resizeCallback(entries, observer, container);\n });\n // Keep the reference of ResizeObserver in the state, as it should live through renders\n const [resizeObserver, setResizeObserver] = React.useState(()=>canUseDOM() ? new ResizeObserver(handleResize) : undefined);\n React.useEffect(()=>{\n // Update our state when resizeCallback changes\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();\n setResizeObserver(canUseDOM() ? new ResizeObserver(handleResize) : undefined);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n resizeCallback\n ]);\n React.useEffect(()=>{\n return ()=>{\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n const scrollRef = React.useCallback((instance)=>{\n if (container.current !== instance) {\n if (container.current) {\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.unobserve(container.current);\n }\n container.current = instance;\n if (container.current) {\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.observe(container.current);\n }\n }\n }, [\n resizeObserver\n ]);\n return scrollRef;\n};\n"],"names":["useResizeObserverRef_unstable","resizeCallback","container","React","useRef","handleResize","debounce","entries","observer","resizeObserver","setResizeObserver","useState","canUseDOM","ResizeObserver","undefined","useEffect","disconnect","scrollRef","useCallback","instance","current","unobserve","observe"],"mappings":";;;;+BAKiBA;;aAAAA;;;6DALM;0BACE;gCACC;AAGf,MAAMA,gCAAgC,CAACC,iBAAiB;IAC/D,MAAMC,YAAYC,OAAMC,MAAM,CAAC,IAAI;IACnC,kCAAkC;IAClC,MAAMC,eAAeC,IAAAA,kBAAQ,EAAC,CAACC,SAASC,WAAW;QAC/CP,eAAeM,SAASC,UAAUN;IACtC;IACA,uFAAuF;IACvF,MAAM,CAACO,gBAAgBC,kBAAkB,GAAGP,OAAMQ,QAAQ,CAAC,IAAIC,IAAAA,yBAAS,MAAK,IAAIC,eAAeR,gBAAgBS,SAAS;IACzHX,OAAMY,SAAS,CAAC,IAAI;QAChB,+CAA+C;QAC/CN,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeO,UAAU,EAAE;QAC3FN,kBAAkBE,IAAAA,yBAAS,MAAK,IAAIC,eAAeR,gBAAgBS,SAAS;IAChF,uDAAuD;IACvD,GAAG;QACCb;KACH;IACDE,OAAMY,SAAS,CAAC,IAAI;QAChB,OAAO,IAAI;YACPN,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeO,UAAU,EAAE;QAC/F;IACJ,uDAAuD;IACvD,GAAG,EAAE;IACL,MAAMC,YAAYd,OAAMe,WAAW,CAAC,CAACC,WAAW;QAC5C,IAAIjB,UAAUkB,OAAO,KAAKD,UAAU;YAChC,IAAIjB,UAAUkB,OAAO,EAAE;gBACnBX,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeY,SAAS,CAACnB,UAAUkB,OAAO,CAAC;YAC/G,CAAC;YACDlB,UAAUkB,OAAO,GAAGD;YACpB,IAAIjB,UAAUkB,OAAO,EAAE;gBACnBX,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAea,OAAO,CAACpB,UAAUkB,OAAO,CAAC;YAC7G,CAAC;QACL,CAAC;IACL,GAAG;QACCX;KACH;IACD,OAAOQ;AACX"}
1
+ {"version":3,"sources":["useResizeObserverRef.js"],"sourcesContent":["import * as React from 'react';\nimport { debounce } from '../utilities/debounce';\nimport { canUseDOM } from '@fluentui/react-utilities';\n/**\n * useResizeObserverRef_unstable simplifies resize observer connection and ensures debounce/cleanup\n */ export const useResizeObserverRef_unstable = (resizeCallback)=>{\n const container = React.useRef(null);\n // the handler for resize observer\n const handleResize = debounce((entries, observer)=>{\n resizeCallback(entries, observer, container);\n });\n // Keep the reference of ResizeObserver in the state, as it should live through renders\n const [resizeObserver, setResizeObserver] = React.useState(()=>canUseDOM() ? new ResizeObserver(handleResize) : undefined);\n React.useEffect(()=>{\n // Update our state when resizeCallback changes\n container.current = null;\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();\n setResizeObserver(canUseDOM() ? new ResizeObserver(handleResize) : undefined);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n resizeCallback\n ]);\n React.useEffect(()=>{\n return ()=>{\n container.current = null;\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n const scrollRef = React.useCallback((instance)=>{\n if (container.current !== instance) {\n if (container.current) {\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.unobserve(container.current);\n }\n container.current = instance;\n if (container.current) {\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.observe(container.current);\n }\n }\n }, [\n resizeObserver\n ]);\n return scrollRef;\n};\n"],"names":["useResizeObserverRef_unstable","resizeCallback","container","React","useRef","handleResize","debounce","entries","observer","resizeObserver","setResizeObserver","useState","canUseDOM","ResizeObserver","undefined","useEffect","current","disconnect","scrollRef","useCallback","instance","unobserve","observe"],"mappings":";;;;+BAKiBA;;aAAAA;;;6DALM;0BACE;gCACC;AAGf,MAAMA,gCAAgC,CAACC,iBAAiB;IAC/D,MAAMC,YAAYC,OAAMC,MAAM,CAAC,IAAI;IACnC,kCAAkC;IAClC,MAAMC,eAAeC,IAAAA,kBAAQ,EAAC,CAACC,SAASC,WAAW;QAC/CP,eAAeM,SAASC,UAAUN;IACtC;IACA,uFAAuF;IACvF,MAAM,CAACO,gBAAgBC,kBAAkB,GAAGP,OAAMQ,QAAQ,CAAC,IAAIC,IAAAA,yBAAS,MAAK,IAAIC,eAAeR,gBAAgBS,SAAS;IACzHX,OAAMY,SAAS,CAAC,IAAI;QAChB,+CAA+C;QAC/Cb,UAAUc,OAAO,GAAG,IAAI;QACxBP,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeQ,UAAU,EAAE;QAC3FP,kBAAkBE,IAAAA,yBAAS,MAAK,IAAIC,eAAeR,gBAAgBS,SAAS;IAChF,uDAAuD;IACvD,GAAG;QACCb;KACH;IACDE,OAAMY,SAAS,CAAC,IAAI;QAChB,OAAO,IAAI;YACPb,UAAUc,OAAO,GAAG,IAAI;YACxBP,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeQ,UAAU,EAAE;QAC/F;IACJ,uDAAuD;IACvD,GAAG,EAAE;IACL,MAAMC,YAAYf,OAAMgB,WAAW,CAAC,CAACC,WAAW;QAC5C,IAAIlB,UAAUc,OAAO,KAAKI,UAAU;YAChC,IAAIlB,UAAUc,OAAO,EAAE;gBACnBP,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeY,SAAS,CAACnB,UAAUc,OAAO,CAAC;YAC/G,CAAC;YACDd,UAAUc,OAAO,GAAGI;YACpB,IAAIlB,UAAUc,OAAO,EAAE;gBACnBP,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAea,OAAO,CAACpB,UAAUc,OAAO,CAAC;YAC7G,CAAC;QACL,CAAC;IACL,GAAG;QACCP;KACH;IACD,OAAOS;AACX"}
@@ -20,6 +20,8 @@ _export(exports, {
20
20
  useResizeObserverRef_unstable: ()=>_hooks.useResizeObserverRef_unstable,
21
21
  VirtualizerContextProvider: ()=>_utilities.VirtualizerContextProvider,
22
22
  useVirtualizerContext_unstable: ()=>_utilities.useVirtualizerContext_unstable,
23
+ scrollToItemStatic: ()=>_utilities.scrollToItemStatic,
24
+ scrollToItemDynamic: ()=>_utilities.scrollToItemDynamic,
23
25
  VirtualizerScrollView: ()=>_virtualizerScrollView.VirtualizerScrollView,
24
26
  virtualizerScrollViewClassNames: ()=>_virtualizerScrollView.virtualizerScrollViewClassNames,
25
27
  useVirtualizerScrollView_unstable: ()=>_virtualizerScrollView.useVirtualizerScrollView_unstable,
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export { Virtualizer, virtualizerClassNames, useVirtualizer_unstable, renderVirtualizer_unstable, useVirtualizerStyles_unstable } from './Virtualizer';\nexport { useIntersectionObserver, useStaticVirtualizerMeasure, useDynamicVirtualizerMeasure, useResizeObserverRef_unstable } from './Hooks';\nexport { VirtualizerContextProvider, useVirtualizerContext_unstable } from './Utilities';\nexport { VirtualizerScrollView, virtualizerScrollViewClassNames, useVirtualizerScrollView_unstable, renderVirtualizerScrollView_unstable, useVirtualizerScrollViewStyles_unstable } from './VirtualizerScrollView';\nexport { VirtualizerScrollViewDynamic, virtualizerScrollViewDynamicClassNames, useVirtualizerScrollViewDynamic_unstable, renderVirtualizerScrollViewDynamic_unstable, useVirtualizerScrollViewDynamicStyles_unstable } from './VirtualizerScrollViewDynamic';\n"],"names":["Virtualizer","virtualizerClassNames","useVirtualizer_unstable","renderVirtualizer_unstable","useVirtualizerStyles_unstable","useIntersectionObserver","useStaticVirtualizerMeasure","useDynamicVirtualizerMeasure","useResizeObserverRef_unstable","VirtualizerContextProvider","useVirtualizerContext_unstable","VirtualizerScrollView","virtualizerScrollViewClassNames","useVirtualizerScrollView_unstable","renderVirtualizerScrollView_unstable","useVirtualizerScrollViewStyles_unstable","VirtualizerScrollViewDynamic","virtualizerScrollViewDynamicClassNames","useVirtualizerScrollViewDynamic_unstable","renderVirtualizerScrollViewDynamic_unstable","useVirtualizerScrollViewDynamicStyles_unstable"],"mappings":";;;;;;;;;;;IAASA,WAAW,MAAXA,wBAAW;IAAEC,qBAAqB,MAArBA,kCAAqB;IAAEC,uBAAuB,MAAvBA,oCAAuB;IAAEC,0BAA0B,MAA1BA,uCAA0B;IAAEC,6BAA6B,MAA7BA,0CAA6B;IACtHC,uBAAuB,MAAvBA,8BAAuB;IAAEC,2BAA2B,MAA3BA,kCAA2B;IAAEC,4BAA4B,MAA5BA,mCAA4B;IAAEC,6BAA6B,MAA7BA,oCAA6B;IACjHC,0BAA0B,MAA1BA,qCAA0B;IAAEC,8BAA8B,MAA9BA,yCAA8B;IAC1DC,qBAAqB,MAArBA,4CAAqB;IAAEC,+BAA+B,MAA/BA,sDAA+B;IAAEC,iCAAiC,MAAjCA,wDAAiC;IAAEC,oCAAoC,MAApCA,2DAAoC;IAAEC,uCAAuC,MAAvCA,8DAAuC;IACxKC,4BAA4B,MAA5BA,0DAA4B;IAAEC,sCAAsC,MAAtCA,oEAAsC;IAAEC,wCAAwC,MAAxCA,sEAAwC;IAAEC,2CAA2C,MAA3CA,yEAA2C;IAAEC,8CAA8C,MAA9CA,4EAA8C;;6BAJ7E;uBACL;2BACvD;uCAC8G;8CACmC"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export { Virtualizer, virtualizerClassNames, useVirtualizer_unstable, renderVirtualizer_unstable, useVirtualizerStyles_unstable } from './Virtualizer';\nexport { useIntersectionObserver, useStaticVirtualizerMeasure, useDynamicVirtualizerMeasure, useResizeObserverRef_unstable } from './Hooks';\nexport { VirtualizerContextProvider, useVirtualizerContext_unstable, scrollToItemStatic, scrollToItemDynamic } from './Utilities';\nexport { VirtualizerScrollView, virtualizerScrollViewClassNames, useVirtualizerScrollView_unstable, renderVirtualizerScrollView_unstable, useVirtualizerScrollViewStyles_unstable } from './VirtualizerScrollView';\nexport { VirtualizerScrollViewDynamic, virtualizerScrollViewDynamicClassNames, useVirtualizerScrollViewDynamic_unstable, renderVirtualizerScrollViewDynamic_unstable, useVirtualizerScrollViewDynamicStyles_unstable } from './VirtualizerScrollViewDynamic';\n"],"names":["Virtualizer","virtualizerClassNames","useVirtualizer_unstable","renderVirtualizer_unstable","useVirtualizerStyles_unstable","useIntersectionObserver","useStaticVirtualizerMeasure","useDynamicVirtualizerMeasure","useResizeObserverRef_unstable","VirtualizerContextProvider","useVirtualizerContext_unstable","scrollToItemStatic","scrollToItemDynamic","VirtualizerScrollView","virtualizerScrollViewClassNames","useVirtualizerScrollView_unstable","renderVirtualizerScrollView_unstable","useVirtualizerScrollViewStyles_unstable","VirtualizerScrollViewDynamic","virtualizerScrollViewDynamicClassNames","useVirtualizerScrollViewDynamic_unstable","renderVirtualizerScrollViewDynamic_unstable","useVirtualizerScrollViewDynamicStyles_unstable"],"mappings":";;;;;;;;;;;IAASA,WAAW,MAAXA,wBAAW;IAAEC,qBAAqB,MAArBA,kCAAqB;IAAEC,uBAAuB,MAAvBA,oCAAuB;IAAEC,0BAA0B,MAA1BA,uCAA0B;IAAEC,6BAA6B,MAA7BA,0CAA6B;IACtHC,uBAAuB,MAAvBA,8BAAuB;IAAEC,2BAA2B,MAA3BA,kCAA2B;IAAEC,4BAA4B,MAA5BA,mCAA4B;IAAEC,6BAA6B,MAA7BA,oCAA6B;IACjHC,0BAA0B,MAA1BA,qCAA0B;IAAEC,8BAA8B,MAA9BA,yCAA8B;IAAEC,kBAAkB,MAAlBA,6BAAkB;IAAEC,mBAAmB,MAAnBA,8BAAmB;IACnGC,qBAAqB,MAArBA,4CAAqB;IAAEC,+BAA+B,MAA/BA,sDAA+B;IAAEC,iCAAiC,MAAjCA,wDAAiC;IAAEC,oCAAoC,MAApCA,2DAAoC;IAAEC,uCAAuC,MAAvCA,8DAAuC;IACxKC,4BAA4B,MAA5BA,0DAA4B;IAAEC,sCAAsC,MAAtCA,oEAAsC;IAAEC,wCAAwC,MAAxCA,sEAAwC;IAAEC,2CAA2C,MAA3CA,yEAA2C;IAAEC,8CAA8C,MAA9CA,4EAA8C;;6BAJ7E;uBACL;2BACd;uCACqE;8CACmC"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "scrollToItemStatic", {
6
+ enumerable: true,
7
+ get: ()=>scrollToItemStatic
8
+ });
9
+ const scrollToItemStatic = (params)=>{
10
+ const { index , itemSize , totalItems , scrollViewRef , axis ='vertical' , reversed =false , behavior ='auto' } = params;
11
+ if (axis === 'horizontal') {
12
+ if (reversed) {
13
+ var _scrollViewRef_current;
14
+ (_scrollViewRef_current = scrollViewRef.current) === null || _scrollViewRef_current === void 0 ? void 0 : _scrollViewRef_current.scrollTo({
15
+ left: totalItems * itemSize - itemSize * index,
16
+ behavior
17
+ });
18
+ } else {
19
+ var _scrollViewRef_current1;
20
+ (_scrollViewRef_current1 = scrollViewRef.current) === null || _scrollViewRef_current1 === void 0 ? void 0 : _scrollViewRef_current1.scrollTo({
21
+ left: itemSize * index,
22
+ behavior
23
+ });
24
+ }
25
+ } else {
26
+ if (reversed) {
27
+ var _scrollViewRef_current2;
28
+ (_scrollViewRef_current2 = scrollViewRef.current) === null || _scrollViewRef_current2 === void 0 ? void 0 : _scrollViewRef_current2.scrollTo({
29
+ top: totalItems * itemSize - itemSize * index,
30
+ behavior
31
+ });
32
+ } else {
33
+ var _scrollViewRef_current3;
34
+ (_scrollViewRef_current3 = scrollViewRef.current) === null || _scrollViewRef_current3 === void 0 ? void 0 : _scrollViewRef_current3.scrollTo({
35
+ top: itemSize * index,
36
+ behavior
37
+ });
38
+ }
39
+ }
40
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["imperativeScrolling.js"],"sourcesContent":["export const scrollToItemStatic = (params)=>{\n const { index , itemSize , totalItems , scrollViewRef , axis ='vertical' , reversed =false , behavior ='auto' } = params;\n if (axis === 'horizontal') {\n if (reversed) {\n var _scrollViewRef_current;\n (_scrollViewRef_current = scrollViewRef.current) === null || _scrollViewRef_current === void 0 ? void 0 : _scrollViewRef_current.scrollTo({\n left: totalItems * itemSize - itemSize * index,\n behavior\n });\n } else {\n var _scrollViewRef_current1;\n (_scrollViewRef_current1 = scrollViewRef.current) === null || _scrollViewRef_current1 === void 0 ? void 0 : _scrollViewRef_current1.scrollTo({\n left: itemSize * index,\n behavior\n });\n }\n } else {\n if (reversed) {\n var _scrollViewRef_current2;\n (_scrollViewRef_current2 = scrollViewRef.current) === null || _scrollViewRef_current2 === void 0 ? void 0 : _scrollViewRef_current2.scrollTo({\n top: totalItems * itemSize - itemSize * index,\n behavior\n });\n } else {\n var _scrollViewRef_current3;\n (_scrollViewRef_current3 = scrollViewRef.current) === null || _scrollViewRef_current3 === void 0 ? void 0 : _scrollViewRef_current3.scrollTo({\n top: itemSize * index,\n behavior\n });\n }\n }\n};\n"],"names":["scrollToItemStatic","params","index","itemSize","totalItems","scrollViewRef","axis","reversed","behavior","_scrollViewRef_current","current","scrollTo","left","_scrollViewRef_current1","_scrollViewRef_current2","top","_scrollViewRef_current3"],"mappings":";;;;+BAAaA;;aAAAA;;AAAN,MAAMA,qBAAqB,CAACC,SAAS;IACxC,MAAM,EAAEC,MAAK,EAAGC,SAAQ,EAAGC,WAAU,EAAGC,cAAa,EAAGC,MAAM,WAAU,EAAGC,UAAU,KAAK,CAAA,EAAGC,UAAU,OAAM,EAAG,GAAGP;IACnH,IAAIK,SAAS,cAAc;QACvB,IAAIC,UAAU;YACV,IAAIE;YACHA,CAAAA,yBAAyBJ,cAAcK,OAAO,AAAD,MAAO,IAAI,IAAID,2BAA2B,KAAK,IAAI,KAAK,IAAIA,uBAAuBE,QAAQ,CAAC;gBACtIC,MAAMR,aAAaD,WAAWA,WAAWD;gBACzCM;YACJ,EAAE;QACN,OAAO;YACH,IAAIK;YACHA,CAAAA,0BAA0BR,cAAcK,OAAO,AAAD,MAAO,IAAI,IAAIG,4BAA4B,KAAK,IAAI,KAAK,IAAIA,wBAAwBF,QAAQ,CAAC;gBACzIC,MAAMT,WAAWD;gBACjBM;YACJ,EAAE;QACN,CAAC;IACL,OAAO;QACH,IAAID,UAAU;YACV,IAAIO;YACHA,CAAAA,0BAA0BT,cAAcK,OAAO,AAAD,MAAO,IAAI,IAAII,4BAA4B,KAAK,IAAI,KAAK,IAAIA,wBAAwBH,QAAQ,CAAC;gBACzII,KAAKX,aAAaD,WAAWA,WAAWD;gBACxCM;YACJ,EAAE;QACN,OAAO;YACH,IAAIQ;YACHA,CAAAA,0BAA0BX,cAAcK,OAAO,AAAD,MAAO,IAAI,IAAIM,4BAA4B,KAAK,IAAI,KAAK,IAAIA,wBAAwBL,QAAQ,CAAC;gBACzII,KAAKZ,WAAWD;gBAChBM;YACJ,EAAE;QACN,CAAC;IACL,CAAC;AACL"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "scrollToItemDynamic", {
6
+ enumerable: true,
7
+ get: ()=>scrollToItemDynamic
8
+ });
9
+ const scrollToItemDynamic = (params)=>{
10
+ const { index , itemSizes , totalSize , scrollViewRef , axis ='vertical' , reversed =false , behavior ='auto' } = params;
11
+ if (!itemSizes.current) {
12
+ return;
13
+ }
14
+ if (itemSizes.current === null || itemSizes.current.length < index) {
15
+ // null check - abort
16
+ return;
17
+ }
18
+ let itemDepth = 0;
19
+ for(let i = 0; i < index; i++){
20
+ if (i < index) {
21
+ itemDepth += itemSizes.current[i];
22
+ }
23
+ }
24
+ if (axis === 'horizontal') {
25
+ if (reversed) {
26
+ var _scrollViewRef_current;
27
+ (_scrollViewRef_current = scrollViewRef.current) === null || _scrollViewRef_current === void 0 ? void 0 : _scrollViewRef_current.scrollTo({
28
+ left: totalSize - itemDepth,
29
+ behavior
30
+ });
31
+ } else {
32
+ var _scrollViewRef_current1;
33
+ (_scrollViewRef_current1 = scrollViewRef.current) === null || _scrollViewRef_current1 === void 0 ? void 0 : _scrollViewRef_current1.scrollTo({
34
+ left: itemDepth,
35
+ behavior
36
+ });
37
+ }
38
+ } else {
39
+ if (reversed) {
40
+ var _scrollViewRef_current2;
41
+ (_scrollViewRef_current2 = scrollViewRef.current) === null || _scrollViewRef_current2 === void 0 ? void 0 : _scrollViewRef_current2.scrollTo({
42
+ top: totalSize - itemDepth,
43
+ behavior
44
+ });
45
+ } else {
46
+ var _scrollViewRef_current3;
47
+ (_scrollViewRef_current3 = scrollViewRef.current) === null || _scrollViewRef_current3 === void 0 ? void 0 : _scrollViewRef_current3.scrollTo({
48
+ top: itemDepth,
49
+ behavior
50
+ });
51
+ }
52
+ }
53
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["imperativeScrollingDynamic.js"],"sourcesContent":["export const scrollToItemDynamic = (params)=>{\n const { index , itemSizes , totalSize , scrollViewRef , axis ='vertical' , reversed =false , behavior ='auto' } = params;\n if (!itemSizes.current) {\n return;\n }\n if (itemSizes.current === null || itemSizes.current.length < index) {\n // null check - abort\n return;\n }\n let itemDepth = 0;\n for(let i = 0; i < index; i++){\n if (i < index) {\n itemDepth += itemSizes.current[i];\n }\n }\n if (axis === 'horizontal') {\n if (reversed) {\n var _scrollViewRef_current;\n (_scrollViewRef_current = scrollViewRef.current) === null || _scrollViewRef_current === void 0 ? void 0 : _scrollViewRef_current.scrollTo({\n left: totalSize - itemDepth,\n behavior\n });\n } else {\n var _scrollViewRef_current1;\n (_scrollViewRef_current1 = scrollViewRef.current) === null || _scrollViewRef_current1 === void 0 ? void 0 : _scrollViewRef_current1.scrollTo({\n left: itemDepth,\n behavior\n });\n }\n } else {\n if (reversed) {\n var _scrollViewRef_current2;\n (_scrollViewRef_current2 = scrollViewRef.current) === null || _scrollViewRef_current2 === void 0 ? void 0 : _scrollViewRef_current2.scrollTo({\n top: totalSize - itemDepth,\n behavior\n });\n } else {\n var _scrollViewRef_current3;\n (_scrollViewRef_current3 = scrollViewRef.current) === null || _scrollViewRef_current3 === void 0 ? void 0 : _scrollViewRef_current3.scrollTo({\n top: itemDepth,\n behavior\n });\n }\n }\n};\n"],"names":["scrollToItemDynamic","params","index","itemSizes","totalSize","scrollViewRef","axis","reversed","behavior","current","length","itemDepth","i","_scrollViewRef_current","scrollTo","left","_scrollViewRef_current1","_scrollViewRef_current2","top","_scrollViewRef_current3"],"mappings":";;;;+BAAaA;;aAAAA;;AAAN,MAAMA,sBAAsB,CAACC,SAAS;IACzC,MAAM,EAAEC,MAAK,EAAGC,UAAS,EAAGC,UAAS,EAAGC,cAAa,EAAGC,MAAM,WAAU,EAAGC,UAAU,KAAK,CAAA,EAAGC,UAAU,OAAM,EAAG,GAAGP;IACnH,IAAI,CAACE,UAAUM,OAAO,EAAE;QACpB;IACJ,CAAC;IACD,IAAIN,UAAUM,OAAO,KAAK,IAAI,IAAIN,UAAUM,OAAO,CAACC,MAAM,GAAGR,OAAO;QAChE,qBAAqB;QACrB;IACJ,CAAC;IACD,IAAIS,YAAY;IAChB,IAAI,IAAIC,IAAI,GAAGA,IAAIV,OAAOU,IAAI;QAC1B,IAAIA,IAAIV,OAAO;YACXS,aAAaR,UAAUM,OAAO,CAACG,EAAE;QACrC,CAAC;IACL;IACA,IAAIN,SAAS,cAAc;QACvB,IAAIC,UAAU;YACV,IAAIM;YACHA,CAAAA,yBAAyBR,cAAcI,OAAO,AAAD,MAAO,IAAI,IAAII,2BAA2B,KAAK,IAAI,KAAK,IAAIA,uBAAuBC,QAAQ,CAAC;gBACtIC,MAAMX,YAAYO;gBAClBH;YACJ,EAAE;QACN,OAAO;YACH,IAAIQ;YACHA,CAAAA,0BAA0BX,cAAcI,OAAO,AAAD,MAAO,IAAI,IAAIO,4BAA4B,KAAK,IAAI,KAAK,IAAIA,wBAAwBF,QAAQ,CAAC;gBACzIC,MAAMJ;gBACNH;YACJ,EAAE;QACN,CAAC;IACL,OAAO;QACH,IAAID,UAAU;YACV,IAAIU;YACHA,CAAAA,0BAA0BZ,cAAcI,OAAO,AAAD,MAAO,IAAI,IAAIQ,4BAA4B,KAAK,IAAI,KAAK,IAAIA,wBAAwBH,QAAQ,CAAC;gBACzII,KAAKd,YAAYO;gBACjBH;YACJ,EAAE;QACN,OAAO;YACH,IAAIW;YACHA,CAAAA,0BAA0Bd,cAAcI,OAAO,AAAD,MAAO,IAAI,IAAIU,4BAA4B,KAAK,IAAI,KAAK,IAAIA,wBAAwBL,QAAQ,CAAC;gBACzII,KAAKP;gBACLH;YACJ,EAAE;QACN,CAAC;IACL,CAAC;AACL"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
+ _exportStar(require("./imperativeScrolling"), exports);
7
+ _exportStar(require("./imperativeScrolling.types"), exports);
8
+ _exportStar(require("./imperativeScrollingDynamic"), exports);
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export * from './imperativeScrolling';\nexport * from './imperativeScrolling.types';\nexport * from './imperativeScrollingDynamic';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA"}
@@ -4,3 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
6
  _exportStar(require("./VirtualizerContext"), exports);
7
+ _exportStar(require("./ImperativeScrolling"), exports);
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export * from './VirtualizerContext';\n"],"names":[],"mappings":";;;;;oBAAc"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export * from './VirtualizerContext';\nexport * from './ImperativeScrolling';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-virtualizer",
3
- "version": "9.0.0-alpha.22",
3
+ "version": "9.0.0-alpha.23",
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,13 +27,13 @@
27
27
  "devDependencies": {
28
28
  "@fluentui/eslint-plugin": "*",
29
29
  "@fluentui/react-conformance": "*",
30
- "@fluentui/react-conformance-griffel": "9.0.0-beta.22",
30
+ "@fluentui/react-conformance-griffel": "9.0.0-beta.23",
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.6",
36
- "@fluentui/react-utilities": "^9.9.2",
35
+ "@fluentui/react-jsx-runtime": "9.0.0-alpha.7",
36
+ "@fluentui/react-utilities": "^9.9.3",
37
37
  "@griffel/react": "^1.5.7",
38
38
  "@swc/helpers": "^0.4.14"
39
39
  },