@fluentui/react-virtualizer 9.0.0-alpha.87 → 9.0.0-alpha.89
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 +29 -5
- package/dist/index.d.ts +21 -22
- package/lib/Hooks.js +1 -1
- package/lib/Hooks.js.map +1 -1
- package/lib/Utilities.js +1 -1
- package/lib/Utilities.js.map +1 -1
- package/lib/Virtualizer.js +1 -1
- package/lib/Virtualizer.js.map +1 -1
- package/lib/VirtualizerScrollView.js +1 -1
- package/lib/VirtualizerScrollView.js.map +1 -1
- package/lib/VirtualizerScrollViewDynamic.js +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 +4 -5
- package/lib/components/Virtualizer/index.js.map +1 -1
- package/lib/components/Virtualizer/renderVirtualizer.js.map +1 -1
- package/lib/components/Virtualizer/useVirtualizer.js +53 -45
- package/lib/components/Virtualizer/useVirtualizer.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 +4 -5
- package/lib/components/VirtualizerScrollView/index.js.map +1 -1
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.js +1 -2
- package/lib/components/VirtualizerScrollView/useVirtualizerScrollView.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 +4 -5
- package/lib/components/VirtualizerScrollViewDynamic/index.js.map +1 -1
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +2 -3
- package/lib/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +1 -1
- package/lib/hooks/hooks.types.js +1 -4
- package/lib/hooks/hooks.types.js.map +1 -1
- package/lib/hooks/index.js +5 -6
- 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/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/useStaticPagination.js +2 -3
- package/lib/hooks/useStaticPagination.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/index.js +2 -3
- package/lib/utilities/ImperativeScrolling/index.js.map +1 -1
- package/lib/utilities/VirtualizerContext/VirtualizerContext.js +3 -4
- package/lib/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -1
- package/lib/utilities/VirtualizerContext/index.js +1 -2
- package/lib/utilities/VirtualizerContext/index.js.map +1 -1
- package/lib/utilities/index.js +2 -2
- package/lib/utilities/index.js.map +1 -1
- package/lib-commonjs/Hooks.js +30 -2
- package/lib-commonjs/Hooks.js.map +1 -1
- package/lib-commonjs/Utilities.js +24 -2
- package/lib-commonjs/Utilities.js.map +1 -1
- package/lib-commonjs/Virtualizer.js +27 -2
- package/lib-commonjs/Virtualizer.js.map +1 -1
- package/lib-commonjs/VirtualizerScrollView.js +24 -2
- package/lib-commonjs/VirtualizerScrollView.js.map +1 -1
- package/lib-commonjs/VirtualizerScrollViewDynamic.js +24 -2
- 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 +30 -6
- 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 +54 -45
- package/lib-commonjs/components/Virtualizer/useVirtualizer.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 +27 -6
- package/lib-commonjs/components/VirtualizerScrollView/index.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/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js +2 -0
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/VirtualizerScrollViewDynamic.types.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js +27 -6
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/index.js.map +1 -1
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js +2 -2
- package/lib-commonjs/components/VirtualizerScrollViewDynamic/useVirtualizerScrollViewDynamic.js.map +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 +34 -7
- 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/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/useStaticPagination.js +2 -2
- package/lib-commonjs/hooks/useStaticPagination.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/index.js +16 -4
- package/lib-commonjs/utilities/ImperativeScrolling/index.js.map +1 -1
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js +3 -3
- package/lib-commonjs/utilities/VirtualizerContext/VirtualizerContext.js.map +1 -1
- package/lib-commonjs/utilities/VirtualizerContext/index.js +18 -3
- package/lib-commonjs/utilities/VirtualizerContext/index.js.map +1 -1
- package/lib-commonjs/utilities/index.js +25 -3
- package/lib-commonjs/utilities/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,21 +1,45 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-virtualizer
|
|
2
2
|
|
|
3
|
-
This log was last generated on Mon,
|
|
3
|
+
This log was last generated on Mon, 16 Dec 2024 16:22:05 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-alpha.89](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.89)
|
|
8
|
+
|
|
9
|
+
Mon, 16 Dec 2024 16:22:05 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.88..@fluentui/react-virtualizer_v9.0.0-alpha.89)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- chore: remove usage of "export *" ([PR #33457](https://github.com/microsoft/fluentui/pull/33457) by olfedias@microsoft.com)
|
|
15
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.48 ([PR #33468](https://github.com/microsoft/fluentui/pull/33468) by beachball)
|
|
16
|
+
- Bump @fluentui/react-utilities to v9.18.19 ([PR #33468](https://github.com/microsoft/fluentui/pull/33468) by beachball)
|
|
17
|
+
- Bump @fluentui/react-shared-contexts to v9.21.2 ([PR #33468](https://github.com/microsoft/fluentui/pull/33468) by beachball)
|
|
18
|
+
|
|
19
|
+
## [9.0.0-alpha.88](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.88)
|
|
20
|
+
|
|
21
|
+
Fri, 06 Dec 2024 12:53:45 GMT
|
|
22
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.87..@fluentui/react-virtualizer_v9.0.0-alpha.88)
|
|
23
|
+
|
|
24
|
+
### Changes
|
|
25
|
+
|
|
26
|
+
- feat: Add gap property to simplify gap css virtualization ([PR #33275](https://github.com/microsoft/fluentui/pull/33275) by mifraser@microsoft.com)
|
|
27
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.47 ([PR #33372](https://github.com/microsoft/fluentui/pull/33372) by beachball)
|
|
28
|
+
- Bump @fluentui/react-utilities to v9.18.18 ([PR #33372](https://github.com/microsoft/fluentui/pull/33372) by beachball)
|
|
29
|
+
- Bump @fluentui/react-shared-contexts to v9.21.1 ([PR #33372](https://github.com/microsoft/fluentui/pull/33372) by beachball)
|
|
30
|
+
|
|
7
31
|
## [9.0.0-alpha.87](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.87)
|
|
8
32
|
|
|
9
|
-
Mon, 11 Nov 2024
|
|
33
|
+
Mon, 11 Nov 2024 10:00:38 GMT
|
|
10
34
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-virtualizer_v9.0.0-alpha.86..@fluentui/react-virtualizer_v9.0.0-alpha.87)
|
|
11
35
|
|
|
12
36
|
### Changes
|
|
13
37
|
|
|
14
38
|
- 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)
|
|
15
39
|
- chore: replace npm-scripts and just-scrtips with nx inferred tasks ([PR #33074](https://github.com/microsoft/fluentui/pull/33074) by martinhochel@microsoft.com)
|
|
16
|
-
- Bump @fluentui/react-jsx-runtime to v9.0.46 ([PR #
|
|
17
|
-
- Bump @fluentui/react-utilities to v9.18.17 ([PR #
|
|
18
|
-
- Bump @fluentui/react-shared-contexts to v9.21.0 ([PR #
|
|
40
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.46 ([PR #33238](https://github.com/microsoft/fluentui/pull/33238) by beachball)
|
|
41
|
+
- Bump @fluentui/react-utilities to v9.18.17 ([PR #33238](https://github.com/microsoft/fluentui/pull/33238) by beachball)
|
|
42
|
+
- Bump @fluentui/react-shared-contexts to v9.21.0 ([PR #33238](https://github.com/microsoft/fluentui/pull/33238) by beachball)
|
|
19
43
|
|
|
20
44
|
## [9.0.0-alpha.86](https://github.com/microsoft/fluentui/tree/@fluentui/react-virtualizer_v9.0.0-alpha.86)
|
|
21
45
|
|
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;
|
|
@@ -84,9 +79,9 @@ export declare const useDynamicVirtualizerMeasure: <TElement extends HTMLElement
|
|
|
84
79
|
* update the init options of the IntersectionObserver and a ref to the IntersectionObserver instance itself.
|
|
85
80
|
*/
|
|
86
81
|
export declare const useIntersectionObserver: (callback: IntersectionObserverCallback, options?: IntersectionObserverInit) => {
|
|
87
|
-
setObserverList: Dispatch<SetStateAction<Element[] | undefined>>;
|
|
82
|
+
setObserverList: React_2.Dispatch<React_2.SetStateAction<Element[] | undefined>>;
|
|
88
83
|
setObserverInit: (newInit: IntersectionObserverInit | undefined) => void;
|
|
89
|
-
observer: MutableRefObject<IntersectionObserver | undefined>;
|
|
84
|
+
observer: React_2.MutableRefObject<IntersectionObserver | undefined>;
|
|
90
85
|
};
|
|
91
86
|
|
|
92
87
|
/**
|
|
@@ -148,7 +143,7 @@ export declare const useVirtualizerStyles_unstable: (state: VirtualizerState) =>
|
|
|
148
143
|
* provides a simple interface for reducing the total number
|
|
149
144
|
* of elements rendered at one time in large lists.
|
|
150
145
|
*/
|
|
151
|
-
export declare const Virtualizer: FC<VirtualizerProps>;
|
|
146
|
+
export declare const Virtualizer: React_2.FC<VirtualizerProps>;
|
|
152
147
|
|
|
153
148
|
/**
|
|
154
149
|
* The main child render method of Virtualization
|
|
@@ -236,21 +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>;
|
|
249
244
|
/**
|
|
250
245
|
* A callback that enables updating scroll position for calculating required dynamic lengths,
|
|
251
246
|
* this should be passed in from useDynamicVirtualizerMeasure
|
|
252
247
|
*/
|
|
253
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;
|
|
254
253
|
};
|
|
255
254
|
|
|
256
255
|
declare type VirtualizerConfigState = {
|
|
@@ -315,10 +314,10 @@ export declare type VirtualizerContextProps = {
|
|
|
315
314
|
export declare const VirtualizerContextProvider: React_2.Provider<VirtualizerContextProps>;
|
|
316
315
|
|
|
317
316
|
export declare type VirtualizerDataRef = {
|
|
318
|
-
progressiveSizes: RefObject<number[]>;
|
|
319
|
-
nodeSizes: RefObject<number[]>;
|
|
317
|
+
progressiveSizes: React_2.RefObject<number[]>;
|
|
318
|
+
nodeSizes: React_2.RefObject<number[]>;
|
|
320
319
|
setFlaggedIndex: (index: number | null) => void;
|
|
321
|
-
currentIndex: RefObject<number>;
|
|
320
|
+
currentIndex: React_2.RefObject<number>;
|
|
322
321
|
};
|
|
323
322
|
|
|
324
323
|
export declare type VirtualizerMeasureDynamicProps = {
|
|
@@ -392,7 +391,7 @@ export declare type VirtualizerScrollViewDynamicProps = ComponentProps<Partial<V
|
|
|
392
391
|
/**
|
|
393
392
|
* Imperative ref contains our scrollTo index functionality for user control.
|
|
394
393
|
*/
|
|
395
|
-
imperativeRef?: RefObject<ScrollToInterface>;
|
|
394
|
+
imperativeRef?: React_2.RefObject<ScrollToInterface>;
|
|
396
395
|
/**
|
|
397
396
|
* Imperative ref contains our scrollTo index functionality for user control.
|
|
398
397
|
*/
|
|
@@ -427,7 +426,7 @@ export declare type VirtualizerScrollViewProps = ComponentProps<Partial<Virtuali
|
|
|
427
426
|
/**
|
|
428
427
|
* Imperative ref contains our scrollTo index functionality for user control.
|
|
429
428
|
*/
|
|
430
|
-
imperativeRef?: RefObject<ScrollToInterface>;
|
|
429
|
+
imperativeRef?: React_2.RefObject<ScrollToInterface>;
|
|
431
430
|
/**
|
|
432
431
|
* Imperative ref contains our scrollTo index functionality for user control.
|
|
433
432
|
*/
|
package/lib/Hooks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { createResizeObserverFromDocument, getRTLRootMargin, useDynamicVirtualizerMeasure, useIntersectionObserver, useMeasureList, useResizeObserverRef_unstable, useStaticVirtualizerMeasure } from './hooks/index';
|
package/lib/Hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Hooks.ts"],"sourcesContent":["export
|
|
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"],"rangeMappings":"","mappings":"AAQA,SACEA,gCAAgC,EAChCC,gBAAgB,EAChBC,4BAA4B,EAC5BC,uBAAuB,EACvBC,cAAc,EACdC,6BAA6B,EAC7BC,2BAA2B,QACtB,gBAAgB"}
|
package/lib/Utilities.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { VirtualizerContextProvider, scrollToItemDynamic, scrollToItemStatic, useVirtualizerContextState_unstable, useVirtualizerContext_unstable } from './utilities/index';
|
package/lib/Utilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Utilities.ts"],"sourcesContent":["export
|
|
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"],"rangeMappings":"","mappings":"AAOA,SACEA,0BAA0B,EAC1BC,mBAAmB,EACnBC,kBAAkB,EAClBC,mCAAmC,EACnCC,8BAA8B,QACzB,oBAAoB"}
|
package/lib/Virtualizer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { Virtualizer, renderVirtualizerChildPlaceholder, renderVirtualizer_unstable, useVirtualizerStyles_unstable, useVirtualizer_unstable, virtualizerClassNames } from './components/Virtualizer/index';
|
package/lib/Virtualizer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Virtualizer.ts"],"sourcesContent":["export
|
|
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"],"rangeMappings":"","mappings":"AASA,SACEA,WAAW,EACXC,iCAAiC,EACjCC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,uBAAuB,EACvBC,qBAAqB,QAChB,iCAAiC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { VirtualizerScrollView, renderVirtualizerScrollView_unstable, useVirtualizerScrollViewStyles_unstable, useVirtualizerScrollView_unstable, virtualizerScrollViewClassNames } from './components/VirtualizerScrollView/index';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/VirtualizerScrollView.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../src/VirtualizerScrollView.ts"],"sourcesContent":["export type {\n VirtualizerScrollViewProps,\n VirtualizerScrollViewSlots,\n VirtualizerScrollViewState,\n} from './components/VirtualizerScrollView/index';\nexport {\n VirtualizerScrollView,\n renderVirtualizerScrollView_unstable,\n useVirtualizerScrollViewStyles_unstable,\n useVirtualizerScrollView_unstable,\n virtualizerScrollViewClassNames,\n} from './components/VirtualizerScrollView/index';\n"],"names":["VirtualizerScrollView","renderVirtualizerScrollView_unstable","useVirtualizerScrollViewStyles_unstable","useVirtualizerScrollView_unstable","virtualizerScrollViewClassNames"],"rangeMappings":"","mappings":"AAKA,SACEA,qBAAqB,EACrBC,oCAAoC,EACpCC,uCAAuC,EACvCC,iCAAiC,EACjCC,+BAA+B,QAC1B,2CAA2C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { VirtualizerScrollViewDynamic, renderVirtualizerScrollViewDynamic_unstable, useVirtualizerScrollViewDynamicStyles_unstable, useVirtualizerScrollViewDynamic_unstable, virtualizerScrollViewDynamicClassNames } from './components/VirtualizerScrollViewDynamic/index';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/VirtualizerScrollViewDynamic.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../src/VirtualizerScrollViewDynamic.ts"],"sourcesContent":["export type {\n VirtualizerScrollViewDynamicProps,\n VirtualizerScrollViewDynamicSlots,\n VirtualizerScrollViewDynamicState,\n} from './components/VirtualizerScrollViewDynamic/index';\nexport {\n VirtualizerScrollViewDynamic,\n renderVirtualizerScrollViewDynamic_unstable,\n useVirtualizerScrollViewDynamicStyles_unstable,\n useVirtualizerScrollViewDynamic_unstable,\n virtualizerScrollViewDynamicClassNames,\n} from './components/VirtualizerScrollViewDynamic/index';\n"],"names":["VirtualizerScrollViewDynamic","renderVirtualizerScrollViewDynamic_unstable","useVirtualizerScrollViewDynamicStyles_unstable","useVirtualizerScrollViewDynamic_unstable","virtualizerScrollViewDynamicClassNames"],"rangeMappings":"","mappings":"AAKA,SACEA,4BAA4B,EAC5BC,2CAA2C,EAC3CC,8CAA8C,EAC9CC,wCAAwC,EACxCC,sCAAsC,QACjC,kDAAkD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Virtualizer/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":["../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';\
|
|
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,5 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export * from './useVirtualizerStyles.styles';
|
|
1
|
+
export { Virtualizer } from './Virtualizer';
|
|
2
|
+
export { useVirtualizer_unstable } from './useVirtualizer';
|
|
3
|
+
export { renderVirtualizerChildPlaceholder, renderVirtualizer_unstable } from './renderVirtualizer';
|
|
4
|
+
export { useVirtualizerStyles_unstable, virtualizerClassNames } from './useVirtualizerStyles.styles';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Virtualizer/index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../src/components/Virtualizer/index.ts"],"sourcesContent":["export { Virtualizer } from './Virtualizer';\nexport type {\n VirtualizerChildRenderFunction,\n VirtualizerConfigProps,\n VirtualizerConfigState,\n VirtualizerDataRef,\n VirtualizerProps,\n VirtualizerSlots,\n VirtualizerState,\n} from './Virtualizer.types';\nexport { useVirtualizer_unstable } from './useVirtualizer';\nexport { renderVirtualizerChildPlaceholder, renderVirtualizer_unstable } from './renderVirtualizer';\nexport { useVirtualizerStyles_unstable, virtualizerClassNames } from './useVirtualizerStyles.styles';\n"],"names":["Virtualizer","useVirtualizer_unstable","renderVirtualizerChildPlaceholder","renderVirtualizer_unstable","useVirtualizerStyles_unstable","virtualizerClassNames"],"rangeMappings":";;;","mappings":"AAAA,SAASA,WAAW,QAAQ,gBAAgB;AAU5C,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,iCAAiC,EAAEC,0BAA0B,QAAQ,sBAAsB;AACpG,SAASC,6BAA6B,EAAEC,qBAAqB,QAAQ,gCAAgC"}
|
|
@@ -1 +1 @@
|
|
|
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';\
|
|
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, updateScrollPosition } = 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) {
|
|
@@ -365,7 +372,7 @@ export function useVirtualizer_unstable(props) {
|
|
|
365
372
|
rootMargin: '0px',
|
|
366
373
|
threshold: 0
|
|
367
374
|
});
|
|
368
|
-
const setBeforeRef = useCallback((element)=>{
|
|
375
|
+
const setBeforeRef = React.useCallback((element)=>{
|
|
369
376
|
if (!element || beforeElementRef.current === element) {
|
|
370
377
|
return;
|
|
371
378
|
}
|
|
@@ -380,7 +387,7 @@ export function useVirtualizer_unstable(props) {
|
|
|
380
387
|
}, [
|
|
381
388
|
setObserverList
|
|
382
389
|
]);
|
|
383
|
-
const setAfterRef = useCallback((element)=>{
|
|
390
|
+
const setAfterRef = React.useCallback((element)=>{
|
|
384
391
|
if (!element || afterElementRef.current === element) {
|
|
385
392
|
return;
|
|
386
393
|
}
|
|
@@ -396,14 +403,14 @@ export function useVirtualizer_unstable(props) {
|
|
|
396
403
|
setObserverList
|
|
397
404
|
]);
|
|
398
405
|
// Initialize the size array before first render.
|
|
399
|
-
const hasInitialized = useRef(false);
|
|
406
|
+
const hasInitialized = React.useRef(false);
|
|
400
407
|
const initializeSizeArray = ()=>{
|
|
401
408
|
if (hasInitialized.current === false) {
|
|
402
409
|
hasInitialized.current = true;
|
|
403
410
|
populateSizeArrays();
|
|
404
411
|
}
|
|
405
412
|
};
|
|
406
|
-
useImperativeHandle(imperativeVirtualizerRef, ()=>{
|
|
413
|
+
React.useImperativeHandle(imperativeVirtualizerRef, ()=>{
|
|
407
414
|
return {
|
|
408
415
|
progressiveSizes: childProgressiveSizes,
|
|
409
416
|
nodeSizes: childSizes,
|
|
@@ -416,7 +423,7 @@ export function useVirtualizer_unstable(props) {
|
|
|
416
423
|
]);
|
|
417
424
|
// Initialization on mount - update array index to 0 (ready state).
|
|
418
425
|
// Only fire on mount (no deps).
|
|
419
|
-
useEffect(()=>{
|
|
426
|
+
React.useEffect(()=>{
|
|
420
427
|
if (actualIndex < 0) {
|
|
421
428
|
batchUpdateNewIndex(0);
|
|
422
429
|
}
|
|
@@ -426,9 +433,9 @@ export function useVirtualizer_unstable(props) {
|
|
|
426
433
|
* forceUpdate:
|
|
427
434
|
* We only want to trigger this when scrollLoading is enabled and set to false,
|
|
428
435
|
* it will force re-render all children elements
|
|
429
|
-
*/ const forceUpdate = useReducer(()=>({}), {})[1];
|
|
436
|
+
*/ const forceUpdate = React.useReducer(()=>({}), {})[1];
|
|
430
437
|
// If the user passes in an updated renderChild function - update current children
|
|
431
|
-
useEffect(()=>{
|
|
438
|
+
React.useEffect(()=>{
|
|
432
439
|
if (actualIndex >= 0) {
|
|
433
440
|
updateChildRows(actualIndex);
|
|
434
441
|
if (enableScrollLoad && !isScrolling) {
|
|
@@ -440,16 +447,17 @@ export function useVirtualizer_unstable(props) {
|
|
|
440
447
|
renderChild,
|
|
441
448
|
isScrolling
|
|
442
449
|
]);
|
|
443
|
-
useEffect(()=>{
|
|
450
|
+
React.useEffect(()=>{
|
|
444
451
|
// Ensure we repopulate if getItemSize callback changes
|
|
445
452
|
populateSizeArrays();
|
|
446
453
|
// We only run this effect on getItemSize change (recalc dynamic sizes)
|
|
447
454
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
448
455
|
}, [
|
|
449
|
-
getItemSize
|
|
456
|
+
getItemSize,
|
|
457
|
+
gap
|
|
450
458
|
]);
|
|
451
459
|
// Effect to check flag index on updates
|
|
452
|
-
useEffect(()=>{
|
|
460
|
+
React.useEffect(()=>{
|
|
453
461
|
if (!onRenderedFlaggedIndex || flaggedIndex.current === null) {
|
|
454
462
|
return;
|
|
455
463
|
}
|