@legendapp/list 3.0.6 → 3.1.1

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/react.d.ts CHANGED
@@ -31,8 +31,8 @@ interface MaintainVisibleContentPositionNormalized<ItemT = any> {
31
31
  shouldRestorePosition?: (item: ItemT, index: number, data: readonly ItemT[]) => boolean;
32
32
  }
33
33
 
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" | `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
38
  alignItemsAtEndPadding: number;
@@ -66,6 +66,7 @@ type ListenerTypeValueMap = {
66
66
  snapToOffsets: number[];
67
67
  stylePaddingTop: number;
68
68
  totalSize: number;
69
+ adaptiveRender: "normal" | "light";
69
70
  } & {
70
71
  [K in ListenerType as K extends `containerItemKey${number}` ? K : never]: string;
71
72
  } & {
@@ -113,6 +114,28 @@ interface NativeSyntheticEvent<T> {
113
114
  }
114
115
  type ViewStyle = Record<string, unknown>;
115
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
+ }
116
139
  type BaseScrollViewProps<TScrollView> = Omit<TScrollView, "contentOffset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children" | "onScroll">;
117
140
  interface DataModeProps<ItemT, TItemType extends string | undefined> {
118
141
  /**
@@ -321,6 +344,10 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
321
344
  * Called when list layout metrics change.
322
345
  */
323
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;
324
351
  /**
325
352
  * Function to call when the user pulls to refresh.
326
353
  */
@@ -456,6 +483,7 @@ interface AlwaysRenderConfig {
456
483
  }
457
484
  interface MaintainScrollAtEndOnOptions {
458
485
  dataChange?: boolean;
486
+ footerLayout?: boolean;
459
487
  itemLayout?: boolean;
460
488
  layout?: boolean;
461
489
  }
@@ -519,6 +547,14 @@ type LegendListState$1 = {
519
547
  startBuffered: number;
520
548
  };
521
549
  type LegendListRef$1 = {
550
+ /**
551
+ * Clears internal virtualization caches.
552
+ * @param options - Cache clearing options.
553
+ * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
554
+ */
555
+ clearCaches(options?: {
556
+ mode?: "sizes" | "full";
557
+ }): void;
522
558
  /**
523
559
  * Displays the scroll indicators momentarily.
524
560
  */
@@ -539,6 +575,11 @@ type LegendListRef$1 = {
539
575
  * Returns the internal state of the scroll virtualization.
540
576
  */
541
577
  getState(): LegendListState$1;
578
+ /**
579
+ * Reports an externally measured content inset. Pass null/undefined to clear.
580
+ * Values are merged on top of props/animated/native insets.
581
+ */
582
+ reportContentInset(inset?: Partial<Insets> | null): void;
542
583
  /**
543
584
  * Scrolls a specific index into view.
544
585
  * @param params - Parameters for scrolling.
@@ -605,29 +646,22 @@ type LegendListRef$1 = {
605
646
  animated?: boolean | undefined;
606
647
  }): Promise<void>;
607
648
  /**
608
- * Sets or adds to the offset of the visible content anchor.
609
- * @param value - The offset to set or add.
610
- * @param animated - If true, uses Animated to animate the change.
649
+ * Sets a measured item size and recalculates list positions as needed.
650
+ * @param itemKey - The key of the item whose size changed.
651
+ * @param size - The measured item size.
611
652
  */
612
- setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
653
+ setItemSize(itemKey: string, size: Pick<LayoutRectangle, "height" | "width">): void;
613
654
  /**
614
655
  * Sets whether scroll processing is enabled.
615
656
  * @param enabled - If true, scroll processing is enabled.
616
657
  */
617
658
  setScrollProcessingEnabled(enabled: boolean): void;
618
659
  /**
619
- * Clears internal virtualization caches.
620
- * @param options - Cache clearing options.
621
- * @param options.mode - `sizes` clears measurement caches. `full` also clears key/position caches.
622
- */
623
- clearCaches(options?: {
624
- mode?: "sizes" | "full";
625
- }): void;
626
- /**
627
- * Reports an externally measured content inset. Pass null/undefined to clear.
628
- * Values are merged on top of props/animated/native insets.
660
+ * Sets or adds to the offset of the visible content anchor.
661
+ * @param value - The offset to set or add.
662
+ * @param animated - If true, uses Animated to animate the change.
629
663
  */
630
- reportContentInset(inset?: Partial<Insets> | null): void;
664
+ setVisibleContentAnchorOffset(value: number | ((val: number) => number)): void;
631
665
  };
632
666
  interface ViewToken<ItemT = any> {
633
667
  containerId: number;
@@ -763,6 +797,8 @@ type LegendListState = Omit<LegendListState$1, "elementAtIndex"> & {
763
797
  };
764
798
  type LegendListComponent = <ItemT = any>(props: LegendListProps<ItemT> & RefAttributes<LegendListRef>) => ReactElement | null;
765
799
 
800
+ declare function useAdaptiveRender(): AdaptiveRender;
801
+ declare function useAdaptiveRenderChange(callback: (mode: AdaptiveRender) => void): void;
766
802
  declare function useViewability<ItemT = any>(callback: ViewabilityCallback<ItemT>, configId?: string): void;
767
803
  declare function useViewabilityAmount<ItemT = any>(callback: ViewabilityAmountCallback<ItemT>): void;
768
804
  declare function useRecyclingEffect(effect: (info: LegendListRecyclingState<unknown>) => void | (() => void)): void;
@@ -776,4 +812,4 @@ declare function useSyncLayout(): () => void;
776
812
 
777
813
  declare const LegendList: LegendListComponent;
778
814
 
779
- 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 };
815
+ 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 };