@legendapp/list 1.0.14 → 1.0.16

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,24 @@
1
+ ## 1.0.16
2
+ - Fix: isAtEnd was going to false when overscrolling
3
+ - Fix: refreshControl not being top padded correctly
4
+ - Fix: type of useLastItem hook
5
+ - Fix: header component was not displaying if a list had no data
6
+ - Fix: scrollToIndex logic that fixes scroll after items layout was not using viewPosition/viewOffset
7
+ - Fix: Improve scrollToIndex accuracy
8
+ - Fix: Improve scrollToEnd accuracy
9
+
10
+ ## 1.0.15
11
+ - Feat: Add a useIsLastItem hook
12
+ - Feat: Support horizontal lists without an intrinsic height, it takes the maximum height of list items
13
+ - Feat: Add onLoad prop
14
+ - Fix: maintainVisibleContentPosition not working on horizontal lists
15
+ - Perf: scrollForNextCalculateItemsInView was not taking drawDistance into account correctly
16
+ - Perf: Improved the algorithm for allocating containers to items
17
+ - Perf: Use useLayoutEffect in LegendList if available to get the outer ScrollView layout as soon as possible
18
+
19
+ ## 1.0.14
20
+ - Fix: A container changing size while inactive but not yet recycled could potentially overlap with elements onscreen if large enough
21
+
1
22
  ## 1.0.13
2
23
  - Fix: Missing React import in ListHeaderComponentContainer crashing some environments
3
24
  - Fix: `initialScrollIndex` was off by padding if using "padding" or "paddingVertical" props
package/animated.d.mts CHANGED
@@ -48,12 +48,15 @@ declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Om
48
48
  recycleItems?: boolean;
49
49
  refScrollView?: React.Ref<react_native.ScrollView>;
50
50
  refreshing?: boolean;
51
- renderItem?: ((props: _legendapp_list.LegendListRenderItemProps<T>) => React$1.ReactNode) | undefined;
51
+ renderItem?: React$1.ComponentType<_legendapp_list.LegendListRenderItemProps<T>> | ((props: _legendapp_list.LegendListRenderItemProps<T>) => React$1.ReactNode) | undefined;
52
52
  renderScrollComponent?: (props: react_native.ScrollViewProps) => React.ReactElement<react_native.ScrollViewProps>;
53
53
  suggestEstimatedItemSize?: boolean;
54
54
  viewabilityConfig?: _legendapp_list.ViewabilityConfig;
55
55
  viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
56
56
  waitForInitialLayout?: boolean;
57
+ onLoad?: (info: {
58
+ elapsedTimeInMs: number;
59
+ }) => void;
57
60
  } & React$1.RefAttributes<_legendapp_list.LegendListRef>) => React.ReactNode)>;
58
61
 
59
62
  export { AnimatedLegendList };
package/animated.d.ts CHANGED
@@ -48,12 +48,15 @@ declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Om
48
48
  recycleItems?: boolean;
49
49
  refScrollView?: React.Ref<react_native.ScrollView>;
50
50
  refreshing?: boolean;
51
- renderItem?: ((props: _legendapp_list.LegendListRenderItemProps<T>) => React$1.ReactNode) | undefined;
51
+ renderItem?: React$1.ComponentType<_legendapp_list.LegendListRenderItemProps<T>> | ((props: _legendapp_list.LegendListRenderItemProps<T>) => React$1.ReactNode) | undefined;
52
52
  renderScrollComponent?: (props: react_native.ScrollViewProps) => React.ReactElement<react_native.ScrollViewProps>;
53
53
  suggestEstimatedItemSize?: boolean;
54
54
  viewabilityConfig?: _legendapp_list.ViewabilityConfig;
55
55
  viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
56
56
  waitForInitialLayout?: boolean;
57
+ onLoad?: (info: {
58
+ elapsedTimeInMs: number;
59
+ }) => void;
57
60
  } & React$1.RefAttributes<_legendapp_list.LegendListRef>) => React.ReactNode)>;
58
61
 
59
62
  export { AnimatedLegendList };
package/index.d.mts CHANGED
@@ -180,10 +180,13 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
180
180
  */
181
181
  refreshing?: boolean;
182
182
  /**
183
- * Function to render each item in the list.
183
+ * Function or React component to render each item in the list.
184
+ * Can be either:
185
+ * - A function: (props: LegendListRenderItemProps<ItemT>) => ReactNode
186
+ * - A React component: React.ComponentType<LegendListRenderItemProps<ItemT>>
184
187
  * @required
185
188
  */
186
- renderItem?: (props: LegendListRenderItemProps<ItemT>) => ReactNode;
189
+ renderItem?: ((props: LegendListRenderItemProps<ItemT>) => ReactNode) | React.ComponentType<LegendListRenderItemProps<ItemT>>;
187
190
  /**
188
191
  * Render custom ScrollView component.
189
192
  * @default (props) => <ScrollView {...props} />
@@ -208,6 +211,9 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
208
211
  * @default false
209
212
  */
210
213
  waitForInitialLayout?: boolean;
214
+ onLoad?: (info: {
215
+ elapsedTimeInMs: number;
216
+ }) => void;
211
217
  };
212
218
  interface ColumnWrapperStyle {
213
219
  rowGap?: number;
@@ -234,8 +240,8 @@ interface InternalState {
234
240
  pendingAdjust: number;
235
241
  isStartReached: boolean;
236
242
  isEndReached: boolean;
237
- isAtBottom: boolean;
238
- isAtTop: boolean;
243
+ isAtEnd: boolean;
244
+ isAtStart: boolean;
239
245
  data: readonly any[];
240
246
  hasScrolled?: boolean;
241
247
  scrollLength: number;
@@ -259,7 +265,7 @@ interface InternalState {
259
265
  nativeMarginTop: number;
260
266
  indexByKey: Map<string, number>;
261
267
  viewabilityConfigCallbackPairs: ViewabilityConfigCallbackPairs | undefined;
262
- renderItem: (props: LegendListRenderItemProps<any>) => ReactNode;
268
+ renderItem: ((props: LegendListRenderItemProps<any>) => ReactNode) | React.ComponentType<LegendListRenderItemProps<any>>;
263
269
  scrollHistory: Array<{
264
270
  scroll: number;
265
271
  time: number;
@@ -278,8 +284,15 @@ interface InternalState {
278
284
  lastBatchingAction: number;
279
285
  ignoreScrollFromCalcTotal?: boolean;
280
286
  disableScrollJumpsFrom?: number;
281
- scrollingToOffset?: number | undefined;
287
+ scrollingTo?: {
288
+ offset: number;
289
+ index?: number;
290
+ viewOffset?: number;
291
+ viewPosition?: number;
292
+ animated?: boolean;
293
+ } | undefined;
282
294
  previousTotalSize?: number;
295
+ needsOtherAxisSize?: boolean;
283
296
  averageSizes: Record<string, {
284
297
  num: number;
285
298
  avg: number;
@@ -509,17 +522,21 @@ declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "sc
509
522
  recycleItems?: boolean;
510
523
  refScrollView?: React$1.Ref<ScrollView>;
511
524
  refreshing?: boolean;
512
- renderItem?: ((props: LegendListRenderItemProps<T>) => React$1.ReactNode) | undefined;
525
+ renderItem?: React$1.ComponentType<LegendListRenderItemProps<T>> | ((props: LegendListRenderItemProps<T>) => React$1.ReactNode) | undefined;
513
526
  renderScrollComponent?: (props: react_native.ScrollViewProps) => React$1.ReactElement<react_native.ScrollViewProps>;
514
527
  suggestEstimatedItemSize?: boolean;
515
528
  viewabilityConfig?: ViewabilityConfig;
516
529
  viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs | undefined;
517
530
  waitForInitialLayout?: boolean;
531
+ onLoad?: (info: {
532
+ elapsedTimeInMs: number;
533
+ }) => void;
518
534
  } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode;
519
535
 
520
536
  declare function useViewability(callback: ViewabilityCallback, configId?: string): void;
521
537
  declare function useViewabilityAmount(callback: ViewabilityAmountCallback): void;
522
538
  declare function useRecyclingEffect(effect: (info: LegendListRecyclingState<unknown>) => void | (() => void)): void;
523
539
  declare function useRecyclingState<ItemT>(valueOrFun: ((info: LegendListRecyclingState<ItemT>) => ItemT) | ItemT): readonly [ItemT | null, Dispatch<SetStateAction<ItemT>>];
540
+ declare function useIsLastItem(): boolean;
524
541
 
525
- 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, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };
542
+ 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, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };
package/index.d.ts CHANGED
@@ -180,10 +180,13 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
180
180
  */
181
181
  refreshing?: boolean;
182
182
  /**
183
- * Function to render each item in the list.
183
+ * Function or React component to render each item in the list.
184
+ * Can be either:
185
+ * - A function: (props: LegendListRenderItemProps<ItemT>) => ReactNode
186
+ * - A React component: React.ComponentType<LegendListRenderItemProps<ItemT>>
184
187
  * @required
185
188
  */
186
- renderItem?: (props: LegendListRenderItemProps<ItemT>) => ReactNode;
189
+ renderItem?: ((props: LegendListRenderItemProps<ItemT>) => ReactNode) | React.ComponentType<LegendListRenderItemProps<ItemT>>;
187
190
  /**
188
191
  * Render custom ScrollView component.
189
192
  * @default (props) => <ScrollView {...props} />
@@ -208,6 +211,9 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
208
211
  * @default false
209
212
  */
210
213
  waitForInitialLayout?: boolean;
214
+ onLoad?: (info: {
215
+ elapsedTimeInMs: number;
216
+ }) => void;
211
217
  };
212
218
  interface ColumnWrapperStyle {
213
219
  rowGap?: number;
@@ -234,8 +240,8 @@ interface InternalState {
234
240
  pendingAdjust: number;
235
241
  isStartReached: boolean;
236
242
  isEndReached: boolean;
237
- isAtBottom: boolean;
238
- isAtTop: boolean;
243
+ isAtEnd: boolean;
244
+ isAtStart: boolean;
239
245
  data: readonly any[];
240
246
  hasScrolled?: boolean;
241
247
  scrollLength: number;
@@ -259,7 +265,7 @@ interface InternalState {
259
265
  nativeMarginTop: number;
260
266
  indexByKey: Map<string, number>;
261
267
  viewabilityConfigCallbackPairs: ViewabilityConfigCallbackPairs | undefined;
262
- renderItem: (props: LegendListRenderItemProps<any>) => ReactNode;
268
+ renderItem: ((props: LegendListRenderItemProps<any>) => ReactNode) | React.ComponentType<LegendListRenderItemProps<any>>;
263
269
  scrollHistory: Array<{
264
270
  scroll: number;
265
271
  time: number;
@@ -278,8 +284,15 @@ interface InternalState {
278
284
  lastBatchingAction: number;
279
285
  ignoreScrollFromCalcTotal?: boolean;
280
286
  disableScrollJumpsFrom?: number;
281
- scrollingToOffset?: number | undefined;
287
+ scrollingTo?: {
288
+ offset: number;
289
+ index?: number;
290
+ viewOffset?: number;
291
+ viewPosition?: number;
292
+ animated?: boolean;
293
+ } | undefined;
282
294
  previousTotalSize?: number;
295
+ needsOtherAxisSize?: boolean;
283
296
  averageSizes: Record<string, {
284
297
  num: number;
285
298
  avg: number;
@@ -509,17 +522,21 @@ declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "sc
509
522
  recycleItems?: boolean;
510
523
  refScrollView?: React$1.Ref<ScrollView>;
511
524
  refreshing?: boolean;
512
- renderItem?: ((props: LegendListRenderItemProps<T>) => React$1.ReactNode) | undefined;
525
+ renderItem?: React$1.ComponentType<LegendListRenderItemProps<T>> | ((props: LegendListRenderItemProps<T>) => React$1.ReactNode) | undefined;
513
526
  renderScrollComponent?: (props: react_native.ScrollViewProps) => React$1.ReactElement<react_native.ScrollViewProps>;
514
527
  suggestEstimatedItemSize?: boolean;
515
528
  viewabilityConfig?: ViewabilityConfig;
516
529
  viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs | undefined;
517
530
  waitForInitialLayout?: boolean;
531
+ onLoad?: (info: {
532
+ elapsedTimeInMs: number;
533
+ }) => void;
518
534
  } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode;
519
535
 
520
536
  declare function useViewability(callback: ViewabilityCallback, configId?: string): void;
521
537
  declare function useViewabilityAmount(callback: ViewabilityAmountCallback): void;
522
538
  declare function useRecyclingEffect(effect: (info: LegendListRecyclingState<unknown>) => void | (() => void)): void;
523
539
  declare function useRecyclingState<ItemT>(valueOrFun: ((info: LegendListRecyclingState<ItemT>) => ItemT) | ItemT): readonly [ItemT | null, Dispatch<SetStateAction<ItemT>>];
540
+ declare function useIsLastItem(): boolean;
524
541
 
525
- 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, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };
542
+ 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, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };