@legendapp/list 3.0.0-beta.32 → 3.0.0-beta.33

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.
Files changed (54) hide show
  1. package/README.md +7 -1
  2. package/animated.d.ts +600 -6
  3. package/animated.js +2 -2
  4. package/animated.mjs +1 -1
  5. package/index.d.ts +454 -108
  6. package/index.js +81 -32
  7. package/index.mjs +81 -32
  8. package/index.native.js +89 -44
  9. package/index.native.mjs +88 -43
  10. package/keyboard-controller.d.ts +611 -6
  11. package/keyboard-controller.js +2 -2
  12. package/keyboard-controller.mjs +1 -1
  13. package/keyboard.d.ts +204 -8
  14. package/keyboard.js +66 -52
  15. package/keyboard.mjs +69 -54
  16. package/{index.d.mts → list-react-native.d.ts} +95 -32
  17. package/list-react-native.js +4234 -0
  18. package/list-react-native.mjs +4204 -0
  19. package/{index.native.d.mts → list-react.d.ts} +355 -40
  20. package/list-react.js +4426 -0
  21. package/list-react.mjs +4396 -0
  22. package/package.json +52 -1
  23. package/reanimated.d.ts +595 -7
  24. package/reanimated.js +156 -11
  25. package/reanimated.mjs +153 -8
  26. package/section-list.d.ts +610 -14
  27. package/section-list.js +6 -6
  28. package/section-list.mjs +1 -1
  29. package/animated.d.mts +0 -9
  30. package/animated.native.d.mts +0 -9
  31. package/animated.native.d.ts +0 -9
  32. package/animated.native.js +0 -9
  33. package/animated.native.mjs +0 -7
  34. package/index.native.d.ts +0 -817
  35. package/keyboard-controller.d.mts +0 -12
  36. package/keyboard-controller.native.d.mts +0 -12
  37. package/keyboard-controller.native.d.ts +0 -12
  38. package/keyboard-controller.native.js +0 -69
  39. package/keyboard-controller.native.mjs +0 -48
  40. package/keyboard.d.mts +0 -13
  41. package/keyboard.native.d.mts +0 -13
  42. package/keyboard.native.d.ts +0 -13
  43. package/keyboard.native.js +0 -399
  44. package/keyboard.native.mjs +0 -377
  45. package/reanimated.d.mts +0 -18
  46. package/reanimated.native.d.mts +0 -18
  47. package/reanimated.native.d.ts +0 -18
  48. package/reanimated.native.js +0 -89
  49. package/reanimated.native.mjs +0 -65
  50. package/section-list.d.mts +0 -112
  51. package/section-list.native.d.mts +0 -112
  52. package/section-list.native.d.ts +0 -112
  53. package/section-list.native.js +0 -293
  54. package/section-list.native.mjs +0 -271
@@ -1,10 +1,14 @@
1
1
  import * as React$1 from 'react';
2
- import { Key, ComponentProps, ReactNode, Dispatch, SetStateAction } from 'react';
3
- import { View, LayoutRectangle, Insets, ScrollView, ScrollViewProps, Animated, StyleProp, ViewStyle, NativeSyntheticEvent, NativeScrollEvent, ScrollViewComponent, ScrollResponderMixin } from 'react-native';
4
- import Reanimated from 'react-native-reanimated';
2
+ import { Key, ReactNode, ReactElement, Dispatch, SetStateAction } from 'react';
3
+ import { ScrollViewProps, NativeSyntheticEvent as NativeSyntheticEvent$1, NativeScrollEvent as NativeScrollEvent$1, ScrollView, StyleProp as StyleProp$1, ViewStyle as ViewStyle$1, ScrollViewComponent, ScrollResponderMixin, Insets as Insets$1, View } from 'react-native';
5
4
 
6
5
  type AnimatedValue = number;
7
6
 
7
+ type LooseMeasureCallback = (x: number, y: number, width: number, height: number, pageX: number, pageY: number) => void;
8
+ interface LooseView {
9
+ measure?: (callback: LooseMeasureCallback) => void;
10
+ }
11
+
8
12
  type ListenerType = "activeStickyIndex" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
9
13
  type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
10
14
  type ListenerTypeValueMap = {
@@ -65,7 +69,7 @@ interface StateContext {
65
69
  positionListeners: Map<string, Set<(value: any) => void>>;
66
70
  state: InternalState;
67
71
  values: Map<ListenerType, any>;
68
- viewRefs: Map<number, React$1.RefObject<View>>;
72
+ viewRefs: Map<number, React$1.RefObject<LooseView>>;
69
73
  }
70
74
 
71
75
  declare class ScrollAdjustHandler {
@@ -85,6 +89,39 @@ type StylesAsSharedValue<Style> = {
85
89
  [key in keyof Style]: Style[key] | BaseSharedValue<Style[key]>;
86
90
  };
87
91
 
92
+ interface Insets {
93
+ top: number;
94
+ left: number;
95
+ bottom: number;
96
+ right: number;
97
+ }
98
+ interface LayoutRectangle {
99
+ x: number;
100
+ y: number;
101
+ width: number;
102
+ height: number;
103
+ }
104
+ interface NativeScrollEvent {
105
+ contentOffset: {
106
+ x: number;
107
+ y: number;
108
+ };
109
+ contentSize: {
110
+ width: number;
111
+ height: number;
112
+ };
113
+ layoutMeasurement: {
114
+ width: number;
115
+ height: number;
116
+ };
117
+ contentInset: Insets;
118
+ zoomScale: number;
119
+ }
120
+ interface NativeSyntheticEvent<T> {
121
+ nativeEvent: T;
122
+ }
123
+ type ViewStyle = Record<string, unknown>;
124
+ type StyleProp<T> = T | T[] | null | undefined | false;
88
125
  type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
89
126
  interface DataModeProps<ItemT, TItemType extends string | undefined> {
90
127
  /**
@@ -311,7 +348,7 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
311
348
  /**
312
349
  * Ref to the underlying ScrollView component.
313
350
  */
314
- refScrollView?: React.Ref<ScrollView>;
351
+ refScrollView?: React.Ref<any>;
315
352
  /**
316
353
  * If true, shows a refresh indicator.
317
354
  * @default false
@@ -322,7 +359,7 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
322
359
  * Note: When using `stickyHeaderIndices`, you must provide an Animated ScrollView component.
323
360
  * @default (props) => <ScrollView {...props} />
324
361
  */
325
- renderScrollComponent?: (props: ScrollViewProps) => React.ReactElement<ScrollViewProps>;
362
+ renderScrollComponent?: (props: any) => React.ReactElement | null;
326
363
  /**
327
364
  * This will log a suggested estimatedItemSize.
328
365
  * @required
@@ -366,7 +403,8 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
366
403
  getFixedItemSize?: (item: ItemT, index: number, type: TItemType) => number | undefined;
367
404
  itemsAreEqual?: (itemPrevious: ItemT, item: ItemT, index: number, data: readonly ItemT[]) => boolean;
368
405
  }
369
- type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView> | ComponentProps<typeof Reanimated.ScrollView>, TItemType extends string | undefined = string | undefined> = BaseScrollViewProps<TScrollView> & LegendListSpecificProps<ItemT, TItemType> & (DataModeProps<ItemT, TItemType> | ChildrenModeProps);
406
+ type LegendListPropsBase<ItemT, TScrollViewProps = Record<string, any>, TItemType extends string | undefined = string | undefined> = BaseScrollViewProps<TScrollViewProps> & LegendListSpecificProps<ItemT, TItemType> & (DataModeProps<ItemT, TItemType> | ChildrenModeProps);
407
+ type LegendListPropsInternal = LegendListSpecificProps<any, string | undefined> & DataModeProps<any, string | undefined>;
370
408
  interface MaintainVisibleContentPositionConfig<ItemT = any> {
371
409
  data?: boolean;
372
410
  size?: boolean;
@@ -410,7 +448,6 @@ interface LegendListMetrics {
410
448
  headerSize: number;
411
449
  footerSize: number;
412
450
  }
413
- type LegendListProps<ItemT = any> = LegendListPropsBase<ItemT, ComponentProps<typeof ScrollView>>;
414
451
  interface ThresholdSnapshot {
415
452
  scrollPosition: number;
416
453
  contentSize?: number;
@@ -490,7 +527,7 @@ interface InternalState {
490
527
  queuedCalculateItemsInView: number | undefined;
491
528
  queuedMVCPRecalculate?: number;
492
529
  queuedInitialLayout?: boolean | undefined;
493
- refScroller: React.RefObject<ScrollView>;
530
+ refScroller: React.RefObject<any>;
494
531
  scroll: number;
495
532
  scrollAdjustHandler: ScrollAdjustHandler;
496
533
  scrollForNextCalculateItemsInView: {
@@ -530,7 +567,7 @@ interface InternalState {
530
567
  viewabilityConfigCallbackPairs: ViewabilityConfigCallbackPairs<any> | undefined;
531
568
  props: {
532
569
  alignItemsAtEnd: boolean;
533
- animatedProps: StylesAsSharedValue<ScrollViewProps>;
570
+ animatedProps: StylesAsSharedValue<Record<string, any>>;
534
571
  alwaysRender: AlwaysRenderConfig | undefined;
535
572
  alwaysRenderIndicesArr: number[];
536
573
  alwaysRenderIndicesSet: Set<number>;
@@ -539,29 +576,31 @@ interface InternalState {
539
576
  dataVersion: Key | undefined;
540
577
  drawDistance: number;
541
578
  estimatedItemSize: number | undefined;
542
- getEstimatedItemSize: LegendListProps["getEstimatedItemSize"];
543
- getFixedItemSize: LegendListProps["getFixedItemSize"];
544
- getItemType: LegendListProps["getItemType"];
579
+ getEstimatedItemSize: LegendListPropsInternal["getEstimatedItemSize"];
580
+ getFixedItemSize: LegendListPropsInternal["getFixedItemSize"];
581
+ getItemType: LegendListPropsInternal["getItemType"];
545
582
  horizontal: boolean;
546
583
  initialContainerPoolRatio: number;
547
- itemsAreEqual: LegendListProps["itemsAreEqual"];
548
- keyExtractor: LegendListProps["keyExtractor"];
584
+ itemsAreEqual: LegendListPropsInternal["itemsAreEqual"];
585
+ keyExtractor: LegendListPropsInternal["keyExtractor"];
549
586
  maintainScrollAtEnd: boolean | MaintainScrollAtEndOptions;
550
587
  maintainScrollAtEndThreshold: number | undefined;
551
588
  maintainVisibleContentPosition: MaintainVisibleContentPositionNormalized;
552
589
  numColumns: number;
553
- onEndReached: LegendListProps["onEndReached"];
590
+ onEndReached: LegendListPropsInternal["onEndReached"];
554
591
  onEndReachedThreshold: number | null | undefined;
555
- onItemSizeChanged: LegendListProps["onItemSizeChanged"];
556
- onLoad: LegendListProps["onLoad"];
557
- onScroll: LegendListProps["onScroll"];
558
- onStartReached: LegendListProps["onStartReached"];
592
+ onItemSizeChanged: LegendListPropsInternal["onItemSizeChanged"];
593
+ onLoad: LegendListPropsInternal["onLoad"];
594
+ onScroll: LegendListPropsInternal["onScroll"];
595
+ onStartReached: LegendListPropsInternal["onStartReached"];
559
596
  onStartReachedThreshold: number | null | undefined;
560
- onStickyHeaderChange: LegendListProps["onStickyHeaderChange"];
561
- overrideItemLayout: LegendListProps["overrideItemLayout"];
597
+ onStickyHeaderChange: LegendListPropsInternal["onStickyHeaderChange"];
598
+ overrideItemLayout: LegendListPropsInternal["overrideItemLayout"];
562
599
  recycleItems: boolean;
563
- renderItem: LegendListProps["renderItem"];
600
+ renderItem: LegendListPropsInternal["renderItem"];
601
+ scrollBuffer?: number;
564
602
  snapToIndices: number[] | undefined;
603
+ stickyPositionComponentInternal: React.ComponentType<any> | undefined;
565
604
  stickyIndicesArr: number[];
566
605
  stickyIndicesSet: Set<number>;
567
606
  stylePaddingBottom: number | undefined;
@@ -583,11 +622,11 @@ interface LegendListRenderItemProps<ItemT, TItemType extends string | number | u
583
622
  item: ItemT;
584
623
  type: TItemType;
585
624
  }
586
- type LegendListState = {
625
+ type LegendListState$1 = {
587
626
  activeStickyIndex: number;
588
627
  contentLength: number;
589
628
  data: readonly any[];
590
- elementAtIndex: (index: number) => View | null | undefined;
629
+ elementAtIndex: (index: number) => any;
591
630
  end: number;
592
631
  endBuffered: number;
593
632
  isAtEnd: boolean;
@@ -604,7 +643,7 @@ type LegendListState = {
604
643
  start: number;
605
644
  startBuffered: number;
606
645
  };
607
- type LegendListRef = {
646
+ type LegendListRef$1 = {
608
647
  /**
609
648
  * Displays the scroll indicators momentarily.
610
649
  */
@@ -612,7 +651,7 @@ type LegendListRef = {
612
651
  /**
613
652
  * Returns the native ScrollView component reference.
614
653
  */
615
- getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
654
+ getNativeScrollRef(): any;
616
655
  /**
617
656
  * Returns the scroll responder instance for handling scroll events.
618
657
  */
@@ -620,11 +659,11 @@ type LegendListRef = {
620
659
  /**
621
660
  * Returns the ScrollResponderMixin for advanced scroll handling.
622
661
  */
623
- getScrollResponder(): ScrollResponderMixin;
662
+ getScrollResponder(): any;
624
663
  /**
625
664
  * Returns the internal state of the scroll virtualization.
626
665
  */
627
- getState(): LegendListState;
666
+ getState(): LegendListState$1;
628
667
  /**
629
668
  * Scrolls a specific index into view.
630
669
  * @param params - Parameters for scrolling.
@@ -704,6 +743,14 @@ type LegendListRef = {
704
743
  * @param enabled - If true, scroll processing is enabled.
705
744
  */
706
745
  setScrollProcessingEnabled(enabled: boolean): void;
746
+ /**
747
+ * Clears internal virtualization caches.
748
+ * @param options - Cache clearing options.
749
+ * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
750
+ */
751
+ clearCaches(options?: {
752
+ mode?: "sizes" | "full";
753
+ }): void;
707
754
  /**
708
755
  * Reports an externally measured content inset. Pass null/undefined to clear.
709
756
  * Values are merged on top of props/animated/native insets.
@@ -799,9 +846,23 @@ type GetRenderedItemResult<ItemT> = {
799
846
  };
800
847
  type GetRenderedItem = (key: string) => GetRenderedItemResult<any> | null;
801
848
 
802
- declare const LegendList: (<T>(props: LegendListProps<T> & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode) & {
803
- displayName?: string;
849
+ type LegendListPropsOverrides<ItemT, TItemType extends string | undefined> = Omit<LegendListPropsBase<ItemT, ScrollViewProps, TItemType>, "onScroll" | "refScrollView" | "renderScrollComponent" | "ListHeaderComponentStyle" | "ListFooterComponentStyle"> & {
850
+ onScroll?: (event: NativeSyntheticEvent$1<NativeScrollEvent$1>) => void;
851
+ refScrollView?: React.Ref<ScrollView>;
852
+ renderScrollComponent?: (props: ScrollViewProps) => ReactElement<ScrollViewProps>;
853
+ ListHeaderComponentStyle?: StyleProp$1<ViewStyle$1> | undefined;
854
+ ListFooterComponentStyle?: StyleProp$1<ViewStyle$1> | undefined;
855
+ };
856
+ type LegendListProps<ItemT = any, TItemType extends string | undefined = string | undefined> = LegendListPropsOverrides<ItemT, TItemType>;
857
+ type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
858
+ getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
859
+ getScrollResponder(): ScrollResponderMixin;
860
+ reportContentInset(inset?: Partial<Insets$1> | null): void;
804
861
  };
862
+ type LegendListState = Omit<LegendListState$1, "elementAtIndex"> & {
863
+ elementAtIndex: (index: number) => View | null | undefined;
864
+ };
865
+ type LegendListComponent = <ItemT = any>(props: LegendListProps<ItemT> & React.RefAttributes<LegendListRef>) => React.ReactElement | null;
805
866
 
806
867
  declare function useViewability<ItemT = any>(callback: ViewabilityCallback<ItemT>, configId?: string): void;
807
868
  declare function useViewabilityAmount<ItemT = any>(callback: ViewabilityAmountCallback<ItemT>): void;
@@ -814,4 +875,6 @@ declare function useListScrollSize(): {
814
875
  };
815
876
  declare function useSyncLayout(): () => void;
816
877
 
817
- export { type AlwaysRenderConfig, type ColumnWrapperStyle, type GetRenderedItem, type GetRenderedItemResult, type InitialScrollAnchor, type InternalState, LegendList, type LegendListMetrics, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListState, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type MaintainVisibleContentPositionNormalized, type OnViewableItemsChanged, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type ScrollTarget, type StickyHeaderConfig, type ThresholdSnapshot, 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, useSyncLayout, useViewability, useViewabilityAmount };
878
+ declare const LegendList: LegendListComponent;
879
+
880
+ export { type AlwaysRenderConfig, type BaseScrollViewProps, type ColumnWrapperStyle, type GetRenderedItem, type GetRenderedItemResult, type InitialScrollAnchor, type Insets, type InternalState, type LayoutRectangle, LegendList, type LegendListComponent, type LegendListMetrics, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListState, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type MaintainVisibleContentPositionNormalized, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type ScrollTarget, type StickyHeaderConfig, type StyleProp, type ThresholdSnapshot, type TypedForwardRef, type TypedMemo, type ViewAmountToken, type ViewStyle, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange, typedForwardRef, typedMemo, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };