@fluentui/react-virtualizer 9.0.0-alpha.37 → 9.0.0-alpha.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +55 -1
- package/CHANGELOG.md +24 -2
- package/lib/components/Virtualizer/Virtualizer.js.map +1 -1
- package/lib/components/Virtualizer/renderVirtualizer.js +17 -7
- package/lib/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizer.js +4 -3
- package/lib/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizerStyles.styles.js.map +1 -1
- package/lib/components/VirtualizerScrollView/VirtualizerScrollView.js.map +1 -1
- package/lib/components/VirtualizerScrollView/renderVirtualizerScrollView.js +4 -2
- package/lib/components/VirtualizerScrollView/renderVirtualizerScrollView.js.map +1 -1
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js +2 -2
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js +4 -2
- package/lib/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +6 -5
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -1
- package/lib/hooks/useDynamicVirtualizerMeasure.js +4 -3
- package/lib/hooks/useDynamicVirtualizerMeasure.js.map +1 -1
- package/lib/hooks/useIntersectionObserver.js +1 -1
- package/lib/hooks/useIntersectionObserver.js.map +1 -1
- package/lib/hooks/useResizeObserverRef.js +8 -4
- package/lib/hooks/useResizeObserverRef.js.map +1 -1
- package/lib/hooks/useVirtualizerMeasure.js +5 -4
- package/lib/hooks/useVirtualizerMeasure.js.map +1 -1
- package/lib/utilities/ImperativeScrolling/imperativeScrolling.js +1 -1
- package/lib/utilities/ImperativeScrolling/imperativeScrolling.js.map +1 -1
- package/lib/utilities/ImperativeScrolling/imperativeScrollingDynamic.js +1 -1
- package/lib/utilities/ImperativeScrolling/imperativeScrollingDynamic.js.map +1 -1
- package/lib/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -1
- package/lib/utilities/debounce.js.map +1 -1
- package/lib-commonjs/Hooks.js +2 -2
- package/lib-commonjs/Hooks.js.map +1 -1
- package/lib-commonjs/Utilities.js +2 -2
- package/lib-commonjs/Utilities.js.map +1 -1
- package/lib-commonjs/Virtualizer.js +2 -2
- package/lib-commonjs/Virtualizer.js.map +1 -1
- package/lib-commonjs/VirtualizerScrollView.js +2 -2
- package/lib-commonjs/VirtualizerScrollView.js.map +1 -1
- package/lib-commonjs/VirtualizerScrollViewDynamic.js +2 -2
- package/lib-commonjs/VirtualizerScrollViewDynamic.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/Virtualizer.js +5 -3
- package/lib-commonjs/components/Virtualizer/Virtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/Virtualizer.types.js +2 -2
- package/lib-commonjs/components/Virtualizer/Virtualizer.types.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/index.js +6 -6
- package/lib-commonjs/components/Virtualizer/index.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/renderVirtualizer.js +27 -13
- package/lib-commonjs/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js +16 -13
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.styles.js +8 -4
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.js +7 -5
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/index.js +6 -6
- package/lib-commonjs/components/VirtualizerScrollView/index.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/renderVirtualizerScrollView.js +10 -6
- package/lib-commonjs/components/VirtualizerScrollView/renderVirtualizerScrollView.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js +13 -11
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js +10 -6
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js +7 -5
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js +6 -6
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js +10 -6
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +19 -16
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js +10 -6
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js.map +1 -1
- package/lib-commonjs/hooks/index.js +6 -6
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js +11 -8
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js.map +1 -1
- package/lib-commonjs/hooks/useIntersectionObserver.js +8 -6
- package/lib-commonjs/hooks/useIntersectionObserver.js.map +1 -1
- package/lib-commonjs/hooks/useResizeObserverRef.js +16 -10
- package/lib-commonjs/hooks/useResizeObserverRef.js.map +1 -1
- package/lib-commonjs/hooks/useVirtualizerMeasure.js +10 -7
- package/lib-commonjs/hooks/useVirtualizerMeasure.js.map +1 -1
- package/lib-commonjs/index.js +74 -28
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.js +4 -2
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.js.map +1 -1
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrollingDynamic.js +4 -2
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrollingDynamic.js.map +1 -1
- package/lib-commonjs/utilities/ImperativeScrolling/index.js +4 -4
- package/lib-commonjs/utilities/ImperativeScrolling/index.js.map +1 -1
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js +11 -5
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -1
- package/lib-commonjs/utilities/VirtualizerContext/index.js +3 -3
- package/lib-commonjs/utilities/VirtualizerContext/index.js.map +1 -1
- package/lib-commonjs/utilities/debounce.js +3 -1
- package/lib-commonjs/utilities/debounce.js.map +1 -1
- package/lib-commonjs/utilities/index.js +3 -3
- package/lib-commonjs/utilities/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -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
|
|
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;YACMA;QAAL,IAAI,GAACA,aAAAA,uBAAAA,iCAAAA,WAAWV,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,UACAC,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
|
3
|
-
const { useState
|
|
3
|
+
const { useState, useRef } = React;
|
|
4
4
|
/**
|
|
5
5
|
* React hook that allows easy usage of the browser API IntersectionObserver within React
|
|
6
6
|
* @param callback - A function called when the percentage of the target element is visible crosses a threshold.
|
|
@@ -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';\n\nconst { useState, useRef } = React;\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: Dispatch<SetStateAction<IntersectionObserverInit | undefined>>;\n observer: MutableRefObject<IntersectionObserver | undefined>;\n} => {\n const observer = useRef<IntersectionObserver>();\n const [observerList, setObserverList] = useState<Element[]>();\n const [observerInit, setObserverInit] = useState<IntersectionObserverInit | undefined>(options);\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 observer.current = new IntersectionObserver(callback, observerInit);\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]);\n\n return { setObserverList, setObserverInit, observer };\n};\n"],"names":["React","useIsomorphicLayoutEffect","useState","useRef","useIntersectionObserver","callback","options","observer","observerList","setObserverList","observerInit","setObserverInit","current","IntersectionObserver","length","forEach","element","observe","disconnect"],"mappings":"AACA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ,4BAA4B;AAEtE,MAAM,EAAEC,
|
|
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';\n\nconst { useState, useRef } = React;\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: Dispatch<SetStateAction<IntersectionObserverInit | undefined>>;\n observer: MutableRefObject<IntersectionObserver | undefined>;\n} => {\n const observer = useRef<IntersectionObserver>();\n const [observerList, setObserverList] = useState<Element[]>();\n const [observerInit, setObserverInit] = useState<IntersectionObserverInit | undefined>(options);\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 observer.current = new IntersectionObserver(callback, observerInit);\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]);\n\n return { setObserverList, setObserverInit, observer };\n};\n"],"names":["React","useIsomorphicLayoutEffect","useState","useRef","useIntersectionObserver","callback","options","observer","observerList","setObserverList","observerInit","setObserverInit","current","IntersectionObserver","length","forEach","element","observe","disconnect"],"mappings":"AACA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,yBAAyB,QAAQ,4BAA4B;AAEtE,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGH;AAE7B;;;;;;;;CAQC,GAED,OAAO,MAAMI,0BAA0B,CACrCC,UACAC;IAMA,MAAMC,WAAWJ;IACjB,MAAM,CAACK,cAAcC,gBAAgB,GAAGP;IACxC,MAAM,CAACQ,cAAcC,gBAAgB,GAAGT,SAA+CI;IAEvF,iEAAiE;IACjE,6DAA6D;IAC7DL,0BAA0B;QACxBM,SAASK,OAAO,GAAG,IAAIC,qBAAqBR,UAAUK;QAEtD,+EAA+E;QAC/E,IAAIH,SAASK,OAAO,IAAIJ,gBAAgBA,aAAaM,MAAM,GAAG,GAAG;YAC/DN,aAAaO,OAAO,CAACC,CAAAA;oBACnBT;iBAAAA,oBAAAA,SAASK,OAAO,cAAhBL,wCAAAA,kBAAkBU,OAAO,CAACD;YAC5B;QACF;QAEA,+CAA+C;QAC/C,OAAO;YACL,IAAIT,SAASK,OAAO,EAAE;gBACpBL,SAASK,OAAO,CAACM,UAAU;YAC7B;QACF;IACF,GAAG;QAACV;QAAcE;QAAcL;KAAS;IAEzC,OAAO;QAAEI;QAAiBE;QAAiBJ;IAAS;AACtD,EAAE"}
|
|
@@ -12,9 +12,10 @@ import { canUseDOM } from '@fluentui/react-utilities';
|
|
|
12
12
|
// Keep the reference of ResizeObserver in the state, as it should live through renders
|
|
13
13
|
const [resizeObserver, setResizeObserver] = React.useState(()=>canUseDOM() ? new ResizeObserver(handleResize) : undefined);
|
|
14
14
|
React.useEffect(()=>{
|
|
15
|
+
var _resizeObserver;
|
|
15
16
|
// Update our state when resizeCallback changes
|
|
16
17
|
container.current = null;
|
|
17
|
-
resizeObserver === null ||
|
|
18
|
+
(_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.disconnect();
|
|
18
19
|
setResizeObserver(canUseDOM() ? new ResizeObserver(handleResize) : undefined);
|
|
19
20
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
21
|
}, [
|
|
@@ -22,19 +23,22 @@ import { canUseDOM } from '@fluentui/react-utilities';
|
|
|
22
23
|
]);
|
|
23
24
|
React.useEffect(()=>{
|
|
24
25
|
return ()=>{
|
|
26
|
+
var _resizeObserver;
|
|
25
27
|
container.current = null;
|
|
26
|
-
resizeObserver === null ||
|
|
28
|
+
(_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.disconnect();
|
|
27
29
|
};
|
|
28
30
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
31
|
}, []);
|
|
30
32
|
const scrollRef = React.useCallback((instance)=>{
|
|
31
33
|
if (container.current !== instance) {
|
|
32
34
|
if (container.current) {
|
|
33
|
-
|
|
35
|
+
var _resizeObserver;
|
|
36
|
+
(_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.unobserve(container.current);
|
|
34
37
|
}
|
|
35
38
|
container.current = instance;
|
|
36
39
|
if (container.current) {
|
|
37
|
-
|
|
40
|
+
var _resizeObserver1;
|
|
41
|
+
(_resizeObserver1 = resizeObserver) === null || _resizeObserver1 === void 0 ? void 0 : _resizeObserver1.observe(container.current);
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useResizeObserverRef.ts"],"sourcesContent":["import * as React from 'react';\nimport { debounce } from '../utilities/debounce';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { ResizeCallbackWithRef } from './hooks.types';\n\n/**\n * useResizeObserverRef_unstable simplifies resize observer connection and ensures debounce/cleanup\n */\nexport const useResizeObserverRef_unstable = (resizeCallback: ResizeCallbackWithRef) => {\n const container = React.useRef<HTMLElement | null>(null);\n // the handler for resize observer\n const handleResize = debounce((entries: ResizeObserverEntry[], observer: ResizeObserver) => {\n resizeCallback(entries, observer, container);\n });\n\n // Keep the reference of ResizeObserver in the state, as it should live through renders\n const [resizeObserver, setResizeObserver] = React.useState(() =>\n canUseDOM() ? new ResizeObserver(handleResize) : undefined,\n );\n\n React.useEffect(() => {\n // Update our state when resizeCallback changes\n container.current = null;\n resizeObserver?.disconnect();\n setResizeObserver(canUseDOM() ? new ResizeObserver(handleResize) : undefined);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [resizeCallback]);\n\n React.useEffect(() => {\n return () => {\n 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","debounce","canUseDOM","useResizeObserverRef_unstable","resizeCallback","container","useRef","handleResize","entries","observer","resizeObserver","setResizeObserver","useState","ResizeObserver","undefined","useEffect","current","disconnect","scrollRef","useCallback","instance","unobserve","observe"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,SAAS,QAAQ,4BAA4B;AAGtD;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC
|
|
1
|
+
{"version":3,"sources":["useResizeObserverRef.ts"],"sourcesContent":["import * as React from 'react';\nimport { debounce } from '../utilities/debounce';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { ResizeCallbackWithRef } from './hooks.types';\n\n/**\n * useResizeObserverRef_unstable simplifies resize observer connection and ensures debounce/cleanup\n */\nexport const useResizeObserverRef_unstable = (resizeCallback: ResizeCallbackWithRef) => {\n const container = React.useRef<HTMLElement | null>(null);\n // the handler for resize observer\n const handleResize = debounce((entries: ResizeObserverEntry[], observer: ResizeObserver) => {\n resizeCallback(entries, observer, container);\n });\n\n // Keep the reference of ResizeObserver in the state, as it should live through renders\n const [resizeObserver, setResizeObserver] = React.useState(() =>\n canUseDOM() ? new ResizeObserver(handleResize) : undefined,\n );\n\n React.useEffect(() => {\n // Update our state when resizeCallback changes\n container.current = null;\n resizeObserver?.disconnect();\n setResizeObserver(canUseDOM() ? new ResizeObserver(handleResize) : undefined);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [resizeCallback]);\n\n React.useEffect(() => {\n return () => {\n 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","debounce","canUseDOM","useResizeObserverRef_unstable","resizeCallback","container","useRef","handleResize","entries","observer","resizeObserver","setResizeObserver","useState","ResizeObserver","undefined","useEffect","current","disconnect","scrollRef","useCallback","instance","unobserve","observe"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,SAAS,QAAQ,4BAA4B;AAGtD;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C,MAAMC,YAAYL,MAAMM,MAAM,CAAqB;IACnD,kCAAkC;IAClC,MAAMC,eAAeN,SAAS,CAACO,SAAgCC;QAC7DL,eAAeI,SAASC,UAAUJ;IACpC;IAEA,uFAAuF;IACvF,MAAM,CAACK,gBAAgBC,kBAAkB,GAAGX,MAAMY,QAAQ,CAAC,IACzDV,cAAc,IAAIW,eAAeN,gBAAgBO;IAGnDd,MAAMe,SAAS,CAAC;YAGdL;QAFA,+CAA+C;QAC/CL,UAAUW,OAAO,GAAG;SACpBN,kBAAAA,4BAAAA,sCAAAA,gBAAgBO,UAAU;QAC1BN,kBAAkBT,cAAc,IAAIW,eAAeN,gBAAgBO;IACnE,uDAAuD;IACzD,GAAG;QAACV;KAAe;IAEnBJ,MAAMe,SAAS,CAAC;QACd,OAAO;gBAELL;YADAL,UAAUW,OAAO,GAAG;aACpBN,kBAAAA,4BAAAA,sCAAAA,gBAAgBO,UAAU;QAC5B;IACA,uDAAuD;IACzD,GAAG,EAAE;IAEL,MAAMC,YAAYlB,MAAMmB,WAAW,CACjC,CAACC;QACC,IAAIf,UAAUW,OAAO,KAAKI,UAAU;YAClC,IAAIf,UAAUW,OAAO,EAAE;oBACrBN;iBAAAA,kBAAAA,4BAAAA,sCAAAA,gBAAgBW,SAAS,CAAChB,UAAUW,OAAO;YAC7C;YAEAX,UAAUW,OAAO,GAAGI;YACpB,IAAIf,UAAUW,OAAO,EAAE;oBACrBN;iBAAAA,mBAAAA,4BAAAA,uCAAAA,iBAAgBY,OAAO,CAACjB,UAAUW,OAAO;YAC3C;QACF;IACF,GACA;QAACN;KAAe;IAGlB,OAAOQ;AACT,EAAE"}
|
|
@@ -3,18 +3,19 @@ import { useResizeObserverRef_unstable } from './useResizeObserverRef';
|
|
|
3
3
|
/**
|
|
4
4
|
* React hook that measures virtualized space based on a static size to ensure optimized virtualization length.
|
|
5
5
|
*/ export const useStaticVirtualizerMeasure = (virtualizerProps)=>{
|
|
6
|
-
const { defaultItemSize
|
|
6
|
+
const { defaultItemSize, direction = 'vertical' } = virtualizerProps;
|
|
7
7
|
const [state, setState] = React.useState({
|
|
8
8
|
virtualizerLength: 0,
|
|
9
9
|
bufferSize: 0,
|
|
10
10
|
bufferItems: 0
|
|
11
11
|
});
|
|
12
|
-
const { virtualizerLength
|
|
12
|
+
const { virtualizerLength, bufferItems, bufferSize } = state;
|
|
13
13
|
const resizeCallback = React.useCallback((_entries, _observer, scrollRef)=>{
|
|
14
|
-
|
|
14
|
+
var _scrollRef, _scrollRef1, _scrollRef2;
|
|
15
|
+
if (!((_scrollRef = scrollRef) === null || _scrollRef === void 0 ? void 0 : _scrollRef.current)) {
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
|
-
const containerSize = direction === 'vertical' ? scrollRef === null ||
|
|
18
|
+
const containerSize = direction === 'vertical' ? (_scrollRef1 = scrollRef) === null || _scrollRef1 === void 0 ? void 0 : _scrollRef1.current.getBoundingClientRect().height : (_scrollRef2 = scrollRef) === null || _scrollRef2 === void 0 ? void 0 : _scrollRef2.current.getBoundingClientRect().width;
|
|
18
19
|
/*
|
|
19
20
|
* Number of items required to cover viewport.
|
|
20
21
|
*/ const length = Math.ceil(containerSize / defaultItemSize + 1);
|
|
@@ -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
|
|
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,UACAC,WACAC;YAEKA,YAMCA,aACAA;QAPN,IAAI,GAACA,aAAAA,uBAAAA,iCAAAA,WAAWC,OAAO,GAAE;YACvB;QACF;QAEA,MAAMC,gBACJb,cAAc,cACVW,cAAAA,uBAAAA,kCAAAA,YAAWC,OAAO,CAACE,qBAAqB,GAAGC,MAAM,IACjDJ,cAAAA,uBAAAA,kCAAAA,YAAWC,OAAO,CAACE,qBAAqB,GAAGE,KAAK;QAEtD;;OAEC,GACD,MAAMC,SAASC,KAAKC,IAAI,CAACN,gBAAgBd,kBAAkB;QAE3D;;OAEC,GACD,MAAMqB,iBAAiBF,KAAKG,GAAG,CAACH,KAAKI,KAAK,CAACL,SAAS,IAAI;QAExD;;OAEC,GACD,MAAMM,gBAAgBL,KAAKG,GAAG,CAACH,KAAKI,KAAK,CAAC,AAACL,SAAS,IAAKlB,kBAAkB;QAE3E,MAAMyB,cAAcP,SAASG,iBAAiB,IAAI;QAElDlB,SAAS;YACPE,mBAAmBoB;YACnBlB,aAAac;YACbf,YAAYkB;QACd;IACF,GACA;QAACxB;QAAiBC;KAAU;IAG9B,MAAMW,YAAYf,8BAA8BW;IAEhD,OAAO;QACLH;QACAE;QACAD;QACAM;IACF;AACF,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const scrollToItemStatic = (params)=>{
|
|
2
|
-
const { index
|
|
2
|
+
const { index, itemSize, totalItems, scrollViewRef, axis = 'vertical', reversed = false, behavior = 'auto' } = params;
|
|
3
3
|
if (axis === 'horizontal') {
|
|
4
4
|
if (reversed) {
|
|
5
5
|
var _scrollViewRef_current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["imperativeScrolling.ts"],"sourcesContent":["import { ScrollToItemStaticParams } from './imperativeScrolling.types';\n\nexport const scrollToItemStatic = (params: ScrollToItemStaticParams) => {\n const { index, itemSize, totalItems, scrollViewRef, axis = 'vertical', reversed = false, behavior = 'auto' } = params;\n\n if (axis === 'horizontal') {\n if (reversed) {\n scrollViewRef.current?.scrollTo({\n left: totalItems * itemSize - itemSize * index,\n behavior,\n });\n } else {\n scrollViewRef.current?.scrollTo({\n left: itemSize * index,\n behavior,\n });\n }\n } else {\n if (reversed) {\n scrollViewRef.current?.scrollTo({\n top: totalItems * itemSize - itemSize * index,\n behavior,\n });\n } else {\n scrollViewRef.current?.scrollTo({\n top: itemSize * index,\n behavior,\n });\n }\n }\n};\n"],"names":["scrollToItemStatic","params","index","itemSize","totalItems","scrollViewRef","axis","reversed","behavior","current","scrollTo","left","top"],"mappings":"AAEA,OAAO,MAAMA,qBAAqB,CAACC
|
|
1
|
+
{"version":3,"sources":["imperativeScrolling.ts"],"sourcesContent":["import { ScrollToItemStaticParams } from './imperativeScrolling.types';\n\nexport const scrollToItemStatic = (params: ScrollToItemStaticParams) => {\n const { index, itemSize, totalItems, scrollViewRef, axis = 'vertical', reversed = false, behavior = 'auto' } = params;\n\n if (axis === 'horizontal') {\n if (reversed) {\n scrollViewRef.current?.scrollTo({\n left: totalItems * itemSize - itemSize * index,\n behavior,\n });\n } else {\n scrollViewRef.current?.scrollTo({\n left: itemSize * index,\n behavior,\n });\n }\n } else {\n if (reversed) {\n scrollViewRef.current?.scrollTo({\n top: totalItems * itemSize - itemSize * index,\n behavior,\n });\n } else {\n scrollViewRef.current?.scrollTo({\n top: itemSize * index,\n behavior,\n });\n }\n }\n};\n"],"names":["scrollToItemStatic","params","index","itemSize","totalItems","scrollViewRef","axis","reversed","behavior","current","scrollTo","left","top"],"mappings":"AAEA,OAAO,MAAMA,qBAAqB,CAACC;IACjC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,aAAa,EAAEC,OAAO,UAAU,EAAEC,WAAW,KAAK,EAAEC,WAAW,MAAM,EAAE,GAAGP;IAE/G,IAAIK,SAAS,cAAc;QACzB,IAAIC,UAAU;gBACZF;aAAAA,yBAAAA,cAAcI,OAAO,cAArBJ,6CAAAA,uBAAuBK,QAAQ,CAAC;gBAC9BC,MAAMP,aAAaD,WAAWA,WAAWD;gBACzCM;YACF;QACF,OAAO;gBACLH;aAAAA,0BAAAA,cAAcI,OAAO,cAArBJ,8CAAAA,wBAAuBK,QAAQ,CAAC;gBAC9BC,MAAMR,WAAWD;gBACjBM;YACF;QACF;IACF,OAAO;QACL,IAAID,UAAU;gBACZF;aAAAA,0BAAAA,cAAcI,OAAO,cAArBJ,8CAAAA,wBAAuBK,QAAQ,CAAC;gBAC9BE,KAAKR,aAAaD,WAAWA,WAAWD;gBACxCM;YACF;QACF,OAAO;gBACLH;aAAAA,0BAAAA,cAAcI,OAAO,cAArBJ,8CAAAA,wBAAuBK,QAAQ,CAAC;gBAC9BE,KAAKT,WAAWD;gBAChBM;YACF;QACF;IACF;AACF,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const scrollToItemDynamic = (params)=>{
|
|
2
|
-
const { index
|
|
2
|
+
const { index, itemSizes, totalSize, scrollViewRef, axis = 'vertical', reversed = false, behavior = 'auto' } = params;
|
|
3
3
|
if (!itemSizes.current) {
|
|
4
4
|
return;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["imperativeScrollingDynamic.ts"],"sourcesContent":["import { ScrollToItemDynamicParams } from './imperativeScrolling.types';\n\nexport const scrollToItemDynamic = (params: ScrollToItemDynamicParams) => {\n const { index, itemSizes, totalSize, scrollViewRef, axis = 'vertical', reversed = false, behavior = 'auto' } = params;\n if (!itemSizes.current) {\n return;\n }\n\n if (itemSizes.current === null || itemSizes.current.length < index) {\n // null check - abort\n return;\n }\n\n let itemDepth = 0;\n for (let i = 0; i < index; i++) {\n if (i < index) {\n itemDepth += itemSizes.current[i];\n }\n }\n\n if (axis === 'horizontal') {\n if (reversed) {\n scrollViewRef.current?.scrollTo({\n left: totalSize - itemDepth,\n behavior,\n });\n } else {\n scrollViewRef.current?.scrollTo({\n left: itemDepth,\n behavior,\n });\n }\n } else {\n if (reversed) {\n scrollViewRef.current?.scrollTo({\n top: totalSize - itemDepth,\n behavior,\n });\n } else {\n scrollViewRef.current?.scrollTo({\n top: itemDepth,\n behavior,\n });\n }\n }\n};\n"],"names":["scrollToItemDynamic","params","index","itemSizes","totalSize","scrollViewRef","axis","reversed","behavior","current","length","itemDepth","i","scrollTo","left","top"],"mappings":"AAEA,OAAO,MAAMA,sBAAsB,CAACC
|
|
1
|
+
{"version":3,"sources":["imperativeScrollingDynamic.ts"],"sourcesContent":["import { ScrollToItemDynamicParams } from './imperativeScrolling.types';\n\nexport const scrollToItemDynamic = (params: ScrollToItemDynamicParams) => {\n const { index, itemSizes, totalSize, scrollViewRef, axis = 'vertical', reversed = false, behavior = 'auto' } = params;\n if (!itemSizes.current) {\n return;\n }\n\n if (itemSizes.current === null || itemSizes.current.length < index) {\n // null check - abort\n return;\n }\n\n let itemDepth = 0;\n for (let i = 0; i < index; i++) {\n if (i < index) {\n itemDepth += itemSizes.current[i];\n }\n }\n\n if (axis === 'horizontal') {\n if (reversed) {\n scrollViewRef.current?.scrollTo({\n left: totalSize - itemDepth,\n behavior,\n });\n } else {\n scrollViewRef.current?.scrollTo({\n left: itemDepth,\n behavior,\n });\n }\n } else {\n if (reversed) {\n scrollViewRef.current?.scrollTo({\n top: totalSize - itemDepth,\n behavior,\n });\n } else {\n scrollViewRef.current?.scrollTo({\n top: itemDepth,\n behavior,\n });\n }\n }\n};\n"],"names":["scrollToItemDynamic","params","index","itemSizes","totalSize","scrollViewRef","axis","reversed","behavior","current","length","itemDepth","i","scrollTo","left","top"],"mappings":"AAEA,OAAO,MAAMA,sBAAsB,CAACC;IAClC,MAAM,EAAEC,KAAK,EAAEC,SAAS,EAAEC,SAAS,EAAEC,aAAa,EAAEC,OAAO,UAAU,EAAEC,WAAW,KAAK,EAAEC,WAAW,MAAM,EAAE,GAAGP;IAC/G,IAAI,CAACE,UAAUM,OAAO,EAAE;QACtB;IACF;IAEA,IAAIN,UAAUM,OAAO,KAAK,QAAQN,UAAUM,OAAO,CAACC,MAAM,GAAGR,OAAO;QAClE,qBAAqB;QACrB;IACF;IAEA,IAAIS,YAAY;IAChB,IAAK,IAAIC,IAAI,GAAGA,IAAIV,OAAOU,IAAK;QAC9B,IAAIA,IAAIV,OAAO;YACbS,aAAaR,UAAUM,OAAO,CAACG,EAAE;QACnC;IACF;IAEA,IAAIN,SAAS,cAAc;QACzB,IAAIC,UAAU;gBACZF;aAAAA,yBAAAA,cAAcI,OAAO,cAArBJ,6CAAAA,uBAAuBQ,QAAQ,CAAC;gBAC9BC,MAAMV,YAAYO;gBAClBH;YACF;QACF,OAAO;gBACLH;aAAAA,0BAAAA,cAAcI,OAAO,cAArBJ,8CAAAA,wBAAuBQ,QAAQ,CAAC;gBAC9BC,MAAMH;gBACNH;YACF;QACF;IACF,OAAO;QACL,IAAID,UAAU;gBACZF;aAAAA,0BAAAA,cAAcI,OAAO,cAArBJ,8CAAAA,wBAAuBQ,QAAQ,CAAC;gBAC9BE,KAAKX,YAAYO;gBACjBH;YACF;QACF,OAAO;gBACLH;aAAAA,0BAAAA,cAAcI,OAAO,cAArBJ,8CAAAA,wBAAuBQ,QAAQ,CAAC;gBAC9BE,KAAKJ;gBACLH;YACF;QACF;IACF;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VirtualizerContext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { VirtualizerContextProps } from './types';\nimport { useMemo, useState } from 'react';\n\nconst VirtualizerContext = React.createContext<VirtualizerContextProps | undefined>(\n undefined,\n) as React.Context<VirtualizerContextProps>;\n\nexport const VirtualizerContextProvider = VirtualizerContext.Provider;\n\nexport const useVirtualizerContext_unstable = () => {\n return React.useContext(VirtualizerContext);\n};\n\nexport const useVirtualizerContextState_unstable = (\n passedContext?: VirtualizerContextProps,\n): VirtualizerContextProps => {\n const virtualizerContext = useVirtualizerContext_unstable();\n const [_contextIndex, _setContextIndex] = useState<number>(-1);\n\n /* We respect any wrapped providers while also ensuring defaults or passed through\n * Order of usage -> Passed Prop -> Provider Context -> Internal State default\n */\n const _context = useMemo(\n () => passedContext ?? virtualizerContext ?? { contextIndex: _contextIndex, setContextIndex: _setContextIndex },\n [_contextIndex, passedContext, virtualizerContext],\n );\n const context = useMemo(() => {\n return { contextIndex: _context.contextIndex, setContextIndex: _context.setContextIndex };\n }, [_context]);\n\n return context;\n};\n"],"names":["React","useMemo","useState","VirtualizerContext","createContext","undefined","VirtualizerContextProvider","Provider","useVirtualizerContext_unstable","useContext","useVirtualizerContextState_unstable","passedContext","virtualizerContext","_contextIndex","_setContextIndex","_context","contextIndex","setContextIndex","context"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAE1C,MAAMC,qBAAqBH,MAAMI,aAAa,CAC5CC;AAGF,OAAO,MAAMC,6BAA6BH,mBAAmBI,QAAQ,CAAC;AAEtE,OAAO,MAAMC,iCAAiC
|
|
1
|
+
{"version":3,"sources":["VirtualizerContext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { VirtualizerContextProps } from './types';\nimport { useMemo, useState } from 'react';\n\nconst VirtualizerContext = React.createContext<VirtualizerContextProps | undefined>(\n undefined,\n) as React.Context<VirtualizerContextProps>;\n\nexport const VirtualizerContextProvider = VirtualizerContext.Provider;\n\nexport const useVirtualizerContext_unstable = () => {\n return React.useContext(VirtualizerContext);\n};\n\nexport const useVirtualizerContextState_unstable = (\n passedContext?: VirtualizerContextProps,\n): VirtualizerContextProps => {\n const virtualizerContext = useVirtualizerContext_unstable();\n const [_contextIndex, _setContextIndex] = useState<number>(-1);\n\n /* We respect any wrapped providers while also ensuring defaults or passed through\n * Order of usage -> Passed Prop -> Provider Context -> Internal State default\n */\n const _context = useMemo(\n () => passedContext ?? virtualizerContext ?? { contextIndex: _contextIndex, setContextIndex: _setContextIndex },\n [_contextIndex, passedContext, virtualizerContext],\n );\n const context = useMemo(() => {\n return { contextIndex: _context.contextIndex, setContextIndex: _context.setContextIndex };\n }, [_context]);\n\n return context;\n};\n"],"names":["React","useMemo","useState","VirtualizerContext","createContext","undefined","VirtualizerContextProvider","Provider","useVirtualizerContext_unstable","useContext","useVirtualizerContextState_unstable","passedContext","virtualizerContext","_contextIndex","_setContextIndex","_context","contextIndex","setContextIndex","context"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAE1C,MAAMC,qBAAqBH,MAAMI,aAAa,CAC5CC;AAGF,OAAO,MAAMC,6BAA6BH,mBAAmBI,QAAQ,CAAC;AAEtE,OAAO,MAAMC,iCAAiC;IAC5C,OAAOR,MAAMS,UAAU,CAACN;AAC1B,EAAE;AAEF,OAAO,MAAMO,sCAAsC,CACjDC;IAEA,MAAMC,qBAAqBJ;IAC3B,MAAM,CAACK,eAAeC,iBAAiB,GAAGZ,SAAiB,CAAC;QAMpDS;IAJR;;GAEC,GACD,MAAMI,WAAWd,QACf,IAAMU,CAAAA,OAAAA,0BAAAA,2BAAAA,gBAAiBC,gCAAjBD,kBAAAA,OAAuC;YAAEK,cAAcH;YAAeI,iBAAiBH;QAAiB,GAC9G;QAACD;QAAeF;QAAeC;KAAmB;IAEpD,MAAMM,UAAUjB,QAAQ;QACtB,OAAO;YAAEe,cAAcD,SAASC,YAAY;YAAEC,iBAAiBF,SAASE,eAAe;QAAC;IAC1F,GAAG;QAACF;KAAS;IAEb,OAAOG;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["debounce.ts"],"sourcesContent":["/**\n * Microtask debouncer\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide\n * @param fn - Function to debounce\n * @returns debounced function\n */\nexport function debounce(fn: Function) {\n let pending: boolean;\n return () => {\n if (!pending) {\n pending = true;\n queueMicrotask(() => {\n // Need to set pending to `false` before the debounced function is run.\n // React can actually interrupt the function while it's running!\n pending = false;\n fn();\n });\n }\n };\n}\n"],"names":["debounce","fn","pending","queueMicrotask"],"mappings":"AAAA;;;;;CAKC,GACD,OAAO,SAASA,SAASC,EAAY
|
|
1
|
+
{"version":3,"sources":["debounce.ts"],"sourcesContent":["/**\n * Microtask debouncer\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide\n * @param fn - Function to debounce\n * @returns debounced function\n */\nexport function debounce(fn: Function) {\n let pending: boolean;\n return () => {\n if (!pending) {\n pending = true;\n queueMicrotask(() => {\n // Need to set pending to `false` before the debounced function is run.\n // React can actually interrupt the function while it's running!\n pending = false;\n fn();\n });\n }\n };\n}\n"],"names":["debounce","fn","pending","queueMicrotask"],"mappings":"AAAA;;;;;CAKC,GACD,OAAO,SAASA,SAASC,EAAY;IACnC,IAAIC;IACJ,OAAO;QACL,IAAI,CAACA,SAAS;YACZA,UAAU;YACVC,eAAe;gBACb,uEAAuE;gBACvE,gEAAgE;gBAChED,UAAU;gBACVD;YACF;QACF;IACF;AACF"}
|
package/lib-commonjs/Hooks.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
+
_export_star._(require("./hooks/index"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Hooks.js"],"sourcesContent":["export * from './hooks/index';\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["Hooks.js"],"sourcesContent":["export * from './hooks/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
+
_export_star._(require("./utilities/index"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Utilities.js"],"sourcesContent":["export * from './utilities/index';\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["Utilities.js"],"sourcesContent":["export * from './utilities/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
+
_export_star._(require("./components/Virtualizer/index"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Virtualizer.js"],"sourcesContent":["export * from './components/Virtualizer/index';\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["Virtualizer.js"],"sourcesContent":["export * from './components/Virtualizer/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
+
_export_star._(require("./components/VirtualizerScrollView/index"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VirtualizerScrollView.js"],"sourcesContent":["export * from './components/VirtualizerScrollView/index';\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["VirtualizerScrollView.js"],"sourcesContent":["export * from './components/VirtualizerScrollView/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
+
_export_star._(require("./components/VirtualizerScrollViewDynamic/index"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VirtualizerScrollViewDynamic.js"],"sourcesContent":["export * from './components/VirtualizerScrollViewDynamic/index';\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["VirtualizerScrollViewDynamic.js"],"sourcesContent":["export * from './components/VirtualizerScrollViewDynamic/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
|
|
@@ -4,14 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "Virtualizer", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return Virtualizer;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
11
|
+
const _useVirtualizerStylesstyles = require("./useVirtualizerStyles.styles");
|
|
10
12
|
const _useVirtualizer = require("./useVirtualizer");
|
|
11
13
|
const _renderVirtualizer = require("./renderVirtualizer");
|
|
12
14
|
const Virtualizer = (props)=>{
|
|
13
15
|
const state = (0, _useVirtualizer.useVirtualizer_unstable)(props);
|
|
14
|
-
(0,
|
|
16
|
+
(0, _useVirtualizerStylesstyles.useVirtualizerStyles_unstable)(state);
|
|
15
17
|
return (0, _renderVirtualizer.renderVirtualizer_unstable)(state);
|
|
16
18
|
};
|
|
17
19
|
Virtualizer.displayName = 'Virtualizer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Virtualizer.js"],"sourcesContent":["import { useVirtualizerStyles_unstable } from './useVirtualizerStyles.styles';\nimport { useVirtualizer_unstable } from './useVirtualizer';\nimport { renderVirtualizer_unstable } from './renderVirtualizer';\n/**\n * Virtualizer pseudo-component, this functional wrapper\n * provides a simple interface for reducing the total number\n * of elements rendered at one time in large lists.\n */ export const Virtualizer = (props)=>{\n const state = useVirtualizer_unstable(props);\n useVirtualizerStyles_unstable(state);\n return renderVirtualizer_unstable(state);\n};\nVirtualizer.displayName = 'Virtualizer';\n"],"names":["Virtualizer","props","state","useVirtualizer_unstable","useVirtualizerStyles_unstable","renderVirtualizer_unstable","displayName"],"mappings":";;;;+BAOiBA
|
|
1
|
+
{"version":3,"sources":["Virtualizer.js"],"sourcesContent":["import { useVirtualizerStyles_unstable } from './useVirtualizerStyles.styles';\nimport { useVirtualizer_unstable } from './useVirtualizer';\nimport { renderVirtualizer_unstable } from './renderVirtualizer';\n/**\n * Virtualizer pseudo-component, this functional wrapper\n * provides a simple interface for reducing the total number\n * of elements rendered at one time in large lists.\n */ export const Virtualizer = (props)=>{\n const state = useVirtualizer_unstable(props);\n useVirtualizerStyles_unstable(state);\n return renderVirtualizer_unstable(state);\n};\nVirtualizer.displayName = 'Virtualizer';\n"],"names":["Virtualizer","props","state","useVirtualizer_unstable","useVirtualizerStyles_unstable","renderVirtualizer_unstable","displayName"],"mappings":";;;;+BAOiBA;;;eAAAA;;;4CAP6B;gCACN;mCACG;AAKhC,MAAMA,cAAc,CAACC;IAC5B,MAAMC,QAAQC,IAAAA,uCAAuB,EAACF;IACtCG,IAAAA,yDAA6B,EAACF;IAC9B,OAAOG,IAAAA,6CAA0B,EAACH;AACtC;AACAF,YAAYM,WAAW,GAAG"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const
|
|
6
|
-
const _react = /*#__PURE__*/
|
|
5
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
6
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Virtualizer.types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["Virtualizer.types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;iEAAuB"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
+
_export_star._(require("./Virtualizer"), exports);
|
|
7
|
+
_export_star._(require("./Virtualizer.types"), exports);
|
|
8
|
+
_export_star._(require("./useVirtualizer"), exports);
|
|
9
|
+
_export_star._(require("./renderVirtualizer"), exports);
|
|
10
|
+
_export_star._(require("./useVirtualizerStyles.styles"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './Virtualizer';\nexport * from './Virtualizer.types';\nexport * from './useVirtualizer';\nexport * from './renderVirtualizer';\nexport * from './useVirtualizerStyles.styles';\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './Virtualizer';\nexport * from './Virtualizer.types';\nexport * from './useVirtualizer';\nexport * from './renderVirtualizer';\nexport * from './useVirtualizerStyles.styles';\n"],"names":[],"mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @jsxRuntime
|
|
1
|
+
/** @jsxRuntime automatic */ /** @jsxImportSource @fluentui/react-jsx-runtime */ "use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
@@ -9,20 +9,34 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
renderVirtualizer_unstable: ()
|
|
13
|
-
|
|
12
|
+
renderVirtualizer_unstable: function() {
|
|
13
|
+
return renderVirtualizer_unstable;
|
|
14
|
+
},
|
|
15
|
+
renderVirtualizerChildPlaceholder: function() {
|
|
16
|
+
return renderVirtualizerChildPlaceholder;
|
|
17
|
+
}
|
|
14
18
|
});
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
20
|
+
const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
|
|
21
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
22
|
+
const _reactutilities = require("@fluentui/react-utilities");
|
|
19
23
|
const renderVirtualizer_unstable = (state)=>{
|
|
20
|
-
(0,
|
|
21
|
-
return /*#__PURE__*/ (0,
|
|
24
|
+
(0, _reactutilities.assertSlots)(state);
|
|
25
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
|
|
26
|
+
children: [
|
|
27
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(state.beforeContainer, {
|
|
28
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.before, {})
|
|
29
|
+
}),
|
|
30
|
+
state.virtualizedChildren,
|
|
31
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(state.afterContainer, {
|
|
32
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.after, {})
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
});
|
|
22
36
|
};
|
|
23
37
|
const renderVirtualizerChildPlaceholder = (child, index)=>{
|
|
24
|
-
return /*#__PURE__*/ (0,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
38
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_react.Suspense, {
|
|
39
|
+
fallback: null,
|
|
40
|
+
children: child
|
|
41
|
+
}, `fui-virtualizer-placeholder-${index}`);
|
|
28
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["renderVirtualizer.js"],"sourcesContent":["/** @jsxRuntime
|
|
1
|
+
{"version":3,"sources":["renderVirtualizer.js"],"sourcesContent":["/** @jsxRuntime automatic */ /** @jsxImportSource @fluentui/react-jsx-runtime */ import { jsx as _jsx, jsxs as _jsxs } from \"@fluentui/react-jsx-runtime/jsx-runtime\";\nimport * as React from 'react';\nimport { assertSlots } from '@fluentui/react-utilities';\nexport const renderVirtualizer_unstable = (state)=>{\n assertSlots(state);\n return /*#__PURE__*/ _jsxs(React.Fragment, {\n children: [\n /*#__PURE__*/ _jsx(state.beforeContainer, {\n children: /*#__PURE__*/ _jsx(state.before, {})\n }),\n state.virtualizedChildren,\n /*#__PURE__*/ _jsx(state.afterContainer, {\n children: /*#__PURE__*/ _jsx(state.after, {})\n })\n ]\n });\n};\nexport const renderVirtualizerChildPlaceholder = (child, index)=>{\n return /*#__PURE__*/ _jsx(React.Suspense, {\n fallback: null,\n children: child\n }, `fui-virtualizer-placeholder-${index}`);\n};\n"],"names":["renderVirtualizer_unstable","renderVirtualizerChildPlaceholder","state","assertSlots","_jsxs","React","Fragment","children","_jsx","beforeContainer","before","virtualizedChildren","afterContainer","after","child","index","Suspense","fallback"],"mappings":"AAAA,0BAA0B,GAAG,iDAAiD;;;;;;;;;;;IAGjEA,0BAA0B;eAA1BA;;IAcAC,iCAAiC;eAAjCA;;;;4BAjB+G;iEACrG;gCACK;AACrB,MAAMD,6BAA6B,CAACE;IACvCC,IAAAA,2BAAW,EAACD;IACZ,OAAO,WAAW,GAAGE,IAAAA,gBAAK,EAACC,OAAMC,QAAQ,EAAE;QACvCC,UAAU;YACN,WAAW,GAAGC,IAAAA,eAAI,EAACN,MAAMO,eAAe,EAAE;gBACtCF,UAAU,WAAW,GAAGC,IAAAA,eAAI,EAACN,MAAMQ,MAAM,EAAE,CAAC;YAChD;YACAR,MAAMS,mBAAmB;YACzB,WAAW,GAAGH,IAAAA,eAAI,EAACN,MAAMU,cAAc,EAAE;gBACrCL,UAAU,WAAW,GAAGC,IAAAA,eAAI,EAACN,MAAMW,KAAK,EAAE,CAAC;YAC/C;SACH;IACL;AACJ;AACO,MAAMZ,oCAAoC,CAACa,OAAOC;IACrD,OAAO,WAAW,GAAGP,IAAAA,eAAI,EAACH,OAAMW,QAAQ,EAAE;QACtCC,UAAU;QACVV,UAAUO;IACd,GAAG,CAAC,4BAA4B,EAAEC,MAAM,CAAC;AAC7C"}
|
|
@@ -4,17 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "useVirtualizer_unstable", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return useVirtualizer_unstable;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _react = require("react");
|
|
10
12
|
const _useIntersectionObserver = require("../../hooks/useIntersectionObserver");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
+
const _reactdom = require("react-dom");
|
|
14
|
+
const _Utilities = require("../../Utilities");
|
|
13
15
|
const _renderVirtualizer = require("./renderVirtualizer");
|
|
14
|
-
const
|
|
16
|
+
const _reactutilities = require("@fluentui/react-utilities");
|
|
15
17
|
function useVirtualizer_unstable(props) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
var _scrollViewRef;
|
|
19
|
+
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;
|
|
20
|
+
/* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/ const _virtualizerContext = (0, _Utilities.useVirtualizerContextState_unstable)(virtualizerContext);
|
|
18
21
|
// We use this ref as a constant source to access the virtualizer's state imperatively
|
|
19
22
|
const actualIndexRef = (0, _react.useRef)(_virtualizerContext.contextIndex);
|
|
20
23
|
if (actualIndexRef.current !== _virtualizerContext.contextIndex) {
|
|
@@ -95,7 +98,7 @@ function useVirtualizer_unstable(props) {
|
|
|
95
98
|
setActualIndex(index);
|
|
96
99
|
};
|
|
97
100
|
// Observe intersections of virtualized components
|
|
98
|
-
const { setObserverList
|
|
101
|
+
const { setObserverList } = (0, _useIntersectionObserver.useIntersectionObserver)((entries, observer)=>{
|
|
99
102
|
/* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {
|
|
100
103
|
if (actualIndex !== 0) {
|
|
101
104
|
batchUpdateNewIndex(0);
|
|
@@ -164,12 +167,12 @@ function useVirtualizer_unstable(props) {
|
|
|
164
167
|
const newStartIndex = Math.min(Math.max(bufferedIndex, 0), maxIndex);
|
|
165
168
|
if (actualIndex !== newStartIndex) {
|
|
166
169
|
// We flush sync this and perform an immediate state update
|
|
167
|
-
(0,
|
|
170
|
+
(0, _reactdom.flushSync)(()=>{
|
|
168
171
|
batchUpdateNewIndex(newStartIndex);
|
|
169
172
|
});
|
|
170
173
|
}
|
|
171
174
|
}, {
|
|
172
|
-
root: scrollViewRef ? scrollViewRef === null ||
|
|
175
|
+
root: scrollViewRef ? (_scrollViewRef = scrollViewRef) === null || _scrollViewRef === void 0 ? void 0 : _scrollViewRef.current : null,
|
|
173
176
|
rootMargin: '0px',
|
|
174
177
|
threshold: 0
|
|
175
178
|
});
|
|
@@ -412,27 +415,27 @@ function useVirtualizer_unstable(props) {
|
|
|
412
415
|
afterContainer: 'div'
|
|
413
416
|
},
|
|
414
417
|
virtualizedChildren: childArray.current,
|
|
415
|
-
before:
|
|
418
|
+
before: _reactutilities.slot.always(props.before, {
|
|
416
419
|
defaultProps: {
|
|
417
420
|
ref: setBeforeRef,
|
|
418
421
|
role: 'none'
|
|
419
422
|
},
|
|
420
423
|
elementType: 'div'
|
|
421
424
|
}),
|
|
422
|
-
after:
|
|
425
|
+
after: _reactutilities.slot.always(props.after, {
|
|
423
426
|
defaultProps: {
|
|
424
427
|
ref: setAfterRef,
|
|
425
428
|
role: 'none'
|
|
426
429
|
},
|
|
427
430
|
elementType: 'div'
|
|
428
431
|
}),
|
|
429
|
-
beforeContainer:
|
|
432
|
+
beforeContainer: _reactutilities.slot.always(props.beforeContainer, {
|
|
430
433
|
defaultProps: {
|
|
431
434
|
role: 'none'
|
|
432
435
|
},
|
|
433
436
|
elementType: 'div'
|
|
434
437
|
}),
|
|
435
|
-
afterContainer:
|
|
438
|
+
afterContainer: _reactutilities.slot.always(props.afterContainer, {
|
|
436
439
|
defaultProps: {
|
|
437
440
|
role: 'none'
|
|
438
441
|
},
|