@tanstack/virtual-core 3.13.23 → 3.15.0

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.
@@ -1,4 +1,6 @@
1
- export * from './utils.js';
1
+ export declare const _resetIOSDetectionForTests: () => void;
2
+ export { approxEqual, debounce, memo, notUndefined } from './utils.js';
3
+ export type { NoInfer, PartialKeys } from './utils.js';
2
4
  type ScrollDirection = 'forward' | 'backward';
3
5
  type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';
4
6
  type ScrollBehavior = 'auto' | 'smooth' | 'instant';
@@ -35,14 +37,15 @@ type ObserveOffsetCallBack = (offset: number, isScrolling: boolean) => void;
35
37
  export declare const observeElementOffset: <T extends Element>(instance: Virtualizer<T, any>, cb: ObserveOffsetCallBack) => (() => void) | undefined;
36
38
  export declare const observeWindowOffset: (instance: Virtualizer<Window, any>, cb: ObserveOffsetCallBack) => (() => void) | undefined;
37
39
  export declare const measureElement: <TItemElement extends Element>(element: TItemElement, entry: ResizeObserverEntry | undefined, instance: Virtualizer<any, TItemElement>) => number;
38
- export declare const windowScroll: <T extends Window>(offset: number, { adjustments, behavior, }: {
40
+ export declare const windowScroll: <T extends Window>(offset: number, options: {
39
41
  adjustments?: number;
40
42
  behavior?: ScrollBehavior;
41
43
  }, instance: Virtualizer<T, any>) => void;
42
- export declare const elementScroll: <T extends Element>(offset: number, { adjustments, behavior, }: {
44
+ export declare const elementScroll: <T extends Element>(offset: number, options: {
43
45
  adjustments?: number;
44
46
  behavior?: ScrollBehavior;
45
47
  }, instance: Virtualizer<T, any>) => void;
48
+ type LaneAssignmentMode = 'estimate' | 'measured';
46
49
  export interface VirtualizerOptions<TScrollElement extends Element | Window, TItemElement extends Element> {
47
50
  count: number;
48
51
  getScrollElement: () => TScrollElement | null;
@@ -76,6 +79,7 @@ export interface VirtualizerOptions<TScrollElement extends Element | Window, TIt
76
79
  enabled?: boolean;
77
80
  isRtl?: boolean;
78
81
  useAnimationFrameWithResizeObserver?: boolean;
82
+ laneAssignmentMode?: LaneAssignmentMode;
79
83
  }
80
84
  export declare class Virtualizer<TScrollElement extends Element | Window, TItemElement extends Element> {
81
85
  private unsubs;
@@ -85,9 +89,11 @@ export declare class Virtualizer<TScrollElement extends Element | Window, TItemE
85
89
  isScrolling: boolean;
86
90
  private scrollState;
87
91
  measurementsCache: Array<VirtualItem>;
92
+ private _flatMeasurements;
88
93
  private itemSizeCache;
94
+ private itemSizeCacheVersion;
89
95
  private laneAssignments;
90
- private pendingMeasuredCacheIndexes;
96
+ private pendingMin;
91
97
  private prevLanes;
92
98
  private lanesChangedFlag;
93
99
  private lanesSettling;
@@ -95,6 +101,11 @@ export declare class Virtualizer<TScrollElement extends Element | Window, TItemE
95
101
  scrollOffset: number | null;
96
102
  scrollDirection: ScrollDirection | null;
97
103
  private scrollAdjustments;
104
+ private _iosDeferredAdjustment;
105
+ private _iosTouching;
106
+ private _iosJustTouchEnded;
107
+ private _iosTouchEndTimerId;
108
+ private _intendedScrollOffset;
98
109
  shouldAdjustScrollPositionOnItemSizeChange: undefined | ((item: VirtualItem, delta: number, instance: Virtualizer<TScrollElement, TItemElement>) => boolean);
99
110
  elementsCache: Map<Key, TItemElement>;
100
111
  private now;
@@ -110,6 +121,7 @@ export declare class Virtualizer<TScrollElement extends Element | Window, TItemE
110
121
  private cleanup;
111
122
  _didMount: () => () => void;
112
123
  _willUpdate: () => void;
124
+ private _flushIosDeferredIfReady;
113
125
  private rafId;
114
126
  private scheduleScrollReconcile;
115
127
  private reconcileScroll;
@@ -127,7 +139,7 @@ export declare class Virtualizer<TScrollElement extends Element | Window, TItemE
127
139
  };
128
140
  getVirtualIndexes: {
129
141
  (): number[];
130
- updateDeps(newDeps: [(range: Range) => number[], number, number, number | null, number | null]): void;
142
+ updateDeps(newDeps: [(range: Range) => Array<number>, number, number, number | null, number | null]): void;
131
143
  };
132
144
  indexFromElement: (node: TItemElement) => number;
133
145
  /**
@@ -150,6 +162,17 @@ export declare class Virtualizer<TScrollElement extends Element | Window, TItemE
150
162
  scrollToIndex: (index: number, { align: initialAlign, behavior, }?: ScrollToIndexOptions) => void;
151
163
  scrollBy: (delta: number, { behavior }?: ScrollToOffsetOptions) => void;
152
164
  getTotalSize: () => number;
165
+ /**
166
+ * Returns a snapshot of currently-measured items suitable for round-
167
+ * tripping through state storage (sessionStorage, history, etc.) and
168
+ * passing back as `initialMeasurementsCache` on remount. Pair with the
169
+ * current `scrollOffset` to restore exact scroll position after navigation.
170
+ *
171
+ * Only items the consumer has actually rendered (and thus measured) appear
172
+ * in the snapshot; unmeasured items will fall back to `estimateSize` on
173
+ * restore. Returns an empty array if no items have been measured.
174
+ */
175
+ takeSnapshot: () => Array<VirtualItem>;
153
176
  private _scrollToOffset;
154
177
  measure: () => void;
155
178
  }