@legendapp/list 3.0.0-beta.16 → 3.0.0-beta.18
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 +756 -9
- package/index.d.ts +756 -9
- package/index.js +37 -18
- package/index.mjs +36 -19
- package/index.native.js +37 -29
- package/index.native.mjs +36 -30
- package/package.json +1 -1
- package/section-list.d.mts +1 -2
- package/section-list.d.ts +1 -2
- package/section-list.js +25 -3891
- package/section-list.mjs +23 -3890
- package/index.native.d.mts +0 -23
- package/index.native.d.ts +0 -23
- package/section-list.native.d.mts +0 -113
- package/section-list.native.d.ts +0 -113
- package/section-list.native.js +0 -3986
- package/section-list.native.mjs +0 -3965
- package/types-Dj2MEm9V.d.mts +0 -752
- package/types-Dj2MEm9V.d.ts +0 -752
package/index.native.mjs
CHANGED
|
@@ -1113,7 +1113,7 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
|
1113
1113
|
}
|
|
1114
1114
|
}
|
|
1115
1115
|
if (getFixedItemSize) {
|
|
1116
|
-
size = getFixedItemSize(
|
|
1116
|
+
size = getFixedItemSize(data, index, itemType);
|
|
1117
1117
|
if (size !== void 0) {
|
|
1118
1118
|
sizesKnown.set(key, size);
|
|
1119
1119
|
}
|
|
@@ -1131,7 +1131,7 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize) {
|
|
|
1131
1131
|
}
|
|
1132
1132
|
}
|
|
1133
1133
|
if (size === void 0) {
|
|
1134
|
-
size = getEstimatedItemSize ? getEstimatedItemSize(
|
|
1134
|
+
size = getEstimatedItemSize ? getEstimatedItemSize(data, index, itemType) : estimatedItemSize;
|
|
1135
1135
|
}
|
|
1136
1136
|
setSize(ctx, key, size);
|
|
1137
1137
|
return size;
|
|
@@ -1301,7 +1301,7 @@ function scrollTo(ctx, params) {
|
|
|
1301
1301
|
|
|
1302
1302
|
// src/utils/checkThreshold.ts
|
|
1303
1303
|
var HYSTERESIS_MULTIPLIER = 1.3;
|
|
1304
|
-
var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
|
|
1304
|
+
var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot, allowReentryOnChange) => {
|
|
1305
1305
|
const absDistance = Math.abs(distance);
|
|
1306
1306
|
const within = atThreshold || threshold > 0 && absDistance <= threshold;
|
|
1307
1307
|
if (wasReached === null) {
|
|
@@ -1311,7 +1311,7 @@ var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, co
|
|
|
1311
1311
|
return null;
|
|
1312
1312
|
}
|
|
1313
1313
|
const updateSnapshot = () => {
|
|
1314
|
-
setSnapshot
|
|
1314
|
+
setSnapshot({
|
|
1315
1315
|
atThreshold,
|
|
1316
1316
|
contentSize: context.contentSize,
|
|
1317
1317
|
dataLength: context.dataLength,
|
|
@@ -1322,19 +1322,21 @@ var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, co
|
|
|
1322
1322
|
if (!within) {
|
|
1323
1323
|
return false;
|
|
1324
1324
|
}
|
|
1325
|
-
onReached
|
|
1325
|
+
onReached(distance);
|
|
1326
1326
|
updateSnapshot();
|
|
1327
1327
|
return true;
|
|
1328
1328
|
}
|
|
1329
1329
|
const reset = !atThreshold && threshold > 0 && absDistance >= threshold * HYSTERESIS_MULTIPLIER || !atThreshold && threshold <= 0 && absDistance > 0;
|
|
1330
1330
|
if (reset) {
|
|
1331
|
-
setSnapshot
|
|
1331
|
+
setSnapshot(void 0);
|
|
1332
1332
|
return false;
|
|
1333
1333
|
}
|
|
1334
1334
|
if (within) {
|
|
1335
1335
|
const changed = !snapshot || snapshot.atThreshold !== atThreshold || snapshot.contentSize !== context.contentSize || snapshot.dataLength !== context.dataLength;
|
|
1336
1336
|
if (changed) {
|
|
1337
|
-
|
|
1337
|
+
if (allowReentryOnChange) {
|
|
1338
|
+
onReached(distance);
|
|
1339
|
+
}
|
|
1338
1340
|
updateSnapshot();
|
|
1339
1341
|
}
|
|
1340
1342
|
}
|
|
@@ -1377,7 +1379,8 @@ function checkAtBottom(ctx) {
|
|
|
1377
1379
|
},
|
|
1378
1380
|
(snapshot) => {
|
|
1379
1381
|
state.endReachedSnapshot = snapshot;
|
|
1380
|
-
}
|
|
1382
|
+
},
|
|
1383
|
+
true
|
|
1381
1384
|
);
|
|
1382
1385
|
}
|
|
1383
1386
|
}
|
|
@@ -1412,7 +1415,8 @@ function checkAtTop(state) {
|
|
|
1412
1415
|
},
|
|
1413
1416
|
(snapshot) => {
|
|
1414
1417
|
state.startReachedSnapshot = snapshot;
|
|
1415
|
-
}
|
|
1418
|
+
},
|
|
1419
|
+
false
|
|
1416
1420
|
);
|
|
1417
1421
|
}
|
|
1418
1422
|
|
|
@@ -1573,7 +1577,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1573
1577
|
const state = ctx.state;
|
|
1574
1578
|
const { idsInView, positions, props } = state;
|
|
1575
1579
|
const {
|
|
1576
|
-
maintainVisibleContentPosition: { data: mvcpData, size: mvcpScroll }
|
|
1580
|
+
maintainVisibleContentPosition: { data: mvcpData, size: mvcpScroll, shouldRestorePosition }
|
|
1577
1581
|
} = props;
|
|
1578
1582
|
const scrollingTo = state.scrollingTo;
|
|
1579
1583
|
let prevPosition;
|
|
@@ -1608,8 +1612,16 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1608
1612
|
return () => {
|
|
1609
1613
|
let positionDiff = 0;
|
|
1610
1614
|
if (dataChanged && targetId === void 0 && mvcpData) {
|
|
1615
|
+
const data = state.props.data;
|
|
1611
1616
|
for (let i = 0; i < idsInViewWithPositions.length; i++) {
|
|
1612
1617
|
const { id, position } = idsInViewWithPositions[i];
|
|
1618
|
+
const index = indexByKey.get(id);
|
|
1619
|
+
if (index !== void 0 && shouldRestorePosition) {
|
|
1620
|
+
const item = data[index];
|
|
1621
|
+
if (item === void 0 || !shouldRestorePosition(item, index, data)) {
|
|
1622
|
+
continue;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1613
1625
|
const newPosition = positions.get(id);
|
|
1614
1626
|
if (newPosition !== void 0) {
|
|
1615
1627
|
positionDiff = newPosition - position;
|
|
@@ -2265,20 +2277,13 @@ function setDidLayout(ctx) {
|
|
|
2265
2277
|
onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
|
|
2266
2278
|
}
|
|
2267
2279
|
};
|
|
2268
|
-
if (
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
setIt();
|
|
2274
|
-
});
|
|
2275
|
-
} else {
|
|
2276
|
-
scrollToIndex(ctx, { ...initialScroll, animated: false });
|
|
2277
|
-
setIt();
|
|
2278
|
-
}
|
|
2279
|
-
} else {
|
|
2280
|
-
setIt();
|
|
2280
|
+
if ((initialScroll == null ? void 0 : initialScroll.index) !== void 0) {
|
|
2281
|
+
const target = initialScroll;
|
|
2282
|
+
const runScroll = () => scrollToIndex(ctx, { ...target, animated: false });
|
|
2283
|
+
runScroll();
|
|
2284
|
+
requestAnimationFrame(runScroll);
|
|
2281
2285
|
}
|
|
2286
|
+
setIt();
|
|
2282
2287
|
}
|
|
2283
2288
|
|
|
2284
2289
|
// src/core/calculateItemsInView.ts
|
|
@@ -2848,7 +2853,7 @@ function doInitialAllocateContainers(ctx) {
|
|
|
2848
2853
|
const item = data[i];
|
|
2849
2854
|
if (item !== void 0) {
|
|
2850
2855
|
const itemType = (_a3 = getItemType == null ? void 0 : getItemType(item, i)) != null ? _a3 : "";
|
|
2851
|
-
totalSize += (_c = (_b = getFixedItemSize == null ? void 0 : getFixedItemSize(
|
|
2856
|
+
totalSize += (_c = (_b = getFixedItemSize == null ? void 0 : getFixedItemSize(item, i, itemType)) != null ? _b : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(item, i, itemType)) != null ? _c : estimatedItemSize;
|
|
2852
2857
|
}
|
|
2853
2858
|
}
|
|
2854
2859
|
averageItemSize = totalSize / num;
|
|
@@ -3035,7 +3040,7 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
3035
3040
|
return;
|
|
3036
3041
|
}
|
|
3037
3042
|
const type = getItemType ? (_a3 = getItemType(itemData, index)) != null ? _a3 : "" : "";
|
|
3038
|
-
const size2 = getFixedItemSize(
|
|
3043
|
+
const size2 = getFixedItemSize(itemData, index, type);
|
|
3039
3044
|
if (size2 !== void 0 && size2 === sizesKnown.get(itemKey)) {
|
|
3040
3045
|
return;
|
|
3041
3046
|
}
|
|
@@ -3333,7 +3338,8 @@ function normalizeMaintainVisibleContentPosition(value) {
|
|
|
3333
3338
|
if (value && typeof value === "object") {
|
|
3334
3339
|
return {
|
|
3335
3340
|
data: (_a3 = value.data) != null ? _a3 : false,
|
|
3336
|
-
size: (_b = value.size) != null ? _b : true
|
|
3341
|
+
size: (_b = value.size) != null ? _b : true,
|
|
3342
|
+
shouldRestorePosition: value.shouldRestorePosition
|
|
3337
3343
|
};
|
|
3338
3344
|
}
|
|
3339
3345
|
if (value === false) {
|
|
@@ -3478,7 +3484,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3478
3484
|
maintainVisibleContentPositionProp
|
|
3479
3485
|
);
|
|
3480
3486
|
const [renderNum, setRenderNum] = useState(0);
|
|
3481
|
-
const initialScrollProp = initialScrollAtEnd ? { index: Math.max(0, dataProp.length - 1), viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
|
|
3487
|
+
const initialScrollProp = initialScrollAtEnd ? { index: Math.max(0, dataProp.length - 1), viewOffset: -stylePaddingBottomState, viewPosition: 1 } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
|
|
3482
3488
|
const [canRender, setCanRender] = React2.useState(!IsNewArchitecture);
|
|
3483
3489
|
const ctx = useStateContext();
|
|
3484
3490
|
ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
|
|
@@ -3704,8 +3710,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3704
3710
|
}
|
|
3705
3711
|
}, []);
|
|
3706
3712
|
const doInitialScroll = useCallback(() => {
|
|
3707
|
-
const initialScroll = state
|
|
3708
|
-
if (initialScroll) {
|
|
3713
|
+
const { initialScroll, didFinishInitialScroll, queuedInitialLayout, scrollingTo } = state;
|
|
3714
|
+
if (initialScroll && !queuedInitialLayout && !didFinishInitialScroll && !scrollingTo) {
|
|
3709
3715
|
scrollTo(ctx, {
|
|
3710
3716
|
animated: false,
|
|
3711
3717
|
index: initialScroll == null ? void 0 : initialScroll.index,
|
|
@@ -3829,4 +3835,4 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3829
3835
|
), IS_DEV && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React2.createElement(DebugView, { state: refState.current }));
|
|
3830
3836
|
});
|
|
3831
3837
|
|
|
3832
|
-
export { LegendList, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
|
|
3838
|
+
export { LegendList, typedForwardRef, typedMemo, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/list",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.18",
|
|
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/section-list.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as react_native from 'react-native';
|
|
2
2
|
import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import 'react-native-reanimated';
|
|
4
|
+
import { LegendListRef, LegendListProps } from '@legendapp/list';
|
|
6
5
|
|
|
7
6
|
type SectionListSeparatorProps<ItemT, SectionT> = {
|
|
8
7
|
leadingItem?: ItemT;
|
package/section-list.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as react_native from 'react-native';
|
|
2
2
|
import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import 'react-native-reanimated';
|
|
4
|
+
import { LegendListRef, LegendListProps } from '@legendapp/list';
|
|
6
5
|
|
|
7
6
|
type SectionListSeparatorProps<ItemT, SectionT> = {
|
|
8
7
|
leadingItem?: ItemT;
|