@onekeyfe/react-native-native-list 6.7.0-2 → 6.7.0-3
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/docs/SPEC.md +365 -9
- package/lib/module/NativeList.js +2 -0
- package/lib/module/NativeList.web.js +135 -29
- package/lib/module/validation.js +143 -34
- package/lib/module/web/NativeListWebEngine.js +353 -62
- package/lib/module/web/templates/ActivityRowRenderer.js +432 -5
- package/lib/module/web/templates/MarketRowRenderer.js +8 -3
- package/lib/module/web/templates/MarketTableRowRenderer.js +576 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
- package/lib/module/web/templates/RowRendererRegistry.js +5 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +34 -1
- package/lib/typescript/src/NativeList.types.d.ts +11 -1
- package/lib/typescript/src/NativeList.web.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +71 -1
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +26 -1
- package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
- package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
- package/package.json +3 -3
- package/src/NativeList.tsx +2 -0
- package/src/NativeList.types.ts +12 -1
- package/src/NativeList.web.tsx +183 -38
- package/src/models.ts +93 -0
- package/src/validation.ts +348 -58
- package/src/web/NativeListWebEngine.ts +600 -95
- package/src/web/templates/ActivityRowRenderer.ts +656 -7
- package/src/web/templates/MarketRowRenderer.ts +19 -3
- package/src/web/templates/MarketTableRowRenderer.ts +752 -0
- package/src/web/templates/MediaTileRowRenderer.ts +313 -5
- package/src/web/templates/RowRendererRegistry.ts +10 -5
- package/src/web/templates/SectionHeaderRowRenderer.ts +42 -1
|
@@ -28,7 +28,7 @@ export declare function resolveMessageRow(row: MessageRow): {
|
|
|
28
28
|
}> | undefined;
|
|
29
29
|
automaticHeight: boolean;
|
|
30
30
|
};
|
|
31
|
-
export declare function classifyMessageUpdate(old: MessageRow | undefined, row: MessageRow): "replace" | "
|
|
31
|
+
export declare function classifyMessageUpdate(old: MessageRow | undefined, row: MessageRow): "replace" | "content" | "unchanged" | "assets";
|
|
32
32
|
export declare function bindMessageRow(body: HTMLElement, row: MessageRow, primitives: RowPrimitives): void;
|
|
33
33
|
export declare function createMessageRow(document: Document, row: MessageRow, primitives: RowPrimitives): HTMLElement;
|
|
34
34
|
export declare function recycleMessageRow(body: HTMLElement): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RowModel } from '../../models';
|
|
2
|
-
export type RowRendererKey = RowModel['type'];
|
|
2
|
+
export type RowRendererKey = RowModel['type'] | 'marketTable';
|
|
3
3
|
export declare function rowRenderer(row: RowModel): {
|
|
4
4
|
key: string;
|
|
5
5
|
appliesSizePreset: boolean;
|
|
@@ -21,6 +21,7 @@ export declare function rowRenderer(row: RowModel): {
|
|
|
21
21
|
overscan?: number;
|
|
22
22
|
loadingStrategy?: import("../..").ImageLoadingStrategy;
|
|
23
23
|
fallbackUri?: string;
|
|
24
|
+
fallbackUris?: readonly string[];
|
|
24
25
|
retryTimes?: number;
|
|
25
26
|
}>) => HTMLElement | undefined;
|
|
26
27
|
textStyle: (element: HTMLElement, style: Readonly<{
|
|
@@ -55,6 +56,7 @@ export declare function rowRenderer(row: RowModel): {
|
|
|
55
56
|
overscan?: number;
|
|
56
57
|
loadingStrategy?: import("../..").ImageLoadingStrategy;
|
|
57
58
|
fallbackUri?: string;
|
|
59
|
+
fallbackUris?: readonly string[];
|
|
58
60
|
retryTimes?: number;
|
|
59
61
|
}>) => HTMLElement | undefined;
|
|
60
62
|
textStyle: (element: HTMLElement, style: Readonly<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-native-list",
|
|
3
|
-
"version": "6.7.0-
|
|
3
|
+
"version": "6.7.0-3",
|
|
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-
|
|
90
|
-
"@onekeyfe/react-native-native-logger": "6.7.0-
|
|
89
|
+
"@onekeyfe/react-native-image": "6.7.0-3",
|
|
90
|
+
"@onekeyfe/react-native-native-logger": "6.7.0-3",
|
|
91
91
|
"react": "*",
|
|
92
92
|
"react-native": "*",
|
|
93
93
|
"react-native-nitro-modules": "0.37.0"
|
package/src/NativeList.tsx
CHANGED
|
@@ -106,6 +106,8 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
106
106
|
topScrollEdgeEffect,
|
|
107
107
|
scrollPositionThresholds,
|
|
108
108
|
webVirtualizationEnabled: _webVirtualizationEnabled,
|
|
109
|
+
webScrollHost: _webScrollHost,
|
|
110
|
+
webStickyInset: _webStickyInset,
|
|
109
111
|
webSectionIndexContainerRef: _webSectionIndexContainerRef,
|
|
110
112
|
keyboardDismissMode = 'none',
|
|
111
113
|
keyboardShouldPersistTaps = 'never',
|
package/src/NativeList.types.ts
CHANGED
|
@@ -71,6 +71,13 @@ export type ScrollToIndexFailedInfo = Readonly<{
|
|
|
71
71
|
| 'item-not-found';
|
|
72
72
|
}>;
|
|
73
73
|
|
|
74
|
+
/** Minimal DOM-free structural surface for an explicit Web scroll element. */
|
|
75
|
+
export type NativeListWebScrollHost = Readonly<{
|
|
76
|
+
clientWidth: number;
|
|
77
|
+
clientHeight: number;
|
|
78
|
+
scrollTop: number;
|
|
79
|
+
}>;
|
|
80
|
+
|
|
74
81
|
type InitialScrollProps =
|
|
75
82
|
| Readonly<{
|
|
76
83
|
initialScrollIndex?: never;
|
|
@@ -120,7 +127,7 @@ export type NativeListRef = Readonly<{
|
|
|
120
127
|
export type NativeListProps = Omit<ViewProps, 'children'> &
|
|
121
128
|
Readonly<{
|
|
122
129
|
snapshot: NativeListSnapshot;
|
|
123
|
-
/**
|
|
130
|
+
/** Container-owned scroll content. Never rendered as a data row. */
|
|
124
131
|
listHeader?: ReactNode;
|
|
125
132
|
listFooter?: ReactNode;
|
|
126
133
|
listEmpty?: ReactNode;
|
|
@@ -130,6 +137,10 @@ export type NativeListProps = Omit<ViewProps, 'children'> &
|
|
|
130
137
|
topScrollEdgeEffect?: `${ScrollEdgeEffect}`;
|
|
131
138
|
/** Web only. Defaults to true and is ignored by the native host. */
|
|
132
139
|
webVirtualizationEnabled?: boolean;
|
|
140
|
+
/** Web only: undefined owns scrolling, null waits for a host element. */
|
|
141
|
+
webScrollHost?: NativeListWebScrollHost | null;
|
|
142
|
+
/** Web only: visible sticky chrome above the parent's list viewport. */
|
|
143
|
+
webStickyInset?: number;
|
|
133
144
|
/** Web only. Hosts the section index inside this container. */
|
|
134
145
|
webSectionIndexContainerRef?: RefObject<View | null>;
|
|
135
146
|
/** Defaults to `none`. `interactive` behaves as `none` on Android. */
|
package/src/NativeList.web.tsx
CHANGED
|
@@ -4,13 +4,14 @@ import React, {
|
|
|
4
4
|
useCallback,
|
|
5
5
|
useEffect,
|
|
6
6
|
useImperativeHandle,
|
|
7
|
+
useLayoutEffect,
|
|
7
8
|
useMemo,
|
|
8
9
|
useRef,
|
|
9
10
|
useState,
|
|
10
11
|
} from 'react';
|
|
11
12
|
import { View } from 'react-native';
|
|
12
13
|
import type { NativeListProps, NativeListRef } from './NativeList.types';
|
|
13
|
-
import type { ImageSource, NativeListSnapshot
|
|
14
|
+
import type { ImageSource, NativeListSnapshot } from './models';
|
|
14
15
|
import {
|
|
15
16
|
normalizeIndexScroll,
|
|
16
17
|
normalizeKeyScroll,
|
|
@@ -20,7 +21,7 @@ import {
|
|
|
20
21
|
validateOffset,
|
|
21
22
|
type NormalizedPositionScroll,
|
|
22
23
|
} from './scrolling';
|
|
23
|
-
import {
|
|
24
|
+
import { applyRowPatches, validateSnapshot } from './validation';
|
|
24
25
|
import {
|
|
25
26
|
NativeListWebEngine,
|
|
26
27
|
type NativeListWebCallbacks,
|
|
@@ -83,11 +84,13 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
83
84
|
function NativeList(
|
|
84
85
|
{
|
|
85
86
|
snapshot,
|
|
86
|
-
listHeader
|
|
87
|
-
listEmpty
|
|
88
|
-
listFooter
|
|
87
|
+
listHeader,
|
|
88
|
+
listEmpty,
|
|
89
|
+
listFooter,
|
|
89
90
|
topOverlay: _topOverlay,
|
|
90
91
|
topScrollEdgeEffect: _topScrollEdgeEffect,
|
|
92
|
+
webScrollHost,
|
|
93
|
+
webStickyInset = 0,
|
|
91
94
|
scrollPositionThresholds: _scrollPositionThresholds,
|
|
92
95
|
onScrollPositionThresholdChange: _onScrollPositionThresholdChange,
|
|
93
96
|
webVirtualizationEnabled = true,
|
|
@@ -113,13 +116,86 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
113
116
|
const fontFamiliesJson = useNativeListFontFamiliesJson();
|
|
114
117
|
const fontFamiliesJsonRef = useRef(fontFamiliesJson);
|
|
115
118
|
fontFamiliesJsonRef.current = fontFamiliesJson;
|
|
119
|
+
const hasEmptySlot = listEmpty !== undefined;
|
|
120
|
+
const hasEmptySlotRef = useRef(hasEmptySlot);
|
|
121
|
+
hasEmptySlotRef.current = hasEmptySlot;
|
|
122
|
+
const [slotState, setSlotState] = useState(() => ({
|
|
123
|
+
hasRows: snapshot.rows.length > 0,
|
|
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
|
+
};
|
|
151
|
+
const normalizeWebSnapshot = (
|
|
152
|
+
next: NativeListSnapshot,
|
|
153
|
+
hasReactEmpty = hasEmptySlotRef.current,
|
|
154
|
+
hasSlotLayout = useSlotLayoutRef.current
|
|
155
|
+
) => {
|
|
156
|
+
if (hasSlotLayout && next.layout.orientation === 'horizontal')
|
|
157
|
+
throw new Error(
|
|
158
|
+
'Web parent scrolling and container slots support vertical lists only'
|
|
159
|
+
);
|
|
160
|
+
const emptySlot = hasReactEmpty && next.rows.length === 0;
|
|
161
|
+
const validated = validateSnapshot(
|
|
162
|
+
emptySlot ? { ...next, emptyState: undefined } : next
|
|
163
|
+
);
|
|
164
|
+
return emptySlot
|
|
165
|
+
? {
|
|
166
|
+
...validated,
|
|
167
|
+
layout: { ...validated.layout, contentPaddingBottom: 0 },
|
|
168
|
+
}
|
|
169
|
+
: validated;
|
|
170
|
+
};
|
|
116
171
|
const [host, setHost] = useState<HTMLElement | null>(null);
|
|
172
|
+
const [contentBounds, setContentBounds] = useState<HTMLElement | null>(
|
|
173
|
+
null
|
|
174
|
+
);
|
|
175
|
+
const [ownedScrollHost, setOwnedScrollHost] = useState<HTMLElement | null>(
|
|
176
|
+
null
|
|
177
|
+
);
|
|
178
|
+
const useSlotLayoutRef = useRef(false);
|
|
179
|
+
useSlotLayoutRef.current ||=
|
|
180
|
+
webScrollHost !== undefined ||
|
|
181
|
+
listHeader !== undefined ||
|
|
182
|
+
listEmpty !== undefined ||
|
|
183
|
+
listFooter !== undefined;
|
|
184
|
+
const useSlotLayout = useSlotLayoutRef.current;
|
|
185
|
+
const resolvedScrollHost =
|
|
186
|
+
webScrollHost === undefined
|
|
187
|
+
? useSlotLayout
|
|
188
|
+
? ownedScrollHost
|
|
189
|
+
: undefined
|
|
190
|
+
: webScrollHost;
|
|
191
|
+
if (!Number.isFinite(webStickyInset) || webStickyInset < 0)
|
|
192
|
+
throw new Error('webStickyInset must be finite and non-negative');
|
|
117
193
|
const engineRef = useRef<NativeListWebEngine | undefined>(undefined);
|
|
118
194
|
const webVirtualizationEnabledRef = useRef(webVirtualizationEnabled);
|
|
119
195
|
webVirtualizationEnabledRef.current = webVirtualizationEnabled;
|
|
120
196
|
const validatedSnapshot = useMemo(
|
|
121
|
-
() =>
|
|
122
|
-
[snapshot]
|
|
197
|
+
() => normalizeWebSnapshot(snapshot, hasEmptySlot, useSlotLayout),
|
|
198
|
+
[snapshot, hasEmptySlot, useSlotLayout]
|
|
123
199
|
);
|
|
124
200
|
const snapshotRef = useRef(validatedSnapshot);
|
|
125
201
|
const snapshotPropRef = useRef(validatedSnapshot);
|
|
@@ -127,15 +203,8 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
127
203
|
if (snapshotPropRef.current !== validatedSnapshot) {
|
|
128
204
|
snapshotPropRef.current = validatedSnapshot;
|
|
129
205
|
snapshotRef.current = validatedSnapshot;
|
|
206
|
+
synchronizeSlots(snapshot);
|
|
130
207
|
}
|
|
131
|
-
// OneKey patch: React refs can be ready before the DOM engine is mounted.
|
|
132
|
-
const pendingPatchesRef = useRef<
|
|
133
|
-
| {
|
|
134
|
-
snapshot: NativeListSnapshot;
|
|
135
|
-
batches: Array<readonly RowPatch[]>;
|
|
136
|
-
}
|
|
137
|
-
| undefined
|
|
138
|
-
>(undefined);
|
|
139
208
|
const appliedSnapshotRef = useRef<NativeListSnapshot | undefined>(
|
|
140
209
|
undefined
|
|
141
210
|
);
|
|
@@ -180,23 +249,38 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
180
249
|
}
|
|
181
250
|
);
|
|
182
251
|
const didApplyInitialScroll = useRef(false);
|
|
252
|
+
const scrollOptionsRef = useRef({
|
|
253
|
+
stickyInset: webStickyInset,
|
|
254
|
+
ownsRefresh: webScrollHost === undefined,
|
|
255
|
+
});
|
|
256
|
+
scrollOptionsRef.current = {
|
|
257
|
+
stickyInset: webStickyInset,
|
|
258
|
+
ownsRefresh: webScrollHost === undefined,
|
|
259
|
+
};
|
|
183
260
|
|
|
184
261
|
useEffect(() => {
|
|
185
|
-
if (
|
|
262
|
+
if (
|
|
263
|
+
!host ||
|
|
264
|
+
resolvedScrollHost === null ||
|
|
265
|
+
(useSlotLayout && !contentBounds)
|
|
266
|
+
)
|
|
267
|
+
return;
|
|
186
268
|
const engine = new NativeListWebEngine(
|
|
187
269
|
host,
|
|
188
270
|
snapshotRef.current,
|
|
189
271
|
callbacksRef.current,
|
|
190
272
|
webVirtualizationEnabledRef.current,
|
|
191
273
|
webSectionIndexContainerRef?.current as unknown as HTMLElement | null,
|
|
192
|
-
fontFamiliesJsonRef.current
|
|
274
|
+
fontFamiliesJsonRef.current,
|
|
275
|
+
{
|
|
276
|
+
scrollHost: resolvedScrollHost as HTMLElement | undefined,
|
|
277
|
+
contentBounds: contentBounds ?? undefined,
|
|
278
|
+
...scrollOptionsRef.current,
|
|
279
|
+
}
|
|
193
280
|
);
|
|
281
|
+
host.style.height = '';
|
|
194
282
|
engineRef.current = engine;
|
|
195
283
|
appliedSnapshotRef.current = snapshotRef.current;
|
|
196
|
-
const pending = pendingPatchesRef.current;
|
|
197
|
-
pendingPatchesRef.current = undefined;
|
|
198
|
-
if (pending?.snapshot === snapshotRef.current)
|
|
199
|
-
pending.batches.forEach((patches) => engine.applyPatches(patches));
|
|
200
284
|
const initial = initialScrollRef.current;
|
|
201
285
|
if (initial && !didApplyInitialScroll.current) {
|
|
202
286
|
didApplyInitialScroll.current = true;
|
|
@@ -206,10 +290,22 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
206
290
|
engine.scrollToKey(initial.key, initial.scroll);
|
|
207
291
|
}
|
|
208
292
|
return () => {
|
|
293
|
+
// Keep the paused tab in normal flow until its engine is restored.
|
|
294
|
+
host.style.height = `${engine.currentContentHeight()}px`;
|
|
209
295
|
engine.destroy();
|
|
210
296
|
if (engineRef.current === engine) engineRef.current = undefined;
|
|
211
297
|
};
|
|
212
|
-
}, [
|
|
298
|
+
}, [
|
|
299
|
+
host,
|
|
300
|
+
webSectionIndexContainerRef,
|
|
301
|
+
resolvedScrollHost,
|
|
302
|
+
contentBounds,
|
|
303
|
+
useSlotLayout,
|
|
304
|
+
]);
|
|
305
|
+
|
|
306
|
+
useEffect(() => {
|
|
307
|
+
engineRef.current?.setStickyInset(webStickyInset);
|
|
308
|
+
}, [webStickyInset]);
|
|
213
309
|
|
|
214
310
|
useEffect(() => {
|
|
215
311
|
engineRef.current?.setFontFamiliesJson(fontFamiliesJson);
|
|
@@ -223,7 +319,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
223
319
|
engineRef.current?.updateCallbacks(callbacksRef.current);
|
|
224
320
|
});
|
|
225
321
|
|
|
226
|
-
|
|
322
|
+
useLayoutEffect(() => {
|
|
227
323
|
const engine = engineRef.current;
|
|
228
324
|
if (!engine || appliedSnapshotRef.current === validatedSnapshot) return;
|
|
229
325
|
engine.applySnapshot(validatedSnapshot);
|
|
@@ -241,25 +337,20 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
241
337
|
|
|
242
338
|
useImperativeHandle(forwardedRef, () => ({
|
|
243
339
|
applySnapshot(nextSnapshot) {
|
|
244
|
-
const next =
|
|
245
|
-
|
|
340
|
+
const next = normalizeWebSnapshot(nextSnapshot);
|
|
341
|
+
engineRef.current?.applySnapshot(next);
|
|
246
342
|
snapshotRef.current = next;
|
|
247
343
|
appliedSnapshotRef.current = next;
|
|
248
|
-
|
|
344
|
+
synchronizeSlots(nextSnapshot);
|
|
249
345
|
},
|
|
250
346
|
applyPatches(patches) {
|
|
251
347
|
if (patches.length > 0) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
snapshot: snapshotRef.current,
|
|
259
|
-
batches: [],
|
|
260
|
-
};
|
|
261
|
-
pendingPatchesRef.current.batches.push(patches);
|
|
262
|
-
}
|
|
348
|
+
const engine = engineRef.current;
|
|
349
|
+
if (engine) {
|
|
350
|
+
engine.applyPatches(patches);
|
|
351
|
+
snapshotRef.current = engine.currentSnapshot();
|
|
352
|
+
} else
|
|
353
|
+
snapshotRef.current = applyRowPatches(snapshotRef.current, patches);
|
|
263
354
|
}
|
|
264
355
|
},
|
|
265
356
|
reconcileSelection(selectedKeys) {
|
|
@@ -339,6 +430,60 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
339
430
|
[]
|
|
340
431
|
);
|
|
341
432
|
|
|
342
|
-
|
|
433
|
+
const setBoundsRef = useCallback(
|
|
434
|
+
(value: React.ComponentRef<typeof View> | null) => {
|
|
435
|
+
setContentBounds(value as unknown as HTMLElement | null);
|
|
436
|
+
},
|
|
437
|
+
[]
|
|
438
|
+
);
|
|
439
|
+
const setScrollHostRef = useCallback(
|
|
440
|
+
(value: React.ComponentRef<typeof View> | null) => {
|
|
441
|
+
setOwnedScrollHost(value as unknown as HTMLElement | null);
|
|
442
|
+
},
|
|
443
|
+
[]
|
|
444
|
+
);
|
|
445
|
+
if (!useSlotLayout) return <View {...viewProps} ref={setHostRef} />;
|
|
446
|
+
const padding = slotState.padding;
|
|
447
|
+
const content = (
|
|
448
|
+
<View
|
|
449
|
+
ref={setBoundsRef}
|
|
450
|
+
style={{ position: 'relative', flexShrink: 0, minWidth: 0 }}
|
|
451
|
+
>
|
|
452
|
+
{listHeader !== undefined ? (
|
|
453
|
+
<View style={{ paddingHorizontal: padding }}>{listHeader}</View>
|
|
454
|
+
) : null}
|
|
455
|
+
<View ref={setHostRef} style={{ flexShrink: 0, minWidth: 0 }} />
|
|
456
|
+
{!slotState.hasRows && hasEmptySlot ? (
|
|
457
|
+
<View
|
|
458
|
+
style={{
|
|
459
|
+
paddingHorizontal: padding,
|
|
460
|
+
paddingBottom: slotState.emptyBottomPadding,
|
|
461
|
+
}}
|
|
462
|
+
>
|
|
463
|
+
{listEmpty}
|
|
464
|
+
</View>
|
|
465
|
+
) : null}
|
|
466
|
+
{listFooter !== undefined ? (
|
|
467
|
+
<View style={{ paddingHorizontal: padding }}>{listFooter}</View>
|
|
468
|
+
) : null}
|
|
469
|
+
</View>
|
|
470
|
+
);
|
|
471
|
+
return (
|
|
472
|
+
<View
|
|
473
|
+
{...viewProps}
|
|
474
|
+
style={[viewProps.style, { position: 'relative', minHeight: 0 }]}
|
|
475
|
+
>
|
|
476
|
+
{webScrollHost === undefined ? (
|
|
477
|
+
<View
|
|
478
|
+
ref={setScrollHostRef}
|
|
479
|
+
style={{ position: 'absolute', inset: 0, overflow: 'scroll' }}
|
|
480
|
+
>
|
|
481
|
+
{content}
|
|
482
|
+
</View>
|
|
483
|
+
) : (
|
|
484
|
+
content
|
|
485
|
+
)}
|
|
486
|
+
</View>
|
|
487
|
+
);
|
|
343
488
|
}
|
|
344
489
|
);
|
package/src/models.ts
CHANGED
|
@@ -25,6 +25,8 @@ export type ImageSource = Readonly<{
|
|
|
25
25
|
loadingStrategy?: ImageLoadingStrategy;
|
|
26
26
|
// OneKey patch: fallbackUri is Web-only; retryTimes opts all platforms into terminal retries.
|
|
27
27
|
fallbackUri?: string;
|
|
28
|
+
/** Web-only ordered continuation; retries each source before advancing. */
|
|
29
|
+
fallbackUris?: readonly string[];
|
|
28
30
|
retryTimes?: number;
|
|
29
31
|
}>;
|
|
30
32
|
|
|
@@ -592,11 +594,95 @@ export type DataRow = RowBase &
|
|
|
592
594
|
style?: DataRowStyle;
|
|
593
595
|
}>;
|
|
594
596
|
|
|
597
|
+
export type WebMarketTableColumn = Readonly<{
|
|
598
|
+
key: string;
|
|
599
|
+
width?: number;
|
|
600
|
+
minWidth?: number;
|
|
601
|
+
flex?: number;
|
|
602
|
+
alignment?: 'start' | 'center' | 'end';
|
|
603
|
+
paddingStart?: number;
|
|
604
|
+
paddingEnd?: number;
|
|
605
|
+
}>;
|
|
606
|
+
|
|
607
|
+
export type WebMarketTableText = Readonly<{
|
|
608
|
+
text: string;
|
|
609
|
+
segments?: readonly ValueTextSegment[];
|
|
610
|
+
tone?: TextTone;
|
|
611
|
+
style?: Pick<
|
|
612
|
+
NativeListTextStyle,
|
|
613
|
+
'fontSize' | 'fontWeight' | 'lineHeight' | 'color'
|
|
614
|
+
>;
|
|
615
|
+
}>;
|
|
616
|
+
|
|
617
|
+
export type WebMarketTableCell = Readonly<{ key: string }> &
|
|
618
|
+
(
|
|
619
|
+
| Readonly<{
|
|
620
|
+
kind: 'favorite';
|
|
621
|
+
active: boolean;
|
|
622
|
+
disabled?: boolean;
|
|
623
|
+
testID?: string;
|
|
624
|
+
hoverActionKey?: string;
|
|
625
|
+
actionKey: string;
|
|
626
|
+
accessibilityLabel: string;
|
|
627
|
+
}>
|
|
628
|
+
| Readonly<{
|
|
629
|
+
kind: 'asset';
|
|
630
|
+
leading: LeadingVisual;
|
|
631
|
+
title: WebMarketTableText;
|
|
632
|
+
secondary?: readonly WebMarketTableText[];
|
|
633
|
+
lineGap?: number;
|
|
634
|
+
secondaryBadges?: readonly Pick<
|
|
635
|
+
MarketBadgeModel,
|
|
636
|
+
'key' | 'text' | 'style'
|
|
637
|
+
>[];
|
|
638
|
+
hoverImages?: readonly (ImageSource | null)[];
|
|
639
|
+
hoverSecondary?: readonly WebMarketTableText[];
|
|
640
|
+
hoverActionKey?: string;
|
|
641
|
+
hoverActionLabel?: string;
|
|
642
|
+
badges?: readonly Pick<
|
|
643
|
+
MarketBadgeModel,
|
|
644
|
+
| 'key'
|
|
645
|
+
| 'text'
|
|
646
|
+
| 'iconName'
|
|
647
|
+
| 'icon'
|
|
648
|
+
| 'textColor'
|
|
649
|
+
| 'backgroundColor'
|
|
650
|
+
| 'actionKey'
|
|
651
|
+
| 'accessibilityLabel'
|
|
652
|
+
| 'style'
|
|
653
|
+
>[];
|
|
654
|
+
}>
|
|
655
|
+
| Readonly<{
|
|
656
|
+
kind: 'text';
|
|
657
|
+
primary: readonly WebMarketTableText[];
|
|
658
|
+
partGap?: number;
|
|
659
|
+
secondary?: readonly WebMarketTableText[];
|
|
660
|
+
}>
|
|
661
|
+
| Readonly<{
|
|
662
|
+
kind: 'sparkline';
|
|
663
|
+
points: readonly number[];
|
|
664
|
+
width: number;
|
|
665
|
+
height: number;
|
|
666
|
+
strokeColor: string;
|
|
667
|
+
fillColor: string;
|
|
668
|
+
}>
|
|
669
|
+
);
|
|
670
|
+
|
|
671
|
+
export type WebMarketTablePresentation = Readonly<{
|
|
672
|
+
draggable?: boolean;
|
|
673
|
+
contextMenuActionKey?: string;
|
|
674
|
+
testID?: string;
|
|
675
|
+
columns: readonly WebMarketTableColumn[];
|
|
676
|
+
cells: readonly WebMarketTableCell[];
|
|
677
|
+
}>;
|
|
678
|
+
|
|
595
679
|
/** Native Market quote row. All values are already localized/formatted strings. */
|
|
596
680
|
export type MarketRow = RowBase &
|
|
597
681
|
Readonly<{
|
|
598
682
|
type: 'market';
|
|
599
683
|
variant: 'token' | 'stock' | 'perp';
|
|
684
|
+
/** Web-only bounded table presentation; native reads the ordinary Market fields. */
|
|
685
|
+
webTable?: WebMarketTablePresentation;
|
|
600
686
|
leadingAction?: Extract<TrailingAccessory, { kind: 'icon' }>;
|
|
601
687
|
leading: LeadingVisual;
|
|
602
688
|
title: string;
|
|
@@ -604,6 +690,8 @@ export type MarketRow = RowBase &
|
|
|
604
690
|
/** OneKey patch: localized name shrinks independently of the volume. */
|
|
605
691
|
subtitlePrefix?: Readonly<{
|
|
606
692
|
text: string;
|
|
693
|
+
/** Web-only anchored help for a truncated name. */
|
|
694
|
+
hoverActionKey?: string;
|
|
607
695
|
gap?: number;
|
|
608
696
|
maxWidth?: number;
|
|
609
697
|
style?: MarketTextStyle;
|
|
@@ -767,6 +855,8 @@ export type NativeListTheme = Readonly<{
|
|
|
767
855
|
rowPressedBackground?: string;
|
|
768
856
|
subduedBackground?: string;
|
|
769
857
|
strongBackground?: string;
|
|
858
|
+
/** Web-only background for a displayed declared image fallback. */
|
|
859
|
+
imageFallbackBackground?: string;
|
|
770
860
|
primaryText: string;
|
|
771
861
|
secondaryText: string;
|
|
772
862
|
disabledText?: string;
|
|
@@ -979,6 +1069,7 @@ export type RowPatch =
|
|
|
979
1069
|
| 'pressInActionKey'
|
|
980
1070
|
| 'longPressActionKey'
|
|
981
1071
|
| 'diagnostics'
|
|
1072
|
+
| 'webTable'
|
|
982
1073
|
| 'style'
|
|
983
1074
|
>
|
|
984
1075
|
>;
|
|
@@ -1097,6 +1188,8 @@ export type NativeListActionAnchor = Readonly<{
|
|
|
1097
1188
|
}>;
|
|
1098
1189
|
|
|
1099
1190
|
export type RowActionEvent = Readonly<{
|
|
1191
|
+
/** Web-only client/window CSS pixel pointer location. */
|
|
1192
|
+
windowPoint?: Readonly<{ x: number; y: number }>;
|
|
1100
1193
|
rowKey?: string;
|
|
1101
1194
|
actionKey: string;
|
|
1102
1195
|
sectionKey?: string;
|