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

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.
@@ -230,6 +230,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
230
230
  * - true enables both behaviors; false disables both.
231
231
  */
232
232
  maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig<ItemT>;
233
+ /**
234
+ * Web only: when true, listens to window/body scrolling instead of rendering a scrollable list container.
235
+ * @default false
236
+ */
237
+ useWindowScroll?: boolean;
233
238
  /**
234
239
  * Number of columns to render items in.
235
240
  * @default 1
@@ -418,7 +423,7 @@ type LegendListState = {
418
423
  listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
419
424
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
420
425
  positionAtIndex: (index: number) => number;
421
- positions: Map<string, number>;
426
+ positionByKey: (key: string) => number | undefined;
422
427
  scroll: number;
423
428
  scrollLength: number;
424
429
  scrollVelocity: number;
@@ -457,7 +462,7 @@ type LegendListRef$1 = {
457
462
  scrollIndexIntoView(params: {
458
463
  animated?: boolean | undefined;
459
464
  index: number;
460
- }): void;
465
+ }): Promise<void>;
461
466
  /**
462
467
  * Scrolls a specific index into view.
463
468
  * @param params - Parameters for scrolling.
@@ -467,7 +472,7 @@ type LegendListRef$1 = {
467
472
  scrollItemIntoView(params: {
468
473
  animated?: boolean | undefined;
469
474
  item: any;
470
- }): void;
475
+ }): Promise<void>;
471
476
  /**
472
477
  * Scrolls to the end of the list.
473
478
  * @param options - Options for scrolling.
@@ -477,7 +482,7 @@ type LegendListRef$1 = {
477
482
  scrollToEnd(options?: {
478
483
  animated?: boolean | undefined;
479
484
  viewOffset?: number | undefined;
480
- }): void;
485
+ }): Promise<void>;
481
486
  /**
482
487
  * Scrolls to a specific index in the list.
483
488
  * @param params - Parameters for scrolling.
@@ -491,7 +496,7 @@ type LegendListRef$1 = {
491
496
  index: number;
492
497
  viewOffset?: number | undefined;
493
498
  viewPosition?: number | undefined;
494
- }): void;
499
+ }): Promise<void>;
495
500
  /**
496
501
  * Scrolls to a specific item in the list.
497
502
  * @param params - Parameters for scrolling.
@@ -505,7 +510,7 @@ type LegendListRef$1 = {
505
510
  item: any;
506
511
  viewOffset?: number | undefined;
507
512
  viewPosition?: number | undefined;
508
- }): void;
513
+ }): Promise<void>;
509
514
  /**
510
515
  * Scrolls to a specific offset in pixels.
511
516
  * @param params - Parameters for scrolling.
@@ -515,7 +520,7 @@ type LegendListRef$1 = {
515
520
  scrollToOffset(params: {
516
521
  offset: number;
517
522
  animated?: boolean | undefined;
518
- }): void;
523
+ }): Promise<void>;
519
524
  /**
520
525
  * Sets or adds to the offset of the visible content anchor.
521
526
  * @param value - The offset to set or add.
package/keyboard.d.ts CHANGED
@@ -68,7 +68,7 @@ type LegendListState = {
68
68
  listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
69
69
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
70
70
  positionAtIndex: (index: number) => number;
71
- positions: Map<string, number>;
71
+ positionByKey: (key: string) => number | undefined;
72
72
  scroll: number;
73
73
  scrollLength: number;
74
74
  scrollVelocity: number;
@@ -107,7 +107,7 @@ type LegendListRef$1 = {
107
107
  scrollIndexIntoView(params: {
108
108
  animated?: boolean | undefined;
109
109
  index: number;
110
- }): void;
110
+ }): Promise<void>;
111
111
  /**
112
112
  * Scrolls a specific index into view.
113
113
  * @param params - Parameters for scrolling.
@@ -117,7 +117,7 @@ type LegendListRef$1 = {
117
117
  scrollItemIntoView(params: {
118
118
  animated?: boolean | undefined;
119
119
  item: any;
120
- }): void;
120
+ }): Promise<void>;
121
121
  /**
122
122
  * Scrolls to the end of the list.
123
123
  * @param options - Options for scrolling.
@@ -127,7 +127,7 @@ type LegendListRef$1 = {
127
127
  scrollToEnd(options?: {
128
128
  animated?: boolean | undefined;
129
129
  viewOffset?: number | undefined;
130
- }): void;
130
+ }): Promise<void>;
131
131
  /**
132
132
  * Scrolls to a specific index in the list.
133
133
  * @param params - Parameters for scrolling.
@@ -141,7 +141,7 @@ type LegendListRef$1 = {
141
141
  index: number;
142
142
  viewOffset?: number | undefined;
143
143
  viewPosition?: number | undefined;
144
- }): void;
144
+ }): Promise<void>;
145
145
  /**
146
146
  * Scrolls to a specific item in the list.
147
147
  * @param params - Parameters for scrolling.
@@ -155,7 +155,7 @@ type LegendListRef$1 = {
155
155
  item: any;
156
156
  viewOffset?: number | undefined;
157
157
  viewPosition?: number | undefined;
158
- }): void;
158
+ }): Promise<void>;
159
159
  /**
160
160
  * Scrolls to a specific offset in pixels.
161
161
  * @param params - Parameters for scrolling.
@@ -165,7 +165,7 @@ type LegendListRef$1 = {
165
165
  scrollToOffset(params: {
166
166
  offset: number;
167
167
  animated?: boolean | undefined;
168
- }): void;
168
+ }): Promise<void>;
169
169
  /**
170
170
  * Sets or adds to the offset of the visible content anchor.
171
171
  * @param value - The offset to set or add.
package/keyboard.js CHANGED
@@ -49,6 +49,7 @@ var useCombinedRef = (...refs) => {
49
49
  }, refs);
50
50
  return callback;
51
51
  };
52
+ var typedForwardRef = React.forwardRef;
52
53
 
53
54
  // src/integrations/keyboard.tsx
54
55
  var clampProgress = (progress) => {
@@ -74,7 +75,7 @@ var calculateKeyboardTargetOffset = (startOffset, keyboardHeight, isOpening, pro
74
75
  const delta = (isOpening ? keyboardHeight : -keyboardHeight) * normalizedProgress;
75
76
  return Math.max(0, startOffset + delta);
76
77
  };
77
- var KeyboardAvoidingLegendList = React.forwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
78
+ var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
78
79
  const {
79
80
  contentContainerStyle: contentContainerStyleProp,
80
81
  contentInset: contentInsetProp,
package/keyboard.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { forwardRef, useRef, useState, useMemo, useCallback, useEffect } from 'react';
2
+ import { useRef, useState, useMemo, useCallback, useEffect, forwardRef } from 'react';
3
3
  import { StyleSheet, Platform } from 'react-native';
4
4
  import { useKeyboardHandler } from 'react-native-keyboard-controller';
5
5
  import { useAnimatedRef, useSharedValue, isWorkletFunction, useAnimatedScrollHandler, runOnJS, useComposedEventHandler, useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
@@ -28,6 +28,7 @@ var useCombinedRef = (...refs) => {
28
28
  }, refs);
29
29
  return callback;
30
30
  };
31
+ var typedForwardRef = forwardRef;
31
32
 
32
33
  // src/integrations/keyboard.tsx
33
34
  var clampProgress = (progress) => {
@@ -53,7 +54,7 @@ var calculateKeyboardTargetOffset = (startOffset, keyboardHeight, isOpening, pro
53
54
  const delta = (isOpening ? keyboardHeight : -keyboardHeight) * normalizedProgress;
54
55
  return Math.max(0, startOffset + delta);
55
56
  };
56
- var KeyboardAvoidingLegendList = forwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
57
+ var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegendList2(props, forwardedRef) {
57
58
  const {
58
59
  contentContainerStyle: contentContainerStyleProp,
59
60
  contentInset: contentInsetProp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "3.0.0-beta.33",
3
+ "version": "3.0.0-beta.35",
4
4
  "description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,
@@ -41,10 +41,10 @@
41
41
  "default": "./reanimated.js"
42
42
  },
43
43
  "./react-native": {
44
- "types": "./list-react-native.d.ts",
45
- "import": "./list-react-native.mjs",
46
- "require": "./list-react-native.js",
47
- "default": "./list-react-native.js"
44
+ "types": "./react-native.d.ts",
45
+ "import": "./react-native.mjs",
46
+ "require": "./react-native.js",
47
+ "default": "./react-native.js"
48
48
  },
49
49
  "./section-list": {
50
50
  "types": "./section-list.d.ts",
@@ -53,10 +53,10 @@
53
53
  "default": "./section-list.js"
54
54
  },
55
55
  "./react": {
56
- "types": "./list-react.d.ts",
57
- "import": "./list-react.mjs",
58
- "require": "./list-react.js",
59
- "default": "./list-react.js"
56
+ "types": "./react.d.ts",
57
+ "import": "./react.mjs",
58
+ "require": "./react.js",
59
+ "default": "./react.js"
60
60
  }
61
61
  },
62
62
  "files": [
@@ -122,6 +122,29 @@ interface NativeSyntheticEvent<T> {
122
122
  }
123
123
  type ViewStyle = Record<string, unknown>;
124
124
  type StyleProp<T> = T | T[] | null | undefined | false;
125
+ interface ScrollEventTargetLike {
126
+ addEventListener(type: string, listener: (...args: any[]) => void): void;
127
+ removeEventListener(type: string, listener: (...args: any[]) => void): void;
128
+ }
129
+ interface ScrollableNodeLike {
130
+ scrollLeft?: number;
131
+ scrollTop?: number;
132
+ }
133
+ interface LegendListScrollerRef {
134
+ flashScrollIndicators(): void;
135
+ getCurrentScrollOffset?(): number;
136
+ getScrollEventTarget(): ScrollEventTargetLike | null;
137
+ getScrollableNode(): ScrollableNodeLike | null;
138
+ getScrollResponder(): unknown;
139
+ scrollTo(options: {
140
+ animated?: boolean;
141
+ x?: number;
142
+ y?: number;
143
+ }): void;
144
+ scrollToEnd(options?: {
145
+ animated?: boolean;
146
+ }): void;
147
+ }
125
148
  type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
126
149
  interface DataModeProps<ItemT, TItemType extends string | undefined> {
127
150
  /**
@@ -278,6 +301,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
278
301
  * - true enables both behaviors; false disables both.
279
302
  */
280
303
  maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig<ItemT>;
304
+ /**
305
+ * Web only: when true, listens to window/body scrolling instead of rendering a scrollable list container.
306
+ * @default false
307
+ */
308
+ useWindowScroll?: boolean;
281
309
  /**
282
310
  * Number of columns to render items in.
283
311
  * @default 1
@@ -472,10 +500,11 @@ interface InternalState {
472
500
  num: number;
473
501
  avg: number;
474
502
  }>;
475
- columns: Map<string, number>;
476
- columnSpans: Map<string, number>;
503
+ columns: Array<number | undefined>;
504
+ columnSpans: Array<number | undefined>;
477
505
  containerItemKeys: Map<string, number>;
478
506
  containerItemTypes: Map<number, string>;
507
+ dataChangeEpoch: number;
479
508
  dataChangeNeedsScrollUpdate: boolean;
480
509
  didColumnsChange?: boolean;
481
510
  didDataChange?: boolean;
@@ -522,12 +551,13 @@ interface InternalState {
522
551
  needsOtherAxisSize?: boolean;
523
552
  otherAxisSize?: number;
524
553
  pendingTotalSize?: number;
525
- positions: Map<string, number>;
554
+ pendingScrollResolve?: (() => void) | undefined;
555
+ positions: Array<number | undefined>;
526
556
  previousData?: readonly unknown[];
527
557
  queuedCalculateItemsInView: number | undefined;
528
558
  queuedMVCPRecalculate?: number;
529
559
  queuedInitialLayout?: boolean | undefined;
530
- refScroller: React.RefObject<any>;
560
+ refScroller: React.RefObject<LegendListScrollerRef | null>;
531
561
  scroll: number;
532
562
  scrollAdjustHandler: ScrollAdjustHandler;
533
563
  scrollForNextCalculateItemsInView: {
@@ -551,6 +581,7 @@ interface InternalState {
551
581
  startBuffered: number;
552
582
  startBufferedId?: string;
553
583
  startNoBuffer: number;
584
+ startReachedSnapshotDataChangeEpoch: number | undefined;
554
585
  startReachedSnapshot: ThresholdSnapshot | undefined;
555
586
  stickyContainerPool: Set<number>;
556
587
  stickyContainers: Map<number, number>;
@@ -600,12 +631,14 @@ interface InternalState {
600
631
  renderItem: LegendListPropsInternal["renderItem"];
601
632
  scrollBuffer?: number;
602
633
  snapToIndices: number[] | undefined;
634
+ positionComponentInternal: React.ComponentType<any> | undefined;
603
635
  stickyPositionComponentInternal: React.ComponentType<any> | undefined;
604
636
  stickyIndicesArr: number[];
605
637
  stickyIndicesSet: Set<number>;
606
638
  stylePaddingBottom: number | undefined;
607
639
  stylePaddingTop: number | undefined;
608
640
  suggestEstimatedItemSize: boolean;
641
+ useWindowScroll: boolean;
609
642
  };
610
643
  }
611
644
  interface ViewableRange<T> {
@@ -634,7 +667,7 @@ type LegendListState$1 = {
634
667
  listen: <T extends LegendListListenerType>(listenerType: T, callback: (value: ListenerTypeValueMap[T]) => void) => () => void;
635
668
  listenToPosition: (key: string, callback: (value: number) => void) => () => void;
636
669
  positionAtIndex: (index: number) => number;
637
- positions: Map<string, number>;
670
+ positionByKey: (key: string) => number | undefined;
638
671
  scroll: number;
639
672
  scrollLength: number;
640
673
  scrollVelocity: number;
@@ -673,7 +706,7 @@ type LegendListRef$1 = {
673
706
  scrollIndexIntoView(params: {
674
707
  animated?: boolean | undefined;
675
708
  index: number;
676
- }): void;
709
+ }): Promise<void>;
677
710
  /**
678
711
  * Scrolls a specific index into view.
679
712
  * @param params - Parameters for scrolling.
@@ -683,7 +716,7 @@ type LegendListRef$1 = {
683
716
  scrollItemIntoView(params: {
684
717
  animated?: boolean | undefined;
685
718
  item: any;
686
- }): void;
719
+ }): Promise<void>;
687
720
  /**
688
721
  * Scrolls to the end of the list.
689
722
  * @param options - Options for scrolling.
@@ -693,7 +726,7 @@ type LegendListRef$1 = {
693
726
  scrollToEnd(options?: {
694
727
  animated?: boolean | undefined;
695
728
  viewOffset?: number | undefined;
696
- }): void;
729
+ }): Promise<void>;
697
730
  /**
698
731
  * Scrolls to a specific index in the list.
699
732
  * @param params - Parameters for scrolling.
@@ -707,7 +740,7 @@ type LegendListRef$1 = {
707
740
  index: number;
708
741
  viewOffset?: number | undefined;
709
742
  viewPosition?: number | undefined;
710
- }): void;
743
+ }): Promise<void>;
711
744
  /**
712
745
  * Scrolls to a specific item in the list.
713
746
  * @param params - Parameters for scrolling.
@@ -721,7 +754,7 @@ type LegendListRef$1 = {
721
754
  item: any;
722
755
  viewOffset?: number | undefined;
723
756
  viewPosition?: number | undefined;
724
- }): void;
757
+ }): Promise<void>;
725
758
  /**
726
759
  * Scrolls to a specific offset in pixels.
727
760
  * @param params - Parameters for scrolling.
@@ -731,7 +764,7 @@ type LegendListRef$1 = {
731
764
  scrollToOffset(params: {
732
765
  offset: number;
733
766
  animated?: boolean | undefined;
734
- }): void;
767
+ }): Promise<void>;
735
768
  /**
736
769
  * Sets or adds to the offset of the visible content anchor.
737
770
  * @param value - The offset to set or add.
@@ -877,4 +910,4 @@ declare function useSyncLayout(): () => void;
877
910
 
878
911
  declare const LegendList: LegendListComponent;
879
912
 
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 };
913
+ 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 LegendListScrollerRef, type LegendListState, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type MaintainVisibleContentPositionNormalized, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type ScrollEventTargetLike, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type ScrollTarget, type ScrollableNodeLike, 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 };