@fluentui/react-virtualizer 9.0.0-alpha.11 → 9.0.0-alpha.13
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/.swcrc +30 -0
- package/CHANGELOG.json +49 -1
- package/CHANGELOG.md +23 -2
- package/lib/Hooks.js.map +1 -1
- package/lib/Virtualizer.js.map +1 -1
- package/lib/components/Virtualizer/Virtualizer.js.map +1 -1
- package/lib/components/Virtualizer/Virtualizer.types.js +1 -1
- package/lib/components/Virtualizer/Virtualizer.types.js.map +1 -1
- package/lib/components/Virtualizer/index.js.map +1 -1
- package/lib/components/Virtualizer/renderVirtualizer.js +1 -9
- package/lib/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizer.js +3 -6
- package/lib/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizerStyles.js.map +1 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useIntersectionObserver.js +2 -2
- package/lib/hooks/useIntersectionObserver.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Hooks.js +5 -4
- package/lib-commonjs/Hooks.js.map +1 -1
- package/lib-commonjs/Virtualizer.js +5 -4
- package/lib-commonjs/Virtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/Virtualizer.js +14 -17
- package/lib-commonjs/components/Virtualizer/Virtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/Virtualizer.types.js +5 -2
- package/lib-commonjs/components/Virtualizer/Virtualizer.types.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/index.js +9 -8
- package/lib-commonjs/components/Virtualizer/index.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/renderVirtualizer.js +13 -21
- package/lib-commonjs/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js +348 -361
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.js +112 -107
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.js.map +1 -1
- package/lib-commonjs/hooks/index.js +5 -4
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useIntersectionObserver.js +49 -54
- package/lib-commonjs/hooks/useIntersectionObserver.js.map +1 -1
- package/lib-commonjs/index.js +18 -40
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useIntersectionObserver_1","require","react_1","react_utilities_1","react_dom_1","useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","intersectionObserverRoot","axis","reversed","onUpdateIndex","onCalculateIndex","virtualizerStartIndex","setVirtualizerStartIndex","useState","beforeElementRef","useRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","useReducer","horizontal","populateSizeArrays","current","length","index","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","useIntersectionObserver","entries","observer","measurementPos","bufferCount","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","target","calculateAfter","calculateTotalSize","abs","boundingClientRect","bottom","top","right","left","calculateBefore","max","startIndex","getIndexFromScrollPosition","bufferedIndex","maxIndex","newStartIndex","min","flushSync","root","rootMargin","threshold","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","lastItemIndex","remainingItems","newIndex","actualIndex","end","i","setBeforeRef","useCallback","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","useEffect","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","resolveShorthand","required","defaultProps","ref","role","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight","exports"],"sources":["../src/packages/react-components/react-virtualizer/src/components/Virtualizer/useVirtualizer.ts"],"sourcesContent":["import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport type { ReactNode } from 'react';\nimport { useEffect, useRef, useState, useCallback, useReducer } from 'react';\n\nimport type { VirtualizerProps, VirtualizerState } from './Virtualizer.types';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\n\nexport function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerState {\n const {\n itemSize,\n numItems,\n virtualizerLength,\n children: renderChild,\n getItemSize,\n bufferItems = Math.round(virtualizerLength / 4.0),\n bufferSize = Math.floor(bufferItems / 2.0) * itemSize,\n intersectionObserverRoot,\n axis = 'vertical',\n reversed = false,\n onUpdateIndex,\n onCalculateIndex,\n } = props;\n\n // Tracks the initial item to start virtualizer at, -1 implies first render cycle\n const [virtualizerStartIndex, setVirtualizerStartIndex] = useState<number>(-1);\n\n // Store ref to before padding element\n const beforeElementRef = useRef<Element | null>(null);\n\n // Store ref to before padding element\n const afterElementRef = useRef<Element | null>(null);\n\n // We need to store an array to track dynamic sizes, we can use this to incrementally update changes\n const childSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n /* We keep track of the progressive sizing/placement down the list,\n this helps us skip re-calculations unless children/size changes */\n const childProgressiveSizes = useRef<number[]>(new Array<number>(getItemSize ? numItems : 0));\n\n // The internal tracking REF for child array (updates often).\n const childArray = useRef<ReactNode[]>(new Array(virtualizerLength));\n\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(() => ({}), {})[1];\n\n const horizontal = axis === 'horizontal';\n\n const populateSizeArrays = () => {\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array<number>(numItems);\n }\n\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array<number>(numItems);\n }\n\n for (let index = 0; index < numItems; index++) {\n childSizes.current[index] = getItemSize(index);\n\n if (index === 0) {\n childProgressiveSizes.current[index] = childSizes.current[index];\n } else {\n childProgressiveSizes.current[index] = childProgressiveSizes.current[index - 1] + childSizes.current[index];\n }\n }\n };\n\n const batchUpdateNewIndex = (index: number) => {\n // Local updates\n onUpdateIndex?.(index, virtualizerStartIndex);\n updateChildRows(index);\n updateCurrentItemSizes(index);\n\n // State setters\n setVirtualizerStartIndex(index);\n };\n\n // Observe intersections of virtualized components\n const { setObserverList } = useIntersectionObserver(\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n /* Sanity check - do we even need virtualization? */\n if (virtualizerLength > numItems) {\n if (virtualizerStartIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n\n /* IO initiates this function when needed (bookend entering view) */\n let measurementPos = 0;\n let bufferCount = bufferItems;\n\n // Grab latest entry that is intersecting\n const latestEntry =\n entries.length === 1\n ? entries[0]\n : entries\n .sort((entry1, entry2) => entry2.time - entry1.time)\n .find(entry => {\n return entry.intersectionRatio > 0;\n });\n\n if (!latestEntry) {\n // If we don't find an intersecting area, ignore for now.\n return;\n }\n\n if (latestEntry.target === afterElementRef.current) {\n // We need to inverse the buffer count\n bufferCount = virtualizerLength - bufferItems;\n measurementPos = reversed ? calculateAfter() : calculateTotalSize() - calculateAfter();\n if (!horizontal) {\n if (reversed) {\n // Scrolling 'up' and hit the after element below\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' and hit the after element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (reversed) {\n // Scrolling 'left' and hit the after element\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'right' and hit the after element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n } else if (latestEntry.target === beforeElementRef.current) {\n measurementPos = reversed ? calculateTotalSize() - calculateBefore() : calculateBefore();\n if (!horizontal) {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.bottom);\n } else if (latestEntry.boundingClientRect.top < 0) {\n // Scrolling 'down' in reverse order and hit the before element above top: 0\n measurementPos -= latestEntry.boundingClientRect.top;\n }\n } else {\n if (!reversed) {\n measurementPos -= Math.abs(latestEntry.boundingClientRect.right);\n } else if (latestEntry.boundingClientRect.left < 0) {\n // Scrolling 'left' and hit before element\n measurementPos -= latestEntry.boundingClientRect.left;\n }\n }\n }\n\n if (reversed) {\n // We're reversed, up is down, left is right, invert the scroll measure.\n measurementPos = Math.max(calculateTotalSize() - Math.abs(measurementPos), 0);\n }\n\n // For now lets use hardcoded size to assess current element to paginate on\n const startIndex = getIndexFromScrollPosition(measurementPos);\n let bufferedIndex = Math.max(startIndex - bufferCount, 0);\n\n if (onCalculateIndex) {\n // User has chance to intervene/customize prior to render\n // They may want to normalize this value.\n bufferedIndex = onCalculateIndex(bufferedIndex);\n }\n\n // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n\n if (virtualizerStartIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n // due to virtualizerStartIndex invalidation.\n flushSync(() => {\n batchUpdateNewIndex(newStartIndex);\n });\n }\n },\n {\n root: intersectionObserverRoot ? intersectionObserverRoot?.current : null,\n rootMargin: '0px',\n threshold: 0,\n },\n );\n\n const findIndexRecursive = (scrollPos: number, lowIndex: number, highIndex: number): number => {\n if (lowIndex > highIndex) {\n // We shouldn't get here - but no-op the index if we do.\n return virtualizerStartIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */\n return midpoint;\n }\n\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n\n const getIndexFromSizeArray = (scrollPos: number): number => {\n /* Quick searches our progressive height array */\n if (\n scrollPos === 0 ||\n childProgressiveSizes.current.length === 0 ||\n scrollPos <= childProgressiveSizes.current[0]\n ) {\n // Check start\n return 0;\n }\n\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n\n const getIndexFromScrollPosition = (scrollPos: number) => {\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n\n return getIndexFromSizeArray(scrollPos);\n };\n\n const calculateTotalSize = () => {\n if (!getItemSize) {\n return itemSize * numItems;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n };\n\n const calculateBefore = () => {\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return virtualizerStartIndex * itemSize;\n }\n\n if (virtualizerStartIndex <= 0) {\n return 0;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[virtualizerStartIndex - 1];\n };\n\n const calculateAfter = () => {\n if (numItems === 0) {\n return 0;\n }\n\n const lastItemIndex = Math.min(virtualizerStartIndex + virtualizerLength, numItems - 1);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex - 1;\n return remainingItems * itemSize;\n }\n\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex];\n };\n\n const updateChildRows = (newIndex: number) => {\n if (numItems === 0) {\n /* Nothing to virtualize */\n\n return [];\n }\n\n if (childArray.current.length !== numItems) {\n childArray.current = new Array(virtualizerLength);\n }\n const actualIndex = Math.max(newIndex, 0);\n const end = Math.min(actualIndex + virtualizerLength, numItems);\n\n for (let i = actualIndex; i < end; i++) {\n childArray.current[i - actualIndex] = renderChild(i);\n }\n };\n\n const setBeforeRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || beforeElementRef.current === element) {\n return;\n }\n beforeElementRef.current = element;\n const newList = [];\n\n newList.push(beforeElementRef.current);\n\n if (afterElementRef.current) {\n newList.push(afterElementRef.current);\n }\n\n // Ensure we update array if before element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const setAfterRef = useCallback(\n (element: HTMLDivElement) => {\n if (!element || afterElementRef.current === element) {\n return;\n }\n afterElementRef.current = element;\n const newList = [];\n\n if (beforeElementRef.current) {\n newList.push(beforeElementRef.current);\n }\n\n newList.push(afterElementRef.current);\n\n // Ensure we update array if after element changed\n setObserverList(newList);\n },\n [setObserverList],\n );\n\n const updateCurrentItemSizes = (newIndex: number) => {\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n\n let didUpdate = false;\n for (let i = startIndex; i < endIndex; i++) {\n const newSize = getItemSize(i);\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n\n if (didUpdate) {\n // Update our progressive size array\n for (let i = startIndex; i < numItems; i++) {\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n };\n\n // Initialize the size array before first render.\n const hasInitialized = useRef<boolean>(false);\n const initializeSizeArray = () => {\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(() => {\n if (virtualizerStartIndex < 0) {\n batchUpdateNewIndex(0);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // If the user passes in an updated renderChild function - update current children\n useEffect(() => {\n if (virtualizerStartIndex >= 0) {\n updateChildRows(virtualizerStartIndex);\n forceUpdate();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild]);\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 const isFullyInitialized = hasInitialized.current && virtualizerStartIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div',\n },\n virtualizedChildren: childArray.current,\n before: resolveShorthand(props.before, {\n required: true,\n defaultProps: {\n ref: setBeforeRef,\n role: 'none',\n },\n }),\n after: resolveShorthand(props.after, {\n required: true,\n defaultProps: {\n ref: setAfterRef,\n role: 'none',\n },\n }),\n beforeContainer: resolveShorthand(props.beforeContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n afterContainer: resolveShorthand(props.afterContainer, {\n required: true,\n defaultProps: {\n role: 'none',\n },\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex,\n axis,\n bufferSize,\n reversed,\n };\n}\n"],"mappings":";;;;;;AAAA,MAAAA,yBAAA,gBAAAC,OAAA;AAEA,MAAAC,OAAA,gBAAAD,OAAA;AAGA,MAAAE,iBAAA,gBAAAF,OAAA;AACA,MAAAG,WAAA,gBAAAH,OAAA;AAEA,SAAgBI,uBAAuBA,CAACC,KAAuB;EAC7D,MAAM;IACJC,QAAQ;IACRC,QAAQ;IACRC,iBAAiB;IACjBC,QAAQ,EAAEC,WAAW;IACrBC,WAAW;IACXC,WAAW,GAAGC,IAAI,CAACC,KAAK,CAACN,iBAAiB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,UAAU;IACVI;GACD;AACH;AAlbAuG,OAAA,CAAAtH,uBAAA,GAAAA,uBAAA"}
|
|
1
|
+
{"version":3,"sources":["../../../lib/components/Virtualizer/useVirtualizer.js"],"sourcesContent":["import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';\nimport { useEffect, useRef, useState, useCallback, useReducer } from 'react';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { flushSync } from 'react-dom';\nexport function useVirtualizer_unstable(props) {\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 intersectionObserverRoot,\n axis = 'vertical',\n reversed = false,\n onUpdateIndex,\n onCalculateIndex\n } = props;\n // Tracks the initial item to start virtualizer at, -1 implies first render cycle\n const [virtualizerStartIndex, setVirtualizerStartIndex] = useState(-1);\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 */\n const childProgressiveSizes = useRef(new Array(getItemSize ? numItems : 0));\n // The internal tracking REF for child array (updates often).\n const childArray = useRef(new Array(virtualizerLength));\n // We want to be methodical about updating the render with child reference array\n const forceUpdate = useReducer(() => ({}), {})[1];\n const horizontal = axis === 'horizontal';\n const populateSizeArrays = () => {\n if (!getItemSize) {\n // Static sizes, never mind!\n return;\n }\n if (numItems !== childSizes.current.length) {\n childSizes.current = new Array(numItems);\n }\n if (numItems !== childProgressiveSizes.current.length) {\n childProgressiveSizes.current = new Array(numItems);\n }\n for (let index = 0; index < numItems; index++) {\n childSizes.current[index] = getItemSize(index);\n if (index === 0) {\n childProgressiveSizes.current[index] = childSizes.current[index];\n } else {\n childProgressiveSizes.current[index] = childProgressiveSizes.current[index - 1] + childSizes.current[index];\n }\n }\n };\n const batchUpdateNewIndex = index => {\n // Local updates\n onUpdateIndex === null || onUpdateIndex === void 0 ? void 0 : onUpdateIndex(index, virtualizerStartIndex);\n updateChildRows(index);\n updateCurrentItemSizes(index);\n // State setters\n setVirtualizerStartIndex(index);\n };\n // Observe intersections of virtualized components\n const {\n setObserverList\n } = useIntersectionObserver((entries, observer) => {\n /* Sanity check - do we even need virtualization? */if (virtualizerLength > numItems) {\n if (virtualizerStartIndex !== 0) {\n batchUpdateNewIndex(0);\n }\n // No-op\n return;\n }\n /* IO initiates this function when needed (bookend entering view) */\n 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 let bufferedIndex = Math.max(startIndex - bufferCount, 0);\n if (onCalculateIndex) {\n // User has chance to intervene/customize prior to render\n // They may want to normalize this value.\n bufferedIndex = onCalculateIndex(bufferedIndex);\n }\n // Safety limits\n const maxIndex = Math.max(numItems - virtualizerLength, 0);\n const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);\n if (virtualizerStartIndex !== newStartIndex) {\n // We flush sync this and perform an immediate state update\n // due to virtualizerStartIndex invalidation.\n flushSync(() => {\n batchUpdateNewIndex(newStartIndex);\n });\n }\n }, {\n root: intersectionObserverRoot ? intersectionObserverRoot === null || intersectionObserverRoot === void 0 ? void 0 : intersectionObserverRoot.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 virtualizerStartIndex;\n }\n const midpoint = Math.floor((lowIndex + highIndex) / 2);\n const iBefore = Math.max(midpoint - 1, 0);\n const iAfter = Math.min(midpoint + 1, childProgressiveSizes.current.length - 1);\n const indexValue = childProgressiveSizes.current[midpoint];\n const afterIndexValue = childProgressiveSizes.current[iAfter];\n const beforeIndexValue = childProgressiveSizes.current[iBefore];\n if (scrollPos <= afterIndexValue && scrollPos >= beforeIndexValue) {\n /* We've found our index - if we are exactly matching before/after index that's ok,\n better to reduce checks if it's right on the boundary. */\n return midpoint;\n }\n if (indexValue > scrollPos) {\n return findIndexRecursive(scrollPos, lowIndex, midpoint - 1);\n } else {\n return findIndexRecursive(scrollPos, midpoint + 1, highIndex);\n }\n };\n const getIndexFromSizeArray = scrollPos => {\n /* Quick searches our progressive height array */if (scrollPos === 0 || childProgressiveSizes.current.length === 0 || scrollPos <= childProgressiveSizes.current[0]) {\n // Check start\n return 0;\n }\n if (scrollPos >= childProgressiveSizes.current[childProgressiveSizes.current.length - 1]) {\n // Check end\n return childProgressiveSizes.current.length - 1;\n }\n return findIndexRecursive(scrollPos, 0, childProgressiveSizes.current.length - 1);\n };\n const getIndexFromScrollPosition = scrollPos => {\n if (!getItemSize) {\n return Math.round(scrollPos / itemSize);\n }\n return getIndexFromSizeArray(scrollPos);\n };\n const calculateTotalSize = () => {\n if (!getItemSize) {\n return itemSize * numItems;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1];\n };\n const calculateBefore = () => {\n if (!getItemSize) {\n // The missing items from before virtualization starts height\n return virtualizerStartIndex * itemSize;\n }\n if (virtualizerStartIndex <= 0) {\n return 0;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[virtualizerStartIndex - 1];\n };\n const calculateAfter = () => {\n if (numItems === 0) {\n return 0;\n }\n const lastItemIndex = Math.min(virtualizerStartIndex + virtualizerLength, numItems - 1);\n if (!getItemSize) {\n // The missing items from after virtualization ends height\n const remainingItems = numItems - lastItemIndex - 1;\n return remainingItems * itemSize;\n }\n // Time for custom size calcs\n return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex];\n };\n const updateChildRows = newIndex => {\n if (numItems === 0) {\n /* Nothing to virtualize */return [];\n }\n if (childArray.current.length !== numItems) {\n childArray.current = new Array(virtualizerLength);\n }\n const actualIndex = Math.max(newIndex, 0);\n const end = Math.min(actualIndex + virtualizerLength, numItems);\n for (let i = actualIndex; i < end; i++) {\n childArray.current[i - actualIndex] = renderChild(i);\n }\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 }, [setObserverList]);\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 }, [setObserverList]);\n const updateCurrentItemSizes = newIndex => {\n if (!getItemSize) {\n // Static sizes, not required.\n return;\n }\n // We should always call our size function on index change (only for the items that will be rendered)\n // This ensures we request the latest data for incoming items in case sizing has changed.\n const endIndex = Math.min(newIndex + virtualizerLength, numItems);\n const startIndex = Math.max(newIndex, 0);\n let didUpdate = false;\n for (let i = startIndex; i < endIndex; i++) {\n const newSize = getItemSize(i);\n if (newSize !== childSizes.current[i]) {\n childSizes.current[i] = newSize;\n didUpdate = true;\n }\n }\n if (didUpdate) {\n // Update our progressive size array\n for (let i = startIndex; i < numItems; i++) {\n const prevSize = i > 0 ? childProgressiveSizes.current[i - 1] : 0;\n childProgressiveSizes.current[i] = prevSize + childSizes.current[i];\n }\n }\n };\n // Initialize the size array before first render.\n const hasInitialized = useRef(false);\n const initializeSizeArray = () => {\n if (hasInitialized.current === false) {\n hasInitialized.current = true;\n populateSizeArrays();\n }\n };\n // Initialization on mount - update array index to 0 (ready state).\n // Only fire on mount (no deps).\n useEffect(() => {\n if (virtualizerStartIndex < 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 (virtualizerStartIndex >= 0) {\n updateChildRows(virtualizerStartIndex);\n forceUpdate();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [renderChild]);\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 const isFullyInitialized = hasInitialized.current && virtualizerStartIndex >= 0;\n return {\n components: {\n before: 'div',\n after: 'div',\n beforeContainer: 'div',\n afterContainer: 'div'\n },\n virtualizedChildren: childArray.current,\n before: resolveShorthand(props.before, {\n required: true,\n defaultProps: {\n ref: setBeforeRef,\n role: 'none'\n }\n }),\n after: resolveShorthand(props.after, {\n required: true,\n defaultProps: {\n ref: setAfterRef,\n role: 'none'\n }\n }),\n beforeContainer: resolveShorthand(props.beforeContainer, {\n required: true,\n defaultProps: {\n role: 'none'\n }\n }),\n afterContainer: resolveShorthand(props.afterContainer, {\n required: true,\n defaultProps: {\n role: 'none'\n }\n }),\n beforeBufferHeight: isFullyInitialized ? calculateBefore() : 0,\n afterBufferHeight: isFullyInitialized ? calculateAfter() : 0,\n totalVirtualizerHeight: isFullyInitialized ? calculateTotalSize() : virtualizerLength * itemSize,\n virtualizerStartIndex,\n axis,\n bufferSize,\n reversed\n };\n}\n//# sourceMappingURL=useVirtualizer.js.map"],"names":["useVirtualizer_unstable","props","itemSize","numItems","virtualizerLength","children","renderChild","getItemSize","bufferItems","Math","round","bufferSize","floor","intersectionObserverRoot","axis","reversed","onUpdateIndex","onCalculateIndex","virtualizerStartIndex","setVirtualizerStartIndex","useState","beforeElementRef","useRef","afterElementRef","childSizes","Array","childProgressiveSizes","childArray","forceUpdate","useReducer","horizontal","populateSizeArrays","current","length","index","batchUpdateNewIndex","updateChildRows","updateCurrentItemSizes","setObserverList","useIntersectionObserver","entries","observer","measurementPos","bufferCount","latestEntry","sort","entry1","entry2","time","find","entry","intersectionRatio","target","calculateAfter","calculateTotalSize","abs","boundingClientRect","bottom","top","right","left","calculateBefore","max","startIndex","getIndexFromScrollPosition","bufferedIndex","maxIndex","newStartIndex","min","flushSync","root","rootMargin","threshold","findIndexRecursive","scrollPos","lowIndex","highIndex","midpoint","iBefore","iAfter","indexValue","afterIndexValue","beforeIndexValue","getIndexFromSizeArray","lastItemIndex","remainingItems","newIndex","actualIndex","end","i","setBeforeRef","useCallback","element","newList","push","setAfterRef","endIndex","didUpdate","newSize","prevSize","hasInitialized","initializeSizeArray","useEffect","isFullyInitialized","components","before","after","beforeContainer","afterContainer","virtualizedChildren","resolveShorthand","required","defaultProps","ref","role","beforeBufferHeight","afterBufferHeight","totalVirtualizerHeight"],"mappings":";;;;+BAIgBA;;aAAAA;;yCAJwB;uBAC6B;gCACpC;0BACP;AACnB,SAASA,wBAAwBC,KAAK,EAAE;IAC7C,MAAM,EACJC,SAAQ,EACRC,SAAQ,EACRC,kBAAiB,EACjBC,UAAUC,YAAW,EACrBC,YAAW,EACXC,aAAcC,KAAKC,KAAK,CAACN,oBAAoB,KAAI,EACjDO,YAAaF,KAAKG,KAAK,CAACJ,cAAc,OAAON,SAAQ,EACrDW,yBAAwB,EACxBC,MAAO,WAAU,EACjBC,UAAW,KAAK,CAAA,EAChBC,cAAa,EACbC,iBAAgB,EACjB,GAAGhB;IACJ,iFAAiF;IACjF,MAAM,CAACiB,uBAAuBC,yBAAyB,GAAGC,IAAAA,eAAQ,EAAC,CAAC;IACpE,sCAAsC;IACtC,MAAMC,mBAAmBC,IAAAA,aAAM,EAAC,IAAI;IACpC,sCAAsC;IACtC,MAAMC,kBAAkBD,IAAAA,aAAM,EAAC,IAAI;IACnC,oGAAoG;IACpG,MAAME,aAAaF,IAAAA,aAAM,EAAC,IAAIG,MAAMlB,cAAcJ,WAAW,CAAC;IAC9D;kEACgE,GAChE,MAAMuB,wBAAwBJ,IAAAA,aAAM,EAAC,IAAIG,MAAMlB,cAAcJ,WAAW,CAAC;IACzE,6DAA6D;IAC7D,MAAMwB,aAAaL,IAAAA,aAAM,EAAC,IAAIG,MAAMrB;IACpC,gFAAgF;IAChF,MAAMwB,cAAcC,IAAAA,iBAAU,EAAC,IAAO,CAAA,CAAC,CAAA,GAAI,CAAC,EAAE,CAAC,EAAE;IACjD,MAAM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nCK,UAAU,IAAI;YACdC,cAAc;gBACZC,KAAKlB;gBACLmB,MAAM;YACR;QACF;QACAP,iBAAiBG,IAAAA,gCAAgB,EAAC7G,MAAM0G,eAAe,EAAE;YACvDI,UAAU,IAAI;YACdC,cAAc;gBACZE,MAAM;YACR;QACF;QACAN,gBAAgBE,IAAAA,gCAAgB,EAAC7G,MAAM2G,cAAc,EAAE;YACrDG,UAAU,IAAI;YACdC,cAAc;gBACZE,MAAM;YACR;QACF;QACAC,oBAAoBZ,qBAAqB1C,oBAAoB,CAAC;QAC9DuD,mBAAmBb,qBAAqBlD,mBAAmB,CAAC;QAC5DgE,wBAAwBd,qBAAqBjD,uBAAuBlD,oBAAoBF,QAAQ;QAChGgB;QACAJ;QACAH;QACAI;IACF;AACF,EACA,0CAA0C"}
|
|
@@ -1,115 +1,120 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
virtualizerClassNames: ()=>virtualizerClassNames,
|
|
13
|
+
useVirtualizerStyles_unstable: ()=>useVirtualizerStyles_unstable
|
|
5
14
|
});
|
|
6
|
-
|
|
7
|
-
const react_1 = /*#__PURE__*/require("@griffel/react");
|
|
15
|
+
const _react = require("@griffel/react");
|
|
8
16
|
const virtualizerClassName = 'fui-Virtualizer';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
const virtualizerClassNames = {
|
|
18
|
+
before: `${virtualizerClassName}__before`,
|
|
19
|
+
beforeContainer: `${virtualizerClassName}__beforeContainer`,
|
|
20
|
+
after: `${virtualizerClassName}__after`,
|
|
21
|
+
afterContainer: `${virtualizerClassName}__afterContainer`
|
|
14
22
|
};
|
|
15
|
-
const useStyles = /*#__PURE__*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const useStyles = /*#__PURE__*/ (0, _react["__styles"])({
|
|
24
|
+
base: {
|
|
25
|
+
mc9l5x: "ftgm304",
|
|
26
|
+
Bkecrkj: "f1aehjj5"
|
|
27
|
+
},
|
|
28
|
+
relative: {
|
|
29
|
+
qhf8xq: "f10pi13n"
|
|
30
|
+
},
|
|
31
|
+
horizontal: {
|
|
32
|
+
sshi5w: "fan4evk"
|
|
33
|
+
},
|
|
34
|
+
vertical: {
|
|
35
|
+
Bf4jedk: "f11qra4b"
|
|
36
|
+
}
|
|
29
37
|
}, {
|
|
30
|
-
|
|
38
|
+
d: [
|
|
39
|
+
".ftgm304{display:block;}",
|
|
40
|
+
".f1aehjj5{pointer-events:none;}",
|
|
41
|
+
".f10pi13n{position:relative;}",
|
|
42
|
+
".fan4evk{min-height:100%;}",
|
|
43
|
+
".f11qra4b{min-width:100%;}"
|
|
44
|
+
]
|
|
31
45
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
beforeBufferHeight
|
|
41
|
-
afterBufferHeight
|
|
42
|
-
bufferSize
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
state.afterContainer.style = {
|
|
108
|
-
height: horizontal ? 'auto' : afterHeightPx,
|
|
109
|
-
width: horizontal ? afterHeightPx : 'auto',
|
|
110
|
-
...state.afterContainer.style
|
|
111
|
-
};
|
|
112
|
-
return state;
|
|
113
|
-
};
|
|
114
|
-
exports.useVirtualizerStyles_unstable = useVirtualizerStyles_unstable;
|
|
46
|
+
const useVirtualizerStyles_unstable = (state)=>{
|
|
47
|
+
const styles = useStyles();
|
|
48
|
+
const { reversed , axis , beforeBufferHeight , afterBufferHeight , bufferSize } = state;
|
|
49
|
+
const horizontal = axis === 'horizontal';
|
|
50
|
+
state.before.className = (0, _react.mergeClasses)(virtualizerClassNames.before, styles.base, styles.relative, horizontal ? styles.horizontal : styles.vertical, state.before.className);
|
|
51
|
+
state.after.className = (0, _react.mergeClasses)(virtualizerClassNames.after, styles.base, styles.relative, horizontal ? styles.horizontal : styles.vertical, state.after.className);
|
|
52
|
+
state.beforeContainer.className = (0, _react.mergeClasses)(virtualizerClassNames.beforeContainer, styles.base, horizontal ? styles.horizontal : styles.vertical, state.beforeContainer.className);
|
|
53
|
+
state.afterContainer.className = (0, _react.mergeClasses)(virtualizerClassNames.afterContainer, styles.base, horizontal ? styles.horizontal : styles.vertical, state.afterContainer.className);
|
|
54
|
+
const beforeHeightPx = beforeBufferHeight + 'px';
|
|
55
|
+
const afterHeightPx = afterBufferHeight + 'px';
|
|
56
|
+
const beforeBufferHeightPx = beforeBufferHeight + bufferSize + 'px';
|
|
57
|
+
const afterBufferHeightPx = afterBufferHeight + bufferSize + 'px';
|
|
58
|
+
const bufferPx = bufferSize + 'px';
|
|
59
|
+
const beforeBuffer = {
|
|
60
|
+
// Column
|
|
61
|
+
...!reversed && !horizontal && {
|
|
62
|
+
marginBottom: `-${bufferPx}`
|
|
63
|
+
},
|
|
64
|
+
// Column-Reverse
|
|
65
|
+
...reversed && !horizontal && {
|
|
66
|
+
marginTop: `-${bufferPx}`
|
|
67
|
+
},
|
|
68
|
+
// Row
|
|
69
|
+
...!reversed && horizontal && {
|
|
70
|
+
marginLeft: `-${bufferPx}`
|
|
71
|
+
},
|
|
72
|
+
// Row-Reverse
|
|
73
|
+
...reversed && horizontal && {
|
|
74
|
+
marginRight: `-${bufferPx}`
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const afterBuffer = {
|
|
78
|
+
// Column
|
|
79
|
+
...!reversed && !horizontal && {
|
|
80
|
+
marginTop: `-${bufferPx}`
|
|
81
|
+
},
|
|
82
|
+
// Column-Reverse
|
|
83
|
+
...reversed && !horizontal && {
|
|
84
|
+
marginBottom: `-${bufferPx}`
|
|
85
|
+
},
|
|
86
|
+
// Row
|
|
87
|
+
...!reversed && horizontal && {
|
|
88
|
+
marginLeft: `-${bufferPx}`
|
|
89
|
+
},
|
|
90
|
+
// Row-Reverse
|
|
91
|
+
...reversed && horizontal && {
|
|
92
|
+
marginRight: `-${bufferPx}`
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
state.before.style = {
|
|
96
|
+
height: horizontal ? '100%' : beforeBufferHeightPx,
|
|
97
|
+
width: horizontal ? beforeBufferHeightPx : '100%',
|
|
98
|
+
...beforeBuffer,
|
|
99
|
+
...state.before.style
|
|
100
|
+
};
|
|
101
|
+
state.beforeContainer.style = {
|
|
102
|
+
height: horizontal ? 'auto' : beforeHeightPx,
|
|
103
|
+
width: horizontal ? beforeHeightPx : 'auto',
|
|
104
|
+
...state.beforeContainer.style
|
|
105
|
+
};
|
|
106
|
+
state.after.style = {
|
|
107
|
+
height: horizontal ? '100%' : afterBufferHeightPx,
|
|
108
|
+
width: horizontal ? afterBufferHeightPx : '100%',
|
|
109
|
+
...afterBuffer,
|
|
110
|
+
...state.after.style
|
|
111
|
+
};
|
|
112
|
+
state.afterContainer.style = {
|
|
113
|
+
height: horizontal ? 'auto' : afterHeightPx,
|
|
114
|
+
width: horizontal ? afterHeightPx : 'auto',
|
|
115
|
+
...state.afterContainer.style
|
|
116
|
+
};
|
|
117
|
+
return state;
|
|
118
|
+
}; //# sourceMappingURL=useVirtualizerStyles.js.map
|
|
119
|
+
|
|
115
120
|
//# sourceMappingURL=useVirtualizerStyles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../lib/components/Virtualizer/useVirtualizerStyles.js"],"sourcesContent":["import { __styles, 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 = /*#__PURE__*/__styles({\n base: {\n mc9l5x: \"ftgm304\",\n Bkecrkj: \"f1aehjj5\"\n },\n relative: {\n qhf8xq: \"f10pi13n\"\n },\n horizontal: {\n sshi5w: \"fan4evk\"\n },\n vertical: {\n Bf4jedk: \"f11qra4b\"\n }\n}, {\n d: [\".ftgm304{display:block;}\", \".f1aehjj5{pointer-events:none;}\", \".f10pi13n{position:relative;}\", \".fan4evk{min-height:100%;}\", \".f11qra4b{min-width:100%;}\"]\n});\n/**\n * Apply styling to the Virtualizer states\n */\nexport const useVirtualizerStyles_unstable = state => {\n const styles = useStyles();\n const {\n reversed,\n axis,\n beforeBufferHeight,\n afterBufferHeight,\n bufferSize\n } = 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 marginLeft: `-${bufferPx}`\n }),\n // Row-Reverse\n ...(reversed && horizontal && {\n marginRight: `-${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//# sourceMappingURL=useVirtualizerStyles.js.map"],"names":["virtualizerClassNames","useVirtualizerStyles_unstable","virtualizerClassName","before","beforeContainer","after","afterContainer","useStyles","__styles","base","mc9l5x","Bkecrkj","relative","qhf8xq","horizontal","sshi5w","vertical","Bf4jedk","d","state","styles","reversed","axis","beforeBufferHeight","afterBufferHeight","bufferSize","className","mergeClasses","beforeHeightPx","afterHeightPx","beforeBufferHeightPx","afterBufferHeightPx","bufferPx","beforeBuffer","marginBottom","marginTop","marginLeft","marginRight","afterBuffer","style","height","width"],"mappings":";;;;;;;;;;;IAEaA,qBAAqB,MAArBA;IA0BAC,6BAA6B,MAA7BA;;uBA5B0B;AACvC,MAAMC,uBAAuB;AACtB,MAAMF,wBAAwB;IACnCG,QAAQ,CAAC,EAAED,qBAAqB,QAAQ,CAAC;IACzCE,iBAAiB,CAAC,EAAEF,qBAAqB,iBAAiB,CAAC;IAC3DG,OAAO,CAAC,EAAEH,qBAAqB,OAAO,CAAC;IACvCI,gBAAgB,CAAC,EAAEJ,qBAAqB,gBAAgB,CAAC;AAC3D;AACA,MAAMK,YAAY,WAAW,GAAEC,IAAAA,kBAAQ,EAAC;IACtCC,MAAM;QACJC,QAAQ;QACRC,SAAS;IACX;IACAC,UAAU;QACRC,QAAQ;IACV;IACAC,YAAY;QACVC,QAAQ;IACV;IACAC,UAAU;QACRC,SAAS;IACX;AACF,GAAG;IACDC,GAAG;QAAC;QAA4B;QAAmC;QAAiC;QAA8B;KAA6B;AACjK;AAIO,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AAW;QACd,GAAGnB,MAAMd,KAAK,CAACkC,KAAK;IACtB;IACApB,MAAMb,cAAc,CAACiC,KAAK,GAAG;QAC3BC,QAAQ1B,aAAa,SAASe,aAAa;QAC3CY,OAAO3B,aAAae,gBAAgB,MAAM;QAC1C,GAAGV,MAAMb,cAAc,CAACiC,KAAK;IAC/B;IACA,OAAOpB;AACT,GACA,gDAAgD"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
|
6
|
+
_exportStar(require("./useIntersectionObserver"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
8
|
+
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/hooks/index.js"],"sourcesContent":["export * from './useIntersectionObserver';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,iCAAiC"}
|
|
@@ -1,59 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useIntersectionObserver", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>useIntersectionObserver
|
|
5
8
|
});
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
observer.current.disconnect();
|
|
49
|
-
}
|
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
11
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
|
12
|
+
const { useState , useRef } = _react;
|
|
13
|
+
const useIntersectionObserver = (callback, options)=>{
|
|
14
|
+
// export const useIntersectionObserver = (
|
|
15
|
+
// callback: IntersectionObserverCallback,
|
|
16
|
+
// options?: IntersectionObserverInit,
|
|
17
|
+
// ): [
|
|
18
|
+
// Dispatch<SetStateAction<Element[] | undefined>>,
|
|
19
|
+
// Dispatch<SetStateAction<IntersectionObserverInit | undefined>>,
|
|
20
|
+
// MutableRefObject<IntersectionObserver | undefined>,
|
|
21
|
+
// ] => {
|
|
22
|
+
const observer = useRef();
|
|
23
|
+
const [observerList, setObserverList] = useState();
|
|
24
|
+
const [observerInit, setObserverInit] = useState(options);
|
|
25
|
+
// Observer elements in passed in list and clean up previous list
|
|
26
|
+
// This effect is only triggered when observerList is updated
|
|
27
|
+
(0, _reactUtilities.useIsomorphicLayoutEffect)(()=>{
|
|
28
|
+
observer.current = new IntersectionObserver(callback, observerInit);
|
|
29
|
+
// If we have an instance of IO and a list with elements, observer the elements
|
|
30
|
+
if (observer.current && observerList && observerList.length > 0) {
|
|
31
|
+
observerList.forEach((element)=>{
|
|
32
|
+
var _observer_current;
|
|
33
|
+
(_observer_current = observer.current) === null || _observer_current === void 0 ? void 0 : _observer_current.observe(element);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// clean up previous elements being listened to
|
|
37
|
+
return ()=>{
|
|
38
|
+
if (observer.current) {
|
|
39
|
+
observer.current.disconnect();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}, [
|
|
43
|
+
observerList,
|
|
44
|
+
observerInit,
|
|
45
|
+
callback
|
|
46
|
+
]);
|
|
47
|
+
return {
|
|
48
|
+
setObserverList,
|
|
49
|
+
setObserverInit,
|
|
50
|
+
observer
|
|
50
51
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
setObserverList,
|
|
54
|
-
setObserverInit,
|
|
55
|
-
observer
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
exports.useIntersectionObserver = useIntersectionObserver;
|
|
52
|
+
}; //# sourceMappingURL=useIntersectionObserver.js.map
|
|
53
|
+
|
|
59
54
|
//# sourceMappingURL=useIntersectionObserver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/hooks/useIntersectionObserver.js"],"sourcesContent":["import * as React from 'react';\nimport { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nconst {\n useState,\n useRef\n} = React;\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 */\nexport const useIntersectionObserver = (callback, options) => {\n // export const useIntersectionObserver = (\n // callback: IntersectionObserverCallback,\n // options?: IntersectionObserverInit,\n // ): [\n // Dispatch<SetStateAction<Element[] | undefined>>,\n // Dispatch<SetStateAction<IntersectionObserverInit | undefined>>,\n // MutableRefObject<IntersectionObserver | undefined>,\n // ] => {\n const observer = useRef();\n const [observerList, setObserverList] = useState();\n const [observerInit, setObserverInit] = useState(options);\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 observer.current = new IntersectionObserver(callback, observerInit);\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 }, [observerList, observerInit, callback]);\n return {\n setObserverList,\n setObserverInit,\n observer\n };\n};\n//# sourceMappingURL=useIntersectionObserver.js.map"],"names":["useIntersectionObserver","useState","useRef","React","callback","options","observer","observerList","setObserverList","observerInit","setObserverInit","useIsomorphicLayoutEffect","current","IntersectionObserver","length","forEach","element","_observer_current","observe","disconnect"],"mappings":";;;;+BAeaA;;aAAAA;;;6DAfU;gCACmB;AAC1C,MAAM,EACJC,SAAQ,EACRC,OAAM,EACP,GAAGC;AAUG,MAAMH,0BAA0B,CAACI,UAAUC,UAAY;IAC5D,2CAA2C;IAC3C,4CAA4C;IAC5C,wCAAwC;IACxC,OAAO;IACP,qDAAqD;IACrD,oEAAoE;IACpE,wDAAwD;IACxD,SAAS;IACT,MAAMC,WAAWJ;IACjB,MAAM,CAACK,cAAcC,gBAAgB,GAAGP;IACxC,MAAM,CAACQ,cAAcC,gBAAgB,GAAGT,SAASI;IACjD,iEAAiE;IACjE,6DAA6D;IAC7DM,IAAAA,yCAAyB,EAAC,IAAM;QAC9BL,SAASM,OAAO,GAAG,IAAIC,qBAAqBT,UAAUK;QACtD,+EAA+E;QAC/E,IAAIH,SAASM,OAAO,IAAIL,gBAAgBA,aAAaO,MAAM,GAAG,GAAG;YAC/DP,aAAaQ,OAAO,CAACC,CAAAA,UAAW;gBAC9B,IAAIC;gBACHA,CAAAA,oBAAoBX,SAASM,OAAO,AAAD,MAAO,IAAI,IAAIK,sBAAsB,KAAK,IAAI,KAAK,IAAIA,kBAAkBC,OAAO,CAACF,QAAQ;YAC/H;QACF,CAAC;QACD,+CAA+C;QAC/C,OAAO,IAAM;YACX,IAAIV,SAASM,OAAO,EAAE;gBACpBN,SAASM,OAAO,CAACO,UAAU;YAC7B,CAAC;QACH;IACF,GAAG;QAACZ;QAAcE;QAAcL;KAAS;IACzC,OAAO;QACLI;QACAE;QACAJ;IACF;AACF,GACA,mDAAmD"}
|