@legendapp/list 3.0.0-beta.36 → 3.0.0-beta.37
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.ts +4 -0
- package/index.js +106 -58
- package/index.mjs +105 -57
- package/index.native.js +132 -82
- package/index.native.mjs +113 -63
- package/keyboard.js +35 -31
- package/keyboard.mjs +31 -27
- package/package.json +1 -1
- package/react-native.d.ts +4 -0
- package/react-native.js +140 -82
- package/react-native.mjs +121 -64
- package/react.d.ts +4 -0
- package/react.js +106 -58
- package/react.mjs +105 -57
- package/reanimated.d.ts +16 -6
- package/reanimated.js +28 -122
- package/reanimated.mjs +22 -116
- package/section-list.d.ts +1 -1
package/react.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React3 from 'react';
|
|
2
2
|
import React3__default, { forwardRef, useReducer, useEffect, createContext, useRef, useState, useMemo, useCallback, useImperativeHandle, useLayoutEffect, memo, useContext } from 'react';
|
|
3
3
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
4
|
-
import
|
|
4
|
+
import * as ReactDOM from 'react-dom';
|
|
5
|
+
import { flushSync } from 'react-dom';
|
|
5
6
|
|
|
6
7
|
// src/components/LegendList.tsx
|
|
7
8
|
forwardRef(function AnimatedView2(props, ref) {
|
|
@@ -1361,8 +1362,8 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1361
1362
|
updateItemSize: updateItemSize2,
|
|
1362
1363
|
refScrollView,
|
|
1363
1364
|
renderScrollComponent,
|
|
1365
|
+
onLayoutFooter,
|
|
1364
1366
|
scrollAdjustHandler,
|
|
1365
|
-
onLayoutHeader,
|
|
1366
1367
|
snapToIndices,
|
|
1367
1368
|
stickyHeaderConfig,
|
|
1368
1369
|
stickyHeaderIndices,
|
|
@@ -1386,6 +1387,21 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1386
1387
|
set$(ctx, "footerSize", 0);
|
|
1387
1388
|
}
|
|
1388
1389
|
}, [ListHeaderComponent, ListFooterComponent, ctx]);
|
|
1390
|
+
const onLayoutHeader = useCallback(
|
|
1391
|
+
(rect) => {
|
|
1392
|
+
const size = rect[horizontal ? "width" : "height"];
|
|
1393
|
+
set$(ctx, "headerSize", size);
|
|
1394
|
+
},
|
|
1395
|
+
[ctx, horizontal]
|
|
1396
|
+
);
|
|
1397
|
+
const onLayoutFooterInternal = useCallback(
|
|
1398
|
+
(rect, fromLayoutEffect) => {
|
|
1399
|
+
const size = rect[horizontal ? "width" : "height"];
|
|
1400
|
+
set$(ctx, "footerSize", size);
|
|
1401
|
+
onLayoutFooter == null ? void 0 : onLayoutFooter(rect, fromLayoutEffect);
|
|
1402
|
+
},
|
|
1403
|
+
[ctx, horizontal, onLayoutFooter]
|
|
1404
|
+
);
|
|
1389
1405
|
return /* @__PURE__ */ React3.createElement(
|
|
1390
1406
|
SnapOrScroll,
|
|
1391
1407
|
{
|
|
@@ -1421,17 +1437,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1421
1437
|
waitForInitialLayout
|
|
1422
1438
|
}
|
|
1423
1439
|
),
|
|
1424
|
-
ListFooterComponent && /* @__PURE__ */ React3.createElement(
|
|
1425
|
-
LayoutView,
|
|
1426
|
-
{
|
|
1427
|
-
onLayoutChange: (layout) => {
|
|
1428
|
-
const size = layout[horizontal ? "width" : "height"];
|
|
1429
|
-
set$(ctx, "footerSize", size);
|
|
1430
|
-
},
|
|
1431
|
-
style: ListFooterComponentStyle
|
|
1432
|
-
},
|
|
1433
|
-
getComponent(ListFooterComponent)
|
|
1434
|
-
),
|
|
1440
|
+
ListFooterComponent && /* @__PURE__ */ React3.createElement(LayoutView, { onLayoutChange: onLayoutFooterInternal, style: ListFooterComponentStyle }, getComponent(ListFooterComponent)),
|
|
1435
1441
|
IS_DEV && ENABLE_DEVMODE
|
|
1436
1442
|
);
|
|
1437
1443
|
});
|
|
@@ -1439,19 +1445,12 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1439
1445
|
// src/core/calculateOffsetForIndex.ts
|
|
1440
1446
|
function calculateOffsetForIndex(ctx, index) {
|
|
1441
1447
|
const state = ctx.state;
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
}
|
|
1449
|
-
const headerSize = peek$(ctx, "headerSize");
|
|
1450
|
-
if (headerSize) {
|
|
1451
|
-
position += headerSize;
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
return position;
|
|
1448
|
+
return index !== void 0 ? state.positions[index] || 0 : 0;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
// src/core/getTopOffsetAdjustment.ts
|
|
1452
|
+
function getTopOffsetAdjustment(ctx) {
|
|
1453
|
+
return (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
|
|
1455
1454
|
}
|
|
1456
1455
|
|
|
1457
1456
|
// src/utils/getId.ts
|
|
@@ -1557,10 +1556,20 @@ function calculateOffsetWithOffsetPosition(ctx, offsetParam, params) {
|
|
|
1557
1556
|
if (viewOffset) {
|
|
1558
1557
|
offset -= viewOffset;
|
|
1559
1558
|
}
|
|
1559
|
+
if (index !== void 0) {
|
|
1560
|
+
const topOffsetAdjustment = getTopOffsetAdjustment(ctx);
|
|
1561
|
+
if (topOffsetAdjustment) {
|
|
1562
|
+
offset += topOffsetAdjustment;
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1560
1565
|
if (viewPosition !== void 0 && index !== void 0) {
|
|
1561
1566
|
const itemSize = getItemSize(ctx, getId(state, index), index, state.props.data[index]);
|
|
1562
1567
|
const trailingInset = getContentInsetEnd(state);
|
|
1563
1568
|
offset -= viewPosition * (state.scrollLength - trailingInset - itemSize);
|
|
1569
|
+
if (index === state.props.data.length - 1) {
|
|
1570
|
+
const footerSize = peek$(ctx, "footerSize") || 0;
|
|
1571
|
+
offset += footerSize;
|
|
1572
|
+
}
|
|
1564
1573
|
}
|
|
1565
1574
|
return offset;
|
|
1566
1575
|
}
|
|
@@ -1761,6 +1770,7 @@ function finishScrollTo(ctx) {
|
|
|
1761
1770
|
state.initialScroll = void 0;
|
|
1762
1771
|
state.initialAnchor = void 0;
|
|
1763
1772
|
state.scrollingTo = void 0;
|
|
1773
|
+
state.stableTarget = void 0;
|
|
1764
1774
|
if (state.pendingTotalSize !== void 0) {
|
|
1765
1775
|
addTotalSize(ctx, null, state.pendingTotalSize);
|
|
1766
1776
|
}
|
|
@@ -1877,8 +1887,9 @@ function scrollTo(ctx, params) {
|
|
|
1877
1887
|
let offset = precomputedWithViewOffset ? scrollTargetOffset : calculateOffsetWithOffsetPosition(ctx, scrollTargetOffset, scrollTarget);
|
|
1878
1888
|
offset = clampScrollOffset(ctx, offset, scrollTarget);
|
|
1879
1889
|
state.scrollHistory.length = 0;
|
|
1890
|
+
state.stableTarget = void 0;
|
|
1880
1891
|
if (!noScrollingTo) {
|
|
1881
|
-
state.scrollingTo = scrollTarget;
|
|
1892
|
+
state.scrollingTo = { ...scrollTarget, offset };
|
|
1882
1893
|
}
|
|
1883
1894
|
state.scrollPending = offset;
|
|
1884
1895
|
if (forceScroll || !isInitialScroll || Platform.OS === "android") {
|
|
@@ -2653,6 +2664,8 @@ function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
|
|
|
2653
2664
|
const cb = ctx.mapViewabilityCallbacks.get(key);
|
|
2654
2665
|
cb == null ? void 0 : cb(viewToken);
|
|
2655
2666
|
}
|
|
2667
|
+
var unstableBatchedUpdates = ReactDOM.unstable_batchedUpdates;
|
|
2668
|
+
var batchedUpdates = typeof unstableBatchedUpdates === "function" ? unstableBatchedUpdates : (fn) => fn();
|
|
2656
2669
|
|
|
2657
2670
|
// src/utils/checkAllSizesKnown.ts
|
|
2658
2671
|
function isNullOrUndefined2(value) {
|
|
@@ -2905,7 +2918,7 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
|
|
|
2905
2918
|
}
|
|
2906
2919
|
function calculateItemsInView(ctx, params = {}) {
|
|
2907
2920
|
const state = ctx.state;
|
|
2908
|
-
|
|
2921
|
+
batchedUpdates(() => {
|
|
2909
2922
|
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2910
2923
|
const {
|
|
2911
2924
|
columns,
|
|
@@ -3317,6 +3330,14 @@ function checkActualChange(state, dataProp, previousData) {
|
|
|
3317
3330
|
}
|
|
3318
3331
|
|
|
3319
3332
|
// src/core/checkFinishedScroll.ts
|
|
3333
|
+
function getCurrentTargetOffset(ctx, scrollingTo) {
|
|
3334
|
+
if (scrollingTo.index !== void 0) {
|
|
3335
|
+
const baseOffset = calculateOffsetForIndex(ctx, scrollingTo.index);
|
|
3336
|
+
const resolvedOffset = calculateOffsetWithOffsetPosition(ctx, baseOffset, scrollingTo);
|
|
3337
|
+
return clampScrollOffset(ctx, resolvedOffset, scrollingTo);
|
|
3338
|
+
}
|
|
3339
|
+
return clampScrollOffset(ctx, scrollingTo.offset, scrollingTo);
|
|
3340
|
+
}
|
|
3320
3341
|
function checkFinishedScroll(ctx) {
|
|
3321
3342
|
ctx.state.animFrameCheckFinishedScroll = requestAnimationFrame(() => checkFinishedScrollFrame(ctx));
|
|
3322
3343
|
}
|
|
@@ -3326,20 +3347,30 @@ function checkFinishedScrollFrame(ctx) {
|
|
|
3326
3347
|
const { state } = ctx;
|
|
3327
3348
|
state.animFrameCheckFinishedScroll = void 0;
|
|
3328
3349
|
const scroll = state.scrollPending;
|
|
3329
|
-
const
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
scrollingTo
|
|
3334
|
-
);
|
|
3350
|
+
const clampedTargetOffset = getCurrentTargetOffset(ctx, scrollingTo);
|
|
3351
|
+
if (Math.abs(scrollingTo.offset - clampedTargetOffset) >= 1) {
|
|
3352
|
+
state.scrollingTo = { ...scrollingTo, offset: clampedTargetOffset };
|
|
3353
|
+
}
|
|
3335
3354
|
const maxOffset = clampScrollOffset(ctx, scroll, scrollingTo);
|
|
3336
3355
|
const diff1 = Math.abs(scroll - clampedTargetOffset);
|
|
3337
|
-
const diff2 = Math.abs(diff1 - adjust);
|
|
3338
3356
|
const isNotOverscrolled = Math.abs(scroll - maxOffset) < 1;
|
|
3339
|
-
const isAtTarget = diff1 < 1
|
|
3357
|
+
const isAtTarget = diff1 < 1;
|
|
3358
|
+
const previousStableTarget = state.stableTarget;
|
|
3359
|
+
const hasStableTargetFrame = !!previousStableTarget && Math.abs(previousStableTarget.target - clampedTargetOffset) < 1 && Math.abs(previousStableTarget.scroll - scroll) < 1;
|
|
3360
|
+
if (isAtTarget && !hasStableTargetFrame) {
|
|
3361
|
+
state.stableTarget = { scroll, target: clampedTargetOffset };
|
|
3362
|
+
state.animFrameCheckFinishedScroll = requestAnimationFrame(() => checkFinishedScrollFrame(ctx));
|
|
3363
|
+
return;
|
|
3364
|
+
}
|
|
3365
|
+
if (!isAtTarget) {
|
|
3366
|
+
state.stableTarget = void 0;
|
|
3367
|
+
}
|
|
3340
3368
|
if (isNotOverscrolled && isAtTarget) {
|
|
3369
|
+
state.stableTarget = void 0;
|
|
3341
3370
|
finishScrollTo(ctx);
|
|
3342
3371
|
}
|
|
3372
|
+
} else {
|
|
3373
|
+
ctx.state.stableTarget = void 0;
|
|
3343
3374
|
}
|
|
3344
3375
|
}
|
|
3345
3376
|
function checkFinishedScrollFallback(ctx) {
|
|
@@ -4276,7 +4307,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
4276
4307
|
const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
|
|
4277
4308
|
maintainVisibleContentPositionProp
|
|
4278
4309
|
);
|
|
4279
|
-
const [renderNum, setRenderNum] = useState(0);
|
|
4280
4310
|
const initialScrollProp = initialScrollAtEnd ? { index: Math.max(0, dataProp.length - 1), viewOffset: -stylePaddingBottomState, viewPosition: 1 } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? {
|
|
4281
4311
|
index: initialScrollIndexProp.index || 0,
|
|
4282
4312
|
viewOffset: initialScrollIndexProp.viewOffset || (initialScrollIndexProp.viewPosition === 1 ? -stylePaddingBottomState : 0),
|
|
@@ -4476,6 +4506,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
4476
4506
|
true
|
|
4477
4507
|
);
|
|
4478
4508
|
}
|
|
4509
|
+
const resolveInitialScrollOffset = useCallback((initialScroll) => {
|
|
4510
|
+
const baseOffset = initialScroll.index !== void 0 ? calculateOffsetForIndex(ctx, initialScroll.index) : 0;
|
|
4511
|
+
const resolvedOffset = calculateOffsetWithOffsetPosition(ctx, baseOffset, initialScroll);
|
|
4512
|
+
return clampScrollOffset(ctx, resolvedOffset, initialScroll);
|
|
4513
|
+
}, []);
|
|
4479
4514
|
const initialContentOffset = useMemo(() => {
|
|
4480
4515
|
let value;
|
|
4481
4516
|
const { initialScroll, initialAnchor } = refState.current;
|
|
@@ -4483,9 +4518,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
4483
4518
|
if (initialScroll.contentOffset !== void 0) {
|
|
4484
4519
|
value = initialScroll.contentOffset;
|
|
4485
4520
|
} else {
|
|
4486
|
-
const
|
|
4487
|
-
const resolvedOffset = calculateOffsetWithOffsetPosition(ctx, baseOffset, initialScroll);
|
|
4488
|
-
const clampedOffset = clampScrollOffset(ctx, resolvedOffset, initialScroll);
|
|
4521
|
+
const clampedOffset = resolveInitialScrollOffset(initialScroll);
|
|
4489
4522
|
const updatedInitialScroll = { ...initialScroll, contentOffset: clampedOffset };
|
|
4490
4523
|
refState.current.initialScroll = updatedInitialScroll;
|
|
4491
4524
|
state.initialScroll = updatedInitialScroll;
|
|
@@ -4499,7 +4532,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
4499
4532
|
setInitialRenderState(ctx, { didInitialScroll: true });
|
|
4500
4533
|
}
|
|
4501
4534
|
return value;
|
|
4502
|
-
}, [
|
|
4535
|
+
}, []);
|
|
4503
4536
|
if (isFirstLocal || didDataChangeLocal || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
4504
4537
|
refState.current.lastBatchingAction = Date.now();
|
|
4505
4538
|
if (!keyExtractorProp && !isFirstLocal && didDataChangeLocal) {
|
|
@@ -4513,30 +4546,45 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
4513
4546
|
set$(ctx, "totalSize", 0);
|
|
4514
4547
|
}
|
|
4515
4548
|
}
|
|
4516
|
-
const onLayoutHeader = useCallback((rect, fromLayoutEffect) => {
|
|
4517
|
-
const { initialScroll } = refState.current;
|
|
4518
|
-
const size = rect[horizontal ? "width" : "height"];
|
|
4519
|
-
set$(ctx, "headerSize", size);
|
|
4520
|
-
if ((initialScroll == null ? void 0 : initialScroll.index) !== void 0) {
|
|
4521
|
-
{
|
|
4522
|
-
if (fromLayoutEffect) {
|
|
4523
|
-
setRenderNum((v) => v + 1);
|
|
4524
|
-
}
|
|
4525
|
-
}
|
|
4526
|
-
}
|
|
4527
|
-
}, []);
|
|
4528
4549
|
const doInitialScroll = useCallback(() => {
|
|
4529
4550
|
const { initialScroll, didFinishInitialScroll, queuedInitialLayout, scrollingTo } = state;
|
|
4530
4551
|
if (initialScroll && !queuedInitialLayout && !didFinishInitialScroll && !scrollingTo) {
|
|
4552
|
+
const offset = resolveInitialScrollOffset(initialScroll);
|
|
4553
|
+
const updatedInitialScroll = { ...initialScroll, contentOffset: offset };
|
|
4554
|
+
refState.current.initialScroll = updatedInitialScroll;
|
|
4555
|
+
state.initialScroll = updatedInitialScroll;
|
|
4531
4556
|
scrollTo(ctx, {
|
|
4532
4557
|
animated: false,
|
|
4533
|
-
index: initialScroll
|
|
4558
|
+
index: initialScroll.index,
|
|
4534
4559
|
isInitialScroll: true,
|
|
4535
|
-
offset
|
|
4560
|
+
offset,
|
|
4536
4561
|
precomputedWithViewOffset: true
|
|
4537
4562
|
});
|
|
4538
4563
|
}
|
|
4539
|
-
}, [
|
|
4564
|
+
}, []);
|
|
4565
|
+
const onLayoutFooter = useCallback(
|
|
4566
|
+
(layout) => {
|
|
4567
|
+
if (!initialScrollAtEnd) {
|
|
4568
|
+
return;
|
|
4569
|
+
}
|
|
4570
|
+
const { initialScroll } = state;
|
|
4571
|
+
if (!initialScroll) {
|
|
4572
|
+
return;
|
|
4573
|
+
}
|
|
4574
|
+
const lastIndex = Math.max(0, dataProp.length - 1);
|
|
4575
|
+
if (initialScroll.index !== lastIndex || initialScroll.viewPosition !== 1) {
|
|
4576
|
+
return;
|
|
4577
|
+
}
|
|
4578
|
+
const footerSize = layout[horizontal ? "width" : "height"];
|
|
4579
|
+
const viewOffset = -stylePaddingBottomState - footerSize;
|
|
4580
|
+
if (initialScroll.viewOffset !== viewOffset) {
|
|
4581
|
+
const updatedInitialScroll = { ...initialScroll, viewOffset };
|
|
4582
|
+
refState.current.initialScroll = updatedInitialScroll;
|
|
4583
|
+
state.initialScroll = updatedInitialScroll;
|
|
4584
|
+
}
|
|
4585
|
+
},
|
|
4586
|
+
[dataProp.length, horizontal, initialScrollAtEnd, stylePaddingBottomState]
|
|
4587
|
+
);
|
|
4540
4588
|
const onLayoutChange = useCallback((layout) => {
|
|
4541
4589
|
doInitialScroll();
|
|
4542
4590
|
handleLayout(ctx, layout, setCanRender);
|
|
@@ -4645,7 +4693,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
4645
4693
|
ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
|
|
4646
4694
|
ListHeaderComponent,
|
|
4647
4695
|
onLayout,
|
|
4648
|
-
|
|
4696
|
+
onLayoutFooter,
|
|
4649
4697
|
onMomentumScrollEnd: fns.onMomentumScrollEnd,
|
|
4650
4698
|
onScroll: onScrollHandler,
|
|
4651
4699
|
recycleItems,
|
package/reanimated.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
|
-
import { Key, ReactNode, ComponentProps } from 'react';
|
|
2
|
+
import { Key, ReactNode, ReactElement, ComponentProps } from 'react';
|
|
3
3
|
import Reanimated from 'react-native-reanimated';
|
|
4
|
-
import { ScrollViewComponent, ScrollResponderMixin, Insets as Insets$1 } from 'react-native';
|
|
4
|
+
import { ScrollViewProps, NativeSyntheticEvent as NativeSyntheticEvent$1, NativeScrollEvent as NativeScrollEvent$1, ScrollView, StyleProp as StyleProp$1, ViewStyle as ViewStyle$1, ScrollViewComponent, ScrollResponderMixin, Insets as Insets$1 } from 'react-native';
|
|
5
5
|
|
|
6
6
|
type ListenerType = "activeStickyIndex" | "debugComputedScroll" | "debugRawScroll" | "extraData" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "maintainVisibleContentPosition" | "numColumns" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "scrollAdjust" | "scrollAdjustPending" | "scrollAdjustUserOffset" | "scrollSize" | "snapToOffsets" | "stylePaddingTop" | "totalSize" | `containerColumn${number}` | `containerSpan${number}` | `containerItemData${number}` | `containerItemKey${number}` | `containerPosition${number}` | `containerSticky${number}`;
|
|
7
7
|
type LegendListListenerType = Extract<ListenerType, "activeStickyIndex" | "footerSize" | "headerSize" | "lastItemKeys" | "lastPositionUpdate" | "numContainers" | "numContainersPooled" | "otherAxisSize" | "readyToRender" | "snapToOffsets" | "totalSize">;
|
|
@@ -590,21 +590,31 @@ interface ViewabilityConfig {
|
|
|
590
590
|
waitForInteraction?: boolean | undefined;
|
|
591
591
|
}
|
|
592
592
|
|
|
593
|
+
type LegendListPropsOverrides<ItemT, TItemType extends string | undefined> = Omit<LegendListPropsBase<ItemT, ScrollViewProps, TItemType>, "onScroll" | "refScrollView" | "renderScrollComponent" | "ListHeaderComponentStyle" | "ListFooterComponentStyle"> & {
|
|
594
|
+
onScroll?: (event: NativeSyntheticEvent$1<NativeScrollEvent$1>) => void;
|
|
595
|
+
refScrollView?: React.Ref<ScrollView>;
|
|
596
|
+
renderScrollComponent?: (props: ScrollViewProps) => ReactElement<ScrollViewProps>;
|
|
597
|
+
ListHeaderComponentStyle?: StyleProp$1<ViewStyle$1> | undefined;
|
|
598
|
+
ListFooterComponentStyle?: StyleProp$1<ViewStyle$1> | undefined;
|
|
599
|
+
};
|
|
600
|
+
type LegendListProps<ItemT = any, TItemType extends string | undefined = string | undefined> = LegendListPropsOverrides<ItemT, TItemType>;
|
|
593
601
|
type LegendListRef = Omit<LegendListRef$1, "getNativeScrollRef" | "getScrollResponder" | "reportContentInset"> & {
|
|
594
602
|
getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
|
|
595
603
|
getScrollResponder(): ScrollResponderMixin;
|
|
596
604
|
reportContentInset(inset?: Partial<Insets$1> | null): void;
|
|
597
605
|
};
|
|
598
606
|
|
|
599
|
-
type KeysToOmit = "
|
|
600
|
-
type PropsBase<ItemT> =
|
|
601
|
-
|
|
607
|
+
type KeysToOmit = "getEstimatedItemSize" | "getFixedItemSize" | "getItemType" | "itemsAreEqual" | "ItemSeparatorComponent" | "keyExtractor" | "onItemSizeChanged" | "renderItem" | "renderScrollComponent";
|
|
608
|
+
type PropsBase<ItemT> = LegendListProps<ItemT>;
|
|
609
|
+
type ReanimatedLayoutAnimation = ComponentProps<typeof Reanimated.View>["layout"];
|
|
610
|
+
interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit | "refScrollView"> {
|
|
611
|
+
animatedProps?: ComponentProps<typeof Reanimated.ScrollView>["animatedProps"];
|
|
602
612
|
refScrollView?: React$1.Ref<Reanimated.ScrollView>;
|
|
603
613
|
/**
|
|
604
614
|
* Reanimated layout transition applied to each item container position view.
|
|
605
615
|
* Example: `LinearTransition.duration(280)`.
|
|
606
616
|
*/
|
|
607
|
-
itemLayoutAnimation?:
|
|
617
|
+
itemLayoutAnimation?: ReanimatedLayoutAnimation;
|
|
608
618
|
}
|
|
609
619
|
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
610
620
|
type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
|
package/reanimated.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var reactNative = require('react-native');
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactNative$1 = require('react-native');
|
|
5
5
|
var Reanimated = require('react-native-reanimated');
|
|
6
|
-
var reactNative
|
|
7
|
-
var shim = require('use-sync-external-store/shim');
|
|
6
|
+
var reactNative = require('@legendapp/list/react-native');
|
|
8
7
|
|
|
9
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
9
|
|
|
@@ -26,105 +25,12 @@ function _interopNamespace(e) {
|
|
|
26
25
|
return Object.freeze(n);
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
var
|
|
28
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
30
29
|
var Reanimated__default = /*#__PURE__*/_interopDefault(Reanimated);
|
|
31
30
|
|
|
32
31
|
// src/integrations/reanimated.tsx
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var POSITION_OUT_OF_VIEW = -1e7;
|
|
36
|
-
|
|
37
|
-
// src/constants-platform.native.ts
|
|
38
|
-
var f = global.nativeFabricUIManager;
|
|
39
|
-
var IsNewArchitecture = f !== void 0 && f != null;
|
|
40
|
-
var ContextState = React3__namespace.createContext(null);
|
|
41
|
-
function createSelectorFunctionsArr(ctx, signalNames) {
|
|
42
|
-
let lastValues = [];
|
|
43
|
-
let lastSignalValues = [];
|
|
44
|
-
return {
|
|
45
|
-
get: () => {
|
|
46
|
-
const currentValues = [];
|
|
47
|
-
let hasChanged = false;
|
|
48
|
-
for (let i = 0; i < signalNames.length; i++) {
|
|
49
|
-
const value = peek$(ctx, signalNames[i]);
|
|
50
|
-
currentValues.push(value);
|
|
51
|
-
if (value !== lastSignalValues[i]) {
|
|
52
|
-
hasChanged = true;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
lastSignalValues = currentValues;
|
|
56
|
-
if (hasChanged) {
|
|
57
|
-
lastValues = currentValues;
|
|
58
|
-
}
|
|
59
|
-
return lastValues;
|
|
60
|
-
},
|
|
61
|
-
subscribe: (cb) => {
|
|
62
|
-
const listeners = [];
|
|
63
|
-
for (const signalName of signalNames) {
|
|
64
|
-
listeners.push(listen$(ctx, signalName, cb));
|
|
65
|
-
}
|
|
66
|
-
return () => {
|
|
67
|
-
for (const listener of listeners) {
|
|
68
|
-
listener();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function listen$(ctx, signalName, cb) {
|
|
75
|
-
const { listeners } = ctx;
|
|
76
|
-
let setListeners = listeners.get(signalName);
|
|
77
|
-
if (!setListeners) {
|
|
78
|
-
setListeners = /* @__PURE__ */ new Set();
|
|
79
|
-
listeners.set(signalName, setListeners);
|
|
80
|
-
}
|
|
81
|
-
setListeners.add(cb);
|
|
82
|
-
return () => setListeners.delete(cb);
|
|
83
|
-
}
|
|
84
|
-
function peek$(ctx, signalName) {
|
|
85
|
-
const { values } = ctx;
|
|
86
|
-
return values.get(signalName);
|
|
87
|
-
}
|
|
88
|
-
function useArr$(signalNames) {
|
|
89
|
-
const ctx = React3__namespace.useContext(ContextState);
|
|
90
|
-
const { subscribe, get } = React3__namespace.useMemo(() => createSelectorFunctionsArr(ctx, signalNames), [ctx, signalNames]);
|
|
91
|
-
const value = shim.useSyncExternalStore(subscribe, get);
|
|
92
|
-
return value;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// src/utils/helpers.ts
|
|
96
|
-
function isFunction(obj) {
|
|
97
|
-
return typeof obj === "function";
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// src/hooks/useCombinedRef.ts
|
|
101
|
-
var useCombinedRef = (...refs) => {
|
|
102
|
-
const callback = React3.useCallback((element) => {
|
|
103
|
-
for (const ref of refs) {
|
|
104
|
-
if (!ref) {
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
if (isFunction(ref)) {
|
|
108
|
-
ref(element);
|
|
109
|
-
} else {
|
|
110
|
-
ref.current = element;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}, refs);
|
|
114
|
-
return callback;
|
|
115
|
-
};
|
|
116
|
-
var getComponent = (Component) => {
|
|
117
|
-
if (React3__namespace.isValidElement(Component)) {
|
|
118
|
-
return Component;
|
|
119
|
-
}
|
|
120
|
-
if (Component) {
|
|
121
|
-
return /* @__PURE__ */ React3__namespace.createElement(Component, null);
|
|
122
|
-
}
|
|
123
|
-
return null;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// src/integrations/reanimated.tsx
|
|
127
|
-
var typedMemo = React3.memo;
|
|
32
|
+
var { POSITION_OUT_OF_VIEW, IsNewArchitecture, useArr$, useCombinedRef, getComponent } = reactNative.internal;
|
|
33
|
+
var typedMemo = React.memo;
|
|
128
34
|
var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent({
|
|
129
35
|
forwardedRef,
|
|
130
36
|
scrollOffset,
|
|
@@ -133,14 +39,14 @@ var ReanimatedScrollBridge = typedMemo(function ReanimatedScrollBridgeComponent(
|
|
|
133
39
|
const animatedScrollRef = Reanimated.useAnimatedRef();
|
|
134
40
|
Reanimated.useScrollViewOffset(animatedScrollRef, scrollOffset);
|
|
135
41
|
const combinedRef = useCombinedRef(animatedScrollRef, forwardedRef);
|
|
136
|
-
return /* @__PURE__ */
|
|
42
|
+
return /* @__PURE__ */ React__namespace.createElement(Reanimated__default.default.ScrollView, { ...props, ref: combinedRef });
|
|
137
43
|
});
|
|
138
44
|
var StickyOverlay = typedMemo(function StickyOverlayComponent({ stickyHeaderConfig }) {
|
|
139
45
|
if (!(stickyHeaderConfig == null ? void 0 : stickyHeaderConfig.backdropComponent)) {
|
|
140
46
|
return null;
|
|
141
47
|
}
|
|
142
|
-
return /* @__PURE__ */
|
|
143
|
-
reactNative.View,
|
|
48
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
49
|
+
reactNative$1.View,
|
|
144
50
|
{
|
|
145
51
|
style: {
|
|
146
52
|
inset: 0,
|
|
@@ -165,11 +71,11 @@ var ReanimatedPositionViewSticky = typedMemo(function ReanimatedPositionViewStic
|
|
|
165
71
|
const delta = Math.max(0, stickyScrollOffset.value - stickyStart);
|
|
166
72
|
return horizontal ? { transform: [{ translateX: position + delta }] } : { transform: [{ translateY: position + delta }] };
|
|
167
73
|
}, [horizontal, position, stickyStart]);
|
|
168
|
-
const viewStyle =
|
|
74
|
+
const viewStyle = React__namespace.useMemo(
|
|
169
75
|
() => [style, { zIndex: index + 1e3 }, transformStyle],
|
|
170
76
|
[index, style, transformStyle]
|
|
171
77
|
);
|
|
172
|
-
return /* @__PURE__ */
|
|
78
|
+
return /* @__PURE__ */ React__namespace.createElement(Reanimated__default.default.View, { ref: refView, style: viewStyle, ...rest }, /* @__PURE__ */ React__namespace.createElement(StickyOverlay, { stickyHeaderConfig }), children);
|
|
173
79
|
});
|
|
174
80
|
var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(props) {
|
|
175
81
|
const { id, horizontal, style, refView, children, recycleItems, layoutTransition, ...rest } = props;
|
|
@@ -177,18 +83,18 @@ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(
|
|
|
177
83
|
`containerPosition${id}`,
|
|
178
84
|
`containerItemKey${id}`
|
|
179
85
|
]);
|
|
180
|
-
const prevItemKeyRef =
|
|
86
|
+
const prevItemKeyRef = React__namespace.useRef(void 0);
|
|
181
87
|
const shouldSkipTransitionForRecycleReuse = !!recycleItems && itemKey !== void 0 && prevItemKeyRef.current !== void 0 && prevItemKeyRef.current !== itemKey;
|
|
182
|
-
|
|
88
|
+
React__namespace.useEffect(() => {
|
|
183
89
|
if (itemKey !== void 0) {
|
|
184
90
|
prevItemKeyRef.current = itemKey;
|
|
185
91
|
}
|
|
186
92
|
}, [itemKey]);
|
|
187
|
-
const viewStyle =
|
|
93
|
+
const viewStyle = React__namespace.useMemo(
|
|
188
94
|
() => [style, horizontal ? { left: positionValue } : { top: positionValue }],
|
|
189
95
|
[horizontal, positionValue, style]
|
|
190
96
|
);
|
|
191
|
-
return /* @__PURE__ */
|
|
97
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
192
98
|
Reanimated__default.default.View,
|
|
193
99
|
{
|
|
194
100
|
layout: shouldSkipTransitionForRecycleReuse ? void 0 : layoutTransition,
|
|
@@ -201,9 +107,9 @@ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(
|
|
|
201
107
|
});
|
|
202
108
|
var LegendListForwardedRef = typedMemo(
|
|
203
109
|
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
204
|
-
|
|
110
|
+
React__namespace.forwardRef(function LegendListForwardedRef2(props, ref) {
|
|
205
111
|
const { itemLayoutAnimation, recycleItems, refLegendList, ...rest } = props;
|
|
206
|
-
const refFn =
|
|
112
|
+
const refFn = React.useCallback(
|
|
207
113
|
(r) => {
|
|
208
114
|
refLegendList(r);
|
|
209
115
|
},
|
|
@@ -211,10 +117,10 @@ var LegendListForwardedRef = typedMemo(
|
|
|
211
117
|
);
|
|
212
118
|
const stickyScrollOffset = Reanimated.useSharedValue(0);
|
|
213
119
|
const shouldUseReanimatedScrollView = IsNewArchitecture;
|
|
214
|
-
const renderReanimatedScrollComponent =
|
|
120
|
+
const renderReanimatedScrollComponent = React.useCallback(
|
|
215
121
|
(scrollViewProps) => {
|
|
216
122
|
const { ref: forwardedRef, ...restScrollViewProps } = scrollViewProps;
|
|
217
|
-
return /* @__PURE__ */
|
|
123
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
218
124
|
ReanimatedScrollBridge,
|
|
219
125
|
{
|
|
220
126
|
...restScrollViewProps,
|
|
@@ -225,21 +131,21 @@ var LegendListForwardedRef = typedMemo(
|
|
|
225
131
|
},
|
|
226
132
|
[stickyScrollOffset]
|
|
227
133
|
);
|
|
228
|
-
const stickyPositionComponentInternal =
|
|
134
|
+
const stickyPositionComponentInternal = React__namespace.useMemo(
|
|
229
135
|
() => function StickyPositionComponent(stickyProps) {
|
|
230
|
-
return /* @__PURE__ */
|
|
136
|
+
return /* @__PURE__ */ React__namespace.createElement(ReanimatedPositionViewSticky, { ...stickyProps, stickyScrollOffset });
|
|
231
137
|
},
|
|
232
138
|
[stickyScrollOffset]
|
|
233
139
|
);
|
|
234
|
-
const itemLayoutAnimationRef =
|
|
140
|
+
const itemLayoutAnimationRef = React__namespace.useRef(itemLayoutAnimation);
|
|
235
141
|
itemLayoutAnimationRef.current = itemLayoutAnimation;
|
|
236
142
|
const hasItemLayoutAnimation = !!itemLayoutAnimation;
|
|
237
|
-
const positionComponentInternal =
|
|
143
|
+
const positionComponentInternal = React__namespace.useMemo(() => {
|
|
238
144
|
if (!hasItemLayoutAnimation) {
|
|
239
145
|
return void 0;
|
|
240
146
|
}
|
|
241
147
|
return function PositionComponent(positionProps) {
|
|
242
|
-
return /* @__PURE__ */
|
|
148
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
243
149
|
ReanimatedPositionView,
|
|
244
150
|
{
|
|
245
151
|
...positionProps,
|
|
@@ -257,18 +163,18 @@ var LegendListForwardedRef = typedMemo(
|
|
|
257
163
|
stickyPositionComponentInternal
|
|
258
164
|
} : {}
|
|
259
165
|
};
|
|
260
|
-
return /* @__PURE__ */
|
|
166
|
+
return /* @__PURE__ */ React__namespace.createElement(reactNative.LegendList, { ref: refFn, refScrollView: ref, ...legendListProps });
|
|
261
167
|
})
|
|
262
168
|
);
|
|
263
169
|
var AnimatedLegendListComponent = Reanimated__default.default.createAnimatedComponent(LegendListForwardedRef);
|
|
264
170
|
var AnimatedLegendList = typedMemo(
|
|
265
171
|
// biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
|
|
266
|
-
|
|
172
|
+
React__namespace.forwardRef(function AnimatedLegendList2(props, ref) {
|
|
267
173
|
const { refScrollView, ...rest } = props;
|
|
268
174
|
const { animatedProps } = props;
|
|
269
|
-
const refLegendList =
|
|
175
|
+
const refLegendList = React__namespace.useRef(null);
|
|
270
176
|
const combinedRef = useCombinedRef(refLegendList, ref);
|
|
271
|
-
return /* @__PURE__ */
|
|
177
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
272
178
|
AnimatedLegendListComponent,
|
|
273
179
|
{
|
|
274
180
|
animatedPropsInternal: animatedProps,
|