@legendapp/list 2.0.0-next.11 → 2.0.0-next.13

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/animated.d.mts CHANGED
@@ -3,7 +3,7 @@ import * as _legendapp_list from '@legendapp/list';
3
3
  import * as react_native from 'react-native';
4
4
  import { Animated } from 'react-native';
5
5
 
6
- declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
6
+ declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "removeClippedSubviews" | "stickyHeaderIndices" | "children" | "contentInset" | "contentOffset" | "maintainVisibleContentPosition"> & {
7
7
  alignItemsAtEnd?: boolean;
8
8
  columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
9
9
  data: readonly T[];
package/animated.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as _legendapp_list from '@legendapp/list';
3
3
  import * as react_native from 'react-native';
4
4
  import { Animated } from 'react-native';
5
5
 
6
- declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
6
+ declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "removeClippedSubviews" | "stickyHeaderIndices" | "children" | "contentInset" | "contentOffset" | "maintainVisibleContentPosition"> & {
7
7
  alignItemsAtEnd?: boolean;
8
8
  columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
9
9
  data: readonly T[];
package/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import * as _legendapp_list_reanimated from '@legendapp/list/reanimated';
2
1
  import * as React$1 from 'react';
3
2
  import { ComponentProps, ReactNode, Dispatch, SetStateAction } from 'react';
4
3
  import * as react_native from 'react-native';
5
4
  import { View, Animated, ScrollView, StyleProp, ViewStyle, ScrollViewProps, LayoutRectangle, ScrollViewComponent, ScrollResponderMixin } from 'react-native';
6
5
  import Animated$1 from 'react-native-reanimated';
6
+ import * as _legendapp_list_reanimated from '@legendapp/list/reanimated';
7
7
 
8
8
  type ListenerType = "numContainers" | "numContainersPooled" | `containerItemKey${number}` | `containerItemData${number}` | `containerPosition${number}` | `containerColumn${number}` | `containerSticky${number}` | `containerStickyOffset${number}` | "containersDidLayout" | "extraData" | "numColumns" | "lastItemKeys" | "totalSize" | "alignItemsPaddingTop" | "stylePaddingTop" | "scrollAdjust" | "scrollAdjustUserOffset" | "headerSize" | "footerSize" | "maintainVisibleContentPosition" | "debugRawScroll" | "debugComputedScroll" | "otherAxisSize" | "snapToOffsets" | "scrollSize";
9
9
  interface StateContext {
@@ -391,17 +391,19 @@ interface LegendListRenderItemProps<ItemT, TItemType extends string | number | u
391
391
  }
392
392
  type ScrollState = {
393
393
  contentLength: number;
394
+ data: readonly any[];
394
395
  end: number;
395
396
  endBuffered: number;
396
397
  isAtEnd: boolean;
397
398
  isAtStart: boolean;
399
+ positionAtIndex: (index: number) => number;
398
400
  positions: Map<string, number>;
399
401
  scroll: number;
400
402
  scrollLength: number;
403
+ sizeAtIndex: (index: number) => number;
404
+ sizes: Map<string, number>;
401
405
  start: number;
402
406
  startBuffered: number;
403
- sizes: Map<string, number>;
404
- sizeAtIndex: (index: number) => number;
405
407
  };
406
408
  type LegendListRef = {
407
409
  /**
@@ -581,7 +583,9 @@ interface LazyLegendListProps<ItemT, ListT> extends Omit<LegendListProps<ItemT>,
581
583
  children?: React$1.ReactNode | undefined;
582
584
  LegendList?: ListT;
583
585
  }
584
- declare const LazyLegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
586
+ declare const LazyLegendList: <ItemT, ListT extends (<ItemT_1>(props: _legendapp_list_reanimated.AnimatedLegendListProps<ItemT_1> & {
587
+ ref?: React$1.Ref<LegendListRef>;
588
+ }) => React$1.ReactElement | null) | (<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "removeClippedSubviews" | "stickyHeaderIndices" | "children" | "contentInset" | "contentOffset" | "maintainVisibleContentPosition"> & {
585
589
  alignItemsAtEnd?: boolean;
586
590
  columnWrapperStyle?: ColumnWrapperStyle;
587
591
  data: readonly T[];
@@ -647,7 +651,7 @@ declare const LazyLegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_
647
651
  stickyIndices?: number[];
648
652
  getItemType?: ((item: T, index: number) => string | undefined) | undefined;
649
653
  getFixedItemSize?: ((index: number, item: T, type: string | undefined) => number) | undefined;
650
- } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode) | react_native.Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
654
+ } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode) | react_native.Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "removeClippedSubviews" | "stickyHeaderIndices" | "children" | "contentInset" | "contentOffset" | "maintainVisibleContentPosition"> & {
651
655
  alignItemsAtEnd?: boolean;
652
656
  columnWrapperStyle?: ColumnWrapperStyle;
653
657
  data: readonly T[];
@@ -713,9 +717,7 @@ declare const LazyLegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_
713
717
  stickyIndices?: number[];
714
718
  getItemType?: ((item: T, index: number) => string | undefined) | undefined;
715
719
  getFixedItemSize?: ((index: number, item: T, type: string | undefined) => number) | undefined;
716
- } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode)> | (<ItemT_1>(props: _legendapp_list_reanimated.AnimatedLegendListProps<ItemT_1> & {
717
- ref?: React$1.Ref<LegendListRef>;
718
- }) => React$1.ReactElement | null) = <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
720
+ } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode)> = <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "removeClippedSubviews" | "stickyHeaderIndices" | "children" | "contentInset" | "contentOffset" | "maintainVisibleContentPosition"> & {
719
721
  alignItemsAtEnd?: boolean;
720
722
  columnWrapperStyle?: ColumnWrapperStyle;
721
723
  data: readonly T[];
@@ -783,7 +785,7 @@ declare const LazyLegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_
783
785
  getFixedItemSize?: ((index: number, item: T, type: string | undefined) => number) | undefined;
784
786
  } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode>(props: LazyLegendListProps<ItemT, ListT> & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode;
785
787
 
786
- declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
788
+ declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "removeClippedSubviews" | "stickyHeaderIndices" | "children" | "contentInset" | "contentOffset" | "maintainVisibleContentPosition"> & {
787
789
  alignItemsAtEnd?: boolean;
788
790
  columnWrapperStyle?: ColumnWrapperStyle;
789
791
  data: readonly T[];
package/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import * as _legendapp_list_reanimated from '@legendapp/list/reanimated';
2
1
  import * as React$1 from 'react';
3
2
  import { ComponentProps, ReactNode, Dispatch, SetStateAction } from 'react';
4
3
  import * as react_native from 'react-native';
5
4
  import { View, Animated, ScrollView, StyleProp, ViewStyle, ScrollViewProps, LayoutRectangle, ScrollViewComponent, ScrollResponderMixin } from 'react-native';
6
5
  import Animated$1 from 'react-native-reanimated';
6
+ import * as _legendapp_list_reanimated from '@legendapp/list/reanimated';
7
7
 
8
8
  type ListenerType = "numContainers" | "numContainersPooled" | `containerItemKey${number}` | `containerItemData${number}` | `containerPosition${number}` | `containerColumn${number}` | `containerSticky${number}` | `containerStickyOffset${number}` | "containersDidLayout" | "extraData" | "numColumns" | "lastItemKeys" | "totalSize" | "alignItemsPaddingTop" | "stylePaddingTop" | "scrollAdjust" | "scrollAdjustUserOffset" | "headerSize" | "footerSize" | "maintainVisibleContentPosition" | "debugRawScroll" | "debugComputedScroll" | "otherAxisSize" | "snapToOffsets" | "scrollSize";
9
9
  interface StateContext {
@@ -391,17 +391,19 @@ interface LegendListRenderItemProps<ItemT, TItemType extends string | number | u
391
391
  }
392
392
  type ScrollState = {
393
393
  contentLength: number;
394
+ data: readonly any[];
394
395
  end: number;
395
396
  endBuffered: number;
396
397
  isAtEnd: boolean;
397
398
  isAtStart: boolean;
399
+ positionAtIndex: (index: number) => number;
398
400
  positions: Map<string, number>;
399
401
  scroll: number;
400
402
  scrollLength: number;
403
+ sizeAtIndex: (index: number) => number;
404
+ sizes: Map<string, number>;
401
405
  start: number;
402
406
  startBuffered: number;
403
- sizes: Map<string, number>;
404
- sizeAtIndex: (index: number) => number;
405
407
  };
406
408
  type LegendListRef = {
407
409
  /**
@@ -581,7 +583,9 @@ interface LazyLegendListProps<ItemT, ListT> extends Omit<LegendListProps<ItemT>,
581
583
  children?: React$1.ReactNode | undefined;
582
584
  LegendList?: ListT;
583
585
  }
584
- declare const LazyLegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
586
+ declare const LazyLegendList: <ItemT, ListT extends (<ItemT_1>(props: _legendapp_list_reanimated.AnimatedLegendListProps<ItemT_1> & {
587
+ ref?: React$1.Ref<LegendListRef>;
588
+ }) => React$1.ReactElement | null) | (<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "removeClippedSubviews" | "stickyHeaderIndices" | "children" | "contentInset" | "contentOffset" | "maintainVisibleContentPosition"> & {
585
589
  alignItemsAtEnd?: boolean;
586
590
  columnWrapperStyle?: ColumnWrapperStyle;
587
591
  data: readonly T[];
@@ -647,7 +651,7 @@ declare const LazyLegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_
647
651
  stickyIndices?: number[];
648
652
  getItemType?: ((item: T, index: number) => string | undefined) | undefined;
649
653
  getFixedItemSize?: ((index: number, item: T, type: string | undefined) => number) | undefined;
650
- } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode) | react_native.Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
654
+ } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode) | react_native.Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "removeClippedSubviews" | "stickyHeaderIndices" | "children" | "contentInset" | "contentOffset" | "maintainVisibleContentPosition"> & {
651
655
  alignItemsAtEnd?: boolean;
652
656
  columnWrapperStyle?: ColumnWrapperStyle;
653
657
  data: readonly T[];
@@ -713,9 +717,7 @@ declare const LazyLegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_
713
717
  stickyIndices?: number[];
714
718
  getItemType?: ((item: T, index: number) => string | undefined) | undefined;
715
719
  getFixedItemSize?: ((index: number, item: T, type: string | undefined) => number) | undefined;
716
- } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode)> | (<ItemT_1>(props: _legendapp_list_reanimated.AnimatedLegendListProps<ItemT_1> & {
717
- ref?: React$1.Ref<LegendListRef>;
718
- }) => React$1.ReactElement | null) = <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
720
+ } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode)> = <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "removeClippedSubviews" | "stickyHeaderIndices" | "children" | "contentInset" | "contentOffset" | "maintainVisibleContentPosition"> & {
719
721
  alignItemsAtEnd?: boolean;
720
722
  columnWrapperStyle?: ColumnWrapperStyle;
721
723
  data: readonly T[];
@@ -783,7 +785,7 @@ declare const LazyLegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_
783
785
  getFixedItemSize?: ((index: number, item: T, type: string | undefined) => number) | undefined;
784
786
  } & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode>(props: LazyLegendListProps<ItemT, ListT> & React$1.RefAttributes<LegendListRef>) => React$1.ReactNode;
785
787
 
786
- declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews" | "children"> & {
788
+ declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "removeClippedSubviews" | "stickyHeaderIndices" | "children" | "contentInset" | "contentOffset" | "maintainVisibleContentPosition"> & {
787
789
  alignItemsAtEnd?: boolean;
788
790
  columnWrapperStyle?: ColumnWrapperStyle;
789
791
  data: readonly T[];
package/index.js CHANGED
@@ -303,12 +303,10 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
303
303
  return /* @__PURE__ */ React3__namespace.createElement(reactNative.Animated.View, { ref: refView, style: viewStyle, ...rest });
304
304
  });
305
305
  var PositionView3 = IsNewArchitecture ? PositionViewState : PositionViewAnimated;
306
-
307
- // src/components/Separator.tsx
308
306
  function Separator({ ItemSeparatorComponent, itemKey, leadingItem }) {
309
307
  const [lastItemKeys] = useArr$(["lastItemKeys"]);
310
308
  const isALastItem = lastItemKeys.includes(itemKey);
311
- return isALastItem ? null : /* @__PURE__ */ React.createElement(ItemSeparatorComponent, { leadingItem });
309
+ return isALastItem ? null : /* @__PURE__ */ React3__namespace.createElement(ItemSeparatorComponent, { leadingItem });
312
310
  }
313
311
  var symbolFirst = Symbol();
314
312
  function useInit(cb) {
@@ -989,41 +987,61 @@ function requestAdjust(ctx, state, positionDiff) {
989
987
  // src/core/prepareMVCP.ts
990
988
  function prepareMVCP(ctx, state, dataChanged) {
991
989
  const {
990
+ idsInView,
992
991
  positions,
993
992
  scrollingTo,
994
993
  props: { maintainVisibleContentPosition }
995
994
  } = state;
996
995
  let prevPosition;
997
996
  let targetId;
998
- let targetIndex;
997
+ const idsInViewWithPositions = [];
999
998
  const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
1000
999
  if (maintainVisibleContentPosition) {
1001
1000
  const indexByKey = state.indexByKey;
1002
1001
  if (scrollTarget !== void 0) {
1003
1002
  targetId = getId(state, scrollTarget);
1004
- targetIndex = scrollTarget;
1005
- } else if (state.idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
1006
- targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
1007
- targetIndex = indexByKey.get(targetId);
1003
+ } else if (idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
1004
+ if (dataChanged) {
1005
+ for (let i = 0; i < idsInView.length; i++) {
1006
+ const id = idsInView[i];
1007
+ const index = indexByKey.get(id);
1008
+ if (index !== void 0) {
1009
+ idsInViewWithPositions.push({ id, position: positions.get(id) });
1010
+ }
1011
+ }
1012
+ } else {
1013
+ targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
1014
+ }
1008
1015
  }
1009
- if (targetId !== void 0 && targetIndex !== void 0) {
1016
+ if (targetId !== void 0) {
1010
1017
  prevPosition = positions.get(targetId);
1011
1018
  }
1012
1019
  }
1013
1020
  return () => {
1021
+ let positionDiff;
1022
+ if (dataChanged && targetId === void 0) {
1023
+ for (let i = 0; i < idsInViewWithPositions.length; i++) {
1024
+ const { id, position } = idsInViewWithPositions[i];
1025
+ const newPosition = positions.get(id);
1026
+ if (newPosition !== void 0) {
1027
+ positionDiff = newPosition - position;
1028
+ break;
1029
+ }
1030
+ }
1031
+ }
1014
1032
  if (targetId !== void 0 && prevPosition !== void 0) {
1015
1033
  const newPosition = positions.get(targetId);
1016
1034
  if (newPosition !== void 0) {
1017
- const positionDiff = newPosition - prevPosition;
1018
- if (Math.abs(positionDiff) > 0.1) {
1019
- if (reactNative.Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff) {
1020
- scrollTo(state, {
1021
- offset: state.scroll + positionDiff
1022
- });
1023
- } else {
1024
- requestAdjust(ctx, state, positionDiff);
1025
- }
1026
- }
1035
+ positionDiff = newPosition - prevPosition;
1036
+ }
1037
+ }
1038
+ if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
1039
+ if (reactNative.Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff) {
1040
+ scrollTo(state, {
1041
+ offset: state.scroll + positionDiff
1042
+ });
1043
+ } else {
1044
+ requestAdjust(ctx, state, positionDiff);
1027
1045
  }
1028
1046
  }
1029
1047
  };
@@ -1173,6 +1191,7 @@ function updateAllPositions(ctx, state, dataChanged) {
1173
1191
  if (dataChanged) {
1174
1192
  indexByKey.clear();
1175
1193
  idCache.clear();
1194
+ positions.clear();
1176
1195
  }
1177
1196
  const useAverageSize = !getEstimatedItemSize;
1178
1197
  const itemType = "";
@@ -2764,10 +2783,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2764
2783
  const state2 = refState.current;
2765
2784
  return state2 ? {
2766
2785
  contentLength: state2.totalSize,
2786
+ data: state2.props.data,
2767
2787
  end: state2.endNoBuffer,
2768
2788
  endBuffered: state2.endBuffered,
2769
2789
  isAtEnd: state2.isAtEnd,
2770
2790
  isAtStart: state2.isAtStart,
2791
+ positionAtIndex: (index) => state2.positions.get(getId(state2, index)),
2771
2792
  positions: state2.positions,
2772
2793
  scroll: state2.scroll,
2773
2794
  scrollLength: state2.scrollLength,
package/index.mjs CHANGED
@@ -282,12 +282,10 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
282
282
  return /* @__PURE__ */ React3.createElement(Animated.View, { ref: refView, style: viewStyle, ...rest });
283
283
  });
284
284
  var PositionView3 = IsNewArchitecture ? PositionViewState : PositionViewAnimated;
285
-
286
- // src/components/Separator.tsx
287
285
  function Separator({ ItemSeparatorComponent, itemKey, leadingItem }) {
288
286
  const [lastItemKeys] = useArr$(["lastItemKeys"]);
289
287
  const isALastItem = lastItemKeys.includes(itemKey);
290
- return isALastItem ? null : /* @__PURE__ */ React.createElement(ItemSeparatorComponent, { leadingItem });
288
+ return isALastItem ? null : /* @__PURE__ */ React3.createElement(ItemSeparatorComponent, { leadingItem });
291
289
  }
292
290
  var symbolFirst = Symbol();
293
291
  function useInit(cb) {
@@ -968,41 +966,61 @@ function requestAdjust(ctx, state, positionDiff) {
968
966
  // src/core/prepareMVCP.ts
969
967
  function prepareMVCP(ctx, state, dataChanged) {
970
968
  const {
969
+ idsInView,
971
970
  positions,
972
971
  scrollingTo,
973
972
  props: { maintainVisibleContentPosition }
974
973
  } = state;
975
974
  let prevPosition;
976
975
  let targetId;
977
- let targetIndex;
976
+ const idsInViewWithPositions = [];
978
977
  const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
979
978
  if (maintainVisibleContentPosition) {
980
979
  const indexByKey = state.indexByKey;
981
980
  if (scrollTarget !== void 0) {
982
981
  targetId = getId(state, scrollTarget);
983
- targetIndex = scrollTarget;
984
- } else if (state.idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
985
- targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
986
- targetIndex = indexByKey.get(targetId);
982
+ } else if (idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
983
+ if (dataChanged) {
984
+ for (let i = 0; i < idsInView.length; i++) {
985
+ const id = idsInView[i];
986
+ const index = indexByKey.get(id);
987
+ if (index !== void 0) {
988
+ idsInViewWithPositions.push({ id, position: positions.get(id) });
989
+ }
990
+ }
991
+ } else {
992
+ targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
993
+ }
987
994
  }
988
- if (targetId !== void 0 && targetIndex !== void 0) {
995
+ if (targetId !== void 0) {
989
996
  prevPosition = positions.get(targetId);
990
997
  }
991
998
  }
992
999
  return () => {
1000
+ let positionDiff;
1001
+ if (dataChanged && targetId === void 0) {
1002
+ for (let i = 0; i < idsInViewWithPositions.length; i++) {
1003
+ const { id, position } = idsInViewWithPositions[i];
1004
+ const newPosition = positions.get(id);
1005
+ if (newPosition !== void 0) {
1006
+ positionDiff = newPosition - position;
1007
+ break;
1008
+ }
1009
+ }
1010
+ }
993
1011
  if (targetId !== void 0 && prevPosition !== void 0) {
994
1012
  const newPosition = positions.get(targetId);
995
1013
  if (newPosition !== void 0) {
996
- const positionDiff = newPosition - prevPosition;
997
- if (Math.abs(positionDiff) > 0.1) {
998
- if (Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff) {
999
- scrollTo(state, {
1000
- offset: state.scroll + positionDiff
1001
- });
1002
- } else {
1003
- requestAdjust(ctx, state, positionDiff);
1004
- }
1005
- }
1014
+ positionDiff = newPosition - prevPosition;
1015
+ }
1016
+ }
1017
+ if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
1018
+ if (Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff) {
1019
+ scrollTo(state, {
1020
+ offset: state.scroll + positionDiff
1021
+ });
1022
+ } else {
1023
+ requestAdjust(ctx, state, positionDiff);
1006
1024
  }
1007
1025
  }
1008
1026
  };
@@ -1152,6 +1170,7 @@ function updateAllPositions(ctx, state, dataChanged) {
1152
1170
  if (dataChanged) {
1153
1171
  indexByKey.clear();
1154
1172
  idCache.clear();
1173
+ positions.clear();
1155
1174
  }
1156
1175
  const useAverageSize = !getEstimatedItemSize;
1157
1176
  const itemType = "";
@@ -2743,10 +2762,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2743
2762
  const state2 = refState.current;
2744
2763
  return state2 ? {
2745
2764
  contentLength: state2.totalSize,
2765
+ data: state2.props.data,
2746
2766
  end: state2.endNoBuffer,
2747
2767
  endBuffered: state2.endBuffered,
2748
2768
  isAtEnd: state2.isAtEnd,
2749
2769
  isAtStart: state2.isAtStart,
2770
+ positionAtIndex: (index) => state2.positions.get(getId(state2, index)),
2750
2771
  positions: state2.positions,
2751
2772
  scroll: state2.scroll,
2752
2773
  scrollLength: state2.scrollLength,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "2.0.0-next.11",
3
+ "version": "2.0.0-next.13",
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,
package/.DS_Store DELETED
Binary file