@legendapp/list 3.6.0 → 3.7.1

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.
@@ -35,8 +35,8 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
35
35
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
36
36
  }
37
37
 
38
- 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}`;
39
- type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
38
+ 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}`;
39
+ type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isFollowingEnd" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
40
40
  type ListenerTypeValueMap = {
41
41
  activeStickyIndex: number;
42
42
  alignItemsAtEndPadding: number;
@@ -48,6 +48,7 @@ type ListenerTypeValueMap = {
48
48
  extraData: any;
49
49
  footerSize: number;
50
50
  headerSize: number;
51
+ isFollowingEnd: boolean;
51
52
  isAtEnd: boolean;
52
53
  isAtStart: boolean;
53
54
  isNearEnd: boolean;
@@ -61,6 +62,7 @@ type ListenerTypeValueMap = {
61
62
  numContainersPooled: number;
62
63
  otherAxisSize: number;
63
64
  readyToRender: boolean;
65
+ isScrollActive: boolean;
64
66
  scrollAdjust: number;
65
67
  scrollAdjustPending: number;
66
68
  scrollAdjustUserOffset: number;
@@ -226,6 +228,7 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
226
228
  extraData?: any;
227
229
  /**
228
230
  * In case items always have a fixed size, you can provide a function to return it.
231
+ * Change extraData when the fixed sizes returned by this callback change.
229
232
  */
230
233
  getFixedItemSize?: (item: ItemT, index: number, type: TItemType) => number | undefined;
231
234
  /**
@@ -298,6 +301,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
298
301
  /**
299
302
  * If true, auto-scrolls to end when new items are added.
300
303
  * Use an options object to opt into specific triggers and control whether that scroll is animated.
304
+ * Setting false pauses maintenance while retaining end-follow intent. Re-enabling resumes
305
+ * that intent even if content grew beyond the threshold; user or list navigation releases it.
306
+ * While paused, isFollowingEnd reports the retained intent.
307
+ * With a native screen reader enabled, unowned accessibility scrolls toward the start
308
+ * release following. Assistive-tech scrolls during library animations are not detected.
301
309
  * @default false
302
310
  */
303
311
  maintainScrollAtEnd?: boolean | MaintainScrollAtEndOptions;
@@ -308,11 +316,13 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
308
316
  maintainScrollAtEndThreshold?: number;
309
317
  /**
310
318
  * Maintains visibility of content.
311
- * - scroll (default: true) stabilizes during size/layout changes while scrolling.
312
- * - data (default: false) stabilizes when the data array changes; passing true also sets the RN maintainVisibleContentPosition prop.
319
+ * - size (default: true) stabilizes during size/layout changes while scrolling.
320
+ * - data (default: false) stabilizes when the data array changes.
313
321
  * - shouldRestorePosition can opt out specific items from data-change anchoring.
314
322
  * - undefined (default) enables scroll stabilization but skips data-change anchoring.
315
- * - true enables both behaviors; false disables both.
323
+ * - true enables both JS behaviors; false disables both.
324
+ * Native iOS maintainVisibleContentPosition is enabled when either size or data stabilization is enabled,
325
+ * and disabled when both are disabled.
316
326
  */
317
327
  maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig<ItemT>;
318
328
  /**
@@ -404,8 +414,25 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
404
414
  */
405
415
  onRefresh?: () => void;
406
416
  /**
407
- * Called when the list scrolls.
408
- */
417
+ * Called once per accepted user gesture, in either direction: native drag (including
418
+ * momentum), web wheel/touch movement, non-repeated scroll keydown, or scrollbar drag.
419
+ * Wheel input at a boundary is ignored unless navigation is active. Without wheel
420
+ * momentum metadata, gesture boundaries are inferred from timing, direction and force.
421
+ * iOS status-bar scrolling emits on native onScrollToTop unless accessibility motion
422
+ * already reported it during the animation.
423
+ * With a native screen reader enabled, otherwise unowned scroll motion with stable
424
+ * content/viewport size is inferred as accessibility input (including focus navigation),
425
+ * once per burst; motion toward the start releases end following. Library animations
426
+ * and controller/native-ref command windows mask assistive-tech scrolling.
427
+ * Native commands bypassing the list and its refs (e.g. Reanimated scrollTo worklets)
428
+ * cannot be distinguished from accessibility input while a screen reader is on; call
429
+ * cancelScroll() on the JS thread before that navigation to release end following.
430
+ * Layout/clamp/MVCP events and commands through the list or its refs do not emit it.
431
+ * @experimental Native pointer/wheel-only input without a screen reader is not detected.
432
+ * Web scrollbar detection requires pointer events in a measurable, non-overlay gutter.
433
+ */
434
+ onUserScroll?: () => void;
435
+ /** Called when the list scrolls. */
409
436
  onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
410
437
  /**
411
438
  * Called when scrolling reaches the start within onStartReachedThreshold.
@@ -537,6 +564,8 @@ interface AlwaysRenderConfig {
537
564
  keys?: string[];
538
565
  }
539
566
  interface MaintainScrollAtEndOnOptions {
567
+ /** Follow only additions that preserve every existing item key in order. */
568
+ dataAppend?: boolean;
540
569
  dataChange?: boolean;
541
570
  footerLayout?: boolean;
542
571
  itemLayout?: boolean;
@@ -578,9 +607,13 @@ type LegendListState$1 = {
578
607
  activeStickyIndex: number;
579
608
  contentLength: number;
580
609
  data: readonly any[];
610
+ dataKey?: Key;
581
611
  elementAtIndex: (index: number) => any;
582
612
  end: number;
583
613
  endBuffered: number;
614
+ /** Distance to the physical scroll edge, including the trailing inset. */
615
+ distanceFromEnd: number;
616
+ isFollowingEnd: boolean;
584
617
  isAtEnd: boolean;
585
618
  isAtStart: boolean;
586
619
  isNearEnd: boolean;
@@ -590,7 +623,10 @@ type LegendListState$1 = {
590
623
  isWithinMaintainScrollAtEndThreshold: boolean;
591
624
  getAverageItemSizes: () => Record<string, LegendListAverageItemSize>;
592
625
  indexByKey: (key: string) => number | undefined;
593
- listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
626
+ listen: {
627
+ <T extends Exclude<LegendListListenerType, "isFollowingEnd">>(listenerType: T, callback: (value: Pick<ListenerTypeValueMap, LegendListListenerType>[T]) => void): () => void;
628
+ <T extends LegendListListenerType>(listenerType: T, callback: (value: Pick<ListenerTypeValueMap, LegendListListenerType>[T]) => void): () => void;
629
+ };
594
630
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
595
631
  positionAtIndex: (index: number) => number;
596
632
  positionByKey: (key: string) => number | undefined;
@@ -603,6 +639,28 @@ type LegendListState$1 = {
603
639
  startBuffered: number;
604
640
  };
605
641
  type LegendListRef$1 = {
642
+ /** Cancels queued and active scrolling, settles its promise, and stops at the observed offset. */
643
+ cancelScroll(): void;
644
+ /** Scrolls by stable item identity through prepends; resolves without scrolling if the key is missing or removed. */
645
+ scrollToKey(params: {
646
+ key: string;
647
+ animated?: boolean;
648
+ viewOffset?: number;
649
+ viewPosition?: number;
650
+ }): Promise<void>;
651
+ /**
652
+ * Captures an item's key and viewport offset, holding it through layout changes by default.
653
+ * Omit key to use the first visible item; set hold to false to read without side effects.
654
+ * Returns undefined before initial placement, during dataset replacement, or if no item is found.
655
+ * While following at the end, returns the anchor without interrupting end following.
656
+ */
657
+ anchorVisibleContent(options?: {
658
+ key?: string;
659
+ hold?: boolean;
660
+ }): {
661
+ key: string;
662
+ offset: number;
663
+ } | undefined;
606
664
  /**
607
665
  * Clears internal virtualization caches.
608
666
  * @param options - Cache clearing options.
@@ -645,20 +703,40 @@ type LegendListRef$1 = {
645
703
  * @param params - Parameters for scrolling.
646
704
  * @param params.animated - If true, animates the scroll. Default: true.
647
705
  * @param params.index - The index to scroll to.
706
+ * @param params.itemOffset - Region start measured from the item's start along the scroll axis. Default: 0 when itemLength is provided.
707
+ * @param params.itemLength - Region length along the scroll axis. Default: 0 when itemOffset is provided. Omit both to reveal the whole item.
708
+ * @param params.viewportMargin - Space to keep clear at the start and end of the viewport along the scroll axis.
709
+ * 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.
648
710
  */
649
711
  scrollIndexIntoView(params: {
650
712
  animated?: boolean | undefined;
651
713
  index: number;
714
+ itemOffset?: number;
715
+ itemLength?: number;
716
+ viewportMargin?: {
717
+ start?: number;
718
+ end?: number;
719
+ };
652
720
  }): Promise<void>;
653
721
  /**
654
- * Scrolls a specific index into view.
722
+ * Scrolls a specific item into view.
655
723
  * @param params - Parameters for scrolling.
656
724
  * @param params.animated - If true, animates the scroll. Default: true.
657
725
  * @param params.item - The item to scroll to.
726
+ * @param params.itemOffset - Region start measured from the item's start along the scroll axis. Default: 0 when itemLength is provided.
727
+ * @param params.itemLength - Region length along the scroll axis. Default: 0 when itemOffset is provided. Omit both to reveal the whole item.
728
+ * @param params.viewportMargin - Space to keep clear at the start and end of the viewport along the scroll axis.
729
+ * 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.
658
730
  */
659
731
  scrollItemIntoView(params: {
660
732
  animated?: boolean | undefined;
661
733
  item: any;
734
+ itemOffset?: number;
735
+ itemLength?: number;
736
+ viewportMargin?: {
737
+ start?: number;
738
+ end?: number;
739
+ };
662
740
  }): Promise<void>;
663
741
  /**
664
742
  * Scrolls to the end of the list.
@@ -737,6 +815,10 @@ interface ViewToken<ItemT = any> {
737
815
  interface ViewAmountToken<ItemT = any> extends ViewToken<ItemT> {
738
816
  percentOfScroller: number;
739
817
  percentVisible: number;
818
+ /**
819
+ * Viewport size used for this measurement, with any integration-reported
820
+ * occlusion (for example a keyboard) already subtracted.
821
+ */
740
822
  scrollSize: number;
741
823
  size: number;
742
824
  sizeVisible: number;
@@ -824,11 +906,13 @@ interface LooseScrollViewProps {
824
906
  autoscrollToTopThreshold?: number;
825
907
  minIndexForVisible: number;
826
908
  };
909
+ onContentSizeChange?: (width: number, height: number) => void;
827
910
  onLayout?: (event: LooseLayoutChangeEvent) => void;
828
911
  onMomentumScrollBegin?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
829
912
  onMomentumScrollEnd?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
830
913
  onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
831
914
  onScrollBeginDrag?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
915
+ onScrollToTop?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
832
916
  onScrollEndDrag?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
833
917
  refreshControl?: ReactElement | null;
834
918
  removeClippedSubviews?: boolean;