@legendapp/list 3.0.5 → 3.1.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 3.1.0
2
+
3
+ - Feat: Add `experimental_adaptiveRender` with `useAdaptiveRender` and `useAdaptiveRenderChange`, so item components can render a lighter version while the list is moving quickly and return to normal after scrolling slows.
4
+ - Feat: Add `setItemSize` to the list ref for updating a known item's measured size directly when its content changes outside normal layout measurement.
5
+ - Fix: Web maintainVisibleContentPosition keeps the intended anchor when headers change, browser scroll anchoring runs, or an animated `scrollToEnd` is already in progress. #468 #463
6
+ - Fix: `initialScrollIndex` and `initialScrollAtEnd` use the latest initial scroll props when data starts empty and loads later, so lists do not scroll to an old startup target.
7
+ - Fix: Changing `gap` now refreshes cached item measurements, and fixed-size rows include the gap in their positions.
8
+ - Fix: SectionList sticky headers update after the section data changes. #445
9
+ - Fix: Horizontal lists with end alignment now place items at the end instead of ignoring the alignment. #472
10
+ - Fix: Lists clear scheduled timers on unmount, preventing delayed adaptive-render or scroll work from running after the list is gone.
11
+ - Perf: The first render starts with a smaller draw distance and expands shortly after, reducing offscreen work before the initial content appears.
12
+ - Perf: `alignItemsAtEnd` spacer updates cause fewer ScrollView rerenders.
13
+ - Types: Export `AdaptiveRender` and `AdaptiveRenderConfig` from the React Native and web type entrypoints.
14
+
15
+ ## 3.0.6
16
+
17
+ - Fix: KeyboardAwareLegendList now accounts for bottom insets when alignItemsAtEnd is used, so short chat-style lists stay pinned above the keyboard or safe area instead of being pushed too low or leaving extra scroll space.
18
+
1
19
  ## 3.0.5
2
20
 
3
21
  - Fix: clearCaches now rechecks the rows that are already on screen, so resetting the size cache does not leave items stuck in old positions.
package/animated.d.ts CHANGED
@@ -8,10 +8,11 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
8
8
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
9
9
  }
10
10
 
11
- type ListenerType = "activeStickyIndex" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
12
- type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
11
+ type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
12
+ type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
13
13
  type ListenerTypeValueMap = {
14
14
  activeStickyIndex: number;
15
+ alignItemsAtEndPadding: number;
15
16
  anchoredEndSpaceSize: number;
16
17
  animatedScrollY: any;
17
18
  debugComputedScroll: number;
@@ -42,6 +43,7 @@ type ListenerTypeValueMap = {
42
43
  snapToOffsets: number[];
43
44
  stylePaddingTop: number;
44
45
  totalSize: number;
46
+ adaptiveRender: "normal" | "light";
45
47
  } & {
46
48
  [K in ListenerType as K extends `containerItemKey${number}` ? K : never]: string;
47
49
  } & {
@@ -62,6 +64,12 @@ interface Insets {
62
64
  bottom: number;
63
65
  right: number;
64
66
  }
67
+ interface LayoutRectangle {
68
+ x: number;
69
+ y: number;
70
+ width: number;
71
+ height: number;
72
+ }
65
73
  interface NativeScrollEvent {
66
74
  contentOffset: {
67
75
  x: number;
@@ -83,6 +91,28 @@ interface NativeSyntheticEvent<T> {
83
91
  }
84
92
  type ViewStyle = Record<string, unknown>;
85
93
  type StyleProp<T> = T | T[] | null | undefined | false;
94
+ type AdaptiveRender = "normal" | "light";
95
+ interface AdaptiveRenderConfig {
96
+ /**
97
+ * Scroll velocity in pixels per millisecond above which items should switch to light mode.
98
+ * @default 4
99
+ */
100
+ enterVelocity?: number;
101
+ /**
102
+ * Scroll velocity in pixels per millisecond below which items can return to normal mode.
103
+ * @default 1
104
+ */
105
+ exitVelocity?: number;
106
+ /**
107
+ * Time to wait without velocity above exitVelocity before returning to normal mode.
108
+ * @default 1000
109
+ */
110
+ exitDelay?: number;
111
+ /**
112
+ * Called when the list-level adaptive render changes.
113
+ */
114
+ onChange?: (mode: AdaptiveRender) => void;
115
+ }
86
116
  type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
87
117
  interface DataModeProps<ItemT, TItemType extends string | undefined> {
88
118
  /**
@@ -291,6 +321,10 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
291
321
  * Called when list layout metrics change.
292
322
  */
293
323
  onMetricsChange?: (metrics: LegendListMetrics) => void;
324
+ /**
325
+ * Configures the adaptive render signal. Items can use this to render a lighter version while scrolling quickly.
326
+ */
327
+ experimental_adaptiveRender?: AdaptiveRenderConfig;
294
328
  /**
295
329
  * Function to call when the user pulls to refresh.
296
330
  */
@@ -489,6 +523,14 @@ type LegendListState = {
489
523
  startBuffered: number;
490
524
  };
491
525
  type LegendListRef$1 = {
526
+ /**
527
+ * Clears internal virtualization caches.
528
+ * @param options - Cache clearing options.
529
+ * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
530
+ */
531
+ clearCaches(options?: {
532
+ mode?: "sizes" | "full";
533
+ }): void;
492
534
  /**
493
535
  * Displays the scroll indicators momentarily.
494
536
  */
@@ -509,6 +551,11 @@ type LegendListRef$1 = {
509
551
  * Returns the internal state of the scroll virtualization.
510
552
  */
511
553
  getState(): LegendListState;
554
+ /**
555
+ * Reports an externally measured content inset. Pass null/undefined to clear.
556
+ * Values are merged on top of props/animated/native insets.
557
+ */
558
+ reportContentInset(inset?: Partial<Insets> | null): void;
512
559
  /**
513
560
  * Scrolls a specific index into view.
514
561
  * @param params - Parameters for scrolling.
@@ -575,29 +622,22 @@ type LegendListRef$1 = {
575
622
  animated?: boolean | undefined;
576
623
  }): Promise<void>;
577
624
  /**
578
- * Sets or adds to the offset of the visible content anchor.
579
- * @param value - The offset to set or add.
580
- * @param animated - If true, uses Animated to animate the change.
625
+ * Sets a measured item size and recalculates list positions as needed.
626
+ * @param itemKey - The key of the item whose size changed.
627
+ * @param size - The measured item size.
581
628
  */
582
- setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
629
+ setItemSize(itemKey: string, size: Pick<LayoutRectangle, "height" | "width">): void;
583
630
  /**
584
631
  * Sets whether scroll processing is enabled.
585
632
  * @param enabled - If true, scroll processing is enabled.
586
633
  */
587
634
  setScrollProcessingEnabled(enabled: boolean): void;
588
635
  /**
589
- * Clears internal virtualization caches.
590
- * @param options - Cache clearing options.
591
- * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
592
- */
593
- clearCaches(options?: {
594
- mode?: "sizes" | "full";
595
- }): void;
596
- /**
597
- * Reports an externally measured content inset. Pass null/undefined to clear.
598
- * Values are merged on top of props/animated/native insets.
636
+ * Sets or adds to the offset of the visible content anchor.
637
+ * @param value - The offset to set or add.
638
+ * @param animated - If true, uses Animated to animate the change.
599
639
  */
600
- reportContentInset(inset?: Partial<Insets> | null): void;
640
+ setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
601
641
  };
602
642
  interface ViewToken<ItemT = any> {
603
643
  containerId: number;
@@ -9,10 +9,11 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
9
9
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
10
10
  }
11
11
 
12
- type ListenerType = "activeStickyIndex" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
13
- type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
12
+ type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
13
+ type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
14
14
  type ListenerTypeValueMap = {
15
15
  activeStickyIndex: number;
16
+ alignItemsAtEndPadding: number;
16
17
  anchoredEndSpaceSize: number;
17
18
  animatedScrollY: any;
18
19
  debugComputedScroll: number;
@@ -43,6 +44,7 @@ type ListenerTypeValueMap = {
43
44
  snapToOffsets: number[];
44
45
  stylePaddingTop: number;
45
46
  totalSize: number;
47
+ adaptiveRender: "normal" | "light";
46
48
  } & {
47
49
  [K in ListenerType as K extends `containerItemKey${number}` ? K : never]: string;
48
50
  } & {
@@ -63,6 +65,12 @@ interface Insets {
63
65
  bottom: number;
64
66
  right: number;
65
67
  }
68
+ interface LayoutRectangle {
69
+ x: number;
70
+ y: number;
71
+ width: number;
72
+ height: number;
73
+ }
66
74
  interface ScrollToEndOptions {
67
75
  animated?: boolean;
68
76
  viewOffset?: number;
@@ -99,6 +107,14 @@ type LegendListState = {
99
107
  startBuffered: number;
100
108
  };
101
109
  type LegendListRef$1 = {
110
+ /**
111
+ * Clears internal virtualization caches.
112
+ * @param options - Cache clearing options.
113
+ * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
114
+ */
115
+ clearCaches(options?: {
116
+ mode?: "sizes" | "full";
117
+ }): void;
102
118
  /**
103
119
  * Displays the scroll indicators momentarily.
104
120
  */
@@ -119,6 +135,11 @@ type LegendListRef$1 = {
119
135
  * Returns the internal state of the scroll virtualization.
120
136
  */
121
137
  getState(): LegendListState;
138
+ /**
139
+ * Reports an externally measured content inset. Pass null/undefined to clear.
140
+ * Values are merged on top of props/animated/native insets.
141
+ */
142
+ reportContentInset(inset?: Partial<Insets> | null): void;
122
143
  /**
123
144
  * Scrolls a specific index into view.
124
145
  * @param params - Parameters for scrolling.
@@ -185,29 +206,22 @@ type LegendListRef$1 = {
185
206
  animated?: boolean | undefined;
186
207
  }): Promise<void>;
187
208
  /**
188
- * Sets or adds to the offset of the visible content anchor.
189
- * @param value - The offset to set or add.
190
- * @param animated - If true, uses Animated to animate the change.
209
+ * Sets a measured item size and recalculates list positions as needed.
210
+ * @param itemKey - The key of the item whose size changed.
211
+ * @param size - The measured item size.
191
212
  */
192
- setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
213
+ setItemSize(itemKey: string, size: Pick<LayoutRectangle, "height" | "width">): void;
193
214
  /**
194
215
  * Sets whether scroll processing is enabled.
195
216
  * @param enabled - If true, scroll processing is enabled.
196
217
  */
197
218
  setScrollProcessingEnabled(enabled: boolean): void;
198
219
  /**
199
- * Clears internal virtualization caches.
200
- * @param options - Cache clearing options.
201
- * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
202
- */
203
- clearCaches(options?: {
204
- mode?: "sizes" | "full";
205
- }): void;
206
- /**
207
- * Reports an externally measured content inset. Pass null/undefined to clear.
208
- * Values are merged on top of props/animated/native insets.
220
+ * Sets or adds to the offset of the visible content anchor.
221
+ * @param value - The offset to set or add.
222
+ * @param animated - If true, uses Animated to animate the change.
209
223
  */
210
- reportContentInset(inset?: Partial<Insets> | null): void;
224
+ setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
211
225
  };
212
226
 
213
227
  type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
package/keyboard.d.ts CHANGED
@@ -10,10 +10,11 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
10
10
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
11
11
  }
12
12
 
13
- type ListenerType = "activeStickyIndex" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
14
- type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
13
+ type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
14
+ type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
15
15
  type ListenerTypeValueMap = {
16
16
  activeStickyIndex: number;
17
+ alignItemsAtEndPadding: number;
17
18
  anchoredEndSpaceSize: number;
18
19
  animatedScrollY: any;
19
20
  debugComputedScroll: number;
@@ -44,6 +45,7 @@ type ListenerTypeValueMap = {
44
45
  snapToOffsets: number[];
45
46
  stylePaddingTop: number;
46
47
  totalSize: number;
48
+ adaptiveRender: "normal" | "light";
47
49
  } & {
48
50
  [K in ListenerType as K extends `containerItemKey${number}` ? K : never]: string;
49
51
  } & {
@@ -64,6 +66,12 @@ interface Insets {
64
66
  bottom: number;
65
67
  right: number;
66
68
  }
69
+ interface LayoutRectangle {
70
+ x: number;
71
+ y: number;
72
+ width: number;
73
+ height: number;
74
+ }
67
75
  interface AnchoredEndSpaceReadyInfo {
68
76
  anchorIndex: number | undefined;
69
77
  anchorKey: string | undefined;
@@ -113,6 +121,14 @@ type LegendListState = {
113
121
  startBuffered: number;
114
122
  };
115
123
  type LegendListRef$1 = {
124
+ /**
125
+ * Clears internal virtualization caches.
126
+ * @param options - Cache clearing options.
127
+ * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
128
+ */
129
+ clearCaches(options?: {
130
+ mode?: "sizes" | "full";
131
+ }): void;
116
132
  /**
117
133
  * Displays the scroll indicators momentarily.
118
134
  */
@@ -133,6 +149,11 @@ type LegendListRef$1 = {
133
149
  * Returns the internal state of the scroll virtualization.
134
150
  */
135
151
  getState(): LegendListState;
152
+ /**
153
+ * Reports an externally measured content inset. Pass null/undefined to clear.
154
+ * Values are merged on top of props/animated/native insets.
155
+ */
156
+ reportContentInset(inset?: Partial<Insets> | null): void;
136
157
  /**
137
158
  * Scrolls a specific index into view.
138
159
  * @param params - Parameters for scrolling.
@@ -199,29 +220,22 @@ type LegendListRef$1 = {
199
220
  animated?: boolean | undefined;
200
221
  }): Promise<void>;
201
222
  /**
202
- * Sets or adds to the offset of the visible content anchor.
203
- * @param value - The offset to set or add.
204
- * @param animated - If true, uses Animated to animate the change.
223
+ * Sets a measured item size and recalculates list positions as needed.
224
+ * @param itemKey - The key of the item whose size changed.
225
+ * @param size - The measured item size.
205
226
  */
206
- setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
227
+ setItemSize(itemKey: string, size: Pick<LayoutRectangle, "height" | "width">): void;
207
228
  /**
208
229
  * Sets whether scroll processing is enabled.
209
230
  * @param enabled - If true, scroll processing is enabled.
210
231
  */
211
232
  setScrollProcessingEnabled(enabled: boolean): void;
212
233
  /**
213
- * Clears internal virtualization caches.
214
- * @param options - Cache clearing options.
215
- * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
216
- */
217
- clearCaches(options?: {
218
- mode?: "sizes" | "full";
219
- }): void;
220
- /**
221
- * Reports an externally measured content inset. Pass null/undefined to clear.
222
- * Values are merged on top of props/animated/native insets.
234
+ * Sets or adds to the offset of the visible content anchor.
235
+ * @param value - The offset to set or add.
236
+ * @param animated - If true, uses Animated to animate the change.
223
237
  */
224
- reportContentInset(inset?: Partial<Insets> | null): void;
238
+ setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
225
239
  };
226
240
 
227
241
  interface AnchoredEndSpaceConfig extends Omit<AnchoredEndSpaceConfig$1, "includeInEndInset"> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "3.0.5",
3
+ "version": "3.1.0",
4
4
  "description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,
package/react-native.d.ts CHANGED
@@ -8,10 +8,11 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
8
8
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
9
9
  }
10
10
 
11
- type ListenerType = "activeStickyIndex" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
12
- type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
11
+ type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "anchoredEndSpaceSize" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
12
+ type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
13
13
  type ListenerTypeValueMap = {
14
14
  activeStickyIndex: number;
15
+ alignItemsAtEndPadding: number;
15
16
  anchoredEndSpaceSize: number;
16
17
  animatedScrollY: any;
17
18
  debugComputedScroll: number;
@@ -42,6 +43,7 @@ type ListenerTypeValueMap = {
42
43
  snapToOffsets: number[];
43
44
  stylePaddingTop: number;
44
45
  totalSize: number;
46
+ adaptiveRender: "normal" | "light";
45
47
  } & {
46
48
  [K in ListenerType as K extends `containerItemKey${number}` ? K : never]: string;
47
49
  } & {
@@ -89,6 +91,28 @@ interface NativeSyntheticEvent<T> {
89
91
  }
90
92
  type ViewStyle = Record<string, unknown>;
91
93
  type StyleProp<T> = T | T[] | null | undefined | false;
94
+ type AdaptiveRender = "normal" | "light";
95
+ interface AdaptiveRenderConfig {
96
+ /**
97
+ * Scroll velocity in pixels per millisecond above which items should switch to light mode.
98
+ * @default 4
99
+ */
100
+ enterVelocity?: number;
101
+ /**
102
+ * Scroll velocity in pixels per millisecond below which items can return to normal mode.
103
+ * @default 1
104
+ */
105
+ exitVelocity?: number;
106
+ /**
107
+ * Time to wait without velocity above exitVelocity before returning to normal mode.
108
+ * @default 1000
109
+ */
110
+ exitDelay?: number;
111
+ /**
112
+ * Called when the list-level adaptive render changes.
113
+ */
114
+ onChange?: (mode: AdaptiveRender) => void;
115
+ }
92
116
  type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
93
117
  interface DataModeProps<ItemT, TItemType extends string | undefined> {
94
118
  /**
@@ -297,6 +321,10 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
297
321
  * Called when list layout metrics change.
298
322
  */
299
323
  onMetricsChange?: (metrics: LegendListMetrics) => void;
324
+ /**
325
+ * Configures the adaptive render signal. Items can use this to render a lighter version while scrolling quickly.
326
+ */
327
+ experimental_adaptiveRender?: AdaptiveRenderConfig;
300
328
  /**
301
329
  * Function to call when the user pulls to refresh.
302
330
  */
@@ -495,6 +523,14 @@ type LegendListState$1 = {
495
523
  startBuffered: number;
496
524
  };
497
525
  type LegendListRef$1 = {
526
+ /**
527
+ * Clears internal virtualization caches.
528
+ * @param options - Cache clearing options.
529
+ * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
530
+ */
531
+ clearCaches(options?: {
532
+ mode?: "sizes" | "full";
533
+ }): void;
498
534
  /**
499
535
  * Displays the scroll indicators momentarily.
500
536
  */
@@ -515,6 +551,11 @@ type LegendListRef$1 = {
515
551
  * Returns the internal state of the scroll virtualization.
516
552
  */
517
553
  getState(): LegendListState$1;
554
+ /**
555
+ * Reports an externally measured content inset. Pass null/undefined to clear.
556
+ * Values are merged on top of props/animated/native insets.
557
+ */
558
+ reportContentInset(inset?: Partial<Insets> | null): void;
518
559
  /**
519
560
  * Scrolls a specific index into view.
520
561
  * @param params - Parameters for scrolling.
@@ -581,29 +622,22 @@ type LegendListRef$1 = {
581
622
  animated?: boolean | undefined;
582
623
  }): Promise<void>;
583
624
  /**
584
- * Sets or adds to the offset of the visible content anchor.
585
- * @param value - The offset to set or add.
586
- * @param animated - If true, uses Animated to animate the change.
625
+ * Sets a measured item size and recalculates list positions as needed.
626
+ * @param itemKey - The key of the item whose size changed.
627
+ * @param size - The measured item size.
587
628
  */
588
- setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
629
+ setItemSize(itemKey: string, size: Pick<LayoutRectangle, "height" | "width">): void;
589
630
  /**
590
631
  * Sets whether scroll processing is enabled.
591
632
  * @param enabled - If true, scroll processing is enabled.
592
633
  */
593
634
  setScrollProcessingEnabled(enabled: boolean): void;
594
635
  /**
595
- * Clears internal virtualization caches.
596
- * @param options - Cache clearing options.
597
- * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
598
- */
599
- clearCaches(options?: {
600
- mode?: "sizes" | "full";
601
- }): void;
602
- /**
603
- * Reports an externally measured content inset. Pass null/undefined to clear.
604
- * Values are merged on top of props/animated/native insets.
636
+ * Sets or adds to the offset of the visible content anchor.
637
+ * @param value - The offset to set or add.
638
+ * @param animated - If true, uses Animated to animate the change.
605
639
  */
606
- reportContentInset(inset?: Partial<Insets> | null): void;
640
+ setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
607
641
  };
608
642
  interface ViewToken<ItemT = any> {
609
643
  containerId: number;
@@ -700,6 +734,8 @@ type LegendListState = Omit<LegendListState$1, "elementAtIndex"> & {
700
734
  };
701
735
  type LegendListComponent = <ItemT = any>(props: LegendListProps<ItemT> & React.RefAttributes<LegendListRef>) => React.ReactElement | null;
702
736
 
737
+ declare function useAdaptiveRender(): AdaptiveRender;
738
+ declare function useAdaptiveRenderChange(callback: (mode: AdaptiveRender) => void): void;
703
739
  declare function useViewability<ItemT = any>(callback: ViewabilityCallback<ItemT>, configId?: string): void;
704
740
  declare function useViewabilityAmount<ItemT = any>(callback: ViewabilityAmountCallback<ItemT>): void;
705
741
  declare function useRecyclingEffect(effect: (info: LegendListRecyclingState<unknown>) => void | (() => void)): void;
@@ -713,4 +749,4 @@ declare function useSyncLayout(): () => void;
713
749
 
714
750
  declare const LegendList: LegendListComponent;
715
751
 
716
- export { type AlwaysRenderConfig, type ColumnWrapperStyle, type Insets, type LayoutRectangle, LegendList, type LegendListAverageItemSize, type LegendListComponent, type LegendListMetrics, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListState, type MaintainScrollAtEndOnOptions, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type OnViewableItemsChangedInfo, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type StickyHeaderConfig, type StyleProp, type ViewAmountToken, type ViewStyle, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
752
+ export { type AdaptiveRender, type AdaptiveRenderConfig, type AlwaysRenderConfig, type ColumnWrapperStyle, type Insets, type LayoutRectangle, LegendList, type LegendListAverageItemSize, type LegendListComponent, type LegendListMetrics, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListState, type MaintainScrollAtEndOnOptions, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type OnViewableItemsChangedInfo, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type StickyHeaderConfig, type StyleProp, type ViewAmountToken, type ViewStyle, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, useAdaptiveRender, useAdaptiveRenderChange, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };