@onekeyfe/react-native-native-list 6.7.0-alpha.344 → 6.7.0-alpha.354
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/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +7 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +240 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +7 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +6 -3
- 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 +87 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +135 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +43 -14
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +17 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +22 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +585 -21
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +1 -0
- package/docs/ROW_TEMPLATES.md +60 -9
- package/docs/SPEC.md +361 -8
- package/docs/STYLE_SPEC.md +6 -0
- package/ios/HybridNativeList.swift +10 -0
- package/ios/NativeListAccessoryStack.swift +220 -37
- package/ios/NativeListActivityDetailsView.swift +18 -8
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +105 -8
- package/ios/NativeListDesignAssets.swift +3 -0
- package/ios/NativeListIdentityRenderer.swift +119 -4
- package/ios/NativeListLeadingVisual.swift +49 -14
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListModels.swift +16 -2
- package/ios/NativeListRendererRegistry.swift +1 -0
- package/ios/NativeListResolvedText.swift +2 -1
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +88 -0
- package/ios/RNCNativeListView.swift +331 -29
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +56 -0
- package/ios/tests/NativeListLifecycleTests.swift +890 -3
- package/lib/module/NativeList.js +64 -27
- package/lib/module/NativeList.web.js +84 -17
- package/lib/module/models.js +1 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +532 -18
- package/lib/module/web/NativeListWebEngine.js +391 -24
- package/lib/module/web/templates/ActivityRowRenderer.js +8 -7
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +40 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +90 -4
- 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 +9 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +5 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +6 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +7 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +6 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +11 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +2 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +3 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +1 -0
- package/lib/typescript/src/NativeList.d.ts +2 -2
- package/lib/typescript/src/NativeList.nitro.d.ts +1 -0
- package/lib/typescript/src/NativeList.types.d.ts +8 -0
- package/lib/typescript/src/models.d.ts +101 -9
- package/lib/typescript/src/validation.d.ts +13 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +26 -0
- 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 +9 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +5 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +6 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +7 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +6 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +11 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +2 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +3 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +1 -0
- package/package.json +3 -3
- package/react-native-native-list.podspec +1 -0
- package/src/NativeList.nitro.ts +1 -0
- package/src/NativeList.tsx +155 -69
- package/src/NativeList.types.ts +9 -0
- package/src/NativeList.web.tsx +159 -49
- package/src/models.ts +113 -3
- package/src/selection.ts +1 -0
- package/src/validation.ts +1156 -18
- package/src/web/NativeListWebEngine.ts +594 -28
- package/src/web/templates/ActivityRowRenderer.ts +14 -6
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +150 -5
- 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
|
@@ -63,6 +63,8 @@ namespace margelo::nitro::nativelist {
|
|
|
63
63
|
virtual void setFontFamiliesJson(const std::string& fontFamiliesJson) = 0;
|
|
64
64
|
virtual std::string getContainerSlotHeightsJson() = 0;
|
|
65
65
|
virtual void setContainerSlotHeightsJson(const std::string& containerSlotHeightsJson) = 0;
|
|
66
|
+
virtual std::string getSidecarLayoutJson() = 0;
|
|
67
|
+
virtual void setSidecarLayoutJson(const std::string& sidecarLayoutJson) = 0;
|
|
66
68
|
virtual NativeListScrollEdgeEffect getTopScrollEdgeEffect() = 0;
|
|
67
69
|
virtual void setTopScrollEdgeEffect(NativeListScrollEdgeEffect topScrollEdgeEffect) = 0;
|
|
68
70
|
virtual double getTopOverlayHeight() = 0;
|
|
@@ -23,6 +23,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
23
23
|
snapshotJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "snapshotJson", rawProps, sourceProps.snapshotJson)),
|
|
24
24
|
fontFamiliesJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "fontFamiliesJson", rawProps, sourceProps.fontFamiliesJson)),
|
|
25
25
|
containerSlotHeightsJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "containerSlotHeightsJson", rawProps, sourceProps.containerSlotHeightsJson)),
|
|
26
|
+
sidecarLayoutJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "sidecarLayoutJson", rawProps, sourceProps.sidecarLayoutJson)),
|
|
26
27
|
topScrollEdgeEffect(nitro::ReactProp<NativeListScrollEdgeEffect>::fromRawValue("NativeList", "topScrollEdgeEffect", rawProps, sourceProps.topScrollEdgeEffect)),
|
|
27
28
|
topOverlayHeight(nitro::ReactProp<double>::fromRawValue("NativeList", "topOverlayHeight", rawProps, sourceProps.topOverlayHeight)),
|
|
28
29
|
scrollPositionThresholdsJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "scrollPositionThresholdsJson", rawProps, sourceProps.scrollPositionThresholdsJson)),
|
|
@@ -42,6 +43,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
42
43
|
case hashString("snapshotJson"): return true;
|
|
43
44
|
case hashString("fontFamiliesJson"): return true;
|
|
44
45
|
case hashString("containerSlotHeightsJson"): return true;
|
|
46
|
+
case hashString("sidecarLayoutJson"): return true;
|
|
45
47
|
case hashString("topScrollEdgeEffect"): return true;
|
|
46
48
|
case hashString("topOverlayHeight"): return true;
|
|
47
49
|
case hashString("scrollPositionThresholdsJson"): return true;
|
|
@@ -49,6 +49,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
49
49
|
nitro::ReactProp<std::string> snapshotJson;
|
|
50
50
|
nitro::ReactProp<std::string> fontFamiliesJson;
|
|
51
51
|
nitro::ReactProp<std::string> containerSlotHeightsJson;
|
|
52
|
+
nitro::ReactProp<std::string> sidecarLayoutJson;
|
|
52
53
|
nitro::ReactProp<NativeListScrollEdgeEffect> topScrollEdgeEffect;
|
|
53
54
|
nitro::ReactProp<double> topOverlayHeight;
|
|
54
55
|
nitro::ReactProp<std::string> scrollPositionThresholdsJson;
|
|
@@ -68,6 +69,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
68
69
|
return snapshotJson.hasSameValue(other.snapshotJson) &&
|
|
69
70
|
fontFamiliesJson.hasSameValue(other.fontFamiliesJson) &&
|
|
70
71
|
containerSlotHeightsJson.hasSameValue(other.containerSlotHeightsJson) &&
|
|
72
|
+
sidecarLayoutJson.hasSameValue(other.sidecarLayoutJson) &&
|
|
71
73
|
topScrollEdgeEffect.hasSameValue(other.topScrollEdgeEffect) &&
|
|
72
74
|
topOverlayHeight.hasSameValue(other.topOverlayHeight) &&
|
|
73
75
|
scrollPositionThresholdsJson.hasSameValue(other.scrollPositionThresholdsJson) &&
|
|
@@ -88,6 +90,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
88
90
|
return snapshotJson.isProvided() ||
|
|
89
91
|
fontFamiliesJson.isProvided() ||
|
|
90
92
|
containerSlotHeightsJson.isProvided() ||
|
|
93
|
+
sidecarLayoutJson.isProvided() ||
|
|
91
94
|
topScrollEdgeEffect.isProvided() ||
|
|
92
95
|
topOverlayHeight.isProvided() ||
|
|
93
96
|
scrollPositionThresholdsJson.isProvided() ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-native-list",
|
|
3
|
-
"version": "6.7.0-alpha.
|
|
3
|
+
"version": "6.7.0-alpha.354",
|
|
4
4
|
"description": "Template-driven native RecyclerView and UICollectionView for React Native",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"typescript": "^5.9.2"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
|
-
"@onekeyfe/react-native-image": "6.7.0-alpha.
|
|
90
|
-
"@onekeyfe/react-native-native-logger": "6.7.0-alpha.
|
|
89
|
+
"@onekeyfe/react-native-image": "6.7.0-alpha.354",
|
|
90
|
+
"@onekeyfe/react-native-native-logger": "6.7.0-alpha.354",
|
|
91
91
|
"react": "*",
|
|
92
92
|
"react-native": "*",
|
|
93
93
|
"react-native-nitro-modules": "0.37.0"
|
|
@@ -33,6 +33,7 @@ Pod::Spec.new do |s|
|
|
|
33
33
|
s.dependency "React-callinvoker"
|
|
34
34
|
|
|
35
35
|
s.test_spec "Tests" do |test_spec|
|
|
36
|
+
test_spec.requires_app_host = true
|
|
36
37
|
test_spec.source_files = "ios/tests/**/*.swift"
|
|
37
38
|
test_spec.pod_target_xcconfig = {
|
|
38
39
|
"PRODUCT_MODULE_NAME" => "NativeListModuleTests",
|
package/src/NativeList.nitro.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface NativeListNativeProps extends HybridViewProps {
|
|
|
13
13
|
snapshotJson: string;
|
|
14
14
|
fontFamiliesJson: string;
|
|
15
15
|
containerSlotHeightsJson: string;
|
|
16
|
+
sidecarLayoutJson: string;
|
|
16
17
|
topScrollEdgeEffect: NativeListScrollEdgeEffect;
|
|
17
18
|
topOverlayHeight: number;
|
|
18
19
|
scrollPositionThresholdsJson: string;
|
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,6 +25,7 @@ import type {
|
|
|
24
25
|
import type {
|
|
25
26
|
ActionAnchorInvalidatedEvent,
|
|
26
27
|
ImageSource,
|
|
28
|
+
NativeListSnapshot,
|
|
27
29
|
RowActionEvent,
|
|
28
30
|
SelectionDeltaEvent,
|
|
29
31
|
ReorderEvent,
|
|
@@ -42,9 +44,12 @@ import {
|
|
|
42
44
|
type NormalizedPositionScroll,
|
|
43
45
|
} from './scrolling';
|
|
44
46
|
import {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
applyOwnedNativePatches,
|
|
48
|
+
captureNativeListInput,
|
|
49
|
+
containNativeListInput,
|
|
50
|
+
emptyNativeListSnapshot,
|
|
51
|
+
ownValidatedNativeSnapshot,
|
|
52
|
+
validateSnapshot,
|
|
48
53
|
} from './validation';
|
|
49
54
|
|
|
50
55
|
export type { NativeListProps, NativeListRef } from './NativeList.types';
|
|
@@ -98,10 +103,12 @@ function parsePayload<T>(payloadJson: string): T {
|
|
|
98
103
|
export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
99
104
|
function NativeList(
|
|
100
105
|
{
|
|
101
|
-
snapshot,
|
|
106
|
+
snapshot: inputSnapshot,
|
|
102
107
|
listHeader,
|
|
103
108
|
listFooter,
|
|
104
109
|
listEmpty,
|
|
110
|
+
listSidecar,
|
|
111
|
+
sidecarLayout,
|
|
105
112
|
topOverlay,
|
|
106
113
|
topScrollEdgeEffect,
|
|
107
114
|
scrollPositionThresholds,
|
|
@@ -128,8 +135,60 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
128
135
|
},
|
|
129
136
|
forwardedRef
|
|
130
137
|
) {
|
|
138
|
+
const snapshotRef = useRef<NativeListSnapshot>(emptyNativeListSnapshot());
|
|
139
|
+
const initializedSnapshot = useRef(false);
|
|
140
|
+
const hasSidecar = listSidecar !== undefined;
|
|
141
|
+
const sidecarWidth = sidecarLayout?.width;
|
|
142
|
+
const sidecarGap = sidecarLayout?.gap;
|
|
143
|
+
const sidecarMaxContentWidth = sidecarLayout?.maxContentWidth;
|
|
144
|
+
const hasContainerSlots = Boolean(
|
|
145
|
+
listHeader || listEmpty || listFooter || listSidecar
|
|
146
|
+
);
|
|
147
|
+
const prepareSnapshot = useCallback(
|
|
148
|
+
(next: NativeListSnapshot) => {
|
|
149
|
+
const accepted = validateSnapshot(captureNativeListInput(next));
|
|
150
|
+
if (hasContainerSlots && accepted.layout.orientation === 'horizontal')
|
|
151
|
+
throw new Error(
|
|
152
|
+
'NativeList container slots require vertical orientation'
|
|
153
|
+
);
|
|
154
|
+
if (hasSidecar !== (sidecarWidth !== undefined))
|
|
155
|
+
throw new Error(
|
|
156
|
+
'listSidecar and sidecarLayout must be supplied together'
|
|
157
|
+
);
|
|
158
|
+
if (sidecarWidth !== undefined) {
|
|
159
|
+
const width = sidecarWidth;
|
|
160
|
+
const gap = sidecarGap ?? NaN;
|
|
161
|
+
const maxContentWidth = sidecarMaxContentWidth ?? NaN;
|
|
162
|
+
if (
|
|
163
|
+
accepted.layout.kind !== 'linear' ||
|
|
164
|
+
!Number.isFinite(width) ||
|
|
165
|
+
width <= 0 ||
|
|
166
|
+
!Number.isFinite(gap) ||
|
|
167
|
+
gap < 0 ||
|
|
168
|
+
!Number.isFinite(maxContentWidth) ||
|
|
169
|
+
maxContentWidth <= width + gap
|
|
170
|
+
)
|
|
171
|
+
throw new Error('Invalid NativeList sidecar layout');
|
|
172
|
+
}
|
|
173
|
+
return ownValidatedNativeSnapshot(accepted);
|
|
174
|
+
},
|
|
175
|
+
[
|
|
176
|
+
hasContainerSlots,
|
|
177
|
+
hasSidecar,
|
|
178
|
+
sidecarWidth,
|
|
179
|
+
sidecarGap,
|
|
180
|
+
sidecarMaxContentWidth,
|
|
181
|
+
]
|
|
182
|
+
);
|
|
183
|
+
const snapshot = useMemo(
|
|
184
|
+
() =>
|
|
185
|
+
containNativeListInput(() => prepareSnapshot(inputSnapshot)) ??
|
|
186
|
+
snapshotRef.current,
|
|
187
|
+
[inputSnapshot, prepareSnapshot]
|
|
188
|
+
);
|
|
131
189
|
const fontFamiliesJson = useNativeListFontFamiliesJson();
|
|
132
|
-
const [slotHeights, setSlotHeights] = useState([0, 0, 0]);
|
|
190
|
+
const [slotHeights, setSlotHeights] = useState([0, 0, 0, 0]);
|
|
191
|
+
const [viewportWidth, setViewportWidth] = useState(0);
|
|
133
192
|
const [topOverlayHeight, setTopOverlayHeight] = useState(0);
|
|
134
193
|
const hasTopOverlay =
|
|
135
194
|
Platform?.OS === 'ios' &&
|
|
@@ -137,19 +196,23 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
137
196
|
(topScrollEdgeEffect === 'hard' || topScrollEdgeEffect === 'soft') &&
|
|
138
197
|
topOverlay != null;
|
|
139
198
|
const containerSlotHeightsJson = JSON.stringify(slotHeights);
|
|
140
|
-
const
|
|
199
|
+
const defaultSlotInset =
|
|
141
200
|
snapshot.layout.contentPaddingHorizontal ??
|
|
142
201
|
snapshot.layout.contentPadding ??
|
|
143
202
|
0;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
203
|
+
const bandWidth = sidecarLayout
|
|
204
|
+
? Math.min(viewportWidth, sidecarLayout.maxContentWidth)
|
|
205
|
+
: 0;
|
|
206
|
+
const slotInset = sidecarLayout
|
|
207
|
+
? Math.max(0, (viewportWidth - bandWidth) / 2)
|
|
208
|
+
: defaultSlotInset;
|
|
209
|
+
const sidecarSpace = sidecarLayout
|
|
210
|
+
? sidecarLayout.width + sidecarLayout.gap
|
|
211
|
+
: 0;
|
|
212
|
+
const slotContents = [listHeader, listEmpty, listFooter, listSidecar];
|
|
213
|
+
const sidecarLayoutJson = sidecarLayout
|
|
214
|
+
? JSON.stringify(sidecarLayout)
|
|
215
|
+
: '';
|
|
153
216
|
const normalizedKeyboardShouldPersistTaps =
|
|
154
217
|
keyboardShouldPersistTaps === true
|
|
155
218
|
? 'always'
|
|
@@ -179,33 +242,40 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
179
242
|
onRefresh,
|
|
180
243
|
onScrollToIndexFailed,
|
|
181
244
|
};
|
|
182
|
-
const scrollPositionThresholdsJson = useMemo(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
245
|
+
const scrollPositionThresholdsJson = useMemo(
|
|
246
|
+
() =>
|
|
247
|
+
containNativeListInput(() => {
|
|
248
|
+
if (
|
|
249
|
+
!scrollPositionThresholds ||
|
|
250
|
+
scrollPositionThresholds.enabled === false
|
|
251
|
+
)
|
|
252
|
+
return '';
|
|
253
|
+
const { start, end } = scrollPositionThresholds;
|
|
254
|
+
if (
|
|
255
|
+
!Number.isFinite(start) ||
|
|
256
|
+
!Number.isFinite(end) ||
|
|
257
|
+
start < 0 ||
|
|
258
|
+
end <= start
|
|
259
|
+
) {
|
|
260
|
+
throw new Error(
|
|
261
|
+
'scrollPositionThresholds requires 0 <= start < end and finite values'
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
return JSON.stringify({ start, end });
|
|
265
|
+
}) ?? '',
|
|
266
|
+
[scrollPositionThresholds]
|
|
267
|
+
);
|
|
268
|
+
const snapshotJson = useMemo(() => JSON.stringify(snapshot), [snapshot]);
|
|
203
269
|
const previousSnapshotJsonRef = useRef(snapshotJson);
|
|
204
270
|
const snapshotChanged = previousSnapshotJsonRef.current !== snapshotJson;
|
|
205
271
|
if (snapshotChanged) {
|
|
206
272
|
snapshotRef.current = snapshot;
|
|
207
273
|
previousSnapshotJsonRef.current = snapshotJson;
|
|
208
274
|
}
|
|
275
|
+
if (!initializedSnapshot.current) {
|
|
276
|
+
snapshotRef.current = snapshot;
|
|
277
|
+
initializedSnapshot.current = true;
|
|
278
|
+
}
|
|
209
279
|
// OneKey patch: range events already cross the bridge only when row indices
|
|
210
280
|
// change. Prefetch is optional work; scrolling and visible loads stay native.
|
|
211
281
|
const avatarQueueRef = useRef<NativeAvatarPrefetchQueue | null>(null);
|
|
@@ -260,26 +330,28 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
260
330
|
}>
|
|
261
331
|
| undefined
|
|
262
332
|
>(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
333
|
+
containNativeListInput(() =>
|
|
334
|
+
initialScrollIndex === undefined && initialScrollKey === undefined
|
|
335
|
+
? undefined
|
|
336
|
+
: initialScrollIndex !== undefined
|
|
337
|
+
? normalizeIndexScroll({
|
|
338
|
+
index: initialScrollIndex,
|
|
339
|
+
animated: false,
|
|
340
|
+
viewPosition: initialScrollViewPosition,
|
|
341
|
+
viewOffset: initialScrollViewOffset,
|
|
342
|
+
})
|
|
343
|
+
: {
|
|
344
|
+
key: initialScrollKey,
|
|
345
|
+
scroll: normalizePositionScroll(
|
|
346
|
+
{
|
|
347
|
+
animated: false,
|
|
348
|
+
viewPosition: initialScrollViewPosition,
|
|
349
|
+
viewOffset: initialScrollViewOffset,
|
|
350
|
+
},
|
|
351
|
+
'start'
|
|
352
|
+
),
|
|
353
|
+
}
|
|
354
|
+
)
|
|
283
355
|
);
|
|
284
356
|
const didApplyInitialScroll = useRef(false);
|
|
285
357
|
|
|
@@ -337,21 +409,28 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
337
409
|
|
|
338
410
|
useImperativeHandle(forwardedRef, () => ({
|
|
339
411
|
applySnapshot(nextSnapshot) {
|
|
340
|
-
const
|
|
412
|
+
const accepted = containNativeListInput(() =>
|
|
413
|
+
prepareSnapshot(nextSnapshot)
|
|
414
|
+
);
|
|
415
|
+
if (!accepted) return;
|
|
416
|
+
const nextSnapshotJson = JSON.stringify(accepted);
|
|
341
417
|
nativeRef.current?.applySnapshot(nextSnapshotJson);
|
|
342
|
-
snapshotRef.current =
|
|
418
|
+
snapshotRef.current = accepted;
|
|
343
419
|
if (nativeRef.current && avatarLifecycle.current !== 'unmounted') {
|
|
344
|
-
avatarModelRef.current?.replaceSnapshot(
|
|
420
|
+
avatarModelRef.current?.replaceSnapshot(accepted.rows);
|
|
345
421
|
updateAvatarPrefetchRef.current();
|
|
346
422
|
}
|
|
347
423
|
},
|
|
348
424
|
applyPatches(patches) {
|
|
349
|
-
|
|
350
|
-
|
|
425
|
+
const accepted = containNativeListInput(() =>
|
|
426
|
+
applyOwnedNativePatches(snapshotRef.current, patches)
|
|
427
|
+
);
|
|
428
|
+
if (!accepted || accepted.patches.length === 0) return;
|
|
429
|
+
const nextSnapshot = accepted.snapshot;
|
|
351
430
|
const native = nativeRef.current;
|
|
352
431
|
const dispatch = native
|
|
353
432
|
? () => {
|
|
354
|
-
native.applyPatches(
|
|
433
|
+
native.applyPatches(accepted.json);
|
|
355
434
|
snapshotRef.current = nextSnapshot;
|
|
356
435
|
}
|
|
357
436
|
: undefined;
|
|
@@ -359,22 +438,23 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
359
438
|
dispatch?.();
|
|
360
439
|
return;
|
|
361
440
|
}
|
|
362
|
-
if (avatarModelRef.current?.applyPatches(patches, dispatch))
|
|
441
|
+
if (avatarModelRef.current?.applyPatches(accepted.patches, dispatch))
|
|
363
442
|
updateAvatarPrefetchRef.current();
|
|
364
443
|
},
|
|
365
444
|
reconcileSelection(selectedKeys) {
|
|
366
|
-
|
|
445
|
+
const capturedKeys = captureNativeListInput(selectedKeys);
|
|
446
|
+
nativeRef.current?.reconcileSelection(JSON.stringify(capturedKeys));
|
|
367
447
|
const current = snapshotRef.current;
|
|
368
448
|
if (
|
|
369
449
|
current.selection &&
|
|
370
|
-
(current.selection.mode !== 'single' ||
|
|
371
|
-
|
|
450
|
+
(current.selection.mode !== 'single' || capturedKeys.length <= 1) &&
|
|
451
|
+
capturedKeys.every((key) =>
|
|
372
452
|
current.rows.some((row) => row.key === key && isSelectableRow(row))
|
|
373
453
|
)
|
|
374
454
|
) {
|
|
375
455
|
snapshotRef.current = {
|
|
376
456
|
...current,
|
|
377
|
-
selection: { ...current.selection, selectedKeys },
|
|
457
|
+
selection: { ...current.selection, selectedKeys: capturedKeys },
|
|
378
458
|
};
|
|
379
459
|
}
|
|
380
460
|
},
|
|
@@ -515,10 +595,15 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
515
595
|
return (
|
|
516
596
|
<NativeListHost
|
|
517
597
|
{...viewProps}
|
|
598
|
+
onLayout={(event) => {
|
|
599
|
+
setViewportWidth(event.nativeEvent.layout.width);
|
|
600
|
+
viewProps.onLayout?.(event);
|
|
601
|
+
}}
|
|
518
602
|
{...nativeCallbacks}
|
|
519
603
|
fontFamiliesJson={fontFamiliesJson}
|
|
520
604
|
snapshotJson={snapshotJson}
|
|
521
605
|
containerSlotHeightsJson={containerSlotHeightsJson}
|
|
606
|
+
sidecarLayoutJson={sidecarLayoutJson}
|
|
522
607
|
topScrollEdgeEffect={
|
|
523
608
|
hasTopOverlay ? topScrollEdgeEffect ?? 'none' : 'none'
|
|
524
609
|
}
|
|
@@ -533,8 +618,9 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
533
618
|
collapsable={false}
|
|
534
619
|
style={{
|
|
535
620
|
position: 'absolute',
|
|
536
|
-
|
|
537
|
-
|
|
621
|
+
start: index === 3 ? 0 : slotInset,
|
|
622
|
+
end: index === 3 ? undefined : slotInset + sidecarSpace,
|
|
623
|
+
width: index === 3 ? sidecarLayout?.width : undefined,
|
|
538
624
|
top: 0,
|
|
539
625
|
}}
|
|
540
626
|
onLayout={(event) => {
|
package/src/NativeList.types.ts
CHANGED
|
@@ -78,6 +78,12 @@ 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
|
+
|
|
81
87
|
type InitialScrollProps =
|
|
82
88
|
| Readonly<{
|
|
83
89
|
initialScrollIndex?: never;
|
|
@@ -131,6 +137,9 @@ export type NativeListProps = Omit<ViewProps, 'children'> &
|
|
|
131
137
|
listHeader?: ReactNode;
|
|
132
138
|
listFooter?: ReactNode;
|
|
133
139
|
listEmpty?: ReactNode;
|
|
140
|
+
/** Scrolling right column for a vertical linear list. Requires sidecarLayout. */
|
|
141
|
+
listSidecar?: ReactNode;
|
|
142
|
+
sidecarLayout?: NativeListSidecarLayout;
|
|
134
143
|
/** Fixed overlay above scrolling rows on iOS 26 and newer. */
|
|
135
144
|
topOverlay?: ReactNode;
|
|
136
145
|
/** Selects UIKit's top scroll-edge effect on iOS 26 and newer. */
|