@legendapp/list 1.0.0-beta.44 → 1.0.0-beta.46

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/index.d.mts CHANGED
@@ -108,8 +108,8 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
108
108
  */
109
109
  maintainScrollAtEnd?: boolean;
110
110
  /**
111
- * Distance threshold in pixels to trigger maintainScrollAtEnd.
112
- * @default 100
111
+ * Distance threshold in percentage of screen size to trigger maintainScrollAtEnd.
112
+ * @default 0.1
113
113
  */
114
114
  maintainScrollAtEndThreshold?: number;
115
115
  /**
package/index.d.ts CHANGED
@@ -108,8 +108,8 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
108
108
  */
109
109
  maintainScrollAtEnd?: boolean;
110
110
  /**
111
- * Distance threshold in pixels to trigger maintainScrollAtEnd.
112
- * @default 100
111
+ * Distance threshold in percentage of screen size to trigger maintainScrollAtEnd.
112
+ * @default 0.1
113
113
  */
114
114
  maintainScrollAtEndThreshold?: number;
115
115
  /**
package/index.js CHANGED
@@ -1039,19 +1039,44 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1039
1039
  }
1040
1040
  return void 0;
1041
1041
  };
1042
- const setDidLayout = () => {
1042
+ const scrollToIndex = ({
1043
+ index,
1044
+ viewOffset = 0,
1045
+ animated = true,
1046
+ viewPosition = 0
1047
+ }) => {
1043
1048
  var _a;
1049
+ const state = refState.current;
1050
+ const firstIndexOffset = calculateOffsetForIndex(index);
1051
+ let firstIndexScrollPostion = firstIndexOffset - viewOffset;
1052
+ const diff = Math.abs(state.scroll - firstIndexScrollPostion);
1053
+ const needsReanchoring = maintainVisibleContentPosition && diff > 100;
1054
+ state.scrollForNextCalculateItemsInView = void 0;
1055
+ if (needsReanchoring) {
1056
+ const id = getId(index);
1057
+ state.anchorElement = { id, coordinate: firstIndexOffset };
1058
+ (_a = state.belowAnchorElementPositions) == null ? void 0 : _a.clear();
1059
+ state.positions.clear();
1060
+ calcTotalSizesAndPositions({ forgetPositions: true });
1061
+ state.startBufferedId = id;
1062
+ state.minIndexSizeChanged = index;
1063
+ firstIndexScrollPostion = firstIndexOffset - viewOffset + state.scrollAdjustHandler.getAppliedAdjust();
1064
+ }
1065
+ if (viewPosition) {
1066
+ firstIndexScrollPostion -= viewPosition * (state.scrollLength - getItemSize(getId(index), index, state.data[index]));
1067
+ }
1068
+ state.scrollAdjustHandler.setDisableAdjust(true);
1069
+ state.scrollingToOffset = firstIndexScrollPostion;
1070
+ scrollTo(firstIndexScrollPostion, animated);
1071
+ };
1072
+ const setDidLayout = () => {
1044
1073
  refState.current.queuedInitialLayout = true;
1045
1074
  checkAtBottom();
1046
1075
  if (initialScrollIndex) {
1047
- const updatedOffset = calculateOffsetForIndex(initialScrollIndex);
1048
- (_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
1049
1076
  queueMicrotask(() => {
1050
- scrollTo(updatedOffset, false);
1077
+ scrollToIndex({ index: initialScrollIndex, animated: false });
1051
1078
  requestAnimationFrame(() => {
1052
- var _a2;
1053
1079
  set$(ctx, "containersDidLayout", true);
1054
- (_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(false);
1055
1080
  });
1056
1081
  });
1057
1082
  } else {
@@ -1953,36 +1978,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1953
1978
  React6.useImperativeHandle(
1954
1979
  forwardedRef,
1955
1980
  () => {
1956
- const scrollToIndex = ({
1957
- index,
1958
- viewOffset = 0,
1959
- animated = true,
1960
- viewPosition = 0
1961
- }) => {
1962
- var _a;
1963
- const state = refState.current;
1964
- const firstIndexOffset = calculateOffsetForIndex(index);
1965
- let firstIndexScrollPostion = firstIndexOffset - viewOffset;
1966
- const diff = Math.abs(state.scroll - firstIndexScrollPostion);
1967
- const needsReanchoring = maintainVisibleContentPosition && diff > 100;
1968
- state.scrollForNextCalculateItemsInView = void 0;
1969
- if (needsReanchoring) {
1970
- const id = getId(index);
1971
- state.anchorElement = { id, coordinate: firstIndexOffset };
1972
- (_a = state.belowAnchorElementPositions) == null ? void 0 : _a.clear();
1973
- state.positions.clear();
1974
- calcTotalSizesAndPositions({ forgetPositions: true });
1975
- state.startBufferedId = id;
1976
- state.minIndexSizeChanged = index;
1977
- firstIndexScrollPostion = firstIndexOffset - viewOffset + state.scrollAdjustHandler.getAppliedAdjust();
1978
- }
1979
- if (viewPosition) {
1980
- firstIndexScrollPostion -= viewPosition * (state.scrollLength - getItemSize(getId(index), index, state.data[index]));
1981
- }
1982
- state.scrollAdjustHandler.setDisableAdjust(true);
1983
- state.scrollingToOffset = firstIndexScrollPostion;
1984
- scrollTo(firstIndexScrollPostion, animated);
1985
- };
1986
1981
  const scrollIndexIntoView = (options) => {
1987
1982
  if (refState.current) {
1988
1983
  const { index, ...rest2 } = options;
package/index.mjs CHANGED
@@ -1018,19 +1018,44 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1018
1018
  }
1019
1019
  return void 0;
1020
1020
  };
1021
- const setDidLayout = () => {
1021
+ const scrollToIndex = ({
1022
+ index,
1023
+ viewOffset = 0,
1024
+ animated = true,
1025
+ viewPosition = 0
1026
+ }) => {
1022
1027
  var _a;
1028
+ const state = refState.current;
1029
+ const firstIndexOffset = calculateOffsetForIndex(index);
1030
+ let firstIndexScrollPostion = firstIndexOffset - viewOffset;
1031
+ const diff = Math.abs(state.scroll - firstIndexScrollPostion);
1032
+ const needsReanchoring = maintainVisibleContentPosition && diff > 100;
1033
+ state.scrollForNextCalculateItemsInView = void 0;
1034
+ if (needsReanchoring) {
1035
+ const id = getId(index);
1036
+ state.anchorElement = { id, coordinate: firstIndexOffset };
1037
+ (_a = state.belowAnchorElementPositions) == null ? void 0 : _a.clear();
1038
+ state.positions.clear();
1039
+ calcTotalSizesAndPositions({ forgetPositions: true });
1040
+ state.startBufferedId = id;
1041
+ state.minIndexSizeChanged = index;
1042
+ firstIndexScrollPostion = firstIndexOffset - viewOffset + state.scrollAdjustHandler.getAppliedAdjust();
1043
+ }
1044
+ if (viewPosition) {
1045
+ firstIndexScrollPostion -= viewPosition * (state.scrollLength - getItemSize(getId(index), index, state.data[index]));
1046
+ }
1047
+ state.scrollAdjustHandler.setDisableAdjust(true);
1048
+ state.scrollingToOffset = firstIndexScrollPostion;
1049
+ scrollTo(firstIndexScrollPostion, animated);
1050
+ };
1051
+ const setDidLayout = () => {
1023
1052
  refState.current.queuedInitialLayout = true;
1024
1053
  checkAtBottom();
1025
1054
  if (initialScrollIndex) {
1026
- const updatedOffset = calculateOffsetForIndex(initialScrollIndex);
1027
- (_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
1028
1055
  queueMicrotask(() => {
1029
- scrollTo(updatedOffset, false);
1056
+ scrollToIndex({ index: initialScrollIndex, animated: false });
1030
1057
  requestAnimationFrame(() => {
1031
- var _a2;
1032
1058
  set$(ctx, "containersDidLayout", true);
1033
- (_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(false);
1034
1059
  });
1035
1060
  });
1036
1061
  } else {
@@ -1932,36 +1957,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1932
1957
  useImperativeHandle(
1933
1958
  forwardedRef,
1934
1959
  () => {
1935
- const scrollToIndex = ({
1936
- index,
1937
- viewOffset = 0,
1938
- animated = true,
1939
- viewPosition = 0
1940
- }) => {
1941
- var _a;
1942
- const state = refState.current;
1943
- const firstIndexOffset = calculateOffsetForIndex(index);
1944
- let firstIndexScrollPostion = firstIndexOffset - viewOffset;
1945
- const diff = Math.abs(state.scroll - firstIndexScrollPostion);
1946
- const needsReanchoring = maintainVisibleContentPosition && diff > 100;
1947
- state.scrollForNextCalculateItemsInView = void 0;
1948
- if (needsReanchoring) {
1949
- const id = getId(index);
1950
- state.anchorElement = { id, coordinate: firstIndexOffset };
1951
- (_a = state.belowAnchorElementPositions) == null ? void 0 : _a.clear();
1952
- state.positions.clear();
1953
- calcTotalSizesAndPositions({ forgetPositions: true });
1954
- state.startBufferedId = id;
1955
- state.minIndexSizeChanged = index;
1956
- firstIndexScrollPostion = firstIndexOffset - viewOffset + state.scrollAdjustHandler.getAppliedAdjust();
1957
- }
1958
- if (viewPosition) {
1959
- firstIndexScrollPostion -= viewPosition * (state.scrollLength - getItemSize(getId(index), index, state.data[index]));
1960
- }
1961
- state.scrollAdjustHandler.setDisableAdjust(true);
1962
- state.scrollingToOffset = firstIndexScrollPostion;
1963
- scrollTo(firstIndexScrollPostion, animated);
1964
- };
1965
1960
  const scrollIndexIntoView = (options) => {
1966
1961
  if (refState.current) {
1967
1962
  const { index, ...rest2 } = options;
@@ -4,6 +4,7 @@ import * as _legendapp_list_reanimated from '@legendapp/list/reanimated';
4
4
  import * as _legendapp_list from '@legendapp/list';
5
5
  import { LegendListRef } from '@legendapp/list';
6
6
  import * as react_native from 'react-native';
7
+ import { Insets } from 'react-native';
7
8
  import * as React from 'react';
8
9
 
9
10
  declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<react_native.ScrollViewProps, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
@@ -122,7 +123,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<react_native.Sc
122
123
  renderItem?: ((props: _legendapp_list.LegendListRenderItemProps<ItemT_1>) => React.ReactNode) | undefined;
123
124
  animatedProps?: Partial<{
124
125
  contentOffset?: react_native.PointProp | react_native_reanimated.SharedValue<react_native.PointProp | undefined> | undefined;
125
- contentInset?: react_native.Insets | react_native_reanimated.SharedValue<react_native.Insets | undefined> | undefined;
126
+ contentInset?: Insets | react_native_reanimated.SharedValue<Insets | undefined> | undefined;
126
127
  maintainVisibleContentPosition?: {
127
128
  autoscrollToTopThreshold?: number | null | undefined;
128
129
  minIndexForVisible: number;
@@ -157,7 +158,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<react_native.Sc
157
158
  disableScrollViewPanResponder?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
158
159
  StickyHeaderComponent?: React.ComponentType<any> | react_native_reanimated.SharedValue<React.ComponentType<any> | undefined> | undefined;
159
160
  children?: React.ReactNode | react_native_reanimated.SharedValue<React.ReactNode>;
160
- hitSlop?: number | react_native.Insets | react_native_reanimated.SharedValue<number | react_native.Insets | null | undefined> | null | undefined;
161
+ hitSlop?: number | Insets | react_native_reanimated.SharedValue<number | Insets | null | undefined> | null | undefined;
161
162
  id?: string | react_native_reanimated.SharedValue<string | undefined> | undefined;
162
163
  needsOffscreenAlphaCompositing?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
163
164
  onLayout?: ((event: react_native.LayoutChangeEvent) => void) | react_native_reanimated.SharedValue<((event: react_native.LayoutChangeEvent) => void) | undefined> | undefined;
@@ -263,7 +264,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<react_native.Sc
263
264
  onScrollAnimationEnd?: (() => void) | react_native_reanimated.SharedValue<(() => void) | undefined> | undefined;
264
265
  pinchGestureEnabled?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
265
266
  scrollEventThrottle?: number | react_native_reanimated.SharedValue<number | undefined> | undefined;
266
- scrollIndicatorInsets?: react_native.Insets | react_native_reanimated.SharedValue<react_native.Insets | undefined> | undefined;
267
+ scrollIndicatorInsets?: Insets | react_native_reanimated.SharedValue<Insets | undefined> | undefined;
267
268
  scrollToOverflowEnabled?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
268
269
  scrollsToTop?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
269
270
  snapToAlignment?: "end" | "start" | "center" | react_native_reanimated.SharedValue<"end" | "start" | "center" | undefined> | undefined;
@@ -4,6 +4,7 @@ import * as _legendapp_list_reanimated from '@legendapp/list/reanimated';
4
4
  import * as _legendapp_list from '@legendapp/list';
5
5
  import { LegendListRef } from '@legendapp/list';
6
6
  import * as react_native from 'react-native';
7
+ import { Insets } from 'react-native';
7
8
  import * as React from 'react';
8
9
 
9
10
  declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<react_native.ScrollViewProps, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
@@ -122,7 +123,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<react_native.Sc
122
123
  renderItem?: ((props: _legendapp_list.LegendListRenderItemProps<ItemT_1>) => React.ReactNode) | undefined;
123
124
  animatedProps?: Partial<{
124
125
  contentOffset?: react_native.PointProp | react_native_reanimated.SharedValue<react_native.PointProp | undefined> | undefined;
125
- contentInset?: react_native.Insets | react_native_reanimated.SharedValue<react_native.Insets | undefined> | undefined;
126
+ contentInset?: Insets | react_native_reanimated.SharedValue<Insets | undefined> | undefined;
126
127
  maintainVisibleContentPosition?: {
127
128
  autoscrollToTopThreshold?: number | null | undefined;
128
129
  minIndexForVisible: number;
@@ -157,7 +158,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<react_native.Sc
157
158
  disableScrollViewPanResponder?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
158
159
  StickyHeaderComponent?: React.ComponentType<any> | react_native_reanimated.SharedValue<React.ComponentType<any> | undefined> | undefined;
159
160
  children?: React.ReactNode | react_native_reanimated.SharedValue<React.ReactNode>;
160
- hitSlop?: number | react_native.Insets | react_native_reanimated.SharedValue<number | react_native.Insets | null | undefined> | null | undefined;
161
+ hitSlop?: number | Insets | react_native_reanimated.SharedValue<number | Insets | null | undefined> | null | undefined;
161
162
  id?: string | react_native_reanimated.SharedValue<string | undefined> | undefined;
162
163
  needsOffscreenAlphaCompositing?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
163
164
  onLayout?: ((event: react_native.LayoutChangeEvent) => void) | react_native_reanimated.SharedValue<((event: react_native.LayoutChangeEvent) => void) | undefined> | undefined;
@@ -263,7 +264,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<react_native.Sc
263
264
  onScrollAnimationEnd?: (() => void) | react_native_reanimated.SharedValue<(() => void) | undefined> | undefined;
264
265
  pinchGestureEnabled?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
265
266
  scrollEventThrottle?: number | react_native_reanimated.SharedValue<number | undefined> | undefined;
266
- scrollIndicatorInsets?: react_native.Insets | react_native_reanimated.SharedValue<react_native.Insets | undefined> | undefined;
267
+ scrollIndicatorInsets?: Insets | react_native_reanimated.SharedValue<Insets | undefined> | undefined;
267
268
  scrollToOverflowEnabled?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
268
269
  scrollsToTop?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
269
270
  snapToAlignment?: "end" | "start" | "center" | react_native_reanimated.SharedValue<"end" | "start" | "center" | undefined> | undefined;
@@ -29,7 +29,12 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
29
  // src/keyboard-controller.tsx
30
30
  var typedForwardRef = React.forwardRef;
31
31
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
32
- const { LegendList: LegendListProp, style: styleProp, ...rest } = props;
32
+ const {
33
+ LegendList: LegendListProp,
34
+ style: styleProp,
35
+ scrollIndicatorInsets: scrollIndicatorInsetsProp,
36
+ ...rest
37
+ } = props;
33
38
  const [padding, setPadding] = React.useState(0);
34
39
  const updatePadding = (height) => {
35
40
  setPadding(height);
@@ -43,7 +48,14 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
43
48
  const LegendListComponent = LegendListProp != null ? LegendListProp : list.LegendList;
44
49
  const styleFlattened = reactNative.StyleSheet.flatten(styleProp) || {};
45
50
  const style = { ...styleFlattened, paddingTop: padding + (styleFlattened.paddingTop || 0) };
46
- return /* @__PURE__ */ React__namespace.createElement(LegendListComponent, { ...rest, style, ref: forwardedRef });
51
+ const scrollIndicatorInsets = scrollIndicatorInsetsProp ? { ...scrollIndicatorInsetsProp } : {};
52
+ if (!props.horizontal) {
53
+ scrollIndicatorInsets.top = (scrollIndicatorInsets.top || 0) + padding;
54
+ }
55
+ return (
56
+ // @ts-expect-error TODO: Fix this type
57
+ /* @__PURE__ */ React__namespace.createElement(LegendListComponent, { ...rest, style, scrollIndicatorInsets, ref: forwardedRef })
58
+ );
47
59
  });
48
60
 
49
61
  exports.LegendList = LegendList;
@@ -8,7 +8,12 @@ import { runOnJS } from 'react-native-reanimated';
8
8
  // src/keyboard-controller.tsx
9
9
  var typedForwardRef = forwardRef;
10
10
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
11
- const { LegendList: LegendListProp, style: styleProp, ...rest } = props;
11
+ const {
12
+ LegendList: LegendListProp,
13
+ style: styleProp,
14
+ scrollIndicatorInsets: scrollIndicatorInsetsProp,
15
+ ...rest
16
+ } = props;
12
17
  const [padding, setPadding] = useState(0);
13
18
  const updatePadding = (height) => {
14
19
  setPadding(height);
@@ -22,7 +27,14 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
22
27
  const LegendListComponent = LegendListProp != null ? LegendListProp : LegendList$1;
23
28
  const styleFlattened = StyleSheet.flatten(styleProp) || {};
24
29
  const style = { ...styleFlattened, paddingTop: padding + (styleFlattened.paddingTop || 0) };
25
- return /* @__PURE__ */ React.createElement(LegendListComponent, { ...rest, style, ref: forwardedRef });
30
+ const scrollIndicatorInsets = scrollIndicatorInsetsProp ? { ...scrollIndicatorInsetsProp } : {};
31
+ if (!props.horizontal) {
32
+ scrollIndicatorInsets.top = (scrollIndicatorInsets.top || 0) + padding;
33
+ }
34
+ return (
35
+ // @ts-expect-error TODO: Fix this type
36
+ /* @__PURE__ */ React.createElement(LegendListComponent, { ...rest, style, scrollIndicatorInsets, ref: forwardedRef })
37
+ );
26
38
  });
27
39
 
28
40
  export { LegendList };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "1.0.0-beta.44",
3
+ "version": "1.0.0-beta.46",
4
4
  "description": "Legend List aims to be a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,