@fluentui/react-virtualizer 9.0.0-alpha.6 → 9.0.0-alpha.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +552 -2
- package/dist/index.d.ts +240 -30
- package/lib/Hooks.js +0 -1
- package/lib/Hooks.js.map +1 -1
- package/lib/Utilities.js +1 -0
- package/lib/Utilities.js.map +1 -0
- package/lib/Virtualizer.js +0 -1
- package/lib/Virtualizer.js.map +1 -1
- package/lib/VirtualizerScrollView.js +1 -0
- package/lib/VirtualizerScrollView.js.map +1 -0
- package/lib/VirtualizerScrollViewDynamic.js +1 -0
- package/lib/VirtualizerScrollViewDynamic.js.map +1 -0
- package/lib/components/Virtualizer/Virtualizer.js +5 -7
- package/lib/components/Virtualizer/Virtualizer.js.map +1 -1
- package/lib/components/Virtualizer/Virtualizer.types.js +1 -2
- package/lib/components/Virtualizer/Virtualizer.types.js.map +1 -1
- package/lib/components/Virtualizer/index.js +1 -2
- package/lib/components/Virtualizer/index.js.map +1 -1
- package/lib/components/Virtualizer/renderVirtualizer.js +21 -16
- package/lib/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizer.js +434 -355
- package/lib/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/{useVirtualizerStyles.js → useVirtualizerStyles.styles.js} +3 -3
- package/lib/components/Virtualizer/useVirtualizerStyles.styles.js.map +1 -0
- package/lib/components/VirtualizerScrollView/VirtualizerScrollView.js +12 -0
- package/lib/components/VirtualizerScrollView/VirtualizerScrollView.js.map +1 -0
- package/lib/components/VirtualizerScrollView/VirtualizerScrollView.types.js +1 -0
- package/lib/components/VirtualizerScrollView/VirtualizerScrollView.types.js.map +1 -0
- package/lib/components/VirtualizerScrollView/index.js +5 -0
- package/lib/components/VirtualizerScrollView/index.js.map +1 -0
- package/lib/components/VirtualizerScrollView/renderVirtualizerScrollView.js +9 -0
- package/lib/components/VirtualizerScrollView/renderVirtualizerScrollView.js.map +1 -0
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js +76 -0
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -0
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js +45 -0
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js +12 -0
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/index.js +5 -0
- package/lib/components/VirtualizerScrollViewDynamic/index.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js +9 -0
- package/lib/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +137 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js +45 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js.map +1 -0
- package/lib/hooks/hooks.types.js +1 -0
- package/lib/hooks/hooks.types.js.map +1 -0
- package/lib/hooks/index.js +4 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useDynamicVirtualizerMeasure.js +99 -0
- package/lib/hooks/useDynamicVirtualizerMeasure.js.map +1 -0
- package/lib/hooks/useIntersectionObserver.js +108 -40
- package/lib/hooks/useIntersectionObserver.js.map +1 -1
- package/lib/hooks/useMeasureList.js +101 -0
- package/lib/hooks/useMeasureList.js.map +1 -0
- package/lib/hooks/useMutationObserver.js +28 -0
- package/lib/hooks/useMutationObserver.js.map +1 -0
- package/lib/hooks/useResizeObserverRef.js +47 -0
- package/lib/hooks/useResizeObserverRef.js.map +1 -0
- package/lib/hooks/useVirtualizerMeasure.js +44 -0
- package/lib/hooks/useVirtualizerMeasure.js.map +1 -0
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/utilities/ImperativeScrolling/imperativeScrolling.js +32 -0
- package/lib/utilities/ImperativeScrolling/imperativeScrolling.js.map +1 -0
- package/lib/utilities/ImperativeScrolling/imperativeScrolling.types.js +1 -0
- package/lib/utilities/ImperativeScrolling/imperativeScrolling.types.js.map +1 -0
- package/lib/utilities/ImperativeScrolling/imperativeScrollingDynamic.js +45 -0
- package/lib/utilities/ImperativeScrolling/imperativeScrollingDynamic.js.map +1 -0
- package/lib/utilities/ImperativeScrolling/index.js +3 -0
- package/lib/utilities/ImperativeScrolling/index.js.map +1 -0
- package/lib/utilities/VirtualizerContext/VirtualizerContext.js +33 -0
- package/lib/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -0
- package/lib/utilities/VirtualizerContext/index.js +2 -0
- package/lib/utilities/VirtualizerContext/index.js.map +1 -0
- package/lib/utilities/VirtualizerContext/types.js +3 -0
- package/lib/utilities/VirtualizerContext/types.js.map +1 -0
- package/lib/utilities/createResizeObserverFromDocument.js +13 -0
- package/lib/utilities/createResizeObserverFromDocument.js.map +1 -0
- package/lib/utilities/debounce.js +19 -0
- package/lib/utilities/debounce.js.map +1 -0
- package/lib/utilities/index.js +2 -0
- package/lib/utilities/index.js.map +1 -0
- package/lib-commonjs/Hooks.js +3 -5
- package/lib-commonjs/Hooks.js.map +1 -1
- package/lib-commonjs/Utilities.js +6 -0
- package/lib-commonjs/Utilities.js.map +1 -0
- package/lib-commonjs/Virtualizer.js +3 -5
- package/lib-commonjs/Virtualizer.js.map +1 -1
- package/lib-commonjs/VirtualizerScrollView.js +6 -0
- package/lib-commonjs/VirtualizerScrollView.js.map +1 -0
- package/lib-commonjs/VirtualizerScrollViewDynamic.js +6 -0
- package/lib-commonjs/VirtualizerScrollViewDynamic.js.map +1 -0
- package/lib-commonjs/components/Virtualizer/Virtualizer.js +15 -18
- package/lib-commonjs/components/Virtualizer/Virtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/Virtualizer.types.js +3 -3
- package/lib-commonjs/components/Virtualizer/Virtualizer.types.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/index.js +7 -9
- package/lib-commonjs/components/Virtualizer/index.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/renderVirtualizer.js +38 -21
- package/lib-commonjs/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js +443 -361
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.styles.js +122 -0
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.styles.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.js +21 -0
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.types.js +4 -0
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.types.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollView/index.js +10 -0
- package/lib-commonjs/components/VirtualizerScrollView/index.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollView/renderVirtualizerScrollView.js +19 -0
- package/lib-commonjs/components/VirtualizerScrollView/renderVirtualizerScrollView.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js +86 -0
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js +69 -0
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js +21 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js +4 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js +10 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js +19 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +147 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js +69 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js.map +1 -0
- package/lib-commonjs/hooks/hooks.types.js +4 -0
- package/lib-commonjs/hooks/hooks.types.js.map +1 -0
- package/lib-commonjs/hooks/index.js +7 -5
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js +107 -0
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js.map +1 -0
- package/lib-commonjs/hooks/useIntersectionObserver.js +120 -53
- package/lib-commonjs/hooks/useIntersectionObserver.js.map +1 -1
- package/lib-commonjs/hooks/useMeasureList.js +108 -0
- package/lib-commonjs/hooks/useMeasureList.js.map +1 -0
- package/lib-commonjs/hooks/useMutationObserver.js +38 -0
- package/lib-commonjs/hooks/useMutationObserver.js.map +1 -0
- package/lib-commonjs/hooks/useResizeObserverRef.js +56 -0
- package/lib-commonjs/hooks/useResizeObserverRef.js.map +1 -0
- package/lib-commonjs/hooks/useVirtualizerMeasure.js +53 -0
- package/lib-commonjs/hooks/useVirtualizerMeasure.js.map +1 -0
- package/lib-commonjs/index.js +82 -41
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.js +42 -0
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.js.map +1 -0
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.types.js +4 -0
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.types.js.map +1 -0
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrollingDynamic.js +55 -0
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrollingDynamic.js.map +1 -0
- package/lib-commonjs/utilities/ImperativeScrolling/index.js +8 -0
- package/lib-commonjs/utilities/ImperativeScrolling/index.js.map +1 -0
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js +54 -0
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -0
- package/lib-commonjs/utilities/VirtualizerContext/index.js +7 -0
- package/lib-commonjs/utilities/VirtualizerContext/index.js.map +1 -0
- package/lib-commonjs/utilities/VirtualizerContext/types.js +6 -0
- package/lib-commonjs/utilities/VirtualizerContext/types.js.map +1 -0
- package/lib-commonjs/utilities/createResizeObserverFromDocument.js +23 -0
- package/lib-commonjs/utilities/createResizeObserverFromDocument.js.map +1 -0
- package/lib-commonjs/utilities/debounce.js +29 -0
- package/lib-commonjs/utilities/debounce.js.map +1 -0
- package/lib-commonjs/utilities/index.js +7 -0
- package/lib-commonjs/utilities/index.js.map +1 -0
- package/package.json +22 -12
- package/CHANGELOG.json +0 -95
- package/lib/components/Virtualizer/useVirtualizerStyles.js.map +0 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.js +0 -115
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useResizeObserverRef.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { debounce } from '../utilities/debounce';\nimport { createResizeObserverFromDocument } from '../utilities/createResizeObserverFromDocument';\nimport { ResizeCallbackWithRef } from './hooks.types';\n\n/**\n * useResizeObserverRef_unstable simplifies resize observer connection and ensures debounce/cleanup\n */\nexport const useResizeObserverRef_unstable = (resizeCallback: ResizeCallbackWithRef) => {\n const { targetDocument } = useFluent();\n const container = React.useRef<HTMLElement | null>(null);\n // the handler for resize observer\n const handleResize = debounce((entries: ResizeObserverEntry[], observer: ResizeObserver) => {\n resizeCallback(entries, observer, container);\n });\n\n // Keep the reference of ResizeObserver in the state, as it should live through renders\n const [resizeObserver, setResizeObserver] = React.useState(() =>\n createResizeObserverFromDocument(targetDocument, handleResize),\n );\n\n React.useEffect(() => {\n // Update our state when resizeCallback changes\n container.current = null;\n resizeObserver?.disconnect();\n setResizeObserver(() => createResizeObserverFromDocument(targetDocument, handleResize));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [resizeCallback, targetDocument]);\n\n React.useEffect(() => {\n return () => {\n container.current = null;\n resizeObserver?.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const scrollRef = React.useCallback(\n (instance: HTMLElement | HTMLDivElement | null) => {\n if (container.current !== instance) {\n if (container.current) {\n resizeObserver?.unobserve(container.current);\n }\n\n container.current = instance;\n if (container.current) {\n resizeObserver?.observe(container.current);\n }\n }\n },\n [resizeObserver],\n );\n\n return scrollRef;\n};\n"],"names":["React","useFluent_unstable","useFluent","debounce","createResizeObserverFromDocument","useResizeObserverRef_unstable","resizeCallback","targetDocument","container","useRef","handleResize","entries","observer","resizeObserver","setResizeObserver","useState","useEffect","current","disconnect","scrollRef","useCallback","instance","unobserve","observe"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,gCAAgC,QAAQ,gDAAgD;AAGjG;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5C,MAAM,EAAEC,cAAc,EAAE,GAAGL;IAC3B,MAAMM,YAAYR,MAAMS,MAAM,CAAqB;IACnD,kCAAkC;IAClC,MAAMC,eAAeP,SAAS,CAACQ,SAAgCC;QAC7DN,eAAeK,SAASC,UAAUJ;IACpC;IAEA,uFAAuF;IACvF,MAAM,CAACK,gBAAgBC,kBAAkB,GAAGd,MAAMe,QAAQ,CAAC,IACzDX,iCAAiCG,gBAAgBG;IAGnDV,MAAMgB,SAAS,CAAC;QACd,+CAA+C;QAC/CR,UAAUS,OAAO,GAAG;QACpBJ,2BAAAA,qCAAAA,eAAgBK,UAAU;QAC1BJ,kBAAkB,IAAMV,iCAAiCG,gBAAgBG;IACzE,uDAAuD;IACzD,GAAG;QAACJ;QAAgBC;KAAe;IAEnCP,MAAMgB,SAAS,CAAC;QACd,OAAO;YACLR,UAAUS,OAAO,GAAG;YACpBJ,2BAAAA,qCAAAA,eAAgBK,UAAU;QAC5B;IACA,uDAAuD;IACzD,GAAG,EAAE;IAEL,MAAMC,YAAYnB,MAAMoB,WAAW,CACjC,CAACC;QACC,IAAIb,UAAUS,OAAO,KAAKI,UAAU;YAClC,IAAIb,UAAUS,OAAO,EAAE;gBACrBJ,2BAAAA,qCAAAA,eAAgBS,SAAS,CAACd,UAAUS,OAAO;YAC7C;YAEAT,UAAUS,OAAO,GAAGI;YACpB,IAAIb,UAAUS,OAAO,EAAE;gBACrBJ,2BAAAA,qCAAAA,eAAgBU,OAAO,CAACf,UAAUS,OAAO;YAC3C;QACF;IACF,GACA;QAACJ;KAAe;IAGlB,OAAOM;AACT,EAAE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useResizeObserverRef_unstable } from './useResizeObserverRef';
|
|
3
|
+
/**
|
|
4
|
+
* React hook that measures virtualized space based on a static size to ensure optimized virtualization length.
|
|
5
|
+
*/ export const useStaticVirtualizerMeasure = (virtualizerProps)=>{
|
|
6
|
+
const { defaultItemSize, direction = 'vertical' } = virtualizerProps;
|
|
7
|
+
const [state, setState] = React.useState({
|
|
8
|
+
virtualizerLength: 0,
|
|
9
|
+
bufferSize: 0,
|
|
10
|
+
bufferItems: 0
|
|
11
|
+
});
|
|
12
|
+
const { virtualizerLength, bufferItems, bufferSize } = state;
|
|
13
|
+
const resizeCallback = React.useCallback((_entries, _observer, scrollRef)=>{
|
|
14
|
+
if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const containerSize = direction === 'vertical' ? scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.getBoundingClientRect().height : scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.getBoundingClientRect().width;
|
|
18
|
+
/*
|
|
19
|
+
* Number of items required to cover viewport.
|
|
20
|
+
*/ const length = Math.ceil(containerSize / defaultItemSize + 1);
|
|
21
|
+
/*
|
|
22
|
+
* Number of items to append at each end, i.e. 'preload' each side before entering view.
|
|
23
|
+
*/ const newBufferItems = Math.max(Math.floor(length / 4), 2);
|
|
24
|
+
/*
|
|
25
|
+
* This is how far we deviate into the bufferItems to detect a redraw.
|
|
26
|
+
*/ const newBufferSize = Math.max(Math.floor(length / 8 * defaultItemSize), 1);
|
|
27
|
+
const totalLength = length + newBufferItems * 2 + 1;
|
|
28
|
+
setState({
|
|
29
|
+
virtualizerLength: totalLength,
|
|
30
|
+
bufferItems: newBufferItems,
|
|
31
|
+
bufferSize: newBufferSize
|
|
32
|
+
});
|
|
33
|
+
}, [
|
|
34
|
+
defaultItemSize,
|
|
35
|
+
direction
|
|
36
|
+
]);
|
|
37
|
+
const scrollRef = useResizeObserverRef_unstable(resizeCallback);
|
|
38
|
+
return {
|
|
39
|
+
virtualizerLength,
|
|
40
|
+
bufferItems,
|
|
41
|
+
bufferSize,
|
|
42
|
+
scrollRef
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useVirtualizerMeasure.ts"],"sourcesContent":["import * as React from 'react';\nimport { VirtualizerMeasureProps } from './hooks.types';\nimport { useResizeObserverRef_unstable } from './useResizeObserverRef';\n\n/**\n * React hook that measures virtualized space based on a static size to ensure optimized virtualization length.\n */\nexport const useStaticVirtualizerMeasure = <TElement extends HTMLElement>(\n virtualizerProps: VirtualizerMeasureProps,\n): {\n virtualizerLength: number;\n bufferItems: number;\n bufferSize: number;\n scrollRef: (instance: TElement | null) => void;\n} => {\n const { defaultItemSize, direction = 'vertical' } = virtualizerProps;\n\n const [state, setState] = React.useState({\n virtualizerLength: 0,\n bufferSize: 0,\n bufferItems: 0,\n });\n\n const { virtualizerLength, bufferItems, bufferSize } = state;\n\n const resizeCallback = React.useCallback(\n (\n _entries: ResizeObserverEntry[],\n _observer: ResizeObserver,\n scrollRef?: React.MutableRefObject<HTMLElement | null>,\n ) => {\n if (!scrollRef?.current) {\n return;\n }\n\n const containerSize =\n direction === 'vertical'\n ? scrollRef?.current.getBoundingClientRect().height\n : scrollRef?.current.getBoundingClientRect().width;\n\n /*\n * Number of items required to cover viewport.\n */\n const length = Math.ceil(containerSize / defaultItemSize + 1);\n\n /*\n * Number of items to append at each end, i.e. 'preload' each side before entering view.\n */\n const newBufferItems = Math.max(Math.floor(length / 4), 2);\n\n /*\n * This is how far we deviate into the bufferItems to detect a redraw.\n */\n const newBufferSize = Math.max(Math.floor((length / 8) * defaultItemSize), 1);\n\n const totalLength = length + newBufferItems * 2 + 1;\n\n setState({\n virtualizerLength: totalLength,\n bufferItems: newBufferItems,\n bufferSize: newBufferSize,\n });\n },\n [defaultItemSize, direction],\n );\n\n const scrollRef = useResizeObserverRef_unstable(resizeCallback);\n\n return {\n virtualizerLength,\n bufferItems,\n bufferSize,\n scrollRef,\n };\n};\n"],"names":["React","useResizeObserverRef_unstable","useStaticVirtualizerMeasure","virtualizerProps","defaultItemSize","direction","state","setState","useState","virtualizerLength","bufferSize","bufferItems","resizeCallback","useCallback","_entries","_observer","scrollRef","current","containerSize","getBoundingClientRect","height","width","length","Math","ceil","newBufferItems","max","floor","newBufferSize","totalLength"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,6BAA6B,QAAQ,yBAAyB;AAEvE;;CAEC,GACD,OAAO,MAAMC,8BAA8B,CACzCC;IAOA,MAAM,EAAEC,eAAe,EAAEC,YAAY,UAAU,EAAE,GAAGF;IAEpD,MAAM,CAACG,OAAOC,SAAS,GAAGP,MAAMQ,QAAQ,CAAC;QACvCC,mBAAmB;QACnBC,YAAY;QACZC,aAAa;IACf;IAEA,MAAM,EAAEF,iBAAiB,EAAEE,WAAW,EAAED,UAAU,EAAE,GAAGJ;IAEvD,MAAMM,iBAAiBZ,MAAMa,WAAW,CACtC,CACEC,UACAC,WACAC;QAEA,IAAI,EAACA,sBAAAA,gCAAAA,UAAWC,OAAO,GAAE;YACvB;QACF;QAEA,MAAMC,gBACJb,cAAc,aACVW,sBAAAA,gCAAAA,UAAWC,OAAO,CAACE,qBAAqB,GAAGC,MAAM,GACjDJ,sBAAAA,gCAAAA,UAAWC,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"}
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { Virtualizer, virtualizerClassNames, useVirtualizer_unstable, renderVirtualizer_unstable, useVirtualizerStyles_unstable } from './Virtualizer';
|
|
2
|
-
export { useIntersectionObserver } from './Hooks';
|
|
3
|
-
|
|
2
|
+
export { useIntersectionObserver, useStaticVirtualizerMeasure, useDynamicVirtualizerMeasure, useResizeObserverRef_unstable } from './Hooks';
|
|
3
|
+
export { VirtualizerContextProvider, useVirtualizerContext_unstable, scrollToItemStatic, scrollToItemDynamic } from './Utilities';
|
|
4
|
+
export { VirtualizerScrollView, virtualizerScrollViewClassNames, useVirtualizerScrollView_unstable, renderVirtualizerScrollView_unstable, useVirtualizerScrollViewStyles_unstable } from './VirtualizerScrollView';
|
|
5
|
+
export { VirtualizerScrollViewDynamic, virtualizerScrollViewDynamicClassNames, useVirtualizerScrollViewDynamic_unstable, renderVirtualizerScrollViewDynamic_unstable, useVirtualizerScrollViewDynamicStyles_unstable } from './VirtualizerScrollViewDynamic';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n Virtualizer,\n virtualizerClassNames,\n useVirtualizer_unstable,\n renderVirtualizer_unstable,\n useVirtualizerStyles_unstable,\n} from './Virtualizer';\n\nexport type {\n VirtualizerProps,\n VirtualizerState,\n VirtualizerSlots,\n VirtualizerChildRenderFunction,\n VirtualizerDataRef,\n} from './Virtualizer';\n\nexport {\n useIntersectionObserver,\n useStaticVirtualizerMeasure,\n useDynamicVirtualizerMeasure,\n useResizeObserverRef_unstable,\n} from './Hooks';\n\nexport type { ResizeCallbackWithRef, VirtualizerMeasureDynamicProps, VirtualizerMeasureProps } from './Hooks';\n\nexport type { ScrollToItemDynamicParams, ScrollToItemStaticParams, ScrollToInterface } from './Utilities';\n\nexport {\n VirtualizerContextProvider,\n useVirtualizerContext_unstable,\n scrollToItemStatic,\n scrollToItemDynamic,\n} from './Utilities';\n\nexport type { VirtualizerContextProps } from './Utilities';\n\nexport {\n VirtualizerScrollView,\n virtualizerScrollViewClassNames,\n useVirtualizerScrollView_unstable,\n renderVirtualizerScrollView_unstable,\n useVirtualizerScrollViewStyles_unstable,\n} from './VirtualizerScrollView';\n\nexport type {\n VirtualizerScrollViewProps,\n VirtualizerScrollViewState,\n VirtualizerScrollViewSlots,\n} from './VirtualizerScrollView';\n\nexport {\n VirtualizerScrollViewDynamic,\n virtualizerScrollViewDynamicClassNames,\n useVirtualizerScrollViewDynamic_unstable,\n renderVirtualizerScrollViewDynamic_unstable,\n useVirtualizerScrollViewDynamicStyles_unstable,\n} from './VirtualizerScrollViewDynamic';\n\nexport type {\n VirtualizerScrollViewDynamicProps,\n VirtualizerScrollViewDynamicState,\n VirtualizerScrollViewDynamicSlots,\n} from './VirtualizerScrollViewDynamic';\n"],"names":["Virtualizer","virtualizerClassNames","useVirtualizer_unstable","renderVirtualizer_unstable","useVirtualizerStyles_unstable","useIntersectionObserver","useStaticVirtualizerMeasure","useDynamicVirtualizerMeasure","useResizeObserverRef_unstable","VirtualizerContextProvider","useVirtualizerContext_unstable","scrollToItemStatic","scrollToItemDynamic","VirtualizerScrollView","virtualizerScrollViewClassNames","useVirtualizerScrollView_unstable","renderVirtualizerScrollView_unstable","useVirtualizerScrollViewStyles_unstable","VirtualizerScrollViewDynamic","virtualizerScrollViewDynamicClassNames","useVirtualizerScrollViewDynamic_unstable","renderVirtualizerScrollViewDynamic_unstable","useVirtualizerScrollViewDynamicStyles_unstable"],"mappings":"AAAA,SACEA,WAAW,EACXC,qBAAqB,EACrBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,6BAA6B,QACxB,gBAAgB;AAUvB,SACEC,uBAAuB,EACvBC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,6BAA6B,QACxB,UAAU;AAMjB,SACEC,0BAA0B,EAC1BC,8BAA8B,EAC9BC,kBAAkB,EAClBC,mBAAmB,QACd,cAAc;AAIrB,SACEC,qBAAqB,EACrBC,+BAA+B,EAC/BC,iCAAiC,EACjCC,oCAAoC,EACpCC,uCAAuC,QAClC,0BAA0B;AAQjC,SACEC,4BAA4B,EAC5BC,sCAAsC,EACtCC,wCAAwC,EACxCC,2CAA2C,EAC3CC,8CAA8C,QACzC,iCAAiC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const scrollToItemStatic = (params)=>{
|
|
2
|
+
const { index, itemSize, totalItems, scrollViewRef, axis = 'vertical', reversed = false, behavior = 'auto' } = params;
|
|
3
|
+
if (axis === 'horizontal') {
|
|
4
|
+
if (reversed) {
|
|
5
|
+
var _scrollViewRef_current;
|
|
6
|
+
(_scrollViewRef_current = scrollViewRef.current) === null || _scrollViewRef_current === void 0 ? void 0 : _scrollViewRef_current.scrollTo({
|
|
7
|
+
left: totalItems * itemSize - itemSize * index,
|
|
8
|
+
behavior
|
|
9
|
+
});
|
|
10
|
+
} else {
|
|
11
|
+
var _scrollViewRef_current1;
|
|
12
|
+
(_scrollViewRef_current1 = scrollViewRef.current) === null || _scrollViewRef_current1 === void 0 ? void 0 : _scrollViewRef_current1.scrollTo({
|
|
13
|
+
left: itemSize * index,
|
|
14
|
+
behavior
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
if (reversed) {
|
|
19
|
+
var _scrollViewRef_current2;
|
|
20
|
+
(_scrollViewRef_current2 = scrollViewRef.current) === null || _scrollViewRef_current2 === void 0 ? void 0 : _scrollViewRef_current2.scrollTo({
|
|
21
|
+
top: totalItems * itemSize - itemSize * index,
|
|
22
|
+
behavior
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
var _scrollViewRef_current3;
|
|
26
|
+
(_scrollViewRef_current3 = scrollViewRef.current) === null || _scrollViewRef_current3 === void 0 ? void 0 : _scrollViewRef_current3.scrollTo({
|
|
27
|
+
top: itemSize * index,
|
|
28
|
+
behavior
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +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;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["imperativeScrolling.types.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nexport type ScrollToItemStaticParams = {\n index: number;\n itemSize: number;\n totalItems: number;\n scrollViewRef: RefObject<HTMLDivElement>;\n axis?: 'horizontal' | 'vertical';\n reversed?: boolean;\n behavior?: ScrollBehavior;\n};\n\nexport type ScrollToItemDynamicParams = {\n index: number;\n itemSizes: RefObject<number[]>;\n totalSize: number;\n scrollViewRef: RefObject<HTMLDivElement>;\n axis?: 'horizontal' | 'vertical';\n reversed?: boolean;\n behavior?: ScrollBehavior;\n};\n\nexport type ScrollToInterface = {\n scrollTo: (index: number, behavior?: ScrollBehavior, callback?: (index: number) => void) => void;\n virtualizerLength: RefObject<number>;\n currentIndex: RefObject<number> | undefined;\n};\n"],"names":[],"mappings":"AAAA,WA0BE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const scrollToItemDynamic = (params)=>{
|
|
2
|
+
const { index, itemSizes, totalSize, scrollViewRef, axis = 'vertical', reversed = false, behavior = 'auto' } = params;
|
|
3
|
+
if (!itemSizes.current) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
if (itemSizes.current === null || itemSizes.current.length < index) {
|
|
7
|
+
// null check - abort
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
let itemDepth = 0;
|
|
11
|
+
for(let i = 0; i < index; i++){
|
|
12
|
+
if (i < index) {
|
|
13
|
+
itemDepth += itemSizes.current[i];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (axis === 'horizontal') {
|
|
17
|
+
if (reversed) {
|
|
18
|
+
var _scrollViewRef_current;
|
|
19
|
+
(_scrollViewRef_current = scrollViewRef.current) === null || _scrollViewRef_current === void 0 ? void 0 : _scrollViewRef_current.scrollTo({
|
|
20
|
+
left: totalSize - itemDepth,
|
|
21
|
+
behavior
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
var _scrollViewRef_current1;
|
|
25
|
+
(_scrollViewRef_current1 = scrollViewRef.current) === null || _scrollViewRef_current1 === void 0 ? void 0 : _scrollViewRef_current1.scrollTo({
|
|
26
|
+
left: itemDepth,
|
|
27
|
+
behavior
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
if (reversed) {
|
|
32
|
+
var _scrollViewRef_current2;
|
|
33
|
+
(_scrollViewRef_current2 = scrollViewRef.current) === null || _scrollViewRef_current2 === void 0 ? void 0 : _scrollViewRef_current2.scrollTo({
|
|
34
|
+
top: totalSize - itemDepth,
|
|
35
|
+
behavior
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
var _scrollViewRef_current3;
|
|
39
|
+
(_scrollViewRef_current3 = scrollViewRef.current) === null || _scrollViewRef_current3 === void 0 ? void 0 : _scrollViewRef_current3.scrollTo({
|
|
40
|
+
top: itemDepth,
|
|
41
|
+
behavior
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -0,0 +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;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './imperativeScrolling';\nexport * from './imperativeScrolling.types';\nexport * from './imperativeScrollingDynamic';\n"],"names":[],"mappings":"AAAA,cAAc,wBAAwB;AACtC,cAAc,8BAA8B;AAC5C,cAAc,+BAA+B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
|
+
const VirtualizerContext = React.createContext(undefined);
|
|
4
|
+
export const VirtualizerContextProvider = VirtualizerContext.Provider;
|
|
5
|
+
export const useVirtualizerContext_unstable = ()=>{
|
|
6
|
+
return React.useContext(VirtualizerContext);
|
|
7
|
+
};
|
|
8
|
+
export const useVirtualizerContextState_unstable = (passedContext)=>{
|
|
9
|
+
const virtualizerContext = useVirtualizerContext_unstable();
|
|
10
|
+
const [_contextIndex, _setContextIndex] = useState(-1);
|
|
11
|
+
/* We respect any wrapped providers while also ensuring defaults or passed through
|
|
12
|
+
* Order of usage -> Passed Prop -> Provider Context -> Internal State default
|
|
13
|
+
*/ const _context = useMemo(()=>{
|
|
14
|
+
var _ref;
|
|
15
|
+
return (_ref = passedContext !== null && passedContext !== void 0 ? passedContext : virtualizerContext) !== null && _ref !== void 0 ? _ref : {
|
|
16
|
+
contextIndex: _contextIndex,
|
|
17
|
+
setContextIndex: _setContextIndex
|
|
18
|
+
};
|
|
19
|
+
}, [
|
|
20
|
+
_contextIndex,
|
|
21
|
+
passedContext,
|
|
22
|
+
virtualizerContext
|
|
23
|
+
]);
|
|
24
|
+
const context = useMemo(()=>{
|
|
25
|
+
return {
|
|
26
|
+
contextIndex: _context.contextIndex,
|
|
27
|
+
setContextIndex: _context.setContextIndex
|
|
28
|
+
};
|
|
29
|
+
}, [
|
|
30
|
+
_context
|
|
31
|
+
]);
|
|
32
|
+
return context;
|
|
33
|
+
};
|
|
@@ -0,0 +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;IAC5C,OAAOR,MAAMS,UAAU,CAACN;AAC1B,EAAE;AAEF,OAAO,MAAMO,sCAAsC,CACjDC;IAEA,MAAMC,qBAAqBJ;IAC3B,MAAM,CAACK,eAAeC,iBAAiB,GAAGZ,SAAiB,CAAC;IAE5D;;GAEC,GACD,MAAMa,WAAWd,QACf;YAAMU;eAAAA,CAAAA,OAAAA,0BAAAA,2BAAAA,gBAAiBC,gCAAjBD,kBAAAA,OAAuC;YAAEK,cAAcH;YAAeI,iBAAiBH;QAAiB;IAAA,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './VirtualizerContext';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["types.ts"],"sourcesContent":["/**\n * {@docCategory Virtualizer}\n */\nexport type VirtualizerContextProps = {\n contextIndex: number;\n setContextIndex: (index: number) => void;\n};\n"],"names":[],"mappings":"AAAA;;CAEC,GACD,WAGE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FIXME - TS 3.8/3.9 don't have ResizeObserver types by default, move this to a shared utility once we bump the minbar
|
|
3
|
+
* A utility method that creates a ResizeObserver from a target document
|
|
4
|
+
* @param targetDocument - document to use to create the ResizeObserver
|
|
5
|
+
* @param callback - https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/ResizeObserver#callback
|
|
6
|
+
* @returns a ResizeObserver instance or null if the global does not exist on the document
|
|
7
|
+
*/ export function createResizeObserverFromDocument(targetDocument, callback) {
|
|
8
|
+
var _targetDocument_defaultView;
|
|
9
|
+
if (!(targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.ResizeObserver)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return new targetDocument.defaultView.ResizeObserver(callback);
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["createResizeObserverFromDocument.ts"],"sourcesContent":["/**\n * FIXME - TS 3.8/3.9 don't have ResizeObserver types by default, move this to a shared utility once we bump the minbar\n * A utility method that creates a ResizeObserver from a target document\n * @param targetDocument - document to use to create the ResizeObserver\n * @param callback - https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/ResizeObserver#callback\n * @returns a ResizeObserver instance or null if the global does not exist on the document\n */\nexport function createResizeObserverFromDocument(\n targetDocument: Document | null | undefined,\n callback: ResizeObserverCallback,\n) {\n if (!targetDocument?.defaultView?.ResizeObserver) {\n return null;\n }\n\n return new targetDocument.defaultView.ResizeObserver(callback);\n}\n"],"names":["createResizeObserverFromDocument","targetDocument","callback","defaultView","ResizeObserver"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,SAASA,iCACdC,cAA2C,EAC3CC,QAAgC;QAE3BD;IAAL,IAAI,EAACA,2BAAAA,sCAAAA,8BAAAA,eAAgBE,WAAW,cAA3BF,kDAAAA,4BAA6BG,cAAc,GAAE;QAChD,OAAO;IACT;IAEA,OAAO,IAAIH,eAAeE,WAAW,CAACC,cAAc,CAACF;AACvD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Microtask debouncer
|
|
3
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide
|
|
4
|
+
* @param fn - Function to debounce
|
|
5
|
+
* @returns debounced function
|
|
6
|
+
*/ export function debounce(fn) {
|
|
7
|
+
let pending;
|
|
8
|
+
return ()=>{
|
|
9
|
+
if (!pending) {
|
|
10
|
+
pending = true;
|
|
11
|
+
queueMicrotask(()=>{
|
|
12
|
+
// Need to set pending to `false` before the debounced function is run.
|
|
13
|
+
// React can actually interrupt the function while it's running!
|
|
14
|
+
pending = false;
|
|
15
|
+
fn();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +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;IACnC,IAAIC;IACJ,OAAO;QACL,IAAI,CAACA,SAAS;YACZA,UAAU;YACVC,eAAe;gBACb,uEAAuE;gBACvE,gEAAgE;gBAChED,UAAU;gBACVD;YACF;QACF;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './VirtualizerContext';\nexport * from './ImperativeScrolling';\n"],"names":[],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,wBAAwB"}
|
package/lib-commonjs/Hooks.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=Hooks.js.map
|
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
+
_export_star._(require("./hooks/index"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["Hooks.js"],"sourcesContent":["export * from './hooks/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Utilities.js"],"sourcesContent":["export * from './utilities/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=Virtualizer.js.map
|
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
+
_export_star._(require("./components/Virtualizer/index"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["Virtualizer.js"],"sourcesContent":["export * from './components/Virtualizer/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["VirtualizerScrollView.js"],"sourcesContent":["export * from './components/VirtualizerScrollView/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["VirtualizerScrollViewDynamic.js"],"sourcesContent":["export * from './components/VirtualizerScrollViewDynamic/index';\n"],"names":[],"mappings":";;;;;uBAAc"}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const Virtualizer = props
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
Object.defineProperty(exports, "Virtualizer", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Virtualizer;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _useVirtualizerStylesstyles = require("./useVirtualizerStyles.styles");
|
|
12
|
+
const _useVirtualizer = require("./useVirtualizer");
|
|
13
|
+
const _renderVirtualizer = require("./renderVirtualizer");
|
|
14
|
+
const Virtualizer = (props)=>{
|
|
15
|
+
const state = (0, _useVirtualizer.useVirtualizer_unstable)(props);
|
|
16
|
+
(0, _useVirtualizerStylesstyles.useVirtualizerStyles_unstable)(state);
|
|
17
|
+
return (0, _renderVirtualizer.renderVirtualizer_unstable)(state);
|
|
19
18
|
};
|
|
20
|
-
|
|
21
|
-
exports.Virtualizer.displayName = 'Virtualizer';
|
|
22
|
-
//# sourceMappingURL=Virtualizer.js.map
|
|
19
|
+
Virtualizer.displayName = 'Virtualizer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
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,"
|
|
1
|
+
{"version":3,"sources":["Virtualizer.types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;iEAAuB"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
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,"
|
|
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,25 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
renderVirtualizer_unstable: function() {
|
|
13
|
+
return renderVirtualizer_unstable;
|
|
14
|
+
},
|
|
15
|
+
renderVirtualizerChildPlaceholder: function() {
|
|
16
|
+
return renderVirtualizerChildPlaceholder;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
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");
|
|
23
|
+
const renderVirtualizer_unstable = (state)=>{
|
|
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
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const renderVirtualizerChildPlaceholder = (child, index)=>{
|
|
38
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_react.Suspense, {
|
|
39
|
+
fallback: null,
|
|
40
|
+
children: child
|
|
41
|
+
}, `fui-virtualizer-placeholder-${index}`);
|
|
23
42
|
};
|
|
24
|
-
exports.renderVirtualizer_unstable = renderVirtualizer_unstable;
|
|
25
|
-
//# sourceMappingURL=renderVirtualizer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["renderVirtualizer.js"],"sourcesContent":[" 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":";;;;;;;;;;;IAGaA,0BAA0B;eAA1BA;;IAcAC,iCAAiC;eAAjCA;;;;4BAjBgC;iEACtB;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"}
|