@legendapp/list 2.1.0-beta.11 → 2.1.0-beta.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/index.d.mts +8 -664
- package/index.d.ts +8 -664
- package/index.js +175 -136
- package/index.mjs +175 -136
- package/index.native.d.mts +8 -664
- package/index.native.d.ts +8 -664
- package/index.native.js +154 -135
- package/index.native.mjs +154 -135
- package/package.json +1 -1
- package/section-list.d.mts +113 -0
- package/section-list.d.ts +113 -0
- package/section-list.js +3924 -0
- package/section-list.mjs +3903 -0
- package/section-list.native.d.mts +113 -0
- package/section-list.native.d.ts +113 -0
- package/section-list.native.js +3703 -0
- package/section-list.native.mjs +3682 -0
- package/types-JPHClxiw.d.mts +670 -0
- package/types-JPHClxiw.d.ts +670 -0
- package/types-YNdphn_A.d.mts +670 -0
- package/types-YNdphn_A.d.ts +670 -0
package/index.native.mjs
CHANGED
|
@@ -811,7 +811,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
811
811
|
scrollAdjustHandler,
|
|
812
812
|
onLayoutHeader,
|
|
813
813
|
snapToIndices,
|
|
814
|
-
|
|
814
|
+
stickyHeaderIndices,
|
|
815
815
|
...rest
|
|
816
816
|
}) {
|
|
817
817
|
const ctx = useStateContext();
|
|
@@ -846,7 +846,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
846
846
|
ScrollComponent: snapToIndices ? ScrollComponent : void 0,
|
|
847
847
|
style
|
|
848
848
|
},
|
|
849
|
-
|
|
849
|
+
/* @__PURE__ */ React2.createElement(ScrollAdjust, null),
|
|
850
850
|
ENABLE_DEVMODE ? /* @__PURE__ */ React2.createElement(PaddingDevMode, null) : /* @__PURE__ */ React2.createElement(Padding, null),
|
|
851
851
|
ListHeaderComponent && /* @__PURE__ */ React2.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
|
|
852
852
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
@@ -1039,6 +1039,70 @@ function calculateOffsetWithOffsetPosition(ctx, state, offsetParam, params) {
|
|
|
1039
1039
|
return offset;
|
|
1040
1040
|
}
|
|
1041
1041
|
|
|
1042
|
+
// src/core/finishScrollTo.ts
|
|
1043
|
+
function finishScrollTo(ctx, state) {
|
|
1044
|
+
var _a3, _b;
|
|
1045
|
+
if (state) {
|
|
1046
|
+
state.scrollHistory.length = 0;
|
|
1047
|
+
state.initialScroll = void 0;
|
|
1048
|
+
state.initialAnchor = void 0;
|
|
1049
|
+
set$(ctx, "scrollingTo", void 0);
|
|
1050
|
+
if (state.pendingTotalSize !== void 0) {
|
|
1051
|
+
addTotalSize(ctx, state, null, state.pendingTotalSize);
|
|
1052
|
+
}
|
|
1053
|
+
if ((_a3 = state.props) == null ? void 0 : _a3.data) {
|
|
1054
|
+
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
var Platform2 = Platform;
|
|
1059
|
+
|
|
1060
|
+
// src/core/scrollTo.ts
|
|
1061
|
+
function scrollTo(ctx, state, params) {
|
|
1062
|
+
var _a3;
|
|
1063
|
+
const { noScrollingTo, ...scrollTarget } = params;
|
|
1064
|
+
const { animated, isInitialScroll, offset: scrollTargetOffset, precomputedWithViewOffset } = scrollTarget;
|
|
1065
|
+
const {
|
|
1066
|
+
refScroller,
|
|
1067
|
+
props: { horizontal }
|
|
1068
|
+
} = state;
|
|
1069
|
+
let offset = precomputedWithViewOffset ? scrollTargetOffset : calculateOffsetWithOffsetPosition(ctx, state, scrollTargetOffset, scrollTarget);
|
|
1070
|
+
if (Number.isFinite(state.scrollLength) && Number.isFinite(state.totalSize)) {
|
|
1071
|
+
const maxOffset = Math.max(0, getContentSize(ctx) - state.scrollLength);
|
|
1072
|
+
offset = Math.min(offset, maxOffset);
|
|
1073
|
+
}
|
|
1074
|
+
state.scrollHistory.length = 0;
|
|
1075
|
+
if (!noScrollingTo) {
|
|
1076
|
+
set$(ctx, "scrollingTo", scrollTarget);
|
|
1077
|
+
}
|
|
1078
|
+
state.scrollPending = offset;
|
|
1079
|
+
if (!isInitialScroll || Platform2.OS === "android") {
|
|
1080
|
+
(_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
|
|
1081
|
+
animated: !!animated,
|
|
1082
|
+
x: horizontal ? offset : 0,
|
|
1083
|
+
y: horizontal ? 0 : offset
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
if (!animated) {
|
|
1087
|
+
state.scroll = offset;
|
|
1088
|
+
if (Platform2.OS === "web") {
|
|
1089
|
+
const unlisten = listen$(ctx, "containersDidLayout", (value) => {
|
|
1090
|
+
if (value && peek$(ctx, "scrollingTo")) {
|
|
1091
|
+
finishScrollTo(ctx, state);
|
|
1092
|
+
unlisten();
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1095
|
+
} else {
|
|
1096
|
+
setTimeout(() => finishScrollTo(ctx, state), 100);
|
|
1097
|
+
}
|
|
1098
|
+
if (isInitialScroll) {
|
|
1099
|
+
setTimeout(() => {
|
|
1100
|
+
state.initialScroll = void 0;
|
|
1101
|
+
}, 500);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1042
1106
|
// src/utils/checkThreshold.ts
|
|
1043
1107
|
var HYSTERESIS_MULTIPLIER = 1.3;
|
|
1044
1108
|
var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
|
|
@@ -1149,24 +1213,7 @@ function checkAtTop(state) {
|
|
|
1149
1213
|
);
|
|
1150
1214
|
}
|
|
1151
1215
|
|
|
1152
|
-
// src/core/
|
|
1153
|
-
function onScroll(ctx, state, event) {
|
|
1154
|
-
var _a3, _b, _c;
|
|
1155
|
-
const {
|
|
1156
|
-
scrollProcessingEnabled,
|
|
1157
|
-
props: { onScroll: onScrollProp }
|
|
1158
|
-
} = state;
|
|
1159
|
-
if (scrollProcessingEnabled === false) {
|
|
1160
|
-
return;
|
|
1161
|
-
}
|
|
1162
|
-
if (((_b = (_a3 = event.nativeEvent) == null ? void 0 : _a3.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
|
|
1163
|
-
return;
|
|
1164
|
-
}
|
|
1165
|
-
const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
1166
|
-
state.scrollPending = newScroll;
|
|
1167
|
-
updateScroll(ctx, state, newScroll);
|
|
1168
|
-
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
1169
|
-
}
|
|
1216
|
+
// src/core/updateScroll.ts
|
|
1170
1217
|
function updateScroll(ctx, state, newScroll, forceUpdate) {
|
|
1171
1218
|
var _a3;
|
|
1172
1219
|
const scrollingTo = peek$(ctx, "scrollingTo");
|
|
@@ -1209,61 +1256,6 @@ function updateScroll(ctx, state, newScroll, forceUpdate) {
|
|
|
1209
1256
|
}
|
|
1210
1257
|
}
|
|
1211
1258
|
|
|
1212
|
-
// src/core/finishScrollTo.ts
|
|
1213
|
-
function finishScrollTo(ctx, state) {
|
|
1214
|
-
var _a3, _b;
|
|
1215
|
-
if (state) {
|
|
1216
|
-
state.scrollHistory.length = 0;
|
|
1217
|
-
state.initialScroll = void 0;
|
|
1218
|
-
state.initialAnchor = void 0;
|
|
1219
|
-
set$(ctx, "scrollingTo", void 0);
|
|
1220
|
-
if (state.pendingTotalSize !== void 0) {
|
|
1221
|
-
addTotalSize(ctx, state, null, state.pendingTotalSize);
|
|
1222
|
-
}
|
|
1223
|
-
if ((_a3 = state.props) == null ? void 0 : _a3.data) {
|
|
1224
|
-
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
var Platform2 = Platform;
|
|
1229
|
-
|
|
1230
|
-
// src/core/scrollTo.ts
|
|
1231
|
-
function scrollTo(ctx, state, params) {
|
|
1232
|
-
var _a3;
|
|
1233
|
-
const { noScrollingTo, ...scrollTarget } = params;
|
|
1234
|
-
const { animated, isInitialScroll, offset: scrollTargetOffset, precomputedWithViewOffset } = scrollTarget;
|
|
1235
|
-
const {
|
|
1236
|
-
refScroller,
|
|
1237
|
-
props: { horizontal }
|
|
1238
|
-
} = state;
|
|
1239
|
-
let offset = precomputedWithViewOffset ? scrollTargetOffset : calculateOffsetWithOffsetPosition(ctx, state, scrollTargetOffset, scrollTarget);
|
|
1240
|
-
if (Number.isFinite(state.scrollLength) && Number.isFinite(state.totalSize)) {
|
|
1241
|
-
const maxOffset = Math.max(0, getContentSize(ctx) - state.scrollLength);
|
|
1242
|
-
offset = Math.min(offset, maxOffset);
|
|
1243
|
-
}
|
|
1244
|
-
state.scrollHistory.length = 0;
|
|
1245
|
-
if (!noScrollingTo) {
|
|
1246
|
-
set$(ctx, "scrollingTo", scrollTarget);
|
|
1247
|
-
}
|
|
1248
|
-
state.scrollPending = offset;
|
|
1249
|
-
if (!isInitialScroll || Platform2.OS === "android") {
|
|
1250
|
-
(_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
|
|
1251
|
-
animated: !!animated,
|
|
1252
|
-
x: horizontal ? offset : 0,
|
|
1253
|
-
y: horizontal ? 0 : offset
|
|
1254
|
-
});
|
|
1255
|
-
}
|
|
1256
|
-
if (!animated) {
|
|
1257
|
-
state.scroll = offset;
|
|
1258
|
-
setTimeout(() => finishScrollTo(ctx, state), 100);
|
|
1259
|
-
if (isInitialScroll) {
|
|
1260
|
-
setTimeout(() => {
|
|
1261
|
-
state.initialScroll = void 0;
|
|
1262
|
-
}, 500);
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
1259
|
// src/utils/requestAdjust.ts
|
|
1268
1260
|
function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
1269
1261
|
if (Math.abs(positionDiff) > 0.1) {
|
|
@@ -1276,6 +1268,9 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
|
1276
1268
|
});
|
|
1277
1269
|
} else {
|
|
1278
1270
|
state.scrollAdjustHandler.requestAdjust(positionDiff);
|
|
1271
|
+
if (state.adjustingFromInitialMount) {
|
|
1272
|
+
state.adjustingFromInitialMount--;
|
|
1273
|
+
}
|
|
1279
1274
|
}
|
|
1280
1275
|
};
|
|
1281
1276
|
state.scroll += positionDiff;
|
|
@@ -1308,6 +1303,7 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
|
1308
1303
|
}, delay);
|
|
1309
1304
|
}
|
|
1310
1305
|
} else {
|
|
1306
|
+
state.adjustingFromInitialMount = (state.adjustingFromInitialMount || 0) + 1;
|
|
1311
1307
|
requestAnimationFrame(doit);
|
|
1312
1308
|
}
|
|
1313
1309
|
}
|
|
@@ -1367,18 +1363,16 @@ function ensureInitialAnchor(ctx, state) {
|
|
|
1367
1363
|
|
|
1368
1364
|
// src/core/mvcp.ts
|
|
1369
1365
|
function prepareMVCP(ctx, state, dataChanged) {
|
|
1370
|
-
const {
|
|
1371
|
-
|
|
1372
|
-
positions,
|
|
1373
|
-
props: { maintainVisibleContentPosition }
|
|
1374
|
-
} = state;
|
|
1366
|
+
const { idsInView, positions, props } = state;
|
|
1367
|
+
const { maintainVisibleContentPosition } = props;
|
|
1375
1368
|
const scrollingTo = peek$(ctx, "scrollingTo");
|
|
1376
1369
|
let prevPosition;
|
|
1377
1370
|
let targetId;
|
|
1378
1371
|
const idsInViewWithPositions = [];
|
|
1379
1372
|
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
1380
|
-
|
|
1381
|
-
|
|
1373
|
+
const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
|
|
1374
|
+
const indexByKey = state.indexByKey;
|
|
1375
|
+
if (shouldMVCP) {
|
|
1382
1376
|
if (scrollTarget !== void 0) {
|
|
1383
1377
|
if (!IsNewArchitecture && (scrollingTo == null ? void 0 : scrollingTo.isInitialScroll)) {
|
|
1384
1378
|
return void 0;
|
|
@@ -1394,44 +1388,44 @@ function prepareMVCP(ctx, state, dataChanged) {
|
|
|
1394
1388
|
}
|
|
1395
1389
|
}
|
|
1396
1390
|
} else {
|
|
1397
|
-
targetId =
|
|
1391
|
+
targetId = idsInView.find((id) => indexByKey.get(id) !== void 0);
|
|
1398
1392
|
}
|
|
1399
1393
|
}
|
|
1400
1394
|
if (targetId !== void 0) {
|
|
1401
1395
|
prevPosition = positions.get(targetId);
|
|
1402
1396
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1397
|
+
return () => {
|
|
1398
|
+
let positionDiff;
|
|
1399
|
+
if (dataChanged && targetId === void 0 && maintainVisibleContentPosition) {
|
|
1400
|
+
for (let i = 0; i < idsInViewWithPositions.length; i++) {
|
|
1401
|
+
const { id, position } = idsInViewWithPositions[i];
|
|
1402
|
+
const newPosition = positions.get(id);
|
|
1403
|
+
if (newPosition !== void 0) {
|
|
1404
|
+
positionDiff = newPosition - position;
|
|
1405
|
+
break;
|
|
1406
|
+
}
|
|
1413
1407
|
}
|
|
1414
1408
|
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1409
|
+
if (targetId !== void 0 && prevPosition !== void 0) {
|
|
1410
|
+
const newPosition = positions.get(targetId);
|
|
1411
|
+
if (newPosition !== void 0) {
|
|
1412
|
+
const totalSize = getContentSize(ctx);
|
|
1413
|
+
let diff = newPosition - prevPosition;
|
|
1414
|
+
if (diff !== 0 && state.scroll + state.scrollLength > totalSize) {
|
|
1415
|
+
if (diff > 0) {
|
|
1416
|
+
diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
|
|
1417
|
+
} else {
|
|
1418
|
+
diff = 0;
|
|
1419
|
+
}
|
|
1426
1420
|
}
|
|
1421
|
+
positionDiff = diff;
|
|
1427
1422
|
}
|
|
1428
|
-
positionDiff = diff;
|
|
1429
1423
|
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1424
|
+
if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
|
|
1425
|
+
requestAdjust(ctx, state, positionDiff, dataChanged && maintainVisibleContentPosition);
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
}
|
|
1435
1429
|
}
|
|
1436
1430
|
|
|
1437
1431
|
// src/core/prepareColumnStartState.ts
|
|
@@ -1573,7 +1567,8 @@ function updateSnapToOffsets(ctx, state) {
|
|
|
1573
1567
|
}
|
|
1574
1568
|
|
|
1575
1569
|
// src/core/updateItemPositions.ts
|
|
1576
|
-
function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false } = {
|
|
1570
|
+
function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false, doMVCP } = {
|
|
1571
|
+
doMVCP: false,
|
|
1577
1572
|
forceFullUpdate: false,
|
|
1578
1573
|
scrollBottomBuffered: -1,
|
|
1579
1574
|
startIndex: 0
|
|
@@ -1585,7 +1580,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1585
1580
|
positions,
|
|
1586
1581
|
idCache,
|
|
1587
1582
|
sizesKnown,
|
|
1588
|
-
props: { getEstimatedItemSize, snapToIndices, enableAverages
|
|
1583
|
+
props: { getEstimatedItemSize, snapToIndices, enableAverages }
|
|
1589
1584
|
} = state;
|
|
1590
1585
|
const data = state.props.data;
|
|
1591
1586
|
const dataLength = data.length;
|
|
@@ -1596,7 +1591,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1596
1591
|
const shouldOptimize = !forceFullUpdate && !dataChanged && Math.abs(getScrollVelocity(state)) > 0;
|
|
1597
1592
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
1598
1593
|
const useAverageSize = enableAverages && !getEstimatedItemSize;
|
|
1599
|
-
const preferCachedSize =
|
|
1594
|
+
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_a3 = peek$(ctx, "scrollAdjustPending")) != null ? _a3 : 0) !== 0;
|
|
1600
1595
|
let currentRowTop = 0;
|
|
1601
1596
|
let column = 1;
|
|
1602
1597
|
let maxSizeInRow = 0;
|
|
@@ -2062,14 +2057,14 @@ function findCurrentStickyIndex(stickyArray, scroll, state) {
|
|
|
2062
2057
|
}
|
|
2063
2058
|
return -1;
|
|
2064
2059
|
}
|
|
2065
|
-
function getActiveStickyIndices(ctx, state,
|
|
2060
|
+
function getActiveStickyIndices(ctx, state, stickyHeaderIndices) {
|
|
2066
2061
|
return new Set(
|
|
2067
|
-
Array.from(state.stickyContainerPool).map((i) => peek$(ctx, `containerItemKey${i}`)).map((key) => key ? state.indexByKey.get(key) : void 0).filter((idx) => idx !== void 0 &&
|
|
2062
|
+
Array.from(state.stickyContainerPool).map((i) => peek$(ctx, `containerItemKey${i}`)).map((key) => key ? state.indexByKey.get(key) : void 0).filter((idx) => idx !== void 0 && stickyHeaderIndices.has(idx))
|
|
2068
2063
|
);
|
|
2069
2064
|
}
|
|
2070
|
-
function handleStickyActivation(ctx, state,
|
|
2065
|
+
function handleStickyActivation(ctx, state, stickyHeaderIndices, stickyArray, currentStickyIdx, needNewContainers, startBuffered, endBuffered) {
|
|
2071
2066
|
var _a3;
|
|
2072
|
-
const activeIndices = getActiveStickyIndices(ctx, state,
|
|
2067
|
+
const activeIndices = getActiveStickyIndices(ctx, state, stickyHeaderIndices);
|
|
2073
2068
|
state.activeStickyIndex = currentStickyIdx >= 0 ? stickyArray[currentStickyIdx] : void 0;
|
|
2074
2069
|
for (let offset = 0; offset <= 1; offset++) {
|
|
2075
2070
|
const idx = currentStickyIdx - offset;
|
|
@@ -2205,6 +2200,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2205
2200
|
}
|
|
2206
2201
|
const startIndex = dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
|
|
2207
2202
|
updateItemPositions(ctx, state, dataChanged, {
|
|
2203
|
+
doMVCP,
|
|
2208
2204
|
forceFullUpdate: !!forceFullItemPositions,
|
|
2209
2205
|
scrollBottomBuffered,
|
|
2210
2206
|
startIndex
|
|
@@ -2499,6 +2495,7 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
|
|
|
2499
2495
|
});
|
|
2500
2496
|
return true;
|
|
2501
2497
|
}
|
|
2498
|
+
return false;
|
|
2502
2499
|
}
|
|
2503
2500
|
|
|
2504
2501
|
// src/utils/updateAveragesOnDataChange.ts
|
|
@@ -2667,6 +2664,25 @@ function handleLayout(ctx, state, layout, setCanRender) {
|
|
|
2667
2664
|
setCanRender(true);
|
|
2668
2665
|
}
|
|
2669
2666
|
|
|
2667
|
+
// src/core/onScroll.ts
|
|
2668
|
+
function onScroll(ctx, state, event) {
|
|
2669
|
+
var _a3, _b, _c;
|
|
2670
|
+
const {
|
|
2671
|
+
scrollProcessingEnabled,
|
|
2672
|
+
props: { onScroll: onScrollProp }
|
|
2673
|
+
} = state;
|
|
2674
|
+
if (scrollProcessingEnabled === false) {
|
|
2675
|
+
return;
|
|
2676
|
+
}
|
|
2677
|
+
if (((_b = (_a3 = event.nativeEvent) == null ? void 0 : _a3.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
|
|
2678
|
+
return;
|
|
2679
|
+
}
|
|
2680
|
+
const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
2681
|
+
state.scrollPending = newScroll;
|
|
2682
|
+
updateScroll(ctx, state, newScroll);
|
|
2683
|
+
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2670
2686
|
// src/core/ScrollAdjustHandler.ts
|
|
2671
2687
|
var ScrollAdjustHandler = class {
|
|
2672
2688
|
constructor(ctx) {
|
|
@@ -2702,12 +2718,7 @@ var ScrollAdjustHandler = class {
|
|
|
2702
2718
|
set$(this.context, "scrollAdjustPending", this.pendingAdjust);
|
|
2703
2719
|
} else {
|
|
2704
2720
|
this.appliedAdjust += add;
|
|
2705
|
-
|
|
2706
|
-
if (this.mounted) {
|
|
2707
|
-
setter();
|
|
2708
|
-
} else {
|
|
2709
|
-
requestAnimationFrame(setter);
|
|
2710
|
-
}
|
|
2721
|
+
set$(this.context, "scrollAdjust", this.appliedAdjust);
|
|
2711
2722
|
}
|
|
2712
2723
|
}
|
|
2713
2724
|
setMounted() {
|
|
@@ -2869,9 +2880,9 @@ function getWindowSize() {
|
|
|
2869
2880
|
};
|
|
2870
2881
|
}
|
|
2871
2882
|
var StyleSheet = StyleSheet$1;
|
|
2872
|
-
function useStickyScrollHandler(
|
|
2883
|
+
function useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, onScroll2) {
|
|
2873
2884
|
return useMemo(() => {
|
|
2874
|
-
if (
|
|
2885
|
+
if (stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.length) {
|
|
2875
2886
|
const { animatedScrollY } = ctx;
|
|
2876
2887
|
return Animated.event(
|
|
2877
2888
|
[
|
|
@@ -2888,7 +2899,7 @@ function useStickyScrollHandler(stickyIndices, horizontal, ctx, onScroll2) {
|
|
|
2888
2899
|
);
|
|
2889
2900
|
}
|
|
2890
2901
|
return onScroll2;
|
|
2891
|
-
}, [
|
|
2902
|
+
}, [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(","), horizontal]);
|
|
2892
2903
|
}
|
|
2893
2904
|
|
|
2894
2905
|
// src/utils/createColumnWrapperStyle.ts
|
|
@@ -3110,7 +3121,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3110
3121
|
ListHeaderComponent,
|
|
3111
3122
|
maintainScrollAtEnd = false,
|
|
3112
3123
|
maintainScrollAtEndThreshold = 0.1,
|
|
3113
|
-
maintainVisibleContentPosition =
|
|
3124
|
+
maintainVisibleContentPosition = false,
|
|
3114
3125
|
numColumns: numColumnsProp = 1,
|
|
3115
3126
|
onEndReached,
|
|
3116
3127
|
onEndReachedThreshold = 0.5,
|
|
@@ -3132,7 +3143,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3132
3143
|
renderItem,
|
|
3133
3144
|
scrollEventThrottle,
|
|
3134
3145
|
snapToIndices,
|
|
3135
|
-
|
|
3146
|
+
stickyHeaderIndices: stickyHeaderIndicesProp,
|
|
3147
|
+
stickyIndices: stickyIndicesDeprecated,
|
|
3136
3148
|
style: styleProp,
|
|
3137
3149
|
suggestEstimatedItemSize,
|
|
3138
3150
|
viewabilityConfig,
|
|
@@ -3154,6 +3166,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3154
3166
|
const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
|
|
3155
3167
|
const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
|
|
3156
3168
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (_item, index) => index.toString();
|
|
3169
|
+
const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
|
|
3170
|
+
if (IS_DEV && stickyIndicesDeprecated && !stickyHeaderIndicesProp) {
|
|
3171
|
+
warnDevOnce(
|
|
3172
|
+
"stickyIndices",
|
|
3173
|
+
"stickyIndices has been renamed to stickyHeaderIndices. Please update your props to use stickyHeaderIndices."
|
|
3174
|
+
);
|
|
3175
|
+
}
|
|
3157
3176
|
const refState = useRef();
|
|
3158
3177
|
if (!refState.current) {
|
|
3159
3178
|
if (!ctx.internalState) {
|
|
@@ -3265,8 +3284,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3265
3284
|
renderItem,
|
|
3266
3285
|
scrollBuffer,
|
|
3267
3286
|
snapToIndices,
|
|
3268
|
-
stickyIndicesArr:
|
|
3269
|
-
stickyIndicesSet: useMemo(() => new Set(
|
|
3287
|
+
stickyIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
|
|
3288
|
+
stickyIndicesSet: useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
|
|
3270
3289
|
stylePaddingBottom: stylePaddingBottomState,
|
|
3271
3290
|
stylePaddingTop: stylePaddingTopState,
|
|
3272
3291
|
suggestEstimatedItemSize: !!suggestEstimatedItemSize
|
|
@@ -3286,7 +3305,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3286
3305
|
setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
|
|
3287
3306
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
3288
3307
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
3289
|
-
if (
|
|
3308
|
+
if (paddingDiff && prevPaddingTop !== void 0 && Platform2.OS === "ios") {
|
|
3290
3309
|
if (state.scroll < 0) {
|
|
3291
3310
|
paddingDiff += state.scroll;
|
|
3292
3311
|
}
|
|
@@ -3334,7 +3353,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3334
3353
|
state.initialScroll = updatedInitialScroll;
|
|
3335
3354
|
refState.current.isStartReached = clampedOffset < refState.current.scrollLength * onStartReachedThreshold;
|
|
3336
3355
|
return clampedOffset;
|
|
3337
|
-
}, [renderNum
|
|
3356
|
+
}, [renderNum]);
|
|
3338
3357
|
if (isFirstLocal || didDataChangeLocal || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
3339
3358
|
refState.current.lastBatchingAction = Date.now();
|
|
3340
3359
|
if (!keyExtractorProp && !isFirstLocal && didDataChangeLocal) {
|
|
@@ -3374,7 +3393,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3374
3393
|
precomputedWithViewOffset: true
|
|
3375
3394
|
});
|
|
3376
3395
|
}
|
|
3377
|
-
}, [initialContentOffset
|
|
3396
|
+
}, [initialContentOffset]);
|
|
3378
3397
|
const onLayoutChange = useCallback((layout) => {
|
|
3379
3398
|
doInitialScroll();
|
|
3380
3399
|
handleLayout(ctx, state, layout, setCanRender);
|
|
@@ -3441,7 +3460,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3441
3460
|
}),
|
|
3442
3461
|
[]
|
|
3443
3462
|
);
|
|
3444
|
-
const onScrollHandler = useStickyScrollHandler(
|
|
3463
|
+
const onScrollHandler = useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, fns.onScroll);
|
|
3445
3464
|
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
3446
3465
|
ListComponent,
|
|
3447
3466
|
{
|
|
@@ -3487,7 +3506,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3487
3506
|
scrollAdjustHandler: (_b = refState.current) == null ? void 0 : _b.scrollAdjustHandler,
|
|
3488
3507
|
scrollEventThrottle: Platform2.OS === "web" ? 16 : void 0,
|
|
3489
3508
|
snapToIndices,
|
|
3490
|
-
|
|
3509
|
+
stickyHeaderIndices,
|
|
3491
3510
|
style,
|
|
3492
3511
|
updateItemSize: fns.updateItemSize,
|
|
3493
3512
|
waitForInitialLayout
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/list",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.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,
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as react_native from 'react-native';
|
|
2
|
+
import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { a as LegendListRef, L as LegendListProps } from './types-JPHClxiw.mjs';
|
|
5
|
+
import 'react-native-reanimated';
|
|
6
|
+
|
|
7
|
+
type SectionListSeparatorProps<ItemT, SectionT> = {
|
|
8
|
+
leadingItem?: ItemT;
|
|
9
|
+
leadingSection?: SectionListData<ItemT, SectionT>;
|
|
10
|
+
section: SectionListData<ItemT, SectionT>;
|
|
11
|
+
trailingItem?: ItemT;
|
|
12
|
+
trailingSection?: SectionListData<ItemT, SectionT>;
|
|
13
|
+
};
|
|
14
|
+
type SectionHeaderItem<SectionT> = {
|
|
15
|
+
kind: "header";
|
|
16
|
+
key: string;
|
|
17
|
+
section: SectionT;
|
|
18
|
+
sectionIndex: number;
|
|
19
|
+
};
|
|
20
|
+
type SectionFooterItem<SectionT> = {
|
|
21
|
+
kind: "footer";
|
|
22
|
+
key: string;
|
|
23
|
+
section: SectionT;
|
|
24
|
+
sectionIndex: number;
|
|
25
|
+
};
|
|
26
|
+
type SectionBodyItem<ItemT, SectionT> = {
|
|
27
|
+
kind: "item";
|
|
28
|
+
key: string;
|
|
29
|
+
section: SectionT;
|
|
30
|
+
sectionIndex: number;
|
|
31
|
+
item: ItemT;
|
|
32
|
+
itemIndex: number;
|
|
33
|
+
absoluteItemIndex: number;
|
|
34
|
+
};
|
|
35
|
+
type SectionItemSeparator<ItemT, SectionT> = {
|
|
36
|
+
kind: "item-separator";
|
|
37
|
+
key: string;
|
|
38
|
+
section: SectionT;
|
|
39
|
+
sectionIndex: number;
|
|
40
|
+
leadingItem: ItemT;
|
|
41
|
+
leadingItemIndex: number;
|
|
42
|
+
trailingItem?: ItemT;
|
|
43
|
+
};
|
|
44
|
+
type SectionSeparator<SectionT> = {
|
|
45
|
+
kind: "section-separator";
|
|
46
|
+
key: string;
|
|
47
|
+
leadingSection: SectionT;
|
|
48
|
+
leadingSectionIndex: number;
|
|
49
|
+
trailingSection?: SectionT;
|
|
50
|
+
};
|
|
51
|
+
type FlatSectionListItem<ItemT, SectionT> = SectionHeaderItem<SectionT> | SectionFooterItem<SectionT> | SectionBodyItem<ItemT, SectionT> | SectionItemSeparator<ItemT, SectionT> | SectionSeparator<SectionT>;
|
|
52
|
+
type SectionMeta = {
|
|
53
|
+
header?: number;
|
|
54
|
+
footer?: number;
|
|
55
|
+
items: number[];
|
|
56
|
+
};
|
|
57
|
+
type BuildSectionListDataResult<ItemT, SectionT> = {
|
|
58
|
+
data: Array<FlatSectionListItem<ItemT, SectionT>>;
|
|
59
|
+
sectionMeta: SectionMeta[];
|
|
60
|
+
stickyHeaderIndices: number[];
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type SectionListViewToken<ItemT, SectionT> = {
|
|
64
|
+
item: ItemT;
|
|
65
|
+
key: string;
|
|
66
|
+
index: number;
|
|
67
|
+
isViewable: boolean;
|
|
68
|
+
section: SectionListData<ItemT, SectionT>;
|
|
69
|
+
};
|
|
70
|
+
type SectionListOnViewableItemsChanged<ItemT, SectionT> = ((info: {
|
|
71
|
+
viewableItems: Array<SectionListViewToken<ItemT, SectionT>>;
|
|
72
|
+
changed: Array<SectionListViewToken<ItemT, SectionT>>;
|
|
73
|
+
}) => void) | null;
|
|
74
|
+
type SectionListLegendProps<ItemT, SectionT> = Omit<LegendListProps<FlatSectionListItem<ItemT, SectionT>>, "data" | "children" | "renderItem" | "keyExtractor" | "ItemSeparatorComponent" | "getItemType" | "getFixedItemSize" | "stickyHeaderIndices" | "numColumns" | "columnWrapperStyle" | "onViewableItemsChanged">;
|
|
75
|
+
type SectionListProps<ItemT, SectionT extends SectionBase<ItemT> = SectionBase<ItemT>> = SectionListLegendProps<ItemT, SectionT> & {
|
|
76
|
+
sections: ReadonlyArray<SectionListData<ItemT, SectionT>>;
|
|
77
|
+
extraData?: any;
|
|
78
|
+
renderItem?: (info: SectionListRenderItemInfo<ItemT, SectionT>) => React.ReactElement | null;
|
|
79
|
+
renderSectionHeader?: (info: {
|
|
80
|
+
section: SectionListData<ItemT, SectionT>;
|
|
81
|
+
}) => React.ReactElement | null;
|
|
82
|
+
renderSectionFooter?: (info: {
|
|
83
|
+
section: SectionListData<ItemT, SectionT>;
|
|
84
|
+
}) => React.ReactElement | null;
|
|
85
|
+
ItemSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null;
|
|
86
|
+
SectionSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | React.ReactElement | null;
|
|
87
|
+
keyExtractor?: (item: ItemT, index: number) => string;
|
|
88
|
+
stickySectionHeadersEnabled?: boolean;
|
|
89
|
+
onViewableItemsChanged?: SectionListOnViewableItemsChanged<ItemT, SectionT>;
|
|
90
|
+
};
|
|
91
|
+
type SectionListRef = LegendListRef & {
|
|
92
|
+
scrollToLocation(params: SectionListScrollParams): void;
|
|
93
|
+
};
|
|
94
|
+
declare const SectionList: (<ItemT, SectionT extends SectionBase<ItemT, react_native.DefaultSectionT>>(props: SectionListLegendProps<ItemT, SectionT> & {
|
|
95
|
+
sections: readonly SectionListData<ItemT, SectionT>[];
|
|
96
|
+
extraData?: any;
|
|
97
|
+
renderItem?: ((info: SectionListRenderItemInfo<ItemT, SectionT>) => React.ReactElement | null) | undefined;
|
|
98
|
+
renderSectionHeader?: ((info: {
|
|
99
|
+
section: SectionListData<ItemT, SectionT>;
|
|
100
|
+
}) => React.ReactElement | null) | undefined;
|
|
101
|
+
renderSectionFooter?: ((info: {
|
|
102
|
+
section: SectionListData<ItemT, SectionT>;
|
|
103
|
+
}) => React.ReactElement | null) | undefined;
|
|
104
|
+
ItemSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null | undefined;
|
|
105
|
+
SectionSeparatorComponent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null | undefined;
|
|
106
|
+
keyExtractor?: ((item: ItemT, index: number) => string) | undefined;
|
|
107
|
+
stickySectionHeadersEnabled?: boolean;
|
|
108
|
+
onViewableItemsChanged?: SectionListOnViewableItemsChanged<ItemT, SectionT> | undefined;
|
|
109
|
+
} & React.RefAttributes<SectionListRef>) => React.ReactNode) & {
|
|
110
|
+
displayName?: string;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export { type BuildSectionListDataResult, type FlatSectionListItem, SectionList, type SectionListOnViewableItemsChanged, type SectionListProps, type SectionListRef, type SectionListSeparatorProps, type SectionListViewToken, type SectionMeta };
|