@fluentui/react-virtualizer 9.0.0-alpha.11 → 9.0.0-alpha.111
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 +1047 -11
- package/README.md +2 -0
- package/dist/index.d.ts +417 -34
- package/lib/Hooks.js +1 -2
- package/lib/Hooks.js.map +1 -1
- package/lib/Utilities.js +1 -0
- package/lib/Utilities.js.map +1 -0
- package/lib/Virtualizer.js +1 -2
- 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 +10 -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 +4 -6
- package/lib/components/Virtualizer/index.js.map +1 -1
- package/lib/components/Virtualizer/renderVirtualizer.js +25 -16
- package/lib/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizer.js +529 -357
- package/lib/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/{useVirtualizerStyles.js → useVirtualizerStyles.styles.js} +11 -4
- package/lib/components/Virtualizer/useVirtualizerStyles.styles.js.map +1 -0
- package/lib/components/Virtualizer/useVirtualizerStyles.styles.raw.js +103 -0
- package/lib/components/Virtualizer/useVirtualizerStyles.styles.raw.js.map +1 -0
- package/lib/components/VirtualizerScrollView/VirtualizerScrollView.js +16 -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 +4 -0
- package/lib/components/VirtualizerScrollView/index.js.map +1 -0
- package/lib/components/VirtualizerScrollView/renderVirtualizerScrollView.js +11 -0
- package/lib/components/VirtualizerScrollView/renderVirtualizerScrollView.js.map +1 -0
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js +83 -0
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -0
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js +52 -0
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js.map +1 -0
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.raw.js +46 -0
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.raw.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js +18 -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 +4 -0
- package/lib/components/VirtualizerScrollViewDynamic/index.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js +11 -0
- package/lib/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +155 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js +52 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js.map +1 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.raw.js +46 -0
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.raw.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 +5 -2
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useDynamicPagination.js +128 -0
- package/lib/hooks/useDynamicPagination.js.map +1 -0
- package/lib/hooks/useDynamicVirtualizerMeasure.js +129 -0
- package/lib/hooks/useDynamicVirtualizerMeasure.js.map +1 -0
- package/lib/hooks/useIntersectionObserver.js +119 -40
- package/lib/hooks/useIntersectionObserver.js.map +1 -1
- package/lib/hooks/useMeasureList.js +130 -0
- package/lib/hooks/useMeasureList.js.map +1 -0
- package/lib/hooks/useMutationObserver.js +40 -0
- package/lib/hooks/useMutationObserver.js.map +1 -0
- package/lib/hooks/useResizeObserverRef.js +61 -0
- package/lib/hooks/useResizeObserverRef.js.map +1 -0
- package/lib/hooks/useStaticPagination.js +104 -0
- package/lib/hooks/useStaticPagination.js.map +1 -0
- package/lib/hooks/useVirtualizerMeasure.js +64 -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 +2 -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 +1 -0
- package/lib/utilities/VirtualizerContext/index.js.map +1 -0
- package/lib/utilities/VirtualizerContext/types.js +1 -0
- package/lib/utilities/VirtualizerContext/types.js.map +1 -0
- package/lib/utilities/createResizeObserverFromDocument.js +14 -0
- package/lib/utilities/createResizeObserverFromDocument.js.map +1 -0
- package/lib/utilities/debounce.js +20 -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 +31 -5
- package/lib-commonjs/Hooks.js.map +1 -1
- package/lib-commonjs/Utilities.js +28 -0
- package/lib-commonjs/Utilities.js.map +1 -0
- package/lib-commonjs/Virtualizer.js +28 -5
- package/lib-commonjs/Virtualizer.js.map +1 -1
- package/lib-commonjs/VirtualizerScrollView.js +28 -0
- package/lib-commonjs/VirtualizerScrollView.js.map +1 -0
- package/lib-commonjs/VirtualizerScrollViewDynamic.js +28 -0
- package/lib-commonjs/VirtualizerScrollViewDynamic.js.map +1 -0
- package/lib-commonjs/components/Virtualizer/Virtualizer.js +20 -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 +31 -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 +535 -362
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.styles.js +124 -0
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.styles.js.map +1 -0
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.styles.raw.js +116 -0
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.js +24 -0
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.types.js +6 -0
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.types.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollView/index.js +31 -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 +92 -0
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js +71 -0
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.raw.js +59 -0
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js +25 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js +6 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js +31 -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 +163 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js +71 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js.map +1 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.raw.js +59 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/hooks/hooks.types.js +6 -0
- package/lib-commonjs/hooks/hooks.types.js.map +1 -0
- package/lib-commonjs/hooks/index.js +35 -5
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useDynamicPagination.js +132 -0
- package/lib-commonjs/hooks/useDynamicPagination.js.map +1 -0
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js +134 -0
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js.map +1 -0
- package/lib-commonjs/hooks/useIntersectionObserver.js +129 -53
- package/lib-commonjs/hooks/useIntersectionObserver.js.map +1 -1
- package/lib-commonjs/hooks/useMeasureList.js +135 -0
- package/lib-commonjs/hooks/useMeasureList.js.map +1 -0
- package/lib-commonjs/hooks/useMutationObserver.js +48 -0
- package/lib-commonjs/hooks/useMutationObserver.js.map +1 -0
- package/lib-commonjs/hooks/useResizeObserverRef.js +69 -0
- package/lib-commonjs/hooks/useResizeObserverRef.js.map +1 -0
- package/lib-commonjs/hooks/useStaticPagination.js +108 -0
- package/lib-commonjs/hooks/useStaticPagination.js.map +1 -0
- package/lib-commonjs/hooks/useVirtualizerMeasure.js +70 -0
- package/lib-commonjs/hooks/useVirtualizerMeasure.js.map +1 -0
- package/lib-commonjs/index.js +85 -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 +6 -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 +20 -0
- package/lib-commonjs/utilities/ImperativeScrolling/index.js.map +1 -0
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js +49 -0
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -0
- package/lib-commonjs/utilities/VirtualizerContext/index.js +22 -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 +24 -0
- package/lib-commonjs/utilities/createResizeObserverFromDocument.js.map +1 -0
- package/lib-commonjs/utilities/debounce.js +30 -0
- package/lib-commonjs/utilities/debounce.js.map +1 -0
- package/lib-commonjs/utilities/index.js +29 -0
- package/lib-commonjs/utilities/index.js.map +1 -0
- package/package.json +18 -28
- package/CHANGELOG.json +0 -170
- 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":["../src/hooks/useResizeObserverRef.ts"],"sourcesContent":["'use client';\n\nimport * 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 * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport const useResizeObserverRef_unstable = (\n resizeCallback: ResizeCallbackWithRef,\n): ((instance: HTMLElement | HTMLDivElement | null) => void) => {\n 'use no memo';\n\n const { targetDocument } = useFluent();\n const container = React.useRef<HTMLElement | null>(null);\n const containerHeightRef = React.useRef<number>(0);\n const containerWidthRef = React.useRef<number>(0);\n // the handler for resize observer\n // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n\n const handleResize = debounce((entries: ResizeObserverEntry[], observer: ResizeObserver) => {\n const containerHeight = container.current?.clientHeight;\n const containerWidth = container.current?.clientWidth;\n // Our resize observer will fire on scroll resize, let index change handle that instead.\n if (containerHeightRef.current !== containerHeight || containerWidth !== containerWidthRef.current) {\n containerWidthRef.current = containerWidth ?? 0;\n containerHeightRef.current = containerHeight ?? 0;\n resizeCallback(entries, observer, container);\n }\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","containerHeightRef","containerWidthRef","handleResize","entries","observer","containerHeight","current","clientHeight","containerWidth","clientWidth","resizeObserver","setResizeObserver","useState","useEffect","disconnect","scrollRef","useCallback","instance","unobserve","observe"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,gCAAgC,QAAQ,gDAAgD;AAGjG;;;CAGC,GACD,OAAO,MAAMC,gCAAgC,CAC3CC;IAEA;IAEA,MAAM,EAAEC,cAAc,EAAE,GAAGL;IAC3B,MAAMM,YAAYR,MAAMS,MAAM,CAAqB;IACnD,MAAMC,qBAAqBV,MAAMS,MAAM,CAAS;IAChD,MAAME,oBAAoBX,MAAMS,MAAM,CAAS;IAC/C,kCAAkC;IAClC,8FAA8F;IAE9F,MAAMG,eAAeT,SAAS,CAACU,SAAgCC;YACrCN,oBACDA;QADvB,MAAMO,mBAAkBP,qBAAAA,UAAUQ,OAAO,cAAjBR,yCAAAA,mBAAmBS,YAAY;QACvD,MAAMC,kBAAiBV,sBAAAA,UAAUQ,OAAO,cAAjBR,0CAAAA,oBAAmBW,WAAW;QACrD,wFAAwF;QACxF,IAAIT,mBAAmBM,OAAO,KAAKD,mBAAmBG,mBAAmBP,kBAAkBK,OAAO,EAAE;YAClGL,kBAAkBK,OAAO,GAAGE,2BAAAA,4BAAAA,iBAAkB;YAC9CR,mBAAmBM,OAAO,GAAGD,4BAAAA,6BAAAA,kBAAmB;YAChDT,eAAeO,SAASC,UAAUN;QACpC;IACF;IAEA,uFAAuF;IACvF,MAAM,CAACY,gBAAgBC,kBAAkB,GAAGrB,MAAMsB,QAAQ,CAAC,IACzDlB,iCAAiCG,gBAAgBK;IAGnDZ,MAAMuB,SAAS,CAAC;QACd,+CAA+C;QAC/Cf,UAAUQ,OAAO,GAAG;QACpBI,2BAAAA,qCAAAA,eAAgBI,UAAU;QAC1BH,kBAAkB,IAAMjB,iCAAiCG,gBAAgBK;IACzE,uDAAuD;IACzD,GAAG;QAACN;QAAgBC;KAAe;IAEnCP,MAAMuB,SAAS,CAAC;QACd,OAAO;YACLf,UAAUQ,OAAO,GAAG;YACpBI,2BAAAA,qCAAAA,eAAgBI,UAAU;QAC5B;IACA,uDAAuD;IACzD,GAAG,EAAE;IAEL,MAAMC,YAAYzB,MAAM0B,WAAW,CACjC,CAACC;QACC,IAAInB,UAAUQ,OAAO,KAAKW,UAAU;YAClC,IAAInB,UAAUQ,OAAO,EAAE;gBACrBI,2BAAAA,qCAAAA,eAAgBQ,SAAS,CAACpB,UAAUQ,OAAO;YAC7C;YAEAR,UAAUQ,OAAO,GAAGW;YACpB,IAAInB,UAAUQ,OAAO,EAAE;gBACrBI,2BAAAA,qCAAAA,eAAgBS,OAAO,CAACrB,UAAUQ,OAAO;YAC3C;QACF;IACF,GACA;QAACI;KAAe;IAGlB,OAAOK;AACT,EAAE"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useTimeout } from '@fluentui/react-utilities';
|
|
4
|
+
/**
|
|
5
|
+
* Optional hook that will enable pagination on the virtualizer so that it 'autoscrolls' to an items exact position
|
|
6
|
+
* Sizes are uniform/static, we round to the nearest item on long scrolls
|
|
7
|
+
* On short scrolls, we will go at minimum to the next/previous item so that arrow pagination works
|
|
8
|
+
* All VirtualizerStaticPaginationProps can be grabbed from Virtualizer hooks externally and passed in/**
|
|
9
|
+
* @deprecated migrated to \@fluentui\-contrib/react\-virtualizer for stable release.
|
|
10
|
+
*/ export const useStaticVirtualizerPagination = (virtualizerProps, paginationEnabled = true)=>{
|
|
11
|
+
'use no memo';
|
|
12
|
+
const { itemSize, axis = 'vertical' } = virtualizerProps;
|
|
13
|
+
const [setScrollTimer, clearScrollTimer] = useTimeout();
|
|
14
|
+
const lastScrollPos = React.useRef(0);
|
|
15
|
+
const lastIndexScrolled = React.useRef(0);
|
|
16
|
+
const scrollContainer = React.useRef(null);
|
|
17
|
+
const clearListeners = ()=>{
|
|
18
|
+
if (scrollContainer.current) {
|
|
19
|
+
scrollContainer.current.removeEventListener('scroll', onScroll);
|
|
20
|
+
scrollContainer.current = null;
|
|
21
|
+
clearScrollTimer();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
React.useEffect(()=>{
|
|
25
|
+
return ()=>{
|
|
26
|
+
clearListeners();
|
|
27
|
+
};
|
|
28
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
+
}, []);
|
|
30
|
+
/**
|
|
31
|
+
* Handle scroll stop event and paginate to the closest item
|
|
32
|
+
* If the closest item is the same as the previous scroll end
|
|
33
|
+
* we paginate to the next/previous one based on direction
|
|
34
|
+
*/ const onScrollEnd = React.useCallback(()=>{
|
|
35
|
+
if (!scrollContainer.current || !paginationEnabled) {
|
|
36
|
+
// No container found
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const currentScrollPos = Math.round(axis === 'vertical' ? scrollContainer.current.scrollTop : scrollContainer.current.scrollLeft);
|
|
40
|
+
const closestItem = Math.round(currentScrollPos / itemSize);
|
|
41
|
+
let nextItem = 0;
|
|
42
|
+
if (Math.round(closestItem - lastIndexScrolled.current) === 0) {
|
|
43
|
+
// Special case for go to next/previous with minimum amount of scroll needed
|
|
44
|
+
const nextTarget = lastScrollPos.current < currentScrollPos ? 1 : -1;
|
|
45
|
+
const isSecondaryScroll = lastScrollPos.current === currentScrollPos;
|
|
46
|
+
const posMod = isSecondaryScroll ? 0 : nextTarget;
|
|
47
|
+
nextItem = closestItem + posMod;
|
|
48
|
+
} else {
|
|
49
|
+
// Pagination for anything else can just jump to the closest!
|
|
50
|
+
nextItem = closestItem;
|
|
51
|
+
}
|
|
52
|
+
const nextItemPos = nextItem * itemSize;
|
|
53
|
+
if (axis === 'vertical') {
|
|
54
|
+
scrollContainer.current.scrollTo({
|
|
55
|
+
top: nextItemPos,
|
|
56
|
+
behavior: 'smooth'
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
scrollContainer.current.scrollTo({
|
|
60
|
+
left: nextItemPos,
|
|
61
|
+
behavior: 'smooth'
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
lastScrollPos.current = nextItemPos;
|
|
65
|
+
lastIndexScrolled.current = nextItem;
|
|
66
|
+
}, [
|
|
67
|
+
paginationEnabled,
|
|
68
|
+
axis,
|
|
69
|
+
itemSize
|
|
70
|
+
]);
|
|
71
|
+
/**
|
|
72
|
+
* On scroll timer that will continuously delay callback until scrolling stops
|
|
73
|
+
*/ const onScroll = React.useCallback(()=>{
|
|
74
|
+
clearScrollTimer();
|
|
75
|
+
setScrollTimer(onScrollEnd, 100);
|
|
76
|
+
}, [
|
|
77
|
+
onScrollEnd,
|
|
78
|
+
clearScrollTimer,
|
|
79
|
+
setScrollTimer
|
|
80
|
+
]);
|
|
81
|
+
/**
|
|
82
|
+
* Pagination ref will ensure we attach listeners to containers on change
|
|
83
|
+
* It is returned from hook and merged into the scroll container externally
|
|
84
|
+
*/ const paginationRef = React.useCallback((instance)=>{
|
|
85
|
+
if (!paginationEnabled) {
|
|
86
|
+
clearListeners();
|
|
87
|
+
scrollContainer.current = null;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (scrollContainer.current !== instance) {
|
|
91
|
+
clearListeners();
|
|
92
|
+
scrollContainer.current = instance;
|
|
93
|
+
if (scrollContainer.current) {
|
|
94
|
+
scrollContainer.current.addEventListener('scroll', onScroll);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
|
+
[
|
|
99
|
+
onScroll,
|
|
100
|
+
onScrollEnd,
|
|
101
|
+
paginationEnabled
|
|
102
|
+
]);
|
|
103
|
+
return paginationRef;
|
|
104
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useStaticPagination.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { VirtualizerStaticPaginationProps } from './hooks.types';\nimport { useTimeout } from '@fluentui/react-utilities';\n\n/**\n * Optional hook that will enable pagination on the virtualizer so that it 'autoscrolls' to an items exact position\n * Sizes are uniform/static, we round to the nearest item on long scrolls\n * On short scrolls, we will go at minimum to the next/previous item so that arrow pagination works\n * All VirtualizerStaticPaginationProps can be grabbed from Virtualizer hooks externally and passed in/**\n * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport const useStaticVirtualizerPagination = (\n virtualizerProps: VirtualizerStaticPaginationProps,\n paginationEnabled: Boolean = true,\n): ((instance: HTMLElement | HTMLDivElement | null) => void) => {\n 'use no memo';\n\n const { itemSize, axis = 'vertical' } = virtualizerProps;\n\n const [setScrollTimer, clearScrollTimer] = useTimeout();\n const lastScrollPos = React.useRef<number>(0);\n const lastIndexScrolled = React.useRef<number>(0);\n\n const scrollContainer = React.useRef<HTMLElement | null>(null);\n\n const clearListeners = () => {\n if (scrollContainer.current) {\n scrollContainer.current.removeEventListener('scroll', onScroll);\n\n scrollContainer.current = null;\n clearScrollTimer();\n }\n };\n\n React.useEffect(() => {\n return () => {\n clearListeners();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n /**\n * Handle scroll stop event and paginate to the closest item\n * If the closest item is the same as the previous scroll end\n * we paginate to the next/previous one based on direction\n */\n const onScrollEnd = React.useCallback(() => {\n if (!scrollContainer.current || !paginationEnabled) {\n // No container found\n return;\n }\n\n const currentScrollPos = Math.round(\n axis === 'vertical' ? scrollContainer.current.scrollTop : scrollContainer.current.scrollLeft,\n );\n const closestItem = Math.round(currentScrollPos / itemSize);\n\n let nextItem = 0;\n if (Math.round(closestItem - lastIndexScrolled.current) === 0) {\n // Special case for go to next/previous with minimum amount of scroll needed\n const nextTarget = lastScrollPos.current < currentScrollPos ? 1 : -1;\n const isSecondaryScroll = lastScrollPos.current === currentScrollPos;\n const posMod = isSecondaryScroll ? 0 : nextTarget;\n\n nextItem = closestItem + posMod;\n } else {\n // Pagination for anything else can just jump to the closest!\n nextItem = closestItem;\n }\n\n const nextItemPos = nextItem * itemSize;\n\n if (axis === 'vertical') {\n scrollContainer.current.scrollTo({ top: nextItemPos, behavior: 'smooth' });\n } else {\n scrollContainer.current.scrollTo({ left: nextItemPos, behavior: 'smooth' });\n }\n lastScrollPos.current = nextItemPos;\n lastIndexScrolled.current = nextItem;\n }, [paginationEnabled, axis, itemSize]);\n\n /**\n * On scroll timer that will continuously delay callback until scrolling stops\n */\n const onScroll = React.useCallback(() => {\n clearScrollTimer();\n setScrollTimer(onScrollEnd, 100);\n }, [onScrollEnd, clearScrollTimer, setScrollTimer]);\n\n /**\n * Pagination ref will ensure we attach listeners to containers on change\n * It is returned from hook and merged into the scroll container externally\n */\n const paginationRef = React.useCallback(\n (instance: HTMLElement | HTMLDivElement | null) => {\n if (!paginationEnabled) {\n clearListeners();\n scrollContainer.current = null;\n return;\n }\n if (scrollContainer.current !== instance) {\n clearListeners();\n\n scrollContainer.current = instance;\n if (scrollContainer.current) {\n scrollContainer.current.addEventListener('scroll', onScroll);\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [onScroll, onScrollEnd, paginationEnabled],\n );\n\n return paginationRef;\n};\n"],"names":["React","useTimeout","useStaticVirtualizerPagination","virtualizerProps","paginationEnabled","itemSize","axis","setScrollTimer","clearScrollTimer","lastScrollPos","useRef","lastIndexScrolled","scrollContainer","clearListeners","current","removeEventListener","onScroll","useEffect","onScrollEnd","useCallback","currentScrollPos","Math","round","scrollTop","scrollLeft","closestItem","nextItem","nextTarget","isSecondaryScroll","posMod","nextItemPos","scrollTo","top","behavior","left","paginationRef","instance","addEventListener"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,UAAU,QAAQ,4BAA4B;AAEvD;;;;;;CAMC,GACD,OAAO,MAAMC,iCAAiC,CAC5CC,kBACAC,oBAA6B,IAAI;IAEjC;IAEA,MAAM,EAAEC,QAAQ,EAAEC,OAAO,UAAU,EAAE,GAAGH;IAExC,MAAM,CAACI,gBAAgBC,iBAAiB,GAAGP;IAC3C,MAAMQ,gBAAgBT,MAAMU,MAAM,CAAS;IAC3C,MAAMC,oBAAoBX,MAAMU,MAAM,CAAS;IAE/C,MAAME,kBAAkBZ,MAAMU,MAAM,CAAqB;IAEzD,MAAMG,iBAAiB;QACrB,IAAID,gBAAgBE,OAAO,EAAE;YAC3BF,gBAAgBE,OAAO,CAACC,mBAAmB,CAAC,UAAUC;YAEtDJ,gBAAgBE,OAAO,GAAG;YAC1BN;QACF;IACF;IAEAR,MAAMiB,SAAS,CAAC;QACd,OAAO;YACLJ;QACF;IACA,uDAAuD;IACzD,GAAG,EAAE;IAEL;;;;GAIC,GACD,MAAMK,cAAclB,MAAMmB,WAAW,CAAC;QACpC,IAAI,CAACP,gBAAgBE,OAAO,IAAI,CAACV,mBAAmB;YAClD,qBAAqB;YACrB;QACF;QAEA,MAAMgB,mBAAmBC,KAAKC,KAAK,CACjChB,SAAS,aAAaM,gBAAgBE,OAAO,CAACS,SAAS,GAAGX,gBAAgBE,OAAO,CAACU,UAAU;QAE9F,MAAMC,cAAcJ,KAAKC,KAAK,CAACF,mBAAmBf;QAElD,IAAIqB,WAAW;QACf,IAAIL,KAAKC,KAAK,CAACG,cAAcd,kBAAkBG,OAAO,MAAM,GAAG;YAC7D,4EAA4E;YAC5E,MAAMa,aAAalB,cAAcK,OAAO,GAAGM,mBAAmB,IAAI,CAAC;YACnE,MAAMQ,oBAAoBnB,cAAcK,OAAO,KAAKM;YACpD,MAAMS,SAASD,oBAAoB,IAAID;YAEvCD,WAAWD,cAAcI;QAC3B,OAAO;YACL,6DAA6D;YAC7DH,WAAWD;QACb;QAEA,MAAMK,cAAcJ,WAAWrB;QAE/B,IAAIC,SAAS,YAAY;YACvBM,gBAAgBE,OAAO,CAACiB,QAAQ,CAAC;gBAAEC,KAAKF;gBAAaG,UAAU;YAAS;QAC1E,OAAO;YACLrB,gBAAgBE,OAAO,CAACiB,QAAQ,CAAC;gBAAEG,MAAMJ;gBAAaG,UAAU;YAAS;QAC3E;QACAxB,cAAcK,OAAO,GAAGgB;QACxBnB,kBAAkBG,OAAO,GAAGY;IAC9B,GAAG;QAACtB;QAAmBE;QAAMD;KAAS;IAEtC;;GAEC,GACD,MAAMW,WAAWhB,MAAMmB,WAAW,CAAC;QACjCX;QACAD,eAAeW,aAAa;IAC9B,GAAG;QAACA;QAAaV;QAAkBD;KAAe;IAElD;;;GAGC,GACD,MAAM4B,gBAAgBnC,MAAMmB,WAAW,CACrC,CAACiB;QACC,IAAI,CAAChC,mBAAmB;YACtBS;YACAD,gBAAgBE,OAAO,GAAG;YAC1B;QACF;QACA,IAAIF,gBAAgBE,OAAO,KAAKsB,UAAU;YACxCvB;YAEAD,gBAAgBE,OAAO,GAAGsB;YAC1B,IAAIxB,gBAAgBE,OAAO,EAAE;gBAC3BF,gBAAgBE,OAAO,CAACuB,gBAAgB,CAAC,UAAUrB;YACrD;QACF;IACF,GACA,uDAAuD;IACvD;QAACA;QAAUE;QAAad;KAAkB;IAG5C,OAAO+B;AACT,EAAE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useResizeObserverRef_unstable } from './useResizeObserverRef';
|
|
4
|
+
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
|
5
|
+
/**
|
|
6
|
+
* React hook that measures virtualized space based on a static size to ensure optimized virtualization length.
|
|
7
|
+
* @deprecated migrated to \@fluentui\-contrib/react\-virtualizer for stable release.
|
|
8
|
+
*/ export const useStaticVirtualizerMeasure = (virtualizerProps)=>{
|
|
9
|
+
const { defaultItemSize, direction = 'vertical', bufferItems, bufferSize } = virtualizerProps;
|
|
10
|
+
const [state, setState] = React.useState({
|
|
11
|
+
virtualizerLength: 0,
|
|
12
|
+
_bufferSize: 0,
|
|
13
|
+
_bufferItems: 0
|
|
14
|
+
});
|
|
15
|
+
const containerSizeRef = React.useRef(0);
|
|
16
|
+
const { targetDocument } = useFluent();
|
|
17
|
+
const { virtualizerLength, _bufferItems, _bufferSize } = state;
|
|
18
|
+
const resizeCallback = React.useCallback((_entries, // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
19
|
+
_observer, // eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
20
|
+
scrollRef)=>{
|
|
21
|
+
if (!(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (scrollRef.current !== (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.body)) {
|
|
25
|
+
// We have a local scroll container
|
|
26
|
+
containerSizeRef.current = direction === 'vertical' ? scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.getBoundingClientRect().height : scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current.getBoundingClientRect().width;
|
|
27
|
+
} else if (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) {
|
|
28
|
+
var _targetDocument_defaultView, _targetDocument_defaultView1;
|
|
29
|
+
// If our scroll ref is the document body, we should check window height
|
|
30
|
+
containerSizeRef.current = direction === 'vertical' ? targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.innerHeight : targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView1 = targetDocument.defaultView) === null || _targetDocument_defaultView1 === void 0 ? void 0 : _targetDocument_defaultView1.innerWidth;
|
|
31
|
+
}
|
|
32
|
+
/*
|
|
33
|
+
* Number of items required to cover viewport.
|
|
34
|
+
*/ const length = Math.ceil(containerSizeRef.current / defaultItemSize + 1);
|
|
35
|
+
/*
|
|
36
|
+
* Number of items to append at each end, i.e. 'preload' each side before entering view.
|
|
37
|
+
* Minimum: 1
|
|
38
|
+
*/ const newBufferItems = bufferItems !== null && bufferItems !== void 0 ? bufferItems : Math.max(Math.ceil(length / 4), 1);
|
|
39
|
+
/*
|
|
40
|
+
* This is how far we deviate into the bufferItems to detect a redraw.
|
|
41
|
+
*/ const newBufferSize = bufferSize !== null && bufferSize !== void 0 ? bufferSize : Math.max(defaultItemSize / 2.0, 1);
|
|
42
|
+
const totalLength = length + newBufferItems * 2;
|
|
43
|
+
setState({
|
|
44
|
+
virtualizerLength: totalLength,
|
|
45
|
+
_bufferItems: newBufferItems,
|
|
46
|
+
_bufferSize: newBufferSize
|
|
47
|
+
});
|
|
48
|
+
}, [
|
|
49
|
+
bufferItems,
|
|
50
|
+
bufferSize,
|
|
51
|
+
defaultItemSize,
|
|
52
|
+
direction,
|
|
53
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.body,
|
|
54
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView
|
|
55
|
+
]);
|
|
56
|
+
const scrollRef = useResizeObserverRef_unstable(resizeCallback);
|
|
57
|
+
return {
|
|
58
|
+
virtualizerLength,
|
|
59
|
+
bufferItems: _bufferItems,
|
|
60
|
+
bufferSize: _bufferSize,
|
|
61
|
+
scrollRef,
|
|
62
|
+
containerSizeRef
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useVirtualizerMeasure.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { VirtualizerMeasureProps } from './hooks.types';\nimport { useResizeObserverRef_unstable } from './useResizeObserverRef';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\n/**\n * React hook that measures virtualized space based on a static size to ensure optimized virtualization length.\n * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n containerSizeRef: React.MutableRefObject<number>;\n} => {\n const { defaultItemSize, direction = 'vertical', bufferItems, bufferSize } = virtualizerProps;\n\n const [state, setState] = React.useState({\n virtualizerLength: 0,\n _bufferSize: 0,\n _bufferItems: 0,\n });\n\n const containerSizeRef = React.useRef<number>(0);\n const { targetDocument } = useFluent();\n\n const { virtualizerLength, _bufferItems, _bufferSize } = state;\n\n const resizeCallback = React.useCallback(\n (\n _entries: ResizeObserverEntry[],\n // TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286\n\n _observer: ResizeObserver,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n scrollRef?: React.MutableRefObject<HTMLElement | null>,\n ) => {\n if (!scrollRef?.current) {\n return;\n }\n\n if (scrollRef.current !== targetDocument?.body) {\n // We have a local scroll container\n containerSizeRef.current =\n direction === 'vertical'\n ? scrollRef?.current.getBoundingClientRect().height\n : scrollRef?.current.getBoundingClientRect().width;\n } else if (targetDocument?.defaultView) {\n // If our scroll ref is the document body, we should check window height\n containerSizeRef.current =\n direction === 'vertical' ? targetDocument?.defaultView?.innerHeight : targetDocument?.defaultView?.innerWidth;\n }\n /*\n * Number of items required to cover viewport.\n */\n const length = Math.ceil(containerSizeRef.current / defaultItemSize + 1);\n\n /*\n * Number of items to append at each end, i.e. 'preload' each side before entering view.\n * Minimum: 1\n */\n const newBufferItems = bufferItems ?? Math.max(Math.ceil(length / 4), 1);\n\n /*\n * This is how far we deviate into the bufferItems to detect a redraw.\n */\n const newBufferSize = bufferSize ?? Math.max(defaultItemSize / 2.0, 1);\n\n const totalLength = length + newBufferItems * 2;\n\n setState({\n virtualizerLength: totalLength,\n _bufferItems: newBufferItems,\n _bufferSize: newBufferSize,\n });\n },\n [bufferItems, bufferSize, defaultItemSize, direction, targetDocument?.body, targetDocument?.defaultView],\n );\n\n const scrollRef = useResizeObserverRef_unstable(resizeCallback);\n\n return {\n virtualizerLength,\n bufferItems: _bufferItems,\n bufferSize: _bufferSize,\n scrollRef,\n containerSizeRef,\n };\n};\n"],"names":["React","useResizeObserverRef_unstable","useFluent_unstable","useFluent","useStaticVirtualizerMeasure","virtualizerProps","defaultItemSize","direction","bufferItems","bufferSize","state","setState","useState","virtualizerLength","_bufferSize","_bufferItems","containerSizeRef","useRef","targetDocument","resizeCallback","useCallback","_entries","_observer","scrollRef","current","body","getBoundingClientRect","height","width","defaultView","innerHeight","innerWidth","length","Math","ceil","newBufferItems","max","newBufferSize","totalLength"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,6BAA6B,QAAQ,yBAAyB;AACvE,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF;;;CAGC,GACD,OAAO,MAAMC,8BAA8B,CACzCC;IASA,MAAM,EAAEC,eAAe,EAAEC,YAAY,UAAU,EAAEC,WAAW,EAAEC,UAAU,EAAE,GAAGJ;IAE7E,MAAM,CAACK,OAAOC,SAAS,GAAGX,MAAMY,QAAQ,CAAC;QACvCC,mBAAmB;QACnBC,aAAa;QACbC,cAAc;IAChB;IAEA,MAAMC,mBAAmBhB,MAAMiB,MAAM,CAAS;IAC9C,MAAM,EAAEC,cAAc,EAAE,GAAGf;IAE3B,MAAM,EAAEU,iBAAiB,EAAEE,YAAY,EAAED,WAAW,EAAE,GAAGJ;IAEzD,MAAMS,iBAAiBnB,MAAMoB,WAAW,CACtC,CACEC,UACA,8FAA8F;IAE9FC,WACA,4DAA4D;IAC5DC;QAEA,IAAI,EAACA,sBAAAA,gCAAAA,UAAWC,OAAO,GAAE;YACvB;QACF;QAEA,IAAID,UAAUC,OAAO,MAAKN,2BAAAA,qCAAAA,eAAgBO,IAAI,GAAE;YAC9C,mCAAmC;YACnCT,iBAAiBQ,OAAO,GACtBjB,cAAc,aACVgB,sBAAAA,gCAAAA,UAAWC,OAAO,CAACE,qBAAqB,GAAGC,MAAM,GACjDJ,sBAAAA,gCAAAA,UAAWC,OAAO,CAACE,qBAAqB,GAAGE,KAAK;QACxD,OAAO,IAAIV,2BAAAA,qCAAAA,eAAgBW,WAAW,EAAE;gBAGTX,6BAA2CA;YAFxE,wEAAwE;YACxEF,iBAAiBQ,OAAO,GACtBjB,cAAc,aAAaW,2BAAAA,sCAAAA,8BAAAA,eAAgBW,WAAW,cAA3BX,kDAAAA,4BAA6BY,WAAW,GAAGZ,2BAAAA,sCAAAA,+BAAAA,eAAgBW,WAAW,cAA3BX,mDAAAA,6BAA6Ba,UAAU;QACjH;QACA;;OAEC,GACD,MAAMC,SAASC,KAAKC,IAAI,CAAClB,iBAAiBQ,OAAO,GAAGlB,kBAAkB;QAEtE;;;OAGC,GACD,MAAM6B,iBAAiB3B,wBAAAA,yBAAAA,cAAeyB,KAAKG,GAAG,CAACH,KAAKC,IAAI,CAACF,SAAS,IAAI;QAEtE;;OAEC,GACD,MAAMK,gBAAgB5B,uBAAAA,wBAAAA,aAAcwB,KAAKG,GAAG,CAAC9B,kBAAkB,KAAK;QAEpE,MAAMgC,cAAcN,SAASG,iBAAiB;QAE9CxB,SAAS;YACPE,mBAAmByB;YACnBvB,cAAcoB;YACdrB,aAAauB;QACf;IACF,GACA;QAAC7B;QAAaC;QAAYH;QAAiBC;QAAWW,2BAAAA,qCAAAA,eAAgBO,IAAI;QAAEP,2BAAAA,qCAAAA,eAAgBW,WAAW;KAAC;IAG1G,MAAMN,YAAYtB,8BAA8BkB;IAEhD,OAAO;QACLN;QACAL,aAAaO;QACbN,YAAYK;QACZS;QACAP;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, useMeasureList } 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":["../src/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 useMeasureList,\n} from './Hooks';\n\nexport type {\n ResizeCallbackWithRef,\n VirtualizerMeasureDynamicProps,\n VirtualizerMeasureProps,\n IndexedResizeCallbackElement,\n} 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, DynamicVirtualizerContextProps } 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","useMeasureList","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,EAC7BC,cAAc,QACT,UAAU;AAWjB,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":["../src/utilities/ImperativeScrolling/imperativeScrolling.ts"],"sourcesContent":["import { ScrollToItemStaticParams } from './imperativeScrolling.types';\n\nexport const scrollToItemStatic = (params: ScrollToItemStaticParams): void => {\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
|
+
import * as React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utilities/ImperativeScrolling/imperativeScrolling.types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type ScrollToItemStaticParams = {\n index: number;\n itemSize: number;\n totalItems: number;\n scrollViewRef: React.RefObject<HTMLDivElement>;\n axis?: 'horizontal' | 'vertical';\n reversed?: boolean;\n behavior?: ScrollBehavior;\n};\n\nexport type ScrollToItemDynamicParams = {\n index: number;\n itemSizes: React.RefObject<number[]>;\n totalSize: number;\n scrollViewRef: React.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: React.RefObject<number>;\n currentIndex: React.RefObject<number> | undefined;\n};\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
@@ -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":["../src/utilities/ImperativeScrolling/imperativeScrollingDynamic.ts"],"sourcesContent":["import { ScrollToItemDynamicParams } from './imperativeScrolling.types';\n\nexport const scrollToItemDynamic = (params: ScrollToItemDynamicParams): void => {\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":["../src/utilities/ImperativeScrolling/index.ts"],"sourcesContent":["export { scrollToItemStatic } from './imperativeScrolling';\nexport type {\n ScrollToInterface,\n ScrollToItemDynamicParams,\n ScrollToItemStaticParams,\n} from './imperativeScrolling.types';\nexport { scrollToItemDynamic } from './imperativeScrollingDynamic';\n"],"names":["scrollToItemStatic","scrollToItemDynamic"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,wBAAwB;AAM3D,SAASC,mBAAmB,QAAQ,+BAA+B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
const VirtualizerContext = React.createContext(undefined);
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated migrated to \@fluentui\-contrib/react\-virtualizer for stable release.
|
|
6
|
+
*/ export const VirtualizerContextProvider = VirtualizerContext.Provider;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated migrated to \@fluentui\-contrib/react\-virtualizer for stable release.
|
|
9
|
+
*/ export const useVirtualizerContext_unstable = ()=>{
|
|
10
|
+
return React.useContext(VirtualizerContext);
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated migrated to \@fluentui\-contrib/react\-virtualizer for stable release.
|
|
14
|
+
*/ export const useVirtualizerContextState_unstable = (passedContext)=>{
|
|
15
|
+
const virtualizerContext = useVirtualizerContext_unstable();
|
|
16
|
+
const [_contextIndex, _setContextIndex] = React.useState(-1);
|
|
17
|
+
const childProgressiveSizes = React.useRef([]);
|
|
18
|
+
/* We respect any wrapped providers while also ensuring defaults or passed through
|
|
19
|
+
* Order of usage -> Passed Prop -> Provider Context -> Internal State default
|
|
20
|
+
*/ const context = React.useMemo(()=>{
|
|
21
|
+
var _passedContext_contextIndex, _ref, _passedContext_setContextIndex, _ref1;
|
|
22
|
+
return {
|
|
23
|
+
contextIndex: (_ref = (_passedContext_contextIndex = passedContext === null || passedContext === void 0 ? void 0 : passedContext.contextIndex) !== null && _passedContext_contextIndex !== void 0 ? _passedContext_contextIndex : virtualizerContext === null || virtualizerContext === void 0 ? void 0 : virtualizerContext.contextIndex) !== null && _ref !== void 0 ? _ref : _contextIndex,
|
|
24
|
+
setContextIndex: (_ref1 = (_passedContext_setContextIndex = passedContext === null || passedContext === void 0 ? void 0 : passedContext.setContextIndex) !== null && _passedContext_setContextIndex !== void 0 ? _passedContext_setContextIndex : virtualizerContext === null || virtualizerContext === void 0 ? void 0 : virtualizerContext.setContextIndex) !== null && _ref1 !== void 0 ? _ref1 : _setContextIndex,
|
|
25
|
+
childProgressiveSizes
|
|
26
|
+
};
|
|
27
|
+
}, [
|
|
28
|
+
_contextIndex,
|
|
29
|
+
passedContext,
|
|
30
|
+
virtualizerContext
|
|
31
|
+
]);
|
|
32
|
+
return context;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utilities/VirtualizerContext/VirtualizerContext.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { DynamicVirtualizerContextProps, VirtualizerContextProps } from './types';\n\nconst VirtualizerContext = React.createContext<VirtualizerContextProps | undefined>(\n undefined,\n) as React.Context<VirtualizerContextProps>;\n\n/**\n * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport const VirtualizerContextProvider = VirtualizerContext.Provider;\n\n/**\n * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport const useVirtualizerContext_unstable = (): VirtualizerContextProps => {\n return React.useContext(VirtualizerContext);\n};\n\n/**\n * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport const useVirtualizerContextState_unstable = (\n passedContext?: VirtualizerContextProps,\n): DynamicVirtualizerContextProps => {\n const virtualizerContext = useVirtualizerContext_unstable();\n const [_contextIndex, _setContextIndex] = React.useState<number>(-1);\n const childProgressiveSizes = React.useRef<number[]>([]);\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 = React.useMemo(\n () => ({\n contextIndex: passedContext?.contextIndex ?? virtualizerContext?.contextIndex ?? _contextIndex,\n setContextIndex: passedContext?.setContextIndex ?? virtualizerContext?.setContextIndex ?? _setContextIndex,\n childProgressiveSizes,\n }),\n [_contextIndex, passedContext, virtualizerContext],\n );\n\n return context;\n};\n"],"names":["React","VirtualizerContext","createContext","undefined","VirtualizerContextProvider","Provider","useVirtualizerContext_unstable","useContext","useVirtualizerContextState_unstable","passedContext","virtualizerContext","_contextIndex","_setContextIndex","useState","childProgressiveSizes","useRef","context","useMemo","contextIndex","setContextIndex"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAG/B,MAAMC,qBAAqBD,MAAME,aAAa,CAC5CC;AAGF;;CAEC,GACD,OAAO,MAAMC,6BAA6BH,mBAAmBI,QAAQ,CAAC;AAEtE;;CAEC,GACD,OAAO,MAAMC,iCAAiC;IAC5C,OAAON,MAAMO,UAAU,CAACN;AAC1B,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMO,sCAAsC,CACjDC;IAEA,MAAMC,qBAAqBJ;IAC3B,MAAM,CAACK,eAAeC,iBAAiB,GAAGZ,MAAMa,QAAQ,CAAS,CAAC;IAClE,MAAMC,wBAAwBd,MAAMe,MAAM,CAAW,EAAE;IAEvD;;GAEC,GACD,MAAMC,UAAUhB,MAAMiB,OAAO,CAC3B;YACgBR,6BAAAA,MACGA,gCAAAA;eAFZ;YACLS,cAAcT,CAAAA,OAAAA,CAAAA,8BAAAA,0BAAAA,oCAAAA,cAAeS,YAAY,cAA3BT,yCAAAA,8BAA+BC,+BAAAA,yCAAAA,mBAAoBQ,YAAY,cAA/DT,kBAAAA,OAAmEE;YACjFQ,iBAAiBV,CAAAA,QAAAA,CAAAA,iCAAAA,0BAAAA,oCAAAA,cAAeU,eAAe,cAA9BV,4CAAAA,iCAAkCC,+BAAAA,yCAAAA,mBAAoBS,eAAe,cAArEV,mBAAAA,QAAyEG;YAC1FE;QACF;OACA;QAACH;QAAeF;QAAeC;KAAmB;IAGpD,OAAOM;AACT,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VirtualizerContextProvider, useVirtualizerContextState_unstable, useVirtualizerContext_unstable } from './VirtualizerContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utilities/VirtualizerContext/index.ts"],"sourcesContent":["export {\n VirtualizerContextProvider,\n useVirtualizerContextState_unstable,\n useVirtualizerContext_unstable,\n} from './VirtualizerContext';\nexport type { DynamicVirtualizerContextProps, VirtualizerContextProps } from './types';\n"],"names":["VirtualizerContextProvider","useVirtualizerContextState_unstable","useVirtualizerContext_unstable"],"mappings":"AAAA,SACEA,0BAA0B,EAC1BC,mCAAmC,EACnCC,8BAA8B,QACzB,uBAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utilities/VirtualizerContext/types.ts"],"sourcesContent":["import * as React from 'react';\n/**\n * {@docCategory Virtualizer}\n * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport type VirtualizerContextProps = {\n contextIndex: number;\n setContextIndex: (index: number) => void;\n /*\n * These optional props are used in dynamic virtualizer\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n childProgressiveSizes?: React.MutableRefObject<number[]>;\n};\n\n/**\n * Some props are optional on static virtualizer, but required for dynamic.\n * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport type DynamicVirtualizerContextProps = Required<VirtualizerContextProps>;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
* @deprecated migrated to \@fluentui\-contrib/react\-virtualizer for stable release.
|
|
8
|
+
*/ export function createResizeObserverFromDocument(targetDocument, callback) {
|
|
9
|
+
var _targetDocument_defaultView;
|
|
10
|
+
if (!(targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.ResizeObserver)) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return new targetDocument.defaultView.ResizeObserver(callback);
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utilities/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 * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport function createResizeObserverFromDocument(\n targetDocument: Document | null | undefined,\n callback: ResizeObserverCallback,\n): ResizeObserver | null {\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;;;;;;;CAOC,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,20 @@
|
|
|
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
|
+
* @deprecated migrated to \@fluentui\-contrib/react\-virtualizer for stable release.
|
|
7
|
+
*/ export function debounce(fn) {
|
|
8
|
+
let pending;
|
|
9
|
+
return ()=>{
|
|
10
|
+
if (!pending) {
|
|
11
|
+
pending = true;
|
|
12
|
+
queueMicrotask(()=>{
|
|
13
|
+
// Need to set pending to `false` before the debounced function is run.
|
|
14
|
+
// React can actually interrupt the function while it's running!
|
|
15
|
+
pending = false;
|
|
16
|
+
fn();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utilities/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 * @deprecated migrated to \\@fluentui\\-contrib/react\\-virtualizer for stable release.\n */\nexport function debounce(fn: Function) {\n let pending: boolean;\n return (): void => {\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;;;;;;CAMC,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":["../src/utilities/index.ts"],"sourcesContent":["export type { DynamicVirtualizerContextProps, VirtualizerContextProps } from './VirtualizerContext';\nexport {\n VirtualizerContextProvider,\n useVirtualizerContextState_unstable,\n useVirtualizerContext_unstable,\n} from './VirtualizerContext';\nexport type { ScrollToInterface, ScrollToItemDynamicParams, ScrollToItemStaticParams } from './ImperativeScrolling';\nexport { scrollToItemDynamic, scrollToItemStatic } from './ImperativeScrolling';\n"],"names":["VirtualizerContextProvider","useVirtualizerContextState_unstable","useVirtualizerContext_unstable","scrollToItemDynamic","scrollToItemStatic"],"mappings":"AACA,SACEA,0BAA0B,EAC1BC,mCAAmC,EACnCC,8BAA8B,QACzB,uBAAuB;AAE9B,SAASC,mBAAmB,EAAEC,kBAAkB,QAAQ,wBAAwB"}
|
package/lib-commonjs/Hooks.js
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
createResizeObserverFromDocument: function() {
|
|
13
|
+
return _index.createResizeObserverFromDocument;
|
|
14
|
+
},
|
|
15
|
+
getRTLRootMargin: function() {
|
|
16
|
+
return _index.getRTLRootMargin;
|
|
17
|
+
},
|
|
18
|
+
useDynamicVirtualizerMeasure: function() {
|
|
19
|
+
return _index.useDynamicVirtualizerMeasure;
|
|
20
|
+
},
|
|
21
|
+
useIntersectionObserver: function() {
|
|
22
|
+
return _index.useIntersectionObserver;
|
|
23
|
+
},
|
|
24
|
+
useMeasureList: function() {
|
|
25
|
+
return _index.useMeasureList;
|
|
26
|
+
},
|
|
27
|
+
useResizeObserverRef_unstable: function() {
|
|
28
|
+
return _index.useResizeObserverRef_unstable;
|
|
29
|
+
},
|
|
30
|
+
useStaticVirtualizerMeasure: function() {
|
|
31
|
+
return _index.useStaticVirtualizerMeasure;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const _index = require("./hooks/index");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/Hooks.ts"],"sourcesContent":["export type {\n IndexedResizeCallbackElement,\n ResizeCallbackWithRef,\n VirtualizerDynamicPaginationProps,\n VirtualizerMeasureDynamicProps,\n VirtualizerMeasureProps,\n VirtualizerStaticPaginationProps,\n} from './hooks/index';\nexport {\n createResizeObserverFromDocument,\n getRTLRootMargin,\n useDynamicVirtualizerMeasure,\n useIntersectionObserver,\n useMeasureList,\n useResizeObserverRef_unstable,\n useStaticVirtualizerMeasure,\n} from './hooks/index';\n"],"names":["createResizeObserverFromDocument","getRTLRootMargin","useDynamicVirtualizerMeasure","useIntersectionObserver","useMeasureList","useResizeObserverRef_unstable","useStaticVirtualizerMeasure"],"mappings":";;;;;;;;;;;;eASEA,uCAAgC;;;eAChCC,uBAAgB;;;eAChBC,mCAA4B;;;eAC5BC,8BAAuB;;;eACvBC,qBAAc;;;eACdC,oCAA6B;;;eAC7BC,kCAA2B;;;uBACtB,gBAAgB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
VirtualizerContextProvider: function() {
|
|
13
|
+
return _index.VirtualizerContextProvider;
|
|
14
|
+
},
|
|
15
|
+
scrollToItemDynamic: function() {
|
|
16
|
+
return _index.scrollToItemDynamic;
|
|
17
|
+
},
|
|
18
|
+
scrollToItemStatic: function() {
|
|
19
|
+
return _index.scrollToItemStatic;
|
|
20
|
+
},
|
|
21
|
+
useVirtualizerContextState_unstable: function() {
|
|
22
|
+
return _index.useVirtualizerContextState_unstable;
|
|
23
|
+
},
|
|
24
|
+
useVirtualizerContext_unstable: function() {
|
|
25
|
+
return _index.useVirtualizerContext_unstable;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const _index = require("./utilities/index");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Utilities.ts"],"sourcesContent":["export type {\n DynamicVirtualizerContextProps,\n ScrollToInterface,\n ScrollToItemDynamicParams,\n ScrollToItemStaticParams,\n VirtualizerContextProps,\n} from './utilities/index';\nexport {\n VirtualizerContextProvider,\n scrollToItemDynamic,\n scrollToItemStatic,\n useVirtualizerContextState_unstable,\n useVirtualizerContext_unstable,\n} from './utilities/index';\n"],"names":["VirtualizerContextProvider","scrollToItemDynamic","scrollToItemStatic","useVirtualizerContextState_unstable","useVirtualizerContext_unstable"],"mappings":";;;;;;;;;;;;eAQEA,iCAA0B;;;eAC1BC,0BAAmB;;;eACnBC,yBAAkB;;;eAClBC,0CAAmC;;;eACnCC,qCAA8B;;;uBACzB,oBAAoB"}
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
Virtualizer: function() {
|
|
13
|
+
return _index.Virtualizer;
|
|
14
|
+
},
|
|
15
|
+
renderVirtualizerChildPlaceholder: function() {
|
|
16
|
+
return _index.renderVirtualizerChildPlaceholder;
|
|
17
|
+
},
|
|
18
|
+
renderVirtualizer_unstable: function() {
|
|
19
|
+
return _index.renderVirtualizer_unstable;
|
|
20
|
+
},
|
|
21
|
+
useVirtualizerStyles_unstable: function() {
|
|
22
|
+
return _index.useVirtualizerStyles_unstable;
|
|
23
|
+
},
|
|
24
|
+
useVirtualizer_unstable: function() {
|
|
25
|
+
return _index.useVirtualizer_unstable;
|
|
26
|
+
},
|
|
27
|
+
virtualizerClassNames: function() {
|
|
28
|
+
return _index.virtualizerClassNames;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _index = require("./components/Virtualizer/index");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/Virtualizer.ts"],"sourcesContent":["export type {\n VirtualizerChildRenderFunction,\n VirtualizerConfigProps,\n VirtualizerConfigState,\n VirtualizerDataRef,\n VirtualizerProps,\n VirtualizerSlots,\n VirtualizerState,\n} from './components/Virtualizer/index';\nexport {\n Virtualizer,\n renderVirtualizerChildPlaceholder,\n renderVirtualizer_unstable,\n useVirtualizerStyles_unstable,\n useVirtualizer_unstable,\n virtualizerClassNames,\n} from './components/Virtualizer/index';\n"],"names":["Virtualizer","renderVirtualizerChildPlaceholder","renderVirtualizer_unstable","useVirtualizerStyles_unstable","useVirtualizer_unstable","virtualizerClassNames"],"mappings":";;;;;;;;;;;;eAUEA,kBAAW;;;eACXC,wCAAiC;;;eACjCC,iCAA0B;;;eAC1BC,oCAA6B;;;eAC7BC,8BAAuB;;;eACvBC,4BAAqB;;;uBAChB,iCAAiC"}
|