@fluentui/react-virtualizer 9.0.0-alpha.78 → 9.0.0-alpha.79
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 +13 -2
- package/lib/components/Virtualizer/useVirtualizer.js +3 -1
- package/lib/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizerStyles.styles.js.map +1 -1
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js.map +1 -1
- package/lib/hooks/hooks.types.js.map +1 -1
- package/lib/hooks/useDynamicVirtualizerMeasure.js +3 -1
- package/lib/hooks/useDynamicVirtualizerMeasure.js.map +1 -1
- package/lib/hooks/useIntersectionObserver.js +15 -11
- package/lib/hooks/useIntersectionObserver.js.map +1 -1
- package/lib/hooks/useMutationObserver.js +11 -2
- package/lib/hooks/useMutationObserver.js.map +1 -1
- package/lib/hooks/useResizeObserverRef.js +2 -0
- package/lib/hooks/useResizeObserverRef.js.map +1 -1
- package/lib/hooks/useVirtualizerMeasure.js +3 -1
- package/lib/hooks/useVirtualizerMeasure.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js +2 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js +2 -1
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js.map +1 -1
- package/lib-commonjs/hooks/useIntersectionObserver.js +15 -11
- package/lib-commonjs/hooks/useIntersectionObserver.js.map +1 -1
- package/lib-commonjs/hooks/useMutationObserver.js +11 -2
- package/lib-commonjs/hooks/useMutationObserver.js.map +1 -1
- package/lib-commonjs/hooks/useResizeObserverRef.js +2 -0
- package/lib-commonjs/hooks/useResizeObserverRef.js.map +1 -1
- package/lib-commonjs/hooks/useVirtualizerMeasure.js +2 -1
- package/lib-commonjs/hooks/useVirtualizerMeasure.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-virtualizer
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 06 Jun 2024 15:22:26 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-alpha.79](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.79)
|
|
8
|
+
|
|
9
|
+
Thu, 06 Jun 2024 15:22:26 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.78..@fluentui/react-virtualizer_v9.0.0-alpha.79)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- fix: update internal function to optionally use global Fluent context. ([PR #30967](https://github.com/microsoft/fluentui/pull/30967) by seanmonahan@microsoft.com)
|
|
15
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.39 ([PR #31586](https://github.com/microsoft/fluentui/pull/31586) by beachball)
|
|
16
|
+
- Bump @fluentui/react-utilities to v9.18.10 ([PR #31586](https://github.com/microsoft/fluentui/pull/31586) by beachball)
|
|
17
|
+
|
|
7
18
|
## [9.0.0-alpha.78](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.78)
|
|
8
19
|
|
|
9
|
-
Mon, 20 May 2024 12:
|
|
20
|
+
Mon, 20 May 2024 12:45:09 GMT
|
|
10
21
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.77..@fluentui/react-virtualizer_v9.0.0-alpha.78)
|
|
11
22
|
|
|
12
23
|
### Changes
|
|
@@ -88,7 +88,9 @@ export function useVirtualizer_unstable(props) {
|
|
|
88
88
|
setActualIndex(index);
|
|
89
89
|
};
|
|
90
90
|
// Observe intersections of virtualized components
|
|
91
|
-
const { setObserverList } = useIntersectionObserver(
|
|
91
|
+
const { setObserverList } = useIntersectionObserver(// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
92
|
+
// eslint-disable-next-line no-restricted-globals
|
|
93
|
+
(entries, observer)=>{
|
|
92
94
|
/* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {
|
|
93
95
|
if (actualIndex !== 0) {
|
|
94
96
|
batchUpdateNewIndex(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useVirtualizer.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { VirtualizerProps, VirtualizerState } from './Virtualizer.types';\n\nimport { useEffect, useRef, useCallback, useReducer, useImperativeHandle, useState } from 'react';\nimport { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { flushSync } from 'react-dom';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { slot, useTimeout } from '@fluentui/react-utilities';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n const {\n itemSize,\n numItems,\n virtualizerLength,\n children: renderChild,\n getItemSize,\n bufferItems = Math.round(virtualizerLength / 4.0),\n bufferSize = Math.floor(bufferItems / 2.0) * itemSize,\n scrollViewRef,\n axis = 'vertical',\n reversed = false,\n virtualizerContext,\n onRenderedFlaggedIndex,\n imperativeVirtualizerRef,\n } = props;\n\n /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/\n const _virtualizerContext = useVirtualizerContextState_unstable(virtualizerContext);\n\n // We use this ref as a constant source to access the virtualizer's state imperatively\n const actualIndexRef = useRef<number>(_virtualizerContext.contextIndex);\n if (actualIndexRef.current !== _virtualizerContext.contextIndex) {\n actualIndexRef.current = _virtualizerContext.contextIndex;\n }\n const flaggedIndex = useRef<number | null>(null);\n\n const actualIndex = _virtualizerContext.contextIndex;\n const setActualIndex = _virtualizerContext.setContextIndex;\n\n // Store ref to before padding element\n const beforeElementRef = useRef<Element | null>(null);\n\n // Store ref to before padding element\n const afterElementRef = useRef<Element | null>(null);\n\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */\n const childProgressiveSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n // The internal tracking REF for child array (updates often).\n const childArray = useRef<ReactNode[]>(new Array(virtualizerLength));\n\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(() => ({}), {})[1];\n\n const horizontal = axis === 'horizontal';\n\n const populateSizeArrays = () => {\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array<number>(numItems);\n }\n\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array<number>(numItems);\n }\n\n for (let index = 0; index < numItems; index++) {\n childSizes.current[index] = getItemSize(index);\n if (index === 0) {\n childProgressiveSizes.current[index] = childSizes.current[index];\n } else {\n childProgressiveSizes.current[index] = childProgressiveSizes.current[index - 1] + childSizes.current[index];\n }\n }\n };\n\n const [isScrolling, setIsScrolling] = useState<boolean>(false);\n const [setScrollTimer, clearScrollTimer] = useTimeout();\n const scrollCounter = useRef<number>(0);\n\n const initializeScrollingTimer = useCallback(() => {\n /*\n * This can be considered the 'velocity' required to start 'isScrolling'\n * INIT_SCROLL_FLAG_REQ: Number of renders required to activate isScrolling\n * INIT_SCROLL_FLAG_DELAY: Amount of time (ms) before current number of renders is reset\n * - Maybe we should let users customize these in the future.\n */\n const INIT_SCROLL_FLAG_REQ = 10;\n const INIT_SCROLL_FLAG_DELAY = 100;\n\n scrollCounter.current++;\n if (scrollCounter.current >= INIT_SCROLL_FLAG_REQ) {\n setIsScrolling(true);\n }\n clearScrollTimer();\n setScrollTimer(() => {\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n }, [clearScrollTimer, setScrollTimer]);\n\n useEffect(() => {\n initializeScrollingTimer();\n }, [actualIndex, initializeScrollingTimer]);\n\n const batchUpdateNewIndex = (index: number) => {\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\n\n // Set before 'setActualIndex' call\n // If it changes before render, or injected via context, re-render will update ref.\n actualIndexRef.current = index;\n\n // State setters\n setActualIndex(index);\n };\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (actualIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n\n /* IO initiates this function when needed (bookend entering view) */\n let measurementPos = 0;\n let bufferCount = bufferItems;\n\n // Grab latest entry that is intersecting\n const latestEntry =\n entries.length === 1\n ? entries[0]\n : entries\n .sort((entry1, entry2) => entry2.time - entry1.time)\n .find(entry => {\n return entry.intersectionRatio > 0;\n });\n\n if (!latestEntry) {\n // If we don't find an intersecting area, ignore for now.\n return;\n }\n\n if (latestEntry.target === afterElementRef.current) {\n // We need to inverse the buffer count\n bufferCount = virtualizerLength - bufferItems;\n measurementPos = reversed ? calculateAfter() : calculateTotalSize() - calculateAfter();\n if (!horizontal) {\n if (reversed) {\n // Scrolling 'up' and hit the after element below\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' and hit the after element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (reversed) {\n // Scrolling 'left' and hit the after element\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'right' and hit the after element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n measurementPos = reversed ? calculateTotalSize() - calculateBefore() : calculateBefore();\n if (!horizontal) {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' in reverse order and hit the before element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'left' and hit before element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n }\n\n if (reversed) {\n // We're reversed, up is down, left is right, invert the scroll measure.\n measurementPos = Math.max(calculateTotalSize() - Math.abs(measurementPos), 0);\n }\n\n // For now lets use hardcoded size to assess current element to paginate on\n const startIndex = getIndexFromScrollPosition(measurementPos);\n const bufferedIndex = Math.max(startIndex - bufferCount, 0);\n\n // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n\n if (actualIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n flushSync(() => {\n batchUpdateNewIndex(newStartIndex);\n });\n }\n },\n {\n root: scrollViewRef ? scrollViewRef?.current : null,\n rootMargin: '0px',\n threshold: 0,\n },\n );\n\n const findIndexRecursive = (scrollPos: number, lowIndex: number, highIndex: number): number => {\n if (lowIndex > highIndex) {\n // We shouldn't get here - but no-op the index if we do.\n return actualIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */\n return midpoint;\n }\n\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n\n const getIndexFromSizeArray = (scrollPos: number): number => {\n /* Quick searches our progressive height array */\n if (\n scrollPos === 0 ||\n childProgressiveSizes.current.length === 0 ||\n scrollPos <= childProgressiveSizes.current[0]\n ) {\n // Check start\n return 0;\n }\n\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n\n const getIndexFromScrollPosition = (scrollPos: number) => {\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n\n return getIndexFromSizeArray(scrollPos);\n };\n\n const calculateTotalSize = useCallback(() => {\n if (!getItemSize) {\n return itemSize * numItems;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n }, [getItemSize, itemSize, numItems]);\n\n const calculateBefore = useCallback(() => {\n const currentIndex = Math.min(actualIndex, numItems - 1);\n\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return currentIndex * itemSize;\n }\n\n if (currentIndex <= 0) {\n return 0;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[currentIndex - 1];\n }, [actualIndex, getItemSize, itemSize, numItems]);\n\n const calculateAfter = useCallback(() => {\n if (numItems === 0 || actualIndex + virtualizerLength >= numItems) {\n return 0;\n }\n\n const lastItemIndex = Math.min(actualIndex + virtualizerLength, numItems);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex;\n return remainingItems * itemSize;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];\n }, [actualIndex, getItemSize, itemSize, numItems, virtualizerLength]);\n\n const updateChildRows = useCallback(\n (newIndex: number) => {\n if (numItems === 0) {\n /* Nothing to virtualize */\n return;\n }\n\n /*\n We reset the array every time to ensure children are re-rendered\n This function should only be called when update is nessecary\n */\n childArray.current = new Array(virtualizerLength);\n const _actualIndex = Math.max(newIndex, 0);\n const end = Math.min(_actualIndex + virtualizerLength, numItems);\n for (let i = _actualIndex; i < end; i++) {\n childArray.current[i - _actualIndex] = renderChild(i, isScrolling);\n }\n },\n [isScrolling, numItems, renderChild, virtualizerLength],\n );\n\n const setBeforeRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n\n newList.push(beforeElementRef.current);\n\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n\n // Ensure we update array if before element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const setAfterRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n\n newList.push(afterElementRef.current);\n\n // Ensure we update array if after element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const updateCurrentItemSizes = (newIndex: number) => {\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n\n let didUpdate = false;\n for (let i = startIndex; i < endIndex; i++) {\n const newSize = getItemSize(i);\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n\n if (didUpdate) {\n // Update our progressive size array\n for (let i = startIndex; i < numItems; i++) {\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n };\n\n // Initialize the size array before first render.\n const hasInitialized = useRef<boolean>(false);\n const initializeSizeArray = () => {\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n\n useImperativeHandle(\n imperativeVirtualizerRef,\n () => {\n return {\n progressiveSizes: childProgressiveSizes,\n nodeSizes: childSizes,\n setFlaggedIndex: (index: number | null) => (flaggedIndex.current = index),\n currentIndex: actualIndexRef,\n };\n },\n [childProgressiveSizes, childSizes],\n );\n\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(() => {\n if (actualIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // If the user passes in an updated renderChild function - update current children\n useEffect(() => {\n if (actualIndex >= 0) {\n updateChildRows(actualIndex);\n forceUpdate();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild, updateChildRows]);\n\n useEffect(() => {\n // Ensure we repopulate if getItemSize callback changes\n populateSizeArrays();\n\n // We only run this effect on getItemSize change (recalc dynamic sizes)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getItemSize]);\n\n // Effect to check flag index on updates\n useEffect(() => {\n if (!onRenderedFlaggedIndex || flaggedIndex.current === null) {\n return;\n }\n if (actualIndex <= flaggedIndex.current && actualIndex + virtualizerLength >= flaggedIndex.current) {\n onRenderedFlaggedIndex(flaggedIndex.current);\n flaggedIndex.current = null;\n }\n }, [actualIndex, onRenderedFlaggedIndex, virtualizerLength]);\n\n // Ensure we have run through and updated the whole size list array at least once.\n initializeSizeArray();\n\n if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {\n // Child length mismatch, repopulate size arrays.\n populateSizeArrays();\n }\n\n // Ensure we recalc if virtualizer length changes\n const maxCompare = Math.min(virtualizerLength, numItems);\n if (childArray.current.length !== maxCompare && actualIndex + childArray.current.length < numItems) {\n updateChildRows(actualIndex);\n }\n\n const isFullyInitialized = hasInitialized.current && actualIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div',\n },\n virtualizedChildren: childArray.current,\n before: slot.always(props.before, {\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n after: slot.always(props.after, {\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeContainer: slot.always(props.beforeContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n afterContainer: slot.always(props.afterContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed,\n childSizes,\n childProgressiveSizes,\n };\n}\n"],"names":["useEffect","useRef","useCallback","useReducer","useImperativeHandle","useState","useIntersectionObserver","flushSync","useVirtualizerContextState_unstable","slot","useTimeout","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","scrollViewRef","axis","reversed","virtualizerContext","onRenderedFlaggedIndex","imperativeVirtualizerRef","_virtualizerContext","actualIndexRef","contextIndex","current","flaggedIndex","actualIndex","setActualIndex","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","horizontal","populateSizeArrays","length","index","isScrolling","setIsScrolling","setScrollTimer","clearScrollTimer","scrollCounter","initializeScrollingTimer","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","entries","observer","measurementPos","bufferCount","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","target","calculateAfter","calculateTotalSize","abs","boundingClientRect","bottom","top","right","left","calculateBefore","max","startIndex","getIndexFromScrollPosition","bufferedIndex","maxIndex","newStartIndex","min","root","rootMargin","threshold","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","currentIndex","lastItemIndex","remainingItems","newIndex","_actualIndex","end","i","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","progressiveSizes","nodeSizes","setFlaggedIndex","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","always","defaultProps","ref","role","elementType","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"mappings":"AAGA,SAASA,SAAS,EAAEC,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAEC,mBAAmB,EAAEC,QAAQ,QAAQ,QAAQ;AAClG,SAASC,uBAAuB,QAAQ,sCAAsC;AAC9E,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,mCAAmC,QAAQ,kBAAkB;AACtE,SAASC,IAAI,EAAEC,UAAU,QAAQ,4BAA4B;AAE7D,OAAO,SAASC,wBAAwBC,KAAuB;IAC7D,MAAM,EACJC,QAAQ,EACRC,QAAQ,EACRC,iBAAiB,EACjBC,UAAUC,WAAW,EACrBC,WAAW,EACXC,cAAcC,KAAKC,KAAK,CAACN,oBAAoB,IAAI,EACjDO,aAAaF,KAAKG,KAAK,CAACJ,cAAc,OAAON,QAAQ,EACrDW,aAAa,EACbC,OAAO,UAAU,EACjBC,WAAW,KAAK,EAChBC,kBAAkB,EAClBC,sBAAsB,EACtBC,wBAAwB,EACzB,GAAGjB;IAEJ,iHAAiH,GACjH,MAAMkB,sBAAsBtB,oCAAoCmB;IAEhE,sFAAsF;IACtF,MAAMI,iBAAiB9B,OAAe6B,oBAAoBE,YAAY;IACtE,IAAID,eAAeE,OAAO,KAAKH,oBAAoBE,YAAY,EAAE;QAC/DD,eAAeE,OAAO,GAAGH,oBAAoBE,YAAY;IAC3D;IACA,MAAME,eAAejC,OAAsB;IAE3C,MAAMkC,cAAcL,oBAAoBE,YAAY;IACpD,MAAMI,iBAAiBN,oBAAoBO,eAA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,MAAM;YACR;YACAC,aAAa;QACf;QACAP,iBAAiBzH,KAAK4H,MAAM,CAACzH,MAAMsH,eAAe,EAAE;YAClDI,cAAc;gBACZE,MAAM;YACR;YACAC,aAAa;QACf;QACAN,gBAAgB1H,KAAK4H,MAAM,CAACzH,MAAMuH,cAAc,EAAE;YAChDG,cAAc;gBACZE,MAAM;YACR;YACAC,aAAa;QACf;QACAC,oBAAoBZ,qBAAqB5C,oBAAoB;QAC7DyD,mBAAmBb,qBAAqBpD,mBAAmB;QAC3DkE,wBAAwBd,qBAAqBnD,uBAAuB5D,oBAAoBF;QACxFgI,uBAAuB1G;QACvBV;QACAH;QACAI;QACAc;QACAE;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["useVirtualizer.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { VirtualizerProps, VirtualizerState } from './Virtualizer.types';\n\nimport { useEffect, useRef, useCallback, useReducer, useImperativeHandle, useState } from 'react';\nimport { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { flushSync } from 'react-dom';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { slot, useTimeout } from '@fluentui/react-utilities';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n const {\n itemSize,\n numItems,\n virtualizerLength,\n children: renderChild,\n getItemSize,\n bufferItems = Math.round(virtualizerLength / 4.0),\n bufferSize = Math.floor(bufferItems / 2.0) * itemSize,\n scrollViewRef,\n axis = 'vertical',\n reversed = false,\n virtualizerContext,\n onRenderedFlaggedIndex,\n imperativeVirtualizerRef,\n } = props;\n\n /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/\n const _virtualizerContext = useVirtualizerContextState_unstable(virtualizerContext);\n\n // We use this ref as a constant source to access the virtualizer's state imperatively\n const actualIndexRef = useRef<number>(_virtualizerContext.contextIndex);\n if (actualIndexRef.current !== _virtualizerContext.contextIndex) {\n actualIndexRef.current = _virtualizerContext.contextIndex;\n }\n const flaggedIndex = useRef<number | null>(null);\n\n const actualIndex = _virtualizerContext.contextIndex;\n const setActualIndex = _virtualizerContext.setContextIndex;\n\n // Store ref to before padding element\n const beforeElementRef = useRef<Element | null>(null);\n\n // Store ref to before padding element\n const afterElementRef = useRef<Element | null>(null);\n\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */\n const childProgressiveSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n // The internal tracking REF for child array (updates often).\n const childArray = useRef<ReactNode[]>(new Array(virtualizerLength));\n\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(() => ({}), {})[1];\n\n const horizontal = axis === 'horizontal';\n\n const populateSizeArrays = () => {\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array<number>(numItems);\n }\n\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array<number>(numItems);\n }\n\n for (let index = 0; index < numItems; index++) {\n childSizes.current[index] = getItemSize(index);\n if (index === 0) {\n childProgressiveSizes.current[index] = childSizes.current[index];\n } else {\n childProgressiveSizes.current[index] = childProgressiveSizes.current[index - 1] + childSizes.current[index];\n }\n }\n };\n\n const [isScrolling, setIsScrolling] = useState<boolean>(false);\n const [setScrollTimer, clearScrollTimer] = useTimeout();\n const scrollCounter = useRef<number>(0);\n\n const initializeScrollingTimer = useCallback(() => {\n /*\n * This can be considered the 'velocity' required to start 'isScrolling'\n * INIT_SCROLL_FLAG_REQ: Number of renders required to activate isScrolling\n * INIT_SCROLL_FLAG_DELAY: Amount of time (ms) before current number of renders is reset\n * - Maybe we should let users customize these in the future.\n */\n const INIT_SCROLL_FLAG_REQ = 10;\n const INIT_SCROLL_FLAG_DELAY = 100;\n\n scrollCounter.current++;\n if (scrollCounter.current >= INIT_SCROLL_FLAG_REQ) {\n setIsScrolling(true);\n }\n clearScrollTimer();\n setScrollTimer(() => {\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n }, [clearScrollTimer, setScrollTimer]);\n\n useEffect(() => {\n initializeScrollingTimer();\n }, [actualIndex, initializeScrollingTimer]);\n\n const batchUpdateNewIndex = (index: number) => {\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\n\n // Set before 'setActualIndex' call\n // If it changes before render, or injected via context, re-render will update ref.\n actualIndexRef.current = index;\n\n // State setters\n setActualIndex(index);\n };\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n // eslint-disable-next-line no-restricted-globals\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (actualIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n\n /* IO initiates this function when needed (bookend entering view) */\n let measurementPos = 0;\n let bufferCount = bufferItems;\n\n // Grab latest entry that is intersecting\n const latestEntry =\n entries.length === 1\n ? entries[0]\n : entries\n .sort((entry1, entry2) => entry2.time - entry1.time)\n .find(entry => {\n return entry.intersectionRatio > 0;\n });\n\n if (!latestEntry) {\n // If we don't find an intersecting area, ignore for now.\n return;\n }\n\n if (latestEntry.target === afterElementRef.current) {\n // We need to inverse the buffer count\n bufferCount = virtualizerLength - bufferItems;\n measurementPos = reversed ? calculateAfter() : calculateTotalSize() - calculateAfter();\n if (!horizontal) {\n if (reversed) {\n // Scrolling 'up' and hit the after element below\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' and hit the after element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (reversed) {\n // Scrolling 'left' and hit the after element\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'right' and hit the after element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n measurementPos = reversed ? calculateTotalSize() - calculateBefore() : calculateBefore();\n if (!horizontal) {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' in reverse order and hit the before element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'left' and hit before element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n }\n\n if (reversed) {\n // We're reversed, up is down, left is right, invert the scroll measure.\n measurementPos = Math.max(calculateTotalSize() - Math.abs(measurementPos), 0);\n }\n\n // For now lets use hardcoded size to assess current element to paginate on\n const startIndex = getIndexFromScrollPosition(measurementPos);\n const bufferedIndex = Math.max(startIndex - bufferCount, 0);\n\n // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n\n if (actualIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n flushSync(() => {\n batchUpdateNewIndex(newStartIndex);\n });\n }\n },\n {\n root: scrollViewRef ? scrollViewRef?.current : null,\n rootMargin: '0px',\n threshold: 0,\n },\n );\n\n const findIndexRecursive = (scrollPos: number, lowIndex: number, highIndex: number): number => {\n if (lowIndex > highIndex) {\n // We shouldn't get here - but no-op the index if we do.\n return actualIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */\n return midpoint;\n }\n\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n\n const getIndexFromSizeArray = (scrollPos: number): number => {\n /* Quick searches our progressive height array */\n if (\n scrollPos === 0 ||\n childProgressiveSizes.current.length === 0 ||\n scrollPos <= childProgressiveSizes.current[0]\n ) {\n // Check start\n return 0;\n }\n\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n\n const getIndexFromScrollPosition = (scrollPos: number) => {\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n\n return getIndexFromSizeArray(scrollPos);\n };\n\n const calculateTotalSize = useCallback(() => {\n if (!getItemSize) {\n return itemSize * numItems;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n }, [getItemSize, itemSize, numItems]);\n\n const calculateBefore = useCallback(() => {\n const currentIndex = Math.min(actualIndex, numItems - 1);\n\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return currentIndex * itemSize;\n }\n\n if (currentIndex <= 0) {\n return 0;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[currentIndex - 1];\n }, [actualIndex, getItemSize, itemSize, numItems]);\n\n const calculateAfter = useCallback(() => {\n if (numItems === 0 || actualIndex + virtualizerLength >= numItems) {\n return 0;\n }\n\n const lastItemIndex = Math.min(actualIndex + virtualizerLength, numItems);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex;\n return remainingItems * itemSize;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];\n }, [actualIndex, getItemSize, itemSize, numItems, virtualizerLength]);\n\n const updateChildRows = useCallback(\n (newIndex: number) => {\n if (numItems === 0) {\n /* Nothing to virtualize */\n return;\n }\n\n /*\n We reset the array every time to ensure children are re-rendered\n This function should only be called when update is nessecary\n */\n childArray.current = new Array(virtualizerLength);\n const _actualIndex = Math.max(newIndex, 0);\n const end = Math.min(_actualIndex + virtualizerLength, numItems);\n for (let i = _actualIndex; i < end; i++) {\n childArray.current[i - _actualIndex] = renderChild(i, isScrolling);\n }\n },\n [isScrolling, numItems, renderChild, virtualizerLength],\n );\n\n const setBeforeRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n\n newList.push(beforeElementRef.current);\n\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n\n // Ensure we update array if before element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const setAfterRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n\n newList.push(afterElementRef.current);\n\n // Ensure we update array if after element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const updateCurrentItemSizes = (newIndex: number) => {\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n\n let didUpdate = false;\n for (let i = startIndex; i < endIndex; i++) {\n const newSize = getItemSize(i);\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n\n if (didUpdate) {\n // Update our progressive size array\n for (let i = startIndex; i < numItems; i++) {\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n };\n\n // Initialize the size array before first render.\n const hasInitialized = useRef<boolean>(false);\n const initializeSizeArray = () => {\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n\n useImperativeHandle(\n imperativeVirtualizerRef,\n () => {\n return {\n progressiveSizes: childProgressiveSizes,\n nodeSizes: childSizes,\n setFlaggedIndex: (index: number | null) => (flaggedIndex.current = index),\n currentIndex: actualIndexRef,\n };\n },\n [childProgressiveSizes, childSizes],\n );\n\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(() => {\n if (actualIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // If the user passes in an updated renderChild function - update current children\n useEffect(() => {\n if (actualIndex >= 0) {\n updateChildRows(actualIndex);\n forceUpdate();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild, updateChildRows]);\n\n useEffect(() => {\n // Ensure we repopulate if getItemSize callback changes\n populateSizeArrays();\n\n // We only run this effect on getItemSize change (recalc dynamic sizes)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getItemSize]);\n\n // Effect to check flag index on updates\n useEffect(() => {\n if (!onRenderedFlaggedIndex || flaggedIndex.current === null) {\n return;\n }\n if (actualIndex <= flaggedIndex.current && actualIndex + virtualizerLength >= flaggedIndex.current) {\n onRenderedFlaggedIndex(flaggedIndex.current);\n flaggedIndex.current = null;\n }\n }, [actualIndex, onRenderedFlaggedIndex, virtualizerLength]);\n\n // Ensure we have run through and updated the whole size list array at least once.\n initializeSizeArray();\n\n if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {\n // Child length mismatch, repopulate size arrays.\n populateSizeArrays();\n }\n\n // Ensure we recalc if virtualizer length changes\n const maxCompare = Math.min(virtualizerLength, numItems);\n if (childArray.current.length !== maxCompare && actualIndex + childArray.current.length < numItems) {\n updateChildRows(actualIndex);\n }\n\n const isFullyInitialized = hasInitialized.current && actualIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div',\n },\n virtualizedChildren: childArray.current,\n before: slot.always(props.before, {\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n after: slot.always(props.after, {\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeContainer: slot.always(props.beforeContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n afterContainer: slot.always(props.afterContainer, {\n defaultProps: {\n role: 'none',\n },\n elementType: 'div',\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed,\n childSizes,\n childProgressiveSizes,\n };\n}\n"],"names":["useEffect","useRef","useCallback","useReducer","useImperativeHandle","useState","useIntersectionObserver","flushSync","useVirtualizerContextState_unstable","slot","useTimeout","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","scrollViewRef","axis","reversed","virtualizerContext","onRenderedFlaggedIndex","imperativeVirtualizerRef","_virtualizerContext","actualIndexRef","contextIndex","current","flaggedIndex","actualIndex","setActualIndex","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","horizontal","populateSizeArrays","length","index","isScrolling","setIsScrolling","setScrollTimer","clearScrollTimer","scrollCounter","initializeScrollingTimer","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","entries","observer","measurementPos","bufferCount","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","target","calculateAfter","calculateTotalSize","abs","boundingClientRect","bottom","top","right","left","calculateBefore","max","startIndex","getIndexFromScrollPosition","bufferedIndex","maxIndex","newStartIndex","min","root","rootMargin","threshold","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","currentIndex","lastItemIndex","remainingItems","newIndex","_actualIndex","end","i","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","progressiveSizes","nodeSizes","setFlaggedIndex","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","always","defaultProps","ref","role","elementType","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"mappings":"AAGA,SAASA,SAAS,EAAEC,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAEC,mBAAmB,EAAEC,QAAQ,QAAQ,QAAQ;AAClG,SAASC,uBAAuB,QAAQ,sCAAsC;AAC9E,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,mCAAmC,QAAQ,kBAAkB;AACtE,SAASC,IAAI,EAAEC,UAAU,QAAQ,4BAA4B;AAE7D,OAAO,SAASC,wBAAwBC,KAAuB;IAC7D,MAAM,EACJC,QAAQ,EACRC,QAAQ,EACRC,iBAAiB,EACjBC,UAAUC,WAAW,EACrBC,WAAW,EACXC,cAAcC,KAAKC,KAAK,CAACN,oBAAoB,IAAI,EACjDO,aAAaF,KAAKG,KAAK,CAACJ,cAAc,OAAON,QAAQ,EACrDW,aAAa,EACbC,OAAO,UAAU,EACjBC,WAAW,KAAK,EAChBC,kBAAkB,EAClBC,sBAAsB,EACtBC,wBAAwB,EACzB,GAAGjB;IAEJ,iHAAiH,GACjH,MAAMkB,sBAAsBtB,oCAAoCmB;IAEhE,sFAAsF;IACtF,MAAMI,iBAAiB9B,OAAe6B,oBAAoBE,YAAY;IACtE,IAAID,eAAeE,OAAO,KAAKH,oBAAoBE,YAAY,EAA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ACzH,MAAMoH,MAAM,EAAE;YAChCM,cAAc;gBACZC,KAAKxB;gBACLyB,MAAM;YACR;YACAC,aAAa;QACf;QACAR,OAAOxH,KAAK4H,MAAM,CAACzH,MAAMqH,KAAK,EAAE;YAC9BK,cAAc;gBACZC,KAAKpB;gBACLqB,MAAM;YACR;YACAC,aAAa;QACf;QACAP,iBAAiBzH,KAAK4H,MAAM,CAACzH,MAAMsH,eAAe,EAAE;YAClDI,cAAc;gBACZE,MAAM;YACR;YACAC,aAAa;QACf;QACAN,gBAAgB1H,KAAK4H,MAAM,CAACzH,MAAMuH,cAAc,EAAE;YAChDG,cAAc;gBACZE,MAAM;YACR;YACAC,aAAa;QACf;QACAC,oBAAoBZ,qBAAqB5C,oBAAoB;QAC7DyD,mBAAmBb,qBAAqBpD,mBAAmB;QAC3DkE,wBAAwBd,qBAAqBnD,uBAAuB5D,oBAAoBF;QACxFgI,uBAAuB1G;QACvBV;QACAH;QACAI;QACAc;QACAE;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__styles","mergeClasses","virtualizerClassName","virtualizerClassNames","before","beforeContainer","after","afterContainer","useStyles","base","mc9l5x","Bkecrkj","relative","qhf8xq","horizontal","sshi5w","vertical","Bf4jedk","d","useVirtualizerStyles_unstable","state","styles","reversed","axis","beforeBufferHeight","afterBufferHeight","bufferSize","className","beforeHeightPx","afterHeightPx","beforeBufferHeightPx","afterBufferHeightPx","bufferPx","beforeBuffer","marginBottom","marginTop","marginRight","marginLeft","afterBuffer","style","height","width"],"sources":["useVirtualizerStyles.styles.js"],"sourcesContent":["import { makeStyles, mergeClasses } from '@griffel/react';\nconst virtualizerClassName = 'fui-Virtualizer';\nexport const virtualizerClassNames = {\n before: `${virtualizerClassName}__before`,\n beforeContainer: `${virtualizerClassName}__beforeContainer`,\n after: `${virtualizerClassName}__after`,\n afterContainer: `${virtualizerClassName}__afterContainer`\n};\nconst useStyles = makeStyles({\n base: {\n display: 'block',\n pointerEvents: 'none'\n },\n relative: {\n position: 'relative'\n },\n horizontal: {\n minHeight: '100%'\n },\n vertical: {\n minWidth: '100%'\n }\n});\n/**\n * Apply styling to the Virtualizer states\n */ export const useVirtualizerStyles_unstable = (state)=>{\n const styles = useStyles();\n const { reversed, axis, beforeBufferHeight, afterBufferHeight, bufferSize } = state;\n const horizontal = axis === 'horizontal';\n state.before.className = mergeClasses(virtualizerClassNames.before, styles.base, styles.relative, horizontal ? styles.horizontal : styles.vertical, state.before.className);\n state.after.className = mergeClasses(virtualizerClassNames.after, styles.base, styles.relative, horizontal ? styles.horizontal : styles.vertical, state.after.className);\n state.beforeContainer.className = mergeClasses(virtualizerClassNames.beforeContainer, styles.base, horizontal ? styles.horizontal : styles.vertical, state.beforeContainer.className);\n state.afterContainer.className = mergeClasses(virtualizerClassNames.afterContainer, styles.base, horizontal ? styles.horizontal : styles.vertical, state.afterContainer.className);\n const beforeHeightPx = beforeBufferHeight + 'px';\n const afterHeightPx = afterBufferHeight + 'px';\n const beforeBufferHeightPx = beforeBufferHeight + bufferSize + 'px';\n const afterBufferHeightPx = afterBufferHeight + bufferSize + 'px';\n const bufferPx = bufferSize + 'px';\n const beforeBuffer = {\n // Column\n ...!reversed && !horizontal && {\n marginBottom: `-${bufferPx}`\n },\n // Column-Reverse\n ...reversed && !horizontal && {\n marginTop: `-${bufferPx}`\n },\n // Row\n ...!reversed && horizontal && {\n marginRight: `-${bufferPx}`\n },\n // Row-Reverse\n ...reversed && horizontal && {\n marginLeft: `-${bufferPx}`\n }\n };\n const afterBuffer = {\n // Column\n ...!reversed && !horizontal && {\n marginTop: `-${bufferPx}`\n },\n // Column-Reverse\n ...reversed && !horizontal && {\n marginBottom: `-${bufferPx}`\n },\n // Row\n ...!reversed && horizontal && {\n marginLeft: `-${bufferPx}`\n },\n // Row-Reverse\n ...reversed && horizontal && {\n marginRight: `-${bufferPx}`\n }\n };\n state.before.style = {\n height: horizontal ? '100%' : beforeBufferHeightPx,\n width: horizontal ? beforeBufferHeightPx : '100%',\n ...beforeBuffer,\n ...state.before.style\n };\n state.beforeContainer.style = {\n height: horizontal ? 'auto' : beforeHeightPx,\n width: horizontal ? beforeHeightPx : 'auto',\n ...state.beforeContainer.style\n };\n state.after.style = {\n height: horizontal ? '100%' : afterBufferHeightPx,\n width: horizontal ? afterBufferHeightPx : '100%',\n ...afterBuffer,\n ...state.after.style\n };\n state.afterContainer.style = {\n height: horizontal ? 'auto' : afterHeightPx,\n width: horizontal ? afterHeightPx : 'auto',\n ...state.afterContainer.style\n };\n return state;\n};\n"],"mappings":"AAAA,SAAAA,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,MAAMC,oBAAoB,GAAG,iBAAiB;AAC9C,OAAO,MAAMC,qBAAqB,GAAG;EACjCC,MAAM,
|
|
1
|
+
{"version":3,"names":["__styles","mergeClasses","virtualizerClassName","virtualizerClassNames","before","beforeContainer","after","afterContainer","useStyles","base","mc9l5x","Bkecrkj","relative","qhf8xq","horizontal","sshi5w","vertical","Bf4jedk","d","useVirtualizerStyles_unstable","state","styles","reversed","axis","beforeBufferHeight","afterBufferHeight","bufferSize","className","beforeHeightPx","afterHeightPx","beforeBufferHeightPx","afterBufferHeightPx","bufferPx","beforeBuffer","marginBottom","marginTop","marginRight","marginLeft","afterBuffer","style","height","width"],"sources":["useVirtualizerStyles.styles.js"],"sourcesContent":["import { makeStyles, mergeClasses } from '@griffel/react';\nconst virtualizerClassName = 'fui-Virtualizer';\nexport const virtualizerClassNames = {\n before: `${virtualizerClassName}__before`,\n beforeContainer: `${virtualizerClassName}__beforeContainer`,\n after: `${virtualizerClassName}__after`,\n afterContainer: `${virtualizerClassName}__afterContainer`\n};\nconst useStyles = makeStyles({\n base: {\n display: 'block',\n pointerEvents: 'none'\n },\n relative: {\n position: 'relative'\n },\n horizontal: {\n minHeight: '100%'\n },\n vertical: {\n minWidth: '100%'\n }\n});\n/**\n * Apply styling to the Virtualizer states\n */ export const useVirtualizerStyles_unstable = (state)=>{\n const styles = useStyles();\n const { reversed, axis, beforeBufferHeight, afterBufferHeight, bufferSize } = state;\n const horizontal = axis === 'horizontal';\n state.before.className = mergeClasses(virtualizerClassNames.before, styles.base, styles.relative, horizontal ? styles.horizontal : styles.vertical, state.before.className);\n state.after.className = mergeClasses(virtualizerClassNames.after, styles.base, styles.relative, horizontal ? styles.horizontal : styles.vertical, state.after.className);\n state.beforeContainer.className = mergeClasses(virtualizerClassNames.beforeContainer, styles.base, horizontal ? styles.horizontal : styles.vertical, state.beforeContainer.className);\n state.afterContainer.className = mergeClasses(virtualizerClassNames.afterContainer, styles.base, horizontal ? styles.horizontal : styles.vertical, state.afterContainer.className);\n const beforeHeightPx = beforeBufferHeight + 'px';\n const afterHeightPx = afterBufferHeight + 'px';\n const beforeBufferHeightPx = beforeBufferHeight + bufferSize + 'px';\n const afterBufferHeightPx = afterBufferHeight + bufferSize + 'px';\n const bufferPx = bufferSize + 'px';\n const beforeBuffer = {\n // Column\n ...!reversed && !horizontal && {\n marginBottom: `-${bufferPx}`\n },\n // Column-Reverse\n ...reversed && !horizontal && {\n marginTop: `-${bufferPx}`\n },\n // Row\n ...!reversed && horizontal && {\n marginRight: `-${bufferPx}`\n },\n // Row-Reverse\n ...reversed && horizontal && {\n marginLeft: `-${bufferPx}`\n }\n };\n const afterBuffer = {\n // Column\n ...!reversed && !horizontal && {\n marginTop: `-${bufferPx}`\n },\n // Column-Reverse\n ...reversed && !horizontal && {\n marginBottom: `-${bufferPx}`\n },\n // Row\n ...!reversed && horizontal && {\n marginLeft: `-${bufferPx}`\n },\n // Row-Reverse\n ...reversed && horizontal && {\n marginRight: `-${bufferPx}`\n }\n };\n state.before.style = {\n height: horizontal ? '100%' : beforeBufferHeightPx,\n width: horizontal ? beforeBufferHeightPx : '100%',\n ...beforeBuffer,\n ...state.before.style\n };\n state.beforeContainer.style = {\n height: horizontal ? 'auto' : beforeHeightPx,\n width: horizontal ? beforeHeightPx : 'auto',\n ...state.beforeContainer.style\n };\n state.after.style = {\n height: horizontal ? '100%' : afterBufferHeightPx,\n width: horizontal ? afterBufferHeightPx : '100%',\n ...afterBuffer,\n ...state.after.style\n };\n state.afterContainer.style = {\n height: horizontal ? 'auto' : afterHeightPx,\n width: horizontal ? afterHeightPx : 'auto',\n ...state.afterContainer.style\n };\n return state;\n};\n"],"mappings":"AAAA,SAAAA,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,MAAMC,oBAAoB,GAAG,iBAAiB;AAC9C,OAAO,MAAMC,qBAAqB,GAAG;EACjCC,MAAM,EAAE,GAAGF,oBAAoB,UAAU;EACzCG,eAAe,EAAE,GAAGH,oBAAoB,mBAAmB;EAC3DI,KAAK,EAAE,GAAGJ,oBAAoB,SAAS;EACvCK,cAAc,EAAE,GAAGL,oBAAoB;AAC3C,CAAC;AACD,MAAMM,SAAS,gBAAGR,QAAA;EAAAS,IAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;EAAAC,QAAA;IAAAC,MAAA;EAAA;EAAAC,UAAA;IAAAC,MAAA;EAAA;EAAAC,QAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,CAcjB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,6BAA6B,GAAIC,KAAK,IAAG;EACtD,MAAMC,MAAM,GAAGb,SAAS,CAAC,CAAC;EAC1B,MAAM;IAAEc,QAAQ;IAAEC,IAAI;IAAEC,kBAAkB;IAAEC,iBAAiB;IAAEC;EAAW,CAAC,GAAGN,KAAK;EACnF,MAAMN,UAAU,GAAGS,IAAI,KAAK,YAAY;EACxCH,KAAK,CAAChB,MAAM,CAACuB,SAAS,GAAG1B,YAAY,CAACE,qBAAqB,CAACC,MAAM,EAAEiB,MAAM,CAACZ,IAAI,EAAEY,MAAM,CAACT,QAAQ,EAAEE,UAAU,GAAGO,MAAM,CAACP,UAAU,GAAGO,MAAM,CAACL,QAAQ,EAAEI,KAAK,CAAChB,MAAM,CAACuB,SAAS,CAAC;EAC3KP,KAAK,CAAC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Ac,CAACgC,KAAK,GAAG;IACzBC,MAAM,EAAE1B,UAAU,GAAG,MAAM,GAAGe,aAAa;IAC3CY,KAAK,EAAE3B,UAAU,GAAGe,aAAa,GAAG,MAAM;IAC1C,GAAGT,KAAK,CAACb,cAAc,CAACgC;EAC5B,CAAC;EACD,OAAOnB,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useVirtualizerStyles_unstable","virtualizerClassNames","__styles","mergeClasses","virtualizerScrollViewClassName","virtualizerScrollViewClassNames","container","useStyles","base","mc9l5x","a9b677","Bqenvij","vertical","Beiy3e4","Bmxbyg5","horizontal","B68tc82","verticalReversed","horizontalReversed","d","useVirtualizerScrollViewStyles_unstable","state","styles","containerStyle","axis","reversed","className"],"sources":["useVirtualizerScrollViewStyles.styles.js"],"sourcesContent":["import { useVirtualizerStyles_unstable, virtualizerClassNames } from '../Virtualizer/useVirtualizerStyles.styles';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nconst virtualizerScrollViewClassName = 'fui-Virtualizer-Scroll-View';\nexport const virtualizerScrollViewClassNames = {\n ...virtualizerClassNames,\n container: `${virtualizerScrollViewClassName}__container`\n};\nconst useStyles = makeStyles({\n base: {\n display: 'flex',\n width: '100%',\n height: '100%'\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 * Apply styling to the Virtualizer states\n */ export const useVirtualizerScrollViewStyles_unstable = (state)=>{\n const styles = useStyles();\n // Default virtualizer styles base\n useVirtualizerStyles_unstable(state);\n const containerStyle = state.axis === 'horizontal' ? state.reversed ? styles.horizontalReversed : styles.horizontal : state.reversed ? styles.verticalReversed : styles.vertical;\n // Add container styles\n state.container.className = mergeClasses(virtualizerScrollViewClassNames.container, styles.base, containerStyle, state.container.className);\n return state;\n};\n"],"mappings":"AAAA,SAASA,6BAA6B,EAAEC,qBAAqB,QAAQ,4CAA4C;AACjH,SAAAC,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,MAAMC,8BAA8B,GAAG,6BAA6B;AACpE,OAAO,MAAMC,+BAA+B,GAAG;EAC3C,GAAGJ,qBAAqB;EACxBK,SAAS,
|
|
1
|
+
{"version":3,"names":["useVirtualizerStyles_unstable","virtualizerClassNames","__styles","mergeClasses","virtualizerScrollViewClassName","virtualizerScrollViewClassNames","container","useStyles","base","mc9l5x","a9b677","Bqenvij","vertical","Beiy3e4","Bmxbyg5","horizontal","B68tc82","verticalReversed","horizontalReversed","d","useVirtualizerScrollViewStyles_unstable","state","styles","containerStyle","axis","reversed","className"],"sources":["useVirtualizerScrollViewStyles.styles.js"],"sourcesContent":["import { useVirtualizerStyles_unstable, virtualizerClassNames } from '../Virtualizer/useVirtualizerStyles.styles';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nconst virtualizerScrollViewClassName = 'fui-Virtualizer-Scroll-View';\nexport const virtualizerScrollViewClassNames = {\n ...virtualizerClassNames,\n container: `${virtualizerScrollViewClassName}__container`\n};\nconst useStyles = makeStyles({\n base: {\n display: 'flex',\n width: '100%',\n height: '100%'\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 * Apply styling to the Virtualizer states\n */ export const useVirtualizerScrollViewStyles_unstable = (state)=>{\n const styles = useStyles();\n // Default virtualizer styles base\n useVirtualizerStyles_unstable(state);\n const containerStyle = state.axis === 'horizontal' ? state.reversed ? styles.horizontalReversed : styles.horizontal : state.reversed ? styles.verticalReversed : styles.vertical;\n // Add container styles\n state.container.className = mergeClasses(virtualizerScrollViewClassNames.container, styles.base, containerStyle, state.container.className);\n return state;\n};\n"],"mappings":"AAAA,SAASA,6BAA6B,EAAEC,qBAAqB,QAAQ,4CAA4C;AACjH,SAAAC,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,MAAMC,8BAA8B,GAAG,6BAA6B;AACpE,OAAO,MAAMC,+BAA+B,GAAG;EAC3C,GAAGJ,qBAAqB;EACxBK,SAAS,EAAE,GAAGF,8BAA8B;AAChD,CAAC;AACD,MAAMG,SAAS,gBAAGL,QAAA;EAAAM,IAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;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,CAsBjB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,uCAAuC,GAAIC,KAAK,IAAG;EAChE,MAAMC,MAAM,GAAGf,SAAS,CAAC,CAAC;EAC1B;EACAP,6BAA6B,CAACqB,KAAK,CAAC;EACpC,MAAME,cAAc,GAAGF,KAAK,CAACG,IAAI,KAAK,YAAY,GAAGH,KAAK,CAACI,QAAQ,GAAGH,MAAM,CAACJ,kBAAkB,GAAGI,MAAM,CAACP,UAAU,GAAGM,KAAK,CAACI,QAAQ,GAAGH,MAAM,CAACL,gBAAgB,GAAGK,MAAM,CAACV,QAAQ;EAChL;EACAS,KAAK,CAACf,SAAS,CAACoB,SAAS,GAAGvB,YAAY,CAACE,+BAA+B,CAACC,SAAS,EAAEgB,MAAM,CAACd,IAAI,EAAEe,cAAc,EAAEF,KAAK,CAACf,SAAS,CAACoB,SAAS,CAAC;EAC3I,OAAOL,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useVirtualizerStyles_unstable","virtualizerClassNames","__styles","mergeClasses","virtualizerScrollViewDynamicClassName","virtualizerScrollViewDynamicClassNames","container","useStyles","base","mc9l5x","a9b677","Bqenvij","vertical","Beiy3e4","Bmxbyg5","horizontal","B68tc82","verticalReversed","horizontalReversed","d","useVirtualizerScrollViewDynamicStyles_unstable","state","styles","containerStyle","axis","reversed","className"],"sources":["useVirtualizerScrollViewDynamicStyles.styles.js"],"sourcesContent":["import { useVirtualizerStyles_unstable, virtualizerClassNames } from '../Virtualizer/useVirtualizerStyles.styles';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nconst virtualizerScrollViewDynamicClassName = 'fui-Virtualizer-Scroll-View-Dynamic';\nexport const virtualizerScrollViewDynamicClassNames = {\n ...virtualizerClassNames,\n container: `${virtualizerScrollViewDynamicClassName}__container`\n};\nconst useStyles = makeStyles({\n base: {\n display: 'flex',\n width: '100%',\n height: '100%'\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 * Apply styling to the Virtualizer states\n */ export const useVirtualizerScrollViewDynamicStyles_unstable = (state)=>{\n const styles = useStyles();\n // Default virtualizer styles base\n useVirtualizerStyles_unstable(state);\n const containerStyle = state.axis === 'horizontal' ? state.reversed ? styles.horizontalReversed : styles.horizontal : state.reversed ? styles.verticalReversed : styles.vertical;\n // Add container styles\n state.container.className = mergeClasses(virtualizerScrollViewDynamicClassNames.container, styles.base, containerStyle, state.container.className);\n return state;\n};\n"],"mappings":"AAAA,SAASA,6BAA6B,EAAEC,qBAAqB,QAAQ,4CAA4C;AACjH,SAAAC,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,MAAMC,qCAAqC,GAAG,qCAAqC;AACnF,OAAO,MAAMC,sCAAsC,GAAG;EAClD,GAAGJ,qBAAqB;EACxBK,SAAS,
|
|
1
|
+
{"version":3,"names":["useVirtualizerStyles_unstable","virtualizerClassNames","__styles","mergeClasses","virtualizerScrollViewDynamicClassName","virtualizerScrollViewDynamicClassNames","container","useStyles","base","mc9l5x","a9b677","Bqenvij","vertical","Beiy3e4","Bmxbyg5","horizontal","B68tc82","verticalReversed","horizontalReversed","d","useVirtualizerScrollViewDynamicStyles_unstable","state","styles","containerStyle","axis","reversed","className"],"sources":["useVirtualizerScrollViewDynamicStyles.styles.js"],"sourcesContent":["import { useVirtualizerStyles_unstable, virtualizerClassNames } from '../Virtualizer/useVirtualizerStyles.styles';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nconst virtualizerScrollViewDynamicClassName = 'fui-Virtualizer-Scroll-View-Dynamic';\nexport const virtualizerScrollViewDynamicClassNames = {\n ...virtualizerClassNames,\n container: `${virtualizerScrollViewDynamicClassName}__container`\n};\nconst useStyles = makeStyles({\n base: {\n display: 'flex',\n width: '100%',\n height: '100%'\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 * Apply styling to the Virtualizer states\n */ export const useVirtualizerScrollViewDynamicStyles_unstable = (state)=>{\n const styles = useStyles();\n // Default virtualizer styles base\n useVirtualizerStyles_unstable(state);\n const containerStyle = state.axis === 'horizontal' ? state.reversed ? styles.horizontalReversed : styles.horizontal : state.reversed ? styles.verticalReversed : styles.vertical;\n // Add container styles\n state.container.className = mergeClasses(virtualizerScrollViewDynamicClassNames.container, styles.base, containerStyle, state.container.className);\n return state;\n};\n"],"mappings":"AAAA,SAASA,6BAA6B,EAAEC,qBAAqB,QAAQ,4CAA4C;AACjH,SAAAC,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,MAAMC,qCAAqC,GAAG,qCAAqC;AACnF,OAAO,MAAMC,sCAAsC,GAAG;EAClD,GAAGJ,qBAAqB;EACxBK,SAAS,EAAE,GAAGF,qCAAqC;AACvD,CAAC;AACD,MAAMG,SAAS,gBAAGL,QAAA;EAAAM,IAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;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,CAsBjB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,8CAA8C,GAAIC,KAAK,IAAG;EACvE,MAAMC,MAAM,GAAGf,SAAS,CAAC,CAAC;EAC1B;EACAP,6BAA6B,CAACqB,KAAK,CAAC;EACpC,MAAME,cAAc,GAAGF,KAAK,CAACG,IAAI,KAAK,YAAY,GAAGH,KAAK,CAACI,QAAQ,GAAGH,MAAM,CAACJ,kBAAkB,GAAGI,MAAM,CAACP,UAAU,GAAGM,KAAK,CAACI,QAAQ,GAAGH,MAAM,CAACL,gBAAgB,GAAGK,MAAM,CAACV,QAAQ;EAChL;EACAS,KAAK,CAACf,SAAS,CAACoB,SAAS,GAAGvB,YAAY,CAACE,sCAAsC,CAACC,SAAS,EAAEgB,MAAM,CAACd,IAAI,EAAEe,cAAc,EAAEF,KAAK,CAACf,SAAS,CAACoB,SAAS,CAAC;EAClJ,OAAOL,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["hooks.types.ts"],"sourcesContent":["import { MutableRefObject, RefObject } 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\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: 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 (entries: ResizeObserverEntry[]
|
|
1
|
+
{"version":3,"sources":["hooks.types.ts"],"sourcesContent":["import { MutableRefObject, RefObject } 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\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: 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?: MutableRefObject<HTMLElement | null>,\n ): void;\n}\n"],"names":[],"mappings":"AAAA,WAuDC"}
|
|
@@ -50,7 +50,9 @@ import { useRef } from 'react';
|
|
|
50
50
|
getItemSize,
|
|
51
51
|
numItems
|
|
52
52
|
]);
|
|
53
|
-
const resizeCallback = React.useCallback((_entries,
|
|
53
|
+
const resizeCallback = React.useCallback((_entries, // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
54
|
+
// eslint-disable-next-line no-restricted-globals
|
|
55
|
+
_observer, scrollRef)=>{
|
|
54
56
|
if (scrollRef) {
|
|
55
57
|
handleScrollResize(scrollRef);
|
|
56
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["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), 4);\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 + 1;\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"],"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","couldBeSmaller","recheckTotal","i","newItemSize","newLength","totalNewLength","compareLengths"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,4BAA4B;AACtE,YAAYC,WAAW,QAAQ;AAE/B,SAASC,6BAA6B,QAAQ,yBAAyB;AACvE,SAASC,MAAM,QAAQ,QAAQ;AAE/B;;CAEC,GACD,OAAO,MAAMC,+BAA+B,CAC1CC;IAOA,MAAM,EAAEC,eAAe,EAAEC,YAAY,UAAU,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,YAAY,EAAE,GAAGL;IACzF,MAAMM,WAAWR,OAAeO;IAChCC,SAASC,OAAO,GAAGF;IAEnB,MAAM,CAACG,OAAOC,SAAS,GAAGb,MAAMc,QAAQ,CAAC;QACvCC,mBAAmB;QACnBC,wBAAwB;QACxBC,uBAAuB;IACzB;IAEA,MAAM,EAAEF,iBAAiB,EAAEC,sBAAsB,EAAEC,qBAAqB,EAAE,GAAGL;IAE7E,MAAMM,YAAYlB,MAAME,MAAM,CAAqB;IACnD,MAAMiB,qBAAqBnB,MAAMoB,WAAW,CAC1C,CAACC;QACC,IAAI,EAACA,sBAAAA,gCAAAA,UAAWV,OAAO,GAAE;YACvB,iBAAiB;YACjB;QACF;QAEA,IAAIU,UAAUV,OAAO,KAAKO,UAAUP,OAAO,EAAE;YAC3CO,UAAUP,OAAO,GAAGU,UAAUV,OAAO;QACvC;QAEA,MAAMW,gBACJhB,cAAc,aACVe,UAAUV,OAAO,CAACY,qBAAqB,GAAGC,MAAM,GAChDH,UAAUV,OAAO,CAACY,qBAAqB,GAAGE,KAAK;QAErD,IAAIC,aAAa;QACjB,IAAIC,SAAS;QAEb,MAAOD,cAAcJ,iBAAiBK,SAASpB,SAAU;YACvD,MAAMqB,YAAYpB,YAAYE,SAASC,OAAO,GAAGgB;YAEjD,YAAY;YACZD,cAAcE;YACdD;QACF;QAEA;;OAEC,GACD,MAAME,cAAcC,KAAKC,GAAG,CAACD,KAAKE,KAAK,CAACL,SAAS,IAAI;QAErD;;OAEC,GACD,MAAMM,aAAaH,KAAKC,GAAG,CAACD,KAAKE,KAAK,CAAC,AAACL,SAAS,IAAKtB,kBAAkB;QAExE,MAAM6B,cAAcP,SAASE,cAAc,IAAI;QAC/ChB,SAAS;YACPE,mBAAmBmB;YACnBjB,uBAAuBgB;YACvBjB,wBAAwBa;QAC1B;IACF,GACA;QAACxB;QAAiBC;QAAWE;QAAaD;KAAS;IAGrD,MAAM4B,iBAAiBnC,MAAMoB,WAAW,CACtC,CACEgB,
|
|
1
|
+
{"version":3,"sources":["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), 4);\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 + 1;\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 // 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 ) => {\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"],"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","couldBeSmaller","recheckTotal","i","newItemSize","newLength","totalNewLength","compareLengths"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,4BAA4B;AACtE,YAAYC,WAAW,QAAQ;AAE/B,SAASC,6BAA6B,QAAQ,yBAAyB;AACvE,SAASC,MAAM,QAAQ,QAAQ;AAE/B;;CAEC,GACD,OAAO,MAAMC,+BAA+B,CAC1CC;IAOA,MAAM,EAAEC,eAA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D,MAAM4B,iBAAiBnC,MAAMoB,WAAW,CACtC,CACEgB,UACA,8FAA8F;IAC9F,iDAAiD;IACjDC,WACAhB;QAEA,IAAIA,WAAW;YACbF,mBAAmBE;QACrB;IACF,GACA;QAACF;KAAmB;IAGtB,MAAME,YAAYpB,8BAA8BkC;IAEhDpC,0BAA0B;YAOlBmB,oBACAA;QAPN,IAAI,CAACA,UAAUP,OAAO,EAAE;YACtB;QACF;QAEA,MAAMW,gBACJhB,cAAc,aACVY,EAAAA,qBAAAA,UAAUP,OAAO,cAAjBO,yCAAAA,mBAAmBK,qBAAqB,GAAGC,MAAM,IAAG,MACpDN,EAAAA,sBAAAA,UAAUP,OAAO,cAAjBO,0CAAAA,oBAAmBK,qBAAqB,GAAGE,KAAK,IAAG;QAEzD,IAAIa,iBAAiB;QACrB,IAAIC,eAAe;QACnB,IAAK,IAAIC,IAAI/B,cAAc+B,IAAI/B,eAAeM,mBAAmByB,IAAK;YACpE,MAAMC,cAAcjC,YAAYgC;YAChCD,gBAAgBE;YAEhB,MAAMC,YAAYF,IAAI/B;YAEtB,MAAMoB,cAAcC,KAAKC,GAAG,CAACD,KAAKE,KAAK,CAACU,YAAY,IAAI;YACxD,MAAMC,iBAAiBD,YAAYb,cAAc,IAAI;YACrD,MAAMe,iBAAiBD,iBAAiB5B;YAExC,IAAIwB,eAAejB,iBAAiBsB,gBAAgB;gBAClDN,iBAAiB;gBACjB;YACF;QACF;QAEA,4EAA4E;QAC5E,IAAIC,eAAejB,iBAAiBgB,gBAAgB;YAClDnB,mBAAmBD;QACrB;IACF,GAAG;QAACV;QAAaC;QAAcH;QAAWS;QAAmBoB;QAAgBhB;KAAmB;IAEhG,OAAO;QACLJ;QACAc,aAAab;QACbiB,YAAYhB;QACZI;IACF;AACF,EAAE"}
|
|
@@ -8,10 +8,10 @@ import { useMutationObserver } from './useMutationObserver';
|
|
|
8
8
|
* @param ltrRootMargin the margin to be processed and flipped if required
|
|
9
9
|
* @param target target element that will have its current reading direction determined
|
|
10
10
|
* @returns the corrected rootMargin (if it was necessary to correct)
|
|
11
|
-
*/ export const getRTLRootMargin = (ltrRootMargin, target)=>{
|
|
12
|
-
if (target) {
|
|
11
|
+
*/ export const getRTLRootMargin = (ltrRootMargin, target, win)=>{
|
|
12
|
+
if (target && win) {
|
|
13
13
|
// get the computed dir for the target element
|
|
14
|
-
const newDir = getComputedStyle(target).direction;
|
|
14
|
+
const newDir = win.getComputedStyle(target).direction;
|
|
15
15
|
// If we're in rtl reading direction, we might need to flip the margins on the left/right sides
|
|
16
16
|
if (newDir === 'rtl') {
|
|
17
17
|
let newMargin = ltrRootMargin;
|
|
@@ -36,14 +36,17 @@ import { useMutationObserver } from './useMutationObserver';
|
|
|
36
36
|
* @returns An array containing a callback to update the list of Elements the observer should listen to, a callback to
|
|
37
37
|
* update the init options of the IntersectionObserver and a ref to the IntersectionObserver instance itself.
|
|
38
38
|
*/ export const useIntersectionObserver = (callback, options)=>{
|
|
39
|
+
// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
40
|
+
// eslint-disable-next-line no-restricted-globals
|
|
39
41
|
const observer = useRef();
|
|
40
42
|
const [observerList, setObserverList] = useState();
|
|
41
43
|
const { targetDocument } = useFluent();
|
|
44
|
+
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
|
42
45
|
var _options_rootMargin;
|
|
43
46
|
// set the initial init with corrected margins based on the observed root's calculated reading direction.
|
|
44
47
|
const [observerInit, setObserverInit] = useState(options && {
|
|
45
48
|
...options,
|
|
46
|
-
rootMargin: getRTLRootMargin((_options_rootMargin = options.rootMargin) !== null && _options_rootMargin !== void 0 ? _options_rootMargin : '0px', options.root)
|
|
49
|
+
rootMargin: getRTLRootMargin((_options_rootMargin = options.rootMargin) !== null && _options_rootMargin !== void 0 ? _options_rootMargin : '0px', options.root, win)
|
|
47
50
|
});
|
|
48
51
|
var _options_rootMargin1;
|
|
49
52
|
// 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.
|
|
@@ -55,14 +58,15 @@ import { useMutationObserver } from './useMutationObserver';
|
|
|
55
58
|
if (mutation.type === 'attributes' && mutation.attributeName === 'dir' && (options === null || options === void 0 ? void 0 : options.root) && mutation.target.contains(options === null || options === void 0 ? void 0 : options.root)) {
|
|
56
59
|
setObserverInit({
|
|
57
60
|
...observerInit,
|
|
58
|
-
rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root)
|
|
61
|
+
rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root, win)
|
|
59
62
|
});
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
}, [
|
|
63
66
|
ltrRootMargin,
|
|
64
67
|
observerInit,
|
|
65
|
-
options === null || options === void 0 ? void 0 : options.root
|
|
68
|
+
options === null || options === void 0 ? void 0 : options.root,
|
|
69
|
+
win
|
|
66
70
|
]);
|
|
67
71
|
// Mutation observer for dir attribute changes in the document
|
|
68
72
|
useMutationObserver(targetDocument, mutationObserverCallback, {
|
|
@@ -75,13 +79,12 @@ import { useMutationObserver } from './useMutationObserver';
|
|
|
75
79
|
// Observer elements in passed in list and clean up previous list
|
|
76
80
|
// This effect is only triggered when observerList is updated
|
|
77
81
|
useIsomorphicLayoutEffect(()=>{
|
|
78
|
-
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
|
79
82
|
if (!win) {
|
|
80
83
|
return;
|
|
81
84
|
}
|
|
82
85
|
observer.current = new win.IntersectionObserver(callback, {
|
|
83
86
|
...observerInit,
|
|
84
|
-
rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root)
|
|
87
|
+
rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root, win)
|
|
85
88
|
});
|
|
86
89
|
// If we have an instance of IO and a list with elements, observer the elements
|
|
87
90
|
if (observer.current && observerList && observerList.length > 0) {
|
|
@@ -100,7 +103,7 @@ import { useMutationObserver } from './useMutationObserver';
|
|
|
100
103
|
observerList,
|
|
101
104
|
observerInit,
|
|
102
105
|
callback,
|
|
103
|
-
|
|
106
|
+
win
|
|
104
107
|
]);
|
|
105
108
|
// Do not use internally, we need to track external settings only here
|
|
106
109
|
const setObserverInitExternal = useCallback((newInit)=>{
|
|
@@ -110,11 +113,12 @@ import { useMutationObserver } from './useMutationObserver';
|
|
|
110
113
|
// Call the internal setter to update the value and ensure if our calculated direction is rtl, we flip the margin
|
|
111
114
|
setObserverInit({
|
|
112
115
|
...newInit,
|
|
113
|
-
rootMargin: getRTLRootMargin(ltrRootMargin.current, newInit === null || newInit === void 0 ? void 0 : newInit.root)
|
|
116
|
+
rootMargin: getRTLRootMargin(ltrRootMargin.current, newInit === null || newInit === void 0 ? void 0 : newInit.root, win)
|
|
114
117
|
});
|
|
115
118
|
}, [
|
|
116
119
|
ltrRootMargin,
|
|
117
|
-
setObserverInit
|
|
120
|
+
setObserverInit,
|
|
121
|
+
win
|
|
118
122
|
]);
|
|
119
123
|
return {
|
|
120
124
|
setObserverList,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useIntersectionObserver.ts"],"sourcesContent":["import type { Dispatch, MutableRefObject, SetStateAction } from 'react';\nimport * 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 = (ltrRootMargin: string
|
|
1
|
+
{"version":3,"sources":["useIntersectionObserver.ts"],"sourcesContent":["import type { Dispatch, MutableRefObject, SetStateAction } from 'react';\nimport * 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: Dispatch<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: MutableRefObject<IntersectionObserver | undefined>;\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"],"mappings":"AACA,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,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1
|
import * as React from 'react';
|
|
2
|
+
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
|
2
3
|
const { useRef, useEffect } = React;
|
|
3
4
|
export const useMutationObserver = (target, callback, options)=>{
|
|
5
|
+
// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
6
|
+
// eslint-disable-next-line no-restricted-globals
|
|
4
7
|
const observer = useRef();
|
|
8
|
+
const { targetDocument } = useFluent();
|
|
9
|
+
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
|
5
10
|
useEffect(()=>{
|
|
11
|
+
if (!win) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
6
14
|
// Create an observer instance linked to the callback function
|
|
7
|
-
observer.current = new MutationObserver(callback);
|
|
15
|
+
observer.current = new win.MutationObserver(callback);
|
|
8
16
|
}, [
|
|
9
|
-
callback
|
|
17
|
+
callback,
|
|
18
|
+
win
|
|
10
19
|
]);
|
|
11
20
|
useEffect(()=>{
|
|
12
21
|
if (target) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useMutationObserver.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport * as React from 'react';\n\nconst { useRef, useEffect } = React;\n\nexport const useMutationObserver = (\n target: Element | Document | undefined,\n callback: MutationCallback,\n options?: MutationObserverInit,\n): {\n observer: MutableRefObject<MutationObserver | undefined
|
|
1
|
+
{"version":3,"sources":["useMutationObserver.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nconst { useRef, useEffect } = React;\n\nexport const useMutationObserver = (\n target: Element | Document | undefined,\n callback: MutationCallback,\n options?: MutationObserverInit,\n): {\n observer: MutableRefObject<MutationObserver | undefined>; // eslint-disable-line no-restricted-globals\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<MutationObserver>();\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n\n useEffect(() => {\n if (!win) {\n return;\n }\n // Create an observer instance linked to the callback function\n observer.current = new win.MutationObserver(callback);\n }, [callback, win]);\n\n useEffect(() => {\n if (target) {\n // Start observing the target node for configured mutations\n observer.current?.observe(target, options);\n }\n\n return () => {\n observer.current?.disconnect();\n };\n }, [target, options]);\n\n return { observer };\n};\n"],"names":["React","useFluent_unstable","useFluent","useRef","useEffect","useMutationObserver","target","callback","options","observer","targetDocument","win","defaultView","current","MutationObserver","observe","disconnect"],"mappings":"AACA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAE,GAAGJ;AAE9B,OAAO,MAAMK,sBAAsB,CACjCC,QACAC,UACAC;IAIA,8FAA8F;IAC9F,iDAAiD;IACjD,MAAMC,WAAWN;IACjB,MAAM,EAAEO,cAAc,EAAE,GAAGR;IAC3B,MAAMS,MAAMD,2BAAAA,qCAAAA,eAAgBE,WAAW;IAEvCR,UAAU;QACR,IAAI,CAACO,KAAK;YACR;QACF;QACA,8DAA8D;QAC9DF,SAASI,OAAO,GAAG,IAAIF,IAAIG,gBAAgB,CAACP;IAC9C,GAAG;QAACA;QAAUI;KAAI;IAElBP,UAAU;QACR,IAAIE,QAAQ;gBACV,2DAA2D;YAC3DG;aAAAA,oBAAAA,SAASI,OAAO,cAAhBJ,wCAAAA,kBAAkBM,OAAO,CAACT,QAAQE;QACpC;QAEA,OAAO;gBACLC;aAAAA,oBAAAA,SAASI,OAAO,cAAhBJ,wCAAAA,kBAAkBO,UAAU;QAC9B;IACF,GAAG;QAACV;QAAQE;KAAQ;IAEpB,OAAO;QAAEC;IAAS;AACpB,EAAE"}
|
|
@@ -8,6 +8,8 @@ import { createResizeObserverFromDocument } from '../utilities/createResizeObser
|
|
|
8
8
|
const { targetDocument } = useFluent();
|
|
9
9
|
const container = React.useRef(null);
|
|
10
10
|
// the handler for resize observer
|
|
11
|
+
// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
12
|
+
// eslint-disable-next-line no-restricted-globals
|
|
11
13
|
const handleResize = debounce((entries, observer)=>{
|
|
12
14
|
resizeCallback(entries, observer, container);
|
|
13
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useResizeObserverRef.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { debounce } from '../utilities/debounce';\nimport { createResizeObserverFromDocument } from '../utilities/createResizeObserverFromDocument';\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 { targetDocument } = useFluent();\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 createResizeObserverFromDocument(targetDocument, handleResize),\n );\n\n React.useEffect(() => {\n // Update our state when resizeCallback changes\n container.current = null;\n resizeObserver?.disconnect();\n setResizeObserver(() => createResizeObserverFromDocument(targetDocument, handleResize));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [resizeCallback, targetDocument]);\n\n React.useEffect(() => {\n return () => {\n container.current = null;\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"],"names":["React","useFluent_unstable","useFluent","debounce","createResizeObserverFromDocument","useResizeObserverRef_unstable","resizeCallback","targetDocument","container","useRef","handleResize","entries","observer","resizeObserver","setResizeObserver","useState","useEffect","current","disconnect","scrollRef","useCallback","instance","unobserve","observe"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,gCAAgC,QAAQ,gDAAgD;AAGjG;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C,MAAM,EAAEC,cAAc,EAAE,GAAGL;IAC3B,MAAMM,YAAYR,MAAMS,MAAM,CAAqB;IACnD,kCAAkC;IAClC,MAAMC,eAAeP,SAAS,CAACQ,SAAgCC;QAC7DN,eAAeK,SAASC,UAAUJ;IACpC;IAEA,uFAAuF;IACvF,MAAM,CAACK,gBAAgBC,kBAAkB,GAAGd,MAAMe,QAAQ,CAAC,IACzDX,iCAAiCG,gBAAgBG;IAGnDV,MAAMgB,SAAS,CAAC;QACd,+CAA+C;QAC/CR,UAAUS,OAAO,GAAG;QACpBJ,2BAAAA,qCAAAA,eAAgBK,UAAU;QAC1BJ,kBAAkB,IAAMV,iCAAiCG,gBAAgBG;IACzE,uDAAuD;IACzD,GAAG;QAACJ;QAAgBC;KAAe;IAEnCP,MAAMgB,SAAS,CAAC;QACd,OAAO;YACLR,UAAUS,OAAO,GAAG;YACpBJ,2BAAAA,qCAAAA,eAAgBK,UAAU;QAC5B;IACA,uDAAuD;IACzD,GAAG,EAAE;IAEL,MAAMC,YAAYnB,MAAMoB,WAAW,CACjC,CAACC;QACC,IAAIb,UAAUS,OAAO,KAAKI,UAAU;YAClC,IAAIb,UAAUS,OAAO,EAAE;gBACrBJ,2BAAAA,qCAAAA,eAAgBS,SAAS,CAACd,UAAUS,OAAO;YAC7C;YAEAT,UAAUS,OAAO,GAAGI;YACpB,IAAIb,UAAUS,OAAO,EAAE;gBACrBJ,2BAAAA,qCAAAA,eAAgBU,OAAO,CAACf,UAAUS,OAAO;YAC3C;QACF;IACF,GACA;QAACJ;KAAe;IAGlB,OAAOM;AACT,EAAE"}
|
|
1
|
+
{"version":3,"sources":["useResizeObserverRef.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { debounce } from '../utilities/debounce';\nimport { createResizeObserverFromDocument } from '../utilities/createResizeObserverFromDocument';\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 { targetDocument } = useFluent();\n const container = React.useRef<HTMLElement | null>(null);\n // the handler for resize observer\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 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 createResizeObserverFromDocument(targetDocument, handleResize),\n );\n\n React.useEffect(() => {\n // Update our state when resizeCallback changes\n container.current = null;\n resizeObserver?.disconnect();\n setResizeObserver(() => createResizeObserverFromDocument(targetDocument, handleResize));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [resizeCallback, targetDocument]);\n\n React.useEffect(() => {\n return () => {\n container.current = null;\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"],"names":["React","useFluent_unstable","useFluent","debounce","createResizeObserverFromDocument","useResizeObserverRef_unstable","resizeCallback","targetDocument","container","useRef","handleResize","entries","observer","resizeObserver","setResizeObserver","useState","useEffect","current","disconnect","scrollRef","useCallback","instance","unobserve","observe"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,gCAAgC,QAAQ,gDAAgD;AAGjG;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C,MAAM,EAAEC,cAAc,EAAE,GAAGL;IAC3B,MAAMM,YAAYR,MAAMS,MAAM,CAAqB;IACnD,kCAAkC;IAClC,8FAA8F;IAC9F,iDAAiD;IACjD,MAAMC,eAAeP,SAAS,CAACQ,SAAgCC;QAC7DN,eAAeK,SAASC,UAAUJ;IACpC;IAEA,uFAAuF;IACvF,MAAM,CAACK,gBAAgBC,kBAAkB,GAAGd,MAAMe,QAAQ,CAAC,IACzDX,iCAAiCG,gBAAgBG;IAGnDV,MAAMgB,SAAS,CAAC;QACd,+CAA+C;QAC/CR,UAAUS,OAAO,GAAG;QACpBJ,2BAAAA,qCAAAA,eAAgBK,UAAU;QAC1BJ,kBAAkB,IAAMV,iCAAiCG,gBAAgBG;IACzE,uDAAuD;IACzD,GAAG;QAACJ;QAAgBC;KAAe;IAEnCP,MAAMgB,SAAS,CAAC;QACd,OAAO;YACLR,UAAUS,OAAO,GAAG;YACpBJ,2BAAAA,qCAAAA,eAAgBK,UAAU;QAC5B;IACA,uDAAuD;IACzD,GAAG,EAAE;IAEL,MAAMC,YAAYnB,MAAMoB,WAAW,CACjC,CAACC;QACC,IAAIb,UAAUS,OAAO,KAAKI,UAAU;YAClC,IAAIb,UAAUS,OAAO,EAAE;gBACrBJ,2BAAAA,qCAAAA,eAAgBS,SAAS,CAACd,UAAUS,OAAO;YAC7C;YAEAT,UAAUS,OAAO,GAAGI;YACpB,IAAIb,UAAUS,OAAO,EAAE;gBACrBJ,2BAAAA,qCAAAA,eAAgBU,OAAO,CAACf,UAAUS,OAAO;YAC3C;QACF;IACF,GACA;QAACJ;KAAe;IAGlB,OAAOM;AACT,EAAE"}
|
|
@@ -10,7 +10,9 @@ import { useResizeObserverRef_unstable } from './useResizeObserverRef';
|
|
|
10
10
|
bufferItems: 0
|
|
11
11
|
});
|
|
12
12
|
const { virtualizerLength, bufferItems, bufferSize } = state;
|
|
13
|
-
const resizeCallback = React.useCallback((_entries,
|
|
13
|
+
const resizeCallback = React.useCallback((_entries, // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
14
|
+
// eslint-disable-next-line no-restricted-globals
|
|
15
|
+
_observer, scrollRef)=>{
|
|
14
16
|
if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
15
17
|
return;
|
|
16
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useVirtualizerMeasure.ts"],"sourcesContent":["import * as React from 'react';\nimport { VirtualizerMeasureProps } from './hooks.types';\nimport { useResizeObserverRef_unstable } from './useResizeObserverRef';\n\n/**\n * React hook that measures virtualized space based on a static size to ensure optimized virtualization length.\n */\nexport const useStaticVirtualizerMeasure = <TElement extends HTMLElement>(\n virtualizerProps: VirtualizerMeasureProps,\n): {\n virtualizerLength: number;\n bufferItems: number;\n bufferSize: number;\n scrollRef: (instance: TElement | null) => void;\n} => {\n const { defaultItemSize, direction = 'vertical' } = virtualizerProps;\n\n const [state, setState] = React.useState({\n virtualizerLength: 0,\n bufferSize: 0,\n bufferItems: 0,\n });\n\n const { virtualizerLength, bufferItems, bufferSize } = state;\n\n const resizeCallback = React.useCallback(\n (\n _entries: ResizeObserverEntry[],\n _observer: ResizeObserver,\n scrollRef?: React.MutableRefObject<HTMLElement | null>,\n ) => {\n if (!scrollRef?.current) {\n return;\n }\n\n const containerSize =\n direction === 'vertical'\n ? scrollRef?.current.getBoundingClientRect().height\n : scrollRef?.current.getBoundingClientRect().width;\n\n /*\n * Number of items required to cover viewport.\n */\n const length = Math.ceil(containerSize / defaultItemSize + 1);\n\n /*\n * Number of items to append at each end, i.e. 'preload' each side before entering view.\n */\n const newBufferItems = 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 newBufferSize = Math.max(Math.floor((length / 8) * defaultItemSize), 1);\n\n const totalLength = length + newBufferItems * 2 + 1;\n\n setState({\n virtualizerLength: totalLength,\n bufferItems: newBufferItems,\n bufferSize: newBufferSize,\n });\n },\n [defaultItemSize, direction],\n );\n\n const scrollRef = useResizeObserverRef_unstable(resizeCallback);\n\n return {\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollRef,\n };\n};\n"],"names":["React","useResizeObserverRef_unstable","useStaticVirtualizerMeasure","virtualizerProps","defaultItemSize","direction","state","setState","useState","virtualizerLength","bufferSize","bufferItems","resizeCallback","useCallback","_entries","_observer","scrollRef","current","containerSize","getBoundingClientRect","height","width","length","Math","ceil","newBufferItems","max","floor","newBufferSize","totalLength"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,6BAA6B,QAAQ,yBAAyB;AAEvE;;CAEC,GACD,OAAO,MAAMC,8BAA8B,CACzCC;IAOA,MAAM,EAAEC,eAAe,EAAEC,YAAY,UAAU,EAAE,GAAGF;IAEpD,MAAM,CAACG,OAAOC,SAAS,GAAGP,MAAMQ,QAAQ,CAAC;QACvCC,mBAAmB;QACnBC,YAAY;QACZC,aAAa;IACf;IAEA,MAAM,EAAEF,iBAAiB,EAAEE,WAAW,EAAED,UAAU,EAAE,GAAGJ;IAEvD,MAAMM,iBAAiBZ,MAAMa,WAAW,CACtC,CACEC,
|
|
1
|
+
{"version":3,"sources":["useVirtualizerMeasure.ts"],"sourcesContent":["import * as React from 'react';\nimport { VirtualizerMeasureProps } from './hooks.types';\nimport { useResizeObserverRef_unstable } from './useResizeObserverRef';\n\n/**\n * React hook that measures virtualized space based on a static size to ensure optimized virtualization length.\n */\nexport const useStaticVirtualizerMeasure = <TElement extends HTMLElement>(\n virtualizerProps: VirtualizerMeasureProps,\n): {\n virtualizerLength: number;\n bufferItems: number;\n bufferSize: number;\n scrollRef: (instance: TElement | null) => void;\n} => {\n const { defaultItemSize, direction = 'vertical' } = virtualizerProps;\n\n const [state, setState] = React.useState({\n virtualizerLength: 0,\n bufferSize: 0,\n bufferItems: 0,\n });\n\n const { virtualizerLength, bufferItems, bufferSize } = state;\n\n const resizeCallback = React.useCallback(\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 ) => {\n if (!scrollRef?.current) {\n return;\n }\n\n const containerSize =\n direction === 'vertical'\n ? scrollRef?.current.getBoundingClientRect().height\n : scrollRef?.current.getBoundingClientRect().width;\n\n /*\n * Number of items required to cover viewport.\n */\n const length = Math.ceil(containerSize / defaultItemSize + 1);\n\n /*\n * Number of items to append at each end, i.e. 'preload' each side before entering view.\n */\n const newBufferItems = 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 newBufferSize = Math.max(Math.floor((length / 8) * defaultItemSize), 1);\n\n const totalLength = length + newBufferItems * 2 + 1;\n\n setState({\n virtualizerLength: totalLength,\n bufferItems: newBufferItems,\n bufferSize: newBufferSize,\n });\n },\n [defaultItemSize, direction],\n );\n\n const scrollRef = useResizeObserverRef_unstable(resizeCallback);\n\n return {\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollRef,\n };\n};\n"],"names":["React","useResizeObserverRef_unstable","useStaticVirtualizerMeasure","virtualizerProps","defaultItemSize","direction","state","setState","useState","virtualizerLength","bufferSize","bufferItems","resizeCallback","useCallback","_entries","_observer","scrollRef","current","containerSize","getBoundingClientRect","height","width","length","Math","ceil","newBufferItems","max","floor","newBufferSize","totalLength"],"m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};
|
|
100
100
|
// Observe intersections of virtualized components
|
|
101
|
-
const { setObserverList } = (0, _useIntersectionObserver.useIntersectionObserver)(
|
|
101
|
+
const { setObserverList } = (0, _useIntersectionObserver.useIntersectionObserver)(// eslint-disable-next-line no-restricted-globals
|
|
102
|
+
(entries, observer)=>{
|
|
102
103
|
/* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {
|
|
103
104
|
if (actualIndex !== 0) {
|
|
104
105
|
batchUpdateNewIndex(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useVirtualizer.js"],"sourcesContent":["import { useEffect, useRef, useCallback, useReducer, useImperativeHandle, useState } from 'react';\nimport { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { flushSync } from 'react-dom';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { slot, useTimeout } from '@fluentui/react-utilities';\nexport function useVirtualizer_unstable(props) {\n const { itemSize, numItems, virtualizerLength, children: renderChild, getItemSize, bufferItems = Math.round(virtualizerLength / 4.0), bufferSize = Math.floor(bufferItems / 2.0) * itemSize, scrollViewRef, axis = 'vertical', reversed = false, virtualizerContext, onRenderedFlaggedIndex, imperativeVirtualizerRef } = props;\n /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/ const _virtualizerContext = useVirtualizerContextState_unstable(virtualizerContext);\n // We use this ref as a constant source to access the virtualizer's state imperatively\n const actualIndexRef = useRef(_virtualizerContext.contextIndex);\n if (actualIndexRef.current !== _virtualizerContext.contextIndex) {\n actualIndexRef.current = _virtualizerContext.contextIndex;\n }\n const flaggedIndex = useRef(null);\n const actualIndex = _virtualizerContext.contextIndex;\n const setActualIndex = _virtualizerContext.setContextIndex;\n // Store ref to before padding element\n const beforeElementRef = useRef(null);\n // Store ref to before padding element\n const afterElementRef = useRef(null);\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef(new Array(getItemSize ? numItems : 0));\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */ const childProgressiveSizes = useRef(new Array(getItemSize ? numItems : 0));\n // The internal tracking REF for child array (updates often).\n const childArray = useRef(new Array(virtualizerLength));\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(()=>({}), {})[1];\n const horizontal = axis === 'horizontal';\n const populateSizeArrays = ()=>{\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array(numItems);\n }\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array(numItems);\n }\n for(let index = 0; index < numItems; index++){\n childSizes.current[index] = getItemSize(index);\n if (index === 0) {\n childProgressiveSizes.current[index] = childSizes.current[index];\n } else {\n childProgressiveSizes.current[index] = childProgressiveSizes.current[index - 1] + childSizes.current[index];\n }\n }\n };\n const [isScrolling, setIsScrolling] = useState(false);\n const [setScrollTimer, clearScrollTimer] = useTimeout();\n const scrollCounter = useRef(0);\n const initializeScrollingTimer = useCallback(()=>{\n /*\n * This can be considered the 'velocity' required to start 'isScrolling'\n * INIT_SCROLL_FLAG_REQ: Number of renders required to activate isScrolling\n * INIT_SCROLL_FLAG_DELAY: Amount of time (ms) before current number of renders is reset\n * - Maybe we should let users customize these in the future.\n */ const INIT_SCROLL_FLAG_REQ = 10;\n const INIT_SCROLL_FLAG_DELAY = 100;\n scrollCounter.current++;\n if (scrollCounter.current >= INIT_SCROLL_FLAG_REQ) {\n setIsScrolling(true);\n }\n clearScrollTimer();\n setScrollTimer(()=>{\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n }, [\n clearScrollTimer,\n setScrollTimer\n ]);\n useEffect(()=>{\n initializeScrollingTimer();\n }, [\n actualIndex,\n initializeScrollingTimer\n ]);\n const batchUpdateNewIndex = (index)=>{\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\n // Set before 'setActualIndex' call\n // If it changes before render, or injected via context, re-render will update ref.\n actualIndexRef.current = index;\n // State setters\n setActualIndex(index);\n };\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver((entries, observer)=>{\n /* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {\n if (actualIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n /* IO initiates this function when needed (bookend entering view) */ let measurementPos = 0;\n let bufferCount = bufferItems;\n // Grab latest entry that is intersecting\n const latestEntry = entries.length === 1 ? entries[0] : entries.sort((entry1, entry2)=>entry2.time - entry1.time).find((entry)=>{\n return entry.intersectionRatio > 0;\n });\n if (!latestEntry) {\n // If we don't find an intersecting area, ignore for now.\n return;\n }\n if (latestEntry.target === afterElementRef.current) {\n // We need to inverse the buffer count\n bufferCount = virtualizerLength - bufferItems;\n measurementPos = reversed ? calculateAfter() : calculateTotalSize() - calculateAfter();\n if (!horizontal) {\n if (reversed) {\n // Scrolling 'up' and hit the after element below\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' and hit the after element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (reversed) {\n // Scrolling 'left' and hit the after element\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'right' and hit the after element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n measurementPos = reversed ? calculateTotalSize() - calculateBefore() : calculateBefore();\n if (!horizontal) {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' in reverse order and hit the before element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'left' and hit before element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n }\n if (reversed) {\n // We're reversed, up is down, left is right, invert the scroll measure.\n measurementPos = Math.max(calculateTotalSize() - Math.abs(measurementPos), 0);\n }\n // For now lets use hardcoded size to assess current element to paginate on\n const startIndex = getIndexFromScrollPosition(measurementPos);\n const bufferedIndex = Math.max(startIndex - bufferCount, 0);\n // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n if (actualIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n flushSync(()=>{\n batchUpdateNewIndex(newStartIndex);\n });\n }\n }, {\n root: scrollViewRef ? scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current : null,\n rootMargin: '0px',\n threshold: 0\n });\n const findIndexRecursive = (scrollPos, lowIndex, highIndex)=>{\n if (lowIndex > highIndex) {\n // We shouldn't get here - but no-op the index if we do.\n return actualIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */ return midpoint;\n }\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n const getIndexFromSizeArray = (scrollPos)=>{\n /* Quick searches our progressive height array */ if (scrollPos === 0 || childProgressiveSizes.current.length === 0 || scrollPos <= childProgressiveSizes.current[0]) {\n // Check start\n return 0;\n }\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n const getIndexFromScrollPosition = (scrollPos)=>{\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n return getIndexFromSizeArray(scrollPos);\n };\n const calculateTotalSize = useCallback(()=>{\n if (!getItemSize) {\n return itemSize * numItems;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n }, [\n getItemSize,\n itemSize,\n numItems\n ]);\n const calculateBefore = useCallback(()=>{\n const currentIndex = Math.min(actualIndex, numItems - 1);\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return currentIndex * itemSize;\n }\n if (currentIndex <= 0) {\n return 0;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[currentIndex - 1];\n }, [\n actualIndex,\n getItemSize,\n itemSize,\n numItems\n ]);\n const calculateAfter = useCallback(()=>{\n if (numItems === 0 || actualIndex + virtualizerLength >= numItems) {\n return 0;\n }\n const lastItemIndex = Math.min(actualIndex + virtualizerLength, numItems);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex;\n return remainingItems * itemSize;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];\n }, [\n actualIndex,\n getItemSize,\n itemSize,\n numItems,\n virtualizerLength\n ]);\n const updateChildRows = useCallback((newIndex)=>{\n if (numItems === 0) {\n /* Nothing to virtualize */ return;\n }\n /*\n We reset the array every time to ensure children are re-rendered\n This function should only be called when update is nessecary\n */ childArray.current = new Array(virtualizerLength);\n const _actualIndex = Math.max(newIndex, 0);\n const end = Math.min(_actualIndex + virtualizerLength, numItems);\n for(let i = _actualIndex; i < end; i++){\n childArray.current[i - _actualIndex] = renderChild(i, isScrolling);\n }\n }, [\n isScrolling,\n numItems,\n renderChild,\n virtualizerLength\n ]);\n const setBeforeRef = useCallback((element)=>{\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n newList.push(beforeElementRef.current);\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n // Ensure we update array if before element changed\n setObserverList(newList);\n }, [\n setObserverList\n ]);\n const setAfterRef = useCallback((element)=>{\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n newList.push(afterElementRef.current);\n // Ensure we update array if after element changed\n setObserverList(newList);\n }, [\n setObserverList\n ]);\n const updateCurrentItemSizes = (newIndex)=>{\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n let didUpdate = false;\n for(let i = startIndex; i < endIndex; i++){\n const newSize = getItemSize(i);\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n if (didUpdate) {\n // Update our progressive size array\n for(let i = startIndex; i < numItems; i++){\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n };\n // Initialize the size array before first render.\n const hasInitialized = useRef(false);\n const initializeSizeArray = ()=>{\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n useImperativeHandle(imperativeVirtualizerRef, ()=>{\n return {\n progressiveSizes: childProgressiveSizes,\n nodeSizes: childSizes,\n setFlaggedIndex: (index)=>flaggedIndex.current = index,\n currentIndex: actualIndexRef\n };\n }, [\n childProgressiveSizes,\n childSizes\n ]);\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(()=>{\n if (actualIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n // If the user passes in an updated renderChild function - update current children\n useEffect(()=>{\n if (actualIndex >= 0) {\n updateChildRows(actualIndex);\n forceUpdate();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n renderChild,\n updateChildRows\n ]);\n useEffect(()=>{\n // Ensure we repopulate if getItemSize callback changes\n populateSizeArrays();\n // We only run this effect on getItemSize change (recalc dynamic sizes)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n getItemSize\n ]);\n // Effect to check flag index on updates\n useEffect(()=>{\n if (!onRenderedFlaggedIndex || flaggedIndex.current === null) {\n return;\n }\n if (actualIndex <= flaggedIndex.current && actualIndex + virtualizerLength >= flaggedIndex.current) {\n onRenderedFlaggedIndex(flaggedIndex.current);\n flaggedIndex.current = null;\n }\n }, [\n actualIndex,\n onRenderedFlaggedIndex,\n virtualizerLength\n ]);\n // Ensure we have run through and updated the whole size list array at least once.\n initializeSizeArray();\n if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {\n // Child length mismatch, repopulate size arrays.\n populateSizeArrays();\n }\n // Ensure we recalc if virtualizer length changes\n const maxCompare = Math.min(virtualizerLength, numItems);\n if (childArray.current.length !== maxCompare && actualIndex + childArray.current.length < numItems) {\n updateChildRows(actualIndex);\n }\n const isFullyInitialized = hasInitialized.current && actualIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div'\n },\n virtualizedChildren: childArray.current,\n before: slot.always(props.before, {\n defaultProps: {\n ref: setBeforeRef,\n role: 'none'\n },\n elementType: 'div'\n }),\n after: slot.always(props.after, {\n defaultProps: {\n ref: setAfterRef,\n role: 'none'\n },\n elementType: 'div'\n }),\n beforeContainer: slot.always(props.beforeContainer, {\n defaultProps: {\n role: 'none'\n },\n elementType: 'div'\n }),\n afterContainer: slot.always(props.afterContainer, {\n defaultProps: {\n role: 'none'\n },\n elementType: 'div'\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed,\n childSizes,\n childProgressiveSizes\n };\n}\n"],"names":["useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","scrollViewRef","axis","reversed","virtualizerContext","onRenderedFlaggedIndex","imperativeVirtualizerRef","_virtualizerContext","useVirtualizerContextState_unstable","actualIndexRef","useRef","contextIndex","current","flaggedIndex","actualIndex","setActualIndex","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","useReducer","horizontal","populateSizeArrays","length","index","isScrolling","setIsScrolling","useState","setScrollTimer","clearScrollTimer","useTimeout","scrollCounter","initializeScrollingTimer","useCallback","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","useEffect","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","useIntersectionObserver","entries","observer","measurementPos","bufferCount","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","target","calculateAfter","calculateTotalSize","abs","boundingClientRect","bottom","top","right","left","calculateBefore","max","startIndex","getIndexFromScrollPosition","bufferedIndex","maxIndex","newStartIndex","min","flushSync","root","rootMargin","threshold","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","currentIndex","lastItemIndex","remainingItems","newIndex","_actualIndex","end","i","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","useImperativeHandle","progressiveSizes","nodeSizes","setFlaggedIndex","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","slot","always","defaultProps","ref","role","elementType","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"mappings":";;;;+BAKgBA;;;eAAAA;;;uBAL0E;yCAClD;0BACd;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ACAC,aAAa;QACjB;QACAC,oBAAoBb,qBAAqB9C,oBAAoB;QAC7D4D,mBAAmBd,qBAAqBtD,mBAAmB;QAC3DqE,wBAAwBf,qBAAqBrD,uBAAuBpE,oBAAoBF;QACxF2I,uBAAuBnH;QACvBZ;QACAH;QACAI;QACAgB;QACAE;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"sources":["useVirtualizer.js"],"sourcesContent":["import { useEffect, useRef, useCallback, useReducer, useImperativeHandle, useState } from 'react';\nimport { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { flushSync } from 'react-dom';\nimport { useVirtualizerContextState_unstable } from '../../Utilities';\nimport { slot, useTimeout } from '@fluentui/react-utilities';\nexport function useVirtualizer_unstable(props) {\n const { itemSize, numItems, virtualizerLength, children: renderChild, getItemSize, bufferItems = Math.round(virtualizerLength / 4.0), bufferSize = Math.floor(bufferItems / 2.0) * itemSize, scrollViewRef, axis = 'vertical', reversed = false, virtualizerContext, onRenderedFlaggedIndex, imperativeVirtualizerRef } = props;\n /* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/ const _virtualizerContext = useVirtualizerContextState_unstable(virtualizerContext);\n // We use this ref as a constant source to access the virtualizer's state imperatively\n const actualIndexRef = useRef(_virtualizerContext.contextIndex);\n if (actualIndexRef.current !== _virtualizerContext.contextIndex) {\n actualIndexRef.current = _virtualizerContext.contextIndex;\n }\n const flaggedIndex = useRef(null);\n const actualIndex = _virtualizerContext.contextIndex;\n const setActualIndex = _virtualizerContext.setContextIndex;\n // Store ref to before padding element\n const beforeElementRef = useRef(null);\n // Store ref to before padding element\n const afterElementRef = useRef(null);\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef(new Array(getItemSize ? numItems : 0));\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */ const childProgressiveSizes = useRef(new Array(getItemSize ? numItems : 0));\n // The internal tracking REF for child array (updates often).\n const childArray = useRef(new Array(virtualizerLength));\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(()=>({}), {})[1];\n const horizontal = axis === 'horizontal';\n const populateSizeArrays = ()=>{\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array(numItems);\n }\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array(numItems);\n }\n for(let index = 0; index < numItems; index++){\n childSizes.current[index] = getItemSize(index);\n if (index === 0) {\n childProgressiveSizes.current[index] = childSizes.current[index];\n } else {\n childProgressiveSizes.current[index] = childProgressiveSizes.current[index - 1] + childSizes.current[index];\n }\n }\n };\n const [isScrolling, setIsScrolling] = useState(false);\n const [setScrollTimer, clearScrollTimer] = useTimeout();\n const scrollCounter = useRef(0);\n const initializeScrollingTimer = useCallback(()=>{\n /*\n * This can be considered the 'velocity' required to start 'isScrolling'\n * INIT_SCROLL_FLAG_REQ: Number of renders required to activate isScrolling\n * INIT_SCROLL_FLAG_DELAY: Amount of time (ms) before current number of renders is reset\n * - Maybe we should let users customize these in the future.\n */ const INIT_SCROLL_FLAG_REQ = 10;\n const INIT_SCROLL_FLAG_DELAY = 100;\n scrollCounter.current++;\n if (scrollCounter.current >= INIT_SCROLL_FLAG_REQ) {\n setIsScrolling(true);\n }\n clearScrollTimer();\n setScrollTimer(()=>{\n setIsScrolling(false);\n scrollCounter.current = 0;\n }, INIT_SCROLL_FLAG_DELAY);\n }, [\n clearScrollTimer,\n setScrollTimer\n ]);\n useEffect(()=>{\n initializeScrollingTimer();\n }, [\n actualIndex,\n initializeScrollingTimer\n ]);\n const batchUpdateNewIndex = (index)=>{\n // Local updates\n updateChildRows(index);\n updateCurrentItemSizes(index);\n // Set before 'setActualIndex' call\n // If it changes before render, or injected via context, re-render will update ref.\n actualIndexRef.current = index;\n // State setters\n setActualIndex(index);\n };\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n // eslint-disable-next-line no-restricted-globals\n (entries, observer)=>{\n /* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {\n if (actualIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n /* IO initiates this function when needed (bookend entering view) */ let measurementPos = 0;\n let bufferCount = bufferItems;\n // Grab latest entry that is intersecting\n const latestEntry = entries.length === 1 ? entries[0] : entries.sort((entry1, entry2)=>entry2.time - entry1.time).find((entry)=>{\n return entry.intersectionRatio > 0;\n });\n if (!latestEntry) {\n // If we don't find an intersecting area, ignore for now.\n return;\n }\n if (latestEntry.target === afterElementRef.current) {\n // We need to inverse the buffer count\n bufferCount = virtualizerLength - bufferItems;\n measurementPos = reversed ? calculateAfter() : calculateTotalSize() - calculateAfter();\n if (!horizontal) {\n if (reversed) {\n // Scrolling 'up' and hit the after element below\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' and hit the after element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (reversed) {\n // Scrolling 'left' and hit the after element\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'right' and hit the after element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n measurementPos = reversed ? calculateTotalSize() - calculateBefore() : calculateBefore();\n if (!horizontal) {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' in reverse order and hit the before element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'left' and hit before element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n }\n if (reversed) {\n // We're reversed, up is down, left is right, invert the scroll measure.\n measurementPos = Math.max(calculateTotalSize() - Math.abs(measurementPos), 0);\n }\n // For now lets use hardcoded size to assess current element to paginate on\n const startIndex = getIndexFromScrollPosition(measurementPos);\n const bufferedIndex = Math.max(startIndex - bufferCount, 0);\n // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n if (actualIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n flushSync(()=>{\n batchUpdateNewIndex(newStartIndex);\n });\n }\n }, {\n root: scrollViewRef ? scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current : null,\n rootMargin: '0px',\n threshold: 0\n });\n const findIndexRecursive = (scrollPos, lowIndex, highIndex)=>{\n if (lowIndex > highIndex) {\n // We shouldn't get here - but no-op the index if we do.\n return actualIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */ return midpoint;\n }\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n const getIndexFromSizeArray = (scrollPos)=>{\n /* Quick searches our progressive height array */ if (scrollPos === 0 || childProgressiveSizes.current.length === 0 || scrollPos <= childProgressiveSizes.current[0]) {\n // Check start\n return 0;\n }\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n const getIndexFromScrollPosition = (scrollPos)=>{\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n return getIndexFromSizeArray(scrollPos);\n };\n const calculateTotalSize = useCallback(()=>{\n if (!getItemSize) {\n return itemSize * numItems;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n }, [\n getItemSize,\n itemSize,\n numItems\n ]);\n const calculateBefore = useCallback(()=>{\n const currentIndex = Math.min(actualIndex, numItems - 1);\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return currentIndex * itemSize;\n }\n if (currentIndex <= 0) {\n return 0;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[currentIndex - 1];\n }, [\n actualIndex,\n getItemSize,\n itemSize,\n numItems\n ]);\n const calculateAfter = useCallback(()=>{\n if (numItems === 0 || actualIndex + virtualizerLength >= numItems) {\n return 0;\n }\n const lastItemIndex = Math.min(actualIndex + virtualizerLength, numItems);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex;\n return remainingItems * itemSize;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];\n }, [\n actualIndex,\n getItemSize,\n itemSize,\n numItems,\n virtualizerLength\n ]);\n const updateChildRows = useCallback((newIndex)=>{\n if (numItems === 0) {\n /* Nothing to virtualize */ return;\n }\n /*\n We reset the array every time to ensure children are re-rendered\n This function should only be called when update is nessecary\n */ childArray.current = new Array(virtualizerLength);\n const _actualIndex = Math.max(newIndex, 0);\n const end = Math.min(_actualIndex + virtualizerLength, numItems);\n for(let i = _actualIndex; i < end; i++){\n childArray.current[i - _actualIndex] = renderChild(i, isScrolling);\n }\n }, [\n isScrolling,\n numItems,\n renderChild,\n virtualizerLength\n ]);\n const setBeforeRef = useCallback((element)=>{\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n newList.push(beforeElementRef.current);\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n // Ensure we update array if before element changed\n setObserverList(newList);\n }, [\n setObserverList\n ]);\n const setAfterRef = useCallback((element)=>{\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n newList.push(afterElementRef.current);\n // Ensure we update array if after element changed\n setObserverList(newList);\n }, [\n setObserverList\n ]);\n const updateCurrentItemSizes = (newIndex)=>{\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n let didUpdate = false;\n for(let i = startIndex; i < endIndex; i++){\n const newSize = getItemSize(i);\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n if (didUpdate) {\n // Update our progressive size array\n for(let i = startIndex; i < numItems; i++){\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n };\n // Initialize the size array before first render.\n const hasInitialized = useRef(false);\n const initializeSizeArray = ()=>{\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n useImperativeHandle(imperativeVirtualizerRef, ()=>{\n return {\n progressiveSizes: childProgressiveSizes,\n nodeSizes: childSizes,\n setFlaggedIndex: (index)=>flaggedIndex.current = index,\n currentIndex: actualIndexRef\n };\n }, [\n childProgressiveSizes,\n childSizes\n ]);\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(()=>{\n if (actualIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n // If the user passes in an updated renderChild function - update current children\n useEffect(()=>{\n if (actualIndex >= 0) {\n updateChildRows(actualIndex);\n forceUpdate();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n renderChild,\n updateChildRows\n ]);\n useEffect(()=>{\n // Ensure we repopulate if getItemSize callback changes\n populateSizeArrays();\n // We only run this effect on getItemSize change (recalc dynamic sizes)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n getItemSize\n ]);\n // Effect to check flag index on updates\n useEffect(()=>{\n if (!onRenderedFlaggedIndex || flaggedIndex.current === null) {\n return;\n }\n if (actualIndex <= flaggedIndex.current && actualIndex + virtualizerLength >= flaggedIndex.current) {\n onRenderedFlaggedIndex(flaggedIndex.current);\n flaggedIndex.current = null;\n }\n }, [\n actualIndex,\n onRenderedFlaggedIndex,\n virtualizerLength\n ]);\n // Ensure we have run through and updated the whole size list array at least once.\n initializeSizeArray();\n if (getItemSize && (numItems !== childSizes.current.length || numItems !== childProgressiveSizes.current.length)) {\n // Child length mismatch, repopulate size arrays.\n populateSizeArrays();\n }\n // Ensure we recalc if virtualizer length changes\n const maxCompare = Math.min(virtualizerLength, numItems);\n if (childArray.current.length !== maxCompare && actualIndex + childArray.current.length < numItems) {\n updateChildRows(actualIndex);\n }\n const isFullyInitialized = hasInitialized.current && actualIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div'\n },\n virtualizedChildren: childArray.current,\n before: slot.always(props.before, {\n defaultProps: {\n ref: setBeforeRef,\n role: 'none'\n },\n elementType: 'div'\n }),\n after: slot.always(props.after, {\n defaultProps: {\n ref: setAfterRef,\n role: 'none'\n },\n elementType: 'div'\n }),\n beforeContainer: slot.always(props.beforeContainer, {\n defaultProps: {\n role: 'none'\n },\n elementType: 'div'\n }),\n afterContainer: slot.always(props.afterContainer, {\n defaultProps: {\n role: 'none'\n },\n elementType: 'div'\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex: actualIndex,\n axis,\n bufferSize,\n reversed,\n childSizes,\n childProgressiveSizes\n };\n}\n"],"names":["useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","scrollViewRef","axis","reversed","virtualizerContext","onRenderedFlaggedIndex","imperativeVirtualizerRef","_virtualizerContext","useVirtualizerContextState_unstable","actualIndexRef","useRef","contextIndex","current","flaggedIndex","actualIndex","setActualIndex","setContextIndex","beforeElementRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","useReducer","horizontal","populateSizeArrays","length","index","isScrolling","setIsScrolling","useState","setScrollTimer","clearScrollTimer","useTimeout","scrollCounter","initializeScrollingTimer","useCallback","INIT_SCROLL_FLAG_REQ","INIT_SCROLL_FLAG_DELAY","useEffect","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","useIntersectionObserver","entries","observer","measurementPos","bufferCount","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","target","calculateAfter","calculateTotalSize","abs","boundingClientRect","bottom","top","right","left","calculateBefore","max","startIndex","getIndexFromScrollPosition","bufferedIndex","maxIndex","newStartIndex","min","flushSync","root","rootMargin","threshold","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","currentIndex","lastItemIndex","remainingItems","newIndex","_actualIndex","end","i","setBeforeRef","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","useImperativeHandle","progressiveSizes","nodeSizes","setFlaggedIndex","maxCompare","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","slot","always","defaultProps","ref","role","elementType","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","virtualizerStartIndex"],"mappings":";;;;+BAKgBA;;;eAAAA;;;uBAL0E;yCAClD;0BACd;2BAC0B;gCACnB;AAC1B,SAASA,wBAAwBC,KA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Bb,qBAAqB9C,oBAAoB;QAC7D4D,mBAAmBd,qBAAqBtD,mBAAmB;QAC3DqE,wBAAwBf,qBAAqBrD,uBAAuBpE,oBAAoBF;QACxF2I,uBAAuBnH;QACvBZ;QACAH;QACAI;QACAgB;QACAE;IACJ;AACJ"}
|
|
@@ -58,7 +58,8 @@ const useDynamicVirtualizerMeasure = (virtualizerProps)=>{
|
|
|
58
58
|
getItemSize,
|
|
59
59
|
numItems
|
|
60
60
|
]);
|
|
61
|
-
const resizeCallback = _react.useCallback((_entries,
|
|
61
|
+
const resizeCallback = _react.useCallback((_entries, // eslint-disable-next-line no-restricted-globals
|
|
62
|
+
_observer, scrollRef)=>{
|
|
62
63
|
if (scrollRef) {
|
|
63
64
|
handleScrollResize(scrollRef);
|
|
64
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useDynamicVirtualizerMeasure.js"],"sourcesContent":["import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { useResizeObserverRef_unstable } from './useResizeObserverRef';\nimport { useRef } from 'react';\n/**\n * React hook that measures virtualized space dynamically to ensure optimized virtualization length.\n */ export const useDynamicVirtualizerMeasure = (virtualizerProps)=>{\n const { defaultItemSize, direction = 'vertical', numItems, getItemSize, currentIndex } = virtualizerProps;\n const indexRef = useRef(currentIndex);\n indexRef.current = currentIndex;\n const [state, setState] = React.useState({\n virtualizerLength: 0,\n virtualizerBufferItems: 0,\n virtualizerBufferSize: 0\n });\n const { virtualizerLength, virtualizerBufferItems, virtualizerBufferSize } = state;\n const container = React.useRef(null);\n const handleScrollResize = React.useCallback((scrollRef)=>{\n if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {\n // Error? ignore?\n return;\n }\n if (scrollRef.current !== container.current) {\n container.current = scrollRef.current;\n }\n const containerSize = direction === 'vertical' ? scrollRef.current.getBoundingClientRect().height : scrollRef.current.getBoundingClientRect().width;\n let indexSizer = 0;\n let length = 0;\n while(indexSizer <= containerSize && length < numItems){\n const iItemSize = getItemSize(indexRef.current + length);\n // Increment\n indexSizer += iItemSize;\n length++;\n }\n /*\n * Number of items to append at each end, i.e. 'preload' each side before entering view.\n */ const bufferItems = Math.max(Math.floor(length / 4), 4);\n /*\n * This is how far we deviate into the bufferItems to detect a redraw.\n */ const bufferSize = Math.max(Math.floor(length / 8 * defaultItemSize), 1);\n const totalLength = length + bufferItems * 2 + 1;\n setState({\n virtualizerLength: totalLength,\n virtualizerBufferSize: bufferSize,\n virtualizerBufferItems: bufferItems\n });\n }, [\n defaultItemSize,\n direction,\n getItemSize,\n numItems\n ]);\n const resizeCallback = React.useCallback((_entries, _observer, scrollRef)=>{\n if (scrollRef) {\n handleScrollResize(scrollRef);\n }\n }, [\n handleScrollResize\n ]);\n const scrollRef = useResizeObserverRef_unstable(resizeCallback);\n useIsomorphicLayoutEffect(()=>{\n var _container_current, _container_current1;\n if (!container.current) {\n return;\n }\n 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;\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 const newLength = i - currentIndex;\n const bufferItems = Math.max(Math.floor(newLength / 4), 2);\n const totalNewLength = newLength + bufferItems * 2 + 4;\n const compareLengths = totalNewLength < virtualizerLength;\n if (recheckTotal > containerSize && compareLengths) {\n couldBeSmaller = true;\n break;\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 }, [\n getItemSize,\n currentIndex,\n direction,\n virtualizerLength,\n resizeCallback,\n handleScrollResize\n ]);\n return {\n virtualizerLength,\n bufferItems: virtualizerBufferItems,\n bufferSize: virtualizerBufferSize,\n scrollRef\n };\n};\n"],"names":["useDynamicVirtualizerMeasure","virtualizerProps","defaultItemSize","direction","numItems","getItemSize","currentIndex","indexRef","useRef","current","state","setState","React","useState","virtualizerLength","virtualizerBufferItems","virtualizerBufferSize","container","handleScrollResize","useCallback","scrollRef","containerSize","getBoundingClientRect","height","width","indexSizer","length","iItemSize","bufferItems","Math","max","floor","bufferSize","totalLength","resizeCallback","_entries","_observer","useResizeObserverRef_unstable","useIsomorphicLayoutEffect","_container_current","_container_current1","couldBeSmaller","recheckTotal","i","newItemSize","newLength","totalNewLength","compareLengths"],"mappings":";;;;+BAMiBA;;;eAAAA;;;;gCANyB;iEACnB;sCACuB;AAInC,MAAMA,+BAA+B,CAACC;IAC7C,MAAM,EAAEC,eAAe,EAAEC,YAAY,UAAU,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,YAAY,EAAE,GAAGL;IACzF,MAAMM,WAAWC,IAAAA,aAAM,EAACF;IACxBC,SAASE,OAAO,GAAGH;IACnB,MAAM,CAACI,OAAOC,SAAS,GAAGC,OAAMC,QAAQ,CAAC;QACrCC,mBAAmB;QACnBC,wBAAwB;QACxBC,uBAAuB;IAC3B;IACA,MAAM,EAAEF,iBAAiB,EAAEC,sBAAsB,EAAEC,qBAAqB,EAAE,GAAGN;IAC7E,MAAMO,YAAYL,OAAMJ,MAAM,CAAC;IAC/B,MAAMU,qBAAqBN,OAAMO,WAAW,CAAC,CAACC;QAC1C,IAAI,CAAEA,CAAAA,cAAc,QAAQA,cAAc,KAAK,IAAI,KAAK,IAAIA,UAAUX,OAAO,AAAD,GAAI;YAC5E,iBAAiB;YACjB;QACJ;QACA,IAAIW,UAAUX,OAAO,KAAKQ,UAAUR,OAAO,EAAE;YACzCQ,UAAUR,OAAO,GAAGW,UAAUX,OAAO;QACzC;QACA,MAAMY,gBAAgBlB,cAAc,aAAaiB,UAAUX,OAAO,CAACa,qBAAqB,GAAGC,MAAM,GAAGH,UAAUX,OAAO,CAACa,qBAAqB,GAAGE,KAAK;QACnJ,IAAIC,aAAa;QACjB,IAAIC,SAAS;QACb,MAAMD,cAAcJ,iBAAiBK,SAAStB,SAAS;YACnD,MAAMuB,YAAYtB,YAAYE,SAASE,OAAO,GAAGiB;YACjD,YAAY;YACZD,cAAcE;YACdD;QACJ;QACA;;OAED,GAAG,MAAME,cAAcC,KAAKC,GAAG,CAACD,KAAKE,KAAK,CAACL,SAAS,IAAI;QACvD;;OAED,GAAG,MAAMM,aAAaH,KAAKC,GAAG,CAACD,KAAKE,KAAK,CAACL,SAAS,IAAIxB,kBAAkB;QACxE,MAAM+B,cAAcP,SAASE,cAAc,IAAI;QAC/CjB,SAAS;YACLG,mBAAmBmB;YACnBjB,uBAAuBgB;YACvBjB,wBAAwBa;QAC5B;IACJ,GAAG;QACC1B;QACAC;QACAE;QACAD;KACH;IACD,MAAM8B,iBAAiBtB,OAAMO,WAAW,CAAC,CAACgB,
|
|
1
|
+
{"version":3,"sources":["useDynamicVirtualizerMeasure.js"],"sourcesContent":["import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { useResizeObserverRef_unstable } from './useResizeObserverRef';\nimport { useRef } from 'react';\n/**\n * React hook that measures virtualized space dynamically to ensure optimized virtualization length.\n */ export const useDynamicVirtualizerMeasure = (virtualizerProps)=>{\n const { defaultItemSize, direction = 'vertical', numItems, getItemSize, currentIndex } = virtualizerProps;\n const indexRef = useRef(currentIndex);\n indexRef.current = currentIndex;\n const [state, setState] = React.useState({\n virtualizerLength: 0,\n virtualizerBufferItems: 0,\n virtualizerBufferSize: 0\n });\n const { virtualizerLength, virtualizerBufferItems, virtualizerBufferSize } = state;\n const container = React.useRef(null);\n const handleScrollResize = React.useCallback((scrollRef)=>{\n if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {\n // Error? ignore?\n return;\n }\n if (scrollRef.current !== container.current) {\n container.current = scrollRef.current;\n }\n const containerSize = direction === 'vertical' ? scrollRef.current.getBoundingClientRect().height : scrollRef.current.getBoundingClientRect().width;\n let indexSizer = 0;\n let length = 0;\n while(indexSizer <= containerSize && length < numItems){\n const iItemSize = getItemSize(indexRef.current + length);\n // Increment\n indexSizer += iItemSize;\n length++;\n }\n /*\n * Number of items to append at each end, i.e. 'preload' each side before entering view.\n */ const bufferItems = Math.max(Math.floor(length / 4), 4);\n /*\n * This is how far we deviate into the bufferItems to detect a redraw.\n */ const bufferSize = Math.max(Math.floor(length / 8 * defaultItemSize), 1);\n const totalLength = length + bufferItems * 2 + 1;\n setState({\n virtualizerLength: totalLength,\n virtualizerBufferSize: bufferSize,\n virtualizerBufferItems: bufferItems\n });\n }, [\n defaultItemSize,\n direction,\n getItemSize,\n numItems\n ]);\n const resizeCallback = React.useCallback((_entries, // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n // eslint-disable-next-line no-restricted-globals\n _observer, scrollRef)=>{\n if (scrollRef) {\n handleScrollResize(scrollRef);\n }\n }, [\n handleScrollResize\n ]);\n const scrollRef = useResizeObserverRef_unstable(resizeCallback);\n useIsomorphicLayoutEffect(()=>{\n var _container_current, _container_current1;\n if (!container.current) {\n return;\n }\n 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;\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 const newLength = i - currentIndex;\n const bufferItems = Math.max(Math.floor(newLength / 4), 2);\n const totalNewLength = newLength + bufferItems * 2 + 4;\n const compareLengths = totalNewLength < virtualizerLength;\n if (recheckTotal > containerSize && compareLengths) {\n couldBeSmaller = true;\n break;\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 }, [\n getItemSize,\n currentIndex,\n direction,\n virtualizerLength,\n resizeCallback,\n handleScrollResize\n ]);\n return {\n virtualizerLength,\n bufferItems: virtualizerBufferItems,\n bufferSize: virtualizerBufferSize,\n scrollRef\n };\n};\n"],"names":["useDynamicVirtualizerMeasure","virtualizerProps","defaultItemSize","direction","numItems","getItemSize","currentIndex","indexRef","useRef","current","state","setState","React","useState","virtualizerLength","virtualizerBufferItems","virtualizerBufferSize","container","handleScrollResize","useCallback","scrollRef","containerSize","getBoundingClientRect","height","width","indexSizer","length","iItemSize","bufferItems","Math","max","floor","bufferSize","totalLength","resizeCallback","_entries","_observer","useResizeObserverRef_unstable","useIsomorphicLayoutEffect","_container_current","_container_current1","couldBeSmaller","recheckTotal","i","newItemSize","newLength","totalNewLength","compareLengths"],"mappings":";;;;+BAMiBA;;;eAAAA;;;;gCANyB;iEACnB;sCACuB;AAInC,MAAMA,+BAA+B,CAACC;IAC7C,MAAM,EAAEC,eAAe,EAAEC,YAAY,UAAU,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,YAAY,EAAE,GAAGL;IACzF,MAAMM,WAAWC,IAAAA,aAAM,EAACF;IACxBC,SAASE,OAAO,GAAGH;IACnB,MAAM,CAACI,OAAOC,SAAS,GAAGC,OAAMC,QAAQ,CAAC;QACrCC,mBAAmB;QACnBC,wBAAwB;QACxBC,uBAAuB;IAC3B;IACA,MAAM,EAAEF,iBAAiB,EAAEC,sBAAsB,EAAEC,qBAAqB,EAAE,GAAGN;IAC7E,MAAMO,YAAYL,OAAMJ,MAAM,CAAC;IAC/B,MAAMU,qBAAqBN,OAAMO,WAAW,CAAC,CAACC;QAC1C,IAAI,CAAEA,CAAAA,cAAc,QAAQA,cAAc,KAAK,IAAI,KAAK,IAAIA,UAAUX,OAAO,AAAD,GAAI;YAC5E,iBAAiB;YACjB;QACJ;QACA,IAAIW,UAAUX,OAAO,KAAKQ,UAAUR,OAAO,EAAE;YACzCQ,UAAUR,OAAO,GAAGW,UA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oBAAoBlB,qBAAqB,GAAGE,KAAK,AAAD,IAAK;QACjW,IAAIiB,iBAAiB;QACrB,IAAIC,eAAe;QACnB,IAAI,IAAIC,IAAIrC,cAAcqC,IAAIrC,eAAeQ,mBAAmB6B,IAAI;YAChE,MAAMC,cAAcvC,YAAYsC;YAChCD,gBAAgBE;YAChB,MAAMC,YAAYF,IAAIrC;YACtB,MAAMsB,cAAcC,KAAKC,GAAG,CAACD,KAAKE,KAAK,CAACc,YAAY,IAAI;YACxD,MAAMC,iBAAiBD,YAAYjB,cAAc,IAAI;YACrD,MAAMmB,iBAAiBD,iBAAiBhC;YACxC,IAAI4B,eAAerB,iBAAiB0B,gBAAgB;gBAChDN,iBAAiB;gBACjB;YACJ;QACJ;QACA,4EAA4E;QAC5E,IAAIC,eAAerB,iBAAiBoB,gBAAgB;YAChDvB,mBAAmBD;QACvB;IACJ,GAAG;QACCZ;QACAC;QACAH;QACAW;QACAoB;QACAhB;KACH;IACD,OAAO;QACHJ;QACAc,aAAab;QACbiB,YAAYhB;QACZI;IACJ;AACJ"}
|
|
@@ -22,10 +22,10 @@ const _reactutilities = require("@fluentui/react-utilities");
|
|
|
22
22
|
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
23
23
|
const _useMutationObserver = require("./useMutationObserver");
|
|
24
24
|
const { useCallback, useState, useRef } = _react;
|
|
25
|
-
const getRTLRootMargin = (ltrRootMargin, target)=>{
|
|
26
|
-
if (target) {
|
|
25
|
+
const getRTLRootMargin = (ltrRootMargin, target, win)=>{
|
|
26
|
+
if (target && win) {
|
|
27
27
|
// get the computed dir for the target element
|
|
28
|
-
const newDir = getComputedStyle(target).direction;
|
|
28
|
+
const newDir = win.getComputedStyle(target).direction;
|
|
29
29
|
// If we're in rtl reading direction, we might need to flip the margins on the left/right sides
|
|
30
30
|
if (newDir === 'rtl') {
|
|
31
31
|
let newMargin = ltrRootMargin;
|
|
@@ -42,14 +42,17 @@ const getRTLRootMargin = (ltrRootMargin, target)=>{
|
|
|
42
42
|
return ltrRootMargin;
|
|
43
43
|
};
|
|
44
44
|
const useIntersectionObserver = (callback, options)=>{
|
|
45
|
+
// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
46
|
+
// eslint-disable-next-line no-restricted-globals
|
|
45
47
|
const observer = useRef();
|
|
46
48
|
const [observerList, setObserverList] = useState();
|
|
47
49
|
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
50
|
+
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
|
48
51
|
var _options_rootMargin;
|
|
49
52
|
// set the initial init with corrected margins based on the observed root's calculated reading direction.
|
|
50
53
|
const [observerInit, setObserverInit] = useState(options && {
|
|
51
54
|
...options,
|
|
52
|
-
rootMargin: getRTLRootMargin((_options_rootMargin = options.rootMargin) !== null && _options_rootMargin !== void 0 ? _options_rootMargin : '0px', options.root)
|
|
55
|
+
rootMargin: getRTLRootMargin((_options_rootMargin = options.rootMargin) !== null && _options_rootMargin !== void 0 ? _options_rootMargin : '0px', options.root, win)
|
|
53
56
|
});
|
|
54
57
|
var _options_rootMargin1;
|
|
55
58
|
// 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.
|
|
@@ -61,14 +64,15 @@ const useIntersectionObserver = (callback, options)=>{
|
|
|
61
64
|
if (mutation.type === 'attributes' && mutation.attributeName === 'dir' && (options === null || options === void 0 ? void 0 : options.root) && mutation.target.contains(options === null || options === void 0 ? void 0 : options.root)) {
|
|
62
65
|
setObserverInit({
|
|
63
66
|
...observerInit,
|
|
64
|
-
rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root)
|
|
67
|
+
rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root, win)
|
|
65
68
|
});
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
}, [
|
|
69
72
|
ltrRootMargin,
|
|
70
73
|
observerInit,
|
|
71
|
-
options === null || options === void 0 ? void 0 : options.root
|
|
74
|
+
options === null || options === void 0 ? void 0 : options.root,
|
|
75
|
+
win
|
|
72
76
|
]);
|
|
73
77
|
// Mutation observer for dir attribute changes in the document
|
|
74
78
|
(0, _useMutationObserver.useMutationObserver)(targetDocument, mutationObserverCallback, {
|
|
@@ -81,13 +85,12 @@ const useIntersectionObserver = (callback, options)=>{
|
|
|
81
85
|
// Observer elements in passed in list and clean up previous list
|
|
82
86
|
// This effect is only triggered when observerList is updated
|
|
83
87
|
(0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
|
|
84
|
-
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
|
85
88
|
if (!win) {
|
|
86
89
|
return;
|
|
87
90
|
}
|
|
88
91
|
observer.current = new win.IntersectionObserver(callback, {
|
|
89
92
|
...observerInit,
|
|
90
|
-
rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root)
|
|
93
|
+
rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root, win)
|
|
91
94
|
});
|
|
92
95
|
// If we have an instance of IO and a list with elements, observer the elements
|
|
93
96
|
if (observer.current && observerList && observerList.length > 0) {
|
|
@@ -106,7 +109,7 @@ const useIntersectionObserver = (callback, options)=>{
|
|
|
106
109
|
observerList,
|
|
107
110
|
observerInit,
|
|
108
111
|
callback,
|
|
109
|
-
|
|
112
|
+
win
|
|
110
113
|
]);
|
|
111
114
|
// Do not use internally, we need to track external settings only here
|
|
112
115
|
const setObserverInitExternal = useCallback((newInit)=>{
|
|
@@ -116,11 +119,12 @@ const useIntersectionObserver = (callback, options)=>{
|
|
|
116
119
|
// Call the internal setter to update the value and ensure if our calculated direction is rtl, we flip the margin
|
|
117
120
|
setObserverInit({
|
|
118
121
|
...newInit,
|
|
119
|
-
rootMargin: getRTLRootMargin(ltrRootMargin.current, newInit === null || newInit === void 0 ? void 0 : newInit.root)
|
|
122
|
+
rootMargin: getRTLRootMargin(ltrRootMargin.current, newInit === null || newInit === void 0 ? void 0 : newInit.root, win)
|
|
120
123
|
});
|
|
121
124
|
}, [
|
|
122
125
|
ltrRootMargin,
|
|
123
|
-
setObserverInit
|
|
126
|
+
setObserverInit,
|
|
127
|
+
win
|
|
124
128
|
]);
|
|
125
129
|
return {
|
|
126
130
|
setObserverList,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useIntersectionObserver.js"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nconst { useCallback, useState, useRef } = React;\nimport { useMutationObserver } from './useMutationObserver';\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 */ export const getRTLRootMargin = (ltrRootMargin, target)=>{\n if (target) {\n // get the computed dir for the target element\n const newDir = getComputedStyle(target).direction;\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 // 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 return newMargin;\n } else {\n return ltrRootMargin;\n }\n }\n return ltrRootMargin;\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 */ export const useIntersectionObserver = (callback, options)=>{\n const observer = useRef();\n const [observerList, setObserverList] = useState();\n const { targetDocument } = useFluent();\n var _options_rootMargin;\n // set the initial init with corrected margins based on the observed root's calculated reading direction.\n const [observerInit, setObserverInit] = useState(options && {\n ...options,\n rootMargin: getRTLRootMargin((_options_rootMargin = options.rootMargin) !== null && _options_rootMargin !== void 0 ? _options_rootMargin : '0px', options.root)\n });\n var _options_rootMargin1;\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((_options_rootMargin1 = options === null || options === void 0 ? void 0 : options.rootMargin) !== null && _options_rootMargin1 !== void 0 ? _options_rootMargin1 : '0px');\n // Callback function to execute when mutations are observed\n const mutationObserverCallback = useCallback((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 (mutation.type === 'attributes' && mutation.attributeName === 'dir' && (options === null || options === void 0 ? void 0 : options.root) && mutation.target.contains(options === null || options === void 0 ? void 0 : options.root)) {\n setObserverInit({\n ...observerInit,\n rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root)\n });\n }\n }\n }, [\n ltrRootMargin,\n observerInit,\n options === null || options === void 0 ? void 0 : options.root\n ]);\n // Mutation observer for dir attribute changes in the document\n useMutationObserver(targetDocument, mutationObserverCallback, {\n attributes: true,\n subtree: true,\n attributeFilter: [\n '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 const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;\n if (!win) {\n return;\n }\n observer.current = new win.IntersectionObserver(callback, {\n ...observerInit,\n rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root)\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 var _observer_current;\n (_observer_current = observer.current) === null || _observer_current === void 0 ? void 0 : _observer_current.observe(element);\n });\n }\n // clean up previous elements being listened to\n return ()=>{\n if (observer.current) {\n observer.current.disconnect();\n }\n };\n }, [\n observerList,\n observerInit,\n callback,\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView\n ]);\n // Do not use internally, we need to track external settings only here\n const setObserverInitExternal = useCallback((newInit)=>{\n var _newInit_rootMargin;\n // Since we know this is coming from consumers, we can store this value as LTR somewhat safely.\n ltrRootMargin.current = (_newInit_rootMargin = newInit === null || newInit === void 0 ? void 0 : newInit.rootMargin) !== null && _newInit_rootMargin !== void 0 ? _newInit_rootMargin : '0px';\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 === null || newInit === void 0 ? void 0 : newInit.root)\n });\n }, [\n ltrRootMargin,\n setObserverInit\n ]);\n return {\n setObserverList,\n setObserverInit: setObserverInitExternal,\n observer\n };\n};\n"],"names":["getRTLRootMargin","useIntersectionObserver","useCallback","useState","useRef","React","ltrRootMargin","target","newDir","getComputedStyle","direction","newMargin","splitMargins","split","length","callback","options","observer","observerList","setObserverList","targetDocument","useFluent","_options_rootMargin","observerInit","setObserverInit","rootMargin","root","_options_rootMargin1","mutationObserverCallback","mutationList","mutation","type","attributeName","contains","current","useMutationObserver","attributes","subtree","attributeFilter","useIsomorphicLayoutEffect","win","defaultView","IntersectionObserver","forEach","element","_observer_current","observe","disconnect","setObserverInitExternal","newInit","_newInit_rootMargin"],"mappings":";;;;;;;;;;;IAUiBA,gBAAgB;eAAhBA;;IA2BAC,uBAAuB;eAAvBA;;;;iEArCM;gCACmB;qCACM;qCAEZ;AADpC,MAAM,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGC;AAO/B,MAAML,mBAAmB,CAACM,eAAeC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AAE;gBAClBjB,SAASiB,OAAO,CAACa,UAAU;YAC/B;QACJ;IACJ,GAAG;QACC7B;QACAK;QACAR;QACAK,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeqB,WAAW;KAC7F;IACD,sEAAsE;IACtE,MAAMO,0BAA0B9C,YAAY,CAAC+C;QACzC,IAAIC;QACJ,+FAA+F;QAC/F5C,cAAc4B,OAAO,GAAG,AAACgB,CAAAA,sBAAsBD,YAAY,QAAQA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQxB,UAAU,AAAD,MAAO,QAAQyB,wBAAwB,KAAK,IAAIA,sBAAsB;QACxL,iHAAiH;QACjH1B,gBAAgB;YACZ,GAAGyB,OAAO;YACVxB,YAAYzB,iBAAiBM,cAAc4B,OAAO,EAAEe,YAAY,QAAQA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQvB,IAAI;QACtH;IACJ,GAAG;QACCpB;QACAkB;KACH;IACD,OAAO;QACHL;QACAK,iBAAiBwB;QACjB/B;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"sources":["useIntersectionObserver.js"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nconst { useCallback, useState, useRef } = React;\nimport { useMutationObserver } from './useMutationObserver';\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 */ export const getRTLRootMargin = (ltrRootMargin, target, win)=>{\n if (target && win) {\n // get the computed dir for the target element\n const newDir = win.getComputedStyle(target).direction;\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 // 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 return newMargin;\n } else {\n return ltrRootMargin;\n }\n }\n return ltrRootMargin;\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 */ export const useIntersectionObserver = (callback, options)=>{\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();\n const [observerList, setObserverList] = useState();\n const { targetDocument } = useFluent();\n const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;\n var _options_rootMargin;\n // set the initial init with corrected margins based on the observed root's calculated reading direction.\n const [observerInit, setObserverInit] = useState(options && {\n ...options,\n rootMargin: getRTLRootMargin((_options_rootMargin = options.rootMargin) !== null && _options_rootMargin !== void 0 ? _options_rootMargin : '0px', options.root, win)\n });\n var _options_rootMargin1;\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((_options_rootMargin1 = options === null || options === void 0 ? void 0 : options.rootMargin) !== null && _options_rootMargin1 !== void 0 ? _options_rootMargin1 : '0px');\n // Callback function to execute when mutations are observed\n const mutationObserverCallback = useCallback((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 (mutation.type === 'attributes' && mutation.attributeName === 'dir' && (options === null || options === void 0 ? void 0 : options.root) && mutation.target.contains(options === null || options === void 0 ? void 0 : options.root)) {\n setObserverInit({\n ...observerInit,\n rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root, win)\n });\n }\n }\n }, [\n ltrRootMargin,\n observerInit,\n options === null || options === void 0 ? void 0 : options.root,\n win\n ]);\n // Mutation observer for dir attribute changes in the document\n useMutationObserver(targetDocument, mutationObserverCallback, {\n attributes: true,\n subtree: true,\n attributeFilter: [\n '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 observer.current = new win.IntersectionObserver(callback, {\n ...observerInit,\n rootMargin: getRTLRootMargin(ltrRootMargin.current, observerInit === null || observerInit === void 0 ? void 0 : observerInit.root, win)\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 var _observer_current;\n (_observer_current = observer.current) === null || _observer_current === void 0 ? void 0 : _observer_current.observe(element);\n });\n }\n // clean up previous elements being listened to\n return ()=>{\n if (observer.current) {\n observer.current.disconnect();\n }\n };\n }, [\n observerList,\n observerInit,\n callback,\n win\n ]);\n // Do not use internally, we need to track external settings only here\n const setObserverInitExternal = useCallback((newInit)=>{\n var _newInit_rootMargin;\n // Since we know this is coming from consumers, we can store this value as LTR somewhat safely.\n ltrRootMargin.current = (_newInit_rootMargin = newInit === null || newInit === void 0 ? void 0 : newInit.rootMargin) !== null && _newInit_rootMargin !== void 0 ? _newInit_rootMargin : '0px';\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 === null || newInit === void 0 ? void 0 : newInit.root, win)\n });\n }, [\n ltrRootMargin,\n setObserverInit,\n win\n ]);\n return {\n setObserverList,\n setObserverInit: setObserverInitExternal,\n observer\n };\n};\n"],"names":["getRTLRootMargin","useIntersectionObserver","useCallback","useState","useRef","React","ltrRootMargin","target","win","newDir","getComputedStyle","direction","newMargin","splitMargins","split","length","callback","options","observer","observerList","setObserverList","targetDocument","useFluent","defaultView","_options_rootMargin","observerInit","setObserverInit","rootMargin","root","_options_rootMargin1","mutationObserverCallback","mutationList","mutation","type","attributeName","contains","current","useMutationObserver","attributes","subtree","attributeFilter","useIsomorphicLayoutEffect","IntersectionObserver","forEach","element","_observer_current","observe","disconnect","setObserverInitExternal","newInit","_newInit_rootMargin"],"mappings":";;;;;;;;;;;IAUiBA,gBAAgB;eAAhBA;;IA2BAC,uBAAuB;eAAvBA;;;;iEArCM;gCACmB;qCACM;qCAEZ;AADpC,MAAM,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGC;AAO/B,MAAML,mBAAmB,CAACM,eAAeC,QAAQC;IACxD,IAAID,UAAUC,KAAK;QACf,8CAA8C;QAC9C,MAAMC,SAASD,IAAIE,gBAAgB,CAACH,QAAQI,SAAS;QACrD,+FAA+F;QAC/F,IAAIF,WAAW,OAAO;YAClB,IAAIG,YAAYN;YAChB,MAAMO,eAAeP,cAAcQ,KAAK,CAAC;YACzC,2GAA2G;YAC3G,IAAID,aAAaE,MAAM,KAAK,GAAG;gBAC3BH,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;YAC7F;YACA,OAAOD;QACX,OAAO;YACH,OAAON;QACX;IACJ;IACA,OAAOA;AACX;AASW,MAAML,0BAA0B,CAACe,UAAUC;IAClD,8FAA8F;IAC9F,iDAAiD;IACjD,MAAMC,WAAWd;IACjB,MAAM,CAACe,cAAcC,gBAAgB,GAAGjB;IACxC,MAAM,EAAEkB,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMd,MAAMa,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeE,WAAW;IACtG,IAAIC;IACJ,yGAAyG;IACzG,MAAM,CAACC,cAAcC,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kB,OAAO,GAAG,IAAI5B,IAAIkC,oBAAoB,CAAC1B,UAAU;YACtD,GAAGS,YAAY;YACfE,YAAY3B,iBAAiBM,cAAc8B,OAAO,EAAEX,iBAAiB,QAAQA,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAaG,IAAI,EAAEpB;QACvI;QACA,+EAA+E;QAC/E,IAAIU,SAASkB,OAAO,IAAIjB,gBAAgBA,aAAaJ,MAAM,GAAG,GAAG;YAC7DI,aAAawB,OAAO,CAAC,CAACC;gBAClB,IAAIC;gBACHA,CAAAA,oBAAoB3B,SAASkB,OAAO,AAAD,MAAO,QAAQS,sBAAsB,KAAK,IAAI,KAAK,IAAIA,kBAAkBC,OAAO,CAACF;YACzH;QACJ;QACA,+CAA+C;QAC/C,OAAO;YACH,IAAI1B,SAASkB,OAAO,EAAE;gBAClBlB,SAASkB,OAAO,CAACW,UAAU;YAC/B;QACJ;IACJ,GAAG;QACC5B;QACAM;QACAT;QACAR;KACH;IACD,sEAAsE;IACtE,MAAMwC,0BAA0B9C,YAAY,CAAC+C;QACzC,IAAIC;QACJ,+FAA+F;QAC/F5C,cAAc8B,OAAO,GAAG,AAACc,CAAAA,sBAAsBD,YAAY,QAAQA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQtB,UAAU,AAAD,MAAO,QAAQuB,wBAAwB,KAAK,IAAIA,sBAAsB;QACxL,iHAAiH;QACjHxB,gBAAgB;YACZ,GAAGuB,OAAO;YACVtB,YAAY3B,iBAAiBM,cAAc8B,OAAO,EAAEa,YAAY,QAAQA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQrB,IAAI,EAAEpB;QACxH;IACJ,GAAG;QACCF;QACAoB;QACAlB;KACH;IACD,OAAO;QACHY;QACAM,iBAAiBsB;QACjB9B;IACJ;AACJ"}
|
|
@@ -10,14 +10,23 @@ Object.defineProperty(exports, "useMutationObserver", {
|
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
+
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
13
14
|
const { useRef, useEffect } = _react;
|
|
14
15
|
const useMutationObserver = (target, callback, options)=>{
|
|
16
|
+
// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
17
|
+
// eslint-disable-next-line no-restricted-globals
|
|
15
18
|
const observer = useRef();
|
|
19
|
+
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
20
|
+
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
|
16
21
|
useEffect(()=>{
|
|
22
|
+
if (!win) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
17
25
|
// Create an observer instance linked to the callback function
|
|
18
|
-
observer.current = new MutationObserver(callback);
|
|
26
|
+
observer.current = new win.MutationObserver(callback);
|
|
19
27
|
}, [
|
|
20
|
-
callback
|
|
28
|
+
callback,
|
|
29
|
+
win
|
|
21
30
|
]);
|
|
22
31
|
useEffect(()=>{
|
|
23
32
|
if (target) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useMutationObserver.js"],"sourcesContent":["import * as React from 'react';\nconst { useRef, useEffect } = React;\nexport const useMutationObserver = (target, callback, options)=>{\n const observer = useRef();\n useEffect(()=>{\n // Create an observer instance linked to the callback function\n observer.current = new MutationObserver(callback);\n }, [\n callback\n ]);\n useEffect(()=>{\n if (target) {\n var // Start observing the target node for configured mutations\n _observer_current;\n (_observer_current = observer.current) === null || _observer_current === void 0 ? void 0 : _observer_current.observe(target, options);\n }\n return ()=>{\n var _observer_current;\n (_observer_current = observer.current) === null || _observer_current === void 0 ? void 0 : _observer_current.disconnect();\n };\n }, [\n target,\n options\n ]);\n return {\n observer\n };\n};\n"],"names":["useMutationObserver","useRef","useEffect","React","target","callback","options","observer","current","MutationObserver","_observer_current","observe","disconnect"],"mappings":";;;;+
|
|
1
|
+
{"version":3,"sources":["useMutationObserver.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nconst { useRef, useEffect } = React;\nexport const useMutationObserver = (target, callback, options)=>{\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();\n const { targetDocument } = useFluent();\n const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;\n useEffect(()=>{\n if (!win) {\n return;\n }\n // Create an observer instance linked to the callback function\n observer.current = new win.MutationObserver(callback);\n }, [\n callback,\n win\n ]);\n useEffect(()=>{\n if (target) {\n var // Start observing the target node for configured mutations\n _observer_current;\n (_observer_current = observer.current) === null || _observer_current === void 0 ? void 0 : _observer_current.observe(target, options);\n }\n return ()=>{\n var _observer_current;\n (_observer_current = observer.current) === null || _observer_current === void 0 ? void 0 : _observer_current.disconnect();\n };\n }, [\n target,\n options\n ]);\n return {\n observer\n };\n};\n"],"names":["useMutationObserver","useRef","useEffect","React","target","callback","options","observer","targetDocument","useFluent","win","defaultView","current","MutationObserver","_observer_current","observe","disconnect"],"mappings":";;;;+BAGaA;;;eAAAA;;;;iEAHU;qCACyB;AAChD,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAE,GAAGC;AACvB,MAAMH,sBAAsB,CAACI,QAAQC,UAAUC;IAClD,8FAA8F;IAC9F,iDAAiD;IACjD,MAAMC,WAAWN;IACjB,MAAM,EAAEO,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,MAAMF,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeG,WAAW;IACtGT,UAAU;QACN,IAAI,CAACQ,KAAK;YACN;QACJ;QACA,8DAA8D;QAC9DH,SAASK,OAAO,GAAG,IAAIF,IAAIG,gBAAgB,CAACR;IAChD,GAAG;QACCA;QACAK;KACH;IACDR,UAAU;QACN,IAAIE,QAAQ;YACR,IACAU;YACCA,CAAAA,oBAAoBP,SAASK,OAAO,AAAD,MAAO,QAAQE,sBAAsB,KAAK,IAAI,KAAK,IAAIA,kBAAkBC,OAAO,CAACX,QAAQE;QACjI;QACA,OAAO;YACH,IAAIQ;YACHA,CAAAA,oBAAoBP,SAASK,OAAO,AAAD,MAAO,QAAQE,sBAAsB,KAAK,IAAI,KAAK,IAAIA,kBAAkBE,UAAU;QAC3H;IACJ,GAAG;QACCZ;QACAE;KACH;IACD,OAAO;QACHC;IACJ;AACJ"}
|
|
@@ -17,6 +17,8 @@ const useResizeObserverRef_unstable = (resizeCallback)=>{
|
|
|
17
17
|
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
18
18
|
const container = _react.useRef(null);
|
|
19
19
|
// the handler for resize observer
|
|
20
|
+
// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
21
|
+
// eslint-disable-next-line no-restricted-globals
|
|
20
22
|
const handleResize = (0, _debounce.debounce)((entries, observer)=>{
|
|
21
23
|
resizeCallback(entries, observer, container);
|
|
22
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useResizeObserverRef.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { debounce } from '../utilities/debounce';\nimport { createResizeObserverFromDocument } from '../utilities/createResizeObserverFromDocument';\n/**\n * useResizeObserverRef_unstable simplifies resize observer connection and ensures debounce/cleanup\n */ export const useResizeObserverRef_unstable = (resizeCallback)=>{\n const { targetDocument } = useFluent();\n const container = React.useRef(null);\n // the handler for resize observer\n const handleResize = debounce((entries, observer)=>{\n resizeCallback(entries, observer, container);\n });\n // Keep the reference of ResizeObserver in the state, as it should live through renders\n const [resizeObserver, setResizeObserver] = React.useState(()=>createResizeObserverFromDocument(targetDocument, handleResize));\n React.useEffect(()=>{\n // Update our state when resizeCallback changes\n container.current = null;\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();\n setResizeObserver(()=>createResizeObserverFromDocument(targetDocument, handleResize));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n resizeCallback,\n targetDocument\n ]);\n React.useEffect(()=>{\n return ()=>{\n container.current = null;\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n const scrollRef = React.useCallback((instance)=>{\n if (container.current !== instance) {\n if (container.current) {\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.unobserve(container.current);\n }\n container.current = instance;\n if (container.current) {\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.observe(container.current);\n }\n }\n }, [\n resizeObserver\n ]);\n return scrollRef;\n};\n"],"names":["useResizeObserverRef_unstable","resizeCallback","targetDocument","useFluent","container","React","useRef","handleResize","debounce","entries","observer","resizeObserver","setResizeObserver","useState","createResizeObserverFromDocument","useEffect","current","disconnect","scrollRef","useCallback","instance","unobserve","observe"],"mappings":";;;;+BAMiBA;;;eAAAA;;;;iEANM;qCACyB;0BACvB;kDACwB;AAGtC,MAAMA,gCAAgC,CAACC;IAC9C,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,YAAYC,OAAMC,MAAM,CAAC;IAC/B,kCAAkC;IAClC,MAAMC,eAAeC,IAAAA,kBAAQ,EAAC,CAACC,SAASC;QACpCT,eAAeQ,SAASC,UAAUN;IACtC;IACA,uFAAuF;IACvF,MAAM,CAACO,gBAAgBC,kBAAkB,GAAGP,OAAMQ,QAAQ,CAAC,IAAIC,IAAAA,kEAAgC,EAACZ,gBAAgBK;IAChHF,OAAMU,SAAS,CAAC;QACZ,+CAA+C;QAC/CX,UAAUY,OAAO,GAAG;QACpBL,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeM,UAAU;QACzFL,kBAAkB,IAAIE,IAAAA,kEAAgC,EAACZ,gBAAgBK;IAC3E,uDAAuD;IACvD,GAAG;QACCN;QACAC;KACH;IACDG,OAAMU,SAAS,CAAC;QACZ,OAAO;YACHX,UAAUY,OAAO,GAAG;YACpBL,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeM,UAAU;QAC7F;IACJ,uDAAuD;IACvD,GAAG,EAAE;IACL,MAAMC,YAAYb,OAAMc,WAAW,CAAC,CAACC;QACjC,IAAIhB,UAAUY,OAAO,KAAKI,UAAU;YAChC,IAAIhB,UAAUY,OAAO,EAAE;gBACnBL,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeU,SAAS,CAACjB,UAAUY,OAAO;YAC9G;YACAZ,UAAUY,OAAO,GAAGI;YACpB,IAAIhB,UAAUY,OAAO,EAAE;gBACnBL,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeW,OAAO,CAAClB,UAAUY,OAAO;YAC5G;QACJ;IACJ,GAAG;QACCL;KACH;IACD,OAAOO;AACX"}
|
|
1
|
+
{"version":3,"sources":["useResizeObserverRef.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { debounce } from '../utilities/debounce';\nimport { createResizeObserverFromDocument } from '../utilities/createResizeObserverFromDocument';\n/**\n * useResizeObserverRef_unstable simplifies resize observer connection and ensures debounce/cleanup\n */ export const useResizeObserverRef_unstable = (resizeCallback)=>{\n const { targetDocument } = useFluent();\n const container = React.useRef(null);\n // the handler for resize observer\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 handleResize = debounce((entries, observer)=>{\n resizeCallback(entries, observer, container);\n });\n // Keep the reference of ResizeObserver in the state, as it should live through renders\n const [resizeObserver, setResizeObserver] = React.useState(()=>createResizeObserverFromDocument(targetDocument, handleResize));\n React.useEffect(()=>{\n // Update our state when resizeCallback changes\n container.current = null;\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();\n setResizeObserver(()=>createResizeObserverFromDocument(targetDocument, handleResize));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n resizeCallback,\n targetDocument\n ]);\n React.useEffect(()=>{\n return ()=>{\n container.current = null;\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n const scrollRef = React.useCallback((instance)=>{\n if (container.current !== instance) {\n if (container.current) {\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.unobserve(container.current);\n }\n container.current = instance;\n if (container.current) {\n resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.observe(container.current);\n }\n }\n }, [\n resizeObserver\n ]);\n return scrollRef;\n};\n"],"names":["useResizeObserverRef_unstable","resizeCallback","targetDocument","useFluent","container","React","useRef","handleResize","debounce","entries","observer","resizeObserver","setResizeObserver","useState","createResizeObserverFromDocument","useEffect","current","disconnect","scrollRef","useCallback","instance","unobserve","observe"],"mappings":";;;;+BAMiBA;;;eAAAA;;;;iEANM;qCACyB;0BACvB;kDACwB;AAGtC,MAAMA,gCAAgC,CAACC;IAC9C,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,YAAYC,OAAMC,MAAM,CAAC;IAC/B,kCAAkC;IAClC,8FAA8F;IAC9F,iDAAiD;IACjD,MAAMC,eAAeC,IAAAA,kBAAQ,EAAC,CAACC,SAASC;QACpCT,eAAeQ,SAASC,UAAUN;IACtC;IACA,uFAAuF;IACvF,MAAM,CAACO,gBAAgBC,kBAAkB,GAAGP,OAAMQ,QAAQ,CAAC,IAAIC,IAAAA,kEAAgC,EAACZ,gBAAgBK;IAChHF,OAAMU,SAAS,CAAC;QACZ,+CAA+C;QAC/CX,UAAUY,OAAO,GAAG;QACpBL,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeM,UAAU;QACzFL,kBAAkB,IAAIE,IAAAA,kEAAgC,EAACZ,gBAAgBK;IAC3E,uDAAuD;IACvD,GAAG;QACCN;QACAC;KACH;IACDG,OAAMU,SAAS,CAAC;QACZ,OAAO;YACHX,UAAUY,OAAO,GAAG;YACpBL,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeM,UAAU;QAC7F;IACJ,uDAAuD;IACvD,GAAG,EAAE;IACL,MAAMC,YAAYb,OAAMc,WAAW,CAAC,CAACC;QACjC,IAAIhB,UAAUY,OAAO,KAAKI,UAAU;YAChC,IAAIhB,UAAUY,OAAO,EAAE;gBACnBL,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeU,SAAS,CAACjB,UAAUY,OAAO;YAC9G;YACAZ,UAAUY,OAAO,GAAGI;YACpB,IAAIhB,UAAUY,OAAO,EAAE;gBACnBL,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeW,OAAO,CAAClB,UAAUY,OAAO;YAC5G;QACJ;IACJ,GAAG;QACCL;KACH;IACD,OAAOO;AACX"}
|
|
@@ -19,7 +19,8 @@ const useStaticVirtualizerMeasure = (virtualizerProps)=>{
|
|
|
19
19
|
bufferItems: 0
|
|
20
20
|
});
|
|
21
21
|
const { virtualizerLength, bufferItems, bufferSize } = state;
|
|
22
|
-
const resizeCallback = _react.useCallback((_entries,
|
|
22
|
+
const resizeCallback = _react.useCallback((_entries, // eslint-disable-next-line no-restricted-globals
|
|
23
|
+
_observer, scrollRef)=>{
|
|
23
24
|
if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useVirtualizerMeasure.js"],"sourcesContent":["import * as React from 'react';\nimport { useResizeObserverRef_unstable } from './useResizeObserverRef';\n/**\n * React hook that measures virtualized space based on a static size to ensure optimized virtualization length.\n */ export const useStaticVirtualizerMeasure = (virtualizerProps)=>{\n const { defaultItemSize, direction = 'vertical' } = virtualizerProps;\n const [state, setState] = React.useState({\n virtualizerLength: 0,\n bufferSize: 0,\n bufferItems: 0\n });\n const { virtualizerLength, bufferItems, bufferSize } = state;\n const resizeCallback = React.useCallback((_entries, _observer, scrollRef)=>{\n if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {\n return;\n }\n 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;\n /*\n * Number of items required to cover viewport.\n */ const length = Math.ceil(containerSize / defaultItemSize + 1);\n /*\n * Number of items to append at each end, i.e. 'preload' each side before entering view.\n */ const newBufferItems = Math.max(Math.floor(length / 4), 2);\n /*\n * This is how far we deviate into the bufferItems to detect a redraw.\n */ const newBufferSize = Math.max(Math.floor(length / 8 * defaultItemSize), 1);\n const totalLength = length + newBufferItems * 2 + 1;\n setState({\n virtualizerLength: totalLength,\n bufferItems: newBufferItems,\n bufferSize: newBufferSize\n });\n }, [\n defaultItemSize,\n direction\n ]);\n const scrollRef = useResizeObserverRef_unstable(resizeCallback);\n return {\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollRef\n };\n};\n"],"names":["useStaticVirtualizerMeasure","virtualizerProps","defaultItemSize","direction","state","setState","React","useState","virtualizerLength","bufferSize","bufferItems","resizeCallback","useCallback","_entries","_observer","scrollRef","current","containerSize","getBoundingClientRect","height","width","length","Math","ceil","newBufferItems","max","floor","newBufferSize","totalLength","useResizeObserverRef_unstable"],"mappings":";;;;+BAIiBA;;;eAAAA;;;;iEAJM;sCACuB;AAGnC,MAAMA,8BAA8B,CAACC;IAC5C,MAAM,EAAEC,eAAe,EAAEC,YAAY,UAAU,EAAE,GAAGF;IACpD,MAAM,CAACG,OAAOC,SAAS,GAAGC,OAAMC,QAAQ,CAAC;QACrCC,mBAAmB;QACnBC,YAAY;QACZC,aAAa;IACjB;IACA,MAAM,EAAEF,iBAAiB,EAAEE,WAAW,EAAED,UAAU,EAAE,GAAGL;IACvD,MAAMO,iBAAiBL,OAAMM,WAAW,CAAC,CAACC,
|
|
1
|
+
{"version":3,"sources":["useVirtualizerMeasure.js"],"sourcesContent":["import * as React from 'react';\nimport { useResizeObserverRef_unstable } from './useResizeObserverRef';\n/**\n * React hook that measures virtualized space based on a static size to ensure optimized virtualization length.\n */ export const useStaticVirtualizerMeasure = (virtualizerProps)=>{\n const { defaultItemSize, direction = 'vertical' } = virtualizerProps;\n const [state, setState] = React.useState({\n virtualizerLength: 0,\n bufferSize: 0,\n bufferItems: 0\n });\n const { virtualizerLength, bufferItems, bufferSize } = state;\n const resizeCallback = React.useCallback((_entries, // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n // eslint-disable-next-line no-restricted-globals\n _observer, scrollRef)=>{\n if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {\n return;\n }\n 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;\n /*\n * Number of items required to cover viewport.\n */ const length = Math.ceil(containerSize / defaultItemSize + 1);\n /*\n * Number of items to append at each end, i.e. 'preload' each side before entering view.\n */ const newBufferItems = Math.max(Math.floor(length / 4), 2);\n /*\n * This is how far we deviate into the bufferItems to detect a redraw.\n */ const newBufferSize = Math.max(Math.floor(length / 8 * defaultItemSize), 1);\n const totalLength = length + newBufferItems * 2 + 1;\n setState({\n virtualizerLength: totalLength,\n bufferItems: newBufferItems,\n bufferSize: newBufferSize\n });\n }, [\n defaultItemSize,\n direction\n ]);\n const scrollRef = useResizeObserverRef_unstable(resizeCallback);\n return {\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollRef\n };\n};\n"],"names":["useStaticVirtualizerMeasure","virtualizerProps","defaultItemSize","direction","state","setState","React","useState","virtualizerLength","bufferSize","bufferItems","resizeCallback","useCallback","_entries","_observer","scrollRef","current","containerSize","getBoundingClientRect","height","width","length","Math","ceil","newBufferItems","max","floor","newBufferSize","totalLength","useResizeObserverRef_unstable"],"mappings":";;;;+BAIiBA;;;eAAAA;;;;iEAJM;sCACuB;AAGnC,MAAMA,8BAA8B,CAACC;IAC5C,MAAM,EAAEC,eAAe,EAAEC,YAAY,UAAU,EAAE,GAAGF;IACpD,MAAM,CAACG,OAAOC,SAAS,GAAGC,OAAMC,QAAQ,CAAC;QACrCC,mBAAmB;QACnBC,YAAY;QACZC,aAAa;IACjB;IACA,MAAM,EAAEF,iBAAiB,EAAEE,WAAW,EAAED,UAAU,EAAE,GAAGL;IACvD,MAAMO,iBAAiBL,OAAMM,WAAW,CAAC,CAACC,UAC1C,iDAAiD;IACjDC,WAAWC;QACP,IAAI,CAAEA,CAAAA,cAAc,QAAQA,cAAc,KAAK,IAAI,KAAK,IAAIA,UAAUC,OAAO,AAAD,GAAI;YAC5E;QACJ;QACA,MAAMC,gBAAgBd,cAAc,aAAaY,cAAc,QAAQA,cAAc,KAAK,IAAI,KAAK,IAAIA,UAAUC,OAAO,CAACE,qBAAqB,GAAGC,MAAM,GAAGJ,cAAc,QAAQA,cAAc,KAAK,IAAI,KAAK,IAAIA,UAAUC,OAAO,CAACE,qBAAqB,GAAGE,KAAK;QAC/P;;OAED,GAAG,MAAMC,SAASC,KAAKC,IAAI,CAACN,gBAAgBf,kBAAkB;QAC7D;;OAED,GAAG,MAAMsB,iBAAiBF,KAAKG,GAAG,CAACH,KAAKI,KAAK,CAACL,SAAS,IAAI;QAC1D;;OAED,GAAG,MAAMM,gBAAgBL,KAAKG,GAAG,CAACH,KAAKI,KAAK,CAACL,SAAS,IAAInB,kBAAkB;QAC3E,MAAM0B,cAAcP,SAASG,iBAAiB,IAAI;QAClDnB,SAAS;YACLG,mBAAmBoB;YACnBlB,aAAac;YACbf,YAAYkB;QAChB;IACJ,GAAG;QACCzB;QACAC;KACH;IACD,MAAMY,YAAYc,IAAAA,mDAA6B,EAAClB;IAChD,OAAO;QACHH;QACAE;QACAD;QACAM;IACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-virtualizer",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.79",
|
|
4
4
|
"description": "Generic and composable virtualizer framework built on browser intersection observer",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@fluentui/scripts-tasks": "*"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@fluentui/react-jsx-runtime": "^9.0.
|
|
36
|
-
"@fluentui/react-utilities": "^9.18.
|
|
35
|
+
"@fluentui/react-jsx-runtime": "^9.0.39",
|
|
36
|
+
"@fluentui/react-utilities": "^9.18.10",
|
|
37
37
|
"@fluentui/react-shared-contexts": "^9.19.0",
|
|
38
38
|
"@griffel/react": "^1.5.22",
|
|
39
39
|
"@swc/helpers": "^0.5.1"
|