@onekeyfe/react-native-native-list 6.7.0-6 → 6.7.0-61
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 +41 -7
- 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.types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ScrollEdgeEffect } from './ScrollEdgeEffect';
|
|
2
|
-
import type { ReactNode, RefObject } from 'react';
|
|
2
|
+
import type { ElementRef, ReactNode, RefObject } from 'react';
|
|
3
3
|
import type { View, ViewProps } from 'react-native';
|
|
4
4
|
import type {
|
|
5
5
|
ActionAnchorInvalidatedEvent,
|
|
@@ -78,6 +78,18 @@ export type NativeListWebScrollHost = Readonly<{
|
|
|
78
78
|
scrollTop: number;
|
|
79
79
|
}>;
|
|
80
80
|
|
|
81
|
+
export type NativeListSidecarLayout = Readonly<{
|
|
82
|
+
width: number;
|
|
83
|
+
gap: number;
|
|
84
|
+
maxContentWidth: number;
|
|
85
|
+
}>;
|
|
86
|
+
|
|
87
|
+
export type StructuralTransitionSettledEvent = Readonly<{
|
|
88
|
+
transitionId: string;
|
|
89
|
+
status: 'completed' | 'interrupted';
|
|
90
|
+
settledExpanded: boolean;
|
|
91
|
+
}>;
|
|
92
|
+
|
|
81
93
|
type InitialScrollProps =
|
|
82
94
|
| Readonly<{
|
|
83
95
|
initialScrollIndex?: never;
|
|
@@ -131,6 +143,13 @@ export type NativeListProps = Omit<ViewProps, 'children'> &
|
|
|
131
143
|
listHeader?: ReactNode;
|
|
132
144
|
listFooter?: ReactNode;
|
|
133
145
|
listEmpty?: ReactNode;
|
|
146
|
+
/** Native disclosure content, retained until its transition settles. */
|
|
147
|
+
listExpandedContent?: ReactNode;
|
|
148
|
+
/** Stable native disclosure toggle after expanded content. */
|
|
149
|
+
listStructureToggle?: ReactNode;
|
|
150
|
+
/** Scrolling right column for a vertical linear list. Requires sidecarLayout. */
|
|
151
|
+
listSidecar?: ReactNode;
|
|
152
|
+
sidecarLayout?: NativeListSidecarLayout;
|
|
134
153
|
/** Fixed overlay above scrolling rows on iOS 26 and newer. */
|
|
135
154
|
topOverlay?: ReactNode;
|
|
136
155
|
/** Selects UIKit's top scroll-edge effect on iOS 26 and newer. */
|
|
@@ -142,7 +161,7 @@ export type NativeListProps = Omit<ViewProps, 'children'> &
|
|
|
142
161
|
/** Web only: visible sticky chrome above the parent's list viewport. */
|
|
143
162
|
webStickyInset?: number;
|
|
144
163
|
/** Web only. Hosts the section index inside this container. */
|
|
145
|
-
webSectionIndexContainerRef?: RefObject<View | null>;
|
|
164
|
+
webSectionIndexContainerRef?: RefObject<ElementRef<typeof View> | null>;
|
|
146
165
|
/** Defaults to `none`. `interactive` behaves as `none` on Android. */
|
|
147
166
|
keyboardDismissMode?: NativeListKeyboardDismissMode;
|
|
148
167
|
/**
|
|
@@ -156,6 +175,9 @@ export type NativeListProps = Omit<ViewProps, 'children'> &
|
|
|
156
175
|
onReorder?: (event: ReorderEvent) => void;
|
|
157
176
|
onEndReached?: (event: EndReachedEvent) => void;
|
|
158
177
|
onVisibleRangeChanged?: (event: VisibleRangeChangedEvent) => void;
|
|
178
|
+
onStructuralTransitionSettled?: (
|
|
179
|
+
event: StructuralTransitionSettledEvent
|
|
180
|
+
) => void;
|
|
159
181
|
/** Native only. Emits initial state and hysteresis transitions, not scroll frames. */
|
|
160
182
|
scrollPositionThresholds?: Readonly<{
|
|
161
183
|
start: number;
|
package/src/NativeList.web.tsx
CHANGED
|
@@ -21,7 +21,12 @@ import {
|
|
|
21
21
|
validateOffset,
|
|
22
22
|
type NormalizedPositionScroll,
|
|
23
23
|
} from './scrolling';
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
applyRowPatches,
|
|
26
|
+
containNativeListInput,
|
|
27
|
+
emptyNativeListSnapshot,
|
|
28
|
+
validateSnapshot,
|
|
29
|
+
} from './validation';
|
|
25
30
|
import {
|
|
26
31
|
NativeListWebEngine,
|
|
27
32
|
type NativeListWebCallbacks,
|
|
@@ -31,6 +36,8 @@ import {
|
|
|
31
36
|
canonicalNativeListAvatarUri,
|
|
32
37
|
} from './web/NativeListWebAvatarCache';
|
|
33
38
|
|
|
39
|
+
const collapsedExpandedContentStyle = { display: 'none' } as const;
|
|
40
|
+
|
|
34
41
|
export type { NativeListProps, NativeListRef } from './NativeList.types';
|
|
35
42
|
export type {
|
|
36
43
|
ActionAnchorState,
|
|
@@ -83,14 +90,18 @@ export function preloadNativeListAvatarImages(
|
|
|
83
90
|
export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
84
91
|
function NativeList(
|
|
85
92
|
{
|
|
86
|
-
snapshot,
|
|
93
|
+
snapshot: inputSnapshot,
|
|
87
94
|
listHeader,
|
|
88
95
|
listEmpty,
|
|
89
96
|
listFooter,
|
|
97
|
+
listExpandedContent,
|
|
98
|
+
listStructureToggle,
|
|
99
|
+
listSidecar,
|
|
100
|
+
sidecarLayout,
|
|
90
101
|
topOverlay: _topOverlay,
|
|
91
102
|
topScrollEdgeEffect: _topScrollEdgeEffect,
|
|
92
103
|
webScrollHost,
|
|
93
|
-
webStickyInset = 0,
|
|
104
|
+
webStickyInset: inputStickyInset = 0,
|
|
94
105
|
scrollPositionThresholds: _scrollPositionThresholds,
|
|
95
106
|
onScrollPositionThresholdChange: _onScrollPositionThresholdChange,
|
|
96
107
|
webVirtualizationEnabled = true,
|
|
@@ -103,6 +114,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
103
114
|
onReorder,
|
|
104
115
|
onEndReached,
|
|
105
116
|
onVisibleRangeChanged,
|
|
117
|
+
onStructuralTransitionSettled: _onStructuralTransitionSettled,
|
|
106
118
|
onRefresh,
|
|
107
119
|
onScrollToIndexFailed,
|
|
108
120
|
initialScrollIndex,
|
|
@@ -113,55 +125,58 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
113
125
|
},
|
|
114
126
|
forwardedRef
|
|
115
127
|
) {
|
|
128
|
+
const acceptedSnapshotRef = useRef<NativeListSnapshot>(
|
|
129
|
+
emptyNativeListSnapshot()
|
|
130
|
+
);
|
|
131
|
+
const initializedSnapshot = useRef(false);
|
|
132
|
+
const webStickyInset = useMemo(
|
|
133
|
+
() =>
|
|
134
|
+
containNativeListInput(() => {
|
|
135
|
+
if (!Number.isFinite(inputStickyInset) || inputStickyInset < 0)
|
|
136
|
+
throw new Error('webStickyInset must be finite and non-negative');
|
|
137
|
+
return inputStickyInset;
|
|
138
|
+
}) ?? 0,
|
|
139
|
+
[inputStickyInset]
|
|
140
|
+
);
|
|
141
|
+
// Freshness is limited to this component invocation; later renders revalidate.
|
|
142
|
+
let freshlyValidatedSnapshot: NativeListSnapshot | undefined;
|
|
143
|
+
const preparedSnapshot = useMemo(() => {
|
|
144
|
+
const prepared = containNativeListInput(() =>
|
|
145
|
+
validateSnapshot(inputSnapshot)
|
|
146
|
+
);
|
|
147
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- The value is intentionally render-local.
|
|
148
|
+
freshlyValidatedSnapshot = prepared;
|
|
149
|
+
return prepared;
|
|
150
|
+
}, [inputSnapshot]);
|
|
151
|
+
const snapshot = preparedSnapshot ?? acceptedSnapshotRef.current;
|
|
116
152
|
const fontFamiliesJson = useNativeListFontFamiliesJson();
|
|
117
153
|
const fontFamiliesJsonRef = useRef(fontFamiliesJson);
|
|
118
154
|
fontFamiliesJsonRef.current = fontFamiliesJson;
|
|
119
155
|
const hasEmptySlot = listEmpty !== undefined;
|
|
120
156
|
const hasEmptySlotRef = useRef(hasEmptySlot);
|
|
121
157
|
hasEmptySlotRef.current = hasEmptySlot;
|
|
122
|
-
const [
|
|
123
|
-
|
|
124
|
-
emptyBottomPadding:
|
|
125
|
-
!snapshot.rows.length && hasEmptySlot
|
|
126
|
-
? snapshot.layout.contentPaddingBottom ??
|
|
127
|
-
snapshot.layout.contentPadding ??
|
|
128
|
-
0
|
|
129
|
-
: 0,
|
|
130
|
-
padding:
|
|
131
|
-
snapshot.layout.contentPaddingHorizontal ??
|
|
132
|
-
snapshot.layout.contentPadding ??
|
|
133
|
-
0,
|
|
134
|
-
}));
|
|
135
|
-
const synchronizeSlots = (next: NativeListSnapshot) => {
|
|
136
|
-
const hasRows = next.rows.length > 0;
|
|
137
|
-
const padding =
|
|
138
|
-
next.layout.contentPaddingHorizontal ?? next.layout.contentPadding ?? 0;
|
|
139
|
-
const emptyBottomPadding =
|
|
140
|
-
!hasRows && hasEmptySlotRef.current
|
|
141
|
-
? next.layout.contentPaddingBottom ?? next.layout.contentPadding ?? 0
|
|
142
|
-
: 0;
|
|
143
|
-
setSlotState((previous) =>
|
|
144
|
-
previous.hasRows === hasRows &&
|
|
145
|
-
previous.padding === padding &&
|
|
146
|
-
previous.emptyBottomPadding === emptyBottomPadding
|
|
147
|
-
? previous
|
|
148
|
-
: { hasRows, padding, emptyBottomPadding }
|
|
149
|
-
);
|
|
150
|
-
};
|
|
158
|
+
const [viewportWidth, setViewportWidth] = useState(0);
|
|
159
|
+
const [sidecarHeight, setSidecarHeight] = useState(0);
|
|
151
160
|
const normalizeWebSnapshot = (
|
|
152
161
|
next: NativeListSnapshot,
|
|
153
162
|
hasReactEmpty = hasEmptySlotRef.current,
|
|
154
|
-
hasSlotLayout = useSlotLayoutRef.current
|
|
163
|
+
hasSlotLayout = useSlotLayoutRef.current,
|
|
164
|
+
validatedInThisRender = false
|
|
155
165
|
) => {
|
|
156
166
|
if (hasSlotLayout && next.layout.orientation === 'horizontal')
|
|
157
167
|
throw new Error(
|
|
158
168
|
'Web parent scrolling and container slots support vertical lists only'
|
|
159
169
|
);
|
|
160
170
|
const emptySlot = hasReactEmpty && next.rows.length === 0;
|
|
161
|
-
const
|
|
162
|
-
emptySlot
|
|
163
|
-
|
|
164
|
-
|
|
171
|
+
const normalized =
|
|
172
|
+
emptySlot && next.emptyState !== undefined
|
|
173
|
+
? { ...next, emptyState: undefined }
|
|
174
|
+
: next;
|
|
175
|
+
const validated = validatedInThisRender
|
|
176
|
+
? normalized
|
|
177
|
+
: validateSnapshot(normalized);
|
|
178
|
+
// Preserve an already normalized fallback's identity across rerenders.
|
|
179
|
+
return emptySlot && validated.layout.contentPaddingBottom !== 0
|
|
165
180
|
? {
|
|
166
181
|
...validated,
|
|
167
182
|
layout: { ...validated.layout, contentPaddingBottom: 0 },
|
|
@@ -181,6 +196,9 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
181
196
|
listHeader !== undefined ||
|
|
182
197
|
listEmpty !== undefined ||
|
|
183
198
|
listFooter !== undefined;
|
|
199
|
+
useSlotLayoutRef.current ||= listSidecar !== undefined;
|
|
200
|
+
useSlotLayoutRef.current ||=
|
|
201
|
+
listExpandedContent !== undefined || listStructureToggle !== undefined;
|
|
184
202
|
const useSlotLayout = useSlotLayoutRef.current;
|
|
185
203
|
const resolvedScrollHost =
|
|
186
204
|
webScrollHost === undefined
|
|
@@ -188,22 +206,103 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
188
206
|
? ownedScrollHost
|
|
189
207
|
: undefined
|
|
190
208
|
: webScrollHost;
|
|
191
|
-
if (!Number.isFinite(webStickyInset) || webStickyInset < 0)
|
|
192
|
-
throw new Error('webStickyInset must be finite and non-negative');
|
|
193
209
|
const engineRef = useRef<NativeListWebEngine | undefined>(undefined);
|
|
194
210
|
const webVirtualizationEnabledRef = useRef(webVirtualizationEnabled);
|
|
195
211
|
webVirtualizationEnabledRef.current = webVirtualizationEnabled;
|
|
196
212
|
const validatedSnapshot = useMemo(
|
|
197
|
-
() =>
|
|
198
|
-
|
|
213
|
+
() =>
|
|
214
|
+
containNativeListInput(() => {
|
|
215
|
+
if ((listSidecar !== undefined) !== (sidecarLayout !== undefined))
|
|
216
|
+
throw new Error(
|
|
217
|
+
'listSidecar and sidecarLayout must be supplied together'
|
|
218
|
+
);
|
|
219
|
+
if (sidecarLayout) {
|
|
220
|
+
const { width, gap, maxContentWidth } = sidecarLayout;
|
|
221
|
+
if (
|
|
222
|
+
snapshot.layout.kind !== 'linear' ||
|
|
223
|
+
!Number.isFinite(width) ||
|
|
224
|
+
width <= 0 ||
|
|
225
|
+
!Number.isFinite(gap) ||
|
|
226
|
+
gap < 0 ||
|
|
227
|
+
!Number.isFinite(maxContentWidth) ||
|
|
228
|
+
maxContentWidth <= width + gap
|
|
229
|
+
)
|
|
230
|
+
throw new Error('Invalid NativeList sidecar layout');
|
|
231
|
+
}
|
|
232
|
+
return normalizeWebSnapshot(
|
|
233
|
+
snapshot,
|
|
234
|
+
hasEmptySlot,
|
|
235
|
+
useSlotLayout,
|
|
236
|
+
preparedSnapshot !== undefined &&
|
|
237
|
+
preparedSnapshot === freshlyValidatedSnapshot
|
|
238
|
+
);
|
|
239
|
+
}) ?? acceptedSnapshotRef.current,
|
|
240
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- Preserve the existing memo dependencies; freshness is render-local.
|
|
241
|
+
[snapshot, hasEmptySlot, useSlotLayout, listSidecar, sidecarLayout]
|
|
199
242
|
);
|
|
243
|
+
const [slotState, setSlotState] = useState(() => ({
|
|
244
|
+
hasRows: validatedSnapshot.rows.length > 0,
|
|
245
|
+
emptyBottomPadding:
|
|
246
|
+
!validatedSnapshot.rows.length && hasEmptySlot
|
|
247
|
+
? validatedSnapshot.layout.contentPaddingBottom ??
|
|
248
|
+
validatedSnapshot.layout.contentPadding ??
|
|
249
|
+
0
|
|
250
|
+
: 0,
|
|
251
|
+
padding:
|
|
252
|
+
validatedSnapshot.layout.contentPaddingHorizontal ??
|
|
253
|
+
validatedSnapshot.layout.contentPadding ??
|
|
254
|
+
0,
|
|
255
|
+
disclosurePresent: validatedSnapshot.disclosure !== undefined,
|
|
256
|
+
disclosureExpanded: validatedSnapshot.disclosure?.expanded === true,
|
|
257
|
+
hasExpandedContent: validatedSnapshot.disclosure?.expanded === true,
|
|
258
|
+
expandedTrailingInset:
|
|
259
|
+
validatedSnapshot.disclosure?.expandedTrailingInset ?? 0,
|
|
260
|
+
}));
|
|
261
|
+
const synchronizeSlots = (next: NativeListSnapshot) => {
|
|
262
|
+
const hasRows = next.rows.length > 0;
|
|
263
|
+
const padding =
|
|
264
|
+
next.layout.contentPaddingHorizontal ?? next.layout.contentPadding ?? 0;
|
|
265
|
+
const emptyBottomPadding =
|
|
266
|
+
!hasRows && hasEmptySlotRef.current
|
|
267
|
+
? next.layout.contentPaddingBottom ?? next.layout.contentPadding ?? 0
|
|
268
|
+
: 0;
|
|
269
|
+
const disclosurePresent = next.disclosure !== undefined;
|
|
270
|
+
const disclosureExpanded = next.disclosure?.expanded === true;
|
|
271
|
+
const expandedTrailingInset = next.disclosure?.expandedTrailingInset ?? 0;
|
|
272
|
+
setSlotState((previous) => {
|
|
273
|
+
const hasExpandedContent =
|
|
274
|
+
previous.hasExpandedContent || disclosureExpanded;
|
|
275
|
+
return previous.hasRows === hasRows &&
|
|
276
|
+
previous.padding === padding &&
|
|
277
|
+
previous.emptyBottomPadding === emptyBottomPadding &&
|
|
278
|
+
previous.disclosurePresent === disclosurePresent &&
|
|
279
|
+
previous.disclosureExpanded === disclosureExpanded &&
|
|
280
|
+
previous.hasExpandedContent === hasExpandedContent &&
|
|
281
|
+
previous.expandedTrailingInset === expandedTrailingInset
|
|
282
|
+
? previous
|
|
283
|
+
: {
|
|
284
|
+
hasRows,
|
|
285
|
+
padding,
|
|
286
|
+
emptyBottomPadding,
|
|
287
|
+
disclosurePresent,
|
|
288
|
+
disclosureExpanded,
|
|
289
|
+
hasExpandedContent,
|
|
290
|
+
expandedTrailingInset,
|
|
291
|
+
};
|
|
292
|
+
});
|
|
293
|
+
};
|
|
200
294
|
const snapshotRef = useRef(validatedSnapshot);
|
|
201
295
|
const snapshotPropRef = useRef(validatedSnapshot);
|
|
202
296
|
// An imperative snapshot survives host mounting until the snapshot prop changes.
|
|
203
297
|
if (snapshotPropRef.current !== validatedSnapshot) {
|
|
204
298
|
snapshotPropRef.current = validatedSnapshot;
|
|
205
299
|
snapshotRef.current = validatedSnapshot;
|
|
206
|
-
|
|
300
|
+
acceptedSnapshotRef.current = validatedSnapshot;
|
|
301
|
+
synchronizeSlots(validatedSnapshot);
|
|
302
|
+
}
|
|
303
|
+
if (!initializedSnapshot.current) {
|
|
304
|
+
acceptedSnapshotRef.current = validatedSnapshot;
|
|
305
|
+
initializedSnapshot.current = true;
|
|
207
306
|
}
|
|
208
307
|
const appliedSnapshotRef = useRef<NativeListSnapshot | undefined>(
|
|
209
308
|
undefined
|
|
@@ -227,26 +326,28 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
227
326
|
}>
|
|
228
327
|
| undefined
|
|
229
328
|
>(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
329
|
+
containNativeListInput(() =>
|
|
330
|
+
initialScrollIndex === undefined && initialScrollKey === undefined
|
|
331
|
+
? undefined
|
|
332
|
+
: initialScrollIndex !== undefined
|
|
333
|
+
? normalizeIndexScroll({
|
|
334
|
+
index: initialScrollIndex,
|
|
335
|
+
animated: false,
|
|
336
|
+
viewPosition: initialScrollViewPosition,
|
|
337
|
+
viewOffset: initialScrollViewOffset,
|
|
338
|
+
})
|
|
339
|
+
: {
|
|
340
|
+
key: initialScrollKey,
|
|
341
|
+
scroll: normalizePositionScroll(
|
|
342
|
+
{
|
|
343
|
+
animated: false,
|
|
344
|
+
viewPosition: initialScrollViewPosition,
|
|
345
|
+
viewOffset: initialScrollViewOffset,
|
|
346
|
+
},
|
|
347
|
+
'start'
|
|
348
|
+
),
|
|
349
|
+
}
|
|
350
|
+
)
|
|
250
351
|
);
|
|
251
352
|
const didApplyInitialScroll = useRef(false);
|
|
252
353
|
const scrollOptionsRef = useRef({
|
|
@@ -265,19 +366,23 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
265
366
|
(useSlotLayout && !contentBounds)
|
|
266
367
|
)
|
|
267
368
|
return;
|
|
268
|
-
const engine =
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
369
|
+
const engine = containNativeListInput(
|
|
370
|
+
() =>
|
|
371
|
+
new NativeListWebEngine(
|
|
372
|
+
host,
|
|
373
|
+
snapshotRef.current,
|
|
374
|
+
callbacksRef.current,
|
|
375
|
+
webVirtualizationEnabledRef.current,
|
|
376
|
+
webSectionIndexContainerRef?.current as unknown as HTMLElement | null,
|
|
377
|
+
fontFamiliesJsonRef.current,
|
|
378
|
+
{
|
|
379
|
+
scrollHost: resolvedScrollHost as HTMLElement | undefined,
|
|
380
|
+
contentBounds: contentBounds ?? undefined,
|
|
381
|
+
...scrollOptionsRef.current,
|
|
382
|
+
}
|
|
383
|
+
)
|
|
280
384
|
);
|
|
385
|
+
if (!engine) return;
|
|
281
386
|
host.style.height = '';
|
|
282
387
|
engineRef.current = engine;
|
|
283
388
|
appliedSnapshotRef.current = snapshotRef.current;
|
|
@@ -337,21 +442,28 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
337
442
|
|
|
338
443
|
useImperativeHandle(forwardedRef, () => ({
|
|
339
444
|
applySnapshot(nextSnapshot) {
|
|
340
|
-
const next =
|
|
445
|
+
const next = containNativeListInput(() =>
|
|
446
|
+
normalizeWebSnapshot(nextSnapshot)
|
|
447
|
+
);
|
|
448
|
+
if (!next) return;
|
|
341
449
|
engineRef.current?.applySnapshot(next);
|
|
342
450
|
snapshotRef.current = next;
|
|
451
|
+
acceptedSnapshotRef.current = next;
|
|
343
452
|
appliedSnapshotRef.current = next;
|
|
344
|
-
synchronizeSlots(
|
|
453
|
+
synchronizeSlots(next);
|
|
345
454
|
},
|
|
346
455
|
applyPatches(patches) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
456
|
+
const engine = engineRef.current;
|
|
457
|
+
if (engine) {
|
|
458
|
+
engine.applyPatches(patches);
|
|
459
|
+
snapshotRef.current = engine.currentSnapshot();
|
|
460
|
+
} else {
|
|
461
|
+
const next = containNativeListInput(() =>
|
|
462
|
+
applyRowPatches(snapshotRef.current, patches)
|
|
463
|
+
);
|
|
464
|
+
if (next) snapshotRef.current = next;
|
|
354
465
|
}
|
|
466
|
+
acceptedSnapshotRef.current = snapshotRef.current;
|
|
355
467
|
},
|
|
356
468
|
reconcileSelection(selectedKeys) {
|
|
357
469
|
engineRef.current?.reconcileSelection(selectedKeys);
|
|
@@ -452,9 +564,19 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
452
564
|
);
|
|
453
565
|
if (!useSlotLayout) return <View {...viewProps} ref={setHostRef} />;
|
|
454
566
|
const padding = slotState.padding;
|
|
567
|
+
const footerBandStyle = { paddingHorizontal: padding };
|
|
568
|
+
const trailingInsetStyle = {
|
|
569
|
+
height: slotState.disclosureExpanded
|
|
570
|
+
? slotState.expandedTrailingInset
|
|
571
|
+
: 0,
|
|
572
|
+
};
|
|
573
|
+
const hasFooterBand =
|
|
574
|
+
listFooter !== undefined ||
|
|
575
|
+
listExpandedContent !== undefined ||
|
|
576
|
+
listStructureToggle !== undefined;
|
|
455
577
|
const content = (
|
|
456
578
|
<View
|
|
457
|
-
ref={setBoundsRef}
|
|
579
|
+
ref={sidecarLayout ? undefined : setBoundsRef}
|
|
458
580
|
style={{ position: 'relative', flexShrink: 0, minWidth: 0 }}
|
|
459
581
|
>
|
|
460
582
|
{listHeader !== undefined ? (
|
|
@@ -471,14 +593,90 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
471
593
|
{listEmpty}
|
|
472
594
|
</View>
|
|
473
595
|
) : null}
|
|
474
|
-
{
|
|
475
|
-
<View style={
|
|
596
|
+
{hasFooterBand ? (
|
|
597
|
+
<View testID="native-list-footer-slot" style={footerBandStyle}>
|
|
598
|
+
{listExpandedContent !== undefined &&
|
|
599
|
+
slotState.hasExpandedContent ? (
|
|
600
|
+
<View
|
|
601
|
+
testID="native-list-expanded-content-slot"
|
|
602
|
+
aria-hidden={!slotState.disclosureExpanded}
|
|
603
|
+
pointerEvents={slotState.disclosureExpanded ? 'auto' : 'none'}
|
|
604
|
+
style={
|
|
605
|
+
slotState.disclosureExpanded
|
|
606
|
+
? undefined
|
|
607
|
+
: collapsedExpandedContentStyle
|
|
608
|
+
}
|
|
609
|
+
>
|
|
610
|
+
{listExpandedContent}
|
|
611
|
+
</View>
|
|
612
|
+
) : null}
|
|
613
|
+
{listStructureToggle !== undefined ? (
|
|
614
|
+
<View
|
|
615
|
+
testID="native-list-structure-toggle-slot"
|
|
616
|
+
aria-hidden={!slotState.disclosurePresent}
|
|
617
|
+
pointerEvents={slotState.disclosurePresent ? 'auto' : 'none'}
|
|
618
|
+
style={
|
|
619
|
+
slotState.disclosurePresent
|
|
620
|
+
? { marginHorizontal: -padding }
|
|
621
|
+
: collapsedExpandedContentStyle
|
|
622
|
+
}
|
|
623
|
+
>
|
|
624
|
+
{listStructureToggle}
|
|
625
|
+
</View>
|
|
626
|
+
) : null}
|
|
627
|
+
{slotState.expandedTrailingInset > 0 &&
|
|
628
|
+
(listExpandedContent !== undefined ||
|
|
629
|
+
listStructureToggle !== undefined) ? (
|
|
630
|
+
<View
|
|
631
|
+
testID="native-list-trailing-inset-slot"
|
|
632
|
+
style={trailingInsetStyle}
|
|
633
|
+
/>
|
|
634
|
+
) : null}
|
|
635
|
+
{listFooter}
|
|
636
|
+
</View>
|
|
476
637
|
) : null}
|
|
477
638
|
</View>
|
|
478
639
|
);
|
|
640
|
+
const bandWidth = sidecarLayout
|
|
641
|
+
? Math.min(viewportWidth, sidecarLayout.maxContentWidth)
|
|
642
|
+
: 0;
|
|
643
|
+
const sidecarMargin = Math.max(0, (viewportWidth - bandWidth) / 2);
|
|
644
|
+
const leftWidth = Math.max(
|
|
645
|
+
0,
|
|
646
|
+
bandWidth - (sidecarLayout?.width ?? 0) - (sidecarLayout?.gap ?? 0)
|
|
647
|
+
);
|
|
648
|
+
const scrollContent = sidecarLayout ? (
|
|
649
|
+
<View
|
|
650
|
+
ref={setBoundsRef}
|
|
651
|
+
style={{ position: 'relative', minHeight: sidecarHeight }}
|
|
652
|
+
>
|
|
653
|
+
<View style={{ marginStart: sidecarMargin, width: leftWidth }}>
|
|
654
|
+
{content}
|
|
655
|
+
</View>
|
|
656
|
+
<View
|
|
657
|
+
style={{
|
|
658
|
+
position: 'absolute',
|
|
659
|
+
end: sidecarMargin,
|
|
660
|
+
top: 0,
|
|
661
|
+
width: sidecarLayout.width,
|
|
662
|
+
}}
|
|
663
|
+
onLayout={(event) =>
|
|
664
|
+
setSidecarHeight(event.nativeEvent.layout.height)
|
|
665
|
+
}
|
|
666
|
+
>
|
|
667
|
+
{listSidecar}
|
|
668
|
+
</View>
|
|
669
|
+
</View>
|
|
670
|
+
) : (
|
|
671
|
+
content
|
|
672
|
+
);
|
|
479
673
|
return (
|
|
480
674
|
<View
|
|
481
675
|
{...viewProps}
|
|
676
|
+
onLayout={(event) => {
|
|
677
|
+
setViewportWidth(event.nativeEvent.layout.width);
|
|
678
|
+
viewProps.onLayout?.(event);
|
|
679
|
+
}}
|
|
482
680
|
style={[viewProps.style, { position: 'relative', minHeight: 0 }]}
|
|
483
681
|
>
|
|
484
682
|
{webScrollHost === undefined ? (
|
|
@@ -486,10 +684,10 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
486
684
|
ref={setScrollHostRef}
|
|
487
685
|
style={{ position: 'absolute', inset: 0, overflow: 'scroll' }}
|
|
488
686
|
>
|
|
489
|
-
{
|
|
687
|
+
{scrollContent}
|
|
490
688
|
</View>
|
|
491
689
|
) : (
|
|
492
|
-
|
|
690
|
+
scrollContent
|
|
493
691
|
)}
|
|
494
692
|
</View>
|
|
495
693
|
);
|
package/src/index.ts
CHANGED
|
@@ -14,10 +14,12 @@ export type {
|
|
|
14
14
|
ScrollToKeyParams,
|
|
15
15
|
ScrollToLocationParams,
|
|
16
16
|
ScrollToOffsetParams,
|
|
17
|
+
StructuralTransitionSettledEvent,
|
|
17
18
|
} from './NativeList';
|
|
18
19
|
export type * from './models';
|
|
19
20
|
export {
|
|
20
21
|
applyRowPatches,
|
|
22
|
+
planNativeListPatches,
|
|
21
23
|
serializePatches,
|
|
22
24
|
serializeSnapshot,
|
|
23
25
|
validatePatches,
|