@onekeyfe/react-native-native-list 6.7.0-6 → 6.7.0-60
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/README.md +312 -375
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +250 -9
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +50 -13
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +47 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +152 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +209 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -287
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +7 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +8 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +130 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1978 -136
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
- package/docs/ROW_TEMPLATES.md +78 -14
- package/docs/SPEC.md +1318 -16
- package/docs/STYLE_SPEC.md +18 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +237 -51
- package/ios/NativeListActivityDetailsView.swift +43 -16
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +167 -30
- package/ios/NativeListDesignAssets.swift +13 -75
- package/ios/NativeListGeneratedIcons.swift +55 -0
- package/ios/NativeListIconBinding.swift +171 -0
- package/ios/NativeListIdentityRenderer.swift +256 -39
- package/ios/NativeListLeadingVisual.swift +127 -28
- package/ios/NativeListMarketRenderer.swift +120 -31
- package/ios/NativeListMediaPlaceholderView.swift +189 -0
- package/ios/NativeListMediaPreviewSlot.swift +122 -61
- package/ios/NativeListMediaTileRenderer.swift +15 -11
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListMetricCardRenderer.swift +4 -2
- package/ios/NativeListModels.swift +42 -2
- package/ios/NativeListRendererRegistry.swift +1 -0
- package/ios/NativeListResolvedText.swift +17 -5
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +100 -4
- package/ios/NativeListTextLabel.swift +106 -0
- package/ios/RNCNativeListView.swift +1097 -60
- package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
- package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +423 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
- package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
- package/ios/tests/NativeListLifecycleTests.swift +2959 -4
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/ios/tests/NativeListMediaVisibilityTests.swift +27 -1
- package/ios/tests/NativeListSharedIconTests.swift +236 -0
- package/lib/module/NativeList.js +236 -38
- package/lib/module/NativeList.web.js +163 -45
- package/lib/module/index.js +1 -1
- package/lib/module/models.js +3 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +1263 -48
- package/lib/module/web/NativeListGeneratedIcons.js +31 -0
- package/lib/module/web/NativeListWebEngine.js +513 -275
- package/lib/module/web/templates/ActivityRowRenderer.js +41 -54
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +56 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +161 -7
- package/lib/module/web/templates/MarketTableRowRenderer.js +36 -19
- package/lib/module/web/templates/MediaTileRowRenderer.js +84 -25
- package/lib/module/web/templates/MessageRowRenderer.js +18 -2
- package/lib/module/web/templates/RowContainerStyle.js +1 -0
- package/lib/module/web/templates/RowRendererRegistry.js +3 -0
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/lib/typescript/src/NativeList.d.ts +3 -3
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
- package/lib/typescript/src/NativeList.types.d.ts +20 -2
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +134 -17
- package/lib/typescript/src/validation.d.ts +20 -0
- package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +32 -1
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/package.json +16 -10
- package/react-native-native-list.podspec +2 -6
- package/scripts/generate-icons.mjs +150 -0
- package/scripts/generate-icons.test.mjs +288 -0
- package/scripts/native-list-icons.json +260 -0
- package/src/NativeList.nitro.ts +2 -0
- package/src/NativeList.tsx +439 -91
- package/src/NativeList.types.ts +24 -2
- package/src/NativeList.web.tsx +286 -88
- package/src/index.ts +2 -0
- package/src/models.ts +272 -144
- package/src/selection.ts +1 -0
- package/src/validation.ts +3041 -146
- package/src/web/NativeListGeneratedIcons.ts +28 -0
- package/src/web/NativeListWebEngine.ts +818 -343
- package/src/web/templates/ActivityRowRenderer.ts +71 -91
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +121 -20
- package/src/web/templates/IdentityRowRenderer.ts +234 -9
- package/src/web/templates/MarketTableRowRenderer.ts +53 -33
- package/src/web/templates/MediaTileRowRenderer.ts +90 -28
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +11 -1
- package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
- package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
package/src/NativeList.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useNativeListFontFamiliesJson } from './fonts';
|
|
2
2
|
import React, {
|
|
3
3
|
forwardRef,
|
|
4
|
+
useCallback,
|
|
4
5
|
useEffect,
|
|
5
6
|
useImperativeHandle,
|
|
6
7
|
useMemo,
|
|
@@ -24,13 +25,18 @@ import type {
|
|
|
24
25
|
import type {
|
|
25
26
|
ActionAnchorInvalidatedEvent,
|
|
26
27
|
ImageSource,
|
|
28
|
+
NativeListSnapshot,
|
|
27
29
|
RowActionEvent,
|
|
28
30
|
SelectionDeltaEvent,
|
|
29
31
|
ReorderEvent,
|
|
30
32
|
EndReachedEvent,
|
|
31
33
|
VisibleRangeChangedEvent,
|
|
32
34
|
} from './models';
|
|
33
|
-
import type {
|
|
35
|
+
import type {
|
|
36
|
+
NativeListProps,
|
|
37
|
+
NativeListRef,
|
|
38
|
+
StructuralTransitionSettledEvent,
|
|
39
|
+
} from './NativeList.types';
|
|
34
40
|
import { isSelectableRow } from './selection';
|
|
35
41
|
import {
|
|
36
42
|
normalizeIndexScroll,
|
|
@@ -42,12 +48,19 @@ import {
|
|
|
42
48
|
type NormalizedPositionScroll,
|
|
43
49
|
} from './scrolling';
|
|
44
50
|
import {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
applyOwnedNativePatches,
|
|
52
|
+
captureNativeListInput,
|
|
53
|
+
containNativeListInput,
|
|
54
|
+
emptyNativeListSnapshot,
|
|
55
|
+
ownValidatedNativeSnapshot,
|
|
56
|
+
validateSnapshot,
|
|
48
57
|
} from './validation';
|
|
49
58
|
|
|
50
|
-
export type {
|
|
59
|
+
export type {
|
|
60
|
+
NativeListProps,
|
|
61
|
+
NativeListRef,
|
|
62
|
+
StructuralTransitionSettledEvent,
|
|
63
|
+
} from './NativeList.types';
|
|
51
64
|
export type {
|
|
52
65
|
ActionAnchorState,
|
|
53
66
|
NativeListKeyboardDismissMode,
|
|
@@ -69,6 +82,8 @@ const NativeListHost = getHostComponent<
|
|
|
69
82
|
NativeListNativeProps,
|
|
70
83
|
NativeListMethods
|
|
71
84
|
>('NativeList', () => NativeListConfig);
|
|
85
|
+
const clearedStructuralTransitionSettled = { f: undefined } as const;
|
|
86
|
+
const disclosureSlotMeasurementStyle = { alignSelf: 'stretch' } as const;
|
|
72
87
|
|
|
73
88
|
export function preloadNativeListAvatarImages(
|
|
74
89
|
sources: readonly ImageSource[]
|
|
@@ -98,10 +113,14 @@ function parsePayload<T>(payloadJson: string): T {
|
|
|
98
113
|
export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
99
114
|
function NativeList(
|
|
100
115
|
{
|
|
101
|
-
snapshot,
|
|
116
|
+
snapshot: inputSnapshot,
|
|
102
117
|
listHeader,
|
|
103
118
|
listFooter,
|
|
104
119
|
listEmpty,
|
|
120
|
+
listSidecar,
|
|
121
|
+
listExpandedContent,
|
|
122
|
+
listStructureToggle,
|
|
123
|
+
sidecarLayout,
|
|
105
124
|
topOverlay,
|
|
106
125
|
topScrollEdgeEffect,
|
|
107
126
|
scrollPositionThresholds,
|
|
@@ -117,6 +136,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
117
136
|
onReorder,
|
|
118
137
|
onEndReached,
|
|
119
138
|
onVisibleRangeChanged,
|
|
139
|
+
onStructuralTransitionSettled,
|
|
120
140
|
onScrollPositionThresholdChange,
|
|
121
141
|
onRefresh,
|
|
122
142
|
onScrollToIndexFailed,
|
|
@@ -128,28 +148,242 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
128
148
|
},
|
|
129
149
|
forwardedRef
|
|
130
150
|
) {
|
|
151
|
+
const snapshotRef = useRef<NativeListSnapshot>(emptyNativeListSnapshot());
|
|
152
|
+
const needsNativeSnapshotRef = useRef(false);
|
|
153
|
+
const renderedSnapshotRef = useRef<NativeListSnapshot | undefined>(
|
|
154
|
+
undefined
|
|
155
|
+
);
|
|
156
|
+
const initializedSnapshot = useRef(false);
|
|
157
|
+
const pendingDisclosureSnapshotRef = useRef<
|
|
158
|
+
| {
|
|
159
|
+
source: 'prop' | 'imperative';
|
|
160
|
+
input: NativeListSnapshot;
|
|
161
|
+
owned: NativeListSnapshot;
|
|
162
|
+
expandedEpoch: number;
|
|
163
|
+
toggleEpoch: number;
|
|
164
|
+
}
|
|
165
|
+
| undefined
|
|
166
|
+
>(undefined);
|
|
167
|
+
const previousPropInputRef = useRef(inputSnapshot);
|
|
168
|
+
const [pendingDisclosureRevision, setPendingDisclosureRevision] =
|
|
169
|
+
useState(0);
|
|
170
|
+
const disclosureSlotMounts = useRef({
|
|
171
|
+
expandedPresent: false,
|
|
172
|
+
togglePresent: false,
|
|
173
|
+
expandedEpoch: 0,
|
|
174
|
+
toggleEpoch: 0,
|
|
175
|
+
});
|
|
176
|
+
const expandedPresent = listExpandedContent != null;
|
|
177
|
+
const togglePresent = listStructureToggle != null;
|
|
178
|
+
if (disclosureSlotMounts.current.expandedPresent !== expandedPresent) {
|
|
179
|
+
disclosureSlotMounts.current.expandedPresent = expandedPresent;
|
|
180
|
+
disclosureSlotMounts.current.expandedEpoch += 1;
|
|
181
|
+
}
|
|
182
|
+
if (disclosureSlotMounts.current.togglePresent !== togglePresent) {
|
|
183
|
+
disclosureSlotMounts.current.togglePresent = togglePresent;
|
|
184
|
+
disclosureSlotMounts.current.toggleEpoch += 1;
|
|
185
|
+
}
|
|
186
|
+
const expandedEpoch = disclosureSlotMounts.current.expandedEpoch;
|
|
187
|
+
const toggleEpoch = disclosureSlotMounts.current.toggleEpoch;
|
|
188
|
+
const iosHeaderPresent = Platform.OS === 'ios' && listHeader != null;
|
|
189
|
+
const [slotMeasurements, setSlotMeasurements] = useState({
|
|
190
|
+
heights: [0, 0, 0, 0, 0, 0],
|
|
191
|
+
readyEpochs: [-1, -1, -1, -1, -1, -1],
|
|
192
|
+
iosHeaderPresent,
|
|
193
|
+
headerEpoch: 0,
|
|
194
|
+
});
|
|
195
|
+
if (slotMeasurements.iosHeaderPresent !== iosHeaderPresent) {
|
|
196
|
+
setSlotMeasurements({
|
|
197
|
+
...slotMeasurements,
|
|
198
|
+
iosHeaderPresent,
|
|
199
|
+
headerEpoch: slotMeasurements.headerEpoch + 1,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
const headerEpoch = slotMeasurements.headerEpoch;
|
|
203
|
+
const hasSidecar = listSidecar !== undefined;
|
|
204
|
+
const sidecarWidth = sidecarLayout?.width;
|
|
205
|
+
const sidecarGap = sidecarLayout?.gap;
|
|
206
|
+
const sidecarMaxContentWidth = sidecarLayout?.maxContentWidth;
|
|
207
|
+
const hasContainerSlots = Boolean(
|
|
208
|
+
listHeader ||
|
|
209
|
+
listEmpty ||
|
|
210
|
+
listFooter ||
|
|
211
|
+
listSidecar ||
|
|
212
|
+
listExpandedContent ||
|
|
213
|
+
listStructureToggle
|
|
214
|
+
);
|
|
215
|
+
const validateContainerConfiguration = useCallback(
|
|
216
|
+
(accepted: NativeListSnapshot) => {
|
|
217
|
+
if (hasContainerSlots && accepted.layout.orientation === 'horizontal')
|
|
218
|
+
throw new Error(
|
|
219
|
+
'NativeList container slots require vertical orientation'
|
|
220
|
+
);
|
|
221
|
+
if (hasSidecar !== (sidecarWidth !== undefined))
|
|
222
|
+
throw new Error(
|
|
223
|
+
'listSidecar and sidecarLayout must be supplied together'
|
|
224
|
+
);
|
|
225
|
+
if (sidecarWidth !== undefined) {
|
|
226
|
+
const width = sidecarWidth;
|
|
227
|
+
const gap = sidecarGap ?? NaN;
|
|
228
|
+
const maxContentWidth = sidecarMaxContentWidth ?? NaN;
|
|
229
|
+
if (
|
|
230
|
+
accepted.layout.kind !== 'linear' ||
|
|
231
|
+
!Number.isFinite(width) ||
|
|
232
|
+
width <= 0 ||
|
|
233
|
+
!Number.isFinite(gap) ||
|
|
234
|
+
gap < 0 ||
|
|
235
|
+
!Number.isFinite(maxContentWidth) ||
|
|
236
|
+
maxContentWidth <= width + gap
|
|
237
|
+
)
|
|
238
|
+
throw new Error('Invalid NativeList sidecar layout');
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
[
|
|
242
|
+
hasContainerSlots,
|
|
243
|
+
hasSidecar,
|
|
244
|
+
sidecarWidth,
|
|
245
|
+
sidecarGap,
|
|
246
|
+
sidecarMaxContentWidth,
|
|
247
|
+
]
|
|
248
|
+
);
|
|
249
|
+
const prepareSnapshot = useCallback(
|
|
250
|
+
(next: NativeListSnapshot) => {
|
|
251
|
+
const accepted = validateSnapshot(captureNativeListInput(next));
|
|
252
|
+
validateContainerConfiguration(accepted);
|
|
253
|
+
return ownValidatedNativeSnapshot(accepted);
|
|
254
|
+
},
|
|
255
|
+
[validateContainerConfiguration]
|
|
256
|
+
);
|
|
257
|
+
const expandedReadyEpoch = slotMeasurements.readyEpochs[4];
|
|
258
|
+
const toggleReadyEpoch = slotMeasurements.readyEpochs[5];
|
|
259
|
+
const snapshot = useMemo(() => {
|
|
260
|
+
// Imperative pending snapshots use this revision to retry the readiness gate.
|
|
261
|
+
// eslint-disable-next-line no-void -- Reading this revision invalidates the readiness memo.
|
|
262
|
+
void pendingDisclosureRevision;
|
|
263
|
+
const propReplaced = previousPropInputRef.current !== inputSnapshot;
|
|
264
|
+
previousPropInputRef.current = inputSnapshot;
|
|
265
|
+
const pending = pendingDisclosureSnapshotRef.current;
|
|
266
|
+
const retained =
|
|
267
|
+
pending &&
|
|
268
|
+
!propReplaced &&
|
|
269
|
+
(pending.source === 'imperative' || pending.input === inputSnapshot) &&
|
|
270
|
+
pending.expandedEpoch === expandedEpoch &&
|
|
271
|
+
pending.toggleEpoch === toggleEpoch
|
|
272
|
+
? pending
|
|
273
|
+
: undefined;
|
|
274
|
+
const candidate =
|
|
275
|
+
retained?.owned ??
|
|
276
|
+
(!propReplaced && initializedSnapshot.current
|
|
277
|
+
? renderedSnapshotRef.current ?? snapshotRef.current
|
|
278
|
+
: containNativeListInput(() => prepareSnapshot(inputSnapshot)) ??
|
|
279
|
+
snapshotRef.current);
|
|
280
|
+
const acceptedCandidate =
|
|
281
|
+
!propReplaced && initializedSnapshot.current
|
|
282
|
+
? containNativeListInput(() => {
|
|
283
|
+
validateContainerConfiguration(candidate);
|
|
284
|
+
return candidate;
|
|
285
|
+
})
|
|
286
|
+
: candidate;
|
|
287
|
+
if (!acceptedCandidate) {
|
|
288
|
+
pendingDisclosureSnapshotRef.current = undefined;
|
|
289
|
+
return renderedSnapshotRef.current ?? snapshotRef.current;
|
|
290
|
+
}
|
|
291
|
+
const transitionId = acceptedCandidate.structuralTransition?.id;
|
|
292
|
+
const newDisclosureCommand =
|
|
293
|
+
initializedSnapshot.current &&
|
|
294
|
+
acceptedCandidate.disclosure !== undefined &&
|
|
295
|
+
transitionId !== undefined &&
|
|
296
|
+
transitionId !== snapshotRef.current.structuralTransition?.id;
|
|
297
|
+
if (
|
|
298
|
+
newDisclosureCommand &&
|
|
299
|
+
((expandedPresent && expandedReadyEpoch !== expandedEpoch) ||
|
|
300
|
+
(togglePresent && toggleReadyEpoch !== toggleEpoch))
|
|
301
|
+
) {
|
|
302
|
+
pendingDisclosureSnapshotRef.current = retained ?? {
|
|
303
|
+
source: 'prop',
|
|
304
|
+
input: inputSnapshot,
|
|
305
|
+
owned: acceptedCandidate,
|
|
306
|
+
expandedEpoch,
|
|
307
|
+
toggleEpoch,
|
|
308
|
+
};
|
|
309
|
+
return snapshotRef.current;
|
|
310
|
+
}
|
|
311
|
+
pendingDisclosureSnapshotRef.current = undefined;
|
|
312
|
+
return acceptedCandidate;
|
|
313
|
+
}, [
|
|
314
|
+
inputSnapshot,
|
|
315
|
+
prepareSnapshot,
|
|
316
|
+
validateContainerConfiguration,
|
|
317
|
+
expandedPresent,
|
|
318
|
+
togglePresent,
|
|
319
|
+
expandedEpoch,
|
|
320
|
+
toggleEpoch,
|
|
321
|
+
expandedReadyEpoch,
|
|
322
|
+
toggleReadyEpoch,
|
|
323
|
+
pendingDisclosureRevision,
|
|
324
|
+
]);
|
|
325
|
+
renderedSnapshotRef.current = snapshot;
|
|
131
326
|
const fontFamiliesJson = useNativeListFontFamiliesJson();
|
|
132
|
-
const
|
|
327
|
+
const slotHeights = slotMeasurements.heights;
|
|
328
|
+
const [viewportWidth, setViewportWidth] = useState(0);
|
|
133
329
|
const [topOverlayHeight, setTopOverlayHeight] = useState(0);
|
|
134
330
|
const hasTopOverlay =
|
|
135
331
|
Platform?.OS === 'ios' &&
|
|
136
332
|
parseInt(String(Platform.Version), 10) >= 26 &&
|
|
137
333
|
(topScrollEdgeEffect === 'hard' || topScrollEdgeEffect === 'soft') &&
|
|
138
334
|
topOverlay != null;
|
|
139
|
-
const containerSlotHeightsJson = JSON.stringify(
|
|
140
|
-
|
|
335
|
+
const containerSlotHeightsJson = JSON.stringify(
|
|
336
|
+
Platform.OS === 'ios' &&
|
|
337
|
+
(!iosHeaderPresent || slotMeasurements.readyEpochs[0] !== headerEpoch)
|
|
338
|
+
? [iosHeaderPresent ? null : 0, ...slotHeights.slice(1)]
|
|
339
|
+
: slotHeights
|
|
340
|
+
);
|
|
341
|
+
const defaultSlotInset =
|
|
141
342
|
snapshot.layout.contentPaddingHorizontal ??
|
|
142
343
|
snapshot.layout.contentPadding ??
|
|
143
344
|
0;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
345
|
+
const bandWidth = sidecarLayout
|
|
346
|
+
? Math.min(viewportWidth, sidecarLayout.maxContentWidth)
|
|
347
|
+
: 0;
|
|
348
|
+
const slotInset = sidecarLayout
|
|
349
|
+
? Math.max(0, (viewportWidth - bandWidth) / 2) + defaultSlotInset
|
|
350
|
+
: defaultSlotInset;
|
|
351
|
+
const sidecarSpace = sidecarLayout
|
|
352
|
+
? sidecarLayout.width + sidecarLayout.gap
|
|
353
|
+
: 0;
|
|
354
|
+
const slotContents = [
|
|
355
|
+
listHeader,
|
|
356
|
+
listEmpty,
|
|
357
|
+
listFooter,
|
|
358
|
+
listSidecar,
|
|
359
|
+
listExpandedContent,
|
|
360
|
+
listStructureToggle,
|
|
361
|
+
];
|
|
362
|
+
const recordSlotLayout = (index: number, height: number, epoch: number) => {
|
|
363
|
+
if (
|
|
364
|
+
(index === 4 && epoch !== disclosureSlotMounts.current.expandedEpoch) ||
|
|
365
|
+
(index === 5 && epoch !== disclosureSlotMounts.current.toggleEpoch)
|
|
366
|
+
) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
setSlotMeasurements((previous) => {
|
|
370
|
+
if (index === 0 && epoch !== previous.headerEpoch) return previous;
|
|
371
|
+
if (
|
|
372
|
+
previous.heights[index] === height &&
|
|
373
|
+
previous.readyEpochs[index] === epoch
|
|
374
|
+
) {
|
|
375
|
+
return previous;
|
|
376
|
+
}
|
|
377
|
+
const heights = [...previous.heights];
|
|
378
|
+
const readyEpochs = [...previous.readyEpochs];
|
|
379
|
+
heights[index] = height;
|
|
380
|
+
readyEpochs[index] = epoch;
|
|
381
|
+
return { ...previous, heights, readyEpochs };
|
|
382
|
+
});
|
|
383
|
+
};
|
|
384
|
+
const sidecarLayoutJson = sidecarLayout
|
|
385
|
+
? JSON.stringify(sidecarLayout)
|
|
386
|
+
: '';
|
|
153
387
|
const normalizedKeyboardShouldPersistTaps =
|
|
154
388
|
keyboardShouldPersistTaps === true
|
|
155
389
|
? 'always'
|
|
@@ -164,6 +398,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
164
398
|
onReorder,
|
|
165
399
|
onEndReached,
|
|
166
400
|
onVisibleRangeChanged,
|
|
401
|
+
onStructuralTransitionSettled,
|
|
167
402
|
onScrollPositionThresholdChange,
|
|
168
403
|
onRefresh,
|
|
169
404
|
onScrollToIndexFailed,
|
|
@@ -175,37 +410,45 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
175
410
|
onReorder,
|
|
176
411
|
onEndReached,
|
|
177
412
|
onVisibleRangeChanged,
|
|
413
|
+
onStructuralTransitionSettled,
|
|
178
414
|
onScrollPositionThresholdChange,
|
|
179
415
|
onRefresh,
|
|
180
416
|
onScrollToIndexFailed,
|
|
181
417
|
};
|
|
182
|
-
const scrollPositionThresholdsJson = useMemo(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
418
|
+
const scrollPositionThresholdsJson = useMemo(
|
|
419
|
+
() =>
|
|
420
|
+
containNativeListInput(() => {
|
|
421
|
+
if (
|
|
422
|
+
!scrollPositionThresholds ||
|
|
423
|
+
scrollPositionThresholds.enabled === false
|
|
424
|
+
)
|
|
425
|
+
return '';
|
|
426
|
+
const { start, end } = scrollPositionThresholds;
|
|
427
|
+
if (
|
|
428
|
+
!Number.isFinite(start) ||
|
|
429
|
+
!Number.isFinite(end) ||
|
|
430
|
+
start < 0 ||
|
|
431
|
+
end <= start
|
|
432
|
+
) {
|
|
433
|
+
throw new Error(
|
|
434
|
+
'scrollPositionThresholds requires 0 <= start < end and finite values'
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
return JSON.stringify({ start, end });
|
|
438
|
+
}) ?? '',
|
|
439
|
+
[scrollPositionThresholds]
|
|
440
|
+
);
|
|
441
|
+
const snapshotJson = useMemo(() => JSON.stringify(snapshot), [snapshot]);
|
|
203
442
|
const previousSnapshotJsonRef = useRef(snapshotJson);
|
|
204
443
|
const snapshotChanged = previousSnapshotJsonRef.current !== snapshotJson;
|
|
205
444
|
if (snapshotChanged) {
|
|
206
445
|
snapshotRef.current = snapshot;
|
|
207
446
|
previousSnapshotJsonRef.current = snapshotJson;
|
|
208
447
|
}
|
|
448
|
+
if (!initializedSnapshot.current) {
|
|
449
|
+
snapshotRef.current = snapshot;
|
|
450
|
+
initializedSnapshot.current = true;
|
|
451
|
+
}
|
|
209
452
|
// OneKey patch: range events already cross the bridge only when row indices
|
|
210
453
|
// change. Prefetch is optional work; scrolling and visible loads stay native.
|
|
211
454
|
const avatarQueueRef = useRef<NativeAvatarPrefetchQueue | null>(null);
|
|
@@ -260,26 +503,28 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
260
503
|
}>
|
|
261
504
|
| undefined
|
|
262
505
|
>(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
506
|
+
containNativeListInput(() =>
|
|
507
|
+
initialScrollIndex === undefined && initialScrollKey === undefined
|
|
508
|
+
? undefined
|
|
509
|
+
: initialScrollIndex !== undefined
|
|
510
|
+
? normalizeIndexScroll({
|
|
511
|
+
index: initialScrollIndex,
|
|
512
|
+
animated: false,
|
|
513
|
+
viewPosition: initialScrollViewPosition,
|
|
514
|
+
viewOffset: initialScrollViewOffset,
|
|
515
|
+
})
|
|
516
|
+
: {
|
|
517
|
+
key: initialScrollKey,
|
|
518
|
+
scroll: normalizePositionScroll(
|
|
519
|
+
{
|
|
520
|
+
animated: false,
|
|
521
|
+
viewPosition: initialScrollViewPosition,
|
|
522
|
+
viewOffset: initialScrollViewOffset,
|
|
523
|
+
},
|
|
524
|
+
'start'
|
|
525
|
+
),
|
|
526
|
+
}
|
|
527
|
+
)
|
|
283
528
|
);
|
|
284
529
|
const didApplyInitialScroll = useRef(false);
|
|
285
530
|
|
|
@@ -337,45 +582,96 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
337
582
|
|
|
338
583
|
useImperativeHandle(forwardedRef, () => ({
|
|
339
584
|
applySnapshot(nextSnapshot) {
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
if (
|
|
344
|
-
|
|
585
|
+
const accepted = containNativeListInput(() =>
|
|
586
|
+
prepareSnapshot(nextSnapshot)
|
|
587
|
+
);
|
|
588
|
+
if (!accepted) return;
|
|
589
|
+
const transitionId = accepted.structuralTransition?.id;
|
|
590
|
+
const waitsForSlots =
|
|
591
|
+
accepted.disclosure !== undefined &&
|
|
592
|
+
transitionId !== undefined &&
|
|
593
|
+
transitionId !== snapshotRef.current.structuralTransition?.id &&
|
|
594
|
+
((expandedPresent &&
|
|
595
|
+
slotMeasurements.readyEpochs[4] !== expandedEpoch) ||
|
|
596
|
+
(togglePresent && slotMeasurements.readyEpochs[5] !== toggleEpoch));
|
|
597
|
+
if (waitsForSlots) {
|
|
598
|
+
pendingDisclosureSnapshotRef.current = {
|
|
599
|
+
source: 'imperative',
|
|
600
|
+
input: nextSnapshot,
|
|
601
|
+
owned: accepted,
|
|
602
|
+
expandedEpoch,
|
|
603
|
+
toggleEpoch,
|
|
604
|
+
};
|
|
605
|
+
setPendingDisclosureRevision((value) => value + 1);
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
pendingDisclosureSnapshotRef.current = undefined;
|
|
609
|
+
const native = nativeRef.current;
|
|
610
|
+
if (native) native.applySnapshot(JSON.stringify(accepted));
|
|
611
|
+
snapshotRef.current = accepted;
|
|
612
|
+
needsNativeSnapshotRef.current = !native;
|
|
613
|
+
if (native && avatarLifecycle.current !== 'unmounted') {
|
|
614
|
+
avatarModelRef.current?.replaceSnapshot(accepted.rows);
|
|
345
615
|
updateAvatarPrefetchRef.current();
|
|
346
616
|
}
|
|
347
617
|
},
|
|
348
618
|
applyPatches(patches) {
|
|
349
|
-
|
|
350
|
-
const
|
|
619
|
+
const pending = pendingDisclosureSnapshotRef.current;
|
|
620
|
+
const accepted = containNativeListInput(() =>
|
|
621
|
+
applyOwnedNativePatches(
|
|
622
|
+
pending?.owned ?? snapshotRef.current,
|
|
623
|
+
patches
|
|
624
|
+
)
|
|
625
|
+
);
|
|
626
|
+
if (!accepted || accepted.patches.length === 0) return;
|
|
627
|
+
const nextSnapshot = accepted.snapshot;
|
|
628
|
+
if (pending) {
|
|
629
|
+
pendingDisclosureSnapshotRef.current = {
|
|
630
|
+
...pending,
|
|
631
|
+
owned: nextSnapshot,
|
|
632
|
+
};
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
351
635
|
const native = nativeRef.current;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
636
|
+
if (!native) {
|
|
637
|
+
snapshotRef.current = nextSnapshot;
|
|
638
|
+
needsNativeSnapshotRef.current = true;
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
const dispatch = () => {
|
|
642
|
+
native.applyPatches(accepted.json);
|
|
643
|
+
snapshotRef.current = nextSnapshot;
|
|
644
|
+
};
|
|
358
645
|
if (avatarLifecycle.current === 'unmounted') {
|
|
359
646
|
dispatch?.();
|
|
360
647
|
return;
|
|
361
648
|
}
|
|
362
|
-
if (avatarModelRef.current?.applyPatches(patches, dispatch))
|
|
649
|
+
if (avatarModelRef.current?.applyPatches(accepted.patches, dispatch))
|
|
363
650
|
updateAvatarPrefetchRef.current();
|
|
364
651
|
},
|
|
365
652
|
reconcileSelection(selectedKeys) {
|
|
366
|
-
|
|
367
|
-
const
|
|
653
|
+
const capturedKeys = captureNativeListInput(selectedKeys);
|
|
654
|
+
const pending = pendingDisclosureSnapshotRef.current;
|
|
655
|
+
if (!pending)
|
|
656
|
+
nativeRef.current?.reconcileSelection(JSON.stringify(capturedKeys));
|
|
657
|
+
const current = pending?.owned ?? snapshotRef.current;
|
|
368
658
|
if (
|
|
369
659
|
current.selection &&
|
|
370
|
-
(current.selection.mode !== 'single' ||
|
|
371
|
-
|
|
660
|
+
(current.selection.mode !== 'single' || capturedKeys.length <= 1) &&
|
|
661
|
+
capturedKeys.every((key) =>
|
|
372
662
|
current.rows.some((row) => row.key === key && isSelectableRow(row))
|
|
373
663
|
)
|
|
374
664
|
) {
|
|
375
|
-
|
|
665
|
+
const next = {
|
|
376
666
|
...current,
|
|
377
|
-
selection: { ...current.selection, selectedKeys },
|
|
667
|
+
selection: { ...current.selection, selectedKeys: capturedKeys },
|
|
378
668
|
};
|
|
669
|
+
if (pending)
|
|
670
|
+
pendingDisclosureSnapshotRef.current = { ...pending, owned: next };
|
|
671
|
+
else {
|
|
672
|
+
snapshotRef.current = next;
|
|
673
|
+
if (!nativeRef.current) needsNativeSnapshotRef.current = true;
|
|
674
|
+
}
|
|
379
675
|
}
|
|
380
676
|
},
|
|
381
677
|
scrollToKey(paramsOrKey, animated, alignment) {
|
|
@@ -441,7 +737,19 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
441
737
|
const nativeCallbacks = useMemo(
|
|
442
738
|
() => ({
|
|
443
739
|
hybridRef: callback((ref: NativeListMethods) => {
|
|
740
|
+
const previous = nativeRef.current;
|
|
444
741
|
nativeRef.current = ref;
|
|
742
|
+
if (
|
|
743
|
+
needsNativeSnapshotRef.current ||
|
|
744
|
+
(previous && previous !== ref)
|
|
745
|
+
) {
|
|
746
|
+
// The parent can publish values before Fabric delivers the host.
|
|
747
|
+
const latest = snapshotRef.current;
|
|
748
|
+
ref.applySnapshot(JSON.stringify(latest));
|
|
749
|
+
needsNativeSnapshotRef.current = false;
|
|
750
|
+
avatarModelRef.current?.replaceSnapshot(latest.rows);
|
|
751
|
+
updateAvatarPrefetchRef.current();
|
|
752
|
+
}
|
|
445
753
|
applyInitialScrollCallbackRef.current();
|
|
446
754
|
}),
|
|
447
755
|
onRowAction: callback((payloadJson: string) => {
|
|
@@ -508,6 +816,11 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
508
816
|
updateAvatarPrefetchRef.current();
|
|
509
817
|
callbacksRef.current.onVisibleRangeChanged?.(payload);
|
|
510
818
|
}),
|
|
819
|
+
onStructuralTransitionSettled: callback((payloadJson: string) => {
|
|
820
|
+
callbacksRef.current.onStructuralTransitionSettled?.(
|
|
821
|
+
parsePayload<StructuralTransitionSettledEvent>(payloadJson)
|
|
822
|
+
);
|
|
823
|
+
}),
|
|
511
824
|
}),
|
|
512
825
|
[]
|
|
513
826
|
);
|
|
@@ -515,10 +828,20 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
515
828
|
return (
|
|
516
829
|
<NativeListHost
|
|
517
830
|
{...viewProps}
|
|
831
|
+
onLayout={(event) => {
|
|
832
|
+
setViewportWidth(event.nativeEvent.layout.width);
|
|
833
|
+
viewProps.onLayout?.(event);
|
|
834
|
+
}}
|
|
518
835
|
{...nativeCallbacks}
|
|
836
|
+
onStructuralTransitionSettled={
|
|
837
|
+
onStructuralTransitionSettled
|
|
838
|
+
? nativeCallbacks.onStructuralTransitionSettled
|
|
839
|
+
: clearedStructuralTransitionSettled
|
|
840
|
+
}
|
|
519
841
|
fontFamiliesJson={fontFamiliesJson}
|
|
520
842
|
snapshotJson={snapshotJson}
|
|
521
843
|
containerSlotHeightsJson={containerSlotHeightsJson}
|
|
844
|
+
sidecarLayoutJson={sidecarLayoutJson}
|
|
522
845
|
topScrollEdgeEffect={
|
|
523
846
|
hasTopOverlay ? topScrollEdgeEffect ?? 'none' : 'none'
|
|
524
847
|
}
|
|
@@ -529,26 +852,51 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
529
852
|
>
|
|
530
853
|
{slotContents.map((content, index) => (
|
|
531
854
|
<View
|
|
532
|
-
key={
|
|
855
|
+
key={
|
|
856
|
+
index === 0 && Platform.OS === 'ios'
|
|
857
|
+
? `header-${headerEpoch}`
|
|
858
|
+
: index
|
|
859
|
+
}
|
|
533
860
|
collapsable={false}
|
|
534
861
|
style={{
|
|
535
862
|
position: 'absolute',
|
|
536
|
-
|
|
537
|
-
|
|
863
|
+
start: index === 3 ? 0 : slotInset,
|
|
864
|
+
end: index === 3 ? undefined : slotInset + sidecarSpace,
|
|
865
|
+
width: index === 3 ? sidecarLayout?.width : undefined,
|
|
538
866
|
top: 0,
|
|
539
867
|
}}
|
|
540
868
|
onLayout={(event) => {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
);
|
|
869
|
+
if (index < 4) {
|
|
870
|
+
recordSlotLayout(
|
|
871
|
+
index,
|
|
872
|
+
Math.ceil(event.nativeEvent.layout.height),
|
|
873
|
+
index === 0 ? headerEpoch : 0
|
|
874
|
+
);
|
|
875
|
+
}
|
|
549
876
|
}}
|
|
550
877
|
>
|
|
551
|
-
{
|
|
878
|
+
{index >= 4 ? (
|
|
879
|
+
<View
|
|
880
|
+
key={
|
|
881
|
+
index === 4
|
|
882
|
+
? `expanded-${expandedEpoch}`
|
|
883
|
+
: `toggle-${toggleEpoch}`
|
|
884
|
+
}
|
|
885
|
+
collapsable={false}
|
|
886
|
+
style={disclosureSlotMeasurementStyle}
|
|
887
|
+
onLayout={(event) =>
|
|
888
|
+
recordSlotLayout(
|
|
889
|
+
index,
|
|
890
|
+
Math.ceil(event.nativeEvent.layout.height),
|
|
891
|
+
index === 4 ? expandedEpoch : toggleEpoch
|
|
892
|
+
)
|
|
893
|
+
}
|
|
894
|
+
>
|
|
895
|
+
{content}
|
|
896
|
+
</View>
|
|
897
|
+
) : (
|
|
898
|
+
content
|
|
899
|
+
)}
|
|
552
900
|
</View>
|
|
553
901
|
))}
|
|
554
902
|
{hasTopOverlay ? (
|