@fluentui/react-virtualizer 9.0.0-alpha.86 → 9.0.0-alpha.88
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 +27 -2
- package/dist/index.d.ts +28 -26
- package/lib/Hooks.js.map +1 -1
- package/lib/Utilities.js.map +1 -1
- package/lib/Virtualizer.js.map +1 -1
- package/lib/VirtualizerScrollView.js.map +1 -1
- package/lib/VirtualizerScrollViewDynamic.js.map +1 -1
- package/lib/components/Virtualizer/Virtualizer.js +1 -0
- package/lib/components/Virtualizer/Virtualizer.js.map +1 -1
- package/lib/components/Virtualizer/Virtualizer.types.js.map +1 -1
- package/lib/components/Virtualizer/index.js.map +1 -1
- package/lib/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizer.js +76 -59
- package/lib/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizerStyles.styles.js +1 -2
- package/lib/components/VirtualizerScrollView/VirtualizerScrollView.js.map +1 -1
- package/lib/components/VirtualizerScrollView/VirtualizerScrollView.types.js +1 -1
- package/lib/components/VirtualizerScrollView/VirtualizerScrollView.types.js.map +1 -1
- package/lib/components/VirtualizerScrollView/index.js.map +1 -1
- package/lib/components/VirtualizerScrollView/renderVirtualizerScrollView.js.map +1 -1
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js +1 -2
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -1
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js +1 -2
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/index.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +7 -6
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js +1 -2
- package/lib/hooks/hooks.types.js +1 -4
- package/lib/hooks/hooks.types.js.map +1 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useDynamicPagination.js +2 -3
- package/lib/hooks/useDynamicPagination.js.map +1 -1
- package/lib/hooks/useDynamicVirtualizerMeasure.js +17 -10
- package/lib/hooks/useDynamicVirtualizerMeasure.js.map +1 -1
- package/lib/hooks/useIntersectionObserver.js.map +1 -1
- package/lib/hooks/useMeasureList.js +1 -2
- package/lib/hooks/useMeasureList.js.map +1 -1
- package/lib/hooks/useMutationObserver.js.map +1 -1
- package/lib/hooks/useResizeObserverRef.js.map +1 -1
- package/lib/hooks/useStaticPagination.js +2 -3
- package/lib/hooks/useStaticPagination.js.map +1 -1
- package/lib/hooks/useVirtualizerMeasure.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/utilities/ImperativeScrolling/imperativeScrolling.js.map +1 -1
- package/lib/utilities/ImperativeScrolling/imperativeScrolling.types.js +1 -1
- package/lib/utilities/ImperativeScrolling/imperativeScrolling.types.js.map +1 -1
- package/lib/utilities/ImperativeScrolling/imperativeScrollingDynamic.js.map +1 -1
- package/lib/utilities/ImperativeScrolling/index.js.map +1 -1
- package/lib/utilities/VirtualizerContext/VirtualizerContext.js +4 -9
- package/lib/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -1
- package/lib/utilities/VirtualizerContext/index.js.map +1 -1
- package/lib/utilities/VirtualizerContext/types.js.map +1 -1
- package/lib/utilities/createResizeObserverFromDocument.js.map +1 -1
- package/lib/utilities/debounce.js.map +1 -1
- package/lib/utilities/index.js.map +1 -1
- package/lib-commonjs/Hooks.js.map +1 -1
- package/lib-commonjs/Utilities.js.map +1 -1
- package/lib-commonjs/Virtualizer.js.map +1 -1
- package/lib-commonjs/VirtualizerScrollView.js.map +1 -1
- package/lib-commonjs/VirtualizerScrollViewDynamic.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/Virtualizer.js +2 -0
- package/lib-commonjs/components/Virtualizer/Virtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/Virtualizer.types.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/index.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js +77 -59
- package/lib-commonjs/components/Virtualizer/useVirtualizer.js.map +1 -1
- package/lib-commonjs/components/Virtualizer/useVirtualizerStyles.styles.js +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.types.js +2 -0
- package/lib-commonjs/components/VirtualizerScrollView/VirtualizerScrollView.types.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/index.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/renderVirtualizerScrollView.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollView.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollView/useVirtualizerScrollViewStyles.styles.js +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js +2 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/renderVirtualizerScrollViewDynamic.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +7 -5
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamicStyles.styles.js +1 -1
- package/lib-commonjs/hooks/hooks.types.js +3 -4
- package/lib-commonjs/hooks/hooks.types.js.map +1 -1
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useDynamicPagination.js +2 -2
- package/lib-commonjs/hooks/useDynamicPagination.js.map +1 -1
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js +17 -9
- package/lib-commonjs/hooks/useDynamicVirtualizerMeasure.js.map +1 -1
- package/lib-commonjs/hooks/useIntersectionObserver.js.map +1 -1
- package/lib-commonjs/hooks/useMeasureList.js +1 -1
- package/lib-commonjs/hooks/useMeasureList.js.map +1 -1
- package/lib-commonjs/hooks/useMutationObserver.js.map +1 -1
- package/lib-commonjs/hooks/useResizeObserverRef.js.map +1 -1
- package/lib-commonjs/hooks/useStaticPagination.js +2 -2
- package/lib-commonjs/hooks/useStaticPagination.js.map +1 -1
- package/lib-commonjs/hooks/useVirtualizerMeasure.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.js.map +1 -1
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.types.js +2 -0
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrolling.types.js.map +1 -1
- package/lib-commonjs/utilities/ImperativeScrolling/imperativeScrollingDynamic.js.map +1 -1
- package/lib-commonjs/utilities/ImperativeScrolling/index.js.map +1 -1
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js +4 -8
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -1
- package/lib-commonjs/utilities/VirtualizerContext/index.js.map +1 -1
- package/lib-commonjs/utilities/VirtualizerContext/types.js.map +1 -1
- package/lib-commonjs/utilities/createResizeObserverFromDocument.js.map +1 -1
- package/lib-commonjs/utilities/debounce.js.map +1 -1
- package/lib-commonjs/utilities/index.js.map +1 -1
- package/package.json +5 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-virtualizer
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 06 Dec 2024 12:49:19 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-alpha.88](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.88)
|
|
8
|
+
|
|
9
|
+
Fri, 06 Dec 2024 12:49:19 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.87..@fluentui/react-virtualizer_v9.0.0-alpha.88)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- feat: Add gap property to simplify gap css virtualization ([PR #33275](https://github.com/microsoft/fluentui/pull/33275) by mifraser@microsoft.com)
|
|
15
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.47 ([PR #33414](https://github.com/microsoft/fluentui/pull/33414) by beachball)
|
|
16
|
+
- Bump @fluentui/react-utilities to v9.18.18 ([PR #33414](https://github.com/microsoft/fluentui/pull/33414) by beachball)
|
|
17
|
+
- Bump @fluentui/react-shared-contexts to v9.21.1 ([PR #33414](https://github.com/microsoft/fluentui/pull/33414) by beachball)
|
|
18
|
+
|
|
19
|
+
## [9.0.0-alpha.87](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.87)
|
|
20
|
+
|
|
21
|
+
Mon, 11 Nov 2024 10:00:38 GMT
|
|
22
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.86..@fluentui/react-virtualizer_v9.0.0-alpha.87)
|
|
23
|
+
|
|
24
|
+
### Changes
|
|
25
|
+
|
|
26
|
+
- fix: Enable virtualizer to fall back to most recent IO event if none intersecting ([PR #33125](https://github.com/microsoft/fluentui/pull/33125) by mifraser@microsoft.com)
|
|
27
|
+
- chore: replace npm-scripts and just-scrtips with nx inferred tasks ([PR #33074](https://github.com/microsoft/fluentui/pull/33074) by martinhochel@microsoft.com)
|
|
28
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.46 ([PR #33238](https://github.com/microsoft/fluentui/pull/33238) by beachball)
|
|
29
|
+
- Bump @fluentui/react-utilities to v9.18.17 ([PR #33238](https://github.com/microsoft/fluentui/pull/33238) by beachball)
|
|
30
|
+
- Bump @fluentui/react-shared-contexts to v9.21.0 ([PR #33238](https://github.com/microsoft/fluentui/pull/33238) by beachball)
|
|
31
|
+
|
|
7
32
|
## [9.0.0-alpha.86](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.86)
|
|
8
33
|
|
|
9
|
-
Tue, 15 Oct 2024 17:
|
|
34
|
+
Tue, 15 Oct 2024 17:17:53 GMT
|
|
10
35
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.85..@fluentui/react-virtualizer_v9.0.0-alpha.86)
|
|
11
36
|
|
|
12
37
|
### Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import type { ComponentProps } from '@fluentui/react-utilities';
|
|
2
2
|
import type { ComponentState } from '@fluentui/react-utilities';
|
|
3
|
-
import type { Dispatch } from 'react';
|
|
4
|
-
import type { FC } from 'react';
|
|
5
|
-
import { MutableRefObject } from 'react';
|
|
6
3
|
import * as React_2 from 'react';
|
|
7
|
-
import type { RefObject } from 'react';
|
|
8
|
-
import type { SetStateAction } from 'react';
|
|
9
4
|
import type { Slot } from '@fluentui/react-utilities';
|
|
10
5
|
import type { SlotClassNames } from '@fluentui/react-utilities';
|
|
11
6
|
|
|
@@ -29,22 +24,22 @@ export declare const renderVirtualizerScrollViewDynamic_unstable: (state: Virtua
|
|
|
29
24
|
* Backwards compatible with ResizeObserverCallback if preferred
|
|
30
25
|
*/
|
|
31
26
|
export declare interface ResizeCallbackWithRef {
|
|
32
|
-
(entries: ResizeObserverEntry[], observer: ResizeObserver, scrollRef?: MutableRefObject<HTMLElement | null>): void;
|
|
27
|
+
(entries: ResizeObserverEntry[], observer: ResizeObserver, scrollRef?: React_2.MutableRefObject<HTMLElement | null>): void;
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
export declare type ScrollToInterface = {
|
|
36
31
|
scrollTo: (index: number, behavior?: ScrollBehavior, callback?: (index: number) => void) => void;
|
|
37
|
-
virtualizerLength: RefObject<number>;
|
|
38
|
-
currentIndex: RefObject<number> | undefined;
|
|
32
|
+
virtualizerLength: React_2.RefObject<number>;
|
|
33
|
+
currentIndex: React_2.RefObject<number> | undefined;
|
|
39
34
|
};
|
|
40
35
|
|
|
41
36
|
export declare const scrollToItemDynamic: (params: ScrollToItemDynamicParams) => void;
|
|
42
37
|
|
|
43
38
|
export declare type ScrollToItemDynamicParams = {
|
|
44
39
|
index: number;
|
|
45
|
-
itemSizes: RefObject<number[]>;
|
|
40
|
+
itemSizes: React_2.RefObject<number[]>;
|
|
46
41
|
totalSize: number;
|
|
47
|
-
scrollViewRef: RefObject<HTMLDivElement>;
|
|
42
|
+
scrollViewRef: React_2.RefObject<HTMLDivElement>;
|
|
48
43
|
axis?: 'horizontal' | 'vertical';
|
|
49
44
|
reversed?: boolean;
|
|
50
45
|
behavior?: ScrollBehavior;
|
|
@@ -56,7 +51,7 @@ export declare type ScrollToItemStaticParams = {
|
|
|
56
51
|
index: number;
|
|
57
52
|
itemSize: number;
|
|
58
53
|
totalItems: number;
|
|
59
|
-
scrollViewRef: RefObject<HTMLDivElement>;
|
|
54
|
+
scrollViewRef: React_2.RefObject<HTMLDivElement>;
|
|
60
55
|
axis?: 'horizontal' | 'vertical';
|
|
61
56
|
reversed?: boolean;
|
|
62
57
|
behavior?: ScrollBehavior;
|
|
@@ -71,6 +66,7 @@ export declare const useDynamicVirtualizerMeasure: <TElement extends HTMLElement
|
|
|
71
66
|
bufferSize: number;
|
|
72
67
|
scrollRef: (instance: TElement | null) => void;
|
|
73
68
|
containerSizeRef: React_2.RefObject<number>;
|
|
69
|
+
updateScrollPosition: (scrollPosition: number) => void;
|
|
74
70
|
};
|
|
75
71
|
|
|
76
72
|
/**
|
|
@@ -83,9 +79,9 @@ export declare const useDynamicVirtualizerMeasure: <TElement extends HTMLElement
|
|
|
83
79
|
* update the init options of the IntersectionObserver and a ref to the IntersectionObserver instance itself.
|
|
84
80
|
*/
|
|
85
81
|
export declare const useIntersectionObserver: (callback: IntersectionObserverCallback, options?: IntersectionObserverInit) => {
|
|
86
|
-
setObserverList: Dispatch<SetStateAction<Element[] | undefined>>;
|
|
82
|
+
setObserverList: React_2.Dispatch<React_2.SetStateAction<Element[] | undefined>>;
|
|
87
83
|
setObserverInit: (newInit: IntersectionObserverInit | undefined) => void;
|
|
88
|
-
observer: MutableRefObject<IntersectionObserver | undefined>;
|
|
84
|
+
observer: React_2.MutableRefObject<IntersectionObserver | undefined>;
|
|
89
85
|
};
|
|
90
86
|
|
|
91
87
|
/**
|
|
@@ -147,7 +143,7 @@ export declare const useVirtualizerStyles_unstable: (state: VirtualizerState) =>
|
|
|
147
143
|
* provides a simple interface for reducing the total number
|
|
148
144
|
* of elements rendered at one time in large lists.
|
|
149
145
|
*/
|
|
150
|
-
export declare const Virtualizer: FC<VirtualizerProps>;
|
|
146
|
+
export declare const Virtualizer: React_2.FC<VirtualizerProps>;
|
|
151
147
|
|
|
152
148
|
/**
|
|
153
149
|
* The main child render method of Virtualization
|
|
@@ -204,8 +200,7 @@ declare type VirtualizerConfigProps = {
|
|
|
204
200
|
bufferSize?: number;
|
|
205
201
|
/**
|
|
206
202
|
* Enables users to override the intersectionObserverRoot.
|
|
207
|
-
*
|
|
208
|
-
* when overlapping with other scroll views
|
|
203
|
+
* We recommend passing this in for accurate distance assessment in IO
|
|
209
204
|
*/
|
|
210
205
|
scrollViewRef?: React_2.MutableRefObject<HTMLElement | null>;
|
|
211
206
|
/**
|
|
@@ -236,16 +231,25 @@ declare type VirtualizerConfigProps = {
|
|
|
236
231
|
* Callback for notifying when a flagged index has been rendered
|
|
237
232
|
*/
|
|
238
233
|
onRenderedFlaggedIndex?: (index: number) => void;
|
|
239
|
-
flaggedIndex?: MutableRefObject<number | null>;
|
|
234
|
+
flaggedIndex?: React_2.MutableRefObject<number | null>;
|
|
240
235
|
/**
|
|
241
236
|
* Imperative ref contains our scrollTo index functionality for user control.
|
|
242
237
|
*/
|
|
243
|
-
imperativeVirtualizerRef?: RefObject<VirtualizerDataRef>;
|
|
238
|
+
imperativeVirtualizerRef?: React_2.RefObject<VirtualizerDataRef>;
|
|
244
239
|
/**
|
|
245
240
|
* A ref that provides the size of container (vertical - height, horizontal - width), set by a resize observer.
|
|
246
241
|
* Virtualizer Measure hooks provide a suitable reference.
|
|
247
242
|
*/
|
|
248
|
-
containerSizeRef: RefObject<number>;
|
|
243
|
+
containerSizeRef: React_2.RefObject<number>;
|
|
244
|
+
/**
|
|
245
|
+
* A callback that enables updating scroll position for calculating required dynamic lengths,
|
|
246
|
+
* this should be passed in from useDynamicVirtualizerMeasure
|
|
247
|
+
*/
|
|
248
|
+
updateScrollPosition?: (position: number) => void;
|
|
249
|
+
/**
|
|
250
|
+
* Spacing between rendered children for calculation, should match the container's gap CSS value.
|
|
251
|
+
*/
|
|
252
|
+
gap?: number;
|
|
249
253
|
};
|
|
250
254
|
|
|
251
255
|
declare type VirtualizerConfigState = {
|
|
@@ -304,18 +308,16 @@ declare type VirtualizerConfigState = {
|
|
|
304
308
|
export declare type VirtualizerContextProps = {
|
|
305
309
|
contextIndex: number;
|
|
306
310
|
setContextIndex: (index: number) => void;
|
|
307
|
-
contextPosition?: number;
|
|
308
|
-
setContextPosition?: (index: number) => void;
|
|
309
311
|
childProgressiveSizes?: React_2.MutableRefObject<number[]>;
|
|
310
312
|
};
|
|
311
313
|
|
|
312
314
|
export declare const VirtualizerContextProvider: React_2.Provider<VirtualizerContextProps>;
|
|
313
315
|
|
|
314
316
|
export declare type VirtualizerDataRef = {
|
|
315
|
-
progressiveSizes: RefObject<number[]>;
|
|
316
|
-
nodeSizes: RefObject<number[]>;
|
|
317
|
+
progressiveSizes: React_2.RefObject<number[]>;
|
|
318
|
+
nodeSizes: React_2.RefObject<number[]>;
|
|
317
319
|
setFlaggedIndex: (index: number | null) => void;
|
|
318
|
-
currentIndex: RefObject<number>;
|
|
320
|
+
currentIndex: React_2.RefObject<number>;
|
|
319
321
|
};
|
|
320
322
|
|
|
321
323
|
export declare type VirtualizerMeasureDynamicProps = {
|
|
@@ -389,7 +391,7 @@ export declare type VirtualizerScrollViewDynamicProps = ComponentProps<Partial<V
|
|
|
389
391
|
/**
|
|
390
392
|
* Imperative ref contains our scrollTo index functionality for user control.
|
|
391
393
|
*/
|
|
392
|
-
imperativeRef?: RefObject<ScrollToInterface>;
|
|
394
|
+
imperativeRef?: React_2.RefObject<ScrollToInterface>;
|
|
393
395
|
/**
|
|
394
396
|
* Imperative ref contains our scrollTo index functionality for user control.
|
|
395
397
|
*/
|
|
@@ -424,7 +426,7 @@ export declare type VirtualizerScrollViewProps = ComponentProps<Partial<Virtuali
|
|
|
424
426
|
/**
|
|
425
427
|
* Imperative ref contains our scrollTo index functionality for user control.
|
|
426
428
|
*/
|
|
427
|
-
imperativeRef?: RefObject<ScrollToInterface>;
|
|
429
|
+
imperativeRef?: React_2.RefObject<ScrollToInterface>;
|
|
428
430
|
/**
|
|
429
431
|
* Imperative ref contains our scrollTo index functionality for user control.
|
|
430
432
|
*/
|
package/lib/Hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Hooks.ts"],"sourcesContent":["export * from './hooks/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,gBAAgB"}
|
|
1
|
+
{"version":3,"sources":["../src/Hooks.ts"],"sourcesContent":["export * from './hooks/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,gBAAgB"}
|
package/lib/Utilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Utilities.ts"],"sourcesContent":["export * from './utilities/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,oBAAoB"}
|
|
1
|
+
{"version":3,"sources":["../src/Utilities.ts"],"sourcesContent":["export * from './utilities/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,oBAAoB"}
|
package/lib/Virtualizer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Virtualizer.ts"],"sourcesContent":["export * from './components/Virtualizer/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,iCAAiC"}
|
|
1
|
+
{"version":3,"sources":["../src/Virtualizer.ts"],"sourcesContent":["export * from './components/Virtualizer/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,iCAAiC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VirtualizerScrollView.ts"],"sourcesContent":["export * from './components/VirtualizerScrollView/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,2CAA2C"}
|
|
1
|
+
{"version":3,"sources":["../src/VirtualizerScrollView.ts"],"sourcesContent":["export * from './components/VirtualizerScrollView/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,2CAA2C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VirtualizerScrollViewDynamic.ts"],"sourcesContent":["export * from './components/VirtualizerScrollViewDynamic/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,kDAAkD"}
|
|
1
|
+
{"version":3,"sources":["../src/VirtualizerScrollViewDynamic.ts"],"sourcesContent":["export * from './components/VirtualizerScrollViewDynamic/index';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,kDAAkD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Virtualizer.ts"],"sourcesContent":["import type { VirtualizerProps } from './Virtualizer.types';\nimport { useVirtualizerStyles_unstable } from './useVirtualizerStyles.styles';\nimport { useVirtualizer_unstable } from './useVirtualizer';\nimport { renderVirtualizer_unstable } from './renderVirtualizer';\
|
|
1
|
+
{"version":3,"sources":["../src/components/Virtualizer/Virtualizer.ts"],"sourcesContent":["import * as React from 'react';\nimport type { VirtualizerProps } from './Virtualizer.types';\nimport { useVirtualizerStyles_unstable } from './useVirtualizerStyles.styles';\nimport { useVirtualizer_unstable } from './useVirtualizer';\nimport { renderVirtualizer_unstable } from './renderVirtualizer';\n\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 */\nexport const Virtualizer: React.FC<VirtualizerProps> = (props: VirtualizerProps) => {\n const state = useVirtualizer_unstable(props);\n useVirtualizerStyles_unstable(state);\n\n return renderVirtualizer_unstable(state);\n};\n\nVirtualizer.displayName = 'Virtualizer';\n"],"names":["React","useVirtualizerStyles_unstable","useVirtualizer_unstable","renderVirtualizer_unstable","Virtualizer","props","state","displayName"],"rangeMappings":";;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,6BAA6B,QAAQ,gCAAgC;AAC9E,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,0BAA0B,QAAQ,sBAAsB;AAEjE;;;;CAIC,GACD,OAAO,MAAMC,cAA0C,CAACC;IACtD,MAAMC,QAAQJ,wBAAwBG;IACtCJ,8BAA8BK;IAE9B,OAAOH,2BAA2BG;AACpC,EAAE;AAEFF,YAAYG,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Virtualizer.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { VirtualizerContextProps } from '../../Utilities';\
|
|
1
|
+
{"version":3,"sources":["../src/components/Virtualizer/Virtualizer.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { VirtualizerContextProps } from '../../Utilities';\n\nexport type VirtualizerSlots = {\n /**\n * The intersection observed 'before' element will detect when scrolling towards the beginning.\n */\n before: NonNullable<Slot<'div', 'td'>>;\n /**\n * A block place holding whitespace at the beginning of current DOM children.\n */\n beforeContainer: NonNullable<Slot<'div', 'tr'>>;\n /**\n * The intersection observed 'after' element will detect when scrolling towards the end.\n */\n after: NonNullable<Slot<'div', 'td'>>;\n /**\n * A block place holding whitespace after the end of current DOM children.\n */\n afterContainer: NonNullable<Slot<'div', 'tr'>>;\n};\n\nexport type VirtualizerConfigState = {\n /**\n * The current virtualized array of children to show in the DOM.\n */\n virtualizedChildren: React.ReactNode[];\n /**\n * The current start index for the virtualizer, all previous index's will be removed from DOM.\n */\n virtualizerStartIndex: number;\n /**\n * Current buffer height required at beginning of array.\n */\n afterBufferHeight: number;\n /**\n * Current buffer height required at end of array.\n */\n beforeBufferHeight: number;\n /**\n * The total current height of the scrollView/child content.\n */\n totalVirtualizerHeight: number;\n /**\n * The scroll direction\n * @default vertical\n */\n axis?: 'vertical' | 'horizontal';\n /**\n * Tells the virtualizer to measure in the reverse direction (for column-reverse order etc.)\n */\n reversed?: boolean;\n /**\n * Enables the isScrolling property in the child render function\n * Default: false - to prevent nessecary render function calls\n */\n enableScrollLoad?: boolean;\n /**\n * Pixel size of intersection observers and how much they 'cross over' into the bufferItems index.\n * Minimum 1px.\n */\n bufferSize: number;\n /**\n * Ref for access to internal size knowledge, can be used to measure updates\n */\n childSizes: React.MutableRefObject<number[]>;\n /**\n * Ref for access to internal progressive size knowledge, can be used to measure updates\n */\n childProgressiveSizes: React.MutableRefObject<number[]>;\n};\n\nexport type VirtualizerState = ComponentState<VirtualizerSlots> & VirtualizerConfigState;\n\n/**\n * The main child render method of Virtualization\n * isScrolling will only be enabled when enableScrollLoad is set to true.\n */\nexport type VirtualizerChildRenderFunction = (index: number, isScrolling: boolean) => React.ReactNode;\n\nexport type VirtualizerDataRef = {\n progressiveSizes: React.RefObject<number[]>;\n nodeSizes: React.RefObject<number[]>;\n setFlaggedIndex: (index: number | null) => void;\n currentIndex: React.RefObject<number>;\n};\n\nexport type VirtualizerConfigProps = {\n /**\n * Child render function.\n * Iteratively called to return current virtualizer DOM children.\n * Will act as a row or column indexer depending on Virtualizer settings.\n * Can be used dynamically.\n */\n children: VirtualizerChildRenderFunction;\n\n /**\n * Default cell size to use if no custom callback provided.\n * If implementing `getItemSize` this should be the initial and ideally minimum cell size.\n */\n itemSize: number;\n\n /**\n * The total number of items to be virtualized.\n */\n numItems: number;\n\n /**\n * Number of children to render in the DOM during virtualization.\n * Constraints:\n * - Large enough that the items rendered in DOM cover the viewport\n * and intersection observer buffers (buffersize) at both ends.\n */\n virtualizerLength: number;\n\n /**\n * Defaults to 1/4th (or 1/3rd for dynamic items) of virtualizerLength.\n * RECOMMEND: Override this with a consistent value if using a dynamic virtualizer.\n *\n * Controls the number of elements rendered before the current index entering the virtualized viewport.\n * Constraints:\n * - Large enough to cover bufferSize (prevents buffers intersecting into the viewport during rest state).\n * - Small enough that the virtualizer only renders a few items outside of view.\n */\n bufferItems?: number;\n\n /**\n * Defaults to half of bufferItems * itemSize size (in pixels).\n * RECOMMEND: Override this with a consistent minimum item size value if using a dynamic virtualizer.\n * The length (in pixels) before the end/start DOM index where the virtualizer recalculation will be triggered.\n * Increasing this reduces whitespace on ultra-fast scroll, as additional elements\n * are buffered to appear while virtualization recalculates.\n * Constraints:\n * - At least 1px - although this will only trigger the recalculation after bookends (whitespace) enter viewport.\n * - BufferSize must be smaller than bufferItems pixel size, as it prevents bookends entering viewport at rest.\n */\n bufferSize?: number;\n\n /**\n * Enables users to override the intersectionObserverRoot.\n * We recommend passing this in for accurate distance assessment in IO\n */\n scrollViewRef?: React.MutableRefObject<HTMLElement | null>;\n\n /**\n * The scroll direction\n * @default vertical\n */\n axis?: 'vertical' | 'horizontal';\n\n /**\n * Tells the virtualizer to measure in the reverse direction (for column-reverse order etc.)\n * This value should be flipped in RTL implementation (TBD whether automate RTL).\n */\n reversed?: boolean;\n\n /**\n * Enables the isScrolling property in the child render function\n * Default: false - to prevent nessecary render function calls\n */\n enableScrollLoad?: boolean;\n\n /**\n * Callback for acquiring size of individual items\n * @param index - the index of the requested size's child\n */\n getItemSize?: (index: number) => number;\n\n /**\n * Virtualizer context can be passed as a prop for extended class use\n */\n virtualizerContext?: VirtualizerContextProps;\n\n /**\n * Callback for notifying when a flagged index has been rendered\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onRenderedFlaggedIndex?: (index: number) => void;\n\n /*\n * Callback for notifying when a flagged index has been rendered\n */\n flaggedIndex?: React.MutableRefObject<number | null>;\n\n /**\n * Imperative ref contains our scrollTo index functionality for user control.\n */\n imperativeVirtualizerRef?: React.RefObject<VirtualizerDataRef>;\n\n /**\n * A ref that provides the size of container (vertical - height, horizontal - width), set by a resize observer.\n * Virtualizer Measure hooks provide a suitable reference.\n */\n containerSizeRef: React.RefObject<number>;\n\n /**\n * A callback that enables updating scroll position for calculating required dynamic lengths,\n * this should be passed in from useDynamicVirtualizerMeasure\n */\n updateScrollPosition?: (position: number) => void;\n\n /**\n * Spacing between rendered children for calculation, should match the container's gap CSS value.\n */\n gap?: number;\n};\n\nexport type VirtualizerProps = ComponentProps<Partial<VirtualizerSlots>> & VirtualizerConfigProps;\n"],"names":["React"],"rangeMappings":"","mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './Virtualizer';\nexport * from './Virtualizer.types';\nexport * from './useVirtualizer';\nexport * from './renderVirtualizer';\nexport * from './useVirtualizerStyles.styles';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,sBAAsB;AACpC,cAAc,gCAAgC"}
|
|
1
|
+
{"version":3,"sources":["../src/components/Virtualizer/index.ts"],"sourcesContent":["export * from './Virtualizer';\nexport * from './Virtualizer.types';\nexport * from './useVirtualizer';\nexport * from './renderVirtualizer';\nexport * from './useVirtualizerStyles.styles';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,sBAAsB;AACpC,cAAc,gCAAgC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["renderVirtualizer.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport * as React from 'react';\nimport type { VirtualizerSlots, VirtualizerState } from './Virtualizer.types';\
|
|
1
|
+
{"version":3,"sources":["../src/components/Virtualizer/renderVirtualizer.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport * as React from 'react';\nimport type { VirtualizerSlots, VirtualizerState } from './Virtualizer.types';\n\nimport { assertSlots } from '@fluentui/react-utilities';\n\nexport const renderVirtualizer_unstable = (state: VirtualizerState) => {\n assertSlots<VirtualizerSlots>(state);\n return (\n <React.Fragment>\n {/* The 'before' bookend to hold items in place and detect scroll previous */}\n <state.beforeContainer>\n <state.before />\n </state.beforeContainer>\n {/* The reduced list of non-virtualized children to be rendered */}\n {state.virtualizedChildren}\n {/* The 'after' bookend to hold items in place and detect scroll next */}\n <state.afterContainer>\n <state.after />\n </state.afterContainer>\n </React.Fragment>\n );\n};\n\nexport const renderVirtualizerChildPlaceholder = (child: React.ReactNode, index: number) => {\n return (\n <React.Suspense key={`fui-virtualizer-placeholder-${index}`} fallback={null}>\n {child}\n </React.Suspense>\n );\n};\n"],"names":["React","assertSlots","renderVirtualizer_unstable","state","Fragment","beforeContainer","before","virtualizedChildren","afterContainer","after","renderVirtualizerChildPlaceholder","child","index","Suspense","fallback"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,YAAYA,WAAW,QAAQ;AAG/B,SAASC,WAAW,QAAQ,4BAA4B;AAExD,OAAO,MAAMC,6BAA6B,CAACC;IACzCF,YAA8BE;IAC9B,qBACE,MAACH,MAAMI,QAAQ;;0BAEb,KAACD,MAAME,eAAe;0BACpB,cAAA,KAACF,MAAMG,MAAM;;YAGdH,MAAMI,mBAAmB;0BAE1B,KAACJ,MAAMK,cAAc;0BACnB,cAAA,KAACL,MAAMM,KAAK;;;;AAIpB,EAAE;AAEF,OAAO,MAAMC,oCAAoC,CAACC,OAAwBC;IACxE,qBACE,KAACZ,MAAMa,QAAQ;QAA8CC,UAAU;kBACpEH;OADkB,CAAC,4BAA4B,EAAEC,MAAM,CAAC;AAI/D,EAAE"}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
|
|
3
3
|
import { useVirtualizerContextState_unstable } from '../../Utilities';
|
|
4
4
|
import { slot, useTimeout } from '@fluentui/react-utilities';
|
|
5
5
|
import { flushSync } from 'react-dom';
|
|
6
6
|
export function useVirtualizer_unstable(props) {
|
|
7
7
|
'use no memo';
|
|
8
|
-
const { itemSize, numItems, virtualizerLength, children: renderChild, getItemSize, bufferItems = Math.round(virtualizerLength / 4.0), bufferSize = Math.floor(bufferItems / 2.0) * itemSize, axis = 'vertical', reversed = false, virtualizerContext, onRenderedFlaggedIndex, imperativeVirtualizerRef, containerSizeRef, scrollViewRef, enableScrollLoad } = props;
|
|
8
|
+
const { itemSize, numItems, virtualizerLength, children: renderChild, getItemSize, bufferItems = Math.round(virtualizerLength / 4.0), bufferSize = Math.floor(bufferItems / 2.0) * itemSize, axis = 'vertical', reversed = false, virtualizerContext, onRenderedFlaggedIndex, imperativeVirtualizerRef, containerSizeRef, scrollViewRef, enableScrollLoad, updateScrollPosition, gap = 0 } = props;
|
|
9
9
|
/* The context is optional, it's useful for injecting additional index logic, or performing uniform state updates*/ const _virtualizerContext = useVirtualizerContextState_unstable(virtualizerContext);
|
|
10
10
|
// We use this ref as a constant source to access the virtualizer's state imperatively
|
|
11
|
-
const actualIndexRef = useRef(_virtualizerContext.contextIndex);
|
|
12
|
-
const flaggedIndex = useRef(null);
|
|
11
|
+
const actualIndexRef = React.useRef(_virtualizerContext.contextIndex);
|
|
12
|
+
const flaggedIndex = React.useRef(null);
|
|
13
13
|
const actualIndex = _virtualizerContext.contextIndex;
|
|
14
14
|
// Just in case our ref gets out of date vs the context during a re-render
|
|
15
15
|
if (_virtualizerContext.contextIndex !== actualIndexRef.current) {
|
|
16
16
|
actualIndexRef.current = _virtualizerContext.contextIndex;
|
|
17
17
|
}
|
|
18
|
-
const setActualIndex = useCallback((index)=>{
|
|
18
|
+
const setActualIndex = React.useCallback((index)=>{
|
|
19
19
|
actualIndexRef.current = index;
|
|
20
20
|
_virtualizerContext.setContextIndex(index);
|
|
21
21
|
}, [
|
|
22
22
|
_virtualizerContext
|
|
23
23
|
]);
|
|
24
24
|
// Store ref to before padding element
|
|
25
|
-
const beforeElementRef = useRef(null);
|
|
25
|
+
const beforeElementRef = React.useRef(null);
|
|
26
26
|
// Store ref to before padding element
|
|
27
|
-
const afterElementRef = useRef(null);
|
|
27
|
+
const afterElementRef = React.useRef(null);
|
|
28
28
|
// We need to store an array to track dynamic sizes, we can use this to incrementally update changes
|
|
29
|
-
const childSizes = useRef(new Array(getItemSize ? numItems : 0));
|
|
29
|
+
const childSizes = React.useRef(new Array(getItemSize ? numItems : 0));
|
|
30
30
|
/* We keep track of the progressive sizing/placement down the list,
|
|
31
|
-
this helps us skip re-calculations unless children/size changes */ const childProgressiveSizes = useRef(new Array(getItemSize ? numItems : 0));
|
|
31
|
+
this helps us skip re-calculations unless children/size changes */ const childProgressiveSizes = React.useRef(new Array(getItemSize ? numItems : 0));
|
|
32
32
|
if (virtualizerContext === null || virtualizerContext === void 0 ? void 0 : virtualizerContext.childProgressiveSizes) {
|
|
33
33
|
virtualizerContext.childProgressiveSizes.current = childProgressiveSizes.current;
|
|
34
34
|
}
|
|
35
35
|
// The internal tracking REF for child array (updates often).
|
|
36
|
-
const childArray = useRef(new Array(virtualizerLength));
|
|
36
|
+
const childArray = React.useRef(new Array(virtualizerLength));
|
|
37
37
|
const populateSizeArrays = ()=>{
|
|
38
38
|
if (!getItemSize) {
|
|
39
39
|
// Static sizes, never mind!
|
|
@@ -49,7 +49,8 @@ export function useVirtualizer_unstable(props) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
for(let index = 0; index < numItems; index++){
|
|
52
|
-
|
|
52
|
+
const _gap = index < numItems - 1 ? gap : 0;
|
|
53
|
+
childSizes.current[index] = getItemSize(index) + _gap;
|
|
53
54
|
if (index === 0) {
|
|
54
55
|
childProgressiveSizes.current[index] = childSizes.current[index];
|
|
55
56
|
} else {
|
|
@@ -57,10 +58,10 @@ export function useVirtualizer_unstable(props) {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
|
-
const [isScrolling, setIsScrolling] = useState(false);
|
|
61
|
+
const [isScrolling, setIsScrolling] = React.useState(false);
|
|
61
62
|
const [setScrollTimer, clearScrollTimer] = useTimeout();
|
|
62
|
-
const scrollCounter = useRef(0);
|
|
63
|
-
const initializeScrollingTimer = useCallback(()=>{
|
|
63
|
+
const scrollCounter = React.useRef(0);
|
|
64
|
+
const initializeScrollingTimer = React.useCallback(()=>{
|
|
64
65
|
if (!enableScrollLoad) {
|
|
65
66
|
// Disabled by default for reduction of render callbacks
|
|
66
67
|
return;
|
|
@@ -86,13 +87,13 @@ export function useVirtualizer_unstable(props) {
|
|
|
86
87
|
setScrollTimer,
|
|
87
88
|
enableScrollLoad
|
|
88
89
|
]);
|
|
89
|
-
useEffect(()=>{
|
|
90
|
+
React.useEffect(()=>{
|
|
90
91
|
initializeScrollingTimer();
|
|
91
92
|
}, [
|
|
92
93
|
actualIndex,
|
|
93
94
|
initializeScrollingTimer
|
|
94
95
|
]);
|
|
95
|
-
const updateChildRows = useCallback((newIndex)=>{
|
|
96
|
+
const updateChildRows = React.useCallback((newIndex)=>{
|
|
96
97
|
if (numItems === 0) {
|
|
97
98
|
/* Nothing to virtualize */ return;
|
|
98
99
|
}
|
|
@@ -111,7 +112,7 @@ export function useVirtualizer_unstable(props) {
|
|
|
111
112
|
renderChild,
|
|
112
113
|
virtualizerLength
|
|
113
114
|
]);
|
|
114
|
-
const updateCurrentItemSizes = useCallback((newIndex)=>{
|
|
115
|
+
const updateCurrentItemSizes = React.useCallback((newIndex)=>{
|
|
115
116
|
if (!getItemSize) {
|
|
116
117
|
// Static sizes, not required.
|
|
117
118
|
return;
|
|
@@ -122,7 +123,8 @@ export function useVirtualizer_unstable(props) {
|
|
|
122
123
|
const startIndex = Math.max(newIndex, 0);
|
|
123
124
|
let didUpdate = false;
|
|
124
125
|
for(let i = startIndex; i < endIndex; i++){
|
|
125
|
-
const
|
|
126
|
+
const _gap = i < numItems - 1 ? gap : 0;
|
|
127
|
+
const newSize = getItemSize(i) + _gap;
|
|
126
128
|
if (newSize !== childSizes.current[i]) {
|
|
127
129
|
childSizes.current[i] = newSize;
|
|
128
130
|
didUpdate = true;
|
|
@@ -138,9 +140,10 @@ export function useVirtualizer_unstable(props) {
|
|
|
138
140
|
}, [
|
|
139
141
|
getItemSize,
|
|
140
142
|
numItems,
|
|
141
|
-
virtualizerLength
|
|
143
|
+
virtualizerLength,
|
|
144
|
+
gap
|
|
142
145
|
]);
|
|
143
|
-
const batchUpdateNewIndex = useCallback((index)=>{
|
|
146
|
+
const batchUpdateNewIndex = React.useCallback((index)=>{
|
|
144
147
|
// Local updates
|
|
145
148
|
updateChildRows(index);
|
|
146
149
|
updateCurrentItemSizes(index);
|
|
@@ -151,7 +154,7 @@ export function useVirtualizer_unstable(props) {
|
|
|
151
154
|
updateChildRows,
|
|
152
155
|
updateCurrentItemSizes
|
|
153
156
|
]);
|
|
154
|
-
const findIndexRecursive = useCallback((scrollPos, lowIndex, highIndex)=>{
|
|
157
|
+
const findIndexRecursive = React.useCallback((scrollPos, lowIndex, highIndex)=>{
|
|
155
158
|
if (lowIndex > highIndex) {
|
|
156
159
|
// We shouldn't get here - but no-op the index if we do.
|
|
157
160
|
return actualIndex;
|
|
@@ -174,7 +177,7 @@ export function useVirtualizer_unstable(props) {
|
|
|
174
177
|
}, [
|
|
175
178
|
actualIndex
|
|
176
179
|
]);
|
|
177
|
-
const getIndexFromSizeArray = useCallback((scrollPos)=>{
|
|
180
|
+
const getIndexFromSizeArray = React.useCallback((scrollPos)=>{
|
|
178
181
|
/* Quick searches our progressive height array */ if (scrollPos === 0 || childProgressiveSizes.current.length === 0 || scrollPos <= childProgressiveSizes.current[0]) {
|
|
179
182
|
// Check start
|
|
180
183
|
return 0;
|
|
@@ -187,32 +190,34 @@ export function useVirtualizer_unstable(props) {
|
|
|
187
190
|
}, [
|
|
188
191
|
findIndexRecursive
|
|
189
192
|
]);
|
|
190
|
-
const getIndexFromScrollPosition = useCallback((scrollPos)=>{
|
|
193
|
+
const getIndexFromScrollPosition = React.useCallback((scrollPos)=>{
|
|
191
194
|
if (!getItemSize) {
|
|
192
|
-
return Math.round(scrollPos / itemSize);
|
|
195
|
+
return Math.round(scrollPos / (itemSize + gap));
|
|
193
196
|
}
|
|
194
197
|
return getIndexFromSizeArray(scrollPos);
|
|
195
198
|
}, [
|
|
196
199
|
getIndexFromSizeArray,
|
|
197
200
|
getItemSize,
|
|
198
|
-
itemSize
|
|
201
|
+
itemSize,
|
|
202
|
+
gap
|
|
199
203
|
]);
|
|
200
|
-
const calculateTotalSize = useCallback(()=>{
|
|
204
|
+
const calculateTotalSize = React.useCallback(()=>{
|
|
201
205
|
if (!getItemSize) {
|
|
202
|
-
return itemSize * numItems;
|
|
206
|
+
return (itemSize + gap) * numItems;
|
|
203
207
|
}
|
|
204
208
|
// Time for custom size calcs
|
|
205
209
|
return childProgressiveSizes.current[numItems - 1];
|
|
206
210
|
}, [
|
|
207
211
|
getItemSize,
|
|
208
212
|
itemSize,
|
|
209
|
-
numItems
|
|
213
|
+
numItems,
|
|
214
|
+
gap
|
|
210
215
|
]);
|
|
211
|
-
const calculateBefore = useCallback(()=>{
|
|
216
|
+
const calculateBefore = React.useCallback(()=>{
|
|
212
217
|
const currentIndex = Math.min(actualIndex, numItems - 1);
|
|
213
218
|
if (!getItemSize) {
|
|
214
219
|
// The missing items from before virtualization starts height
|
|
215
|
-
return currentIndex * itemSize;
|
|
220
|
+
return currentIndex * (itemSize + gap);
|
|
216
221
|
}
|
|
217
222
|
if (currentIndex <= 0) {
|
|
218
223
|
return 0;
|
|
@@ -223,9 +228,10 @@ export function useVirtualizer_unstable(props) {
|
|
|
223
228
|
actualIndex,
|
|
224
229
|
getItemSize,
|
|
225
230
|
itemSize,
|
|
226
|
-
numItems
|
|
231
|
+
numItems,
|
|
232
|
+
gap
|
|
227
233
|
]);
|
|
228
|
-
const calculateAfter = useCallback(()=>{
|
|
234
|
+
const calculateAfter = React.useCallback(()=>{
|
|
229
235
|
if (numItems === 0 || actualIndex + virtualizerLength >= numItems) {
|
|
230
236
|
return 0;
|
|
231
237
|
}
|
|
@@ -233,7 +239,7 @@ export function useVirtualizer_unstable(props) {
|
|
|
233
239
|
if (!getItemSize) {
|
|
234
240
|
// The missing items from after virtualization ends height
|
|
235
241
|
const remainingItems = numItems - lastItemIndex;
|
|
236
|
-
return remainingItems * itemSize;
|
|
242
|
+
return remainingItems * (itemSize + gap) - gap;
|
|
237
243
|
}
|
|
238
244
|
// Time for custom size calcs
|
|
239
245
|
return childProgressiveSizes.current[numItems - 1] - childProgressiveSizes.current[lastItemIndex - 1];
|
|
@@ -242,10 +248,11 @@ export function useVirtualizer_unstable(props) {
|
|
|
242
248
|
getItemSize,
|
|
243
249
|
itemSize,
|
|
244
250
|
numItems,
|
|
245
|
-
virtualizerLength
|
|
251
|
+
virtualizerLength,
|
|
252
|
+
gap
|
|
246
253
|
]);
|
|
247
254
|
// Observe intersections of virtualized components
|
|
248
|
-
const { setObserverList } = useIntersectionObserver(useCallback(// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
255
|
+
const { setObserverList } = useIntersectionObserver(React.useCallback(// TODO: exclude types from this lint rule: https://github.com/microsoft/fluentui/issues/31286
|
|
249
256
|
// eslint-disable-next-line no-restricted-globals
|
|
250
257
|
(entries, observer)=>{
|
|
251
258
|
/* Sanity check - do we even need virtualization? */ if (virtualizerLength > numItems) {
|
|
@@ -255,12 +262,16 @@ export function useVirtualizer_unstable(props) {
|
|
|
255
262
|
// No-op
|
|
256
263
|
return;
|
|
257
264
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return
|
|
265
|
+
if (entries.length === 0) {
|
|
266
|
+
// No entries found, return.
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
// Find the latest entry that is intersecting
|
|
270
|
+
const sortedEntries = entries.sort((entry1, entry2)=>entry2.time - entry1.time);
|
|
271
|
+
const latestEntry = sortedEntries.find((entry)=>{
|
|
272
|
+
return entry.isIntersecting;
|
|
261
273
|
});
|
|
262
|
-
if (!latestEntry
|
|
263
|
-
// If we don't find an intersecting area, ignore for now.
|
|
274
|
+
if (!latestEntry) {
|
|
264
275
|
return;
|
|
265
276
|
}
|
|
266
277
|
// We have to be sure our item sizes are up to date with current indexed ref before calculation
|
|
@@ -330,33 +341,38 @@ export function useVirtualizer_unstable(props) {
|
|
|
330
341
|
// Safety limits
|
|
331
342
|
const newStartIndex = Math.min(Math.max(startIndex, 0), maxIndex);
|
|
332
343
|
flushSync(()=>{
|
|
333
|
-
|
|
344
|
+
// Callback to allow measure functions to check virtualizer length
|
|
345
|
+
if (newStartIndex + virtualizerLength >= numItems && actualIndex + virtualizerLength >= numItems) {
|
|
346
|
+
// We've already hit the end, no need to update state.
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
updateScrollPosition === null || updateScrollPosition === void 0 ? void 0 : updateScrollPosition(measurementPos);
|
|
334
350
|
if (actualIndex !== newStartIndex) {
|
|
335
351
|
batchUpdateNewIndex(newStartIndex);
|
|
336
352
|
}
|
|
337
353
|
});
|
|
338
354
|
}, [
|
|
339
|
-
_virtualizerContext,
|
|
340
355
|
actualIndex,
|
|
356
|
+
virtualizerLength,
|
|
341
357
|
axis,
|
|
342
|
-
|
|
343
|
-
|
|
358
|
+
reversed,
|
|
359
|
+
numItems,
|
|
344
360
|
bufferSize,
|
|
361
|
+
bufferItems,
|
|
362
|
+
containerSizeRef,
|
|
363
|
+
updateScrollPosition,
|
|
364
|
+
batchUpdateNewIndex,
|
|
345
365
|
calculateAfter,
|
|
346
366
|
calculateBefore,
|
|
347
367
|
calculateTotalSize,
|
|
348
|
-
containerSizeRef,
|
|
349
368
|
getIndexFromScrollPosition,
|
|
350
|
-
|
|
351
|
-
reversed,
|
|
352
|
-
updateCurrentItemSizes,
|
|
353
|
-
virtualizerLength
|
|
369
|
+
updateCurrentItemSizes
|
|
354
370
|
]), {
|
|
355
371
|
root: scrollViewRef ? scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current : null,
|
|
356
372
|
rootMargin: '0px',
|
|
357
373
|
threshold: 0
|
|
358
374
|
});
|
|
359
|
-
const setBeforeRef = useCallback((element)=>{
|
|
375
|
+
const setBeforeRef = React.useCallback((element)=>{
|
|
360
376
|
if (!element || beforeElementRef.current === element) {
|
|
361
377
|
return;
|
|
362
378
|
}
|
|
@@ -371,7 +387,7 @@ export function useVirtualizer_unstable(props) {
|
|
|
371
387
|
}, [
|
|
372
388
|
setObserverList
|
|
373
389
|
]);
|
|
374
|
-
const setAfterRef = useCallback((element)=>{
|
|
390
|
+
const setAfterRef = React.useCallback((element)=>{
|
|
375
391
|
if (!element || afterElementRef.current === element) {
|
|
376
392
|
return;
|
|
377
393
|
}
|
|
@@ -387,14 +403,14 @@ export function useVirtualizer_unstable(props) {
|
|
|
387
403
|
setObserverList
|
|
388
404
|
]);
|
|
389
405
|
// Initialize the size array before first render.
|
|
390
|
-
const hasInitialized = useRef(false);
|
|
406
|
+
const hasInitialized = React.useRef(false);
|
|
391
407
|
const initializeSizeArray = ()=>{
|
|
392
408
|
if (hasInitialized.current === false) {
|
|
393
409
|
hasInitialized.current = true;
|
|
394
410
|
populateSizeArrays();
|
|
395
411
|
}
|
|
396
412
|
};
|
|
397
|
-
useImperativeHandle(imperativeVirtualizerRef, ()=>{
|
|
413
|
+
React.useImperativeHandle(imperativeVirtualizerRef, ()=>{
|
|
398
414
|
return {
|
|
399
415
|
progressiveSizes: childProgressiveSizes,
|
|
400
416
|
nodeSizes: childSizes,
|
|
@@ -407,7 +423,7 @@ export function useVirtualizer_unstable(props) {
|
|
|
407
423
|
]);
|
|
408
424
|
// Initialization on mount - update array index to 0 (ready state).
|
|
409
425
|
// Only fire on mount (no deps).
|
|
410
|
-
useEffect(()=>{
|
|
426
|
+
React.useEffect(()=>{
|
|
411
427
|
if (actualIndex < 0) {
|
|
412
428
|
batchUpdateNewIndex(0);
|
|
413
429
|
}
|
|
@@ -417,9 +433,9 @@ export function useVirtualizer_unstable(props) {
|
|
|
417
433
|
* forceUpdate:
|
|
418
434
|
* We only want to trigger this when scrollLoading is enabled and set to false,
|
|
419
435
|
* it will force re-render all children elements
|
|
420
|
-
*/ const forceUpdate = useReducer(()=>({}), {})[1];
|
|
436
|
+
*/ const forceUpdate = React.useReducer(()=>({}), {})[1];
|
|
421
437
|
// If the user passes in an updated renderChild function - update current children
|
|
422
|
-
useEffect(()=>{
|
|
438
|
+
React.useEffect(()=>{
|
|
423
439
|
if (actualIndex >= 0) {
|
|
424
440
|
updateChildRows(actualIndex);
|
|
425
441
|
if (enableScrollLoad && !isScrolling) {
|
|
@@ -431,16 +447,17 @@ export function useVirtualizer_unstable(props) {
|
|
|
431
447
|
renderChild,
|
|
432
448
|
isScrolling
|
|
433
449
|
]);
|
|
434
|
-
useEffect(()=>{
|
|
450
|
+
React.useEffect(()=>{
|
|
435
451
|
// Ensure we repopulate if getItemSize callback changes
|
|
436
452
|
populateSizeArrays();
|
|
437
453
|
// We only run this effect on getItemSize change (recalc dynamic sizes)
|
|
438
454
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
439
455
|
}, [
|
|
440
|
-
getItemSize
|
|
456
|
+
getItemSize,
|
|
457
|
+
gap
|
|
441
458
|
]);
|
|
442
459
|
// Effect to check flag index on updates
|
|
443
|
-
useEffect(()=>{
|
|
460
|
+
React.useEffect(()=>{
|
|
444
461
|
if (!onRenderedFlaggedIndex || flaggedIndex.current === null) {
|
|
445
462
|
return;
|
|
446
463
|
}
|