@legendapp/list 3.0.0-beta.13 → 3.0.0-beta.15
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/CHANGELOG.md +19 -0
- package/README.md +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +57 -29
- package/index.mjs +57 -29
- package/index.native.d.mts +2 -2
- package/index.native.d.ts +2 -2
- package/index.native.js +92 -42
- package/index.native.mjs +92 -42
- package/package.json +1 -1
- package/reanimated.js +2 -2
- package/reanimated.mjs +2 -2
- package/section-list.d.mts +1 -1
- package/section-list.d.ts +1 -1
- package/section-list.js +57 -29
- package/section-list.mjs +57 -29
- package/section-list.native.d.mts +1 -1
- package/section-list.native.d.ts +1 -1
- package/section-list.native.js +92 -42
- package/section-list.native.mjs +92 -42
- package/{types-BSoW8ni4.d.mts → types-Dj2MEm9V.d.mts} +25 -7
- package/{types-BSoW8ni4.d.ts → types-Dj2MEm9V.d.ts} +25 -7
package/reanimated.js
CHANGED
|
@@ -70,13 +70,13 @@ var AnimatedLegendListComponent = Reanimated__default.default.createAnimatedComp
|
|
|
70
70
|
var AnimatedLegendList = typedMemo(
|
|
71
71
|
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
72
72
|
React__namespace.forwardRef(function AnimatedLegendList2(props, ref) {
|
|
73
|
-
const { refScrollView,
|
|
73
|
+
const { refScrollView, ...rest } = props;
|
|
74
|
+
const { animatedProps } = props;
|
|
74
75
|
const refLegendList = React__namespace.useRef(null);
|
|
75
76
|
const combinedRef = useCombinedRef(refLegendList, ref);
|
|
76
77
|
return /* @__PURE__ */ React__namespace.createElement(
|
|
77
78
|
AnimatedLegendListComponent,
|
|
78
79
|
{
|
|
79
|
-
animatedProps,
|
|
80
80
|
animatedPropsInternal: animatedProps,
|
|
81
81
|
ref: refScrollView,
|
|
82
82
|
refLegendList: combinedRef,
|
package/reanimated.mjs
CHANGED
|
@@ -46,13 +46,13 @@ var AnimatedLegendListComponent = Reanimated.createAnimatedComponent(LegendListF
|
|
|
46
46
|
var AnimatedLegendList = typedMemo(
|
|
47
47
|
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
48
48
|
React.forwardRef(function AnimatedLegendList2(props, ref) {
|
|
49
|
-
const { refScrollView,
|
|
49
|
+
const { refScrollView, ...rest } = props;
|
|
50
|
+
const { animatedProps } = props;
|
|
50
51
|
const refLegendList = React.useRef(null);
|
|
51
52
|
const combinedRef = useCombinedRef(refLegendList, ref);
|
|
52
53
|
return /* @__PURE__ */ React.createElement(
|
|
53
54
|
AnimatedLegendListComponent,
|
|
54
55
|
{
|
|
55
|
-
animatedProps,
|
|
56
56
|
animatedPropsInternal: animatedProps,
|
|
57
57
|
ref: refScrollView,
|
|
58
58
|
refLegendList: combinedRef,
|
package/section-list.d.mts
CHANGED
|
@@ -1,7 +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 { a as LegendListRef, L as LegendListProps } from './types-
|
|
4
|
+
import { a as LegendListRef, L as LegendListProps } from './types-Dj2MEm9V.mjs';
|
|
5
5
|
import 'react-native-reanimated';
|
|
6
6
|
|
|
7
7
|
type SectionListSeparatorProps<ItemT, SectionT> = {
|
package/section-list.d.ts
CHANGED
|
@@ -1,7 +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 { a as LegendListRef, L as LegendListProps } from './types-
|
|
4
|
+
import { a as LegendListRef, L as LegendListProps } from './types-Dj2MEm9V.js';
|
|
5
5
|
import 'react-native-reanimated';
|
|
6
6
|
|
|
7
7
|
type SectionListSeparatorProps<ItemT, SectionT> = {
|
package/section-list.js
CHANGED
|
@@ -489,7 +489,8 @@ var Container = typedMemo(function Container2({
|
|
|
489
489
|
horizontal,
|
|
490
490
|
getRenderedItem: getRenderedItem2,
|
|
491
491
|
updateItemSize: updateItemSize2,
|
|
492
|
-
ItemSeparatorComponent
|
|
492
|
+
ItemSeparatorComponent,
|
|
493
|
+
stickyHeaderConfig
|
|
493
494
|
}) {
|
|
494
495
|
const ctx = useStateContext();
|
|
495
496
|
const { columnWrapperStyle, animatedScrollY } = ctx;
|
|
@@ -603,6 +604,7 @@ var Container = typedMemo(function Container2({
|
|
|
603
604
|
key: recycleItems ? void 0 : itemKey,
|
|
604
605
|
onLayout,
|
|
605
606
|
refView: ref,
|
|
607
|
+
stickyHeaderConfig,
|
|
606
608
|
stickyOffset: isSticky ? stickyOffset : void 0,
|
|
607
609
|
style
|
|
608
610
|
},
|
|
@@ -762,7 +764,8 @@ var Containers = typedMemo(function Containers2({
|
|
|
762
764
|
ItemSeparatorComponent,
|
|
763
765
|
waitForInitialLayout,
|
|
764
766
|
updateItemSize: updateItemSize2,
|
|
765
|
-
getRenderedItem: getRenderedItem2
|
|
767
|
+
getRenderedItem: getRenderedItem2,
|
|
768
|
+
stickyHeaderConfig
|
|
766
769
|
}) {
|
|
767
770
|
const [numContainers, numColumns] = useArr$(["numContainersPooled", "numColumns"]);
|
|
768
771
|
const containers = [];
|
|
@@ -777,6 +780,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
777
780
|
id: i,
|
|
778
781
|
key: i,
|
|
779
782
|
recycleItems,
|
|
783
|
+
stickyHeaderConfig,
|
|
780
784
|
updateItemSize: updateItemSize2
|
|
781
785
|
}
|
|
782
786
|
)
|
|
@@ -1040,8 +1044,6 @@ var LayoutView = ({ onLayoutChange, refView, children, ...rest }) => {
|
|
|
1040
1044
|
useOnLayoutSync({ onLayoutChange, ref });
|
|
1041
1045
|
return /* @__PURE__ */ React3__namespace.createElement("div", { ...rest, ref }, children);
|
|
1042
1046
|
};
|
|
1043
|
-
|
|
1044
|
-
// src/components/ListComponent.tsx
|
|
1045
1047
|
var getComponent = (Component) => {
|
|
1046
1048
|
if (React3__namespace.isValidElement(Component)) {
|
|
1047
1049
|
return Component;
|
|
@@ -1051,6 +1053,8 @@ var getComponent = (Component) => {
|
|
|
1051
1053
|
}
|
|
1052
1054
|
return null;
|
|
1053
1055
|
};
|
|
1056
|
+
|
|
1057
|
+
// src/components/ListComponent.tsx
|
|
1054
1058
|
var ListComponent = typedMemo(function ListComponent2({
|
|
1055
1059
|
canRender,
|
|
1056
1060
|
style,
|
|
@@ -1075,6 +1079,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1075
1079
|
scrollAdjustHandler,
|
|
1076
1080
|
onLayoutHeader,
|
|
1077
1081
|
snapToIndices,
|
|
1082
|
+
stickyHeaderConfig,
|
|
1078
1083
|
stickyHeaderIndices,
|
|
1079
1084
|
...rest
|
|
1080
1085
|
}) {
|
|
@@ -1097,7 +1102,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1097
1102
|
],
|
|
1098
1103
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
1099
1104
|
horizontal,
|
|
1100
|
-
maintainVisibleContentPosition: maintainVisibleContentPosition.
|
|
1105
|
+
maintainVisibleContentPosition: maintainVisibleContentPosition.size || maintainVisibleContentPosition.data ? { minIndexForVisible: 0 } : void 0,
|
|
1101
1106
|
onLayout,
|
|
1102
1107
|
onScroll: onScroll2,
|
|
1103
1108
|
ref: refScrollView,
|
|
@@ -1115,6 +1120,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1115
1120
|
horizontal,
|
|
1116
1121
|
ItemSeparatorComponent,
|
|
1117
1122
|
recycleItems,
|
|
1123
|
+
stickyHeaderConfig,
|
|
1118
1124
|
updateItemSize: updateItemSize2,
|
|
1119
1125
|
waitForInitialLayout
|
|
1120
1126
|
}
|
|
@@ -1309,7 +1315,7 @@ function clampScrollOffset(ctx, offset) {
|
|
|
1309
1315
|
const state = ctx.state;
|
|
1310
1316
|
const contentSize = getContentSize(ctx);
|
|
1311
1317
|
let clampedOffset = offset;
|
|
1312
|
-
if (Number.isFinite(contentSize) && Number.isFinite(state.scrollLength)) {
|
|
1318
|
+
if (Number.isFinite(contentSize) && Number.isFinite(state.scrollLength) && state.lastLayout) {
|
|
1313
1319
|
const maxOffset = Math.max(0, contentSize - state.scrollLength);
|
|
1314
1320
|
clampedOffset = Math.min(offset, maxOffset);
|
|
1315
1321
|
}
|
|
@@ -1339,6 +1345,7 @@ function finishScrollTo(ctx) {
|
|
|
1339
1345
|
var _a3, _b;
|
|
1340
1346
|
const state = ctx.state;
|
|
1341
1347
|
if (state == null ? void 0 : state.scrollingTo) {
|
|
1348
|
+
const scrollingTo = state.scrollingTo;
|
|
1342
1349
|
state.scrollHistory.length = 0;
|
|
1343
1350
|
state.initialScroll = void 0;
|
|
1344
1351
|
state.initialAnchor = void 0;
|
|
@@ -1350,7 +1357,7 @@ function finishScrollTo(ctx) {
|
|
|
1350
1357
|
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
1351
1358
|
}
|
|
1352
1359
|
{
|
|
1353
|
-
state.scrollAdjustHandler.commitPendingAdjust();
|
|
1360
|
+
state.scrollAdjustHandler.commitPendingAdjust(scrollingTo);
|
|
1354
1361
|
}
|
|
1355
1362
|
setInitialRenderState(ctx, { didInitialScroll: true });
|
|
1356
1363
|
}
|
|
@@ -1642,7 +1649,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1642
1649
|
const state = ctx.state;
|
|
1643
1650
|
const { idsInView, positions, props } = state;
|
|
1644
1651
|
const {
|
|
1645
|
-
maintainVisibleContentPosition: {
|
|
1652
|
+
maintainVisibleContentPosition: { data: mvcpData, size: mvcpScroll }
|
|
1646
1653
|
} = props;
|
|
1647
1654
|
const scrollingTo = state.scrollingTo;
|
|
1648
1655
|
let prevPosition;
|
|
@@ -1650,7 +1657,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1650
1657
|
const idsInViewWithPositions = [];
|
|
1651
1658
|
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
1652
1659
|
const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
|
|
1653
|
-
const shouldMVCP = dataChanged ?
|
|
1660
|
+
const shouldMVCP = dataChanged ? mvcpData : mvcpScroll;
|
|
1654
1661
|
const indexByKey = state.indexByKey;
|
|
1655
1662
|
if (shouldMVCP) {
|
|
1656
1663
|
if (scrollTarget !== void 0) {
|
|
@@ -1673,7 +1680,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1673
1680
|
}
|
|
1674
1681
|
return () => {
|
|
1675
1682
|
let positionDiff = 0;
|
|
1676
|
-
if (dataChanged && targetId === void 0 &&
|
|
1683
|
+
if (dataChanged && targetId === void 0 && mvcpData) {
|
|
1677
1684
|
for (let i = 0; i < idsInViewWithPositions.length; i++) {
|
|
1678
1685
|
const { id, position } = idsInViewWithPositions[i];
|
|
1679
1686
|
const newPosition = positions.get(id);
|
|
@@ -2626,7 +2633,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2626
2633
|
if (needNewContainers.length > 0) {
|
|
2627
2634
|
const requiredItemTypes = getItemType ? needNewContainers.map((i) => {
|
|
2628
2635
|
const itemType = getItemType(data[i], i);
|
|
2629
|
-
return itemType ? String(itemType) : "";
|
|
2636
|
+
return itemType !== void 0 ? String(itemType) : "";
|
|
2630
2637
|
}) : void 0;
|
|
2631
2638
|
const availableContainers = findAvailableContainers(
|
|
2632
2639
|
ctx,
|
|
@@ -2938,8 +2945,10 @@ function doInitialAllocateContainers(ctx) {
|
|
|
2938
2945
|
const num = Math.min(20, data.length);
|
|
2939
2946
|
for (let i = 0; i < num; i++) {
|
|
2940
2947
|
const item = data[i];
|
|
2941
|
-
|
|
2942
|
-
|
|
2948
|
+
if (item !== void 0) {
|
|
2949
|
+
const itemType = (_a3 = getItemType == null ? void 0 : getItemType(item, i)) != null ? _a3 : "";
|
|
2950
|
+
totalSize += (_c = (_b = getFixedItemSize == null ? void 0 : getFixedItemSize(i, item, itemType)) != null ? _b : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(i, item, itemType)) != null ? _c : estimatedItemSize;
|
|
2951
|
+
}
|
|
2943
2952
|
}
|
|
2944
2953
|
averageItemSize = totalSize / num;
|
|
2945
2954
|
} else {
|
|
@@ -3069,17 +3078,28 @@ var ScrollAdjustHandler = class {
|
|
|
3069
3078
|
getAdjust() {
|
|
3070
3079
|
return this.appliedAdjust;
|
|
3071
3080
|
}
|
|
3072
|
-
commitPendingAdjust() {
|
|
3081
|
+
commitPendingAdjust(scrollTarget) {
|
|
3073
3082
|
{
|
|
3074
3083
|
const state = this.ctx.state;
|
|
3075
3084
|
const pending = this.pendingAdjust;
|
|
3085
|
+
this.pendingAdjust = 0;
|
|
3076
3086
|
if (pending !== 0) {
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3087
|
+
let targetScroll;
|
|
3088
|
+
if ((scrollTarget == null ? void 0 : scrollTarget.index) !== void 0) {
|
|
3089
|
+
const currentOffset = calculateOffsetForIndex(this.ctx, scrollTarget.index);
|
|
3090
|
+
targetScroll = calculateOffsetWithOffsetPosition(this.ctx, currentOffset, scrollTarget);
|
|
3091
|
+
targetScroll = clampScrollOffset(this.ctx, targetScroll);
|
|
3092
|
+
} else {
|
|
3093
|
+
targetScroll = clampScrollOffset(this.ctx, state.scroll + pending);
|
|
3094
|
+
}
|
|
3095
|
+
const adjustment = targetScroll - state.scroll;
|
|
3096
|
+
if (Math.abs(adjustment) > 0.1 || Math.abs(pending) > 0.1) {
|
|
3097
|
+
this.appliedAdjust += adjustment;
|
|
3098
|
+
state.scroll = targetScroll;
|
|
3099
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
3100
|
+
set$(this.ctx, "scrollAdjust", this.appliedAdjust);
|
|
3101
|
+
}
|
|
3081
3102
|
set$(this.ctx, "scrollAdjustPending", 0);
|
|
3082
|
-
set$(this.ctx, "scrollAdjust", this.appliedAdjust);
|
|
3083
3103
|
calculateItemsInView(this.ctx);
|
|
3084
3104
|
}
|
|
3085
3105
|
}
|
|
@@ -3220,6 +3240,12 @@ function updateOneItemSize(ctx, itemKey, sizeObj) {
|
|
|
3220
3240
|
}
|
|
3221
3241
|
return 0;
|
|
3222
3242
|
}
|
|
3243
|
+
function useWrapIfItem(fn) {
|
|
3244
|
+
return React3.useMemo(
|
|
3245
|
+
() => fn ? (arg1, arg2, arg3) => arg1 !== void 0 && arg2 !== void 0 ? fn(arg1, arg2, arg3) : void 0 : void 0,
|
|
3246
|
+
[fn]
|
|
3247
|
+
);
|
|
3248
|
+
}
|
|
3223
3249
|
var useCombinedRef = (...refs) => {
|
|
3224
3250
|
const callback = React3.useCallback((element) => {
|
|
3225
3251
|
for (const ref of refs) {
|
|
@@ -3382,18 +3408,18 @@ function getRenderedItem(ctx, key) {
|
|
|
3382
3408
|
function normalizeMaintainVisibleContentPosition(value) {
|
|
3383
3409
|
var _a3, _b;
|
|
3384
3410
|
if (value === true) {
|
|
3385
|
-
return {
|
|
3411
|
+
return { data: true, size: true };
|
|
3386
3412
|
}
|
|
3387
3413
|
if (value && typeof value === "object") {
|
|
3388
3414
|
return {
|
|
3389
|
-
|
|
3390
|
-
|
|
3415
|
+
data: (_a3 = value.data) != null ? _a3 : false,
|
|
3416
|
+
size: (_b = value.size) != null ? _b : true
|
|
3391
3417
|
};
|
|
3392
3418
|
}
|
|
3393
3419
|
if (value === false) {
|
|
3394
|
-
return {
|
|
3420
|
+
return { data: false, size: false };
|
|
3395
3421
|
}
|
|
3396
|
-
return {
|
|
3422
|
+
return { data: false, size: true };
|
|
3397
3423
|
}
|
|
3398
3424
|
function useThrottleDebounce(mode) {
|
|
3399
3425
|
const timeoutRef = React3.useRef(null);
|
|
@@ -3519,6 +3545,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3519
3545
|
viewabilityConfig,
|
|
3520
3546
|
viewabilityConfigCallbackPairs,
|
|
3521
3547
|
waitForInitialLayout = true,
|
|
3548
|
+
stickyHeaderConfig,
|
|
3522
3549
|
...rest
|
|
3523
3550
|
} = props;
|
|
3524
3551
|
const animatedPropsInternal = props.animatedPropsInternal;
|
|
@@ -3636,13 +3663,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3636
3663
|
data: dataProp,
|
|
3637
3664
|
dataVersion,
|
|
3638
3665
|
estimatedItemSize,
|
|
3639
|
-
getEstimatedItemSize,
|
|
3640
|
-
getFixedItemSize,
|
|
3641
|
-
getItemType,
|
|
3666
|
+
getEstimatedItemSize: useWrapIfItem(getEstimatedItemSize),
|
|
3667
|
+
getFixedItemSize: useWrapIfItem(getFixedItemSize),
|
|
3668
|
+
getItemType: useWrapIfItem(getItemType),
|
|
3642
3669
|
horizontal: !!horizontal,
|
|
3643
3670
|
initialContainerPoolRatio,
|
|
3644
3671
|
itemsAreEqual,
|
|
3645
|
-
keyExtractor,
|
|
3672
|
+
keyExtractor: useWrapIfItem(keyExtractor),
|
|
3646
3673
|
maintainScrollAtEnd,
|
|
3647
3674
|
maintainScrollAtEndThreshold,
|
|
3648
3675
|
maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
|
|
@@ -3680,7 +3707,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3680
3707
|
setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
|
|
3681
3708
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
3682
3709
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
3683
|
-
if (maintainVisibleContentPositionConfig.
|
|
3710
|
+
if (maintainVisibleContentPositionConfig.size && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
3684
3711
|
if (state.scroll < 0) {
|
|
3685
3712
|
paddingDiff += state.scroll;
|
|
3686
3713
|
}
|
|
@@ -3856,6 +3883,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3856
3883
|
scrollAdjustHandler: (_b = refState.current) == null ? void 0 : _b.scrollAdjustHandler,
|
|
3857
3884
|
scrollEventThrottle: 0,
|
|
3858
3885
|
snapToIndices,
|
|
3886
|
+
stickyHeaderConfig,
|
|
3859
3887
|
stickyHeaderIndices,
|
|
3860
3888
|
style,
|
|
3861
3889
|
updateItemSize: fns.updateItemSize,
|
package/section-list.mjs
CHANGED
|
@@ -468,7 +468,8 @@ var Container = typedMemo(function Container2({
|
|
|
468
468
|
horizontal,
|
|
469
469
|
getRenderedItem: getRenderedItem2,
|
|
470
470
|
updateItemSize: updateItemSize2,
|
|
471
|
-
ItemSeparatorComponent
|
|
471
|
+
ItemSeparatorComponent,
|
|
472
|
+
stickyHeaderConfig
|
|
472
473
|
}) {
|
|
473
474
|
const ctx = useStateContext();
|
|
474
475
|
const { columnWrapperStyle, animatedScrollY } = ctx;
|
|
@@ -582,6 +583,7 @@ var Container = typedMemo(function Container2({
|
|
|
582
583
|
key: recycleItems ? void 0 : itemKey,
|
|
583
584
|
onLayout,
|
|
584
585
|
refView: ref,
|
|
586
|
+
stickyHeaderConfig,
|
|
585
587
|
stickyOffset: isSticky ? stickyOffset : void 0,
|
|
586
588
|
style
|
|
587
589
|
},
|
|
@@ -741,7 +743,8 @@ var Containers = typedMemo(function Containers2({
|
|
|
741
743
|
ItemSeparatorComponent,
|
|
742
744
|
waitForInitialLayout,
|
|
743
745
|
updateItemSize: updateItemSize2,
|
|
744
|
-
getRenderedItem: getRenderedItem2
|
|
746
|
+
getRenderedItem: getRenderedItem2,
|
|
747
|
+
stickyHeaderConfig
|
|
745
748
|
}) {
|
|
746
749
|
const [numContainers, numColumns] = useArr$(["numContainersPooled", "numColumns"]);
|
|
747
750
|
const containers = [];
|
|
@@ -756,6 +759,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
756
759
|
id: i,
|
|
757
760
|
key: i,
|
|
758
761
|
recycleItems,
|
|
762
|
+
stickyHeaderConfig,
|
|
759
763
|
updateItemSize: updateItemSize2
|
|
760
764
|
}
|
|
761
765
|
)
|
|
@@ -1019,8 +1023,6 @@ var LayoutView = ({ onLayoutChange, refView, children, ...rest }) => {
|
|
|
1019
1023
|
useOnLayoutSync({ onLayoutChange, ref });
|
|
1020
1024
|
return /* @__PURE__ */ React3.createElement("div", { ...rest, ref }, children);
|
|
1021
1025
|
};
|
|
1022
|
-
|
|
1023
|
-
// src/components/ListComponent.tsx
|
|
1024
1026
|
var getComponent = (Component) => {
|
|
1025
1027
|
if (React3.isValidElement(Component)) {
|
|
1026
1028
|
return Component;
|
|
@@ -1030,6 +1032,8 @@ var getComponent = (Component) => {
|
|
|
1030
1032
|
}
|
|
1031
1033
|
return null;
|
|
1032
1034
|
};
|
|
1035
|
+
|
|
1036
|
+
// src/components/ListComponent.tsx
|
|
1033
1037
|
var ListComponent = typedMemo(function ListComponent2({
|
|
1034
1038
|
canRender,
|
|
1035
1039
|
style,
|
|
@@ -1054,6 +1058,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1054
1058
|
scrollAdjustHandler,
|
|
1055
1059
|
onLayoutHeader,
|
|
1056
1060
|
snapToIndices,
|
|
1061
|
+
stickyHeaderConfig,
|
|
1057
1062
|
stickyHeaderIndices,
|
|
1058
1063
|
...rest
|
|
1059
1064
|
}) {
|
|
@@ -1076,7 +1081,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1076
1081
|
],
|
|
1077
1082
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
1078
1083
|
horizontal,
|
|
1079
|
-
maintainVisibleContentPosition: maintainVisibleContentPosition.
|
|
1084
|
+
maintainVisibleContentPosition: maintainVisibleContentPosition.size || maintainVisibleContentPosition.data ? { minIndexForVisible: 0 } : void 0,
|
|
1080
1085
|
onLayout,
|
|
1081
1086
|
onScroll: onScroll2,
|
|
1082
1087
|
ref: refScrollView,
|
|
@@ -1094,6 +1099,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1094
1099
|
horizontal,
|
|
1095
1100
|
ItemSeparatorComponent,
|
|
1096
1101
|
recycleItems,
|
|
1102
|
+
stickyHeaderConfig,
|
|
1097
1103
|
updateItemSize: updateItemSize2,
|
|
1098
1104
|
waitForInitialLayout
|
|
1099
1105
|
}
|
|
@@ -1288,7 +1294,7 @@ function clampScrollOffset(ctx, offset) {
|
|
|
1288
1294
|
const state = ctx.state;
|
|
1289
1295
|
const contentSize = getContentSize(ctx);
|
|
1290
1296
|
let clampedOffset = offset;
|
|
1291
|
-
if (Number.isFinite(contentSize) && Number.isFinite(state.scrollLength)) {
|
|
1297
|
+
if (Number.isFinite(contentSize) && Number.isFinite(state.scrollLength) && state.lastLayout) {
|
|
1292
1298
|
const maxOffset = Math.max(0, contentSize - state.scrollLength);
|
|
1293
1299
|
clampedOffset = Math.min(offset, maxOffset);
|
|
1294
1300
|
}
|
|
@@ -1318,6 +1324,7 @@ function finishScrollTo(ctx) {
|
|
|
1318
1324
|
var _a3, _b;
|
|
1319
1325
|
const state = ctx.state;
|
|
1320
1326
|
if (state == null ? void 0 : state.scrollingTo) {
|
|
1327
|
+
const scrollingTo = state.scrollingTo;
|
|
1321
1328
|
state.scrollHistory.length = 0;
|
|
1322
1329
|
state.initialScroll = void 0;
|
|
1323
1330
|
state.initialAnchor = void 0;
|
|
@@ -1329,7 +1336,7 @@ function finishScrollTo(ctx) {
|
|
|
1329
1336
|
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
1330
1337
|
}
|
|
1331
1338
|
{
|
|
1332
|
-
state.scrollAdjustHandler.commitPendingAdjust();
|
|
1339
|
+
state.scrollAdjustHandler.commitPendingAdjust(scrollingTo);
|
|
1333
1340
|
}
|
|
1334
1341
|
setInitialRenderState(ctx, { didInitialScroll: true });
|
|
1335
1342
|
}
|
|
@@ -1621,7 +1628,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1621
1628
|
const state = ctx.state;
|
|
1622
1629
|
const { idsInView, positions, props } = state;
|
|
1623
1630
|
const {
|
|
1624
|
-
maintainVisibleContentPosition: {
|
|
1631
|
+
maintainVisibleContentPosition: { data: mvcpData, size: mvcpScroll }
|
|
1625
1632
|
} = props;
|
|
1626
1633
|
const scrollingTo = state.scrollingTo;
|
|
1627
1634
|
let prevPosition;
|
|
@@ -1629,7 +1636,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1629
1636
|
const idsInViewWithPositions = [];
|
|
1630
1637
|
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
1631
1638
|
const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
|
|
1632
|
-
const shouldMVCP = dataChanged ?
|
|
1639
|
+
const shouldMVCP = dataChanged ? mvcpData : mvcpScroll;
|
|
1633
1640
|
const indexByKey = state.indexByKey;
|
|
1634
1641
|
if (shouldMVCP) {
|
|
1635
1642
|
if (scrollTarget !== void 0) {
|
|
@@ -1652,7 +1659,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1652
1659
|
}
|
|
1653
1660
|
return () => {
|
|
1654
1661
|
let positionDiff = 0;
|
|
1655
|
-
if (dataChanged && targetId === void 0 &&
|
|
1662
|
+
if (dataChanged && targetId === void 0 && mvcpData) {
|
|
1656
1663
|
for (let i = 0; i < idsInViewWithPositions.length; i++) {
|
|
1657
1664
|
const { id, position } = idsInViewWithPositions[i];
|
|
1658
1665
|
const newPosition = positions.get(id);
|
|
@@ -2605,7 +2612,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
2605
2612
|
if (needNewContainers.length > 0) {
|
|
2606
2613
|
const requiredItemTypes = getItemType ? needNewContainers.map((i) => {
|
|
2607
2614
|
const itemType = getItemType(data[i], i);
|
|
2608
|
-
return itemType ? String(itemType) : "";
|
|
2615
|
+
return itemType !== void 0 ? String(itemType) : "";
|
|
2609
2616
|
}) : void 0;
|
|
2610
2617
|
const availableContainers = findAvailableContainers(
|
|
2611
2618
|
ctx,
|
|
@@ -2917,8 +2924,10 @@ function doInitialAllocateContainers(ctx) {
|
|
|
2917
2924
|
const num = Math.min(20, data.length);
|
|
2918
2925
|
for (let i = 0; i < num; i++) {
|
|
2919
2926
|
const item = data[i];
|
|
2920
|
-
|
|
2921
|
-
|
|
2927
|
+
if (item !== void 0) {
|
|
2928
|
+
const itemType = (_a3 = getItemType == null ? void 0 : getItemType(item, i)) != null ? _a3 : "";
|
|
2929
|
+
totalSize += (_c = (_b = getFixedItemSize == null ? void 0 : getFixedItemSize(i, item, itemType)) != null ? _b : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(i, item, itemType)) != null ? _c : estimatedItemSize;
|
|
2930
|
+
}
|
|
2922
2931
|
}
|
|
2923
2932
|
averageItemSize = totalSize / num;
|
|
2924
2933
|
} else {
|
|
@@ -3048,17 +3057,28 @@ var ScrollAdjustHandler = class {
|
|
|
3048
3057
|
getAdjust() {
|
|
3049
3058
|
return this.appliedAdjust;
|
|
3050
3059
|
}
|
|
3051
|
-
commitPendingAdjust() {
|
|
3060
|
+
commitPendingAdjust(scrollTarget) {
|
|
3052
3061
|
{
|
|
3053
3062
|
const state = this.ctx.state;
|
|
3054
3063
|
const pending = this.pendingAdjust;
|
|
3064
|
+
this.pendingAdjust = 0;
|
|
3055
3065
|
if (pending !== 0) {
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3066
|
+
let targetScroll;
|
|
3067
|
+
if ((scrollTarget == null ? void 0 : scrollTarget.index) !== void 0) {
|
|
3068
|
+
const currentOffset = calculateOffsetForIndex(this.ctx, scrollTarget.index);
|
|
3069
|
+
targetScroll = calculateOffsetWithOffsetPosition(this.ctx, currentOffset, scrollTarget);
|
|
3070
|
+
targetScroll = clampScrollOffset(this.ctx, targetScroll);
|
|
3071
|
+
} else {
|
|
3072
|
+
targetScroll = clampScrollOffset(this.ctx, state.scroll + pending);
|
|
3073
|
+
}
|
|
3074
|
+
const adjustment = targetScroll - state.scroll;
|
|
3075
|
+
if (Math.abs(adjustment) > 0.1 || Math.abs(pending) > 0.1) {
|
|
3076
|
+
this.appliedAdjust += adjustment;
|
|
3077
|
+
state.scroll = targetScroll;
|
|
3078
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
3079
|
+
set$(this.ctx, "scrollAdjust", this.appliedAdjust);
|
|
3080
|
+
}
|
|
3060
3081
|
set$(this.ctx, "scrollAdjustPending", 0);
|
|
3061
|
-
set$(this.ctx, "scrollAdjust", this.appliedAdjust);
|
|
3062
3082
|
calculateItemsInView(this.ctx);
|
|
3063
3083
|
}
|
|
3064
3084
|
}
|
|
@@ -3199,6 +3219,12 @@ function updateOneItemSize(ctx, itemKey, sizeObj) {
|
|
|
3199
3219
|
}
|
|
3200
3220
|
return 0;
|
|
3201
3221
|
}
|
|
3222
|
+
function useWrapIfItem(fn) {
|
|
3223
|
+
return useMemo(
|
|
3224
|
+
() => fn ? (arg1, arg2, arg3) => arg1 !== void 0 && arg2 !== void 0 ? fn(arg1, arg2, arg3) : void 0 : void 0,
|
|
3225
|
+
[fn]
|
|
3226
|
+
);
|
|
3227
|
+
}
|
|
3202
3228
|
var useCombinedRef = (...refs) => {
|
|
3203
3229
|
const callback = useCallback((element) => {
|
|
3204
3230
|
for (const ref of refs) {
|
|
@@ -3361,18 +3387,18 @@ function getRenderedItem(ctx, key) {
|
|
|
3361
3387
|
function normalizeMaintainVisibleContentPosition(value) {
|
|
3362
3388
|
var _a3, _b;
|
|
3363
3389
|
if (value === true) {
|
|
3364
|
-
return {
|
|
3390
|
+
return { data: true, size: true };
|
|
3365
3391
|
}
|
|
3366
3392
|
if (value && typeof value === "object") {
|
|
3367
3393
|
return {
|
|
3368
|
-
|
|
3369
|
-
|
|
3394
|
+
data: (_a3 = value.data) != null ? _a3 : false,
|
|
3395
|
+
size: (_b = value.size) != null ? _b : true
|
|
3370
3396
|
};
|
|
3371
3397
|
}
|
|
3372
3398
|
if (value === false) {
|
|
3373
|
-
return {
|
|
3399
|
+
return { data: false, size: false };
|
|
3374
3400
|
}
|
|
3375
|
-
return {
|
|
3401
|
+
return { data: false, size: true };
|
|
3376
3402
|
}
|
|
3377
3403
|
function useThrottleDebounce(mode) {
|
|
3378
3404
|
const timeoutRef = useRef(null);
|
|
@@ -3498,6 +3524,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3498
3524
|
viewabilityConfig,
|
|
3499
3525
|
viewabilityConfigCallbackPairs,
|
|
3500
3526
|
waitForInitialLayout = true,
|
|
3527
|
+
stickyHeaderConfig,
|
|
3501
3528
|
...rest
|
|
3502
3529
|
} = props;
|
|
3503
3530
|
const animatedPropsInternal = props.animatedPropsInternal;
|
|
@@ -3615,13 +3642,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3615
3642
|
data: dataProp,
|
|
3616
3643
|
dataVersion,
|
|
3617
3644
|
estimatedItemSize,
|
|
3618
|
-
getEstimatedItemSize,
|
|
3619
|
-
getFixedItemSize,
|
|
3620
|
-
getItemType,
|
|
3645
|
+
getEstimatedItemSize: useWrapIfItem(getEstimatedItemSize),
|
|
3646
|
+
getFixedItemSize: useWrapIfItem(getFixedItemSize),
|
|
3647
|
+
getItemType: useWrapIfItem(getItemType),
|
|
3621
3648
|
horizontal: !!horizontal,
|
|
3622
3649
|
initialContainerPoolRatio,
|
|
3623
3650
|
itemsAreEqual,
|
|
3624
|
-
keyExtractor,
|
|
3651
|
+
keyExtractor: useWrapIfItem(keyExtractor),
|
|
3625
3652
|
maintainScrollAtEnd,
|
|
3626
3653
|
maintainScrollAtEndThreshold,
|
|
3627
3654
|
maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
|
|
@@ -3659,7 +3686,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3659
3686
|
setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
|
|
3660
3687
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
3661
3688
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
3662
|
-
if (maintainVisibleContentPositionConfig.
|
|
3689
|
+
if (maintainVisibleContentPositionConfig.size && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
3663
3690
|
if (state.scroll < 0) {
|
|
3664
3691
|
paddingDiff += state.scroll;
|
|
3665
3692
|
}
|
|
@@ -3835,6 +3862,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3835
3862
|
scrollAdjustHandler: (_b = refState.current) == null ? void 0 : _b.scrollAdjustHandler,
|
|
3836
3863
|
scrollEventThrottle: 0,
|
|
3837
3864
|
snapToIndices,
|
|
3865
|
+
stickyHeaderConfig,
|
|
3838
3866
|
stickyHeaderIndices,
|
|
3839
3867
|
style,
|
|
3840
3868
|
updateItemSize: fns.updateItemSize,
|
|
@@ -1,7 +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 { a as LegendListRef, L as LegendListProps } from './types-
|
|
4
|
+
import { a as LegendListRef, L as LegendListProps } from './types-Dj2MEm9V.mjs';
|
|
5
5
|
import 'react-native-reanimated';
|
|
6
6
|
|
|
7
7
|
type SectionListSeparatorProps<ItemT, SectionT> = {
|
package/section-list.native.d.ts
CHANGED
|
@@ -1,7 +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 { a as LegendListRef, L as LegendListProps } from './types-
|
|
4
|
+
import { a as LegendListRef, L as LegendListProps } from './types-Dj2MEm9V.js';
|
|
5
5
|
import 'react-native-reanimated';
|
|
6
6
|
|
|
7
7
|
type SectionListSeparatorProps<ItemT, SectionT> = {
|