@legendapp/list 3.0.0-beta.54 → 3.0.0-beta.55
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/animated.d.ts +13 -0
- package/index.d.ts +17 -0
- package/index.js +333 -81
- package/index.mjs +333 -81
- package/index.native.js +255 -59
- package/index.native.mjs +256 -60
- package/package.json +1 -1
- package/react-native.d.ts +13 -0
- package/react-native.js +255 -59
- package/react-native.mjs +256 -60
- package/react-native.web.d.ts +13 -0
- package/react-native.web.js +333 -81
- package/react-native.web.mjs +333 -81
- package/react.d.ts +13 -0
- package/react.js +333 -81
- package/react.mjs +333 -81
- package/reanimated.d.ts +13 -0
- package/section-list.d.ts +13 -0
package/index.mjs
CHANGED
|
@@ -13,6 +13,115 @@ var View = forwardRef(function View2(props, ref) {
|
|
|
13
13
|
});
|
|
14
14
|
var Text = View;
|
|
15
15
|
|
|
16
|
+
// src/platform/Platform.ts
|
|
17
|
+
var Platform = {
|
|
18
|
+
// Widen the type to avoid unreachable-branch lints in cross-platform code that compares against other OSes
|
|
19
|
+
OS: "web"
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/utils/rtl.ts
|
|
23
|
+
function clampHorizontalOffset(offset, maxOffset) {
|
|
24
|
+
if (maxOffset === void 0) {
|
|
25
|
+
return offset;
|
|
26
|
+
}
|
|
27
|
+
return Math.max(0, Math.min(maxOffset, offset));
|
|
28
|
+
}
|
|
29
|
+
function getHorizontalMaxOffset(state, contentWidth) {
|
|
30
|
+
if (contentWidth === void 0 || !Number.isFinite(contentWidth) || !Number.isFinite(state.scrollLength) || contentWidth <= state.scrollLength) {
|
|
31
|
+
return contentWidth !== void 0 && Number.isFinite(contentWidth) && Number.isFinite(state.scrollLength) ? 0 : void 0;
|
|
32
|
+
}
|
|
33
|
+
return Math.max(0, contentWidth - state.scrollLength);
|
|
34
|
+
}
|
|
35
|
+
function getDefaultHorizontalRTLScrollType() {
|
|
36
|
+
return "normal" ;
|
|
37
|
+
}
|
|
38
|
+
function getNativeHorizontalRTLScrollType(state) {
|
|
39
|
+
var _a3;
|
|
40
|
+
return (_a3 = state == null ? void 0 : state.horizontalRTLScrollType) != null ? _a3 : getDefaultHorizontalRTLScrollType();
|
|
41
|
+
}
|
|
42
|
+
function isRTLProps(props) {
|
|
43
|
+
var _a3;
|
|
44
|
+
return (_a3 = props == null ? void 0 : props.rtl) != null ? _a3 : false;
|
|
45
|
+
}
|
|
46
|
+
function isHorizontalRTL(state) {
|
|
47
|
+
return isHorizontalRTLProps(state == null ? void 0 : state.props);
|
|
48
|
+
}
|
|
49
|
+
function isHorizontalRTLProps(props) {
|
|
50
|
+
return !!(props == null ? void 0 : props.horizontal) && isRTLProps(props);
|
|
51
|
+
}
|
|
52
|
+
function getLogicalHorizontalMaxOffset(state, contentWidth) {
|
|
53
|
+
var _a3;
|
|
54
|
+
return (_a3 = getHorizontalMaxOffset(state, contentWidth)) != null ? _a3 : 0;
|
|
55
|
+
}
|
|
56
|
+
function getHorizontalInsetEnd(state, inset) {
|
|
57
|
+
if (!inset) {
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
return (isHorizontalRTL(state) ? inset.left : inset.right) || 0;
|
|
61
|
+
}
|
|
62
|
+
function toPhysicalHorizontalItemPosition(state, logicalPosition, itemSize, listSize) {
|
|
63
|
+
if (!isHorizontalRTL(state) || listSize === void 0 || !Number.isFinite(listSize)) {
|
|
64
|
+
return logicalPosition;
|
|
65
|
+
}
|
|
66
|
+
return Math.max(0, listSize - logicalPosition - itemSize);
|
|
67
|
+
}
|
|
68
|
+
function toNativeHorizontalOffset(state, logicalOffset, contentWidth) {
|
|
69
|
+
if (!state || !isHorizontalRTL(state)) {
|
|
70
|
+
return logicalOffset;
|
|
71
|
+
}
|
|
72
|
+
const maxOffset = getHorizontalMaxOffset(state, contentWidth);
|
|
73
|
+
const clampedLogicalOffset = clampHorizontalOffset(logicalOffset, maxOffset);
|
|
74
|
+
const mode = getNativeHorizontalRTLScrollType(state);
|
|
75
|
+
if (mode === "negative") {
|
|
76
|
+
return clampedLogicalOffset === 0 ? 0 : -clampedLogicalOffset;
|
|
77
|
+
}
|
|
78
|
+
if (mode === "inverted") {
|
|
79
|
+
if (maxOffset === void 0) {
|
|
80
|
+
return clampedLogicalOffset;
|
|
81
|
+
}
|
|
82
|
+
return clampHorizontalOffset(maxOffset - clampedLogicalOffset, maxOffset);
|
|
83
|
+
}
|
|
84
|
+
return clampedLogicalOffset;
|
|
85
|
+
}
|
|
86
|
+
function toLogicalHorizontalOffset(state, rawOffset, contentWidth) {
|
|
87
|
+
if (!isHorizontalRTL(state)) {
|
|
88
|
+
state.horizontalRTLScrollType = void 0;
|
|
89
|
+
return rawOffset;
|
|
90
|
+
}
|
|
91
|
+
const maxOffset = getHorizontalMaxOffset(state, contentWidth);
|
|
92
|
+
if (rawOffset < 0) {
|
|
93
|
+
state.horizontalRTLScrollType = "negative";
|
|
94
|
+
return clampHorizontalOffset(-rawOffset, maxOffset);
|
|
95
|
+
}
|
|
96
|
+
if (maxOffset === void 0) {
|
|
97
|
+
return rawOffset;
|
|
98
|
+
}
|
|
99
|
+
const normalOffset = rawOffset;
|
|
100
|
+
const invertedOffset = maxOffset - rawOffset;
|
|
101
|
+
if (!Number.isFinite(invertedOffset)) {
|
|
102
|
+
state.horizontalRTLScrollType = "normal";
|
|
103
|
+
return normalOffset;
|
|
104
|
+
}
|
|
105
|
+
const previousMode = state.horizontalRTLScrollType;
|
|
106
|
+
if (previousMode === "inverted") {
|
|
107
|
+
return clampHorizontalOffset(invertedOffset, maxOffset);
|
|
108
|
+
}
|
|
109
|
+
if (previousMode === "normal") {
|
|
110
|
+
return clampHorizontalOffset(normalOffset, maxOffset);
|
|
111
|
+
}
|
|
112
|
+
if (!state.hasScrolled) {
|
|
113
|
+
const defaultMode = getDefaultHorizontalRTLScrollType();
|
|
114
|
+
state.horizontalRTLScrollType = defaultMode;
|
|
115
|
+
return clampHorizontalOffset(normalOffset, maxOffset);
|
|
116
|
+
}
|
|
117
|
+
const referenceScroll = state.scroll;
|
|
118
|
+
const distanceNormal = Math.abs(normalOffset - referenceScroll);
|
|
119
|
+
const distanceInverted = Math.abs(invertedOffset - referenceScroll);
|
|
120
|
+
const useInverted = distanceInverted + 0.5 < distanceNormal;
|
|
121
|
+
state.horizontalRTLScrollType = useInverted ? "inverted" : "normal";
|
|
122
|
+
return clampHorizontalOffset(useInverted ? invertedOffset : normalOffset, maxOffset);
|
|
123
|
+
}
|
|
124
|
+
|
|
16
125
|
// src/platform/Animated.tsx
|
|
17
126
|
var createAnimatedValue = (value) => value;
|
|
18
127
|
|
|
@@ -155,7 +264,7 @@ function getContentInsetEnd(ctx, contentInsetEndAdjustmentOverride) {
|
|
|
155
264
|
const horizontal = props.horizontal;
|
|
156
265
|
const contentInset = props.contentInset;
|
|
157
266
|
const baseInset = contentInset != null ? contentInset : state.nativeContentInset;
|
|
158
|
-
const baseEndInset = (horizontal ?
|
|
267
|
+
const baseEndInset = (horizontal ? getHorizontalInsetEnd(state, baseInset) : baseInset == null ? void 0 : baseInset.bottom) || 0;
|
|
159
268
|
const contentInsetEndAdjustment = getContentInsetEndAdjustmentEnd(
|
|
160
269
|
contentInsetEndAdjustmentOverride != null ? contentInsetEndAdjustmentOverride : props.contentInsetEndAdjustment
|
|
161
270
|
);
|
|
@@ -164,9 +273,9 @@ function getContentInsetEnd(ctx, contentInsetEndAdjustmentOverride) {
|
|
|
164
273
|
const overrideInset = (_b = state.contentInsetOverride) != null ? _b : void 0;
|
|
165
274
|
const adjustedBaseEndInset = baseEndInset + contentInsetEndAdjustment;
|
|
166
275
|
if (overrideInset) {
|
|
167
|
-
const mergedInset = { bottom: 0, right: 0, ...baseInset, ...overrideInset };
|
|
276
|
+
const mergedInset = { bottom: 0, left: 0, right: 0, ...baseInset, ...overrideInset };
|
|
168
277
|
return Math.max(
|
|
169
|
-
((horizontal ? mergedInset
|
|
278
|
+
((horizontal ? getHorizontalInsetEnd(state, mergedInset) : mergedInset.bottom) || 0) + contentInsetEndAdjustment,
|
|
170
279
|
anchoredEndInset
|
|
171
280
|
);
|
|
172
281
|
}
|
|
@@ -260,6 +369,15 @@ var ENABLE_DEVMODE = IS_DEV && false;
|
|
|
260
369
|
var ENABLE_DEBUG_VIEW = IS_DEV && false;
|
|
261
370
|
var typedForwardRef = React3.forwardRef;
|
|
262
371
|
var typedMemo = React3.memo;
|
|
372
|
+
var getComponent = (Component) => {
|
|
373
|
+
if (React3.isValidElement(Component)) {
|
|
374
|
+
return Component;
|
|
375
|
+
}
|
|
376
|
+
if (Component) {
|
|
377
|
+
return /* @__PURE__ */ React3.createElement(Component, null);
|
|
378
|
+
}
|
|
379
|
+
return null;
|
|
380
|
+
};
|
|
263
381
|
|
|
264
382
|
// src/utils/helpers.ts
|
|
265
383
|
function isFunction(obj) {
|
|
@@ -286,7 +404,8 @@ function comparatorDefault(a, b) {
|
|
|
286
404
|
}
|
|
287
405
|
function getPadding(s, type) {
|
|
288
406
|
var _a3, _b, _c;
|
|
289
|
-
|
|
407
|
+
const axisPadding = type === "Left" || type === "Right" ? s.paddingHorizontal : s.paddingVertical;
|
|
408
|
+
return (_c = (_b = (_a3 = s[`padding${type}`]) != null ? _a3 : axisPadding) != null ? _b : s.padding) != null ? _c : 0;
|
|
290
409
|
}
|
|
291
410
|
function extractPadding(style, contentContainerStyle, type) {
|
|
292
411
|
return getPadding(style, type) + getPadding(contentContainerStyle, type);
|
|
@@ -308,6 +427,14 @@ function findContainerId(ctx, key) {
|
|
|
308
427
|
}
|
|
309
428
|
|
|
310
429
|
// src/components/PositionView.tsx
|
|
430
|
+
var isRNWeb = typeof document !== "undefined" && !!document.getElementById("react-native-stylesheet");
|
|
431
|
+
var baseCss = {
|
|
432
|
+
contain: "paint layout style",
|
|
433
|
+
...isRNWeb ? {
|
|
434
|
+
display: "flex",
|
|
435
|
+
flexDirection: "column"
|
|
436
|
+
} : {}
|
|
437
|
+
};
|
|
311
438
|
var PositionViewState = typedMemo(function PositionViewState2({
|
|
312
439
|
id,
|
|
313
440
|
horizontal,
|
|
@@ -316,11 +443,8 @@ var PositionViewState = typedMemo(function PositionViewState2({
|
|
|
316
443
|
...props
|
|
317
444
|
}) {
|
|
318
445
|
const [position = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
|
|
319
|
-
const base = {
|
|
320
|
-
contain: "paint layout style"
|
|
321
|
-
};
|
|
322
446
|
const composed = isArray(style) ? Object.assign({}, ...style) : style;
|
|
323
|
-
const combinedStyle = horizontal ? { ...
|
|
447
|
+
const combinedStyle = horizontal ? { ...baseCss, ...composed, left: position } : { ...baseCss, ...composed, top: position };
|
|
324
448
|
const {
|
|
325
449
|
animatedScrollY: _animatedScrollY,
|
|
326
450
|
index,
|
|
@@ -348,9 +472,6 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
|
348
472
|
`containerPosition${id}`,
|
|
349
473
|
"activeStickyIndex"
|
|
350
474
|
]);
|
|
351
|
-
const base = {
|
|
352
|
-
contain: "paint layout style"
|
|
353
|
-
};
|
|
354
475
|
const composed = React3.useMemo(
|
|
355
476
|
() => {
|
|
356
477
|
var _a3;
|
|
@@ -360,10 +481,9 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
|
360
481
|
);
|
|
361
482
|
const viewStyle = React3.useMemo(() => {
|
|
362
483
|
var _a3;
|
|
363
|
-
const styleBase = { ...
|
|
484
|
+
const styleBase = { ...baseCss, ...composed };
|
|
364
485
|
delete styleBase.transform;
|
|
365
|
-
const
|
|
366
|
-
const offset = stickyConfigOffset != null ? stickyConfigOffset : 0;
|
|
486
|
+
const offset = (_a3 = stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset) != null ? _a3 : 0;
|
|
367
487
|
const isActive = activeStickyIndex === index;
|
|
368
488
|
styleBase.position = isActive ? "sticky" : "absolute";
|
|
369
489
|
styleBase.zIndex = index + 1e3;
|
|
@@ -374,6 +494,20 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
|
374
494
|
}
|
|
375
495
|
return styleBase;
|
|
376
496
|
}, [composed, horizontal, position, index, activeStickyIndex, stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.offset]);
|
|
497
|
+
const renderStickyHeaderBackdrop = React3.useMemo(
|
|
498
|
+
() => (stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent) ? /* @__PURE__ */ React3.createElement(
|
|
499
|
+
"div",
|
|
500
|
+
{
|
|
501
|
+
style: {
|
|
502
|
+
inset: 0,
|
|
503
|
+
pointerEvents: "none",
|
|
504
|
+
position: "absolute"
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
getComponent(stickyHeaderConfig.backdropComponent)
|
|
508
|
+
) : null,
|
|
509
|
+
[stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent]
|
|
510
|
+
);
|
|
377
511
|
return /* @__PURE__ */ React3.createElement(
|
|
378
512
|
"div",
|
|
379
513
|
{
|
|
@@ -382,6 +516,7 @@ var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
|
382
516
|
style: viewStyle,
|
|
383
517
|
...webProps
|
|
384
518
|
},
|
|
519
|
+
renderStickyHeaderBackdrop,
|
|
385
520
|
children
|
|
386
521
|
);
|
|
387
522
|
});
|
|
@@ -643,12 +778,6 @@ function toLayout(rect) {
|
|
|
643
778
|
};
|
|
644
779
|
}
|
|
645
780
|
|
|
646
|
-
// src/platform/Platform.ts
|
|
647
|
-
var Platform = {
|
|
648
|
-
// Widen the type to avoid unreachable-branch lints in cross-platform code that compares against other OSes
|
|
649
|
-
OS: "web"
|
|
650
|
-
};
|
|
651
|
-
|
|
652
781
|
// src/utils/hasActiveMVCPAnchorLock.ts
|
|
653
782
|
function hasActiveMVCPAnchorLock(state) {
|
|
654
783
|
const lock = state.mvcpAnchorLock;
|
|
@@ -672,6 +801,7 @@ function getContainerPositionStyle({
|
|
|
672
801
|
columnWrapperStyle,
|
|
673
802
|
horizontal,
|
|
674
803
|
hasItemSeparator,
|
|
804
|
+
isHorizontalRTLList,
|
|
675
805
|
numColumns,
|
|
676
806
|
otherAxisPos,
|
|
677
807
|
otherAxisSize
|
|
@@ -695,6 +825,7 @@ function getContainerPositionStyle({
|
|
|
695
825
|
}
|
|
696
826
|
return horizontal ? {
|
|
697
827
|
boxSizing: paddingStyles ? "border-box" : void 0,
|
|
828
|
+
direction: isHorizontalRTLList && Platform.OS === "web" ? "ltr" : void 0,
|
|
698
829
|
flexDirection: hasItemSeparator ? "row" : void 0,
|
|
699
830
|
height: otherAxisSize,
|
|
700
831
|
left: 0,
|
|
@@ -723,6 +854,7 @@ var Container = typedMemo(function Container2({
|
|
|
723
854
|
}) {
|
|
724
855
|
const ctx = useStateContext();
|
|
725
856
|
const { columnWrapperStyle, animatedScrollY } = ctx;
|
|
857
|
+
const isHorizontalRTLList = isHorizontalRTL(ctx.state);
|
|
726
858
|
const positionComponentInternal = ctx.state.props.positionComponentInternal;
|
|
727
859
|
const stickyPositionComponentInternal = ctx.state.props.stickyPositionComponentInternal;
|
|
728
860
|
const [column = 0, span = 1, data, numColumns = 1, extraData, isSticky] = useArr$([
|
|
@@ -754,11 +886,20 @@ var Container = typedMemo(function Container2({
|
|
|
754
886
|
columnWrapperStyle,
|
|
755
887
|
hasItemSeparator: !!ItemSeparatorComponent,
|
|
756
888
|
horizontal,
|
|
889
|
+
isHorizontalRTLList,
|
|
757
890
|
numColumns,
|
|
758
891
|
otherAxisPos,
|
|
759
892
|
otherAxisSize
|
|
760
893
|
}),
|
|
761
|
-
[
|
|
894
|
+
[
|
|
895
|
+
horizontal,
|
|
896
|
+
isHorizontalRTLList,
|
|
897
|
+
otherAxisPos,
|
|
898
|
+
otherAxisSize,
|
|
899
|
+
columnWrapperStyle,
|
|
900
|
+
numColumns,
|
|
901
|
+
ItemSeparatorComponent
|
|
902
|
+
]
|
|
762
903
|
);
|
|
763
904
|
const renderedItemInfo = useMemo(
|
|
764
905
|
() => itemKey !== void 0 ? getRenderedItem2(itemKey) : null,
|
|
@@ -998,9 +1139,16 @@ var ContainersInner = typedMemo(function ContainersInner2({ horizontal, numColum
|
|
|
998
1139
|
const ref = useRef(null);
|
|
999
1140
|
const ctx = useStateContext();
|
|
1000
1141
|
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
1142
|
+
const isHorizontalRTLList = isHorizontalRTL(ctx.state);
|
|
1001
1143
|
const [otherAxisSize, readyToRender, totalSize] = useArr$(["otherAxisSize", "readyToRender", "totalSize"]);
|
|
1002
1144
|
useDOMOrder(ref);
|
|
1003
|
-
const style = horizontal ? {
|
|
1145
|
+
const style = horizontal ? {
|
|
1146
|
+
direction: isHorizontalRTLList ? "ltr" : void 0,
|
|
1147
|
+
minHeight: otherAxisSize,
|
|
1148
|
+
opacity: readyToRender ? 1 : 0,
|
|
1149
|
+
position: "relative",
|
|
1150
|
+
width: totalSize
|
|
1151
|
+
} : { height: totalSize, minWidth: otherAxisSize, opacity: readyToRender ? 1 : 0, position: "relative" };
|
|
1004
1152
|
if (!readyToRender) {
|
|
1005
1153
|
style.pointerEvents = "none";
|
|
1006
1154
|
}
|
|
@@ -1211,6 +1359,31 @@ function getContentInsetEndAdjustmentEnd2(ctx) {
|
|
|
1211
1359
|
const adjustment = (_b = (_a3 = ctx.state) == null ? void 0 : _a3.props) == null ? void 0 : _b.contentInsetEndAdjustment;
|
|
1212
1360
|
return Math.max(0, adjustment != null ? adjustment : 0);
|
|
1213
1361
|
}
|
|
1362
|
+
function getFiniteSnapOffsets(snapToOffsets) {
|
|
1363
|
+
if (!(snapToOffsets == null ? void 0 : snapToOffsets.length)) {
|
|
1364
|
+
return [];
|
|
1365
|
+
}
|
|
1366
|
+
const snapOffsets = [];
|
|
1367
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1368
|
+
for (const offset of snapToOffsets) {
|
|
1369
|
+
if (Number.isFinite(offset) && !seen.has(offset)) {
|
|
1370
|
+
seen.add(offset);
|
|
1371
|
+
snapOffsets.push(offset);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
return snapOffsets;
|
|
1375
|
+
}
|
|
1376
|
+
function getSnapAnchorStyle(offset, horizontal) {
|
|
1377
|
+
return {
|
|
1378
|
+
height: horizontal ? "100%" : 1,
|
|
1379
|
+
left: horizontal ? offset : 0,
|
|
1380
|
+
pointerEvents: "none",
|
|
1381
|
+
position: "absolute",
|
|
1382
|
+
scrollSnapAlign: "start",
|
|
1383
|
+
top: horizontal ? 0 : offset,
|
|
1384
|
+
width: horizontal ? 1 : "100%"
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1214
1387
|
var ListComponentScrollView = forwardRef(function ListComponentScrollView2({
|
|
1215
1388
|
children,
|
|
1216
1389
|
style,
|
|
@@ -1228,7 +1401,7 @@ var ListComponentScrollView = forwardRef(function ListComponentScrollView2({
|
|
|
1228
1401
|
onLayout,
|
|
1229
1402
|
...props
|
|
1230
1403
|
}, ref) {
|
|
1231
|
-
var _a3, _b, _c;
|
|
1404
|
+
var _a3, _b, _c, _d;
|
|
1232
1405
|
const ctx = useStateContext();
|
|
1233
1406
|
const [anchoredEndSpaceSize] = useArr$(["anchoredEndSpaceSize"]);
|
|
1234
1407
|
const scrollRef = useRef(null);
|
|
@@ -1443,10 +1616,16 @@ var ListComponentScrollView = forwardRef(function ListComponentScrollView2({
|
|
|
1443
1616
|
contentInset: _contentInset,
|
|
1444
1617
|
scrollEventThrottle: _scrollEventThrottle,
|
|
1445
1618
|
ScrollComponent: _ScrollComponent,
|
|
1619
|
+
snapToOffsets,
|
|
1446
1620
|
useWindowScroll: _useWindowScroll,
|
|
1447
1621
|
className: scrollViewClassNameProp,
|
|
1448
1622
|
...webProps
|
|
1449
1623
|
} = props;
|
|
1624
|
+
const snapOffsets = !isWindowScroll ? getFiniteSnapOffsets(snapToOffsets) : [];
|
|
1625
|
+
if (snapOffsets.length > 0) {
|
|
1626
|
+
scrollViewStyle.scrollSnapType = horizontal ? "x mandatory" : "y mandatory";
|
|
1627
|
+
contentStyle.position = (_d = contentStyle.position) != null ? _d : "relative";
|
|
1628
|
+
}
|
|
1450
1629
|
const scrollViewClassName = hiddenScrollIndicatorClassName ? scrollViewClassNameProp ? `${scrollViewClassNameProp} ${hiddenScrollIndicatorClassName}` : hiddenScrollIndicatorClassName : scrollViewClassNameProp;
|
|
1451
1630
|
if (IS_DEV) {
|
|
1452
1631
|
if (/(?:^|\s)(?:[a-z0-9_-]+:)*gap(?:-[xy])?-(?:\[[^\]]+\]|[^\s]+)/.test(
|
|
@@ -1467,9 +1646,29 @@ var ListComponentScrollView = forwardRef(function ListComponentScrollView2({
|
|
|
1467
1646
|
style: scrollViewStyle
|
|
1468
1647
|
},
|
|
1469
1648
|
refreshControl,
|
|
1470
|
-
/* @__PURE__ */ React3.createElement("div", { className, ref: contentRef, style: contentStyle },
|
|
1649
|
+
/* @__PURE__ */ React3.createElement("div", { className, ref: contentRef, style: contentStyle }, snapOffsets.map((offset) => /* @__PURE__ */ React3.createElement(
|
|
1650
|
+
"div",
|
|
1651
|
+
{
|
|
1652
|
+
"aria-hidden": true,
|
|
1653
|
+
"data-legend-list-snap-anchor": offset,
|
|
1654
|
+
key: `snap-${offset}`,
|
|
1655
|
+
style: getSnapAnchorStyle(offset, horizontal)
|
|
1656
|
+
}
|
|
1657
|
+
)), children, contentInsetEndAdjustmentSpacerStyle ? /* @__PURE__ */ React3.createElement("div", { "aria-hidden": true, style: contentInsetEndAdjustmentSpacerStyle }) : null)
|
|
1471
1658
|
);
|
|
1472
1659
|
});
|
|
1660
|
+
|
|
1661
|
+
// src/components/listComponentStyles.ts
|
|
1662
|
+
function getAutoOtherAxisStyle({
|
|
1663
|
+
horizontal,
|
|
1664
|
+
needsOtherAxisSize,
|
|
1665
|
+
otherAxisSize
|
|
1666
|
+
}) {
|
|
1667
|
+
if (!needsOtherAxisSize || !otherAxisSize || otherAxisSize <= 0) {
|
|
1668
|
+
return void 0;
|
|
1669
|
+
}
|
|
1670
|
+
return horizontal ? { height: otherAxisSize } : { width: otherAxisSize };
|
|
1671
|
+
}
|
|
1473
1672
|
function useValueListener$(key, callback) {
|
|
1474
1673
|
const ctx = useStateContext();
|
|
1475
1674
|
useLayoutEffect(() => {
|
|
@@ -1564,10 +1763,10 @@ function ScrollAdjust() {
|
|
|
1564
1763
|
useValueListener$("scrollAdjustUserOffset", callback);
|
|
1565
1764
|
return null;
|
|
1566
1765
|
}
|
|
1567
|
-
|
|
1766
|
+
var SnapWrapper = React3.forwardRef(function SnapWrapperInner({ ScrollComponent, ...props }, ref) {
|
|
1568
1767
|
const [snapToOffsets] = useArr$(["snapToOffsets"]);
|
|
1569
|
-
return /* @__PURE__ */ React3.createElement(ScrollComponent, { ...props, snapToOffsets });
|
|
1570
|
-
}
|
|
1768
|
+
return /* @__PURE__ */ React3.createElement(ScrollComponent, { ...props, ref, snapToOffsets });
|
|
1769
|
+
});
|
|
1571
1770
|
function WebAnchoredEndSpace({ horizontal }) {
|
|
1572
1771
|
const ctx = useStateContext();
|
|
1573
1772
|
const [anchoredEndSpaceSize] = useArr$(["anchoredEndSpaceSize"]);
|
|
@@ -1584,15 +1783,6 @@ var LayoutView = ({ onLayoutChange, refView, children, ...rest }) => {
|
|
|
1584
1783
|
useOnLayoutSync({ onLayoutChange, ref });
|
|
1585
1784
|
return /* @__PURE__ */ React3.createElement("div", { ...rest, ref }, children);
|
|
1586
1785
|
};
|
|
1587
|
-
var getComponent = (Component) => {
|
|
1588
|
-
if (React3.isValidElement(Component)) {
|
|
1589
|
-
return Component;
|
|
1590
|
-
}
|
|
1591
|
-
if (Component) {
|
|
1592
|
-
return /* @__PURE__ */ React3.createElement(Component, null);
|
|
1593
|
-
}
|
|
1594
|
-
return null;
|
|
1595
|
-
};
|
|
1596
1786
|
|
|
1597
1787
|
// src/components/ListComponent.tsx
|
|
1598
1788
|
var ListComponent = typedMemo(function ListComponent2({
|
|
@@ -1625,6 +1815,12 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1625
1815
|
}) {
|
|
1626
1816
|
const ctx = useStateContext();
|
|
1627
1817
|
const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
|
|
1818
|
+
const [otherAxisSize = 0] = useArr$(["otherAxisSize"]);
|
|
1819
|
+
const autoOtherAxisStyle = getAutoOtherAxisStyle({
|
|
1820
|
+
horizontal,
|
|
1821
|
+
needsOtherAxisSize: ctx.state.needsOtherAxisSize,
|
|
1822
|
+
otherAxisSize
|
|
1823
|
+
});
|
|
1628
1824
|
const ScrollComponent = useMemo(() => {
|
|
1629
1825
|
if (!renderScrollComponent) {
|
|
1630
1826
|
return ListComponentScrollView;
|
|
@@ -1663,10 +1859,10 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1663
1859
|
...rest,
|
|
1664
1860
|
...ScrollComponent === ListComponentScrollView ? { useWindowScroll } : {},
|
|
1665
1861
|
contentContainerStyle: [
|
|
1666
|
-
contentContainerStyle,
|
|
1667
1862
|
horizontal ? {
|
|
1668
1863
|
height: "100%"
|
|
1669
|
-
} : {}
|
|
1864
|
+
} : {},
|
|
1865
|
+
contentContainerStyle
|
|
1670
1866
|
],
|
|
1671
1867
|
contentOffset: initialContentOffset !== void 0 ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
1672
1868
|
horizontal,
|
|
@@ -1675,7 +1871,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1675
1871
|
onScroll: onScroll2,
|
|
1676
1872
|
ref: refScrollView,
|
|
1677
1873
|
ScrollComponent: snapToIndices ? ScrollComponent : void 0,
|
|
1678
|
-
style
|
|
1874
|
+
style: autoOtherAxisStyle ? [autoOtherAxisStyle, style] : style
|
|
1679
1875
|
},
|
|
1680
1876
|
/* @__PURE__ */ React3.createElement(ScrollAdjust, null),
|
|
1681
1877
|
ListHeaderComponent && /* @__PURE__ */ React3.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
|
|
@@ -2392,7 +2588,8 @@ function doScrollTo(ctx, params) {
|
|
|
2392
2588
|
}
|
|
2393
2589
|
const isAnimated = !!animated;
|
|
2394
2590
|
const isHorizontal = !!horizontal;
|
|
2395
|
-
const
|
|
2591
|
+
const contentSize = isHorizontal ? getContentSize(ctx) : void 0;
|
|
2592
|
+
const left = isHorizontal ? toNativeHorizontalOffset(state, offset, contentSize) : 0;
|
|
2396
2593
|
const top = isHorizontal ? 0 : offset;
|
|
2397
2594
|
scroller.scrollTo({ animated: isAnimated, x: left, y: top });
|
|
2398
2595
|
if (isAnimated) {
|
|
@@ -3453,7 +3650,14 @@ function handleInitialScrollLayoutReady(ctx) {
|
|
|
3453
3650
|
}
|
|
3454
3651
|
function initializeInitialScrollOnMount(ctx, options) {
|
|
3455
3652
|
var _a3, _b;
|
|
3456
|
-
const {
|
|
3653
|
+
const {
|
|
3654
|
+
alwaysDispatchInitialScroll,
|
|
3655
|
+
dataLength,
|
|
3656
|
+
hasFooterComponent,
|
|
3657
|
+
initialContentOffset,
|
|
3658
|
+
initialScrollAtEnd,
|
|
3659
|
+
useBootstrapInitialScroll
|
|
3660
|
+
} = options;
|
|
3457
3661
|
const state = ctx.state;
|
|
3458
3662
|
const initialScroll = state.initialScroll;
|
|
3459
3663
|
const resolvedInitialContentOffset = initialContentOffset != null ? initialContentOffset : 0;
|
|
@@ -3473,7 +3677,7 @@ function initializeInitialScrollOnMount(ctx, options) {
|
|
|
3473
3677
|
return;
|
|
3474
3678
|
}
|
|
3475
3679
|
const hasPendingDataDependentInitialScroll = !!initialScroll && dataLength === 0 && !(resolvedInitialContentOffset === 0 && !initialScrollAtEnd);
|
|
3476
|
-
if (!resolvedInitialContentOffset && !hasPendingDataDependentInitialScroll) {
|
|
3680
|
+
if (!alwaysDispatchInitialScroll && !resolvedInitialContentOffset && !hasPendingDataDependentInitialScroll) {
|
|
3477
3681
|
if (initialScroll && !initialScrollAtEnd) {
|
|
3478
3682
|
finishInitialScroll(ctx, {
|
|
3479
3683
|
resolvedOffset: resolvedInitialContentOffset
|
|
@@ -3794,9 +3998,18 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
3794
3998
|
}
|
|
3795
3999
|
}
|
|
3796
4000
|
|
|
4001
|
+
// src/core/resetLayoutCachesForDataChange.ts
|
|
4002
|
+
function resetLayoutCachesForDataChange(state) {
|
|
4003
|
+
state.indexByKey.clear();
|
|
4004
|
+
state.idCache.length = 0;
|
|
4005
|
+
state.positions.length = 0;
|
|
4006
|
+
state.columns.length = 0;
|
|
4007
|
+
state.columnSpans.length = 0;
|
|
4008
|
+
}
|
|
4009
|
+
|
|
3797
4010
|
// src/core/syncMountedContainer.ts
|
|
3798
4011
|
function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
|
|
3799
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h;
|
|
4012
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3800
4013
|
const state = ctx.state;
|
|
3801
4014
|
const {
|
|
3802
4015
|
columns,
|
|
@@ -3808,7 +4021,8 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
|
|
|
3808
4021
|
if (item === void 0) {
|
|
3809
4022
|
return { didChangePosition: false, didRefreshData: false };
|
|
3810
4023
|
}
|
|
3811
|
-
const
|
|
4024
|
+
const itemKey = (_a3 = state.idCache[itemIndex]) != null ? _a3 : getId(state, itemIndex);
|
|
4025
|
+
const updateLayout = (_b = options == null ? void 0 : options.updateLayout) != null ? _b : true;
|
|
3812
4026
|
let didChangePosition = false;
|
|
3813
4027
|
let didRefreshData = false;
|
|
3814
4028
|
if (updateLayout) {
|
|
@@ -3817,7 +4031,9 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
|
|
|
3817
4031
|
set$(ctx, `containerPosition${containerIndex}`, POSITION_OUT_OF_VIEW);
|
|
3818
4032
|
return { didChangePosition: false, didRefreshData: false };
|
|
3819
4033
|
}
|
|
3820
|
-
const
|
|
4034
|
+
const logicalPosition = (positionValue || 0) - ((_c = options == null ? void 0 : options.scrollAdjustPending) != null ? _c : 0);
|
|
4035
|
+
const itemSize = (_d = state.sizes.get(itemKey)) != null ? _d : getItemSize(ctx, itemKey, itemIndex, item);
|
|
4036
|
+
const position = toPhysicalHorizontalItemPosition(state, logicalPosition, itemSize, peek$(ctx, "totalSize"));
|
|
3821
4037
|
const column = columns[itemIndex] || 1;
|
|
3822
4038
|
const span = columnSpans[itemIndex] || 1;
|
|
3823
4039
|
const prevPos = peek$(ctx, `containerPosition${containerIndex}`);
|
|
@@ -3836,15 +4052,15 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
|
|
|
3836
4052
|
}
|
|
3837
4053
|
const prevData = peek$(ctx, `containerItemData${containerIndex}`);
|
|
3838
4054
|
if (prevData !== item) {
|
|
3839
|
-
const pendingDataComparison = ((
|
|
3840
|
-
const cachedComparison = (
|
|
4055
|
+
const pendingDataComparison = ((_e = state.pendingDataComparison) == null ? void 0 : _e.previousData) === state.previousData && ((_f = state.pendingDataComparison) == null ? void 0 : _f.nextData) === data ? state.pendingDataComparison : void 0;
|
|
4056
|
+
const cachedComparison = (_g = pendingDataComparison == null ? void 0 : pendingDataComparison.byIndex[itemIndex]) != null ? _g : 0;
|
|
3841
4057
|
if (cachedComparison === 2) {
|
|
3842
4058
|
set$(ctx, `containerItemData${containerIndex}`, item);
|
|
3843
4059
|
didRefreshData = true;
|
|
3844
4060
|
} else if (cachedComparison !== 1) {
|
|
3845
|
-
const
|
|
4061
|
+
const nextItemKey = (_h = peek$(ctx, `containerItemKey${containerIndex}`)) != null ? _h : itemKey;
|
|
3846
4062
|
const prevKey = keyExtractor == null ? void 0 : keyExtractor(prevData, itemIndex);
|
|
3847
|
-
if (prevData === void 0 || !keyExtractor || prevKey !==
|
|
4063
|
+
if (prevData === void 0 || !keyExtractor || prevKey !== nextItemKey) {
|
|
3848
4064
|
set$(ctx, `containerItemData${containerIndex}`, item);
|
|
3849
4065
|
didRefreshData = true;
|
|
3850
4066
|
} else if (!itemsAreEqual) {
|
|
@@ -3861,7 +4077,7 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
|
|
|
3861
4077
|
};
|
|
3862
4078
|
}
|
|
3863
4079
|
}
|
|
3864
|
-
if ((
|
|
4080
|
+
if ((_i = state.pendingDataComparison) == null ? void 0 : _i.byIndex) {
|
|
3865
4081
|
state.pendingDataComparison.byIndex[itemIndex] = isEqual ? 1 : 2;
|
|
3866
4082
|
}
|
|
3867
4083
|
if (!isEqual) {
|
|
@@ -4026,11 +4242,13 @@ function updateSnapToOffsets(ctx) {
|
|
|
4026
4242
|
const {
|
|
4027
4243
|
props: { snapToIndices }
|
|
4028
4244
|
} = state;
|
|
4245
|
+
const contentSize = state.props.horizontal ? getContentSize(ctx) : void 0;
|
|
4029
4246
|
const snapToOffsets = Array(snapToIndices.length);
|
|
4030
4247
|
for (let i = 0; i < snapToIndices.length; i++) {
|
|
4031
4248
|
const idx = snapToIndices[i];
|
|
4032
4249
|
getId(state, idx);
|
|
4033
|
-
|
|
4250
|
+
const logicalOffset = state.positions[idx];
|
|
4251
|
+
snapToOffsets[i] = toNativeHorizontalOffset(state, logicalOffset, contentSize);
|
|
4034
4252
|
}
|
|
4035
4253
|
set$(ctx, "snapToOffsets", snapToOffsets);
|
|
4036
4254
|
}
|
|
@@ -4639,7 +4857,6 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4639
4857
|
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
4640
4858
|
const {
|
|
4641
4859
|
columns,
|
|
4642
|
-
columnSpans,
|
|
4643
4860
|
containerItemKeys,
|
|
4644
4861
|
enableScrollForNextCalculateItemsInView,
|
|
4645
4862
|
idCache,
|
|
@@ -4689,8 +4906,10 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4689
4906
|
let scrollTopBuffered = 0;
|
|
4690
4907
|
let scrollBottom = 0;
|
|
4691
4908
|
let scrollBottomBuffered = 0;
|
|
4909
|
+
let nativeScrollState = scrollState;
|
|
4692
4910
|
const updateScroll2 = (nextScrollState) => {
|
|
4693
4911
|
var _a4;
|
|
4912
|
+
nativeScrollState = nextScrollState;
|
|
4694
4913
|
scrollAdjustPending = (_a4 = peek$(ctx, "scrollAdjustPending")) != null ? _a4 : 0;
|
|
4695
4914
|
scrollAdjustPad = scrollAdjustPending - topPad;
|
|
4696
4915
|
scroll = Math.round(nextScrollState + scrollExtra + scrollAdjustPad);
|
|
@@ -4702,9 +4921,17 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4702
4921
|
const previousStickyIndex = peek$(ctx, "activeStickyIndex");
|
|
4703
4922
|
const currentStickyIdx = stickyIndicesArr.length > 0 ? findCurrentStickyIndex(stickyIndicesArr, scroll, state) : -1;
|
|
4704
4923
|
const nextActiveStickyIndex = currentStickyIdx >= 0 ? stickyIndicesArr[currentStickyIdx] : -1;
|
|
4924
|
+
const stickyIndexDidChange = previousStickyIndex !== nextActiveStickyIndex;
|
|
4705
4925
|
if (currentStickyIdx >= 0 || previousStickyIndex >= 0) {
|
|
4706
4926
|
set$(ctx, "activeStickyIndex", nextActiveStickyIndex);
|
|
4707
4927
|
}
|
|
4928
|
+
const shouldNotifyStickyHeaderChange = !!onStickyHeaderChange && stickyIndicesArr.length > 0 && stickyIndexDidChange;
|
|
4929
|
+
const finishCalculateItemsInView = shouldNotifyStickyHeaderChange ? () => {
|
|
4930
|
+
const item = data[nextActiveStickyIndex];
|
|
4931
|
+
if (item !== void 0) {
|
|
4932
|
+
onStickyHeaderChange == null ? void 0 : onStickyHeaderChange({ index: nextActiveStickyIndex, item });
|
|
4933
|
+
}
|
|
4934
|
+
} : void 0;
|
|
4708
4935
|
let scrollBufferTop = drawDistance;
|
|
4709
4936
|
let scrollBufferBottom = drawDistance;
|
|
4710
4937
|
if (speed > 0 || speed === 0 && scroll < Math.max(50, drawDistance)) {
|
|
@@ -4715,8 +4942,10 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4715
4942
|
scrollBufferBottom = drawDistance * 0.5;
|
|
4716
4943
|
}
|
|
4717
4944
|
const updateScrollRange = () => {
|
|
4718
|
-
|
|
4719
|
-
|
|
4945
|
+
const scrollStart = Math.max(0, scroll);
|
|
4946
|
+
const overscrollBeforeContent = Math.max(0, -nativeScrollState);
|
|
4947
|
+
scrollTopBuffered = scrollStart - scrollBufferTop;
|
|
4948
|
+
scrollBottom = Math.max(scrollStart, scroll + scrollLength + overscrollBeforeContent);
|
|
4720
4949
|
scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
4721
4950
|
};
|
|
4722
4951
|
updateScrollRange();
|
|
@@ -4726,17 +4955,14 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4726
4955
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
4727
4956
|
} else if ((top === null || scrollTopBuffered > top) && (bottom === null || scrollBottomBuffered < bottom)) {
|
|
4728
4957
|
if (!isInMVCPActiveMode(state)) {
|
|
4958
|
+
finishCalculateItemsInView == null ? void 0 : finishCalculateItemsInView();
|
|
4729
4959
|
return;
|
|
4730
4960
|
}
|
|
4731
4961
|
}
|
|
4732
4962
|
}
|
|
4733
4963
|
const checkMVCP = doMVCP && !suppressInitialScrollSideEffects ? prepareMVCP(ctx, dataChanged) : void 0;
|
|
4734
4964
|
if (dataChanged) {
|
|
4735
|
-
|
|
4736
|
-
idCache.length = 0;
|
|
4737
|
-
positions.length = 0;
|
|
4738
|
-
columns.length = 0;
|
|
4739
|
-
columnSpans.length = 0;
|
|
4965
|
+
resetLayoutCachesForDataChange(state);
|
|
4740
4966
|
}
|
|
4741
4967
|
const startIndex = forceFullItemPositions || dataChanged ? 0 : (_c = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _c : 0;
|
|
4742
4968
|
const optimizeForVisibleWindow = !forceFullItemPositions && !dataChanged && numColumns > 1 && minIndexSizeChanged !== void 0;
|
|
@@ -5050,12 +5276,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
5050
5276
|
);
|
|
5051
5277
|
}
|
|
5052
5278
|
}
|
|
5053
|
-
|
|
5054
|
-
const item = data[nextActiveStickyIndex];
|
|
5055
|
-
if (item !== void 0) {
|
|
5056
|
-
onStickyHeaderChange({ index: nextActiveStickyIndex, item });
|
|
5057
|
-
}
|
|
5058
|
-
}
|
|
5279
|
+
finishCalculateItemsInView == null ? void 0 : finishCalculateItemsInView();
|
|
5059
5280
|
});
|
|
5060
5281
|
}
|
|
5061
5282
|
|
|
@@ -5083,11 +5304,22 @@ function doMaintainScrollAtEnd(ctx) {
|
|
|
5083
5304
|
if (!state.maintainingScrollAtEnd) {
|
|
5084
5305
|
state.maintainingScrollAtEnd = true;
|
|
5085
5306
|
requestAnimationFrame(() => {
|
|
5086
|
-
var _a3;
|
|
5087
5307
|
if (peek$(ctx, "isWithinMaintainScrollAtEndThreshold")) {
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5308
|
+
const scroller = refScroller.current;
|
|
5309
|
+
if (state.props.horizontal && isHorizontalRTL(state)) {
|
|
5310
|
+
const currentContentSize = getContentSize(ctx);
|
|
5311
|
+
const logicalEndOffset = getLogicalHorizontalMaxOffset(state, currentContentSize);
|
|
5312
|
+
const nativeOffset = toNativeHorizontalOffset(state, logicalEndOffset, currentContentSize);
|
|
5313
|
+
scroller == null ? void 0 : scroller.scrollTo({
|
|
5314
|
+
animated: maintainScrollAtEnd.animated,
|
|
5315
|
+
x: nativeOffset,
|
|
5316
|
+
y: 0
|
|
5317
|
+
});
|
|
5318
|
+
} else {
|
|
5319
|
+
scroller == null ? void 0 : scroller.scrollToEnd({
|
|
5320
|
+
animated: maintainScrollAtEnd.animated
|
|
5321
|
+
});
|
|
5322
|
+
}
|
|
5091
5323
|
setTimeout(
|
|
5092
5324
|
() => {
|
|
5093
5325
|
state.maintainingScrollAtEnd = false;
|
|
@@ -5287,7 +5519,8 @@ function handleLayout(ctx, layoutParam, setCanRender) {
|
|
|
5287
5519
|
}
|
|
5288
5520
|
checkThresholds(ctx);
|
|
5289
5521
|
if (state) {
|
|
5290
|
-
|
|
5522
|
+
const crossAxisPadding = state.props.horizontal ? (state.props.stylePaddingTop || 0) + (state.props.stylePaddingBottom || 0) : (state.props.stylePaddingLeft || 0) + (state.props.stylePaddingRight || 0);
|
|
5523
|
+
state.needsOtherAxisSize = otherAxisSize - crossAxisPadding < 10;
|
|
5291
5524
|
}
|
|
5292
5525
|
if (IS_DEV && measuredLength === 0) {
|
|
5293
5526
|
warnDevOnce(
|
|
@@ -5401,7 +5634,7 @@ function cloneScrollEvent(event) {
|
|
|
5401
5634
|
};
|
|
5402
5635
|
}
|
|
5403
5636
|
function onScroll(ctx, event) {
|
|
5404
|
-
var _a3, _b, _c, _d;
|
|
5637
|
+
var _a3, _b, _c, _d, _e;
|
|
5405
5638
|
const state = ctx.state;
|
|
5406
5639
|
const { scrollProcessingEnabled } = state;
|
|
5407
5640
|
if (scrollProcessingEnabled === false) {
|
|
@@ -5420,6 +5653,9 @@ function onScroll(ctx, event) {
|
|
|
5420
5653
|
}
|
|
5421
5654
|
}
|
|
5422
5655
|
let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
5656
|
+
if (state.props.horizontal) {
|
|
5657
|
+
newScroll = toLogicalHorizontalOffset(state, newScroll, (_e = event.nativeEvent.contentSize) == null ? void 0 : _e.width);
|
|
5658
|
+
}
|
|
5423
5659
|
if (state.scrollingTo && state.scrollingTo.offset >= newScroll) {
|
|
5424
5660
|
const maxOffset = clampScrollOffset(ctx, newScroll, state.scrollingTo);
|
|
5425
5661
|
if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
|
|
@@ -5591,6 +5827,16 @@ function runOrScheduleMVCPRecalculate(ctx) {
|
|
|
5591
5827
|
});
|
|
5592
5828
|
}
|
|
5593
5829
|
}
|
|
5830
|
+
function updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal) {
|
|
5831
|
+
const state = ctx.state;
|
|
5832
|
+
if (state.needsOtherAxisSize) {
|
|
5833
|
+
const otherAxisSize = horizontal ? sizeObj.height : sizeObj.width;
|
|
5834
|
+
const currentOtherAxisSize = peek$(ctx, "otherAxisSize");
|
|
5835
|
+
if (!currentOtherAxisSize || otherAxisSize > currentOtherAxisSize) {
|
|
5836
|
+
set$(ctx, "otherAxisSize", otherAxisSize);
|
|
5837
|
+
}
|
|
5838
|
+
}
|
|
5839
|
+
}
|
|
5594
5840
|
function updateItemSize(ctx, itemKey, sizeObj) {
|
|
5595
5841
|
var _a3;
|
|
5596
5842
|
const state = ctx.state;
|
|
@@ -5614,13 +5860,13 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
5614
5860
|
const type = getItemType ? (_a3 = getItemType(itemData, index)) != null ? _a3 : "" : "";
|
|
5615
5861
|
const size2 = getFixedItemSize(itemData, index, type);
|
|
5616
5862
|
if (size2 !== void 0 && size2 === sizesKnown.get(itemKey)) {
|
|
5863
|
+
updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
|
|
5617
5864
|
return;
|
|
5618
5865
|
}
|
|
5619
5866
|
}
|
|
5620
5867
|
let needsRecalculate = !didContainersLayout;
|
|
5621
5868
|
let shouldMaintainScrollAtEnd = false;
|
|
5622
5869
|
let minIndexSizeChanged;
|
|
5623
|
-
let maxOtherAxisSize = peek$(ctx, "otherAxisSize") || 0;
|
|
5624
5870
|
const prevSizeKnown = state.sizesKnown.get(itemKey);
|
|
5625
5871
|
const diff = updateOneItemSize(ctx, itemKey, sizeObj);
|
|
5626
5872
|
const size = roundSize(horizontal ? sizeObj.width : sizeObj.height);
|
|
@@ -5631,10 +5877,6 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
5631
5877
|
if (!needsRecalculate && state.containerItemKeys.has(itemKey)) {
|
|
5632
5878
|
needsRecalculate = true;
|
|
5633
5879
|
}
|
|
5634
|
-
if (state.needsOtherAxisSize) {
|
|
5635
|
-
const otherAxisSize = horizontal ? sizeObj.height : sizeObj.width;
|
|
5636
|
-
maxOtherAxisSize = Math.max(maxOtherAxisSize, otherAxisSize);
|
|
5637
|
-
}
|
|
5638
5880
|
if (prevSizeKnown !== void 0 && Math.abs(prevSizeKnown - size) > 5) {
|
|
5639
5881
|
shouldMaintainScrollAtEnd = true;
|
|
5640
5882
|
}
|
|
@@ -5650,10 +5892,7 @@ function updateItemSize(ctx, itemKey, sizeObj) {
|
|
|
5650
5892
|
if (minIndexSizeChanged !== void 0) {
|
|
5651
5893
|
state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, minIndexSizeChanged) : minIndexSizeChanged;
|
|
5652
5894
|
}
|
|
5653
|
-
|
|
5654
|
-
if (!cur || maxOtherAxisSize > cur) {
|
|
5655
|
-
set$(ctx, "otherAxisSize", maxOtherAxisSize);
|
|
5656
|
-
}
|
|
5895
|
+
updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
|
|
5657
5896
|
if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
|
|
5658
5897
|
if (needsRecalculate) {
|
|
5659
5898
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
@@ -6228,7 +6467,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6228
6467
|
getFixedItemSize,
|
|
6229
6468
|
getItemType,
|
|
6230
6469
|
horizontal,
|
|
6470
|
+
rtl,
|
|
6231
6471
|
initialContainerPoolRatio = 3,
|
|
6472
|
+
estimatedHeaderSize,
|
|
6232
6473
|
initialScrollAtEnd = false,
|
|
6233
6474
|
initialScrollIndex: initialScrollIndexProp,
|
|
6234
6475
|
initialScrollOffset: initialScrollOffsetProp,
|
|
@@ -6296,13 +6537,16 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6296
6537
|
const style = { ...StyleSheet.flatten(styleProp) };
|
|
6297
6538
|
const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
|
|
6298
6539
|
const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
|
|
6540
|
+
const stylePaddingLeftState = extractPadding(style, contentContainerStyle, "Left");
|
|
6541
|
+
const stylePaddingRightState = extractPadding(style, contentContainerStyle, "Right");
|
|
6299
6542
|
const maintainScrollAtEndConfig = normalizeMaintainScrollAtEnd(maintainScrollAtEnd);
|
|
6300
6543
|
const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
|
|
6301
6544
|
maintainVisibleContentPositionProp
|
|
6302
6545
|
);
|
|
6303
6546
|
const hasInitialScrollIndex = initialScrollIndexProp !== void 0 && initialScrollIndexProp !== null;
|
|
6304
6547
|
const hasInitialScrollOffset = initialScrollOffsetProp !== void 0 && initialScrollOffsetProp !== null;
|
|
6305
|
-
const
|
|
6548
|
+
const shouldInitializeHorizontalRTL = !initialScrollAtEnd && !hasInitialScrollIndex && !hasInitialScrollOffset && isHorizontalRTLProps({ horizontal, rtl });
|
|
6549
|
+
const initialScrollUsesOffsetOnly = !initialScrollAtEnd && !hasInitialScrollIndex && (hasInitialScrollOffset || shouldInitializeHorizontalRTL);
|
|
6306
6550
|
const usesBootstrapInitialScroll = initialScrollAtEnd || hasInitialScrollIndex;
|
|
6307
6551
|
const initialScrollProp = initialScrollAtEnd ? {
|
|
6308
6552
|
index: Math.max(0, dataProp.length - 1),
|
|
@@ -6418,6 +6662,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6418
6662
|
internalState.reprocessCurrentScroll = () => updateScroll(ctx, internalState.scroll, true);
|
|
6419
6663
|
set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
|
|
6420
6664
|
set$(ctx, "extraData", extraData);
|
|
6665
|
+
if (estimatedHeaderSize !== void 0) {
|
|
6666
|
+
set$(ctx, "headerSize", estimatedHeaderSize);
|
|
6667
|
+
}
|
|
6421
6668
|
}
|
|
6422
6669
|
refState.current = ctx.state;
|
|
6423
6670
|
}
|
|
@@ -6477,11 +6724,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6477
6724
|
positionComponentInternal,
|
|
6478
6725
|
recycleItems: !!recycleItems,
|
|
6479
6726
|
renderItem,
|
|
6727
|
+
rtl,
|
|
6480
6728
|
snapToIndices,
|
|
6481
6729
|
stickyIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
|
|
6482
6730
|
stickyIndicesSet: useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
|
|
6483
6731
|
stickyPositionComponentInternal,
|
|
6484
6732
|
stylePaddingBottom: stylePaddingBottomState,
|
|
6733
|
+
stylePaddingLeft: stylePaddingLeftState,
|
|
6734
|
+
stylePaddingRight: stylePaddingRightState,
|
|
6485
6735
|
stylePaddingTop: stylePaddingTopState,
|
|
6486
6736
|
useWindowScroll: useWindowScrollResolved
|
|
6487
6737
|
};
|
|
@@ -6504,6 +6754,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6504
6754
|
};
|
|
6505
6755
|
if (isFirstLocal) {
|
|
6506
6756
|
initializeStateVars(false);
|
|
6757
|
+
resetLayoutCachesForDataChange(state);
|
|
6507
6758
|
updateItemPositions(
|
|
6508
6759
|
ctx,
|
|
6509
6760
|
/*dataChanged*/
|
|
@@ -6521,6 +6772,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6521
6772
|
}, [usesBootstrapInitialScroll]);
|
|
6522
6773
|
useLayoutEffect(() => {
|
|
6523
6774
|
initializeInitialScrollOnMount(ctx, {
|
|
6775
|
+
alwaysDispatchInitialScroll: shouldInitializeHorizontalRTL,
|
|
6524
6776
|
dataLength: dataProp.length,
|
|
6525
6777
|
hasFooterComponent: !!ListFooterComponent,
|
|
6526
6778
|
initialContentOffset,
|