@legendapp/list 2.0.8 → 2.0.10

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,14 @@
1
+ ## 2.0.10
2
+ - Feat: Add onStickyHeaderChange callback for sticky headers
3
+ - Fix: Items with a falsy value like 0 were not rendering
4
+ - Fix: Column positions sometimes not calculating correctly
5
+ - Perf: updateItemsPositions was not breaking early sometimes
6
+ - Perf: Changed idCache to be an array instead of a Map for better performance
7
+ - Perf: Speed up container reuse lookups
8
+
9
+ ## 2.0.9
10
+ - Fix: Improve initialScrollIndex accuracy and reliability
11
+
1
12
  ## 2.0.8
2
13
  - Fix: Data changing sometimes left blank spaces because it was ignoring scroll
3
14
  - Fix: Toggling between empty and non-empty causing maintainVisibleContentPosition issues
package/index.d.mts CHANGED
@@ -5,6 +5,7 @@ import Animated$1 from 'react-native-reanimated';
5
5
 
6
6
  type ListenerType = "numContainers" | "numContainersPooled" | `containerItemKey${number}` | `containerItemData${number}` | `containerPosition${number}` | `containerColumn${number}` | `containerSticky${number}` | `containerStickyOffset${number}` | "containersDidLayout" | "extraData" | "numColumns" | "lastItemKeys" | "totalSize" | "alignItemsPaddingTop" | "stylePaddingTop" | "scrollAdjust" | "scrollAdjustUserOffset" | "headerSize" | "footerSize" | "maintainVisibleContentPosition" | "debugRawScroll" | "debugComputedScroll" | "otherAxisSize" | "snapToOffsets" | "scrollSize";
7
7
  interface StateContext {
8
+ internalState: InternalState | undefined;
8
9
  listeners: Map<ListenerType, Set<(value: any) => void>>;
9
10
  values: Map<ListenerType, any>;
10
11
  mapViewabilityCallbacks: Map<string, ViewabilityCallback>;
@@ -208,6 +209,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
208
209
  * @default 0.5
209
210
  */
210
211
  onStartReachedThreshold?: number | null | undefined;
212
+ /**
213
+ * Called when the sticky header changes.
214
+ */
215
+ onStickyHeaderChange?: (info: {
216
+ index: number;
217
+ item: any;
218
+ }) => void;
211
219
  /**
212
220
  * Called when the viewability of items changes.
213
221
  */
@@ -315,7 +323,7 @@ interface InternalState {
315
323
  timeoutSizeMessage: any;
316
324
  nativeMarginTop: number;
317
325
  indexByKey: Map<string, number>;
318
- idCache: Map<number, string>;
326
+ idCache: string[];
319
327
  viewabilityConfigCallbackPairs: ViewabilityConfigCallbackPairs<any> | undefined;
320
328
  scrollHistory: Array<{
321
329
  scroll: number;
@@ -344,6 +352,7 @@ interface InternalState {
344
352
  viewOffset?: number;
345
353
  viewPosition?: number;
346
354
  animated?: boolean;
355
+ isInitialScroll?: boolean;
347
356
  } | undefined;
348
357
  needsOtherAxisSize?: boolean;
349
358
  averageSizes: Record<string, {
@@ -378,6 +387,7 @@ interface InternalState {
378
387
  onScroll: LegendListProps["onScroll"];
379
388
  onStartReached: LegendListProps["onStartReached"];
380
389
  onStartReachedThreshold: number | null | undefined;
390
+ onStickyHeaderChange: LegendListProps["onStickyHeaderChange"];
381
391
  recycleItems: boolean;
382
392
  suggestEstimatedItemSize: boolean;
383
393
  stylePaddingBottom: number | undefined;
@@ -540,7 +550,7 @@ interface ViewAmountToken<ItemT = any> extends ViewToken<ItemT> {
540
550
  percentOfScroller: number;
541
551
  scrollSize: number;
542
552
  }
543
- interface ViewabilityConfigCallbackPair<ItemT> {
553
+ interface ViewabilityConfigCallbackPair<ItemT = any> {
544
554
  viewabilityConfig: ViewabilityConfig;
545
555
  onViewableItemsChanged?: OnViewableItemsChanged<ItemT>;
546
556
  }
package/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import Animated$1 from 'react-native-reanimated';
5
5
 
6
6
  type ListenerType = "numContainers" | "numContainersPooled" | `containerItemKey${number}` | `containerItemData${number}` | `containerPosition${number}` | `containerColumn${number}` | `containerSticky${number}` | `containerStickyOffset${number}` | "containersDidLayout" | "extraData" | "numColumns" | "lastItemKeys" | "totalSize" | "alignItemsPaddingTop" | "stylePaddingTop" | "scrollAdjust" | "scrollAdjustUserOffset" | "headerSize" | "footerSize" | "maintainVisibleContentPosition" | "debugRawScroll" | "debugComputedScroll" | "otherAxisSize" | "snapToOffsets" | "scrollSize";
7
7
  interface StateContext {
8
+ internalState: InternalState | undefined;
8
9
  listeners: Map<ListenerType, Set<(value: any) => void>>;
9
10
  values: Map<ListenerType, any>;
10
11
  mapViewabilityCallbacks: Map<string, ViewabilityCallback>;
@@ -208,6 +209,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
208
209
  * @default 0.5
209
210
  */
210
211
  onStartReachedThreshold?: number | null | undefined;
212
+ /**
213
+ * Called when the sticky header changes.
214
+ */
215
+ onStickyHeaderChange?: (info: {
216
+ index: number;
217
+ item: any;
218
+ }) => void;
211
219
  /**
212
220
  * Called when the viewability of items changes.
213
221
  */
@@ -315,7 +323,7 @@ interface InternalState {
315
323
  timeoutSizeMessage: any;
316
324
  nativeMarginTop: number;
317
325
  indexByKey: Map<string, number>;
318
- idCache: Map<number, string>;
326
+ idCache: string[];
319
327
  viewabilityConfigCallbackPairs: ViewabilityConfigCallbackPairs<any> | undefined;
320
328
  scrollHistory: Array<{
321
329
  scroll: number;
@@ -344,6 +352,7 @@ interface InternalState {
344
352
  viewOffset?: number;
345
353
  viewPosition?: number;
346
354
  animated?: boolean;
355
+ isInitialScroll?: boolean;
347
356
  } | undefined;
348
357
  needsOtherAxisSize?: boolean;
349
358
  averageSizes: Record<string, {
@@ -378,6 +387,7 @@ interface InternalState {
378
387
  onScroll: LegendListProps["onScroll"];
379
388
  onStartReached: LegendListProps["onStartReached"];
380
389
  onStartReachedThreshold: number | null | undefined;
390
+ onStickyHeaderChange: LegendListProps["onStickyHeaderChange"];
381
391
  recycleItems: boolean;
382
392
  suggestEstimatedItemSize: boolean;
383
393
  stylePaddingBottom: number | undefined;
@@ -540,7 +550,7 @@ interface ViewAmountToken<ItemT = any> extends ViewToken<ItemT> {
540
550
  percentOfScroller: number;
541
551
  scrollSize: number;
542
552
  }
543
- interface ViewabilityConfigCallbackPair<ItemT> {
553
+ interface ViewabilityConfigCallbackPair<ItemT = any> {
544
554
  viewabilityConfig: ViewabilityConfig;
545
555
  onViewableItemsChanged?: OnViewableItemsChanged<ItemT>;
546
556
  }