@legendapp/list 0.6.0 → 0.6.2
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/README.md +1 -6
- package/animated.d.mts +9 -0
- package/animated.d.ts +9 -0
- package/animated.js +9 -0
- package/animated.mjs +7 -0
- package/index.d.mts +5 -2
- package/index.d.ts +5 -2
- package/index.js +30 -8
- package/index.mjs +30 -8
- package/package.json +1 -1
- package/reanimated.d.mts +13 -0
- package/reanimated.d.ts +13 -0
- package/reanimated.js +47 -0
- package/reanimated.mjs +40 -0
package/README.md
CHANGED
|
@@ -67,12 +67,7 @@ There's not a lot of code here so hopefully it's easy to contribute. If you want
|
|
|
67
67
|
|
|
68
68
|
## TODO list
|
|
69
69
|
|
|
70
|
-
-
|
|
71
|
-
- Adjust scroll when item heights change above the viewable area so they don't jump
|
|
72
|
-
- A prop to start with items at the bottom like a chat interface, just needs to pad the top with screen height - items height
|
|
73
|
-
- Other important missing features from FlatList or other lists libraries
|
|
74
|
-
- Optimizations:
|
|
75
|
-
- Loop over only potentially changed items when adjusting heights rather than data array
|
|
70
|
+
See [Road to v1](https://github.com/LegendApp/legend-list/issues/28)
|
|
76
71
|
|
|
77
72
|
## Community
|
|
78
73
|
|
package/animated.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as _legendapp_list from '@legendapp/list';
|
|
3
|
+
import { Animated } from 'react-native';
|
|
4
|
+
|
|
5
|
+
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: _legendapp_list.LegendListProps<T> & {
|
|
6
|
+
ref?: React.ForwardedRef<_legendapp_list.LegendListRef>;
|
|
7
|
+
}) => React.ReactElement)>;
|
|
8
|
+
|
|
9
|
+
export { AnimatedLegendList };
|
package/animated.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as _legendapp_list from '@legendapp/list';
|
|
3
|
+
import { Animated } from 'react-native';
|
|
4
|
+
|
|
5
|
+
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: _legendapp_list.LegendListProps<T> & {
|
|
6
|
+
ref?: React.ForwardedRef<_legendapp_list.LegendListRef>;
|
|
7
|
+
}) => React.ReactElement)>;
|
|
8
|
+
|
|
9
|
+
export { AnimatedLegendList };
|
package/animated.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var list = require('@legendapp/list');
|
|
4
|
+
var reactNative = require('react-native');
|
|
5
|
+
|
|
6
|
+
// src/animated.tsx
|
|
7
|
+
var AnimatedLegendList = reactNative.Animated.createAnimatedComponent(list.LegendList);
|
|
8
|
+
|
|
9
|
+
exports.AnimatedLegendList = AnimatedLegendList;
|
package/animated.mjs
ADDED
package/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode, ForwardedRef, ReactElement } from 'react';
|
|
2
2
|
import { ScrollView, StyleProp, ViewStyle, ScrollViewComponent, ScrollResponderMixin } from 'react-native';
|
|
3
|
+
import Animated from 'react-native-reanimated';
|
|
3
4
|
|
|
4
5
|
declare class ScrollAdjustHandler {
|
|
5
6
|
private ctx;
|
|
@@ -13,7 +14,7 @@ declare class ScrollAdjustHandler {
|
|
|
13
14
|
getAppliedAdjust(): number;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
type
|
|
17
|
+
type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView>> = Omit<TScrollView, 'contentOffset' | 'contentInset' | 'maintainVisibleContentPosition' | 'stickyHeaderIndices'> & {
|
|
17
18
|
data: ArrayLike<any> & ItemT[];
|
|
18
19
|
initialScrollOffset?: number;
|
|
19
20
|
initialScrollIndex?: number;
|
|
@@ -27,6 +28,7 @@ type LegendListProps<ItemT> = Omit<ComponentProps<typeof ScrollView>, 'contentOf
|
|
|
27
28
|
alignItemsAtEnd?: boolean;
|
|
28
29
|
maintainVisibleContentPosition?: boolean;
|
|
29
30
|
numColumns?: number;
|
|
31
|
+
refScrollView?: React.Ref<ScrollView>;
|
|
30
32
|
estimatedItemSize?: number;
|
|
31
33
|
getEstimatedItemSize?: (index: number, item: ItemT) => number;
|
|
32
34
|
onStartReached?: ((info: {
|
|
@@ -48,6 +50,7 @@ type LegendListProps<ItemT> = Omit<ComponentProps<typeof ScrollView>, 'contentOf
|
|
|
48
50
|
viewabilityConfig?: ViewabilityConfig;
|
|
49
51
|
onViewableItemsChanged?: OnViewableItemsChanged | undefined;
|
|
50
52
|
};
|
|
53
|
+
type LegendListProps<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof ScrollView>>;
|
|
51
54
|
interface InternalState {
|
|
52
55
|
anchorElement?: {
|
|
53
56
|
id: string;
|
|
@@ -214,4 +217,4 @@ declare const LegendList: <T>(props: LegendListProps<T> & {
|
|
|
214
217
|
ref?: ForwardedRef<LegendListRef>;
|
|
215
218
|
}) => ReactElement;
|
|
216
219
|
|
|
217
|
-
export { type InternalState, LegendList, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange };
|
|
220
|
+
export { type InternalState, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange };
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode, ForwardedRef, ReactElement } from 'react';
|
|
2
2
|
import { ScrollView, StyleProp, ViewStyle, ScrollViewComponent, ScrollResponderMixin } from 'react-native';
|
|
3
|
+
import Animated from 'react-native-reanimated';
|
|
3
4
|
|
|
4
5
|
declare class ScrollAdjustHandler {
|
|
5
6
|
private ctx;
|
|
@@ -13,7 +14,7 @@ declare class ScrollAdjustHandler {
|
|
|
13
14
|
getAppliedAdjust(): number;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
type
|
|
17
|
+
type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView>> = Omit<TScrollView, 'contentOffset' | 'contentInset' | 'maintainVisibleContentPosition' | 'stickyHeaderIndices'> & {
|
|
17
18
|
data: ArrayLike<any> & ItemT[];
|
|
18
19
|
initialScrollOffset?: number;
|
|
19
20
|
initialScrollIndex?: number;
|
|
@@ -27,6 +28,7 @@ type LegendListProps<ItemT> = Omit<ComponentProps<typeof ScrollView>, 'contentOf
|
|
|
27
28
|
alignItemsAtEnd?: boolean;
|
|
28
29
|
maintainVisibleContentPosition?: boolean;
|
|
29
30
|
numColumns?: number;
|
|
31
|
+
refScrollView?: React.Ref<ScrollView>;
|
|
30
32
|
estimatedItemSize?: number;
|
|
31
33
|
getEstimatedItemSize?: (index: number, item: ItemT) => number;
|
|
32
34
|
onStartReached?: ((info: {
|
|
@@ -48,6 +50,7 @@ type LegendListProps<ItemT> = Omit<ComponentProps<typeof ScrollView>, 'contentOf
|
|
|
48
50
|
viewabilityConfig?: ViewabilityConfig;
|
|
49
51
|
onViewableItemsChanged?: OnViewableItemsChanged | undefined;
|
|
50
52
|
};
|
|
53
|
+
type LegendListProps<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof ScrollView>>;
|
|
51
54
|
interface InternalState {
|
|
52
55
|
anchorElement?: {
|
|
53
56
|
id: string;
|
|
@@ -214,4 +217,4 @@ declare const LegendList: <T>(props: LegendListProps<T> & {
|
|
|
214
217
|
ref?: ForwardedRef<LegendListRef>;
|
|
215
218
|
}) => ReactElement;
|
|
216
219
|
|
|
217
|
-
export { type InternalState, LegendList, type LegendListProps, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange };
|
|
220
|
+
export { type InternalState, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type OnViewableItemsChanged, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange };
|
package/index.js
CHANGED
|
@@ -107,7 +107,8 @@ var Container = ({
|
|
|
107
107
|
}
|
|
108
108
|
const lastItemKey = use$("lastItemKey");
|
|
109
109
|
const itemKey = use$(`containerItemKey${id}`);
|
|
110
|
-
const
|
|
110
|
+
const data = use$(`containerItemData${id}`);
|
|
111
|
+
const renderedItem = React4.useMemo(() => itemKey !== void 0 && getRenderedItem(itemKey, id), [itemKey, data]);
|
|
111
112
|
return /* @__PURE__ */ React4__namespace.default.createElement(
|
|
112
113
|
reactNative.View,
|
|
113
114
|
{
|
|
@@ -203,7 +204,7 @@ var ListComponent = React4__namespace.memo(function ListComponent2({
|
|
|
203
204
|
ListEmptyComponentStyle,
|
|
204
205
|
getRenderedItem,
|
|
205
206
|
updateItemSize,
|
|
206
|
-
|
|
207
|
+
refScrollView,
|
|
207
208
|
maintainVisibleContentPosition,
|
|
208
209
|
...rest
|
|
209
210
|
}) {
|
|
@@ -227,7 +228,7 @@ var ListComponent = React4__namespace.memo(function ListComponent2({
|
|
|
227
228
|
onLayout,
|
|
228
229
|
horizontal,
|
|
229
230
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
230
|
-
ref:
|
|
231
|
+
ref: refScrollView
|
|
231
232
|
},
|
|
232
233
|
/* @__PURE__ */ React4__namespace.createElement(reactNative.Animated.View, { style: additionalSize }),
|
|
233
234
|
ListHeaderComponent && /* @__PURE__ */ React4__namespace.createElement(
|
|
@@ -483,12 +484,12 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
483
484
|
onEndReached,
|
|
484
485
|
onStartReached,
|
|
485
486
|
ListEmptyComponent,
|
|
487
|
+
refScrollView,
|
|
486
488
|
...rest
|
|
487
489
|
} = props;
|
|
488
490
|
const { style, contentContainerStyle } = props;
|
|
489
491
|
const ctx = useStateContext();
|
|
490
|
-
const
|
|
491
|
-
const refScroller = internalRef;
|
|
492
|
+
const refScroller = React4.useRef(null);
|
|
492
493
|
const scrollBuffer = drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE;
|
|
493
494
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
|
|
494
495
|
const refState = React4.useRef();
|
|
@@ -688,7 +689,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
688
689
|
return res;
|
|
689
690
|
};
|
|
690
691
|
const calculateItemsInView = React4.useCallback((speed) => {
|
|
691
|
-
var _a2, _b2;
|
|
692
|
+
var _a2, _b2, _c2, _d2;
|
|
692
693
|
const state = refState.current;
|
|
693
694
|
const {
|
|
694
695
|
data: data2,
|
|
@@ -838,10 +839,14 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
838
839
|
}
|
|
839
840
|
if (furthestIndex >= 0) {
|
|
840
841
|
set$(ctx, `containerItemKey${furthestIndex}`, id);
|
|
842
|
+
const index = (_b2 = refState.current) == null ? void 0 : _b2.indexByKey.get(id);
|
|
843
|
+
set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
|
|
841
844
|
} else {
|
|
842
845
|
const containerId = numContainers;
|
|
843
846
|
numContainers++;
|
|
844
847
|
set$(ctx, `containerItemKey${containerId}`, id);
|
|
848
|
+
const index = (_c2 = refState.current) == null ? void 0 : _c2.indexByKey.get(id);
|
|
849
|
+
set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
|
|
845
850
|
set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
|
|
846
851
|
set$(ctx, `containerColumn${containerId}`, -1);
|
|
847
852
|
if (__DEV__ && numContainers > peek$(ctx, "numContainersPooled")) {
|
|
@@ -861,7 +866,7 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
861
866
|
}
|
|
862
867
|
for (let i = 0; i < numContainers; i++) {
|
|
863
868
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
864
|
-
const itemIndex = (
|
|
869
|
+
const itemIndex = (_d2 = refState.current) == null ? void 0 : _d2.indexByKey.get(itemKey);
|
|
865
870
|
const item = data2[itemIndex];
|
|
866
871
|
if (item) {
|
|
867
872
|
const id = getId(itemIndex);
|
|
@@ -877,12 +882,16 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
877
882
|
const column2 = columns.get(id) || 1;
|
|
878
883
|
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
879
884
|
const prevColumn = peek$(ctx, `containerColumn${i}`);
|
|
885
|
+
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
880
886
|
if (pos > POSITION_OUT_OF_VIEW && pos !== prevPos) {
|
|
881
887
|
set$(ctx, `containerPosition${i}`, pos);
|
|
882
888
|
}
|
|
883
889
|
if (column2 >= 0 && column2 !== prevColumn) {
|
|
884
890
|
set$(ctx, `containerColumn${i}`, column2);
|
|
885
891
|
}
|
|
892
|
+
if (prevData !== item) {
|
|
893
|
+
set$(ctx, `containerItemData${i}`, data2[itemIndex]);
|
|
894
|
+
}
|
|
886
895
|
}
|
|
887
896
|
}
|
|
888
897
|
}
|
|
@@ -1002,6 +1011,10 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1002
1011
|
}
|
|
1003
1012
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
1004
1013
|
if (!isFirst) {
|
|
1014
|
+
if (data.length > refState.current.data.length) {
|
|
1015
|
+
refState.current.isEndReached = false;
|
|
1016
|
+
}
|
|
1017
|
+
refState.current.data = data;
|
|
1005
1018
|
const numContainers = peek$(ctx, "numContainers");
|
|
1006
1019
|
for (let i = 0; i < numContainers; i++) {
|
|
1007
1020
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
@@ -1305,7 +1318,16 @@ var LegendListInner = React4.forwardRef(function LegendListInner2(props, forward
|
|
|
1305
1318
|
{
|
|
1306
1319
|
...rest,
|
|
1307
1320
|
horizontal,
|
|
1308
|
-
|
|
1321
|
+
refScrollView: (r) => {
|
|
1322
|
+
refScroller.current = r;
|
|
1323
|
+
if (refScrollView) {
|
|
1324
|
+
if (typeof refScrollView === "function") {
|
|
1325
|
+
refScrollView(r);
|
|
1326
|
+
} else {
|
|
1327
|
+
refScrollView.current = r;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1309
1331
|
initialContentOffset,
|
|
1310
1332
|
getRenderedItem,
|
|
1311
1333
|
updateItemSize,
|
package/index.mjs
CHANGED
|
@@ -86,7 +86,8 @@ var Container = ({
|
|
|
86
86
|
}
|
|
87
87
|
const lastItemKey = use$("lastItemKey");
|
|
88
88
|
const itemKey = use$(`containerItemKey${id}`);
|
|
89
|
-
const
|
|
89
|
+
const data = use$(`containerItemData${id}`);
|
|
90
|
+
const renderedItem = useMemo(() => itemKey !== void 0 && getRenderedItem(itemKey, id), [itemKey, data]);
|
|
90
91
|
return /* @__PURE__ */ React4__default.createElement(
|
|
91
92
|
View,
|
|
92
93
|
{
|
|
@@ -182,7 +183,7 @@ var ListComponent = React4.memo(function ListComponent2({
|
|
|
182
183
|
ListEmptyComponentStyle,
|
|
183
184
|
getRenderedItem,
|
|
184
185
|
updateItemSize,
|
|
185
|
-
|
|
186
|
+
refScrollView,
|
|
186
187
|
maintainVisibleContentPosition,
|
|
187
188
|
...rest
|
|
188
189
|
}) {
|
|
@@ -206,7 +207,7 @@ var ListComponent = React4.memo(function ListComponent2({
|
|
|
206
207
|
onLayout,
|
|
207
208
|
horizontal,
|
|
208
209
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
209
|
-
ref:
|
|
210
|
+
ref: refScrollView
|
|
210
211
|
},
|
|
211
212
|
/* @__PURE__ */ React4.createElement(Animated.View, { style: additionalSize }),
|
|
212
213
|
ListHeaderComponent && /* @__PURE__ */ React4.createElement(
|
|
@@ -462,12 +463,12 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
462
463
|
onEndReached,
|
|
463
464
|
onStartReached,
|
|
464
465
|
ListEmptyComponent,
|
|
466
|
+
refScrollView,
|
|
465
467
|
...rest
|
|
466
468
|
} = props;
|
|
467
469
|
const { style, contentContainerStyle } = props;
|
|
468
470
|
const ctx = useStateContext();
|
|
469
|
-
const
|
|
470
|
-
const refScroller = internalRef;
|
|
471
|
+
const refScroller = useRef(null);
|
|
471
472
|
const scrollBuffer = drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE;
|
|
472
473
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
|
|
473
474
|
const refState = useRef();
|
|
@@ -667,7 +668,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
667
668
|
return res;
|
|
668
669
|
};
|
|
669
670
|
const calculateItemsInView = useCallback((speed) => {
|
|
670
|
-
var _a2, _b2;
|
|
671
|
+
var _a2, _b2, _c2, _d2;
|
|
671
672
|
const state = refState.current;
|
|
672
673
|
const {
|
|
673
674
|
data: data2,
|
|
@@ -817,10 +818,14 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
817
818
|
}
|
|
818
819
|
if (furthestIndex >= 0) {
|
|
819
820
|
set$(ctx, `containerItemKey${furthestIndex}`, id);
|
|
821
|
+
const index = (_b2 = refState.current) == null ? void 0 : _b2.indexByKey.get(id);
|
|
822
|
+
set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
|
|
820
823
|
} else {
|
|
821
824
|
const containerId = numContainers;
|
|
822
825
|
numContainers++;
|
|
823
826
|
set$(ctx, `containerItemKey${containerId}`, id);
|
|
827
|
+
const index = (_c2 = refState.current) == null ? void 0 : _c2.indexByKey.get(id);
|
|
828
|
+
set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
|
|
824
829
|
set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
|
|
825
830
|
set$(ctx, `containerColumn${containerId}`, -1);
|
|
826
831
|
if (__DEV__ && numContainers > peek$(ctx, "numContainersPooled")) {
|
|
@@ -840,7 +845,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
840
845
|
}
|
|
841
846
|
for (let i = 0; i < numContainers; i++) {
|
|
842
847
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
843
|
-
const itemIndex = (
|
|
848
|
+
const itemIndex = (_d2 = refState.current) == null ? void 0 : _d2.indexByKey.get(itemKey);
|
|
844
849
|
const item = data2[itemIndex];
|
|
845
850
|
if (item) {
|
|
846
851
|
const id = getId(itemIndex);
|
|
@@ -856,12 +861,16 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
856
861
|
const column2 = columns.get(id) || 1;
|
|
857
862
|
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
858
863
|
const prevColumn = peek$(ctx, `containerColumn${i}`);
|
|
864
|
+
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
859
865
|
if (pos > POSITION_OUT_OF_VIEW && pos !== prevPos) {
|
|
860
866
|
set$(ctx, `containerPosition${i}`, pos);
|
|
861
867
|
}
|
|
862
868
|
if (column2 >= 0 && column2 !== prevColumn) {
|
|
863
869
|
set$(ctx, `containerColumn${i}`, column2);
|
|
864
870
|
}
|
|
871
|
+
if (prevData !== item) {
|
|
872
|
+
set$(ctx, `containerItemData${i}`, data2[itemIndex]);
|
|
873
|
+
}
|
|
865
874
|
}
|
|
866
875
|
}
|
|
867
876
|
}
|
|
@@ -981,6 +990,10 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
981
990
|
}
|
|
982
991
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
983
992
|
if (!isFirst) {
|
|
993
|
+
if (data.length > refState.current.data.length) {
|
|
994
|
+
refState.current.isEndReached = false;
|
|
995
|
+
}
|
|
996
|
+
refState.current.data = data;
|
|
984
997
|
const numContainers = peek$(ctx, "numContainers");
|
|
985
998
|
for (let i = 0; i < numContainers; i++) {
|
|
986
999
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
@@ -1284,7 +1297,16 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1284
1297
|
{
|
|
1285
1298
|
...rest,
|
|
1286
1299
|
horizontal,
|
|
1287
|
-
|
|
1300
|
+
refScrollView: (r) => {
|
|
1301
|
+
refScroller.current = r;
|
|
1302
|
+
if (refScrollView) {
|
|
1303
|
+
if (typeof refScrollView === "function") {
|
|
1304
|
+
refScrollView(r);
|
|
1305
|
+
} else {
|
|
1306
|
+
refScrollView.current = r;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
},
|
|
1288
1310
|
initialContentOffset,
|
|
1289
1311
|
getRenderedItem,
|
|
1290
1312
|
updateItemSize,
|
package/package.json
CHANGED
package/reanimated.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LegendListRef, LegendListPropsBase } from '@legendapp/list';
|
|
2
|
+
import React__default, { ComponentProps } from 'react';
|
|
3
|
+
import Animated from 'react-native-reanimated';
|
|
4
|
+
|
|
5
|
+
type KeysToOmit = "getEstimatedItemSize" | "keyExtractor" | "animatedProps" | "renderItem";
|
|
6
|
+
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Animated.ScrollView>>;
|
|
7
|
+
interface AnimatedLegendListProps<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
|
|
8
|
+
refScrollView?: React__default.Ref<Animated.ScrollView>;
|
|
9
|
+
}
|
|
10
|
+
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
11
|
+
declare const AnimatedLegendList: React__default.ForwardRefExoticComponent<Omit<Omit<AnimatedLegendListProps<unknown>, "refLegendList"> & OtherAnimatedLegendListProps<unknown>, "ref"> & React__default.RefAttributes<LegendListRef>>;
|
|
12
|
+
|
|
13
|
+
export { AnimatedLegendList };
|
package/reanimated.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LegendListRef, LegendListPropsBase } from '@legendapp/list';
|
|
2
|
+
import React__default, { ComponentProps } from 'react';
|
|
3
|
+
import Animated from 'react-native-reanimated';
|
|
4
|
+
|
|
5
|
+
type KeysToOmit = "getEstimatedItemSize" | "keyExtractor" | "animatedProps" | "renderItem";
|
|
6
|
+
type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Animated.ScrollView>>;
|
|
7
|
+
interface AnimatedLegendListProps<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
|
|
8
|
+
refScrollView?: React__default.Ref<Animated.ScrollView>;
|
|
9
|
+
}
|
|
10
|
+
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
11
|
+
declare const AnimatedLegendList: React__default.ForwardRefExoticComponent<Omit<Omit<AnimatedLegendListProps<unknown>, "refLegendList"> & OtherAnimatedLegendListProps<unknown>, "ref"> & React__default.RefAttributes<LegendListRef>>;
|
|
12
|
+
|
|
13
|
+
export { AnimatedLegendList };
|
package/reanimated.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var list = require('@legendapp/list');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var Animated = require('react-native-reanimated');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
10
|
+
var Animated__default = /*#__PURE__*/_interopDefault(Animated);
|
|
11
|
+
|
|
12
|
+
// src/reanimated.tsx
|
|
13
|
+
var LegendListForwardedRef = React__default.default.forwardRef(function LegendListForwardedRef2(props, ref) {
|
|
14
|
+
const { refLegendList, ...rest } = props;
|
|
15
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
16
|
+
list.LegendList,
|
|
17
|
+
{
|
|
18
|
+
refScrollView: ref,
|
|
19
|
+
ref: (r) => {
|
|
20
|
+
refLegendList(r);
|
|
21
|
+
},
|
|
22
|
+
...rest
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
var AnimatedLegendListComponent = Animated__default.default.createAnimatedComponent(LegendListForwardedRef);
|
|
27
|
+
var AnimatedLegendList = React__default.default.forwardRef(function AnimatedLegendList2(props, ref) {
|
|
28
|
+
const { refScrollView, ...rest } = props;
|
|
29
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
30
|
+
AnimatedLegendListComponent,
|
|
31
|
+
{
|
|
32
|
+
refLegendList: (r) => {
|
|
33
|
+
if (ref) {
|
|
34
|
+
if (typeof ref === "function") {
|
|
35
|
+
ref(r);
|
|
36
|
+
} else {
|
|
37
|
+
ref.current = r;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
ref: refScrollView,
|
|
42
|
+
...rest
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
exports.AnimatedLegendList = AnimatedLegendList;
|
package/reanimated.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LegendList } from '@legendapp/list';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Animated from 'react-native-reanimated';
|
|
4
|
+
|
|
5
|
+
// src/reanimated.tsx
|
|
6
|
+
var LegendListForwardedRef = React.forwardRef(function LegendListForwardedRef2(props, ref) {
|
|
7
|
+
const { refLegendList, ...rest } = props;
|
|
8
|
+
return /* @__PURE__ */ React.createElement(
|
|
9
|
+
LegendList,
|
|
10
|
+
{
|
|
11
|
+
refScrollView: ref,
|
|
12
|
+
ref: (r) => {
|
|
13
|
+
refLegendList(r);
|
|
14
|
+
},
|
|
15
|
+
...rest
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
var AnimatedLegendListComponent = Animated.createAnimatedComponent(LegendListForwardedRef);
|
|
20
|
+
var AnimatedLegendList = React.forwardRef(function AnimatedLegendList2(props, ref) {
|
|
21
|
+
const { refScrollView, ...rest } = props;
|
|
22
|
+
return /* @__PURE__ */ React.createElement(
|
|
23
|
+
AnimatedLegendListComponent,
|
|
24
|
+
{
|
|
25
|
+
refLegendList: (r) => {
|
|
26
|
+
if (ref) {
|
|
27
|
+
if (typeof ref === "function") {
|
|
28
|
+
ref(r);
|
|
29
|
+
} else {
|
|
30
|
+
ref.current = r;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
ref: refScrollView,
|
|
35
|
+
...rest
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export { AnimatedLegendList };
|