@fluentui/react-virtualizer 9.0.0-alpha.87 → 9.0.0-alpha.89
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.md +29 -5
- package/dist/index.d.ts +21 -22
- package/lib/Hooks.js +1 -1
- package/lib/Hooks.js.map +1 -1
- package/lib/Utilities.js +1 -1
- package/lib/Utilities.js.map +1 -1
- package/lib/Virtualizer.js +1 -1
- package/lib/Virtualizer.js.map +1 -1
- package/lib/VirtualizerScrollView.js +1 -1
- package/lib/VirtualizerScrollView.js.map +1 -1
- package/lib/VirtualizerScrollViewDynamic.js +1 -1
- package/lib/VirtualizerScrollViewDynamic.js.map +1 -1
- package/lib/components/Virtualizer/Virtualizer.js +1 -0
- package/lib/components/Virtualizer/Virtualizer.js.map +1 -1
- package/lib/components/Virtualizer/Virtualizer.types.js.map +1 -1
- package/lib/components/Virtualizer/index.js +4 -5
- package/lib/components/Virtualizer/index.js.map +1 -1
- package/lib/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizer.js +53 -45
- package/lib/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib/components/VirtualizerScrollView/VirtualizerScrollView.types.js +1 -1
- package/lib/components/VirtualizerScrollView/VirtualizerScrollView.types.js.map +1 -1
- package/lib/components/VirtualizerScrollView/index.js +4 -5
- package/lib/components/VirtualizerScrollView/index.js.map +1 -1
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js +1 -2
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/index.js +4 -5
- package/lib/components/VirtualizerScrollViewDynamic/index.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +2 -3
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -1
- package/lib/hooks/hooks.types.js +1 -4
- package/lib/hooks/hooks.types.js.map +1 -1
- package/lib/hooks/index.js +5 -6
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useDynamicPagination.js +2 -3
- package/lib/hooks/useDynamicPagination.js.map +1 -1
- package/lib/hooks/useIntersectionObserver.js.map +1 -1
- package/lib/hooks/useMeasureList.js +1 -2
- package/lib/hooks/useMeasureList.js.map +1 -1
- package/lib/hooks/useMutationObserver.js.map +1 -1
- package/lib/hooks/useStaticPagination.js +2 -3
- package/lib/hooks/useStaticPagination.js.map +1 -1
- package/lib/utilities/ImperativeScrolling/imperativeScrolling.types.js +1 -1
- package/lib/utilities/ImperativeScrolling/imperativeScrolling.types.js.map +1 -1
- package/lib/utilities/ImperativeScrolling/index.js +2 -3
- package/lib/utilities/ImperativeScrolling/index.js.map +1 -1
- package/lib/utilities/VirtualizerContext/VirtualizerContext.js +3 -4
- package/lib/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -1
- package/lib/utilities/VirtualizerContext/index.js +1 -2
- package/lib/utilities/VirtualizerContext/index.js.map +1 -1
- package/lib/utilities/index.js +2 -2
- package/lib/utilities/index.js.map +1 -1
- package/lib-commonjs/Hooks.js +30 -2
- package/lib-commonjs/Hooks.js.map +1 -1
- package/lib-commonjs/Utilities.js +24 -2
- package/lib-commonjs/Utilities.js.map +1 -1
- package/lib-commonjs/Virtualizer.js +27 -2
- package/lib-commonjs/Virtualizer.js.map +1 -1
- package/lib-commonjs/VirtualizerScrollView.js +24 -2
- package/lib-commonjs/VirtualizerScrollView.js.map +1 -1
- package/lib-commonjs/VirtualizerScrollViewDynamic.js +24 -2
- package/lib-commonjs/VirtualizerScrollViewDynamic.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/Virtualizer.js +2 -0
- package/lib-commonjs/components/Virtualizer/Virtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/Virtualizer.types.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/index.js +30 -6
- package/lib-commonjs/components/Virtualizer/index.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js +54 -45
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.types.js +2 -0
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.types.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/index.js +27 -6
- package/lib-commonjs/components/VirtualizerScrollView/index.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js +2 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js +27 -6
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +2 -2
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -1
- package/lib-commonjs/hooks/hooks.types.js +3 -4
- package/lib-commonjs/hooks/hooks.types.js.map +1 -1
- package/lib-commonjs/hooks/index.js +34 -7
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useDynamicPagination.js +2 -2
- package/lib-commonjs/hooks/useDynamicPagination.js.map +1 -1
- package/lib-commonjs/hooks/useIntersectionObserver.js.map +1 -1
- package/lib-commonjs/hooks/useMeasureList.js +1 -1
- package/lib-commonjs/hooks/useMeasureList.js.map +1 -1
- package/lib-commonjs/hooks/useMutationObserver.js.map +1 -1
- package/lib-commonjs/hooks/useStaticPagination.js +2 -2
- package/lib-commonjs/hooks/useStaticPagination.js.map +1 -1
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.types.js +2 -0
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.types.js.map +1 -1
- package/lib-commonjs/utilities/ImperativeScrolling/index.js +16 -4
- package/lib-commonjs/utilities/ImperativeScrolling/index.js.map +1 -1
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js +3 -3
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -1
- package/lib-commonjs/utilities/VirtualizerContext/index.js +18 -3
- package/lib-commonjs/utilities/VirtualizerContext/index.js.map +1 -1
- package/lib-commonjs/utilities/index.js +25 -3
- package/lib-commonjs/utilities/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Virtualizer/useVirtualizer.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { VirtualizerProps, VirtualizerState } from './Virtualizer.types';\n\nimport { useEffect, useRef, useCallback, useImperativeHandle, useState, useReducer } from 'react';\nimport { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { slot, useTimeout } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n 'use no memo';\n\n const {\n itemSize,\n numItems,\n virtualizerLength,\n children: renderChild,\n getItemSize,\n bufferItems = Math.round(virtualizerLength / 4.0),\n bufferSize = Math.floor(bufferItems / 2.0) * itemSize,\n axis = 'vertical',\n reversed = false,\n virtualizerContext,\n onRenderedFlaggedIndex,\n imperativeVirtualizerRef,\n containerSizeRef,\n scrollViewRef,\n enableScrollLoad,\n updateScrollPosition,\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\n const flaggedIndex = useRef<number | null>(null);\n const actualIndex = _virtualizerContext.contextIndex;\n\n // Just in case our ref gets out of date vs the context during a re-render\n if (_virtualizerContext.contextIndex !== actualIndexRef.current) {\n actualIndexRef.current = _virtualizerContext.contextIndex;\n }\n const setActualIndex = useCallback(\n (index: number) => {\n actualIndexRef.current = index;\n _virtualizerContext.setContextIndex(index);\n },\n [_virtualizerContext],\n );\n\n // Store ref to before padding element\n const beforeElementRef = useRef<HTMLElement | null>(null);\n\n // Store ref to before padding element\n const afterElementRef = useRef<HTMLElement | null>(null);\n\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */\n const childProgressiveSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n if (virtualizerContext?.childProgressiveSizes) {\n virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;\n }\n\n // The internal tracking REF for child array (updates often).\n const childArray = useRef<ReactNode[]>(new Array(virtualizerLength));\n\n const populateSizeArrays = () => {\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array<number>(numItems);\n }\n\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array<number>(numItems);\n if (virtualizerContext?.childProgressiveSizes) {\n virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;\n }\n }\n\n for (let index = 0; index < numItems; index++) {\n childSizes.current[index] = getItemSize(index);\n if (index === 0) {\n childProgressiveSizes.current[index] = childSizes.current[index];\n } else {\n childProgressiveSizes.current[index] = childProgressiveSizes.current[index - 1] + childSizes.current[index];\n }\n }\n };\n\n const [isScrolling, setIsScrolling] = useState<boolean>(false);\n const [setScrollTimer, clearScrollTimer] = useTimeout();\n const scrollCounter = useRef<number>(0);\n\n const initializeScrollingTimer = useCallback(() => {\n if (!enableScrollLoad) {\n // Disabled by default for reduction of render callbacks\n return;\n }\n /*\n * This can be considered the 'velocity' required to start 'isScrolling'\n * INIT_SCROLL_FLAG_REQ: Number of renders required to activate isScrolling\n * INIT_SCROLL_FLAG_DELAY: Amount of time (ms) before current number of renders is reset\n * - Maybe we should let users customize these in the future.\n */\n const INIT_SCROLL_FLAG_REQ = 10;\n const INIT_SCROLL_FLAG_DELAY = 100;\n\n scrollCounter.current++;\n if (scrollCounter.current >= INIT_SCROLL_FLAG_REQ) {\n setIsScrolling(true);\n }\n clearScrollTimer();\n setScrollTimer(() => {\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n }, [clearScrollTimer, setScrollTimer, enableScrollLoad]);\n\n useEffect(() => {\n initializeScrollingTimer();\n }, [actualIndex, initializeScrollingTimer]);\n\n const updateChildRows = useCallback(\n (newIndex: number) => {\n if (numItems === 0) {\n /* Nothing to virtualize */\n return;\n }\n\n /*\n We reset the array every time to ensure children are re-rendered\n This function should only be called when update is nessecary\n */\n childArray.current = new Array(virtualizerLength);\n const _actualIndex = Math.max(newIndex, 0);\n const end = Math.min(_actualIndex + virtualizerLength, numItems);\n for (let i = _actualIndex; i < end; i++) {\n childArray.current[i - _actualIndex] = renderChild(i, isScrolling);\n }\n },\n [isScrolling, numItems, renderChild, virtualizerLength],\n );\n\n const updateCurrentItemSizes = useCallback(\n (newIndex: number) => {\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n\n let didUpdate = false;\n for (let i = startIndex; i < endIndex; i++) {\n const newSize = getItemSize(i);\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n\n if (didUpdate) {\n // Update our progressive size array\n for (let i = startIndex; i < numItems; i++) {\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n },\n [getItemSize, numItems, virtualizerLength],\n );\n\n const batchUpdateNewIndex = useCallback(\n (index: number) => {\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\n\n // State setters\n setActualIndex(index);\n },\n [setActualIndex, updateChildRows, updateCurrentItemSizes],\n );\n\n const findIndexRecursive = useCallback(\n (scrollPos: number, lowIndex: number, highIndex: number): number => {\n if (lowIndex > highIndex) {\n // We shouldn't get here - but no-op the index if we do.\n return actualIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */\n return midpoint;\n }\n\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n },\n [actualIndex],\n );\n\n const getIndexFromSizeArray = useCallback(\n (scrollPos: number): number => {\n /* Quick searches our progressive height array */\n if (\n scrollPos === 0 ||\n childProgressiveSizes.current.length === 0 ||\n scrollPos <= childProgressiveSizes.current[0]\n ) {\n // Check start\n return 0;\n }\n\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n },\n [findIndexRecursive],\n );\n const getIndexFromScrollPosition = useCallback(\n (scrollPos: number) => {\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n\n return getIndexFromSizeArray(scrollPos);\n },\n [getIndexFromSizeArray, getItemSize, itemSize],\n );\n\n const calculateTotalSize = useCallback(() => {\n if (!getItemSize) {\n return itemSize * numItems;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n }, [getItemSize, itemSize, numItems]);\n\n const calculateBefore = useCallback(() => {\n const currentIndex = Math.min(actualIndex, numItems - 1);\n\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return currentIndex * itemSize;\n }\n\n if (currentIndex <= 0) {\n return 0;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[currentIndex - 1];\n }, [actualIndex, getItemSize, itemSize, numItems]);\n\n const calculateAfter = useCallback(() => {\n if (numItems === 0 || actualIndex + virtualizerLength >= numItems) {\n return 0;\n }\n\n const lastItemIndex = Math.min(actualIndex + virtualizerLength, numItems);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex;\n return remainingItems * itemSize;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];\n }, [actualIndex, getItemSize, itemSize, numItems, virtualizerLength]);\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n useCallback(\n // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n // eslint-disable-next-line no-restricted-globals\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (actualIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n\n if (entries.length === 0) {\n // No entries found, return.\n return;\n }\n // Find the latest entry that is intersecting\n const sortedEntries = entries.sort((entry1, entry2) => entry2.time - entry1.time);\n const latestEntry = sortedEntries.find(entry => {\n return entry.isIntersecting;\n });\n\n if (!latestEntry) {\n return;\n }\n\n // We have to be sure our item sizes are up to date with current indexed ref before calculation\n // Check if we still need\n updateCurrentItemSizes(actualIndexRef.current);\n\n const calculateOverBuffer = (): number => {\n /**\n * We avoid using the scroll ref scrollTop, it may be incorrect\n * as virtualization may exist within a scroll view with other elements\n * The benefit of using IO is that we can detect relative scrolls,\n * so any items can be placed around the virtualizer in the scroll view\n */\n let measurementPos = 0;\n if (latestEntry.target === afterElementRef.current) {\n // Get after buffers position\n measurementPos = calculateTotalSize() - calculateAfter();\n\n // Get exact intersection position based on overflow size (how far into IO did we scroll?)\n const overflowAmount =\n axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;\n // Add to original after position\n measurementPos += overflowAmount;\n // Ignore buffer size (IO offset)\n measurementPos -= bufferSize;\n // we hit the after buffer and detected the end of view, we need to find the start index.\n measurementPos -= containerSizeRef.current ?? 0;\n\n // Calculate how far past the window bounds we are (this will be zero if IO is within window)\n const hOverflow = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;\n const hOverflowReversed = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;\n const wOverflow = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;\n const wOverflowReversed = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;\n const widthOverflow = reversed ? wOverflowReversed : wOverflow;\n const heightOverflow = reversed ? hOverflowReversed : hOverflow;\n const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;\n\n if (reversed) {\n measurementPos += additionalOverflow;\n } else {\n measurementPos -= additionalOverflow;\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n // Get before buffers position\n measurementPos = calculateBefore();\n\n // Get exact intersection position based on overflow size (how far into window did we scroll IO?)\n const overflowAmount =\n axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;\n\n // Minus from original before position\n measurementPos -= overflowAmount;\n // Ignore buffer size (IO offset)\n measurementPos += bufferSize;\n // Calculate how far past the window bounds we are (this will be zero if IO is within window)\n const hOverflow = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;\n const hOverflowReversed = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;\n const wOverflow = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;\n const wOverflowReversed = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;\n const widthOverflow = reversed ? wOverflowReversed : wOverflow;\n const heightOverflow = reversed ? hOverflowReversed : hOverflow;\n const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;\n\n if (reversed) {\n measurementPos += additionalOverflow;\n } else {\n measurementPos -= additionalOverflow;\n }\n }\n\n return measurementPos;\n };\n\n // Get exact relative 'scrollTop' via IO values\n const measurementPos = calculateOverBuffer();\n\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n\n const startIndex = getIndexFromScrollPosition(measurementPos) - bufferItems;\n\n // Safety limits\n const newStartIndex = Math.min(Math.max(startIndex, 0), maxIndex);\n flushSync(() => {\n // Callback to allow measure functions to check virtualizer length\n if (newStartIndex + virtualizerLength >= numItems && actualIndex + virtualizerLength >= numItems) {\n // We've already hit the end, no need to update state.\n return;\n }\n updateScrollPosition?.(measurementPos);\n if (actualIndex !== newStartIndex) {\n batchUpdateNewIndex(newStartIndex);\n }\n });\n },\n [\n actualIndex,\n virtualizerLength,\n axis,\n reversed,\n numItems,\n bufferSize,\n bufferItems,\n containerSizeRef,\n updateScrollPosition,\n batchUpdateNewIndex,\n calculateAfter,\n calculateBefore,\n calculateTotalSize,\n getIndexFromScrollPosition,\n updateCurrentItemSizes,\n ],\n ),\n {\n root: scrollViewRef ? scrollViewRef?.current : null,\n rootMargin: '0px',\n threshold: 0,\n },\n );\n\n const setBeforeRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n\n newList.push(beforeElementRef.current);\n\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n\n // Ensure we update array if before element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const setAfterRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n\n newList.push(afterElementRef.current);\n\n // Ensure we update array if after element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n // Initialize the size array before first render.\n const hasInitialized = useRef<boolean>(false);\n const initializeSizeArray = () => {\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n\n useImperativeHandle(\n imperativeVirtualizerRef,\n () => {\n return {\n progressiveSizes: childProgressiveSizes,\n nodeSizes: childSizes,\n setFlaggedIndex: (index: number | null) => (flaggedIndex.current = index),\n currentIndex: actualIndexRef,\n };\n },\n [childProgressiveSizes, childSizes],\n );\n\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(() => {\n if (actualIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n /*\n * forceUpdate:\n * We only want to trigger this when scrollLoading is enabled and set to false,\n * it will force re-render all children elements\n */\n const forceUpdate = useReducer(() => ({}), {})[1];\n // If the user passes in an updated renderChild function - update current children\n useEffect(() => {\n if (actualIndex >= 0) {\n updateChildRows(actualIndex);\n if (enableScrollLoad && !isScrolling) {\n forceUpdate();\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild, isScrolling]);\n\n useEffect(() => {\n // Ensure we repopulate if getItemSize callback changes\n populateSizeArrays();\n\n // We only run this effect on getItemSize change (recalc dynamic sizes)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getItemSize]);\n\n // Effect to check flag index on updates\n useEffect(() => {\n if (!onRenderedFlaggedIndex || flaggedIndex.current === null) {\n return;\n }\n if (actualIndex <= flaggedIndex.current && actualIndex + virtualizerLength >= flaggedIndex.current) {\n onRenderedFlaggedIndex(flaggedIndex.current);\n flaggedIndex.current = null;\n }\n }, [actualIndex, onRenderedFlaggedIndex, virtualizerLength]);\n\n // Ensure we have run through and updated the whole size list array at least once.\n initializeSizeArray();\n\n if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {\n // Child length mismatch, repopulate size arrays.\n populateSizeArrays();\n }\n\n // Ensure we recalc if virtualizer length changes\n const maxCompare = Math.min(virtualizerLength, numItems);\n if (childArray.current.length !== maxCompare && actualIndex + childArray.current.length < numItems) {\n updateChildRows(actualIndex);\n }\n\n const isFullyInitialized = hasInitialized.current && actualIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div',\n },\n virtualizedChildren: childArray.current,\n before: slot.always(props.before, {\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n after: slot.always(props.after, {\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeContainer: slot.always(props.beforeContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n afterContainer: slot.always(props.afterContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed,\n childSizes,\n childProgressiveSizes,\n };\n}\n"],"names":["useEffect","useRef","useCallback","useImperativeHandle","useState","useReducer","useIntersectionObserver","useVirtualizerContextState_unstable","slot","useTimeout","flushSync","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","axis","reversed","virtualizerContext","onRenderedFlaggedIndex","imperativeVirtualizerRef","containerSizeRef","scrollViewRef","enableScrollLoad","updateScrollPosition","_virtualizerContext","actualIndexRef","contextIndex","flaggedIndex","actualIndex","current","setActualIndex","index","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","populateSizeArrays","length","isScrolling","setIsScrolling","setScrollTimer","clearScrollTimer","scrollCounter","initializeScrollingTimer","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","updateChildRows","newIndex","_actualIndex","max","end","min","i","updateCurrentItemSizes","endIndex","startIndex","didUpdate","newSize","prevSize","batchUpdateNewIndex","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","getIndexFromScrollPosition","calculateTotalSize","calculateBefore","currentIndex","calculateAfter","lastItemIndex","remainingItems","setObserverList","entries","observer","sortedEntries","sort","entry1","entry2","time","latestEntry","find","entry","isIntersecting","calculateOverBuffer","measurementPos","target","overflowAmount","intersectionRect","height","width","hOverflow","boundingClientRect","top","hOverflowReversed","bottom","wOverflow","left","wOverflowReversed","right","widthOverflow","heightOverflow","additionalOverflow","maxIndex","newStartIndex","root","rootMargin","threshold","setBeforeRef","element","newList","push","setAfterRef","hasInitialized","initializeSizeArray","progressiveSizes","nodeSizes","setFlaggedIndex","forceUpdate","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","always","defaultProps","ref","role","elementType","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACvCsG,QAAQpI,KAAKyI,MAAM,CAACrI,MAAMgI,MAAM,EAAE;YAChCM,cAAc;gBACZC,KAAKrB;gBACLsB,MAAM;YACR;YACAC,aAAa;QACf;QACAR,OAAOrI,KAAKyI,MAAM,CAACrI,MAAMiI,KAAK,EAAE;YAC9BK,cAAc;gBACZC,KAAKjB;gBACLkB,MAAM;YACR;YACAC,aAAa;QACf;QACAP,iBAAiBtI,KAAKyI,MAAM,CAACrI,MAAMkI,eAAe,EAAE;YAClDI,cAAc;gBACZE,MAAM;YACR;YACAC,aAAa;QACf;QACAN,gBAAgBvI,KAAKyI,MAAM,CAACrI,MAAMmI,cAAc,EAAE;YAChDG,cAAc;gBACZE,MAAM;YACR;YACAC,aAAa;QACf;QACAC,oBAAoBZ,qBAAqBrD,oBAAoB;QAC7DkE,mBAAmBb,qBAAqBnD,mBAAmB;QAC3DiE,wBAAwBd,qBAAqBtD,uBAAuBrE,oBAAoBF;QACxF4I,uBAAuBpH;QACvBb;QACAF;QACAG;QACAmB;QACAE;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../src/components/Virtualizer/useVirtualizer.ts"],"sourcesContent":["import * as React from 'react';\nimport type { VirtualizerProps, VirtualizerState } from './Virtualizer.types';\n\nimport { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { slot, useTimeout } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n 'use no memo';\n\n const {\n itemSize,\n numItems,\n virtualizerLength,\n children: renderChild,\n getItemSize,\n bufferItems = Math.round(virtualizerLength / 4.0),\n bufferSize = Math.floor(bufferItems / 2.0) * itemSize,\n axis = 'vertical',\n reversed = false,\n virtualizerContext,\n onRenderedFlaggedIndex,\n imperativeVirtualizerRef,\n containerSizeRef,\n scrollViewRef,\n enableScrollLoad,\n updateScrollPosition,\n gap = 0,\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 = React.useRef<number>(_virtualizerContext.contextIndex);\n\n const flaggedIndex = React.useRef<number | null>(null);\n const actualIndex = _virtualizerContext.contextIndex;\n\n // Just in case our ref gets out of date vs the context during a re-render\n if (_virtualizerContext.contextIndex !== actualIndexRef.current) {\n actualIndexRef.current = _virtualizerContext.contextIndex;\n }\n const setActualIndex = React.useCallback(\n (index: number) => {\n actualIndexRef.current = index;\n _virtualizerContext.setContextIndex(index);\n },\n [_virtualizerContext],\n );\n\n // Store ref to before padding element\n const beforeElementRef = React.useRef<HTMLElement | null>(null);\n\n // Store ref to before padding element\n const afterElementRef = React.useRef<HTMLElement | 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 = React.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 = React.useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n if (virtualizerContext?.childProgressiveSizes) {\n virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;\n }\n\n // The internal tracking REF for child array (updates often).\n const childArray = React.useRef<React.ReactNode[]>(new Array(virtualizerLength));\n\n const populateSizeArrays = () => {\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array<number>(numItems);\n }\n\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array<number>(numItems);\n if (virtualizerContext?.childProgressiveSizes) {\n virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;\n }\n }\n\n for (let index = 0; index < numItems; index++) {\n const _gap = index < numItems - 1 ? gap : 0;\n childSizes.current[index] = getItemSize(index) + _gap;\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] = React.useState<boolean>(false);\n const [setScrollTimer, clearScrollTimer] = useTimeout();\n const scrollCounter = React.useRef<number>(0);\n\n const initializeScrollingTimer = React.useCallback(() => {\n if (!enableScrollLoad) {\n // Disabled by default for reduction of render callbacks\n return;\n }\n /*\n * This can be considered the 'velocity' required to start 'isScrolling'\n * INIT_SCROLL_FLAG_REQ: Number of renders required to activate isScrolling\n * INIT_SCROLL_FLAG_DELAY: Amount of time (ms) before current number of renders is reset\n * - Maybe we should let users customize these in the future.\n */\n const INIT_SCROLL_FLAG_REQ = 10;\n const INIT_SCROLL_FLAG_DELAY = 100;\n\n scrollCounter.current++;\n if (scrollCounter.current >= INIT_SCROLL_FLAG_REQ) {\n setIsScrolling(true);\n }\n clearScrollTimer();\n setScrollTimer(() => {\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n }, [clearScrollTimer, setScrollTimer, enableScrollLoad]);\n\n React.useEffect(() => {\n initializeScrollingTimer();\n }, [actualIndex, initializeScrollingTimer]);\n\n const updateChildRows = React.useCallback(\n (newIndex: number) => {\n if (numItems === 0) {\n /* Nothing to virtualize */\n return;\n }\n\n /*\n We reset the array every time to ensure children are re-rendered\n This function should only be called when update is nessecary\n */\n childArray.current = new Array(virtualizerLength);\n const _actualIndex = Math.max(newIndex, 0);\n const end = Math.min(_actualIndex + virtualizerLength, numItems);\n for (let i = _actualIndex; i < end; i++) {\n childArray.current[i - _actualIndex] = renderChild(i, isScrolling);\n }\n },\n [isScrolling, numItems, renderChild, virtualizerLength],\n );\n\n const updateCurrentItemSizes = React.useCallback(\n (newIndex: number) => {\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n\n let didUpdate = false;\n for (let i = startIndex; i < endIndex; i++) {\n const _gap = i < numItems - 1 ? gap : 0;\n const newSize = getItemSize(i) + _gap;\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n\n if (didUpdate) {\n // Update our progressive size array\n for (let i = startIndex; i < numItems; i++) {\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n },\n [getItemSize, numItems, virtualizerLength, gap],\n );\n\n const batchUpdateNewIndex = React.useCallback(\n (index: number) => {\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\n\n // State setters\n setActualIndex(index);\n },\n [setActualIndex, updateChildRows, updateCurrentItemSizes],\n );\n\n const findIndexRecursive = React.useCallback(\n (scrollPos: number, lowIndex: number, highIndex: number): number => {\n if (lowIndex > highIndex) {\n // We shouldn't get here - but no-op the index if we do.\n return actualIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */\n return midpoint;\n }\n\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n },\n [actualIndex],\n );\n\n const getIndexFromSizeArray = React.useCallback(\n (scrollPos: number): number => {\n /* Quick searches our progressive height array */\n if (\n scrollPos === 0 ||\n childProgressiveSizes.current.length === 0 ||\n scrollPos <= childProgressiveSizes.current[0]\n ) {\n // Check start\n return 0;\n }\n\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n },\n [findIndexRecursive],\n );\n const getIndexFromScrollPosition = React.useCallback(\n (scrollPos: number) => {\n if (!getItemSize) {\n return Math.round(scrollPos / (itemSize + gap));\n }\n\n return getIndexFromSizeArray(scrollPos);\n },\n [getIndexFromSizeArray, getItemSize, itemSize, gap],\n );\n\n const calculateTotalSize = React.useCallback(() => {\n if (!getItemSize) {\n return (itemSize + gap) * numItems;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n }, [getItemSize, itemSize, numItems, gap]);\n\n const calculateBefore = React.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 + gap);\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, gap]);\n\n const calculateAfter = React.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 + gap) - gap;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];\n }, [actualIndex, getItemSize, itemSize, numItems, virtualizerLength, gap]);\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n React.useCallback(\n // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n // eslint-disable-next-line no-restricted-globals\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (actualIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n\n if (entries.length === 0) {\n // No entries found, return.\n return;\n }\n // Find the latest entry that is intersecting\n const sortedEntries = entries.sort((entry1, entry2) => entry2.time - entry1.time);\n const latestEntry = sortedEntries.find(entry => {\n return entry.isIntersecting;\n });\n\n if (!latestEntry) {\n return;\n }\n\n // We have to be sure our item sizes are up to date with current indexed ref before calculation\n // Check if we still need\n updateCurrentItemSizes(actualIndexRef.current);\n\n const calculateOverBuffer = (): number => {\n /**\n * We avoid using the scroll ref scrollTop, it may be incorrect\n * as virtualization may exist within a scroll view with other elements\n * The benefit of using IO is that we can detect relative scrolls,\n * so any items can be placed around the virtualizer in the scroll view\n */\n let measurementPos = 0;\n if (latestEntry.target === afterElementRef.current) {\n // Get after buffers position\n measurementPos = calculateTotalSize() - calculateAfter();\n\n // Get exact intersection position based on overflow size (how far into IO did we scroll?)\n const overflowAmount =\n axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;\n // Add to original after position\n measurementPos += overflowAmount;\n // Ignore buffer size (IO offset)\n measurementPos -= bufferSize;\n // we hit the after buffer and detected the end of view, we need to find the start index.\n measurementPos -= containerSizeRef.current ?? 0;\n\n // Calculate how far past the window bounds we are (this will be zero if IO is within window)\n const hOverflow = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;\n const hOverflowReversed = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;\n const wOverflow = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;\n const wOverflowReversed = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;\n const widthOverflow = reversed ? wOverflowReversed : wOverflow;\n const heightOverflow = reversed ? hOverflowReversed : hOverflow;\n const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;\n\n if (reversed) {\n measurementPos += additionalOverflow;\n } else {\n measurementPos -= additionalOverflow;\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n // Get before buffers position\n measurementPos = calculateBefore();\n\n // Get exact intersection position based on overflow size (how far into window did we scroll IO?)\n const overflowAmount =\n axis === 'vertical' ? latestEntry.intersectionRect.height : latestEntry.intersectionRect.width;\n\n // Minus from original before position\n measurementPos -= overflowAmount;\n // Ignore buffer size (IO offset)\n measurementPos += bufferSize;\n // Calculate how far past the window bounds we are (this will be zero if IO is within window)\n const hOverflow = latestEntry.boundingClientRect.bottom - latestEntry.intersectionRect.bottom;\n const hOverflowReversed = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;\n const wOverflow = latestEntry.boundingClientRect.right - latestEntry.intersectionRect.right;\n const wOverflowReversed = latestEntry.boundingClientRect.left - latestEntry.intersectionRect.left;\n const widthOverflow = reversed ? wOverflowReversed : wOverflow;\n const heightOverflow = reversed ? hOverflowReversed : hOverflow;\n const additionalOverflow = axis === 'vertical' ? heightOverflow : widthOverflow;\n\n if (reversed) {\n measurementPos += additionalOverflow;\n } else {\n measurementPos -= additionalOverflow;\n }\n }\n\n return measurementPos;\n };\n\n // Get exact relative 'scrollTop' via IO values\n const measurementPos = calculateOverBuffer();\n\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n\n const startIndex = getIndexFromScrollPosition(measurementPos) - bufferItems;\n\n // Safety limits\n const newStartIndex = Math.min(Math.max(startIndex, 0), maxIndex);\n flushSync(() => {\n // Callback to allow measure functions to check virtualizer length\n if (newStartIndex + virtualizerLength >= numItems && actualIndex + virtualizerLength >= numItems) {\n // We've already hit the end, no need to update state.\n return;\n }\n updateScrollPosition?.(measurementPos);\n if (actualIndex !== newStartIndex) {\n batchUpdateNewIndex(newStartIndex);\n }\n });\n },\n [\n actualIndex,\n virtualizerLength,\n axis,\n reversed,\n numItems,\n bufferSize,\n bufferItems,\n containerSizeRef,\n updateScrollPosition,\n batchUpdateNewIndex,\n calculateAfter,\n calculateBefore,\n calculateTotalSize,\n getIndexFromScrollPosition,\n updateCurrentItemSizes,\n ],\n ),\n {\n root: scrollViewRef ? scrollViewRef?.current : null,\n rootMargin: '0px',\n threshold: 0,\n },\n );\n\n const setBeforeRef = React.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 = React.useCallback(\n (element: HTMLDivElement) => {\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n\n newList.push(afterElementRef.current);\n\n // Ensure we update array if after element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n // Initialize the size array before first render.\n const hasInitialized = React.useRef<boolean>(false);\n const initializeSizeArray = () => {\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n\n React.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 React.useEffect(() => {\n if (actualIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n /*\n * forceUpdate:\n * We only want to trigger this when scrollLoading is enabled and set to false,\n * it will force re-render all children elements\n */\n const forceUpdate = React.useReducer(() => ({}), {})[1];\n // If the user passes in an updated renderChild function - update current children\n React.useEffect(() => {\n if (actualIndex >= 0) {\n updateChildRows(actualIndex);\n if (enableScrollLoad && !isScrolling) {\n forceUpdate();\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild, isScrolling]);\n\n React.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, gap]);\n\n // Effect to check flag index on updates\n React.useEffect(() => {\n if (!onRenderedFlaggedIndex || flaggedIndex.current === null) {\n return;\n }\n if (actualIndex <= flaggedIndex.current && actualIndex + virtualizerLength >= flaggedIndex.current) {\n onRenderedFlaggedIndex(flaggedIndex.current);\n flaggedIndex.current = null;\n }\n }, [actualIndex, onRenderedFlaggedIndex, virtualizerLength]);\n\n // Ensure we have run through and updated the whole size list array at least once.\n initializeSizeArray();\n\n if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {\n // Child length mismatch, repopulate size arrays.\n populateSizeArrays();\n }\n\n // Ensure we recalc if virtualizer length changes\n const maxCompare = Math.min(virtualizerLength, numItems);\n if (childArray.current.length !== maxCompare && actualIndex + childArray.current.length < numItems) {\n updateChildRows(actualIndex);\n }\n\n const isFullyInitialized = hasInitialized.current && actualIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div',\n },\n virtualizedChildren: childArray.current,\n before: slot.always(props.before, {\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n after: slot.always(props.after, {\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeContainer: slot.always(props.beforeContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n afterContainer: slot.always(props.afterContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed,\n childSizes,\n childProgressiveSizes,\n };\n}\n"],"names":["React","useIntersectionObserver","useVirtualizerContextState_unstable","slot","useTimeout","flushSync","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","axis","reversed","virtualizerContext","onRenderedFlaggedIndex","imperativeVirtualizerRef","containerSizeRef","scrollViewRef","enableScrollLoad","updateScrollPosition","gap","_virtualizerContext","actualIndexRef","useRef","contextIndex","flaggedIndex","actualIndex","current","setActualIndex","useCallback","index","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","populateSizeArrays","length","_gap","isScrolling","setIsScrolling","useState","setScrollTimer","clearScrollTimer","scrollCounter","initializeScrollingTimer","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","useEffect","updateChildRows","newIndex","_actualIndex","max","end","min","i","updateCurrentItemSizes","endIndex","startIndex","didUpdate","newSize","prevSize","batchUpdateNewIndex","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","getIndexFromScrollPosition","calculateTotalSize","calculateBefore","currentIndex","calculateAfter","lastItemIndex","remainingItems","setObserverList","entries","observer","sortedEntries","sort","entry1","entry2","time","latestEntry","find","entry","isIntersecting","calculateOverBuffer","measurementPos","target","overflowAmount","intersectionRect","height","width","hOverflow","boundingClientRect","top","hOverflowReversed","bottom","wOverflow","left","wOverflowReversed","right","widthOverflow","heightOverflow","additionalOverflow","maxIndex","newStartIndex","root","rootMargin","threshold","setBeforeRef","element","newList","push","setAfterRef","hasInitialized","initializeSizeArray","useImperativeHandle","progressiveSizes","nodeSizes","setFlaggedIndex","forceUpdate","useReducer","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","always","defaultProps","ref","role","elementType","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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R;YACAC,aAAa;QACf;QACAN,gBAAgB/I,KAAKiJ,MAAM,CAAC7I,MAAM2I,cAAc,EAAE;YAChDG,cAAc;gBACZE,MAAM;YACR;YACAC,aAAa;QACf;QACAC,oBAAoBZ,qBAAqBvD,oBAAoB;QAC7DoE,mBAAmBb,qBAAqBrD,mBAAmB;QAC3DmE,wBAAwBd,qBAAqBxD,uBAAuB3E,oBAAoBF;QACxFoJ,uBAAuB1H;QACvBf;QACAF;QACAG;QACAsB;QACAE;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/VirtualizerScrollView/VirtualizerScrollView.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type {\n VirtualizerSlots,\n VirtualizerConfigProps,\n VirtualizerConfigState,\n VirtualizerChildRenderFunction,\n} from '../Virtualizer/Virtualizer.types';\nimport type { ScrollToInterface } from '../../Utilities';\
|
|
1
|
+
{"version":3,"sources":["../src/components/VirtualizerScrollView/VirtualizerScrollView.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type {\n VirtualizerSlots,\n VirtualizerConfigProps,\n VirtualizerConfigState,\n VirtualizerChildRenderFunction,\n} from '../Virtualizer/Virtualizer.types';\nimport type { ScrollToInterface } from '../../Utilities';\n\nexport type VirtualizerScrollViewSlots = VirtualizerSlots & {\n /**\n * The root container that provides embedded scrolling.\n */\n container: NonNullable<Slot<'div'>>;\n};\n\nexport type VirtualizerScrollViewProps = ComponentProps<Partial<VirtualizerScrollViewSlots>> &\n Partial<\n Omit<\n VirtualizerConfigProps,\n 'itemSize' | 'numItems' | 'getItemSize' | 'children' | 'flagIndex' | 'imperativeVirtualizerRef'\n >\n > & {\n /**\n * Virtualizer item size in pixels - static.\n * Axis: 'vertical' = Height\n * Axis: 'horizontal' = Width\n */\n itemSize: number;\n /**\n * The total number of items to be virtualized.\n */\n numItems: number;\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 */\n children: VirtualizerChildRenderFunction;\n /**\n * Imperative ref contains our scrollTo index functionality for user control.\n */\n imperativeRef?: React.RefObject<ScrollToInterface>;\n /**\n * Imperative ref contains our scrollTo index functionality for user control.\n */\n enablePagination?: boolean;\n };\n\nexport type VirtualizerScrollViewState = ComponentState<VirtualizerScrollViewSlots> & VirtualizerConfigState;\n"],"names":["React"],"rangeMappings":"","mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export * from './useVirtualizerScrollViewStyles.styles';
|
|
1
|
+
export { VirtualizerScrollView } from './VirtualizerScrollView';
|
|
2
|
+
export { useVirtualizerScrollView_unstable } from './useVirtualizerScrollView';
|
|
3
|
+
export { renderVirtualizerScrollView_unstable } from './renderVirtualizerScrollView';
|
|
4
|
+
export { useVirtualizerScrollViewStyles_unstable, virtualizerScrollViewClassNames } from './useVirtualizerScrollViewStyles.styles';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/VirtualizerScrollView/index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../src/components/VirtualizerScrollView/index.ts"],"sourcesContent":["export { VirtualizerScrollView } from './VirtualizerScrollView';\nexport type {\n VirtualizerScrollViewProps,\n VirtualizerScrollViewSlots,\n VirtualizerScrollViewState,\n} from './VirtualizerScrollView.types';\nexport { useVirtualizerScrollView_unstable } from './useVirtualizerScrollView';\nexport { renderVirtualizerScrollView_unstable } from './renderVirtualizerScrollView';\nexport {\n useVirtualizerScrollViewStyles_unstable,\n virtualizerScrollViewClassNames,\n} from './useVirtualizerScrollViewStyles.styles';\n"],"names":["VirtualizerScrollView","useVirtualizerScrollView_unstable","renderVirtualizerScrollView_unstable","useVirtualizerScrollViewStyles_unstable","virtualizerScrollViewClassNames"],"rangeMappings":";;;","mappings":"AAAA,SAASA,qBAAqB,QAAQ,0BAA0B;AAMhE,SAASC,iCAAiC,QAAQ,6BAA6B;AAC/E,SAASC,oCAAoC,QAAQ,gCAAgC;AACrF,SACEC,uCAAuC,EACvCC,+BAA+B,QAC1B,0CAA0C"}
|
|
@@ -2,7 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
import { slot, useMergedRefs } from '@fluentui/react-utilities';
|
|
3
3
|
import { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';
|
|
4
4
|
import { useStaticVirtualizerMeasure } from '../../Hooks';
|
|
5
|
-
import { useImperativeHandle } from 'react';
|
|
6
5
|
import { scrollToItemStatic } from '../../Utilities';
|
|
7
6
|
import { useStaticVirtualizerPagination } from '../../hooks/useStaticPagination';
|
|
8
7
|
export function useVirtualizerScrollView_unstable(props) {
|
|
@@ -24,7 +23,7 @@ export function useVirtualizerScrollView_unstable(props) {
|
|
|
24
23
|
const scrollViewRef = useMergedRefs(props.scrollViewRef, scrollRef, paginationRef);
|
|
25
24
|
const imperativeVirtualizerRef = React.useRef(null);
|
|
26
25
|
const scrollCallbackRef = React.useRef(null);
|
|
27
|
-
useImperativeHandle(imperativeRef, ()=>{
|
|
26
|
+
React.useImperativeHandle(imperativeRef, ()=>{
|
|
28
27
|
var _imperativeVirtualizerRef_current;
|
|
29
28
|
return {
|
|
30
29
|
scrollTo (index, behavior = 'auto', callback) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/VirtualizerScrollView/useVirtualizerScrollView.ts"],"sourcesContent":["import * as React from 'react';\nimport { slot, useMergedRefs } from '@fluentui/react-utilities';\nimport { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';\nimport type { VirtualizerScrollViewProps, VirtualizerScrollViewState } from './VirtualizerScrollView.types';\nimport { useStaticVirtualizerMeasure } from '../../Hooks';\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/components/VirtualizerScrollView/useVirtualizerScrollView.ts"],"sourcesContent":["import * as React from 'react';\nimport { slot, useMergedRefs } from '@fluentui/react-utilities';\nimport { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';\nimport type { VirtualizerScrollViewProps, VirtualizerScrollViewState } from './VirtualizerScrollView.types';\nimport { useStaticVirtualizerMeasure } from '../../Hooks';\nimport { scrollToItemStatic } from '../../Utilities';\nimport type { VirtualizerDataRef } from '../Virtualizer/Virtualizer.types';\nimport { useStaticVirtualizerPagination } from '../../hooks/useStaticPagination';\n\nexport function useVirtualizerScrollView_unstable(props: VirtualizerScrollViewProps): VirtualizerScrollViewState {\n const { imperativeRef, itemSize, numItems, axis = 'vertical', reversed, enablePagination = false } = props;\n const { virtualizerLength, bufferItems, bufferSize, scrollRef, containerSizeRef } = 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\n const paginationRef = useStaticVirtualizerPagination({ axis, itemSize }, enablePagination);\n const scrollViewRef = useMergedRefs(props.scrollViewRef, scrollRef, paginationRef) as React.RefObject<HTMLDivElement>;\n const imperativeVirtualizerRef = React.useRef<VirtualizerDataRef | null>(null);\n const scrollCallbackRef = React.useRef<null | ((index: number) => void)>(null);\n\n React.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 onRenderedFlaggedIndex: handleRenderedIndex,\n imperativeVirtualizerRef,\n containerSizeRef,\n });\n\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div',\n },\n container: slot.always(props.container, {\n defaultProps: {\n ref: scrollViewRef as React.RefObject<HTMLDivElement>,\n },\n elementType: 'div',\n }),\n };\n}\n"],"names":["React","slot","useMergedRefs","useVirtualizer_unstable","useStaticVirtualizerMeasure","scrollToItemStatic","useStaticVirtualizerPagination","useVirtualizerScrollView_unstable","props","imperativeRef","itemSize","numItems","axis","reversed","enablePagination","virtualizerLength","bufferItems","bufferSize","scrollRef","containerSizeRef","defaultItemSize","direction","virtualizerLengthRef","useRef","current","paginationRef","scrollViewRef","imperativeVirtualizerRef","scrollCallbackRef","useImperativeHandle","scrollTo","index","behavior","callback","setFlaggedIndex","totalItems","currentIndex","handleRenderedIndex","virtualizerState","onRenderedFlaggedIndex","components","container","always","defaultProps","ref","elementType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,IAAI,EAAEC,aAAa,QAAQ,4BAA4B;AAChE,SAASC,uBAAuB,QAAQ,gCAAgC;AAExE,SAASC,2BAA2B,QAAQ,cAAc;AAC1D,SAASC,kBAAkB,QAAQ,kBAAkB;AAErD,SAASC,8BAA8B,QAAQ,kCAAkC;AAEjF,OAAO,SAASC,kCAAkCC,KAAiC;IACjF,MAAM,EAAEC,aAAa,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,OAAO,UAAU,EAAEC,QAAQ,E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wB;QAC/C,GAAGK,KAAK;QACRO;QACAC;QACAC;QACAsB,wBAAwBF;QACxBV;QACAR;IACF;IAEA,OAAO;QACL,GAAGmB,gBAAgB;QACnBE,YAAY;YACV,GAAGF,iBAAiBE,UAAU;YAC9BC,WAAW;QACb;QACAA,WAAWxC,KAAKyC,MAAM,CAAClC,MAAMiC,SAAS,EAAE;YACtCE,cAAc;gBACZC,KAAKlB;YACP;YACAmB,aAAa;QACf;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState } from '@fluentui/react-utilities';\nimport type {\n VirtualizerConfigProps,\n VirtualizerConfigState,\n VirtualizerChildRenderFunction,\n} from '../Virtualizer/Virtualizer.types';\n\nimport type { VirtualizerScrollViewSlots } from '../VirtualizerScrollView/VirtualizerScrollView.types';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState } from '@fluentui/react-utilities';\nimport type {\n VirtualizerConfigProps,\n VirtualizerConfigState,\n VirtualizerChildRenderFunction,\n} from '../Virtualizer/Virtualizer.types';\n\nimport type { VirtualizerScrollViewSlots } from '../VirtualizerScrollView/VirtualizerScrollView.types';\nimport type { DynamicVirtualizerContextProps, ScrollToInterface } from '../../Utilities';\n\nexport type VirtualizerScrollViewDynamicSlots = VirtualizerScrollViewSlots;\n\nexport type VirtualizerScrollViewDynamicProps = ComponentProps<Partial<VirtualizerScrollViewDynamicSlots>> &\n Partial<\n Omit<\n VirtualizerConfigProps,\n 'itemSize' | 'numItems' | 'getItemSize' | 'children' | 'flagIndex' | 'virtualizerContext'\n >\n > & {\n /**\n * Set as the minimum item size.\n * Axis: 'vertical' = Height\n * Axis: 'horizontal' = Width\n */\n itemSize: number;\n /**\n * Callback for acquiring size of individual items\n * @param index - the index of the requested size's child\n * If undefined, Virtualizer will auto-measure by default (performance tradeoff)\n */\n getItemSize?: (index: number) => number;\n /**\n * The total number of items to be virtualized.\n */\n numItems: number;\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 */\n children: VirtualizerChildRenderFunction;\n /**\n * Imperative ref contains our scrollTo index functionality for user control.\n */\n imperativeRef?: React.RefObject<ScrollToInterface>;\n /**\n * Imperative ref contains our scrollTo index functionality for user control.\n */\n enablePagination?: boolean;\n /**\n * Enables override of dynamic virtualizer context if required.\n */\n virtualizerContext?: DynamicVirtualizerContextProps;\n };\n\nexport type VirtualizerScrollViewDynamicState = ComponentState<VirtualizerScrollViewDynamicSlots> &\n VirtualizerConfigState;\n"],"names":["React"],"rangeMappings":"","mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export * from './useVirtualizerScrollViewDynamicStyles.styles';
|
|
1
|
+
export { VirtualizerScrollViewDynamic } from './VirtualizerScrollViewDynamic';
|
|
2
|
+
export { useVirtualizerScrollViewDynamic_unstable } from './useVirtualizerScrollViewDynamic';
|
|
3
|
+
export { renderVirtualizerScrollViewDynamic_unstable } from './renderVirtualizerScrollViewDynamic';
|
|
4
|
+
export { useVirtualizerScrollViewDynamicStyles_unstable, virtualizerScrollViewDynamicClassNames } from './useVirtualizerScrollViewDynamicStyles.styles';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/VirtualizerScrollViewDynamic/index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../src/components/VirtualizerScrollViewDynamic/index.ts"],"sourcesContent":["export { VirtualizerScrollViewDynamic } from './VirtualizerScrollViewDynamic';\nexport type {\n VirtualizerScrollViewDynamicProps,\n VirtualizerScrollViewDynamicSlots,\n VirtualizerScrollViewDynamicState,\n} from './VirtualizerScrollViewDynamic.types';\nexport { useVirtualizerScrollViewDynamic_unstable } from './useVirtualizerScrollViewDynamic';\nexport { renderVirtualizerScrollViewDynamic_unstable } from './renderVirtualizerScrollViewDynamic';\nexport {\n useVirtualizerScrollViewDynamicStyles_unstable,\n virtualizerScrollViewDynamicClassNames,\n} from './useVirtualizerScrollViewDynamicStyles.styles';\n"],"names":["VirtualizerScrollViewDynamic","useVirtualizerScrollViewDynamic_unstable","renderVirtualizerScrollViewDynamic_unstable","useVirtualizerScrollViewDynamicStyles_unstable","virtualizerScrollViewDynamicClassNames"],"rangeMappings":";;;","mappings":"AAAA,SAASA,4BAA4B,QAAQ,iCAAiC;AAM9E,SAASC,wCAAwC,QAAQ,oCAAoC;AAC7F,SAASC,2CAA2C,QAAQ,uCAAuC;AACnG,SACEC,8CAA8C,EAC9CC,sCAAsC,QACjC,iDAAiD"}
|
|
@@ -3,7 +3,6 @@ import { slot, useMergedRefs } from '@fluentui/react-utilities';
|
|
|
3
3
|
import { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';
|
|
4
4
|
import { useDynamicVirtualizerMeasure } from '../../Hooks';
|
|
5
5
|
import { useVirtualizerContextState_unstable, scrollToItemDynamic } from '../../Utilities';
|
|
6
|
-
import { useImperativeHandle, useState } from 'react';
|
|
7
6
|
import { useMeasureList } from '../../hooks/useMeasureList';
|
|
8
7
|
import { useDynamicVirtualizerPagination } from '../../hooks/useDynamicPagination';
|
|
9
8
|
export function useVirtualizerScrollViewDynamic_unstable(props) {
|
|
@@ -13,7 +12,7 @@ export function useVirtualizerScrollViewDynamic_unstable(props) {
|
|
|
13
12
|
const { imperativeRef, axis = 'vertical', reversed, imperativeVirtualizerRef, enablePagination = false, bufferItems: _bufferItems, bufferSize: _bufferSize } = props;
|
|
14
13
|
let sizeTrackingArray = React.useRef(new Array(props.numItems).fill(props.itemSize));
|
|
15
14
|
// This lets us trigger updates when a size change occurs.
|
|
16
|
-
const [sizeUpdateCount, setSizeUpdateCount] = useState(0);
|
|
15
|
+
const [sizeUpdateCount, setSizeUpdateCount] = React.useState(0);
|
|
17
16
|
const getChildSizeAuto = React.useCallback((index)=>{
|
|
18
17
|
if (sizeTrackingArray.current.length <= index || sizeTrackingArray.current[index] <= 0) {
|
|
19
18
|
// Default size for initial state or untracked
|
|
@@ -53,7 +52,7 @@ export function useVirtualizerScrollViewDynamic_unstable(props) {
|
|
|
53
52
|
}
|
|
54
53
|
const scrollViewRef = useMergedRefs(props.scrollViewRef, scrollRef, paginationRef);
|
|
55
54
|
const scrollCallbackRef = React.useRef(null);
|
|
56
|
-
useImperativeHandle(imperativeRef, ()=>{
|
|
55
|
+
React.useImperativeHandle(imperativeRef, ()=>{
|
|
57
56
|
var _imperativeVirtualizerRef_current;
|
|
58
57
|
return {
|
|
59
58
|
scrollTo (index, behavior = 'auto', callback) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.tsx"],"sourcesContent":["import * as React from 'react';\nimport { slot, 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, useState } from 'react';\nimport { useMeasureList } from '../../hooks/useMeasureList';\nimport type { IndexedResizeCallbackElement } from '../../hooks/useMeasureList';\nimport { useDynamicVirtualizerPagination } from '../../hooks/useDynamicPagination';\n\nexport function useVirtualizerScrollViewDynamic_unstable(\n props: VirtualizerScrollViewDynamicProps,\n): VirtualizerScrollViewDynamicState {\n 'use no memo';\n\n const contextState = useVirtualizerContextState_unstable(props.virtualizerContext);\n const {\n imperativeRef,\n axis = 'vertical',\n reversed,\n imperativeVirtualizerRef,\n enablePagination = false,\n bufferItems: _bufferItems,\n bufferSize: _bufferSize,\n } = props;\n\n let sizeTrackingArray = React.useRef<number[]>(new Array(props.numItems).fill(props.itemSize));\n\n // This lets us trigger updates when a size change occurs.\n const [sizeUpdateCount, setSizeUpdateCount] = useState(0);\n\n const getChildSizeAuto = React.useCallback(\n (index: number) => {\n if (sizeTrackingArray.current.length <= index || sizeTrackingArray.current[index] <= 0) {\n // Default size for initial state or untracked\n return props.itemSize;\n }\n /* Required to be defined prior to our measure function\n * we use a sizing array ref that we will update post-render\n */\n return sizeTrackingArray.current[index];\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [sizeTrackingArray, props.itemSize, sizeUpdateCount],\n );\n\n const { virtualizerLength, bufferItems, bufferSize, scrollRef, containerSizeRef, updateScrollPosition } =\n useDynamicVirtualizerMeasure({\n defaultItemSize: props.itemSize,\n direction: props.axis ?? 'vertical',\n getItemSize: props.getItemSize ?? getChildSizeAuto,\n virtualizerContext: contextState,\n numItems: props.numItems,\n bufferItems: _bufferItems,\n bufferSize: _bufferSize,\n });\n\n const _imperativeVirtualizerRef = useMergedRefs(React.useRef<VirtualizerDataRef>(null), imperativeVirtualizerRef);\n\n const paginationRef = useDynamicVirtualizerPagination(\n {\n axis,\n progressiveItemSizes: _imperativeVirtualizerRef.current?.progressiveSizes,\n virtualizerLength,\n currentIndex: contextState?.contextIndex ?? 0,\n },\n enablePagination,\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(props.scrollViewRef, scrollRef, paginationRef);\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: 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: scrollViewRef as React.RefObject<HTMLDivElement>,\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 getItemSize: props.getItemSize ?? getChildSizeAuto,\n virtualizerLength,\n bufferItems,\n bufferSize,\n virtualizerContext: contextState,\n imperativeVirtualizerRef: _imperativeVirtualizerRef,\n onRenderedFlaggedIndex: handleRenderedIndex,\n containerSizeRef,\n scrollViewRef,\n updateScrollPosition,\n });\n\n const measureObject = useMeasureList(\n virtualizerState.virtualizerStartIndex,\n virtualizerLength,\n props.numItems,\n props.itemSize,\n );\n\n if (enablePagination && measureObject.sizeUpdateCount !== sizeUpdateCount) {\n /* This enables us to let callback know that the sizes have been updated\n triggers a re-render but is only required on pagination (else index change handles) */\n setSizeUpdateCount(measureObject.sizeUpdateCount);\n }\n\n if (axis === 'horizontal') {\n sizeTrackingArray = measureObject.widthArray;\n } else {\n sizeTrackingArray = measureObject.heightArray;\n }\n\n if (!props.getItemSize) {\n // Auto-measuring is required\n React.Children.map(virtualizerState.virtualizedChildren, (child, index) => {\n if (React.isValidElement(child)) {\n virtualizerState.virtualizedChildren[index] = (\n <child.type\n {...child.props}\n key={child.key}\n ref={(element: HTMLElement & IndexedResizeCallbackElement) => {\n if (child.hasOwnProperty('ref')) {\n // We must access this from the child directly, not props (forward ref).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const localRef = (child as any)?.ref;\n\n if (typeof localRef === 'function') {\n localRef(element);\n } else if (localRef) {\n localRef.current = element;\n }\n }\n\n // Call the auto-measure ref attachment.\n measureObject.createIndexedRef(index)(element);\n }}\n />\n );\n }\n });\n }\n\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div',\n },\n container: slot.always(props.container, {\n defaultProps: {\n ref: scrollViewRef,\n },\n elementType: 'div',\n }),\n };\n}\n"],"names":["React","slot","useMergedRefs","useVirtualizer_unstable","useDynamicVirtualizerMeasure","useVirtualizerContextState_unstable","scrollToItemDynamic","useImperativeHandle","useState","useMeasureList","useDynamicVirtualizerPagination","useVirtualizerScrollViewDynamic_unstable","props","_imperativeVirtualizerRef","contextState","virtualizerContext","imperativeRef","axis","reversed","imperativeVirtualizerRef","enablePagination","bufferItems","_bufferItems","bufferSize","_bufferSize","sizeTrackingArray","useRef","Array","numItems","fill","itemSize","sizeUpdateCount","setSizeUpdateCount","getChildSizeAuto","useCallback","index","current","length","virtualizerLength","scrollRef","containerSizeRef","updateScrollPosition","defaultItemSize","direction","getItemSize","paginationRef","progressiveItemSizes","progressiveSizes","currentIndex","contextIndex","virtualizerLengthRef","scrollViewRef","scrollCallbackRef","scrollTo","behavior","callback","totalSize","Math","max","setFlaggedIndex","itemSizes","nodeSizes","handleRenderedIndex","virtualizerState","onRenderedFlaggedIndex","measureObject","virtualizerStartIndex","widthArray","heightArray","Children","map","virtualizedChildren","child","isValidElement","type","key","ref","element","hasOwnProperty","localRef","createIndexedRef","components","container","always","defaultProps","elementType"],"rangeMappings":";;;;;;;;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EAAE;QACtB,6BAA6B;QAC7B5C,MAAMqE,QAAQ,CAACC,GAAG,CAACP,iBAAiBQ,mBAAmB,EAAE,CAACC,OAAOrC;YAC/D,kBAAInC,MAAMyE,cAAc,CAACD,QAAQ;gBAC/BT,iBAAiBQ,mBAAmB,CAACpC,MAAM,iBACzC,oBAACqC,MAAME,IAAI;oBACR,GAAGF,MAAM5D,KAAK;oBACf+D,KAAKH,MAAMG,GAAG;oBACdC,KAAK,CAACC;wBACJ,IAAIL,MAAMM,cAAc,CAAC,QAAQ;4BAC/B,wEAAwE;4BACxE,+DAA+D;4BAC/D,MAAMC,WAAYP,kBAAAA,4BAAD,AAACA,MAAeI,GAAG;4BAEpC,IAAI,OAAOG,aAAa,YAAY;gCAClCA,SAASF;4BACX,OAAO,IAAIE,UAAU;gCACnBA,SAAS3C,OAAO,GAAGyC;4BACrB;wBACF;wBAEA,wCAAwC;wBACxCZ,cAAce,gBAAgB,CAAC7C,OAAO0C;oBACxC;;YAGN;QACF;IACF;IAEA,OAAO;QACL,GAAGd,gBAAgB;QACnBkB,YAAY;YACV,GAAGlB,iBAAiBkB,UAAU;YAC9BC,WAAW;QACb;QACAA,WAAWjF,KAAKkF,MAAM,CAACvE,MAAMsE,SAAS,EAAE;YACtCE,cAAc;gBACZR,KAAKzB;YACP;YACAkC,aAAa;QACf;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../src/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.tsx"],"sourcesContent":["import * as React from 'react';\nimport { slot, 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 { useMeasureList } from '../../hooks/useMeasureList';\nimport type { IndexedResizeCallbackElement } from '../../hooks/useMeasureList';\nimport { useDynamicVirtualizerPagination } from '../../hooks/useDynamicPagination';\n\nexport function useVirtualizerScrollViewDynamic_unstable(\n props: VirtualizerScrollViewDynamicProps,\n): VirtualizerScrollViewDynamicState {\n 'use no memo';\n\n const contextState = useVirtualizerContextState_unstable(props.virtualizerContext);\n const {\n imperativeRef,\n axis = 'vertical',\n reversed,\n imperativeVirtualizerRef,\n enablePagination = false,\n bufferItems: _bufferItems,\n bufferSize: _bufferSize,\n } = props;\n\n let sizeTrackingArray = React.useRef<number[]>(new Array(props.numItems).fill(props.itemSize));\n\n // This lets us trigger updates when a size change occurs.\n const [sizeUpdateCount, setSizeUpdateCount] = React.useState(0);\n\n const getChildSizeAuto = React.useCallback(\n (index: number) => {\n if (sizeTrackingArray.current.length <= index || sizeTrackingArray.current[index] <= 0) {\n // Default size for initial state or untracked\n return props.itemSize;\n }\n /* Required to be defined prior to our measure function\n * we use a sizing array ref that we will update post-render\n */\n return sizeTrackingArray.current[index];\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [sizeTrackingArray, props.itemSize, sizeUpdateCount],\n );\n\n const { virtualizerLength, bufferItems, bufferSize, scrollRef, containerSizeRef, updateScrollPosition } =\n useDynamicVirtualizerMeasure({\n defaultItemSize: props.itemSize,\n direction: props.axis ?? 'vertical',\n getItemSize: props.getItemSize ?? getChildSizeAuto,\n virtualizerContext: contextState,\n numItems: props.numItems,\n bufferItems: _bufferItems,\n bufferSize: _bufferSize,\n });\n\n const _imperativeVirtualizerRef = useMergedRefs(React.useRef<VirtualizerDataRef>(null), imperativeVirtualizerRef);\n\n const paginationRef = useDynamicVirtualizerPagination(\n {\n axis,\n progressiveItemSizes: _imperativeVirtualizerRef.current?.progressiveSizes,\n virtualizerLength,\n currentIndex: contextState?.contextIndex ?? 0,\n },\n enablePagination,\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(props.scrollViewRef, scrollRef, paginationRef);\n const scrollCallbackRef = React.useRef<null | ((index: number) => void)>(null);\n\n React.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: scrollViewRef as React.RefObject<HTMLDivElement>,\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 getItemSize: props.getItemSize ?? getChildSizeAuto,\n virtualizerLength,\n bufferItems,\n bufferSize,\n virtualizerContext: contextState,\n imperativeVirtualizerRef: _imperativeVirtualizerRef,\n onRenderedFlaggedIndex: handleRenderedIndex,\n containerSizeRef,\n scrollViewRef,\n updateScrollPosition,\n });\n\n const measureObject = useMeasureList(\n virtualizerState.virtualizerStartIndex,\n virtualizerLength,\n props.numItems,\n props.itemSize,\n );\n\n if (enablePagination && measureObject.sizeUpdateCount !== sizeUpdateCount) {\n /* This enables us to let callback know that the sizes have been updated\n triggers a re-render but is only required on pagination (else index change handles) */\n setSizeUpdateCount(measureObject.sizeUpdateCount);\n }\n\n if (axis === 'horizontal') {\n sizeTrackingArray = measureObject.widthArray;\n } else {\n sizeTrackingArray = measureObject.heightArray;\n }\n\n if (!props.getItemSize) {\n // Auto-measuring is required\n React.Children.map(virtualizerState.virtualizedChildren, (child, index) => {\n if (React.isValidElement(child)) {\n virtualizerState.virtualizedChildren[index] = (\n <child.type\n {...child.props}\n key={child.key}\n ref={(element: HTMLElement & IndexedResizeCallbackElement) => {\n if (child.hasOwnProperty('ref')) {\n // We must access this from the child directly, not props (forward ref).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const localRef = (child as any)?.ref;\n\n if (typeof localRef === 'function') {\n localRef(element);\n } else if (localRef) {\n localRef.current = element;\n }\n }\n\n // Call the auto-measure ref attachment.\n measureObject.createIndexedRef(index)(element);\n }}\n />\n );\n }\n });\n }\n\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div',\n },\n container: slot.always(props.container, {\n defaultProps: {\n ref: scrollViewRef,\n },\n elementType: 'div',\n }),\n };\n}\n"],"names":["React","slot","useMergedRefs","useVirtualizer_unstable","useDynamicVirtualizerMeasure","useVirtualizerContextState_unstable","scrollToItemDynamic","useMeasureList","useDynamicVirtualizerPagination","useVirtualizerScrollViewDynamic_unstable","props","_imperativeVirtualizerRef","contextState","virtualizerContext","imperativeRef","axis","reversed","imperativeVirtualizerRef","enablePagination","bufferItems","_bufferItems","bufferSize","_bufferSize","sizeTrackingArray","useRef","Array","numItems","fill","itemSize","sizeUpdateCount","setSizeUpdateCount","useState","getChildSizeAuto","useCallback","index","current","length","virtualizerLength","scrollRef","containerSizeRef","updateScrollPosition","defaultItemSize","direction","getItemSize","paginationRef","progressiveItemSizes","progressiveSizes","currentIndex","contextIndex","virtualizerLengthRef","scrollViewRef","scrollCallbackRef","useImperativeHandle","scrollTo","behavior","callback","totalSize","Math","max","setFlaggedIndex","itemSizes","nodeSizes","handleRenderedIndex","virtualizerState","onRenderedFlaggedIndex","measureObject","virtualizerStartIndex","widthArray","heightArray","Children","map","virtualizedChildren","child","isValidElement","type","key","ref","element","hasOwnProperty","localRef","createIndexedRef","components","container","always","defaultProps","elementType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,IAAI,EAAEC,aAAa,QAAQ,4BAA4B;AAChE,SAASC,uBAAuB,QAAQ,gCAAgC;AAKxE,SAASC,4BAA4B,QAAQ,cAAc;AAC3D,SAASC,mCAAmC,EAAEC,mBAAmB,QAAQ,kBAAkB;AAE3F,SAASC,cAAc,QAAQ,6BAA6B;AAE5D,SAASC,+BAA+B,QAAQ,mCAAmC;AAEnF,OAAO,SAASC,yCACdC,KAAwC;IAExC;QAiD0BC;IA/C1B,MAAMC,eAAeP,oCAAoCK,MAAMG,kBAAkB;IACjF,MAAM,EACJC,aAAa,EACbC,OAAO,UAAU,EACjBC,QAAQ,EACRC,wBAAwB,EACxBC,mBAAmB,KAAK,EACxBC,aAAaC,YAAY,EACzBC,YAAYC,WAAW,EACxB,GAAGZ;IAEJ,IAAIa,oBAAoBvB,MAAMwB,MAAM,CAAW,IAAIC,MAAMf,MAAMgB,QAAQ,EAAEC,IAAI,CAACjB,MAAMkB,QAAQ;IAE5F,0DAA0D;IAC1D,MAAM,CAACC,iBAAiBC,mBAAmB,GAAG9B,MAAM+B,QAAQ,CAAC;IAE7D,MAAMC,mBAAmBhC,MAAMiC,WAAW,CACxC,CAACC;QACC,IAAIX,kBAAkBY,OAAO,CAACC,MAAM,IAAIF,SAASX,kBAAkBY,OAAO,CAACD,MAAM,IAAI,GAAG;YACtF,8CAA8C;YAC9C,OAAOxB,MAAMkB,QAAQ;QACvB;QACA;;OAEC,GACD,OA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zBQ,oBAAoB0C,cAAcE,UAAU;IAC9C,OAAO;QACL5C,oBAAoB0C,cAAcG,WAAW;IAC/C;IAEA,IAAI,CAAC1D,MAAMiC,WAAW,EAAE;QACtB,6BAA6B;QAC7B3C,MAAMqE,QAAQ,CAACC,GAAG,CAACP,iBAAiBQ,mBAAmB,EAAE,CAACC,OAAOtC;YAC/D,kBAAIlC,MAAMyE,cAAc,CAACD,QAAQ;gBAC/BT,iBAAiBQ,mBAAmB,CAACrC,MAAM,iBACzC,oBAACsC,MAAME,IAAI;oBACR,GAAGF,MAAM9D,KAAK;oBACfiE,KAAKH,MAAMG,GAAG;oBACdC,KAAK,CAACC;wBACJ,IAAIL,MAAMM,cAAc,CAAC,QAAQ;4BAC/B,wEAAwE;4BACxE,+DAA+D;4BAC/D,MAAMC,WAAYP,kBAAAA,4BAAD,AAACA,MAAeI,GAAG;4BAEpC,IAAI,OAAOG,aAAa,YAAY;gCAClCA,SAASF;4BACX,OAAO,IAAIE,UAAU;gCACnBA,SAAS5C,OAAO,GAAG0C;4BACrB;wBACF;wBAEA,wCAAwC;wBACxCZ,cAAce,gBAAgB,CAAC9C,OAAO2C;oBACxC;;YAGN;QACF;IACF;IAEA,OAAO;QACL,GAAGd,gBAAgB;QACnBkB,YAAY;YACV,GAAGlB,iBAAiBkB,UAAU;YAC9BC,WAAW;QACb;QACAA,WAAWjF,KAAKkF,MAAM,CAACzE,MAAMwE,SAAS,EAAE;YACtCE,cAAc;gBACZR,KAAK1B;YACP;YACAmC,aAAa;QACf;IACF;AACF"}
|
package/lib/hooks/hooks.types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/hooks.types.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../src/hooks/hooks.types.ts"],"sourcesContent":["import * as React from 'react';\nimport { DynamicVirtualizerContextProps } from '../Utilities';\n\nexport type VirtualizerMeasureProps = {\n defaultItemSize: number;\n direction?: 'vertical' | 'horizontal';\n\n /**\n * Override recommended number of buffer items\n */\n bufferItems?: number;\n\n /**\n * Override recommended buffer size (px)\n */\n bufferSize?: number;\n};\n\nexport type VirtualizerMeasureDynamicProps = {\n defaultItemSize: number;\n virtualizerContext: DynamicVirtualizerContextProps;\n numItems: number;\n getItemSize: (index: number) => number;\n direction?: 'vertical' | 'horizontal';\n\n /**\n * Override recommended number of buffer items\n */\n bufferItems?: number;\n\n /**\n * Override recommended buffer size (px)\n */\n bufferSize?: number;\n};\n\nexport type VirtualizerStaticPaginationProps = {\n itemSize: number;\n axis?: 'vertical' | 'horizontal';\n};\n\n/**\n * Props to be passed into dynamic virtualization hooks\n * All props can be acquired from useVirtualizer hooks themselves and passed in\n */\nexport type VirtualizerDynamicPaginationProps = {\n /**\n * An array that tracks the sizing of each item in virtualizer cumulatively\n */\n progressiveItemSizes: React.RefObject<number[]> | undefined;\n /**\n * The current starting index of the virtualizer's DOM elements\n */\n currentIndex: number;\n /**\n * The axis we should paginate on (should match virtualizer's axis)\n */\n axis?: 'vertical' | 'horizontal';\n /**\n * The current length of Virtualizer's actual DOM elements\n */\n virtualizerLength: number;\n};\n\n/**\n * Additional direct Ref prevents reading old resize entry data\n * Backwards compatible with ResizeObserverCallback if preferred\n */\nexport interface ResizeCallbackWithRef {\n (\n entries: ResizeObserverEntry[],\n // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n // eslint-disable-next-line no-restricted-globals\n observer: ResizeObserver,\n scrollRef?: React.MutableRefObject<HTMLElement | null>,\n ): void;\n}\n"],"names":["React"],"rangeMappings":"","mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
package/lib/hooks/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export * from './useMeasureList';
|
|
1
|
+
export { getRTLRootMargin, useIntersectionObserver } from './useIntersectionObserver';
|
|
2
|
+
export { useStaticVirtualizerMeasure } from './useVirtualizerMeasure';
|
|
3
|
+
export { useDynamicVirtualizerMeasure } from './useDynamicVirtualizerMeasure';
|
|
4
|
+
export { useResizeObserverRef_unstable } from './useResizeObserverRef';
|
|
5
|
+
export { createResizeObserverFromDocument, useMeasureList } from './useMeasureList';
|
package/lib/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../src/hooks/index.ts"],"sourcesContent":["export { getRTLRootMargin, useIntersectionObserver } from './useIntersectionObserver';\nexport { useStaticVirtualizerMeasure } from './useVirtualizerMeasure';\nexport { useDynamicVirtualizerMeasure } from './useDynamicVirtualizerMeasure';\nexport { useResizeObserverRef_unstable } from './useResizeObserverRef';\nexport type {\n ResizeCallbackWithRef,\n VirtualizerDynamicPaginationProps,\n VirtualizerMeasureDynamicProps,\n VirtualizerMeasureProps,\n VirtualizerStaticPaginationProps,\n} from './hooks.types';\nexport type { IndexedResizeCallbackElement } from './useMeasureList';\nexport { createResizeObserverFromDocument, useMeasureList } from './useMeasureList';\n"],"names":["getRTLRootMargin","useIntersectionObserver","useStaticVirtualizerMeasure","useDynamicVirtualizerMeasure","useResizeObserverRef_unstable","createResizeObserverFromDocument","useMeasureList"],"rangeMappings":";;;;","mappings":"AAAA,SAASA,gBAAgB,EAAEC,uBAAuB,QAAQ,4BAA4B;AACtF,SAASC,2BAA2B,QAAQ,0BAA0B;AACtE,SAASC,4BAA4B,QAAQ,iCAAiC;AAC9E,SAASC,6BAA6B,QAAQ,yBAAyB;AASvE,SAASC,gCAAgC,EAAEC,cAAc,QAAQ,mBAAmB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useRef } from 'react';
|
|
3
2
|
import { useTimeout } from '@fluentui/react-utilities';
|
|
4
3
|
/**
|
|
5
4
|
* Optional hook that will enable pagination on the virtualizer so that it 'autoscrolls' to an items exact position
|
|
@@ -10,8 +9,8 @@ import { useTimeout } from '@fluentui/react-utilities';
|
|
|
10
9
|
'use no memo';
|
|
11
10
|
const { axis = 'vertical', currentIndex, progressiveItemSizes, virtualizerLength } = virtualizerProps;
|
|
12
11
|
const [setScrollTimer, clearScrollTimer] = useTimeout();
|
|
13
|
-
const lastScrollPos = useRef(-1);
|
|
14
|
-
const lastIndexScrolled = useRef(-1);
|
|
12
|
+
const lastScrollPos = React.useRef(-1);
|
|
13
|
+
const lastIndexScrolled = React.useRef(-1);
|
|
15
14
|
const scrollContainer = React.useRef(null);
|
|
16
15
|
const clearListeners = ()=>{
|
|
17
16
|
if (scrollContainer.current) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useDynamicPagination.ts"],"sourcesContent":["import * as React from 'react';\nimport { VirtualizerDynamicPaginationProps } from './hooks.types';\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useDynamicPagination.ts"],"sourcesContent":["import * as React from 'react';\nimport { VirtualizerDynamicPaginationProps } from './hooks.types';\nimport { useTimeout } from '@fluentui/react-utilities';\n\n/**\n * Optional hook that will enable pagination on the virtualizer so that it 'autoscrolls' to an items exact position\n * Sizes are dynamic so we require a progressive sizing array (passed in from Dynamic virtualizer hooks)\n * On short scrolls, we will go at minimum to the next/previous item so that arrow pagination works\n * All VirtualizerDynamicPaginationProps can be grabbed from dynamic Virtualizer hooks externally and passed in\n */\nexport const useDynamicVirtualizerPagination = (\n virtualizerProps: VirtualizerDynamicPaginationProps,\n paginationEnabled: Boolean = true,\n) => {\n 'use no memo';\n\n const { axis = 'vertical', currentIndex, progressiveItemSizes, virtualizerLength } = virtualizerProps;\n\n const [setScrollTimer, clearScrollTimer] = useTimeout();\n const lastScrollPos = React.useRef<number>(-1);\n const lastIndexScrolled = React.useRef<number>(-1);\n\n const scrollContainer = React.useRef<HTMLElement | null>(null);\n\n const clearListeners = () => {\n if (scrollContainer.current) {\n scrollContainer.current.removeEventListener('scroll', onScroll);\n scrollContainer.current = null;\n clearScrollTimer();\n }\n };\n\n React.useEffect(() => {\n return () => {\n clearListeners();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n /**\n * Handle scroll stop event and paginate to the closest item\n * If the closest item is the same as the previous scroll end\n * we paginate to the next/previous one based on direction\n *\n * Users/Virtualizer-Hooks must pass in a cumulative array of sizes\n * This prevents the need to recalculate and ensures size arrays are synced externally\n */\n const onScrollEnd = React.useCallback(() => {\n if (!scrollContainer.current || !paginationEnabled || !progressiveItemSizes?.current) {\n // No container found\n return;\n }\n\n const currentScrollPos = Math.round(\n axis === 'vertical' ? scrollContainer.current.scrollTop : scrollContainer.current.scrollLeft,\n );\n let closestItemPos = 0;\n let closestItem = 0;\n const endItem = Math.min(currentIndex + virtualizerLength, progressiveItemSizes.current.length);\n\n for (let i = currentIndex; i < endItem - 1; i++) {\n if (\n currentScrollPos <= progressiveItemSizes.current[i + 1] &&\n currentScrollPos >= progressiveItemSizes.current[i]\n ) {\n // Found our in between position\n const distanceToPrev = Math.abs(currentScrollPos - progressiveItemSizes.current[i]);\n const distanceToNext = Math.abs(progressiveItemSizes.current[i + 1] - currentScrollPos);\n if (distanceToPrev < distanceToNext) {\n closestItem = i;\n } else {\n closestItem = i + 1;\n }\n break;\n }\n }\n\n let nextItem;\n if (Math.round(closestItem - lastIndexScrolled.current) === 0) {\n // Special case for go to next/previous with minimum amount of scroll needed\n const nextTarget = lastScrollPos.current < currentScrollPos ? 1 : -1;\n // This will also handle a case where we scrolled to the exact correct position (noop)\n const isSecondaryScroll = Math.round(lastScrollPos.current - currentScrollPos) === 0;\n const posMod = isSecondaryScroll ? 0 : nextTarget;\n nextItem = closestItem + posMod;\n } else {\n // Pagination for anything else can just jump to the closest!\n nextItem = closestItem;\n }\n\n // Safeguard nextItem\n nextItem = Math.min(Math.max(0, nextItem), progressiveItemSizes.current.length);\n closestItemPos = progressiveItemSizes.current[nextItem];\n\n if (axis === 'vertical') {\n scrollContainer.current.scrollTo({ top: closestItemPos, behavior: 'smooth' });\n } else {\n scrollContainer.current.scrollTo({ left: closestItemPos, behavior: 'smooth' });\n }\n lastScrollPos.current = progressiveItemSizes.current[nextItem];\n lastIndexScrolled.current = nextItem;\n }, [paginationEnabled, currentIndex, scrollContainer, virtualizerLength, axis, progressiveItemSizes]);\n\n /**\n * On scroll timer that will continuously delay callback until scrolling stops\n */\n const onScroll = React.useCallback(\n event => {\n clearScrollTimer();\n setScrollTimer(onScrollEnd, 100);\n },\n [onScrollEnd, clearScrollTimer, setScrollTimer],\n );\n\n /**\n * Pagination ref will ensure we attach listeners to containers on change\n * It is returned from hook and merged into the scroll container externally\n */\n const paginationRef = React.useCallback(\n (instance: HTMLElement | HTMLDivElement | null) => {\n if (!paginationEnabled) {\n clearListeners();\n scrollContainer.current = null;\n return;\n }\n if (scrollContainer.current !== instance) {\n clearListeners();\n\n scrollContainer.current = instance;\n if (scrollContainer.current) {\n scrollContainer.current.addEventListener('scroll', onScroll);\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [onScroll, onScrollEnd, paginationEnabled],\n );\n\n return paginationRef;\n};\n"],"names":["React","useTimeout","useDynamicVirtualizerPagination","virtualizerProps","paginationEnabled","axis","currentIndex","progressiveItemSizes","virtualizerLength","setScrollTimer","clearScrollTimer","lastScrollPos","useRef","lastIndexScrolled","scrollContainer","clearListeners","current","removeEventListener","onScroll","useEffect","onScrollEnd","useCallback","currentScrollPos","Math","round","scrollTop","scrollLeft","closestItemPos","closestItem","endItem","min","length","i","distanceToPrev","abs","distanceToNext","nextItem","nextTarget","isSecondaryScroll","posMod","max","scrollTo","top","behavior","left","event","paginationRef","instance","addEventListener"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAA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MAAMqB,WAAW,CAChCwB,CAAAA;QACEnC;QACAD,eAAeW,aAAa;IAC9B,GACA;QAACA;QAAaV;QAAkBD;KAAe;IAGjD;;;GAGC,GACD,MAAMqC,gBAAgB9C,MAAMqB,WAAW,CACrC,CAAC0B;QACC,IAAI,CAAC3C,mBAAmB;YACtBW;YACAD,gBAAgBE,OAAO,GAAG;YAC1B;QACF;QACA,IAAIF,gBAAgBE,OAAO,KAAK+B,UAAU;YACxChC;YAEAD,gBAAgBE,OAAO,GAAG+B;YAC1B,IAAIjC,gBAAgBE,OAAO,EAAE;gBAC3BF,gBAAgBE,OAAO,CAACgC,gBAAgB,CAAC,UAAU9B;YACrD;QACF;IACF,GACA,uDAAuD;IACvD;QAACA;QAAUE;QAAahB;KAAkB;IAG5C,OAAO0C;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useIntersectionObserver.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useIntersectionObserver.ts"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nconst { useCallback, useState, useRef } = React;\nimport { useMutationObserver } from './useMutationObserver';\n\n/**\n * This function will take the rootMargin and flip the sides if we are in RTL based on the computed reading direction of the target element.\n * @param ltrRootMargin the margin to be processed and flipped if required\n * @param target target element that will have its current reading direction determined\n * @returns the corrected rootMargin (if it was necessary to correct)\n */\nexport const getRTLRootMargin = (\n ltrRootMargin: string,\n target?: Element | Document | null | undefined,\n win?: Window | null,\n): string => {\n if (target && win) {\n // get the computed dir for the target element\n const newDir = win.getComputedStyle(target as Element).direction;\n\n // If we're in rtl reading direction, we might need to flip the margins on the left/right sides\n if (newDir === 'rtl') {\n let newMargin = ltrRootMargin;\n const splitMargins = ltrRootMargin.split(' ');\n\n // We only need to do this if we get four values, otherwise the sides are equal and don't require flipping.\n if (splitMargins.length === 4) {\n newMargin = `${splitMargins[0]} ${splitMargins[3]} ${splitMargins[2]} ${splitMargins[1]}`;\n }\n\n return newMargin;\n } else {\n return ltrRootMargin;\n }\n }\n\n return ltrRootMargin;\n};\n\n/**\n * React hook that allows easy usage of the browser API IntersectionObserver within React\n * @param callback - A function called when the percentage of the target element is visible crosses a threshold.\n * @param options - An optional object which customizes the observer. If options isn't specified, the observer uses the\n * document's viewport as the root, with no margin, and a 0% threshold (meaning that even a one-pixel change is\n * enough to trigger a callback).\n * @returns An array containing a callback to update the list of Elements the observer should listen to, a callback to\n * update the init options of the IntersectionObserver and a ref to the IntersectionObserver instance itself.\n */\n\nexport const useIntersectionObserver = (\n callback: IntersectionObserverCallback,\n options?: IntersectionObserverInit,\n): {\n setObserverList: React.Dispatch<React.SetStateAction<Element[] | undefined>>;\n setObserverInit: (newInit: IntersectionObserverInit | undefined) => void;\n // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n // eslint-disable-next-line no-restricted-globals\n observer: React.MutableRefObject<IntersectionObserver | undefined>;\n} => {\n 'use no memo';\n\n // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n // eslint-disable-next-line no-restricted-globals\n const observer = useRef<IntersectionObserver>();\n const [observerList, setObserverList] = useState<Element[]>();\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n\n // set the initial init with corrected margins based on the observed root's calculated reading direction.\n const [observerInit, setObserverInit] = useState<IntersectionObserverInit | undefined>(\n options && {\n ...options,\n rootMargin: getRTLRootMargin(options.rootMargin ?? '0px', options.root as Element, win),\n },\n );\n\n // We have to assume that any values passed in for rootMargin by the consuming app are ltr values. As such we will store the ltr value.\n const ltrRootMargin = useRef<string>(options?.rootMargin ?? '0px');\n\n // Callback function to execute when mutations are observed\n const mutationObserverCallback: MutationCallback = useCallback(\n mutationList => {\n for (const mutation of mutationList) {\n // Ensuring that the right attribute is being observed and that the root is within the tree of the element being mutated.\n if (\n mutation.type === 'attributes' &&\n mutation.attributeName === 'dir' &&\n options?.root &&\n mutation.target.contains(options?.root)\n ) {\n setObserverInit({\n ...observerInit,\n rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit?.root, win),\n });\n }\n }\n },\n [ltrRootMargin, observerInit, options?.root, win],\n );\n\n // Mutation observer for dir attribute changes in the document\n useMutationObserver(targetDocument, mutationObserverCallback, {\n attributes: true,\n subtree: true,\n attributeFilter: ['dir'],\n });\n\n // Observer elements in passed in list and clean up previous list\n // This effect is only triggered when observerList is updated\n useIsomorphicLayoutEffect(() => {\n if (!win) {\n return;\n }\n\n observer.current = new win.IntersectionObserver(callback, {\n ...observerInit,\n rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit?.root, win),\n });\n\n // If we have an instance of IO and a list with elements, observer the elements\n if (observer.current && observerList && observerList.length > 0) {\n observerList.forEach(element => {\n observer.current?.observe(element);\n });\n }\n\n // clean up previous elements being listened to\n return () => {\n if (observer.current) {\n observer.current.disconnect();\n }\n };\n }, [observerList, observerInit, callback, win]);\n\n // Do not use internally, we need to track external settings only here\n const setObserverInitExternal = useCallback(\n (newInit: IntersectionObserverInit | undefined) => {\n // Since we know this is coming from consumers, we can store this value as LTR somewhat safely.\n ltrRootMargin.current = newInit?.rootMargin ?? '0px';\n\n // Call the internal setter to update the value and ensure if our calculated direction is rtl, we flip the margin\n setObserverInit({\n ...newInit,\n rootMargin: getRTLRootMargin(ltrRootMargin.current, newInit?.root as Element, win),\n });\n },\n [ltrRootMargin, setObserverInit, win],\n );\n\n return { setObserverList, setObserverInit: setObserverInitExternal, observer };\n};\n"],"names":["React","useIsomorphicLayoutEffect","useFluent_unstable","useFluent","useCallback","useState","useRef","useMutationObserver","getRTLRootMargin","ltrRootMargin","target","win","newDir","getComputedStyle","direction","newMargin","splitMargins","split","length","useIntersectionObserver","callback","options","observer","observerList","setObserverList","targetDocument","defaultView","observerInit","setObserverInit","rootMargin","root","mutationObserverCallback","mutationList","mutation","type","attributeName","contains","current","attributes","subtree","attributeFilter","IntersectionObserver","forEach","element","observe","disconnect","setObserverInitExternal","newInit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ,4BAA4B;AACtE,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF,MAAM,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGN;AAC1C,SAASO,mBAAmB,QAAQ,wBAAwB;AAE5D;;;;;CAKC,GACD,OAAO,MAAMC,mBAAmB,CAC9BC,eACAC,QACAC;IAEA,IAAID,UAAUC,KAAK;QACjB,8CAA8C;QAC9C,MAAMC,SAASD,IAAIE,gBAAgB,CAACH,QAAmBI,SAAS;QAEhE,+FAA+F;QAC/F,IAAIF,WAAW,OAAO;YACpB,IAAIG,YAAYN;YAChB,MAAMO,eAAeP,cAAcQ,KAAK,CAAC;YAEzC,2GAA2G;YAC3G,IAAID,aAAaE,MAAM,KAAK,GAAG;gBAC7BH,YAAY,CAAC,EAAEC,YAAY,CAAC,EAAE,CAAC,CAAC,EAAEA,YAAY,CAAC,EAAE,CAAC,CAAC,EAAEA,YAAY,CAAC,EAAE,CAAC,CAAC,EAAEA,YAAY,CAAC,EAAE,CAAC,CAAC;YAC3F;YAEA,OAAOD;QACT,OAAO;YACL,OAAON;QACT;IACF;IAEA,OAAOA;AACT,EAAE;AAEF;;;;;;;;CAQC,GAED,OAAO,MAAMU,0BAA0B,CACrCC,UACAC;IAQA;IAEA,8FAA8F;IAC9F,iDAAiD;IACjD,MAAMC,WAAWhB;IACjB,MAAM,CAACiB,cAAcC,gBAAgB,GAAGnB;IACxC,MAAM,EAAEoB,cAAc,EAAE,GAAGtB;IAC3B,MAAMQ,MAAMc,2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