@fluentui/react-virtualizer 9.0.0-alpha.18 → 9.0.0-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +49 -2
- package/CHANGELOG.md +16 -3
- package/dist/index.d.ts +93 -10
- package/lib/Utilities.js +2 -0
- package/lib/Utilities.js.map +1 -0
- package/lib/VirtualizerScrollViewDynamic.js +2 -0
- package/lib/VirtualizerScrollViewDynamic.js.map +1 -0
- package/lib/components/Virtualizer/Virtualizer.types.js.map +1 -1
- package/lib/components/Virtualizer/renderVirtualizer.js +6 -0
- package/lib/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizer.js +35 -32
- package/lib/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.js +2 -1
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js +14 -0
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js +2 -0
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/index.js +6 -0
- package/lib/components/VirtualizerScrollViewDynamic/index.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js +11 -0
- package/lib/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +44 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.js +46 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.js.map +1 -0
- package/lib/hooks/hooks.types.js +2 -0
- package/lib/hooks/hooks.types.js.map +1 -0
- package/lib/hooks/index.js +3 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useDynamicVirtualizerMeasure.js +99 -0
- package/lib/hooks/useDynamicVirtualizerMeasure.js.map +1 -0
- package/lib/hooks/useResizeObserverRef.js +40 -0
- package/lib/hooks/useResizeObserverRef.js.map +1 -0
- package/lib/hooks/useVirtualizerMeasure.js +6 -29
- package/lib/hooks/useVirtualizerMeasure.js.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/utilities/VirtualizerContext/VirtualizerContext.js +27 -0
- package/lib/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -0
- package/lib/utilities/VirtualizerContext/index.js +3 -0
- package/lib/utilities/VirtualizerContext/index.js.map +1 -0
- package/lib/utilities/VirtualizerContext/types.js +4 -0
- package/lib/utilities/VirtualizerContext/types.js.map +1 -0
- package/lib/utilities/index.js +2 -0
- package/lib/utilities/index.js.map +1 -0
- package/lib-commonjs/Utilities.js +9 -0
- package/lib-commonjs/Utilities.js.map +1 -0
- package/lib-commonjs/VirtualizerScrollViewDynamic.js +9 -0
- package/lib-commonjs/VirtualizerScrollViewDynamic.js.map +1 -0
- package/lib-commonjs/components/Virtualizer/renderVirtualizer.js +15 -3
- package/lib-commonjs/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js +35 -30
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.js +2 -1
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js +21 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js +7 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js +13 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js +17 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +49 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.js +69 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.js.map +1 -0
- package/lib-commonjs/hooks/hooks.types.js +7 -0
- package/lib-commonjs/hooks/hooks.types.js.map +1 -0
- package/lib-commonjs/hooks/index.js +3 -0
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js +107 -0
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js.map +1 -0
- package/lib-commonjs/hooks/useResizeObserverRef.js +51 -0
- package/lib-commonjs/hooks/useResizeObserverRef.js.map +1 -0
- package/lib-commonjs/hooks/useVirtualizerMeasure.js +7 -29
- package/lib-commonjs/hooks/useVirtualizerMeasure.js.map +1 -1
- package/lib-commonjs/index.js +12 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js +48 -0
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -0
- package/lib-commonjs/utilities/VirtualizerContext/index.js +10 -0
- package/lib-commonjs/utilities/VirtualizerContext/index.js.map +1 -0
- package/lib-commonjs/utilities/VirtualizerContext/types.js +9 -0
- package/lib-commonjs/utilities/VirtualizerContext/types.js.map +1 -0
- package/lib-commonjs/utilities/index.js +9 -0
- package/lib-commonjs/utilities/index.js.map +1 -0
- package/package.json +4 -4
- package/.swcrc +0 -30
- package/lib/hooks/useVirtualizerMeasure.types.js +0 -2
- package/lib/hooks/useVirtualizerMeasure.types.js.map +0 -1
- package/lib-commonjs/hooks/useVirtualizerMeasure.types.js +0 -7
- package/lib-commonjs/hooks/useVirtualizerMeasure.types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useIntersectionObserver","useEffect","useRef","useState","useCallback","useReducer","resolveShorthand","flushSync","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","scrollViewRef","axis","reversed","onUpdateIndex","onCalculateIndex","virtualizerStartIndex","setVirtualizerStartIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","horizontal","populateSizeArrays","current","length","index","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","entries","observer","measurementPos","bufferCount","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","target","calculateAfter","calculateTotalSize","abs","boundingClientRect","bottom","top","right","left","calculateBefore","max","startIndex","getIndexFromScrollPosition","bufferedIndex","maxIndex","newStartIndex","min","root","rootMargin","threshold","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","lastItemIndex","remainingItems","newIndex","actualIndex","end","i","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","required","defaultProps","ref","role","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight"],"sources":["../../../src/components/Virtualizer/useVirtualizer.ts"],"sourcesContent":["import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport type { ReactNode } from 'react';\nimport { useEffect, useRef, useState, useCallback, useReducer } from 'react';\n\nimport type { VirtualizerProps, VirtualizerState } from './Virtualizer.types';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n const {\n itemSize,\n numItems,\n virtualizerLength,\n children: renderChild,\n getItemSize,\n bufferItems = Math.round(virtualizerLength / 4.0),\n bufferSize = Math.floor(bufferItems / 2.0) * itemSize,\n scrollViewRef,\n axis = 'vertical',\n reversed = false,\n onUpdateIndex,\n onCalculateIndex,\n } = props;\n\n // Tracks the initial item to start virtualizer at, -1 implies first render cycle\n const [virtualizerStartIndex, setVirtualizerStartIndex] = useState<number>(-1);\n\n // Store ref to before padding element\n const beforeElementRef = useRef<Element | null>(null);\n\n // Store ref to before padding element\n const afterElementRef = useRef<Element | null>(null);\n\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */\n const childProgressiveSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n // The internal tracking REF for child array (updates often).\n const childArray = useRef<ReactNode[]>(new Array(virtualizerLength));\n\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(() => ({}), {})[1];\n\n const horizontal = axis === 'horizontal';\n\n const populateSizeArrays = () => {\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array<number>(numItems);\n }\n\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array<number>(numItems);\n }\n\n for (let index = 0; index < numItems; index++) {\n childSizes.current[index] = getItemSize(index);\n\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 batchUpdateNewIndex = (index: number) => {\n // Local updates\n onUpdateIndex?.(index, virtualizerStartIndex);\n updateChildRows(index);\n updateCurrentItemSizes(index);\n\n // State setters\n setVirtualizerStartIndex(index);\n };\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (virtualizerStartIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n\n /* IO initiates this function when needed (bookend entering view) */\n let measurementPos = 0;\n let bufferCount = bufferItems;\n\n // Grab latest entry that is intersecting\n const latestEntry =\n entries.length === 1\n ? entries[0]\n : entries\n .sort((entry1, entry2) => entry2.time - entry1.time)\n .find(entry => {\n return entry.intersectionRatio > 0;\n });\n\n if (!latestEntry) {\n // If we don't find an intersecting area, ignore for now.\n return;\n }\n\n if (latestEntry.target === afterElementRef.current) {\n // We need to inverse the buffer count\n bufferCount = virtualizerLength - bufferItems;\n measurementPos = reversed ? calculateAfter() : calculateTotalSize() - calculateAfter();\n if (!horizontal) {\n if (reversed) {\n // Scrolling 'up' and hit the after element below\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' and hit the after element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (reversed) {\n // Scrolling 'left' and hit the after element\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'right' and hit the after element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n measurementPos = reversed ? calculateTotalSize() - calculateBefore() : calculateBefore();\n if (!horizontal) {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' in reverse order and hit the before element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'left' and hit before element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n }\n\n if (reversed) {\n // We're reversed, up is down, left is right, invert the scroll measure.\n measurementPos = Math.max(calculateTotalSize() - Math.abs(measurementPos), 0);\n }\n\n // For now lets use hardcoded size to assess current element to paginate on\n const startIndex = getIndexFromScrollPosition(measurementPos);\n let bufferedIndex = Math.max(startIndex - bufferCount, 0);\n\n if (onCalculateIndex) {\n // User has chance to intervene/customize prior to render\n // They may want to normalize this value.\n bufferedIndex = onCalculateIndex(bufferedIndex);\n }\n\n // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n\n if (virtualizerStartIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n // due to virtualizerStartIndex invalidation.\n flushSync(() => {\n batchUpdateNewIndex(newStartIndex);\n });\n }\n },\n {\n root: scrollViewRef ? scrollViewRef?.current : null,\n rootMargin: '0px',\n threshold: 0,\n },\n );\n\n const findIndexRecursive = (scrollPos: number, lowIndex: number, highIndex: number): number => {\n if (lowIndex > highIndex) {\n // We shouldn't get here - but no-op the index if we do.\n return virtualizerStartIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */\n return midpoint;\n }\n\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n\n const getIndexFromSizeArray = (scrollPos: number): number => {\n /* Quick searches our progressive height array */\n if (\n scrollPos === 0 ||\n childProgressiveSizes.current.length === 0 ||\n scrollPos <= childProgressiveSizes.current[0]\n ) {\n // Check start\n return 0;\n }\n\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n\n const getIndexFromScrollPosition = (scrollPos: number) => {\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n\n return getIndexFromSizeArray(scrollPos);\n };\n\n const calculateTotalSize = () => {\n if (!getItemSize) {\n return itemSize * numItems;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n };\n\n const calculateBefore = () => {\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return virtualizerStartIndex * itemSize;\n }\n\n if (virtualizerStartIndex <= 0) {\n return 0;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[virtualizerStartIndex - 1];\n };\n\n const calculateAfter = () => {\n if (numItems === 0) {\n return 0;\n }\n\n const lastItemIndex = Math.min(virtualizerStartIndex + virtualizerLength, numItems - 1);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex - 1;\n return remainingItems * itemSize;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex];\n };\n\n const updateChildRows = useCallback(\n (newIndex: number) => {\n if (numItems === 0) {\n /* Nothing to virtualize */\n\n return [];\n }\n\n if (childArray.current.length !== numItems) {\n childArray.current = new Array(virtualizerLength);\n }\n const actualIndex = Math.max(newIndex, 0);\n const end = Math.min(actualIndex + virtualizerLength, numItems);\n\n for (let i = actualIndex; i < end; i++) {\n childArray.current[i - actualIndex] = renderChild(i);\n }\n },\n [numItems, renderChild, virtualizerLength],\n );\n\n const setBeforeRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n\n newList.push(beforeElementRef.current);\n\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n\n // Ensure we update array if before element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const setAfterRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n\n newList.push(afterElementRef.current);\n\n // Ensure we update array if after element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const updateCurrentItemSizes = (newIndex: number) => {\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n\n let didUpdate = false;\n for (let i = startIndex; i < endIndex; i++) {\n const newSize = getItemSize(i);\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n\n if (didUpdate) {\n // Update our progressive size array\n for (let i = startIndex; i < numItems; i++) {\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n };\n\n // Initialize the size array before first render.\n const hasInitialized = useRef<boolean>(false);\n const initializeSizeArray = () => {\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(() => {\n if (virtualizerStartIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // If the user passes in an updated renderChild function - update current children\n useEffect(() => {\n if (virtualizerStartIndex >= 0) {\n updateChildRows(virtualizerStartIndex);\n forceUpdate();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild, updateChildRows]);\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 && virtualizerStartIndex + childArray.current.length < numItems) {\n updateChildRows(virtualizerStartIndex);\n }\n\n const isFullyInitialized = hasInitialized.current && virtualizerStartIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div',\n },\n virtualizedChildren: childArray.current,\n before: resolveShorthand(props.before, {\n required: true,\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n }),\n after: resolveShorthand(props.after, {\n required: true,\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n }),\n beforeContainer: resolveShorthand(props.beforeContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n afterContainer: resolveShorthand(props.afterContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex,\n axis,\n bufferSize,\n reversed,\n };\n}\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ;AAExC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,UAAU,QAAQ;AAGrE,SAASC,gBAAgB,QAAQ;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,gBAAA,CAAiBG,KAAA,CAAMkG,MAAM,EAAE;MACrCK,QAAA,EAAU,IAAI;MACdC,YAAA,EAAc;QACZC,GAAA,EAAKrB,YAAA;QACLsB,IAAA,EAAM;MACR;IACF;IACAP,KAAA,EAAOtG,gBAAA,CAAiBG,KAAA,CAAMmG,KAAK,EAAE;MACnCI,QAAA,EAAU,IAAI;MACdC,YAAA,EAAc;QACZC,GAAA,EAAKjB,WAAA;QACLkB,IAAA,EAAM;MACR;IACF;IACAN,eAAA,EAAiBvG,gBAAA,CAAiBG,KAAA,CAAMoG,eAAe,EAAE;MACvDG,QAAA,EAAU,IAAI;MACdC,YAAA,EAAc;QACZE,IAAA,EAAM;MACR;IACF;IACAL,cAAA,EAAgBxG,gBAAA,CAAiBG,KAAA,CAAMqG,cAAc,EAAE;MACrDE,QAAA,EAAU,IAAI;MACdC,YAAA,EAAc;QACZE,IAAA,EAAM;MACR;IACF;IACAC,kBAAA,EAAoBX,kBAAA,GAAqBxC,eAAA,KAAoB,CAAC;IAC9DoD,iBAAA,EAAmBZ,kBAAA,GAAqBhD,cAAA,KAAmB,CAAC;IAC5D6D,sBAAA,EAAwBb,kBAAA,GAAqB/C,kBAAA,KAAuB9C,iBAAA,GAAoBF,QAAQ;IAChGgB,qBAAA;IACAJ,IAAA;IACAH,UAAA;IACAI;EACF;AACF"}
|
|
1
|
+
{"version":3,"names":["useIntersectionObserver","useEffect","useRef","useCallback","useReducer","resolveShorthand","flushSync","useVirtualizerContextState_unstable","renderVirtualizerChildPlaceholder","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","scrollViewRef","axis","reversed","virtualizerContext","_virtualizerContext","actualIndex","contextIndex","setActualIndex","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","horizontal","populateSizeArrays","current","length","index","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","entries","observer","measurementPos","bufferCount","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","target","calculateAfter","calculateTotalSize","abs","boundingClientRect","bottom","top","right","left","calculateBefore","max","startIndex","getIndexFromScrollPosition","bufferedIndex","maxIndex","newStartIndex","min","root","rootMargin","threshold","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","currentIndex","lastItemIndex","remainingItems","newIndex","_actualIndex","end","i","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","required","defaultProps","ref","role","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"sources":["../../../src/components/Virtualizer/useVirtualizer.ts"],"sourcesContent":["import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport type { ReactNode } from 'react';\nimport { useEffect, useRef, useCallback, useReducer } from 'react';\n\nimport type { VirtualizerProps, VirtualizerState } from './Virtualizer.types';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\n\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { renderVirtualizerChildPlaceholder } from './renderVirtualizer';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n const {\n itemSize,\n numItems,\n virtualizerLength,\n children: renderChild,\n getItemSize,\n bufferItems = Math.round(virtualizerLength / 4.0),\n bufferSize = Math.floor(bufferItems / 2.0) * itemSize,\n scrollViewRef,\n axis = 'vertical',\n reversed = false,\n virtualizerContext,\n } = props;\n\n /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/\n const _virtualizerContext = useVirtualizerContextState_unstable(virtualizerContext);\n\n const actualIndex = _virtualizerContext.contextIndex;\n const setActualIndex = _virtualizerContext.setContextIndex;\n\n // Store ref to before padding element\n const beforeElementRef = useRef<Element | null>(null);\n\n // Store ref to before padding element\n const afterElementRef = useRef<Element | null>(null);\n\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */\n const childProgressiveSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n // The internal tracking REF for child array (updates often).\n const childArray = useRef<ReactNode[]>(new Array(virtualizerLength));\n\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(() => ({}), {})[1];\n\n const horizontal = axis === 'horizontal';\n\n const populateSizeArrays = () => {\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array<number>(numItems);\n }\n\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array<number>(numItems);\n }\n\n for (let index = 0; index < numItems; index++) {\n childSizes.current[index] = getItemSize(index);\n if (index === 0) {\n childProgressiveSizes.current[index] = childSizes.current[index];\n } else {\n childProgressiveSizes.current[index] = childProgressiveSizes.current[index - 1] + childSizes.current[index];\n }\n }\n };\n\n const batchUpdateNewIndex = (index: number) => {\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\n\n // State setters\n setActualIndex(index);\n };\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (actualIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n\n /* IO initiates this function when needed (bookend entering view) */\n let measurementPos = 0;\n let bufferCount = bufferItems;\n\n // Grab latest entry that is intersecting\n const latestEntry =\n entries.length === 1\n ? entries[0]\n : entries\n .sort((entry1, entry2) => entry2.time - entry1.time)\n .find(entry => {\n return entry.intersectionRatio > 0;\n });\n\n if (!latestEntry) {\n // If we don't find an intersecting area, ignore for now.\n return;\n }\n\n if (latestEntry.target === afterElementRef.current) {\n // We need to inverse the buffer count\n bufferCount = virtualizerLength - bufferItems;\n measurementPos = reversed ? calculateAfter() : calculateTotalSize() - calculateAfter();\n if (!horizontal) {\n if (reversed) {\n // Scrolling 'up' and hit the after element below\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' and hit the after element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (reversed) {\n // Scrolling 'left' and hit the after element\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'right' and hit the after element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n measurementPos = reversed ? calculateTotalSize() - calculateBefore() : calculateBefore();\n if (!horizontal) {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' in reverse order and hit the before element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'left' and hit before element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n }\n\n if (reversed) {\n // We're reversed, up is down, left is right, invert the scroll measure.\n measurementPos = Math.max(calculateTotalSize() - Math.abs(measurementPos), 0);\n }\n\n // For now lets use hardcoded size to assess current element to paginate on\n const startIndex = getIndexFromScrollPosition(measurementPos);\n const bufferedIndex = Math.max(startIndex - bufferCount, 0);\n\n // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n\n if (actualIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n flushSync(() => {\n batchUpdateNewIndex(newStartIndex);\n });\n }\n },\n {\n root: scrollViewRef ? scrollViewRef?.current : null,\n rootMargin: '0px',\n threshold: 0,\n },\n );\n\n const findIndexRecursive = (scrollPos: number, lowIndex: number, highIndex: number): number => {\n if (lowIndex > highIndex) {\n // We shouldn't get here - but no-op the index if we do.\n return actualIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */\n return midpoint;\n }\n\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n\n const getIndexFromSizeArray = (scrollPos: number): number => {\n /* Quick searches our progressive height array */\n if (\n scrollPos === 0 ||\n childProgressiveSizes.current.length === 0 ||\n scrollPos <= childProgressiveSizes.current[0]\n ) {\n // Check start\n return 0;\n }\n\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n\n const getIndexFromScrollPosition = (scrollPos: number) => {\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n\n return getIndexFromSizeArray(scrollPos);\n };\n\n const calculateTotalSize = () => {\n if (!getItemSize) {\n return itemSize * numItems;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n };\n\n const calculateBefore = () => {\n const currentIndex = Math.min(actualIndex, numItems);\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 };\n\n const calculateAfter = () => {\n if (numItems === 0) {\n return 0;\n }\n\n const lastItemIndex = Math.min(actualIndex + virtualizerLength, numItems - 1);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex - 1;\n return remainingItems * itemSize;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex];\n };\n\n const updateChildRows = useCallback(\n (newIndex: number) => {\n if (numItems === 0) {\n /* Nothing to virtualize */\n\n return [];\n }\n\n if (childArray.current.length !== numItems) {\n childArray.current = new Array(virtualizerLength);\n }\n const _actualIndex = Math.max(newIndex, 0);\n const end = Math.min(_actualIndex + virtualizerLength, numItems);\n\n for (let i = _actualIndex; i < end; i++) {\n childArray.current[i - _actualIndex] = renderVirtualizerChildPlaceholder(renderChild(i), i);\n }\n },\n [numItems, renderChild, virtualizerLength],\n );\n\n const setBeforeRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n\n newList.push(beforeElementRef.current);\n\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n\n // Ensure we update array if before element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const setAfterRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n\n newList.push(afterElementRef.current);\n\n // Ensure we update array if after element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const updateCurrentItemSizes = (newIndex: number) => {\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n\n let didUpdate = false;\n for (let i = startIndex; i < endIndex; i++) {\n const newSize = getItemSize(i);\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n\n if (didUpdate) {\n // Update our progressive size array\n for (let i = startIndex; i < numItems; i++) {\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n };\n\n // Initialize the size array before first render.\n const hasInitialized = useRef<boolean>(false);\n const initializeSizeArray = () => {\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(() => {\n if (actualIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // If the user passes in an updated renderChild function - update current children\n useEffect(() => {\n if (actualIndex >= 0) {\n updateChildRows(actualIndex);\n forceUpdate();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild, updateChildRows]);\n\n useEffect(() => {\n // Ensure we repopulate if getItemSize callback changes\n populateSizeArrays();\n\n // We only run this effect on getItemSize change (recalc dynamic sizes)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getItemSize]);\n\n // Ensure we have run through and updated the whole size list array at least once.\n initializeSizeArray();\n\n if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {\n // Child length mismatch, repopulate size arrays.\n populateSizeArrays();\n }\n\n // Ensure we recalc if virtualizer length changes\n const maxCompare = Math.min(virtualizerLength, numItems);\n if (childArray.current.length !== maxCompare && actualIndex + childArray.current.length < numItems) {\n updateChildRows(actualIndex);\n }\n\n const isFullyInitialized = hasInitialized.current && actualIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div',\n },\n virtualizedChildren: childArray.current,\n before: resolveShorthand(props.before, {\n required: true,\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n }),\n after: resolveShorthand(props.after, {\n required: true,\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n }),\n beforeContainer: resolveShorthand(props.beforeContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n afterContainer: resolveShorthand(props.afterContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed,\n };\n}\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ;AAExC,SAASC,SAAS,EAAEC,MAAM,EAAEC,WAAW,EAAEC,UAAU,QAAQ;AAG3D,SAASC,gBAAgB,QAAQ;AACjC,SAASC,SAAS,QAAQ;AAE1B,SAASC,mCAAmC,QAAQ;AACpD,SAASC,iCAAiC,QAAQ;AAElD,OAAO,SAASC,wBAAwBC,KAAuB,EAAoB;EACjF,MAAM;IACJC,QAAA;IACAC,QAAA;IACAC,iBAAA;IACAC,QAAA,EAAUC,WAAA;IACVC,WAAA;IACAC,WAAA,GAAcC,IAAA,CAAKC,KAAK,CAACN,iBAAA,GAAoB;IAC7CO,UAAA,GAAaF,IAAA,CAAKG,KAAK,CAACJ,WAAA,GAAc,OAAON,QAAA;IAC7CW,aAAA;IACAC,IAAA,GAAO;IACPC,QAAA,GAAW,KAAK;IAChBC;EAAkB,CACnB,GAAGf,KAAA;EAEJ;EACA,MAAMgB,mBAAA,GAAsBnB,mCAAA,CAAoCkB,kBAAA;EAEhE,MAAME,WAAA,GAAcD,mBAAA,CAAoBE,YAAY;EACpD,MAAMC,cAAA,GAAiBH,mBAAA,CAAoBI,eAAe;EAE1D;EACA,MAAMC,gBAAA,GAAmB7B,MAAA,CAAuB,IAAI;EAEpD;EACA,MA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A,EAAM;MACR;IACF;IACAC,kBAAA,EAAoBX,kBAAA,GAAqBzC,eAAA,KAAoB,CAAC;IAC9DqD,iBAAA,EAAmBZ,kBAAA,GAAqBjD,cAAA,KAAmB,CAAC;IAC5D8D,sBAAA,EAAwBb,kBAAA,GAAqBhD,kBAAA,KAAuBhD,iBAAA,GAAoBF,QAAQ;IAChGgH,qBAAA,EAAuBhG,WAAA;IACvBJ,IAAA;IACAH,UAAA;IACAI;EACF;AACF"}
|
|
@@ -37,9 +37,10 @@ const useStyles = /*#__PURE__*/__styles({
|
|
|
37
37
|
*/
|
|
38
38
|
export const useVirtualizerScrollViewStyles_unstable = state => {
|
|
39
39
|
const styles = useStyles();
|
|
40
|
-
//
|
|
40
|
+
// Default virtualizer styles base
|
|
41
41
|
useVirtualizerStyles_unstable(state);
|
|
42
42
|
const containerStyle = state.axis === 'horizontal' ? state.reversed ? styles.horizontalReversed : styles.horizontal : state.reversed ? styles.verticalReversed : styles.vertical;
|
|
43
|
+
// Add container styles
|
|
43
44
|
state.container.className = mergeClasses(virtualizerScrollViewClassNames.container, styles.base, containerStyle, state.container.className);
|
|
44
45
|
return state;
|
|
45
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useVirtualizerStyles_unstable","virtualizerClassNames","__styles","mergeClasses","virtualizerScrollViewClassName","virtualizerScrollViewClassNames","container","useStyles","base","mc9l5x","a9b677","Bqenvij","Eiaeu8","vertical","Beiy3e4","Bmxbyg5","horizontal","B68tc82","verticalReversed","horizontalReversed","d","useVirtualizerScrollViewStyles_unstable","state","styles","containerStyle","axis","reversed","className"],"sources":["../../../src/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.ts"],"sourcesContent":["import { VirtualizerScrollViewState } from './VirtualizerScrollView.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { VirtualizerScrollViewSlots } from './VirtualizerScrollView.types';\nimport { useVirtualizerStyles_unstable, virtualizerClassNames } from '../Virtualizer/useVirtualizerStyles';\nimport { makeStyles, mergeClasses } from '@griffel/react';\n\nconst virtualizerScrollViewClassName = 'fui-Virtualizer-Scroll-View';\n\nexport const virtualizerScrollViewClassNames: SlotClassNames<VirtualizerScrollViewSlots> = {\n ...virtualizerClassNames,\n container: `${virtualizerScrollViewClassName}__container`,\n};\n\nconst useStyles = makeStyles({\n base: {\n display: 'flex',\n width: '100%',\n height: '100%',\n overflowAnchor: 'none',\n },\n vertical: {\n flexDirection: 'column',\n overflowAnchor: 'none',\n overflowY: 'auto',\n },\n horizontal: {\n flexDirection: 'row',\n overflowX: 'auto',\n },\n verticalReversed: {\n flexDirection: 'column-reverse',\n overflowY: 'auto',\n },\n horizontalReversed: {\n flexDirection: 'row-reverse',\n overflowX: 'auto',\n },\n});\n\n/**\n * Apply styling to the Virtualizer states\n */\nexport const useVirtualizerScrollViewStyles_unstable = (\n state: VirtualizerScrollViewState,\n): VirtualizerScrollViewState => {\n const styles = useStyles();\n\n //
|
|
1
|
+
{"version":3,"names":["useVirtualizerStyles_unstable","virtualizerClassNames","__styles","mergeClasses","virtualizerScrollViewClassName","virtualizerScrollViewClassNames","container","useStyles","base","mc9l5x","a9b677","Bqenvij","Eiaeu8","vertical","Beiy3e4","Bmxbyg5","horizontal","B68tc82","verticalReversed","horizontalReversed","d","useVirtualizerScrollViewStyles_unstable","state","styles","containerStyle","axis","reversed","className"],"sources":["../../../src/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.ts"],"sourcesContent":["import { VirtualizerScrollViewState } from './VirtualizerScrollView.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { VirtualizerScrollViewSlots } from './VirtualizerScrollView.types';\nimport { useVirtualizerStyles_unstable, virtualizerClassNames } from '../Virtualizer/useVirtualizerStyles';\nimport { makeStyles, mergeClasses } from '@griffel/react';\n\nconst virtualizerScrollViewClassName = 'fui-Virtualizer-Scroll-View';\n\nexport const virtualizerScrollViewClassNames: SlotClassNames<VirtualizerScrollViewSlots> = {\n ...virtualizerClassNames,\n container: `${virtualizerScrollViewClassName}__container`,\n};\n\nconst useStyles = makeStyles({\n base: {\n display: 'flex',\n width: '100%',\n height: '100%',\n overflowAnchor: 'none',\n },\n vertical: {\n flexDirection: 'column',\n overflowAnchor: 'none',\n overflowY: 'auto',\n },\n horizontal: {\n flexDirection: 'row',\n overflowX: 'auto',\n },\n verticalReversed: {\n flexDirection: 'column-reverse',\n overflowY: 'auto',\n },\n horizontalReversed: {\n flexDirection: 'row-reverse',\n overflowX: 'auto',\n },\n});\n\n/**\n * Apply styling to the Virtualizer states\n */\nexport const useVirtualizerScrollViewStyles_unstable = (\n state: VirtualizerScrollViewState,\n): VirtualizerScrollViewState => {\n const styles = useStyles();\n\n // Default virtualizer styles base\n useVirtualizerStyles_unstable(state);\n\n const containerStyle =\n state.axis === 'horizontal'\n ? state.reversed\n ? styles.horizontalReversed\n : styles.horizontal\n : state.reversed\n ? styles.verticalReversed\n : styles.vertical;\n\n // Add container styles\n state.container.className = mergeClasses(\n virtualizerScrollViewClassNames.container,\n styles.base,\n containerStyle,\n state.container.className,\n );\n\n return state;\n};\n"],"mappings":"AAGA,SAASA,6BAA6B,EAAEC,qBAAqB,QAAQ;AACrE,SAAAC,QAAA,EAAqBC,YAAY,QAAQ;AAEzC,MAAMC,8BAAA,GAAiC;AAEvC,OAAO,MAAMC,+BAAA,GAA8E;EACzF,GAAGJ,qBAAqB;EACxBK,SAAA,EAAY,GAAEF,8BAA+B;AAC/C;AAEA,MAAMG,SAAA,gBAAYL,QAAA;EAAAM,IAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAC,QAAA;IAAAC,OAAA;IAAAF,MAAA;IAAAG,OAAA;EAAA;EAAAC,UAAA;IAAAF,OAAA;IAAAG,OAAA;EAAA;EAAAC,gBAAA;IAAAJ,OAAA;IAAAC,OAAA;EAAA;EAAAI,kBAAA;IAAAL,OAAA;IAAAG,OAAA;EAAA;AAAA;EAAAG,CAAA;AAAA,EAwBlB;AAEA;;;AAGA,OAAO,MAAMC,uCAAA,GACXC,KAAA,IAC+B;EAC/B,MAAMC,MAAA,GAAShB,SAAA;EAEf;EACAP,6BAAA,CAA8BsB,KAAA;EAE9B,MAAME,cAAA,GACJF,KAAA,CAAMG,IAAI,KAAK,eACXH,KAAA,CAAMI,QAAQ,GACZH,MAAA,CAAOJ,kBAAkB,GACzBI,MAAA,CAAOP,UAAU,GACnBM,KAAA,CAAMI,QAAQ,GACdH,MAAA,CAAOL,gBAAgB,GACvBK,MAAA,CAAOV,QAAQ;EAErB;EACAS,KAAA,CAAMhB,SAAS,CAACqB,SAAS,GAAGxB,YAAA,CAC1BE,+BAAA,CAAgCC,SAAS,EACzCiB,MAAA,CAAOf,IAAI,EACXgB,cAAA,EACAF,KAAA,CAAMhB,SAAS,CAACqB,SAAS;EAG3B,OAAOL,KAAA;AACT"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useVirtualizerScrollViewDynamic_unstable } from './useVirtualizerScrollViewDynamic';
|
|
2
|
+
import { renderVirtualizerScrollViewDynamic_unstable } from './renderVirtualizerScrollViewDynamic';
|
|
3
|
+
import { useVirtualizerScrollViewDynamicStyles_unstable } from './useVirtualizerScrollViewDynamicStyles';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
/**
|
|
6
|
+
* Virtualizer ScrollView
|
|
7
|
+
*/
|
|
8
|
+
export const VirtualizerScrollViewDynamic = (props, context) => {
|
|
9
|
+
const state = useVirtualizerScrollViewDynamic_unstable(props);
|
|
10
|
+
useVirtualizerScrollViewDynamicStyles_unstable(state);
|
|
11
|
+
return renderVirtualizerScrollViewDynamic_unstable(state);
|
|
12
|
+
};
|
|
13
|
+
VirtualizerScrollViewDynamic.displayName = 'VirtualizerScrollViewDynamic';
|
|
14
|
+
//# sourceMappingURL=VirtualizerScrollViewDynamic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useVirtualizerScrollViewDynamic_unstable","renderVirtualizerScrollViewDynamic_unstable","useVirtualizerScrollViewDynamicStyles_unstable","React","VirtualizerScrollViewDynamic","props","context","state","displayName"],"sources":["../../../src/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.ts"],"sourcesContent":["import { VirtualizerScrollViewDynamicProps } from './VirtualizerScrollViewDynamic.types';\nimport { useVirtualizerScrollViewDynamic_unstable } from './useVirtualizerScrollViewDynamic';\nimport { renderVirtualizerScrollViewDynamic_unstable } from './renderVirtualizerScrollViewDynamic';\nimport { useVirtualizerScrollViewDynamicStyles_unstable } from './useVirtualizerScrollViewDynamicStyles';\nimport * as React from 'react';\nimport { VirtualizerContextProps } from '../../Utilities';\n\n/**\n * Virtualizer ScrollView\n */\n\nexport const VirtualizerScrollViewDynamic: React.FC<VirtualizerScrollViewDynamicProps> = (\n props: VirtualizerScrollViewDynamicProps,\n context: React.Context<VirtualizerContextProps>,\n) => {\n const state = useVirtualizerScrollViewDynamic_unstable(props);\n\n useVirtualizerScrollViewDynamicStyles_unstable(state);\n\n return renderVirtualizerScrollViewDynamic_unstable(state);\n};\n\nVirtualizerScrollViewDynamic.displayName = 'VirtualizerScrollViewDynamic';\n"],"mappings":"AACA,SAASA,wCAAwC,QAAQ;AACzD,SAASC,2CAA2C,QAAQ;AAC5D,SAASC,8CAA8C,QAAQ;AAC/D,YAAYC,KAAA,MAAW;AAGvB;;;AAIA,OAAO,MAAMC,4BAAA,GAA4EA,CACvFC,KAAA,EACAC,OAAA,KACG;EACH,MAAMC,KAAA,GAAQP,wCAAA,CAAyCK,KAAA;EAEvDH,8CAAA,CAA+CK,KAAA;EAE/C,OAAON,2CAAA,CAA4CM,KAAA;AACrD;AAEAH,4BAAA,CAA6BI,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.ts"],"sourcesContent":["import { ComponentProps, ComponentState } from '@fluentui/react-utilities';\nimport {\n VirtualizerConfigProps,\n VirtualizerConfigState,\n VirtualizerChildRenderFunction,\n} from '../Virtualizer/Virtualizer.types';\n\nimport { VirtualizerScrollViewSlots } from '../VirtualizerScrollView/VirtualizerScrollView.types';\n\nexport type VirtualizerScrollViewDynamicSlots = VirtualizerScrollViewSlots;\n\nexport type VirtualizerScrollViewDynamicProps = ComponentProps<Partial<VirtualizerScrollViewDynamicSlots>> &\n Partial<Omit<VirtualizerConfigProps, 'itemSize' | 'numItems' | 'getItemSize' | 'children'>> & {\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 */\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\nexport type VirtualizerScrollViewDynamicState = ComponentState<VirtualizerScrollViewDynamicSlots> &\n VirtualizerConfigState;\n"],"mappings":"AAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './VirtualizerScrollViewDynamic';
|
|
2
|
+
export * from './VirtualizerScrollViewDynamic.types';
|
|
3
|
+
export * from './useVirtualizerScrollViewDynamic';
|
|
4
|
+
export * from './renderVirtualizerScrollViewDynamic';
|
|
5
|
+
export * from './useVirtualizerScrollViewDynamicStyles';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/VirtualizerScrollViewDynamic/index.ts"],"sourcesContent":["export * from './VirtualizerScrollViewDynamic';\nexport * from './VirtualizerScrollViewDynamic.types';\nexport * from './useVirtualizerScrollViewDynamic';\nexport * from './renderVirtualizerScrollViewDynamic';\nexport * from './useVirtualizerScrollViewDynamicStyles';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @jsxRuntime classic */ /** @jsx createElement */import { createElement } from '@fluentui/react-jsx-runtime';
|
|
2
|
+
import { getSlotsNext } from '@fluentui/react-utilities';
|
|
3
|
+
import { renderVirtualizer_unstable } from '../Virtualizer/renderVirtualizer';
|
|
4
|
+
export const renderVirtualizerScrollViewDynamic_unstable = state => {
|
|
5
|
+
const {
|
|
6
|
+
slots,
|
|
7
|
+
slotProps
|
|
8
|
+
} = getSlotsNext(state);
|
|
9
|
+
return /*#__PURE__*/createElement(slots.container, slotProps.container, renderVirtualizer_unstable(state));
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=renderVirtualizerScrollViewDynamic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createElement","getSlotsNext","renderVirtualizer_unstable","renderVirtualizerScrollViewDynamic_unstable","state","slots","slotProps","container"],"sources":["../../../src/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.tsx"],"sourcesContent":["/** @jsxRuntime classic */\n/** @jsx createElement */\n\nimport { createElement } from '@fluentui/react-jsx-runtime';\nimport { getSlotsNext } from '@fluentui/react-utilities';\nimport {\n VirtualizerScrollViewDynamicSlots,\n VirtualizerScrollViewDynamicState,\n} from './VirtualizerScrollViewDynamic.types';\nimport { renderVirtualizer_unstable } from '../Virtualizer/renderVirtualizer';\n\nexport const renderVirtualizerScrollViewDynamic_unstable = (state: VirtualizerScrollViewDynamicState) => {\n const { slots, slotProps } = getSlotsNext<VirtualizerScrollViewDynamicSlots>(state);\n return <slots.container {...slotProps.container}>{renderVirtualizer_unstable(state)}</slots.container>;\n};\n"],"mappings":"AAAA,2BACA,yBAEA,SAASA,aAAa,QAAQ;AAC9B,SAASC,YAAY,QAAQ;AAK7B,SAASC,0BAA0B,QAAQ;AAE3C,OAAO,MAAMC,2CAAA,GAA+CC,KAAA,IAA6C;EACvG,MAAM;IAAEC,KAAA;IAAOC;EAAS,CAAE,GAAGL,YAAA,CAAgDG,KAAA;EAC7E,oBAAOJ,aAZT,CAYUK,KAAA,CAAME,SAAS,EAAKD,SAAA,CAAUC,SAAS,EAAGL,0BAAA,CAA2BE,KAAA;AAC/E"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';
|
|
3
|
+
import { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';
|
|
4
|
+
import { useDynamicVirtualizerMeasure } from '../../Hooks';
|
|
5
|
+
import { useVirtualizerContextState_unstable } from '../../Utilities';
|
|
6
|
+
export function useVirtualizerScrollViewDynamic_unstable(props) {
|
|
7
|
+
const contextState = useVirtualizerContextState_unstable(props.virtualizerContext);
|
|
8
|
+
var _props_axis, _contextState_contextIndex;
|
|
9
|
+
const {
|
|
10
|
+
virtualizerLength,
|
|
11
|
+
bufferItems,
|
|
12
|
+
bufferSize,
|
|
13
|
+
scrollRef
|
|
14
|
+
} = useDynamicVirtualizerMeasure({
|
|
15
|
+
defaultItemSize: props.itemSize,
|
|
16
|
+
direction: (_props_axis = props.axis) !== null && _props_axis !== void 0 ? _props_axis : 'vertical',
|
|
17
|
+
getItemSize: props.getItemSize,
|
|
18
|
+
currentIndex: (_contextState_contextIndex = contextState === null || contextState === void 0 ? void 0 : contextState.contextIndex) !== null && _contextState_contextIndex !== void 0 ? _contextState_contextIndex : 0,
|
|
19
|
+
numItems: props.numItems
|
|
20
|
+
});
|
|
21
|
+
const iScrollRef = useMergedRefs(React.useRef(null), scrollRef);
|
|
22
|
+
const virtualizerState = useVirtualizer_unstable({
|
|
23
|
+
...props,
|
|
24
|
+
virtualizerLength,
|
|
25
|
+
bufferItems,
|
|
26
|
+
bufferSize,
|
|
27
|
+
scrollViewRef: iScrollRef,
|
|
28
|
+
virtualizerContext: contextState
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
...virtualizerState,
|
|
32
|
+
components: {
|
|
33
|
+
...virtualizerState.components,
|
|
34
|
+
container: 'div'
|
|
35
|
+
},
|
|
36
|
+
container: resolveShorthand(props.container, {
|
|
37
|
+
required: true,
|
|
38
|
+
defaultProps: {
|
|
39
|
+
ref: iScrollRef
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=useVirtualizerScrollViewDynamic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","resolveShorthand","useMergedRefs","useVirtualizer_unstable","useDynamicVirtualizerMeasure","useVirtualizerContextState_unstable","useVirtualizerScrollViewDynamic_unstable","props","contextState","virtualizerContext","_props_axis","_contextState_contextIndex","virtualizerLength","bufferItems","bufferSize","scrollRef","defaultItemSize","itemSize","direction","axis","getItemSize","currentIndex","contextIndex","numItems","iScrollRef","useRef","virtualizerState","scrollViewRef","components","container","required","defaultProps","ref"],"sources":["../../../src/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.ts"],"sourcesContent":["import * as React from 'react';\nimport { resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';\nimport { useVirtualizer_unstable } from '../Virtualizer/useVirtualizer';\nimport {\n VirtualizerScrollViewDynamicProps,\n VirtualizerScrollViewDynamicState,\n} from './VirtualizerScrollViewDynamic.types';\nimport { useDynamicVirtualizerMeasure } from '../../Hooks';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\n\nexport function useVirtualizerScrollViewDynamic_unstable(\n props: VirtualizerScrollViewDynamicProps,\n): VirtualizerScrollViewDynamicState {\n const contextState = useVirtualizerContextState_unstable(props.virtualizerContext);\n\n const { virtualizerLength, bufferItems, bufferSize, scrollRef } = useDynamicVirtualizerMeasure({\n defaultItemSize: props.itemSize,\n direction: props.axis ?? 'vertical',\n getItemSize: props.getItemSize,\n currentIndex: contextState?.contextIndex ?? 0,\n numItems: props.numItems,\n });\n\n const iScrollRef = useMergedRefs(React.useRef<HTMLDivElement>(null), scrollRef) as React.RefObject<HTMLDivElement>;\n\n const virtualizerState = useVirtualizer_unstable({\n ...props,\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollViewRef: iScrollRef,\n virtualizerContext: contextState,\n });\n\n return {\n ...virtualizerState,\n components: {\n ...virtualizerState.components,\n container: 'div',\n },\n container: resolveShorthand(props.container, {\n required: true,\n defaultProps: {\n ref: iScrollRef,\n },\n }),\n };\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,gBAAgB,EAAEC,aAAa,QAAQ;AAChD,SAASC,uBAAuB,QAAQ;AAKxC,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,mCAAmC,QAAQ;AAEpD,OAAO,SAASC,yCACdC,KAAwC,EACL;EACnC,MAAMC,YAAA,GAAeH,mCAAA,CAAoCE,KAAA,CAAME,kBAAkB;MAIpEC,WAAA,EAEGC,0BAAA;EAJhB,MAAM;IAAEC,iBAAA;IAAmBC,WAAA;IAAaC,UAAA;IAAYC;EAAS,CAAE,GAAGX,4BAAA,CAA6B;IAC7FY,eAAA,EAAiBT,KAAA,CAAMU,QAAQ;IAC/BC,SAAA,EAAW,CAAAR,WAAA,GAAAH,KAAA,CAAMY,IAAI,cAAVT,WAAA,cAAAA,WAAA,GAAc,UAAU;IACnCU,WAAA,EAAab,KAAA,CAAMa,WAAW;IAC9BC,YAAA,EAAc,CAAAV,0BAAA,GAAAH,YAAA,aAAAA,YAAA,uBAAAA,YAAA,CAAcc,YAAY,cAA1BX,0BAAA,cAAAA,0BAAA,GAA8B,CAAC;IAC7CY,QAAA,EAAUhB,KAAA,CAAMgB;EAClB;EAEA,MAAMC,UAAA,GAAatB,aAAA,CAAcF,KAAA,CAAMyB,MAAM,CAAiB,IAAI,GAAGV,SAAA;EAErE,MAAMW,gBAAA,GAAmBvB,uBAAA,CAAwB;IAC/C,GAAGI,KAAK;IACRK,iBAAA;IACAC,WAAA;IACAC,UAAA;IACAa,aAAA,EAAeH,UAAA;IACff,kBAAA,EAAoBD;EACtB;EAEA,OAAO;IACL,GAAGkB,gBAAgB;IACnBE,UAAA,EAAY;MACV,GAAGF,gBAAA,CAAiBE,UAAU;MAC9BC,SAAA,EAAW;IACb;IACAA,SAAA,EAAW5B,gBAAA,CAAiBM,KAAA,CAAMsB,SAAS,EAAE;MAC3CC,QAAA,EAAU,IAAI;MACdC,YAAA,EAAc;QACZC,GAAA,EAAKR;MACP;IACF;EACF;AACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useVirtualizerStyles_unstable, virtualizerClassNames } from '../Virtualizer/useVirtualizerStyles';
|
|
2
|
+
import { __styles, mergeClasses } from '@griffel/react';
|
|
3
|
+
const virtualizerScrollViewDynamicClassName = 'fui-Virtualizer-Scroll-View-Dynamic';
|
|
4
|
+
export const virtualizerScrollViewDynamicClassNames = {
|
|
5
|
+
...virtualizerClassNames,
|
|
6
|
+
container: `${virtualizerScrollViewDynamicClassName}__container`
|
|
7
|
+
};
|
|
8
|
+
const useStyles = /*#__PURE__*/__styles({
|
|
9
|
+
base: {
|
|
10
|
+
mc9l5x: "f22iagw",
|
|
11
|
+
a9b677: "fly5x3f",
|
|
12
|
+
Bqenvij: "f1l02sjl",
|
|
13
|
+
Eiaeu8: "f1115ve7"
|
|
14
|
+
},
|
|
15
|
+
vertical: {
|
|
16
|
+
Beiy3e4: "f1vx9l62",
|
|
17
|
+
Bmxbyg5: "f5zp4f"
|
|
18
|
+
},
|
|
19
|
+
horizontal: {
|
|
20
|
+
Beiy3e4: "f1063pyq",
|
|
21
|
+
B68tc82: "f1oy3dpc"
|
|
22
|
+
},
|
|
23
|
+
verticalReversed: {
|
|
24
|
+
Beiy3e4: "f1gkdon0",
|
|
25
|
+
Bmxbyg5: "f5zp4f"
|
|
26
|
+
},
|
|
27
|
+
horizontalReversed: {
|
|
28
|
+
Beiy3e4: "f1oztnx0",
|
|
29
|
+
B68tc82: "f1oy3dpc"
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
d: [".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".fly5x3f{width:100%;}", ".f1l02sjl{height:100%;}", ".f1115ve7{overflow-anchor:none;}", ".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}", ".f5zp4f{overflow-y:auto;}", ".f1063pyq{-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;}", ".f1oy3dpc{overflow-x:auto;}", ".f1gkdon0{-webkit-flex-direction:column-reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse;}", ".f1oztnx0{-webkit-flex-direction:row-reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse;}"]
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Apply styling to the Virtualizer states
|
|
36
|
+
*/
|
|
37
|
+
export const useVirtualizerScrollViewDynamicStyles_unstable = state => {
|
|
38
|
+
const styles = useStyles();
|
|
39
|
+
// Default virtualizer styles base
|
|
40
|
+
useVirtualizerStyles_unstable(state);
|
|
41
|
+
const containerStyle = state.axis === 'horizontal' ? state.reversed ? styles.horizontalReversed : styles.horizontal : state.reversed ? styles.verticalReversed : styles.vertical;
|
|
42
|
+
// Add container styles
|
|
43
|
+
state.container.className = mergeClasses(virtualizerScrollViewDynamicClassNames.container, styles.base, containerStyle, state.container.className);
|
|
44
|
+
return state;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=useVirtualizerScrollViewDynamicStyles.js.map
|
package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useVirtualizerStyles_unstable","virtualizerClassNames","__styles","mergeClasses","virtualizerScrollViewDynamicClassName","virtualizerScrollViewDynamicClassNames","container","useStyles","base","mc9l5x","a9b677","Bqenvij","Eiaeu8","vertical","Beiy3e4","Bmxbyg5","horizontal","B68tc82","verticalReversed","horizontalReversed","d","useVirtualizerScrollViewDynamicStyles_unstable","state","styles","containerStyle","axis","reversed","className"],"sources":["../../../src/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.ts"],"sourcesContent":["import type { SlotClassNames } from '@fluentui/react-utilities';\nimport {\n VirtualizerScrollViewDynamicSlots,\n VirtualizerScrollViewDynamicState,\n} from './VirtualizerScrollViewDynamic.types';\nimport { useVirtualizerStyles_unstable, virtualizerClassNames } from '../Virtualizer/useVirtualizerStyles';\nimport { makeStyles, mergeClasses } from '@griffel/react';\n\nconst virtualizerScrollViewDynamicClassName = 'fui-Virtualizer-Scroll-View-Dynamic';\n\nexport const virtualizerScrollViewDynamicClassNames: SlotClassNames<VirtualizerScrollViewDynamicSlots> = {\n ...virtualizerClassNames,\n container: `${virtualizerScrollViewDynamicClassName}__container`,\n};\n\nconst useStyles = makeStyles({\n base: {\n display: 'flex',\n width: '100%',\n height: '100%',\n overflowAnchor: 'none',\n },\n vertical: {\n flexDirection: 'column',\n overflowY: 'auto',\n },\n horizontal: {\n flexDirection: 'row',\n overflowX: 'auto',\n },\n verticalReversed: {\n flexDirection: 'column-reverse',\n overflowY: 'auto',\n },\n horizontalReversed: {\n flexDirection: 'row-reverse',\n overflowX: 'auto',\n },\n});\n\n/**\n * Apply styling to the Virtualizer states\n */\nexport const useVirtualizerScrollViewDynamicStyles_unstable = (\n state: VirtualizerScrollViewDynamicState,\n): VirtualizerScrollViewDynamicState => {\n const styles = useStyles();\n\n // Default virtualizer styles base\n useVirtualizerStyles_unstable(state);\n\n const containerStyle =\n state.axis === 'horizontal'\n ? state.reversed\n ? styles.horizontalReversed\n : styles.horizontal\n : state.reversed\n ? styles.verticalReversed\n : styles.vertical;\n\n // Add container styles\n state.container.className = mergeClasses(\n virtualizerScrollViewDynamicClassNames.container,\n styles.base,\n containerStyle,\n state.container.className,\n );\n\n return state;\n};\n"],"mappings":"AAKA,SAASA,6BAA6B,EAAEC,qBAAqB,QAAQ;AACrE,SAAAC,QAAA,EAAqBC,YAAY,QAAQ;AAEzC,MAAMC,qCAAA,GAAwC;AAE9C,OAAO,MAAMC,sCAAA,GAA4F;EACvG,GAAGJ,qBAAqB;EACxBK,SAAA,EAAY,GAAEF,qCAAsC;AACtD;AAEA,MAAMG,SAAA,gBAAYL,QAAA;EAAAM,IAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAC,QAAA;IAAAC,OAAA;IAAAC,OAAA;EAAA;EAAAC,UAAA;IAAAF,OAAA;IAAAG,OAAA;EAAA;EAAAC,gBAAA;IAAAJ,OAAA;IAAAC,OAAA;EAAA;EAAAI,kBAAA;IAAAL,OAAA;IAAAG,OAAA;EAAA;AAAA;EAAAG,CAAA;AAAA,EAuBlB;AAEA;;;AAGA,OAAO,MAAMC,8CAAA,GACXC,KAAA,IACsC;EACtC,MAAMC,MAAA,GAAShB,SAAA;EAEf;EACAP,6BAAA,CAA8BsB,KAAA;EAE9B,MAAME,cAAA,GACJF,KAAA,CAAMG,IAAI,KAAK,eACXH,KAAA,CAAMI,QAAQ,GACZH,MAAA,CAAOJ,kBAAkB,GACzBI,MAAA,CAAOP,UAAU,GACnBM,KAAA,CAAMI,QAAQ,GACdH,MAAA,CAAOL,gBAAgB,GACvBK,MAAA,CAAOV,QAAQ;EAErB;EACAS,KAAA,CAAMhB,SAAS,CAACqB,SAAS,GAAGxB,YAAA,CAC1BE,sCAAA,CAAuCC,SAAS,EAChDiB,MAAA,CAAOf,IAAI,EACXgB,cAAA,EACAF,KAAA,CAAMhB,SAAS,CAACqB,SAAS;EAG3B,OAAOL,KAAA;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/hooks/hooks.types.ts"],"sourcesContent":["import { MutableRefObject } from 'react';\n\nexport type VirtualizerMeasureProps = {\n defaultItemSize: number;\n direction?: 'vertical' | 'horizontal';\n};\n\nexport type VirtualizerMeasureDynamicProps = {\n defaultItemSize: number;\n currentIndex: number;\n numItems: number;\n getItemSize: (index: number) => number;\n direction?: 'vertical' | 'horizontal';\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 (entries: ResizeObserverEntry[], observer: ResizeObserver, scrollRef?: MutableRefObject<HTMLElement | null>): void;\n}\n"],"mappings":"AAAA"}
|
package/lib/hooks/index.js
CHANGED
package/lib/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/hooks/index.ts"],"sourcesContent":["export * from './useIntersectionObserver';\nexport * from './useVirtualizerMeasure';\n"],"mappings":"AAAA,cAAc;AACd,cAAc"}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/hooks/index.ts"],"sourcesContent":["export * from './useIntersectionObserver';\nexport * from './useVirtualizerMeasure';\nexport * from './useDynamicVirtualizerMeasure';\nexport * from './useResizeObserverRef';\nexport * from './hooks.types';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useResizeObserverRef_unstable } from './useResizeObserverRef';
|
|
4
|
+
import { useRef } from 'react';
|
|
5
|
+
/**
|
|
6
|
+
* React hook that measures virtualized space dynamically to ensure optimized virtualization length.
|
|
7
|
+
*/
|
|
8
|
+
export const useDynamicVirtualizerMeasure = virtualizerProps => {
|
|
9
|
+
const {
|
|
10
|
+
defaultItemSize,
|
|
11
|
+
direction = 'vertical',
|
|
12
|
+
numItems,
|
|
13
|
+
getItemSize,
|
|
14
|
+
currentIndex
|
|
15
|
+
} = virtualizerProps;
|
|
16
|
+
const indexRef = useRef(currentIndex);
|
|
17
|
+
indexRef.current = currentIndex;
|
|
18
|
+
const [state, setState] = React.useState({
|
|
19
|
+
virtualizerLength: 0,
|
|
20
|
+
virtualizerBufferItems: 0,
|
|
21
|
+
virtualizerBufferSize: 0
|
|
22
|
+
});
|
|
23
|
+
const {
|
|
24
|
+
virtualizerLength,
|
|
25
|
+
virtualizerBufferItems,
|
|
26
|
+
virtualizerBufferSize
|
|
27
|
+
} = state;
|
|
28
|
+
const container = React.useRef(null);
|
|
29
|
+
const handleScrollResize = React.useCallback(scrollRef => {
|
|
30
|
+
if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
31
|
+
// Error? ignore?
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (scrollRef.current !== container.current) {
|
|
35
|
+
container.current = scrollRef.current;
|
|
36
|
+
}
|
|
37
|
+
const containerSize = direction === 'vertical' ? scrollRef.current.getBoundingClientRect().height : scrollRef.current.getBoundingClientRect().width;
|
|
38
|
+
let indexSizer = 0;
|
|
39
|
+
let length = 0;
|
|
40
|
+
while (indexSizer <= containerSize && length < numItems) {
|
|
41
|
+
const iItemSize = getItemSize(indexRef.current + length);
|
|
42
|
+
// Increment
|
|
43
|
+
indexSizer += iItemSize;
|
|
44
|
+
length++;
|
|
45
|
+
}
|
|
46
|
+
/*
|
|
47
|
+
* Number of items to append at each end, i.e. 'preload' each side before entering view.
|
|
48
|
+
*/
|
|
49
|
+
const bufferItems = Math.max(Math.floor(length / 4), 2);
|
|
50
|
+
/*
|
|
51
|
+
* This is how far we deviate into the bufferItems to detect a redraw.
|
|
52
|
+
*/
|
|
53
|
+
const bufferSize = Math.max(Math.floor(length / 8 * defaultItemSize), 1);
|
|
54
|
+
const totalLength = length + bufferItems * 2 + 3;
|
|
55
|
+
setState({
|
|
56
|
+
virtualizerLength: totalLength,
|
|
57
|
+
virtualizerBufferSize: bufferSize,
|
|
58
|
+
virtualizerBufferItems: bufferItems
|
|
59
|
+
});
|
|
60
|
+
}, [defaultItemSize, direction, getItemSize, numItems]);
|
|
61
|
+
const resizeCallback = React.useCallback((_entries, _observer, scrollRef) => {
|
|
62
|
+
if (scrollRef) {
|
|
63
|
+
handleScrollResize(scrollRef);
|
|
64
|
+
}
|
|
65
|
+
}, [handleScrollResize]);
|
|
66
|
+
const scrollRef = useResizeObserverRef_unstable(resizeCallback);
|
|
67
|
+
useIsomorphicLayoutEffect(() => {
|
|
68
|
+
var _container_current, _container_current1;
|
|
69
|
+
if (!container.current) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const containerSize = direction === 'vertical' ? ((_container_current = container.current) === null || _container_current === void 0 ? void 0 : _container_current.getBoundingClientRect().height) * 1.5 : ((_container_current1 = container.current) === null || _container_current1 === void 0 ? void 0 : _container_current1.getBoundingClientRect().width) * 1.5;
|
|
73
|
+
let couldBeSmaller = false;
|
|
74
|
+
let recheckTotal = 0;
|
|
75
|
+
for (let i = currentIndex; i < currentIndex + virtualizerLength; i++) {
|
|
76
|
+
const newItemSize = getItemSize(i);
|
|
77
|
+
recheckTotal += newItemSize;
|
|
78
|
+
const newLength = i - currentIndex;
|
|
79
|
+
const bufferItems = Math.max(Math.floor(newLength / 4), 2);
|
|
80
|
+
const totalNewLength = newLength + bufferItems * 2 + 4;
|
|
81
|
+
const compareLengths = totalNewLength < virtualizerLength;
|
|
82
|
+
if (recheckTotal > containerSize && compareLengths) {
|
|
83
|
+
couldBeSmaller = true;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Check if the render has caused us to need a re-calc of virtualizer length
|
|
88
|
+
if (recheckTotal < containerSize || couldBeSmaller) {
|
|
89
|
+
handleScrollResize(container);
|
|
90
|
+
}
|
|
91
|
+
}, [getItemSize, currentIndex, direction, virtualizerLength, resizeCallback, handleScrollResize]);
|
|
92
|
+
return {
|
|
93
|
+
virtualizerLength,
|
|
94
|
+
bufferItems: virtualizerBufferItems,
|
|
95
|
+
bufferSize: virtualizerBufferSize,
|
|
96
|
+
scrollRef
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=useDynamicVirtualizerMeasure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useIsomorphicLayoutEffect","React","useResizeObserverRef_unstable","useRef","useDynamicVirtualizerMeasure","virtualizerProps","defaultItemSize","direction","numItems","getItemSize","currentIndex","indexRef","current","state","setState","useState","virtualizerLength","virtualizerBufferItems","virtualizerBufferSize","container","handleScrollResize","useCallback","scrollRef","containerSize","getBoundingClientRect","height","width","indexSizer","length","iItemSize","bufferItems","Math","max","floor","bufferSize","totalLength","resizeCallback","_entries","_observer","_container_current","_container_current1","couldBeSmaller","recheckTotal","i","newItemSize","newLength","totalNewLength","compareLengths"],"sources":["../../src/hooks/useDynamicVirtualizerMeasure.ts"],"sourcesContent":["import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { VirtualizerMeasureDynamicProps } from './hooks.types';\nimport { useResizeObserverRef_unstable } from './useResizeObserverRef';\nimport { useRef } from 'react';\n\n/**\n * React hook that measures virtualized space dynamically to ensure optimized virtualization length.\n */\nexport const useDynamicVirtualizerMeasure = <TElement extends HTMLElement>(\n virtualizerProps: VirtualizerMeasureDynamicProps,\n): {\n virtualizerLength: number;\n bufferItems: number;\n bufferSize: number;\n scrollRef: (instance: TElement | null) => void;\n} => {\n const { defaultItemSize, direction = 'vertical', numItems, getItemSize, currentIndex } = virtualizerProps;\n const indexRef = useRef<number>(currentIndex);\n indexRef.current = currentIndex;\n\n const [state, setState] = React.useState({\n virtualizerLength: 0,\n virtualizerBufferItems: 0,\n virtualizerBufferSize: 0,\n });\n\n const { virtualizerLength, virtualizerBufferItems, virtualizerBufferSize } = state;\n\n const container = React.useRef<HTMLElement | null>(null);\n const handleScrollResize = React.useCallback(\n (scrollRef: React.MutableRefObject<HTMLElement | null>) => {\n if (!scrollRef?.current) {\n // Error? ignore?\n return;\n }\n\n if (scrollRef.current !== container.current) {\n container.current = scrollRef.current;\n }\n\n const containerSize =\n direction === 'vertical'\n ? scrollRef.current.getBoundingClientRect().height\n : scrollRef.current.getBoundingClientRect().width;\n\n let indexSizer = 0;\n let length = 0;\n\n while (indexSizer <= containerSize && length < numItems) {\n const iItemSize = getItemSize(indexRef.current + length);\n\n // Increment\n indexSizer += iItemSize;\n length++;\n }\n\n /*\n * Number of items to append at each end, i.e. 'preload' each side before entering view.\n */\n const bufferItems = Math.max(Math.floor(length / 4), 2);\n\n /*\n * This is how far we deviate into the bufferItems to detect a redraw.\n */\n const bufferSize = Math.max(Math.floor((length / 8) * defaultItemSize), 1);\n\n const totalLength = length + bufferItems * 2 + 3;\n setState({\n virtualizerLength: totalLength,\n virtualizerBufferSize: bufferSize,\n virtualizerBufferItems: bufferItems,\n });\n },\n [defaultItemSize, direction, getItemSize, numItems],\n );\n\n const resizeCallback = React.useCallback(\n (\n _entries: ResizeObserverEntry[],\n _observer: ResizeObserver,\n scrollRef?: React.MutableRefObject<HTMLElement | null>,\n ) => {\n if (scrollRef) {\n handleScrollResize(scrollRef);\n }\n },\n [handleScrollResize],\n );\n\n const scrollRef = useResizeObserverRef_unstable(resizeCallback);\n\n useIsomorphicLayoutEffect(() => {\n if (!container.current) {\n return;\n }\n\n const containerSize =\n direction === 'vertical'\n ? container.current?.getBoundingClientRect().height * 1.5\n : container.current?.getBoundingClientRect().width * 1.5;\n\n let couldBeSmaller = false;\n let recheckTotal = 0;\n for (let i = currentIndex; i < currentIndex + virtualizerLength; i++) {\n const newItemSize = getItemSize(i);\n recheckTotal += newItemSize;\n\n const newLength = i - currentIndex;\n\n const bufferItems = Math.max(Math.floor(newLength / 4), 2);\n const totalNewLength = newLength + bufferItems * 2 + 4;\n const compareLengths = totalNewLength < virtualizerLength;\n\n if (recheckTotal > containerSize && compareLengths) {\n couldBeSmaller = true;\n break;\n }\n }\n\n // Check if the render has caused us to need a re-calc of virtualizer length\n if (recheckTotal < containerSize || couldBeSmaller) {\n handleScrollResize(container);\n }\n }, [getItemSize, currentIndex, direction, virtualizerLength, resizeCallback, handleScrollResize]);\n\n return {\n virtualizerLength,\n bufferItems: virtualizerBufferItems,\n bufferSize: virtualizerBufferSize,\n scrollRef,\n };\n};\n"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ;AAC1C,YAAYC,KAAA,MAAW;AAEvB,SAASC,6BAA6B,QAAQ;AAC9C,SAASC,MAAM,QAAQ;AAEvB;;;AAGA,OAAO,MAAMC,4BAAA,GACXC,gBAAA,IAMG;EACH,MAAM;IAAEC,eAAA;IAAiBC,SAAA,GAAY;IAAYC,QAAA;IAAUC,WAAA;IAAaC;EAAY,CAAE,GAAGL,gBAAA;EACzF,MAAMM,QAAA,GAAWR,MAAA,CAAeO,YAAA;EAChCC,QAAA,CAASC,OAAO,GAAGF,YAAA;EAEnB,MAAM,CAACG,KAAA,EAAOC,QAAA,CAAS,GAAGb,KAAA,CAAMc,QAAQ,CAAC;IACvCC,iBAAA,EAAmB;IACnBC,sBAAA,EAAwB;IACxBC,qBAAA,EAAuB;EACzB;EAEA,MAAM;IAAEF,iBAAA;IAAmBC,sBAAA;IAAwBC;EAAqB,CAAE,GAAGL,KAAA;EAE7E,MAAMM,SAAA,GAAYlB,KAAA,CAAME,MAAM,CAAqB,IAAI;EACvD,MAAMiB,kBAAA,GAAqBnB,KAAA,CAAMoB,WAAW,CACzCC,SAAA,IAA0D;IACzD,IAAI,EAACA,SAAA,aAAAA,SAAA,uBAAAA,SAAA,CAAWV,OAAO,CAAD,EAAG;MACvB;MACA;IACF;IAEA,IAAIU,SAAA,CAAUV,OAAO,KAAKO,SAAA,CAAUP,OAAO,EAAE;MAC3CO,SAAA,CAAUP,OAAO,GAAGU,SAAA,CAAUV,OAAO;IACvC;IAEA,MAAMW,aAAA,GACJhB,SAAA,KAAc,aACVe,SAAA,CAAUV,OAAO,CAACY,qBAAqB,GAAGC,MAAM,GAChDH,SAAA,CAAUV,OAAO,CAACY,qBAAqB,GAAGE,KAAK;IAErD,IAAIC,UAAA,GAAa;IACjB,IAAIC,MAAA,GAAS;IA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mBAAA,CAAmBhB,qBAAA,GAAwBE,KAAK,IAAG,GAAG;IAE5D,IAAIe,cAAA,GAAiB,KAAK;IAC1B,IAAIC,YAAA,GAAe;IACnB,KAAK,IAAIC,CAAA,GAAIjC,YAAA,EAAciC,CAAA,GAAIjC,YAAA,GAAeM,iBAAA,EAAmB2B,CAAA,IAAK;MACpE,MAAMC,WAAA,GAAcnC,WAAA,CAAYkC,CAAA;MAChCD,YAAA,IAAgBE,WAAA;MAEhB,MAAMC,SAAA,GAAYF,CAAA,GAAIjC,YAAA;MAEtB,MAAMoB,WAAA,GAAcC,IAAA,CAAKC,GAAG,CAACD,IAAA,CAAKE,KAAK,CAACY,SAAA,GAAY,IAAI;MACxD,MAAMC,cAAA,GAAiBD,SAAA,GAAYf,WAAA,GAAc,IAAI;MACrD,MAAMiB,cAAA,GAAiBD,cAAA,GAAiB9B,iBAAA;MAExC,IAAI0B,YAAA,GAAenB,aAAA,IAAiBwB,cAAA,EAAgB;QAClDN,cAAA,GAAiB,IAAI;QACrB;MACF;IACF;IAEA;IACA,IAAIC,YAAA,GAAenB,aAAA,IAAiBkB,cAAA,EAAgB;MAClDrB,kBAAA,CAAmBD,SAAA;IACrB;EACF,GAAG,CAACV,WAAA,EAAaC,YAAA,EAAcH,SAAA,EAAWS,iBAAA,EAAmBoB,cAAA,EAAgBhB,kBAAA,CAAmB;EAEhG,OAAO;IACLJ,iBAAA;IACAc,WAAA,EAAab,sBAAA;IACbiB,UAAA,EAAYhB,qBAAA;IACZI;EACF;AACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { debounce } from '../utilities/debounce';
|
|
3
|
+
import { canUseDOM } from '@fluentui/react-utilities';
|
|
4
|
+
/**
|
|
5
|
+
* useResizeObserverRef_unstable simplifies resize observer connection and ensures debounce/cleanup
|
|
6
|
+
*/
|
|
7
|
+
export const useResizeObserverRef_unstable = resizeCallback => {
|
|
8
|
+
const container = React.useRef(null);
|
|
9
|
+
// the handler for resize observer
|
|
10
|
+
const handleResize = debounce((entries, observer) => {
|
|
11
|
+
resizeCallback(entries, observer, container);
|
|
12
|
+
});
|
|
13
|
+
// Keep the reference of ResizeObserver in the state, as it should live through renders
|
|
14
|
+
const [resizeObserver, setResizeObserver] = React.useState(() => canUseDOM() ? new ResizeObserver(handleResize) : undefined);
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
// Update our state when resizeCallback changes
|
|
17
|
+
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
|
|
18
|
+
setResizeObserver(canUseDOM() ? new ResizeObserver(handleResize) : undefined);
|
|
19
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
+
}, [resizeCallback]);
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
return () => {
|
|
23
|
+
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
|
|
24
|
+
};
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
}, []);
|
|
27
|
+
const scrollRef = React.useCallback(instance => {
|
|
28
|
+
if (container.current !== instance) {
|
|
29
|
+
if (container.current) {
|
|
30
|
+
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.unobserve(container.current);
|
|
31
|
+
}
|
|
32
|
+
container.current = instance;
|
|
33
|
+
if (container.current) {
|
|
34
|
+
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.observe(container.current);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}, [resizeObserver]);
|
|
38
|
+
return scrollRef;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=useResizeObserverRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","debounce","canUseDOM","useResizeObserverRef_unstable","resizeCallback","container","useRef","handleResize","entries","observer","resizeObserver","setResizeObserver","useState","ResizeObserver","undefined","useEffect","disconnect","scrollRef","useCallback","instance","current","unobserve","observe"],"sources":["../../src/hooks/useResizeObserverRef.ts"],"sourcesContent":["import * as React from 'react';\nimport { debounce } from '../utilities/debounce';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { ResizeCallbackWithRef } from './hooks.types';\n\n/**\n * useResizeObserverRef_unstable simplifies resize observer connection and ensures debounce/cleanup\n */\nexport const useResizeObserverRef_unstable = (resizeCallback: ResizeCallbackWithRef) => {\n const container = React.useRef<HTMLElement | null>(null);\n // the handler for resize observer\n const handleResize = debounce((entries: ResizeObserverEntry[], observer: ResizeObserver) => {\n resizeCallback(entries, observer, container);\n });\n\n // Keep the reference of ResizeObserver in the state, as it should live through renders\n const [resizeObserver, setResizeObserver] = React.useState(() =>\n canUseDOM() ? new ResizeObserver(handleResize) : undefined,\n );\n\n React.useEffect(() => {\n // Update our state when resizeCallback changes\n resizeObserver?.disconnect();\n setResizeObserver(canUseDOM() ? new ResizeObserver(handleResize) : undefined);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [resizeCallback]);\n\n React.useEffect(() => {\n return () => {\n resizeObserver?.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const scrollRef = React.useCallback(\n (instance: HTMLElement | HTMLDivElement | null) => {\n if (container.current !== instance) {\n if (container.current) {\n resizeObserver?.unobserve(container.current);\n }\n\n container.current = instance;\n if (container.current) {\n resizeObserver?.observe(container.current);\n }\n }\n },\n [resizeObserver],\n );\n\n return scrollRef;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,QAAQ,QAAQ;AACzB,SAASC,SAAS,QAAQ;AAG1B;;;AAGA,OAAO,MAAMC,6BAAA,GAAiCC,cAAA,IAA0C;EACtF,MAAMC,SAAA,GAAYL,KAAA,CAAMM,MAAM,CAAqB,IAAI;EACvD;EACA,MAAMC,YAAA,GAAeN,QAAA,CAAS,CAACO,OAAA,EAAgCC,QAAA,KAA6B;IAC1FL,cAAA,CAAeI,OAAA,EAASC,QAAA,EAAUJ,SAAA;EACpC;EAEA;EACA,MAAM,CAACK,cAAA,EAAgBC,iBAAA,CAAkB,GAAGX,KAAA,CAAMY,QAAQ,CAAC,MACzDV,SAAA,KAAc,IAAIW,cAAA,CAAeN,YAAA,IAAgBO,SAAS;EAG5Dd,KAAA,CAAMe,SAAS,CAAC,MAAM;IACpB;IACAL,cAAA,aAAAA,cAAA,uBAAAA,cAAA,CAAgBM,UAAU;IAC1BL,iBAAA,CAAkBT,SAAA,KAAc,IAAIW,cAAA,CAAeN,YAAA,IAAgBO,SAAS;IAC5E;EACF,GAAG,CAACV,cAAA,CAAe;EAEnBJ,KAAA,CAAMe,SAAS,CAAC,MAAM;IACpB,OAAO,MAAM;MACXL,cAAA,aAAAA,cAAA,uBAAAA,cAAA,CAAgBM,UAAU;IAC5B;IACA;EACF,GAAG,EAAE;EAEL,MAAMC,SAAA,GAAYjB,KAAA,CAAMkB,WAAW,CAChCC,QAAA,IAAkD;IACjD,IAAId,SAAA,CAAUe,OAAO,KAAKD,QAAA,EAAU;MAClC,IAAId,SAAA,CAAUe,OAAO,EAAE;QACrBV,cAAA,aAAAA,cAAA,uBAAAA,cAAA,CAAgBW,SAAS,CAAChB,SAAA,CAAUe,OAAO;MAC7C;MAEAf,SAAA,CAAUe,OAAO,GAAGD,QAAA;MACpB,IAAId,SAAA,CAAUe,OAAO,EAAE;QACrBV,cAAA,aAAAA,cAAA,uBAAAA,cAAA,CAAgBY,OAAO,CAACjB,SAAA,CAAUe,OAAO;MAC3C;IACF;EACF,GACA,CAACV,cAAA,CAAe;EAGlB,OAAOO,SAAA;AACT"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { debounce } from '../utilities/debounce';
|
|
2
|
+
import { useResizeObserverRef_unstable } from './useResizeObserverRef';
|
|
4
3
|
/**
|
|
5
4
|
* React hook that measures virtualized space based on a static size to ensure optimized virtualization length.
|
|
6
5
|
*/
|
|
@@ -19,13 +18,11 @@ export const useStaticVirtualizerMeasure = virtualizerProps => {
|
|
|
19
18
|
bufferItems,
|
|
20
19
|
bufferSize
|
|
21
20
|
} = state;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const resizeCallback = () => {
|
|
25
|
-
if (!container.current) {
|
|
21
|
+
const resizeCallback = React.useCallback((_entries, _observer, scrollRef) => {
|
|
22
|
+
if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
26
23
|
return;
|
|
27
24
|
}
|
|
28
|
-
const containerSize = direction === 'vertical' ?
|
|
25
|
+
const containerSize = direction === 'vertical' ? scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.getBoundingClientRect().height : scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.getBoundingClientRect().width;
|
|
29
26
|
/*
|
|
30
27
|
* Number of items required to cover viewport.
|
|
31
28
|
*/
|
|
@@ -44,28 +41,8 @@ export const useStaticVirtualizerMeasure = virtualizerProps => {
|
|
|
44
41
|
bufferItems: newBufferItems,
|
|
45
42
|
bufferSize: newBufferSize
|
|
46
43
|
});
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const handleResize = debounce(resizeCallback);
|
|
50
|
-
// Keep the reference of ResizeObserver in the state, as it should live through renders
|
|
51
|
-
const [resizeObserver] = React.useState(canUseDOM() ? new ResizeObserver(handleResize) : undefined);
|
|
52
|
-
React.useEffect(() => {
|
|
53
|
-
return () => {
|
|
54
|
-
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
|
|
55
|
-
};
|
|
56
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
-
}, []);
|
|
58
|
-
const scrollRef = React.useCallback(el => {
|
|
59
|
-
if (container.current !== el) {
|
|
60
|
-
if (container.current) {
|
|
61
|
-
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.unobserve(container.current);
|
|
62
|
-
}
|
|
63
|
-
container.current = el;
|
|
64
|
-
if (container.current) {
|
|
65
|
-
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.observe(container.current);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}, [resizeObserver]);
|
|
44
|
+
}, [defaultItemSize, direction]);
|
|
45
|
+
const scrollRef = useResizeObserverRef_unstable(resizeCallback);
|
|
69
46
|
return {
|
|
70
47
|
virtualizerLength,
|
|
71
48
|
bufferItems,
|