@legendapp/list 3.6.0 → 3.7.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/react-native.d.ts CHANGED
@@ -8,8 +8,8 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
8
8
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
9
9
  }
10
10
 
11
- type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "anchoredEndSpaceSize" | "containerLayoutEpoch" | "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}` | `containerItemIndex${number}` | `containerItemKey${number}` | `containerLayoutReady${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">;
11
+ type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "anchoredEndSpaceSize" | "containerLayoutEpoch" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "isScrollActive" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | "isFollowingEnd" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemIndex${number}` | `containerItemKey${number}` | `containerLayoutReady${number}` | `containerPosition${number}` | `containerSticky${number}`;
12
+ type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isFollowingEnd" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
13
13
  type ListenerTypeValueMap = {
14
14
  activeStickyIndex: number;
15
15
  alignItemsAtEndPadding: number;
@@ -21,6 +21,7 @@ type ListenerTypeValueMap = {
21
21
  extraData: any;
22
22
  footerSize: number;
23
23
  headerSize: number;
24
+ isFollowingEnd: boolean;
24
25
  isAtEnd: boolean;
25
26
  isAtStart: boolean;
26
27
  isNearEnd: boolean;
@@ -34,6 +35,7 @@ type ListenerTypeValueMap = {
34
35
  numContainersPooled: number;
35
36
  otherAxisSize: number;
36
37
  readyToRender: boolean;
38
+ isScrollActive: boolean;
37
39
  scrollAdjust: number;
38
40
  scrollAdjustPending: number;
39
41
  scrollAdjustUserOffset: number;
@@ -199,6 +201,7 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
199
201
  extraData?: any;
200
202
  /**
201
203
  * In case items always have a fixed size, you can provide a function to return it.
204
+ * Change extraData when the fixed sizes returned by this callback change.
202
205
  */
203
206
  getFixedItemSize?: (item: ItemT, index: number, type: TItemType) => number | undefined;
204
207
  /**
@@ -271,6 +274,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
271
274
  /**
272
275
  * If true, auto-scrolls to end when new items are added.
273
276
  * Use an options object to opt into specific triggers and control whether that scroll is animated.
277
+ * Setting false pauses maintenance while retaining end-follow intent. Re-enabling resumes
278
+ * that intent even if content grew beyond the threshold; user or list navigation releases it.
279
+ * While paused, isFollowingEnd reports the retained intent.
280
+ * With a native screen reader enabled, unowned accessibility scrolls toward the start
281
+ * release following. Assistive-tech scrolls during library animations are not detected.
274
282
  * @default false
275
283
  */
276
284
  maintainScrollAtEnd?: boolean | MaintainScrollAtEndOptions;
@@ -281,11 +289,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
281
289
  maintainScrollAtEndThreshold?: number;
282
290
  /**
283
291
  * Maintains visibility of content.
284
- * - scroll (default: true) stabilizes during size/layout changes while scrolling.
285
- * - data (default: false) stabilizes when the data array changes; passing true also sets the RN maintainVisibleContentPosition prop.
292
+ * - size (default: true) stabilizes during size/layout changes while scrolling.
293
+ * - data (default: false) stabilizes when the data array changes.
286
294
  * - shouldRestorePosition can opt out specific items from data-change anchoring.
287
295
  * - undefined (default) enables scroll stabilization but skips data-change anchoring.
288
- * - true enables both behaviors; false disables both.
296
+ * - true enables both JS behaviors; false disables both.
297
+ * Native iOS maintainVisibleContentPosition is enabled when either size or data stabilization is enabled,
298
+ * and disabled when both are disabled.
289
299
  */
290
300
  maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig<ItemT>;
291
301
  /**
@@ -377,8 +387,25 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
377
387
  */
378
388
  onRefresh?: () => void;
379
389
  /**
380
- * Called when the list scrolls.
381
- */
390
+ * Called once per accepted user gesture, in either direction: native drag (including
391
+ * momentum), web wheel/touch movement, non-repeated scroll keydown, or scrollbar drag.
392
+ * Wheel input at a boundary is ignored unless navigation is active. Without wheel
393
+ * momentum metadata, gesture boundaries are inferred from timing, direction and force.
394
+ * iOS status-bar scrolling emits on native onScrollToTop unless accessibility motion
395
+ * already reported it during the animation.
396
+ * With a native screen reader enabled, otherwise unowned scroll motion with stable
397
+ * content/viewport size is inferred as accessibility input (including focus navigation),
398
+ * once per burst; motion toward the start releases end following. Library animations
399
+ * and controller/native-ref command windows mask assistive-tech scrolling.
400
+ * Native commands bypassing the list and its refs (e.g. Reanimated scrollTo worklets)
401
+ * cannot be distinguished from accessibility input while a screen reader is on; call
402
+ * cancelScroll() on the JS thread before that navigation to release end following.
403
+ * Layout/clamp/MVCP events and commands through the list or its refs do not emit it.
404
+ * @experimental Native pointer/wheel-only input without a screen reader is not detected.
405
+ * Web scrollbar detection requires pointer events in a measurable, non-overlay gutter.
406
+ */
407
+ onUserScroll?: () => void;
408
+ /** Called when the list scrolls. */
382
409
  onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
383
410
  /**
384
411
  * Called when scrolling reaches the start within onStartReachedThreshold.
@@ -510,6 +537,8 @@ interface AlwaysRenderConfig {
510
537
  keys?: string[];
511
538
  }
512
539
  interface MaintainScrollAtEndOnOptions {
540
+ /** Follow only additions that preserve every existing item key in order. */
541
+ dataAppend?: boolean;
513
542
  dataChange?: boolean;
514
543
  footerLayout?: boolean;
515
544
  itemLayout?: boolean;
@@ -551,9 +580,13 @@ type LegendListState$1 = {
551
580
  activeStickyIndex: number;
552
581
  contentLength: number;
553
582
  data: readonly any[];
583
+ dataKey?: Key;
554
584
  elementAtIndex: (index: number) => any;
555
585
  end: number;
556
586
  endBuffered: number;
587
+ /** Distance to the physical scroll edge, including the trailing inset. */
588
+ distanceFromEnd: number;
589
+ isFollowingEnd: boolean;
557
590
  isAtEnd: boolean;
558
591
  isAtStart: boolean;
559
592
  isNearEnd: boolean;
@@ -563,7 +596,10 @@ type LegendListState$1 = {
563
596
  isWithinMaintainScrollAtEndThreshold: boolean;
564
597
  getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
565
598
  indexByKey: (key: string) => number | undefined;
566
- listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
599
+ listen: {
600
+ <T extends Exclude<LegendListListenerType, "isFollowingEnd">>(listenerType: T, callback: (value: Pick<ListenerTypeValueMap, LegendListListenerType>[T]) => void): () => void;
601
+ <T extends LegendListListenerType>(listenerType: T, callback: (value: Pick<ListenerTypeValueMap, LegendListListenerType>[T]) => void): () => void;
602
+ };
567
603
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
568
604
  positionAtIndex: (index: number) => number;
569
605
  positionByKey: (key: string) => number | undefined;
@@ -576,6 +612,28 @@ type LegendListState$1 = {
576
612
  startBuffered: number;
577
613
  };
578
614
  type LegendListRef$1 = {
615
+ /** Cancels queued and active scrolling, settles its promise, and stops at the observed offset. */
616
+ cancelScroll(): void;
617
+ /** Scrolls by stable item identity through prepends; resolves without scrolling if the key is missing or removed. */
618
+ scrollToKey(params: {
619
+ key: string;
620
+ animated?: boolean;
621
+ viewOffset?: number;
622
+ viewPosition?: number;
623
+ }): Promise<void>;
624
+ /**
625
+ * Captures an item's key and viewport offset, holding it through layout changes by default.
626
+ * Omit key to use the first visible item; set hold to false to read without side effects.
627
+ * Returns undefined before initial placement, during dataset replacement, or if no item is found.
628
+ * While following at the end, returns the anchor without interrupting end following.
629
+ */
630
+ anchorVisibleContent(options?: {
631
+ key?: string;
632
+ hold?: boolean;
633
+ }): {
634
+ key: string;
635
+ offset: number;
636
+ } | undefined;
579
637
  /**
580
638
  * Clears internal virtualization caches.
581
639
  * @param options - Cache clearing options.
@@ -618,20 +676,40 @@ type LegendListRef$1 = {
618
676
  * @param params - Parameters for scrolling.
619
677
  * @param params.animated - If true, animates the scroll. Default: true.
620
678
  * @param params.index - The index to scroll to.
679
+ * @param params.itemOffset - Region start measured from the item's start along the scroll axis. Default: 0 when itemLength is provided.
680
+ * @param params.itemLength - Region length along the scroll axis. Default: 0 when itemOffset is provided. Omit both to reveal the whole item.
681
+ * @param params.viewportMargin - Space to keep clear at the start and end of the viewport along the scroll axis.
682
+ * The region should be within the item. A visible region does not scroll; otherwise its nearest edge aligns inside the margins. A region larger than the available space aligns its start.
621
683
  */
622
684
  scrollIndexIntoView(params: {
623
685
  animated?: boolean | undefined;
624
686
  index: number;
687
+ itemOffset?: number;
688
+ itemLength?: number;
689
+ viewportMargin?: {
690
+ start?: number;
691
+ end?: number;
692
+ };
625
693
  }): Promise<void>;
626
694
  /**
627
- * Scrolls a specific index into view.
695
+ * Scrolls a specific item into view.
628
696
  * @param params - Parameters for scrolling.
629
697
  * @param params.animated - If true, animates the scroll. Default: true.
630
698
  * @param params.item - The item to scroll to.
699
+ * @param params.itemOffset - Region start measured from the item's start along the scroll axis. Default: 0 when itemLength is provided.
700
+ * @param params.itemLength - Region length along the scroll axis. Default: 0 when itemOffset is provided. Omit both to reveal the whole item.
701
+ * @param params.viewportMargin - Space to keep clear at the start and end of the viewport along the scroll axis.
702
+ * The region should be within the item. A visible region does not scroll; otherwise its nearest edge aligns inside the margins. A region larger than the available space aligns its start.
631
703
  */
632
704
  scrollItemIntoView(params: {
633
705
  animated?: boolean | undefined;
634
706
  item: any;
707
+ itemOffset?: number;
708
+ itemLength?: number;
709
+ viewportMargin?: {
710
+ start?: number;
711
+ end?: number;
712
+ };
635
713
  }): Promise<void>;
636
714
  /**
637
715
  * Scrolls to the end of the list.
@@ -710,6 +788,10 @@ interface ViewToken<ItemT = any> {
710
788
  interface ViewAmountToken<ItemT = any> extends ViewToken<ItemT> {
711
789
  percentOfScroller: number;
712
790
  percentVisible: number;
791
+ /**
792
+ * Viewport size used for this measurement, with any integration-reported
793
+ * occlusion (for example a keyboard) already subtracted.
794
+ */
713
795
  scrollSize: number;
714
796
  size: number;
715
797
  sizeVisible: number;
@@ -789,7 +871,9 @@ type LegendListPropsOverrides<ItemT, TItemType extends string | undefined> = Omi
789
871
  };
790
872
  type LegendListProps<ItemT = any, TItemType extends string | undefined = string | undefined> = LegendListPropsOverrides<ItemT, TItemType>;
791
873
  type LegendListRef = Omit<LegendListRef$1, "getAnimatableRef" | "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
874
+ /** Call cancelScroll() before scrolling it directly so end following and list scrolling stop first. */
792
875
  getAnimatableRef(): React.ElementRef<typeof ScrollViewComponent>;
876
+ /** Call cancelScroll() before scrolling it directly so end following and list scrolling stop first. */
793
877
  getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
794
878
  getScrollResponder(): ScrollResponderMixin;
795
879
  reportContentInset(inset?: Partial<Insets$1> | null): void;