@legendapp/list 3.0.5 → 3.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.
@@ -31,10 +31,11 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
31
31
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
32
32
  }
33
33
 
34
- type ListenerType = "activeStickyIndex" | "anchoredEndSpaceSize" | "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" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
35
- type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
34
+ type ListenerType = "activeStickyIndex" | "alignItemsAtEndPadding" | "anchoredEndSpaceSize" | "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}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
35
+ type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "anchoredEndSpaceSize" | "footerSize" | "headerSize" | "isAtEnd" | "isAtStart" | "isNearEnd" | "isNearStart" | "isWithinMaintainScrollAtEndThreshold" | "adaptiveRender" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
36
36
  type ListenerTypeValueMap = {
37
37
  activeStickyIndex: number;
38
+ alignItemsAtEndPadding: number;
38
39
  anchoredEndSpaceSize: number;
39
40
  animatedScrollY: any;
40
41
  debugComputedScroll: number;
@@ -65,6 +66,7 @@ type ListenerTypeValueMap = {
65
66
  snapToOffsets: number[];
66
67
  stylePaddingTop: number;
67
68
  totalSize: number;
69
+ adaptiveRender: "normal" | "light";
68
70
  } & {
69
71
  [K in ListenerType as K extends `containerItemKey${number}` ? K : never]: string;
70
72
  } & {
@@ -112,6 +114,28 @@ interface NativeSyntheticEvent<T> {
112
114
  }
113
115
  type ViewStyle = Record<string, unknown>;
114
116
  type StyleProp<T> = T | T[] | null | undefined | false;
117
+ type AdaptiveRender = "normal" | "light";
118
+ interface AdaptiveRenderConfig {
119
+ /**
120
+ * Scroll velocity in pixels per millisecond above which items should switch to light mode.
121
+ * @default 4
122
+ */
123
+ enterVelocity?: number;
124
+ /**
125
+ * Scroll velocity in pixels per millisecond below which items can return to normal mode.
126
+ * @default 1
127
+ */
128
+ exitVelocity?: number;
129
+ /**
130
+ * Time to wait without velocity above exitVelocity before returning to normal mode.
131
+ * @default 1000
132
+ */
133
+ exitDelay?: number;
134
+ /**
135
+ * Called when the list-level adaptive render changes.
136
+ */
137
+ onChange?: (mode: AdaptiveRender) => void;
138
+ }
115
139
  type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
116
140
  interface DataModeProps<ItemT, TItemType extends string | undefined> {
117
141
  /**
@@ -320,6 +344,10 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
320
344
  * Called when list layout metrics change.
321
345
  */
322
346
  onMetricsChange?: (metrics: LegendListMetrics) => void;
347
+ /**
348
+ * Configures the adaptive render signal. Items can use this to render a lighter version while scrolling quickly.
349
+ */
350
+ experimental_adaptiveRender?: AdaptiveRenderConfig;
323
351
  /**
324
352
  * Function to call when the user pulls to refresh.
325
353
  */
@@ -518,6 +546,14 @@ type LegendListState$1 = {
518
546
  startBuffered: number;
519
547
  };
520
548
  type LegendListRef$1 = {
549
+ /**
550
+ * Clears internal virtualization caches.
551
+ * @param options - Cache clearing options.
552
+ * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
553
+ */
554
+ clearCaches(options?: {
555
+ mode?: "sizes" | "full";
556
+ }): void;
521
557
  /**
522
558
  * Displays the scroll indicators momentarily.
523
559
  */
@@ -538,6 +574,11 @@ type LegendListRef$1 = {
538
574
  * Returns the internal state of the scroll virtualization.
539
575
  */
540
576
  getState(): LegendListState$1;
577
+ /**
578
+ * Reports an externally measured content inset. Pass null/undefined to clear.
579
+ * Values are merged on top of props/animated/native insets.
580
+ */
581
+ reportContentInset(inset?: Partial<Insets> | null): void;
541
582
  /**
542
583
  * Scrolls a specific index into view.
543
584
  * @param params - Parameters for scrolling.
@@ -604,29 +645,22 @@ type LegendListRef$1 = {
604
645
  animated?: boolean | undefined;
605
646
  }): Promise<void>;
606
647
  /**
607
- * Sets or adds to the offset of the visible content anchor.
608
- * @param value - The offset to set or add.
609
- * @param animated - If true, uses Animated to animate the change.
648
+ * Sets a measured item size and recalculates list positions as needed.
649
+ * @param itemKey - The key of the item whose size changed.
650
+ * @param size - The measured item size.
610
651
  */
611
- setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
652
+ setItemSize(itemKey: string, size: Pick<LayoutRectangle, "height" | "width">): void;
612
653
  /**
613
654
  * Sets whether scroll processing is enabled.
614
655
  * @param enabled - If true, scroll processing is enabled.
615
656
  */
616
657
  setScrollProcessingEnabled(enabled: boolean): void;
617
658
  /**
618
- * Clears internal virtualization caches.
619
- * @param options - Cache clearing options.
620
- * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
621
- */
622
- clearCaches(options?: {
623
- mode?: "sizes" | "full";
624
- }): void;
625
- /**
626
- * Reports an externally measured content inset. Pass null/undefined to clear.
627
- * Values are merged on top of props/animated/native insets.
659
+ * Sets or adds to the offset of the visible content anchor.
660
+ * @param value - The offset to set or add.
661
+ * @param animated - If true, uses Animated to animate the change.
628
662
  */
629
- reportContentInset(inset?: Partial<Insets> | null): void;
663
+ setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
630
664
  };
631
665
  interface ViewToken<ItemT = any> {
632
666
  containerId: number;
@@ -762,6 +796,8 @@ type LegendListState = Omit<LegendListState$1, "elementAtIndex"> & {
762
796
  };
763
797
  type LegendListComponent = <ItemT = any>(props: LegendListProps<ItemT> & RefAttributes<LegendListRef>) => ReactElement | null;
764
798
 
799
+ declare function useAdaptiveRender(): AdaptiveRender;
800
+ declare function useAdaptiveRenderChange(callback: (mode: AdaptiveRender) => void): void;
765
801
  declare function useViewability<ItemT = any>(callback: ViewabilityCallback<ItemT>, configId?: string): void;
766
802
  declare function useViewabilityAmount<ItemT = any>(callback: ViewabilityAmountCallback<ItemT>): void;
767
803
  declare function useRecyclingEffect(effect: (info: LegendListRecyclingState<unknown>) => void | (() => void)): void;
@@ -775,4 +811,4 @@ declare function useSyncLayout(): () => void;
775
811
 
776
812
  declare const LegendList: LegendListComponent;
777
813
 
778
- export { type AlwaysRenderConfig, type AnchoredEndSpaceConfig, type ColumnWrapperStyle, type Insets, type LayoutRectangle, LegendList, type LegendListAverageItemSize, type LegendListComponent, type LegendListMetrics, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListState, type MaintainScrollAtEndOnOptions, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type OnViewableItemsChangedInfo, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type StickyHeaderConfig, type StyleProp, type ViewAmountToken, type ViewStyle, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
814
+ export { type AdaptiveRender, type AdaptiveRenderConfig, type AlwaysRenderConfig, type AnchoredEndSpaceConfig, type ColumnWrapperStyle, type Insets, type LayoutRectangle, LegendList, type LegendListAverageItemSize, type LegendListComponent, type LegendListMetrics, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type LegendListState, type MaintainScrollAtEndOnOptions, type MaintainScrollAtEndOptions, type MaintainVisibleContentPositionConfig, type NativeScrollEvent, type NativeSyntheticEvent, type OnViewableItemsChanged, type OnViewableItemsChangedInfo, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type StickyHeaderConfig, type StyleProp, type ViewAmountToken, type ViewStyle, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, useAdaptiveRender, useAdaptiveRenderChange, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };