@legendapp/list 1.0.19 → 1.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,11 @@
1
+ ## 1.1.0
2
+ - Feat: Add LazyLegendList component for virtualizing regular children
3
+ - Feat: Support initialScrollIndex with viewOffset and viewPosition
4
+ - Feat: Add estimatedListSize prop for better initial size estimation
5
+
6
+ ## 1.0.20
7
+ - Types: Fix type of ref in Reanimated LegendList
8
+
1
9
  ## 1.0.19
2
10
  - Fix: scrollToEnd not including footerSize
3
11
 
package/animated.d.mts CHANGED
@@ -3,17 +3,25 @@ import * as _legendapp_list from '@legendapp/list';
3
3
  import * as react_native from 'react-native';
4
4
  import { Animated } from 'react-native';
5
5
 
6
- declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
6
+ declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
7
7
  alignItemsAtEnd?: boolean;
8
8
  columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
9
9
  data: readonly T[];
10
10
  drawDistance?: number;
11
11
  estimatedItemSize?: number;
12
+ estimatedListSize?: {
13
+ height: number;
14
+ width: number;
15
+ };
12
16
  extraData?: any;
13
17
  getEstimatedItemSize?: ((index: number, item: T) => number) | undefined;
14
18
  initialContainerPoolRatio?: number | undefined;
15
19
  initialScrollOffset?: number;
16
- initialScrollIndex?: number;
20
+ initialScrollIndex?: number | {
21
+ index: number;
22
+ viewOffset?: number | undefined;
23
+ viewPosition?: number | undefined;
24
+ };
17
25
  ItemSeparatorComponent?: React$1.ComponentType<{
18
26
  leadingItem: T;
19
27
  }> | undefined;
package/animated.d.ts CHANGED
@@ -3,17 +3,25 @@ import * as _legendapp_list from '@legendapp/list';
3
3
  import * as react_native from 'react-native';
4
4
  import { Animated } from 'react-native';
5
5
 
6
- declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
6
+ declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
7
7
  alignItemsAtEnd?: boolean;
8
8
  columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
9
9
  data: readonly T[];
10
10
  drawDistance?: number;
11
11
  estimatedItemSize?: number;
12
+ estimatedListSize?: {
13
+ height: number;
14
+ width: number;
15
+ };
12
16
  extraData?: any;
13
17
  getEstimatedItemSize?: ((index: number, item: T) => number) | undefined;
14
18
  initialContainerPoolRatio?: number | undefined;
15
19
  initialScrollOffset?: number;
16
- initialScrollIndex?: number;
20
+ initialScrollIndex?: number | {
21
+ index: number;
22
+ viewOffset?: number | undefined;
23
+ viewPosition?: number | undefined;
24
+ };
17
25
  ItemSeparatorComponent?: React$1.ComponentType<{
18
26
  leadingItem: T;
19
27
  }> | undefined;
package/index.d.mts CHANGED
@@ -2,7 +2,10 @@ import * as React$1 from 'react';
2
2
  import { ComponentProps, ReactNode, Dispatch, SetStateAction } from 'react';
3
3
  import * as react_native from 'react-native';
4
4
  import { ScrollView, StyleProp, ViewStyle, ScrollViewProps, NativeSyntheticEvent, NativeScrollEvent, ScrollViewComponent, ScrollResponderMixin } from 'react-native';
5
- import react_native_reanimated__default from 'react-native-reanimated';
5
+ import Animated from 'react-native-reanimated';
6
+ import * as _legendapp_list_reanimated from '@legendapp/list/reanimated';
7
+ import * as _legendapp_list from '@legendapp/list';
8
+ import { LegendListProps as LegendListProps$1, LegendListRenderItemProps as LegendListRenderItemProps$1, LegendListRef as LegendListRef$1 } from '@legendapp/list';
6
9
 
7
10
  declare class ScrollAdjustHandler {
8
11
  private ctx;
@@ -20,7 +23,7 @@ declare class ScrollAdjustHandler {
20
23
  unPauseAdjust(): boolean;
21
24
  }
22
25
 
23
- type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof react_native_reanimated__default.ScrollView>> = Omit<TScrollView, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
26
+ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView>> = Omit<TScrollView, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
24
27
  /**
25
28
  * If true, aligns items at the end of the list.
26
29
  * @default false
@@ -46,6 +49,14 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
46
49
  * @default undefined
47
50
  */
48
51
  estimatedItemSize?: number;
52
+ /**
53
+ * Estimated size of the ScrollView in pixels, a hint for the first render to improve performance
54
+ * @default undefined
55
+ */
56
+ estimatedListSize?: {
57
+ height: number;
58
+ width: number;
59
+ };
49
60
  /**
50
61
  * Extra data to trigger re-rendering when changed.
51
62
  */
@@ -69,7 +80,11 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
69
80
  * Index to scroll to initially.
70
81
  * @default 0
71
82
  */
72
- initialScrollIndex?: number;
83
+ initialScrollIndex?: number | {
84
+ index: number;
85
+ viewOffset?: number | undefined;
86
+ viewPosition?: number | undefined;
87
+ };
73
88
  /**
74
89
  * Component to render between items, receiving the leading item as prop.
75
90
  */
@@ -478,18 +493,31 @@ type TypedMemo = <T extends React.ComponentType<any>>(Component: T, propsAreEqua
478
493
  displayName?: string;
479
494
  };
480
495
  declare const typedMemo: TypedMemo;
496
+ type ScrollIndexWithOffsetPosition = {
497
+ index: number;
498
+ viewOffset?: number;
499
+ viewPosition?: number;
500
+ };
481
501
 
482
- declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
502
+ declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
483
503
  alignItemsAtEnd?: boolean;
484
504
  columnWrapperStyle?: ColumnWrapperStyle;
485
505
  data: readonly T[];
486
506
  drawDistance?: number;
487
507
  estimatedItemSize?: number;
508
+ estimatedListSize?: {
509
+ height: number;
510
+ width: number;
511
+ };
488
512
  extraData?: any;
489
513
  getEstimatedItemSize?: ((index: number, item: T) => number) | undefined;
490
514
  initialContainerPoolRatio?: number | undefined;
491
515
  initialScrollOffset?: number;
492
- initialScrollIndex?: number;
516
+ initialScrollIndex?: number | {
517
+ index: number;
518
+ viewOffset?: number | undefined;
519
+ viewPosition?: number | undefined;
520
+ };
493
521
  ItemSeparatorComponent?: React$1.ComponentType<{
494
522
  leadingItem: T;
495
523
  }> | undefined;
@@ -535,6 +563,200 @@ declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "sc
535
563
  }) => void;
536
564
  } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode;
537
565
 
566
+ interface LazyLegendListProps<ItemT, ListT> extends Omit<LegendListProps$1<ItemT>, "data" | "keyExtractor" | "renderItem"> {
567
+ children?: React$1.ReactNode | undefined;
568
+ LegendList?: ListT;
569
+ }
570
+ declare const LazyLegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
571
+ alignItemsAtEnd?: boolean;
572
+ columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
573
+ data: readonly T[];
574
+ drawDistance?: number;
575
+ estimatedItemSize?: number;
576
+ estimatedListSize?: {
577
+ height: number;
578
+ width: number;
579
+ };
580
+ extraData?: any;
581
+ getEstimatedItemSize?: ((index: number, item: T) => number) | undefined;
582
+ initialContainerPoolRatio?: number | undefined;
583
+ initialScrollOffset?: number;
584
+ initialScrollIndex?: number | {
585
+ index: number;
586
+ viewOffset?: number | undefined;
587
+ viewPosition?: number | undefined;
588
+ };
589
+ ItemSeparatorComponent?: React$1.ComponentType<{
590
+ leadingItem: T;
591
+ }> | undefined;
592
+ keyExtractor?: ((item: T, index: number) => string) | undefined;
593
+ ListEmptyComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
594
+ ListFooterComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
595
+ ListFooterComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
596
+ ListHeaderComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
597
+ ListHeaderComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
598
+ maintainScrollAtEnd?: boolean;
599
+ maintainScrollAtEndThreshold?: number;
600
+ maintainVisibleContentPosition?: boolean;
601
+ numColumns?: number;
602
+ onEndReached?: ((info: {
603
+ distanceFromEnd: number;
604
+ }) => void) | null | undefined;
605
+ onEndReachedThreshold?: number | null | undefined;
606
+ onItemSizeChanged?: ((info: {
607
+ size: number;
608
+ previous: number;
609
+ index: number;
610
+ itemKey: string;
611
+ itemData: T;
612
+ }) => void) | undefined;
613
+ onRefresh?: () => void;
614
+ onStartReached?: ((info: {
615
+ distanceFromStart: number;
616
+ }) => void) | null | undefined;
617
+ onStartReachedThreshold?: number | null | undefined;
618
+ onViewableItemsChanged?: _legendapp_list.OnViewableItemsChanged | undefined;
619
+ progressViewOffset?: number;
620
+ recycleItems?: boolean;
621
+ refScrollView?: React$1.Ref<react_native.ScrollView>;
622
+ refreshing?: boolean;
623
+ renderItem?: React$1.ComponentType<LegendListRenderItemProps$1<T>> | ((props: LegendListRenderItemProps$1<T>) => React$1.ReactNode) | undefined;
624
+ renderScrollComponent?: (props: react_native.ScrollViewProps) => React$1.ReactElement<react_native.ScrollViewProps>;
625
+ suggestEstimatedItemSize?: boolean;
626
+ viewabilityConfig?: _legendapp_list.ViewabilityConfig;
627
+ viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
628
+ waitForInitialLayout?: boolean;
629
+ onLoad?: (info: {
630
+ elapsedTimeInMs: number;
631
+ }) => void;
632
+ } & React$1.RefAttributes<LegendListRef$1>) => React$1.ReactNode) | react_native.Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
633
+ alignItemsAtEnd?: boolean;
634
+ columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
635
+ data: readonly T[];
636
+ drawDistance?: number;
637
+ estimatedItemSize?: number;
638
+ estimatedListSize?: {
639
+ height: number;
640
+ width: number;
641
+ };
642
+ extraData?: any;
643
+ getEstimatedItemSize?: ((index: number, item: T) => number) | undefined;
644
+ initialContainerPoolRatio?: number | undefined;
645
+ initialScrollOffset?: number;
646
+ initialScrollIndex?: number | {
647
+ index: number;
648
+ viewOffset?: number | undefined;
649
+ viewPosition?: number | undefined;
650
+ };
651
+ ItemSeparatorComponent?: React$1.ComponentType<{
652
+ leadingItem: T;
653
+ }> | undefined;
654
+ keyExtractor?: ((item: T, index: number) => string) | undefined;
655
+ ListEmptyComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
656
+ ListFooterComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
657
+ ListFooterComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
658
+ ListHeaderComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
659
+ ListHeaderComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
660
+ maintainScrollAtEnd?: boolean;
661
+ maintainScrollAtEndThreshold?: number;
662
+ maintainVisibleContentPosition?: boolean;
663
+ numColumns?: number;
664
+ onEndReached?: ((info: {
665
+ distanceFromEnd: number;
666
+ }) => void) | null | undefined;
667
+ onEndReachedThreshold?: number | null | undefined;
668
+ onItemSizeChanged?: ((info: {
669
+ size: number;
670
+ previous: number;
671
+ index: number;
672
+ itemKey: string;
673
+ itemData: T;
674
+ }) => void) | undefined;
675
+ onRefresh?: () => void;
676
+ onStartReached?: ((info: {
677
+ distanceFromStart: number;
678
+ }) => void) | null | undefined;
679
+ onStartReachedThreshold?: number | null | undefined;
680
+ onViewableItemsChanged?: _legendapp_list.OnViewableItemsChanged | undefined;
681
+ progressViewOffset?: number;
682
+ recycleItems?: boolean;
683
+ refScrollView?: React$1.Ref<react_native.ScrollView>;
684
+ refreshing?: boolean;
685
+ renderItem?: React$1.ComponentType<LegendListRenderItemProps$1<T>> | ((props: LegendListRenderItemProps$1<T>) => React$1.ReactNode) | undefined;
686
+ renderScrollComponent?: (props: react_native.ScrollViewProps) => React$1.ReactElement<react_native.ScrollViewProps>;
687
+ suggestEstimatedItemSize?: boolean;
688
+ viewabilityConfig?: _legendapp_list.ViewabilityConfig;
689
+ viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
690
+ waitForInitialLayout?: boolean;
691
+ onLoad?: (info: {
692
+ elapsedTimeInMs: number;
693
+ }) => void;
694
+ } & React$1.RefAttributes<LegendListRef$1>) => React$1.ReactNode)> | (<ItemT_1>(props: _legendapp_list_reanimated.AnimatedLegendListProps<ItemT_1> & {
695
+ ref?: React$1.Ref<LegendListRef$1>;
696
+ }) => React$1.ReactElement | null) = <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
697
+ alignItemsAtEnd?: boolean;
698
+ columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
699
+ data: readonly T[];
700
+ drawDistance?: number;
701
+ estimatedItemSize?: number;
702
+ estimatedListSize?: {
703
+ height: number;
704
+ width: number;
705
+ };
706
+ extraData?: any;
707
+ getEstimatedItemSize?: ((index: number, item: T) => number) | undefined;
708
+ initialContainerPoolRatio?: number | undefined;
709
+ initialScrollOffset?: number;
710
+ initialScrollIndex?: number | {
711
+ index: number;
712
+ viewOffset?: number | undefined;
713
+ viewPosition?: number | undefined;
714
+ };
715
+ ItemSeparatorComponent?: React$1.ComponentType<{
716
+ leadingItem: T;
717
+ }> | undefined;
718
+ keyExtractor?: ((item: T, index: number) => string) | undefined;
719
+ ListEmptyComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
720
+ ListFooterComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
721
+ ListFooterComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
722
+ ListHeaderComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
723
+ ListHeaderComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
724
+ maintainScrollAtEnd?: boolean;
725
+ maintainScrollAtEndThreshold?: number;
726
+ maintainVisibleContentPosition?: boolean;
727
+ numColumns?: number;
728
+ onEndReached?: ((info: {
729
+ distanceFromEnd: number;
730
+ }) => void) | null | undefined;
731
+ onEndReachedThreshold?: number | null | undefined;
732
+ onItemSizeChanged?: ((info: {
733
+ size: number;
734
+ previous: number;
735
+ index: number;
736
+ itemKey: string;
737
+ itemData: T;
738
+ }) => void) | undefined;
739
+ onRefresh?: () => void;
740
+ onStartReached?: ((info: {
741
+ distanceFromStart: number;
742
+ }) => void) | null | undefined;
743
+ onStartReachedThreshold?: number | null | undefined;
744
+ onViewableItemsChanged?: _legendapp_list.OnViewableItemsChanged | undefined;
745
+ progressViewOffset?: number;
746
+ recycleItems?: boolean;
747
+ refScrollView?: React$1.Ref<react_native.ScrollView>;
748
+ refreshing?: boolean;
749
+ renderItem?: React$1.ComponentType<LegendListRenderItemProps$1<T>> | ((props: LegendListRenderItemProps$1<T>) => React$1.ReactNode) | undefined;
750
+ renderScrollComponent?: (props: react_native.ScrollViewProps) => React$1.ReactElement<react_native.ScrollViewProps>;
751
+ suggestEstimatedItemSize?: boolean;
752
+ viewabilityConfig?: _legendapp_list.ViewabilityConfig;
753
+ viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
754
+ waitForInitialLayout?: boolean;
755
+ onLoad?: (info: {
756
+ elapsedTimeInMs: number;
757
+ }) => void;
758
+ } & React$1.RefAttributes<LegendListRef$1>) => React$1.ReactNode>(props: LazyLegendListProps<ItemT, ListT> & React$1.RefAttributes<LegendListRef$1>) => React$1.ReactNode;
759
+
538
760
  declare function useViewability(callback: ViewabilityCallback, configId?: string): void;
539
761
  declare function useViewabilityAmount(callback: ViewabilityAmountCallback): void;
540
762
  declare function useRecyclingEffect(effect: (info: LegendListRecyclingState<unknown>) => void | (() => void)): void;
@@ -545,4 +767,4 @@ declare function useListScrollSize(): {
545
767
  height: number;
546
768
  };
547
769
 
548
- export { type AnchoredPosition, type ColumnWrapperStyle, type InternalState, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ScrollState, type TypedForwardRef, type TypedMemo, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange, typedForwardRef, typedMemo, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };
770
+ export { type AnchoredPosition, type ColumnWrapperStyle, type InternalState, LazyLegendList, type LazyLegendListProps, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ScrollIndexWithOffsetPosition, type ScrollState, type TypedForwardRef, type TypedMemo, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange, typedForwardRef, typedMemo, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };
package/index.d.ts CHANGED
@@ -2,7 +2,10 @@ import * as React$1 from 'react';
2
2
  import { ComponentProps, ReactNode, Dispatch, SetStateAction } from 'react';
3
3
  import * as react_native from 'react-native';
4
4
  import { ScrollView, StyleProp, ViewStyle, ScrollViewProps, NativeSyntheticEvent, NativeScrollEvent, ScrollViewComponent, ScrollResponderMixin } from 'react-native';
5
- import react_native_reanimated__default from 'react-native-reanimated';
5
+ import Animated from 'react-native-reanimated';
6
+ import * as _legendapp_list_reanimated from '@legendapp/list/reanimated';
7
+ import * as _legendapp_list from '@legendapp/list';
8
+ import { LegendListProps as LegendListProps$1, LegendListRenderItemProps as LegendListRenderItemProps$1, LegendListRef as LegendListRef$1 } from '@legendapp/list';
6
9
 
7
10
  declare class ScrollAdjustHandler {
8
11
  private ctx;
@@ -20,7 +23,7 @@ declare class ScrollAdjustHandler {
20
23
  unPauseAdjust(): boolean;
21
24
  }
22
25
 
23
- type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof react_native_reanimated__default.ScrollView>> = Omit<TScrollView, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
26
+ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView>> = Omit<TScrollView, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
24
27
  /**
25
28
  * If true, aligns items at the end of the list.
26
29
  * @default false
@@ -46,6 +49,14 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
46
49
  * @default undefined
47
50
  */
48
51
  estimatedItemSize?: number;
52
+ /**
53
+ * Estimated size of the ScrollView in pixels, a hint for the first render to improve performance
54
+ * @default undefined
55
+ */
56
+ estimatedListSize?: {
57
+ height: number;
58
+ width: number;
59
+ };
49
60
  /**
50
61
  * Extra data to trigger re-rendering when changed.
51
62
  */
@@ -69,7 +80,11 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
69
80
  * Index to scroll to initially.
70
81
  * @default 0
71
82
  */
72
- initialScrollIndex?: number;
83
+ initialScrollIndex?: number | {
84
+ index: number;
85
+ viewOffset?: number | undefined;
86
+ viewPosition?: number | undefined;
87
+ };
73
88
  /**
74
89
  * Component to render between items, receiving the leading item as prop.
75
90
  */
@@ -478,18 +493,31 @@ type TypedMemo = <T extends React.ComponentType<any>>(Component: T, propsAreEqua
478
493
  displayName?: string;
479
494
  };
480
495
  declare const typedMemo: TypedMemo;
496
+ type ScrollIndexWithOffsetPosition = {
497
+ index: number;
498
+ viewOffset?: number;
499
+ viewPosition?: number;
500
+ };
481
501
 
482
- declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
502
+ declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
483
503
  alignItemsAtEnd?: boolean;
484
504
  columnWrapperStyle?: ColumnWrapperStyle;
485
505
  data: readonly T[];
486
506
  drawDistance?: number;
487
507
  estimatedItemSize?: number;
508
+ estimatedListSize?: {
509
+ height: number;
510
+ width: number;
511
+ };
488
512
  extraData?: any;
489
513
  getEstimatedItemSize?: ((index: number, item: T) => number) | undefined;
490
514
  initialContainerPoolRatio?: number | undefined;
491
515
  initialScrollOffset?: number;
492
- initialScrollIndex?: number;
516
+ initialScrollIndex?: number | {
517
+ index: number;
518
+ viewOffset?: number | undefined;
519
+ viewPosition?: number | undefined;
520
+ };
493
521
  ItemSeparatorComponent?: React$1.ComponentType<{
494
522
  leadingItem: T;
495
523
  }> | undefined;
@@ -535,6 +563,200 @@ declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "sc
535
563
  }) => void;
536
564
  } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode;
537
565
 
566
+ interface LazyLegendListProps<ItemT, ListT> extends Omit<LegendListProps$1<ItemT>, "data" | "keyExtractor" | "renderItem"> {
567
+ children?: React$1.ReactNode | undefined;
568
+ LegendList?: ListT;
569
+ }
570
+ declare const LazyLegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
571
+ alignItemsAtEnd?: boolean;
572
+ columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
573
+ data: readonly T[];
574
+ drawDistance?: number;
575
+ estimatedItemSize?: number;
576
+ estimatedListSize?: {
577
+ height: number;
578
+ width: number;
579
+ };
580
+ extraData?: any;
581
+ getEstimatedItemSize?: ((index: number, item: T) => number) | undefined;
582
+ initialContainerPoolRatio?: number | undefined;
583
+ initialScrollOffset?: number;
584
+ initialScrollIndex?: number | {
585
+ index: number;
586
+ viewOffset?: number | undefined;
587
+ viewPosition?: number | undefined;
588
+ };
589
+ ItemSeparatorComponent?: React$1.ComponentType<{
590
+ leadingItem: T;
591
+ }> | undefined;
592
+ keyExtractor?: ((item: T, index: number) => string) | undefined;
593
+ ListEmptyComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
594
+ ListFooterComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
595
+ ListFooterComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
596
+ ListHeaderComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
597
+ ListHeaderComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
598
+ maintainScrollAtEnd?: boolean;
599
+ maintainScrollAtEndThreshold?: number;
600
+ maintainVisibleContentPosition?: boolean;
601
+ numColumns?: number;
602
+ onEndReached?: ((info: {
603
+ distanceFromEnd: number;
604
+ }) => void) | null | undefined;
605
+ onEndReachedThreshold?: number | null | undefined;
606
+ onItemSizeChanged?: ((info: {
607
+ size: number;
608
+ previous: number;
609
+ index: number;
610
+ itemKey: string;
611
+ itemData: T;
612
+ }) => void) | undefined;
613
+ onRefresh?: () => void;
614
+ onStartReached?: ((info: {
615
+ distanceFromStart: number;
616
+ }) => void) | null | undefined;
617
+ onStartReachedThreshold?: number | null | undefined;
618
+ onViewableItemsChanged?: _legendapp_list.OnViewableItemsChanged | undefined;
619
+ progressViewOffset?: number;
620
+ recycleItems?: boolean;
621
+ refScrollView?: React$1.Ref<react_native.ScrollView>;
622
+ refreshing?: boolean;
623
+ renderItem?: React$1.ComponentType<LegendListRenderItemProps$1<T>> | ((props: LegendListRenderItemProps$1<T>) => React$1.ReactNode) | undefined;
624
+ renderScrollComponent?: (props: react_native.ScrollViewProps) => React$1.ReactElement<react_native.ScrollViewProps>;
625
+ suggestEstimatedItemSize?: boolean;
626
+ viewabilityConfig?: _legendapp_list.ViewabilityConfig;
627
+ viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
628
+ waitForInitialLayout?: boolean;
629
+ onLoad?: (info: {
630
+ elapsedTimeInMs: number;
631
+ }) => void;
632
+ } & React$1.RefAttributes<LegendListRef$1>) => React$1.ReactNode) | react_native.Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
633
+ alignItemsAtEnd?: boolean;
634
+ columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
635
+ data: readonly T[];
636
+ drawDistance?: number;
637
+ estimatedItemSize?: number;
638
+ estimatedListSize?: {
639
+ height: number;
640
+ width: number;
641
+ };
642
+ extraData?: any;
643
+ getEstimatedItemSize?: ((index: number, item: T) => number) | undefined;
644
+ initialContainerPoolRatio?: number | undefined;
645
+ initialScrollOffset?: number;
646
+ initialScrollIndex?: number | {
647
+ index: number;
648
+ viewOffset?: number | undefined;
649
+ viewPosition?: number | undefined;
650
+ };
651
+ ItemSeparatorComponent?: React$1.ComponentType<{
652
+ leadingItem: T;
653
+ }> | undefined;
654
+ keyExtractor?: ((item: T, index: number) => string) | undefined;
655
+ ListEmptyComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
656
+ ListFooterComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
657
+ ListFooterComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
658
+ ListHeaderComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
659
+ ListHeaderComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
660
+ maintainScrollAtEnd?: boolean;
661
+ maintainScrollAtEndThreshold?: number;
662
+ maintainVisibleContentPosition?: boolean;
663
+ numColumns?: number;
664
+ onEndReached?: ((info: {
665
+ distanceFromEnd: number;
666
+ }) => void) | null | undefined;
667
+ onEndReachedThreshold?: number | null | undefined;
668
+ onItemSizeChanged?: ((info: {
669
+ size: number;
670
+ previous: number;
671
+ index: number;
672
+ itemKey: string;
673
+ itemData: T;
674
+ }) => void) | undefined;
675
+ onRefresh?: () => void;
676
+ onStartReached?: ((info: {
677
+ distanceFromStart: number;
678
+ }) => void) | null | undefined;
679
+ onStartReachedThreshold?: number | null | undefined;
680
+ onViewableItemsChanged?: _legendapp_list.OnViewableItemsChanged | undefined;
681
+ progressViewOffset?: number;
682
+ recycleItems?: boolean;
683
+ refScrollView?: React$1.Ref<react_native.ScrollView>;
684
+ refreshing?: boolean;
685
+ renderItem?: React$1.ComponentType<LegendListRenderItemProps$1<T>> | ((props: LegendListRenderItemProps$1<T>) => React$1.ReactNode) | undefined;
686
+ renderScrollComponent?: (props: react_native.ScrollViewProps) => React$1.ReactElement<react_native.ScrollViewProps>;
687
+ suggestEstimatedItemSize?: boolean;
688
+ viewabilityConfig?: _legendapp_list.ViewabilityConfig;
689
+ viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
690
+ waitForInitialLayout?: boolean;
691
+ onLoad?: (info: {
692
+ elapsedTimeInMs: number;
693
+ }) => void;
694
+ } & React$1.RefAttributes<LegendListRef$1>) => React$1.ReactNode)> | (<ItemT_1>(props: _legendapp_list_reanimated.AnimatedLegendListProps<ItemT_1> & {
695
+ ref?: React$1.Ref<LegendListRef$1>;
696
+ }) => React$1.ReactElement | null) = <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
697
+ alignItemsAtEnd?: boolean;
698
+ columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
699
+ data: readonly T[];
700
+ drawDistance?: number;
701
+ estimatedItemSize?: number;
702
+ estimatedListSize?: {
703
+ height: number;
704
+ width: number;
705
+ };
706
+ extraData?: any;
707
+ getEstimatedItemSize?: ((index: number, item: T) => number) | undefined;
708
+ initialContainerPoolRatio?: number | undefined;
709
+ initialScrollOffset?: number;
710
+ initialScrollIndex?: number | {
711
+ index: number;
712
+ viewOffset?: number | undefined;
713
+ viewPosition?: number | undefined;
714
+ };
715
+ ItemSeparatorComponent?: React$1.ComponentType<{
716
+ leadingItem: T;
717
+ }> | undefined;
718
+ keyExtractor?: ((item: T, index: number) => string) | undefined;
719
+ ListEmptyComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
720
+ ListFooterComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
721
+ ListFooterComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
722
+ ListHeaderComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
723
+ ListHeaderComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
724
+ maintainScrollAtEnd?: boolean;
725
+ maintainScrollAtEndThreshold?: number;
726
+ maintainVisibleContentPosition?: boolean;
727
+ numColumns?: number;
728
+ onEndReached?: ((info: {
729
+ distanceFromEnd: number;
730
+ }) => void) | null | undefined;
731
+ onEndReachedThreshold?: number | null | undefined;
732
+ onItemSizeChanged?: ((info: {
733
+ size: number;
734
+ previous: number;
735
+ index: number;
736
+ itemKey: string;
737
+ itemData: T;
738
+ }) => void) | undefined;
739
+ onRefresh?: () => void;
740
+ onStartReached?: ((info: {
741
+ distanceFromStart: number;
742
+ }) => void) | null | undefined;
743
+ onStartReachedThreshold?: number | null | undefined;
744
+ onViewableItemsChanged?: _legendapp_list.OnViewableItemsChanged | undefined;
745
+ progressViewOffset?: number;
746
+ recycleItems?: boolean;
747
+ refScrollView?: React$1.Ref<react_native.ScrollView>;
748
+ refreshing?: boolean;
749
+ renderItem?: React$1.ComponentType<LegendListRenderItemProps$1<T>> | ((props: LegendListRenderItemProps$1<T>) => React$1.ReactNode) | undefined;
750
+ renderScrollComponent?: (props: react_native.ScrollViewProps) => React$1.ReactElement<react_native.ScrollViewProps>;
751
+ suggestEstimatedItemSize?: boolean;
752
+ viewabilityConfig?: _legendapp_list.ViewabilityConfig;
753
+ viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
754
+ waitForInitialLayout?: boolean;
755
+ onLoad?: (info: {
756
+ elapsedTimeInMs: number;
757
+ }) => void;
758
+ } & React$1.RefAttributes<LegendListRef$1>) => React$1.ReactNode>(props: LazyLegendListProps<ItemT, ListT> & React$1.RefAttributes<LegendListRef$1>) => React$1.ReactNode;
759
+
538
760
  declare function useViewability(callback: ViewabilityCallback, configId?: string): void;
539
761
  declare function useViewabilityAmount(callback: ViewabilityAmountCallback): void;
540
762
  declare function useRecyclingEffect(effect: (info: LegendListRecyclingState<unknown>) => void | (() => void)): void;
@@ -545,4 +767,4 @@ declare function useListScrollSize(): {
545
767
  height: number;
546
768
  };
547
769
 
548
- export { type AnchoredPosition, type ColumnWrapperStyle, type InternalState, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ScrollState, type TypedForwardRef, type TypedMemo, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange, typedForwardRef, typedMemo, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };
770
+ export { type AnchoredPosition, type ColumnWrapperStyle, type InternalState, LazyLegendList, type LazyLegendListProps, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ScrollIndexWithOffsetPosition, type ScrollState, type TypedForwardRef, type TypedMemo, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange, typedForwardRef, typedMemo, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };