@onekeyfe/react-native-native-list 6.7.0-17 → 6.7.0-19
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/NativeListView.kt +29 -73
- package/docs/SPEC.md +52 -8
- package/ios/HybridNativeList.swift +8 -4
- package/ios/RNCNativeListView.swift +35 -8
- package/ios/tests/NativeListLifecycleTests.swift +243 -18
- package/lib/module/NativeList.js +5 -1
- package/lib/module/NativeList.web.js +79 -30
- package/lib/module/index.js +1 -1
- package/lib/module/validation.js +90 -0
- package/lib/module/web/NativeListWebEngine.js +4 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/validation.d.ts +2 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +1 -0
- package/package.json +3 -3
- package/src/NativeList.tsx +7 -1
- package/src/NativeList.web.tsx +136 -47
- package/src/index.ts +1 -0
- package/src/validation.ts +110 -0
- package/src/web/NativeListWebEngine.ts +5 -1
|
@@ -8,6 +8,8 @@ export declare function captureNativeListInput<T>(value: T): T;
|
|
|
8
8
|
/** Private native-wrapper ownership; exported validators keep their public identity. */
|
|
9
9
|
export declare function ownValidatedNativeSnapshot(snapshot: NativeListSnapshot): NativeListSnapshot;
|
|
10
10
|
export declare function validatePatches(patches: readonly RowPatch[]): readonly RowPatch[];
|
|
11
|
+
/** Plan value-only patches; callers own valid immutable snapshots and commit state. */
|
|
12
|
+
export declare function planNativeListPatches(previous: NativeListSnapshot, next: NativeListSnapshot): readonly RowPatch[] | undefined;
|
|
11
13
|
export declare function applyRowPatches(snapshot: NativeListSnapshot, patches: readonly RowPatch[]): NativeListSnapshot;
|
|
12
14
|
/** Native wrapper only: preserve full public validation for unsupported patches. */
|
|
13
15
|
export declare function applyOwnedNativePatches(snapshot: NativeListSnapshot, patches: readonly RowPatch[]): {
|
|
@@ -189,6 +189,7 @@ export declare class NativeListWebEngine {
|
|
|
189
189
|
updateCallbacks(callbacks: NativeListWebCallbacks): void;
|
|
190
190
|
setVirtualizationEnabled(enabled: boolean): void;
|
|
191
191
|
applySnapshot(snapshot: NativeListSnapshot): void;
|
|
192
|
+
private applyValidatedSnapshot;
|
|
192
193
|
private cancelStructuralAnimation;
|
|
193
194
|
private handleStructuralUserScroll;
|
|
194
195
|
private updateStructuralTailWindow;
|
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-19",
|
|
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-19",
|
|
90
|
+
"@onekeyfe/react-native-native-logger": "6.7.0-19",
|
|
91
91
|
"react": "*",
|
|
92
92
|
"react-native": "*",
|
|
93
93
|
"react-native-nitro-modules": "0.37.0"
|
package/src/NativeList.tsx
CHANGED
|
@@ -82,6 +82,7 @@ const NativeListHost = getHostComponent<
|
|
|
82
82
|
NativeListNativeProps,
|
|
83
83
|
NativeListMethods
|
|
84
84
|
>('NativeList', () => NativeListConfig);
|
|
85
|
+
const clearedStructuralTransitionSettled = { f: undefined } as const;
|
|
85
86
|
const disclosureSlotMeasurementStyle = { alignSelf: 'stretch' } as const;
|
|
86
87
|
|
|
87
88
|
export function preloadNativeListAvatarImages(
|
|
@@ -328,7 +329,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
328
329
|
? Math.min(viewportWidth, sidecarLayout.maxContentWidth)
|
|
329
330
|
: 0;
|
|
330
331
|
const slotInset = sidecarLayout
|
|
331
|
-
? Math.max(0, (viewportWidth - bandWidth) / 2)
|
|
332
|
+
? Math.max(0, (viewportWidth - bandWidth) / 2) + defaultSlotInset
|
|
332
333
|
: defaultSlotInset;
|
|
333
334
|
const sidecarSpace = sidecarLayout
|
|
334
335
|
? sidecarLayout.width + sidecarLayout.gap
|
|
@@ -795,6 +796,11 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
795
796
|
viewProps.onLayout?.(event);
|
|
796
797
|
}}
|
|
797
798
|
{...nativeCallbacks}
|
|
799
|
+
onStructuralTransitionSettled={
|
|
800
|
+
onStructuralTransitionSettled
|
|
801
|
+
? nativeCallbacks.onStructuralTransitionSettled
|
|
802
|
+
: clearedStructuralTransitionSettled
|
|
803
|
+
}
|
|
798
804
|
fontFamiliesJson={fontFamiliesJson}
|
|
799
805
|
snapshotJson={snapshotJson}
|
|
800
806
|
containerSlotHeightsJson={containerSlotHeightsJson}
|
package/src/NativeList.web.tsx
CHANGED
|
@@ -37,6 +37,8 @@ import {
|
|
|
37
37
|
canonicalNativeListAvatarUri,
|
|
38
38
|
} from './web/NativeListWebAvatarCache';
|
|
39
39
|
|
|
40
|
+
const collapsedExpandedContentStyle = { display: 'none' } as const;
|
|
41
|
+
|
|
40
42
|
export type { NativeListProps, NativeListRef } from './NativeList.types';
|
|
41
43
|
export type {
|
|
42
44
|
ActionAnchorState,
|
|
@@ -93,8 +95,8 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
93
95
|
listHeader,
|
|
94
96
|
listEmpty,
|
|
95
97
|
listFooter,
|
|
96
|
-
listExpandedContent
|
|
97
|
-
listStructureToggle
|
|
98
|
+
listExpandedContent,
|
|
99
|
+
listStructureToggle,
|
|
98
100
|
listSidecar,
|
|
99
101
|
sidecarLayout,
|
|
100
102
|
topOverlay: _topOverlay,
|
|
@@ -137,10 +139,16 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
137
139
|
}) ?? 0,
|
|
138
140
|
[inputStickyInset]
|
|
139
141
|
);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
// Freshness is limited to this component invocation; later renders revalidate.
|
|
143
|
+
let freshlyValidatedSnapshot: NativeListSnapshot | undefined;
|
|
144
|
+
const preparedSnapshot = useMemo(() => {
|
|
145
|
+
const prepared = containNativeListInput(() =>
|
|
146
|
+
validateSnapshot(inputSnapshot)
|
|
147
|
+
);
|
|
148
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- The value is intentionally render-local.
|
|
149
|
+
freshlyValidatedSnapshot = prepared;
|
|
150
|
+
return prepared;
|
|
151
|
+
}, [inputSnapshot]);
|
|
144
152
|
const snapshot = preparedSnapshot ?? acceptedSnapshotRef.current;
|
|
145
153
|
const fontFamiliesJson = useNativeListFontFamiliesJson();
|
|
146
154
|
const fontFamiliesJsonRef = useRef(fontFamiliesJson);
|
|
@@ -148,51 +156,28 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
148
156
|
const hasEmptySlot = listEmpty !== undefined;
|
|
149
157
|
const hasEmptySlotRef = useRef(hasEmptySlot);
|
|
150
158
|
hasEmptySlotRef.current = hasEmptySlot;
|
|
151
|
-
const [slotState, setSlotState] = useState(() => ({
|
|
152
|
-
hasRows: snapshot.rows.length > 0,
|
|
153
|
-
emptyBottomPadding:
|
|
154
|
-
!snapshot.rows.length && hasEmptySlot
|
|
155
|
-
? snapshot.layout.contentPaddingBottom ??
|
|
156
|
-
snapshot.layout.contentPadding ??
|
|
157
|
-
0
|
|
158
|
-
: 0,
|
|
159
|
-
padding:
|
|
160
|
-
snapshot.layout.contentPaddingHorizontal ??
|
|
161
|
-
snapshot.layout.contentPadding ??
|
|
162
|
-
0,
|
|
163
|
-
}));
|
|
164
159
|
const [viewportWidth, setViewportWidth] = useState(0);
|
|
165
160
|
const [sidecarHeight, setSidecarHeight] = useState(0);
|
|
166
|
-
const synchronizeSlots = (next: NativeListSnapshot) => {
|
|
167
|
-
const hasRows = next.rows.length > 0;
|
|
168
|
-
const padding =
|
|
169
|
-
next.layout.contentPaddingHorizontal ?? next.layout.contentPadding ?? 0;
|
|
170
|
-
const emptyBottomPadding =
|
|
171
|
-
!hasRows && hasEmptySlotRef.current
|
|
172
|
-
? next.layout.contentPaddingBottom ?? next.layout.contentPadding ?? 0
|
|
173
|
-
: 0;
|
|
174
|
-
setSlotState((previous) =>
|
|
175
|
-
previous.hasRows === hasRows &&
|
|
176
|
-
previous.padding === padding &&
|
|
177
|
-
previous.emptyBottomPadding === emptyBottomPadding
|
|
178
|
-
? previous
|
|
179
|
-
: { hasRows, padding, emptyBottomPadding }
|
|
180
|
-
);
|
|
181
|
-
};
|
|
182
161
|
const normalizeWebSnapshot = (
|
|
183
162
|
next: NativeListSnapshot,
|
|
184
163
|
hasReactEmpty = hasEmptySlotRef.current,
|
|
185
|
-
hasSlotLayout = useSlotLayoutRef.current
|
|
164
|
+
hasSlotLayout = useSlotLayoutRef.current,
|
|
165
|
+
validatedInThisRender = false
|
|
186
166
|
) => {
|
|
187
167
|
if (hasSlotLayout && next.layout.orientation === 'horizontal')
|
|
188
168
|
throw new Error(
|
|
189
169
|
'Web parent scrolling and container slots support vertical lists only'
|
|
190
170
|
);
|
|
191
171
|
const emptySlot = hasReactEmpty && next.rows.length === 0;
|
|
192
|
-
const
|
|
193
|
-
emptySlot
|
|
194
|
-
|
|
195
|
-
|
|
172
|
+
const normalized =
|
|
173
|
+
emptySlot && next.emptyState !== undefined
|
|
174
|
+
? { ...next, emptyState: undefined }
|
|
175
|
+
: next;
|
|
176
|
+
const validated = validatedInThisRender
|
|
177
|
+
? normalized
|
|
178
|
+
: validateSnapshot(normalized);
|
|
179
|
+
// Preserve an already normalized fallback's identity across rerenders.
|
|
180
|
+
return emptySlot && validated.layout.contentPaddingBottom !== 0
|
|
196
181
|
? {
|
|
197
182
|
...validated,
|
|
198
183
|
layout: { ...validated.layout, contentPaddingBottom: 0 },
|
|
@@ -213,6 +198,8 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
213
198
|
listEmpty !== undefined ||
|
|
214
199
|
listFooter !== undefined;
|
|
215
200
|
useSlotLayoutRef.current ||= listSidecar !== undefined;
|
|
201
|
+
useSlotLayoutRef.current ||=
|
|
202
|
+
listExpandedContent !== undefined || listStructureToggle !== undefined;
|
|
216
203
|
const useSlotLayout = useSlotLayoutRef.current;
|
|
217
204
|
const resolvedScrollHost =
|
|
218
205
|
webScrollHost === undefined
|
|
@@ -243,10 +230,68 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
243
230
|
)
|
|
244
231
|
throw new Error('Invalid NativeList sidecar layout');
|
|
245
232
|
}
|
|
246
|
-
return normalizeWebSnapshot(
|
|
233
|
+
return normalizeWebSnapshot(
|
|
234
|
+
snapshot,
|
|
235
|
+
hasEmptySlot,
|
|
236
|
+
useSlotLayout,
|
|
237
|
+
preparedSnapshot !== undefined &&
|
|
238
|
+
preparedSnapshot === freshlyValidatedSnapshot
|
|
239
|
+
);
|
|
247
240
|
}) ?? acceptedSnapshotRef.current,
|
|
241
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- Preserve the existing memo dependencies; freshness is render-local.
|
|
248
242
|
[snapshot, hasEmptySlot, useSlotLayout, listSidecar, sidecarLayout]
|
|
249
243
|
);
|
|
244
|
+
const [slotState, setSlotState] = useState(() => ({
|
|
245
|
+
hasRows: validatedSnapshot.rows.length > 0,
|
|
246
|
+
emptyBottomPadding:
|
|
247
|
+
!validatedSnapshot.rows.length && hasEmptySlot
|
|
248
|
+
? validatedSnapshot.layout.contentPaddingBottom ??
|
|
249
|
+
validatedSnapshot.layout.contentPadding ??
|
|
250
|
+
0
|
|
251
|
+
: 0,
|
|
252
|
+
padding:
|
|
253
|
+
validatedSnapshot.layout.contentPaddingHorizontal ??
|
|
254
|
+
validatedSnapshot.layout.contentPadding ??
|
|
255
|
+
0,
|
|
256
|
+
disclosurePresent: validatedSnapshot.disclosure !== undefined,
|
|
257
|
+
disclosureExpanded: validatedSnapshot.disclosure?.expanded === true,
|
|
258
|
+
hasExpandedContent: validatedSnapshot.disclosure?.expanded === true,
|
|
259
|
+
expandedTrailingInset:
|
|
260
|
+
validatedSnapshot.disclosure?.expandedTrailingInset ?? 0,
|
|
261
|
+
}));
|
|
262
|
+
const synchronizeSlots = (next: NativeListSnapshot) => {
|
|
263
|
+
const hasRows = next.rows.length > 0;
|
|
264
|
+
const padding =
|
|
265
|
+
next.layout.contentPaddingHorizontal ?? next.layout.contentPadding ?? 0;
|
|
266
|
+
const emptyBottomPadding =
|
|
267
|
+
!hasRows && hasEmptySlotRef.current
|
|
268
|
+
? next.layout.contentPaddingBottom ?? next.layout.contentPadding ?? 0
|
|
269
|
+
: 0;
|
|
270
|
+
const disclosurePresent = next.disclosure !== undefined;
|
|
271
|
+
const disclosureExpanded = next.disclosure?.expanded === true;
|
|
272
|
+
const expandedTrailingInset = next.disclosure?.expandedTrailingInset ?? 0;
|
|
273
|
+
setSlotState((previous) => {
|
|
274
|
+
const hasExpandedContent =
|
|
275
|
+
previous.hasExpandedContent || disclosureExpanded;
|
|
276
|
+
return previous.hasRows === hasRows &&
|
|
277
|
+
previous.padding === padding &&
|
|
278
|
+
previous.emptyBottomPadding === emptyBottomPadding &&
|
|
279
|
+
previous.disclosurePresent === disclosurePresent &&
|
|
280
|
+
previous.disclosureExpanded === disclosureExpanded &&
|
|
281
|
+
previous.hasExpandedContent === hasExpandedContent &&
|
|
282
|
+
previous.expandedTrailingInset === expandedTrailingInset
|
|
283
|
+
? previous
|
|
284
|
+
: {
|
|
285
|
+
hasRows,
|
|
286
|
+
padding,
|
|
287
|
+
emptyBottomPadding,
|
|
288
|
+
disclosurePresent,
|
|
289
|
+
disclosureExpanded,
|
|
290
|
+
hasExpandedContent,
|
|
291
|
+
expandedTrailingInset,
|
|
292
|
+
};
|
|
293
|
+
});
|
|
294
|
+
};
|
|
250
295
|
const snapshotRef = useRef(validatedSnapshot);
|
|
251
296
|
const snapshotPropRef = useRef(validatedSnapshot);
|
|
252
297
|
// An imperative snapshot survives host mounting until the snapshot prop changes.
|
|
@@ -254,7 +299,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
254
299
|
snapshotPropRef.current = validatedSnapshot;
|
|
255
300
|
snapshotRef.current = validatedSnapshot;
|
|
256
301
|
acceptedSnapshotRef.current = validatedSnapshot;
|
|
257
|
-
synchronizeSlots(
|
|
302
|
+
synchronizeSlots(validatedSnapshot);
|
|
258
303
|
}
|
|
259
304
|
if (!initializedSnapshot.current) {
|
|
260
305
|
acceptedSnapshotRef.current = validatedSnapshot;
|
|
@@ -523,6 +568,16 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
523
568
|
);
|
|
524
569
|
if (!useSlotLayout) return <View {...viewProps} ref={setHostRef} />;
|
|
525
570
|
const padding = slotState.padding;
|
|
571
|
+
const footerBandStyle = { paddingHorizontal: padding };
|
|
572
|
+
const trailingInsetStyle = {
|
|
573
|
+
height: slotState.disclosureExpanded
|
|
574
|
+
? slotState.expandedTrailingInset
|
|
575
|
+
: 0,
|
|
576
|
+
};
|
|
577
|
+
const hasFooterBand =
|
|
578
|
+
listFooter !== undefined ||
|
|
579
|
+
listExpandedContent !== undefined ||
|
|
580
|
+
listStructureToggle !== undefined;
|
|
526
581
|
const content = (
|
|
527
582
|
<View
|
|
528
583
|
ref={sidecarLayout ? undefined : setBoundsRef}
|
|
@@ -542,11 +597,45 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
|
|
|
542
597
|
{listEmpty}
|
|
543
598
|
</View>
|
|
544
599
|
) : null}
|
|
545
|
-
{
|
|
546
|
-
<View
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
600
|
+
{hasFooterBand ? (
|
|
601
|
+
<View testID="native-list-footer-slot" style={footerBandStyle}>
|
|
602
|
+
{listExpandedContent !== undefined &&
|
|
603
|
+
slotState.hasExpandedContent ? (
|
|
604
|
+
<View
|
|
605
|
+
testID="native-list-expanded-content-slot"
|
|
606
|
+
aria-hidden={!slotState.disclosureExpanded}
|
|
607
|
+
pointerEvents={slotState.disclosureExpanded ? 'auto' : 'none'}
|
|
608
|
+
style={
|
|
609
|
+
slotState.disclosureExpanded
|
|
610
|
+
? undefined
|
|
611
|
+
: collapsedExpandedContentStyle
|
|
612
|
+
}
|
|
613
|
+
>
|
|
614
|
+
{listExpandedContent}
|
|
615
|
+
</View>
|
|
616
|
+
) : null}
|
|
617
|
+
{listStructureToggle !== undefined ? (
|
|
618
|
+
<View
|
|
619
|
+
testID="native-list-structure-toggle-slot"
|
|
620
|
+
aria-hidden={!slotState.disclosurePresent}
|
|
621
|
+
pointerEvents={slotState.disclosurePresent ? 'auto' : 'none'}
|
|
622
|
+
style={
|
|
623
|
+
slotState.disclosurePresent
|
|
624
|
+
? undefined
|
|
625
|
+
: collapsedExpandedContentStyle
|
|
626
|
+
}
|
|
627
|
+
>
|
|
628
|
+
{listStructureToggle}
|
|
629
|
+
</View>
|
|
630
|
+
) : null}
|
|
631
|
+
{slotState.expandedTrailingInset > 0 &&
|
|
632
|
+
(listExpandedContent !== undefined ||
|
|
633
|
+
listStructureToggle !== undefined) ? (
|
|
634
|
+
<View
|
|
635
|
+
testID="native-list-trailing-inset-slot"
|
|
636
|
+
style={trailingInsetStyle}
|
|
637
|
+
/>
|
|
638
|
+
) : null}
|
|
550
639
|
{listFooter}
|
|
551
640
|
</View>
|
|
552
641
|
) : null}
|
package/src/index.ts
CHANGED
package/src/validation.ts
CHANGED
|
@@ -3186,6 +3186,116 @@ function normalizePatchStyles(
|
|
|
3186
3186
|
return changed ? next : patches;
|
|
3187
3187
|
}
|
|
3188
3188
|
|
|
3189
|
+
const EMPTY_ROW_PATCHES: readonly RowPatch[] = Object.freeze([]);
|
|
3190
|
+
|
|
3191
|
+
function sameJsonValue(left: unknown, right: unknown): boolean {
|
|
3192
|
+
if (left === right) return true;
|
|
3193
|
+
if (left === null || right === null) return false;
|
|
3194
|
+
if (typeof left !== 'object' || typeof right !== 'object') return false;
|
|
3195
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
3196
|
+
return (
|
|
3197
|
+
Array.isArray(left) &&
|
|
3198
|
+
Array.isArray(right) &&
|
|
3199
|
+
left.length === right.length &&
|
|
3200
|
+
left.every((value, index) => sameJsonValue(value, right[index]))
|
|
3201
|
+
);
|
|
3202
|
+
}
|
|
3203
|
+
const leftObject = left as Record<string, unknown>;
|
|
3204
|
+
const rightObject = right as Record<string, unknown>;
|
|
3205
|
+
const leftKeys = Object.keys(leftObject).filter(
|
|
3206
|
+
(key) => leftObject[key] !== undefined
|
|
3207
|
+
);
|
|
3208
|
+
const rightKeys = Object.keys(rightObject).filter(
|
|
3209
|
+
(key) => rightObject[key] !== undefined
|
|
3210
|
+
);
|
|
3211
|
+
return (
|
|
3212
|
+
leftKeys.length === rightKeys.length &&
|
|
3213
|
+
leftKeys.every((key) => sameJsonValue(leftObject[key], rightObject[key]))
|
|
3214
|
+
);
|
|
3215
|
+
}
|
|
3216
|
+
|
|
3217
|
+
function sameOptionalPresence(left: unknown, right: unknown): boolean {
|
|
3218
|
+
return (left === undefined) === (right === undefined);
|
|
3219
|
+
}
|
|
3220
|
+
|
|
3221
|
+
/** Plan value-only patches; callers own valid immutable snapshots and commit state. */
|
|
3222
|
+
export function planNativeListPatches(
|
|
3223
|
+
previous: NativeListSnapshot,
|
|
3224
|
+
next: NativeListSnapshot
|
|
3225
|
+
): readonly RowPatch[] | undefined {
|
|
3226
|
+
if (previous === next) return EMPTY_ROW_PATCHES;
|
|
3227
|
+
const { rows: previousRows, ...previousMetadata } = previous;
|
|
3228
|
+
const { rows: nextRows, ...nextMetadata } = next;
|
|
3229
|
+
if (
|
|
3230
|
+
previousRows.length !== nextRows.length ||
|
|
3231
|
+
!sameJsonValue(previousMetadata, nextMetadata)
|
|
3232
|
+
)
|
|
3233
|
+
return undefined;
|
|
3234
|
+
if (previousRows === nextRows) return EMPTY_ROW_PATCHES;
|
|
3235
|
+
|
|
3236
|
+
const patches: RowPatch[] = [];
|
|
3237
|
+
for (let index = 0; index < nextRows.length; index += 1) {
|
|
3238
|
+
const oldRow = previousRows[index];
|
|
3239
|
+
const row = nextRows[index];
|
|
3240
|
+
if (oldRow.key !== row.key || oldRow.type !== row.type) return undefined;
|
|
3241
|
+
if (oldRow === row) continue;
|
|
3242
|
+
|
|
3243
|
+
if (oldRow.type === 'identity' && row.type === 'identity') {
|
|
3244
|
+
const {
|
|
3245
|
+
subtitle: oldSubtitle,
|
|
3246
|
+
subtitleSegments: oldSubtitleSegments,
|
|
3247
|
+
trailing: oldTrailing,
|
|
3248
|
+
...oldMetadata
|
|
3249
|
+
} = oldRow;
|
|
3250
|
+
const { subtitle, subtitleSegments, trailing, ...metadata } = row;
|
|
3251
|
+
if (
|
|
3252
|
+
!sameOptionalPresence(oldSubtitle, subtitle) ||
|
|
3253
|
+
!sameOptionalPresence(oldSubtitleSegments, subtitleSegments) ||
|
|
3254
|
+
!sameOptionalPresence(oldTrailing, trailing) ||
|
|
3255
|
+
!sameJsonValue(oldMetadata, metadata)
|
|
3256
|
+
)
|
|
3257
|
+
return undefined;
|
|
3258
|
+
if (
|
|
3259
|
+
!sameJsonValue(oldSubtitle, subtitle) ||
|
|
3260
|
+
!sameJsonValue(oldSubtitleSegments, subtitleSegments) ||
|
|
3261
|
+
!sameJsonValue(oldTrailing, trailing)
|
|
3262
|
+
) {
|
|
3263
|
+
patches.push({
|
|
3264
|
+
type: 'identity',
|
|
3265
|
+
key: row.key,
|
|
3266
|
+
changes: { subtitle, subtitleSegments, trailing },
|
|
3267
|
+
});
|
|
3268
|
+
}
|
|
3269
|
+
} else if (oldRow.type === 'dataRow' && row.type === 'dataRow') {
|
|
3270
|
+
const {
|
|
3271
|
+
columns: oldColumns,
|
|
3272
|
+
trailing: oldTrailing,
|
|
3273
|
+
...oldMetadata
|
|
3274
|
+
} = oldRow;
|
|
3275
|
+
const { columns, trailing, ...metadata } = row;
|
|
3276
|
+
if (
|
|
3277
|
+
!sameOptionalPresence(oldTrailing, trailing) ||
|
|
3278
|
+
!sameJsonValue(oldMetadata, metadata) ||
|
|
3279
|
+
!sameJsonValue(oldColumns[0], columns[0])
|
|
3280
|
+
)
|
|
3281
|
+
return undefined;
|
|
3282
|
+
if (
|
|
3283
|
+
!sameJsonValue(oldColumns.slice(1), columns.slice(1)) ||
|
|
3284
|
+
!sameJsonValue(oldTrailing, trailing)
|
|
3285
|
+
) {
|
|
3286
|
+
patches.push({
|
|
3287
|
+
type: 'dataRow',
|
|
3288
|
+
key: row.key,
|
|
3289
|
+
changes: { columns, trailing },
|
|
3290
|
+
});
|
|
3291
|
+
}
|
|
3292
|
+
} else if (!sameJsonValue(oldRow, row)) {
|
|
3293
|
+
return undefined;
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
return patches.length === 0 ? EMPTY_ROW_PATCHES : patches;
|
|
3297
|
+
}
|
|
3298
|
+
|
|
3189
3299
|
export function applyRowPatches(
|
|
3190
3300
|
snapshot: NativeListSnapshot,
|
|
3191
3301
|
patches: readonly RowPatch[]
|
|
@@ -2611,7 +2611,7 @@ export class NativeListWebEngine {
|
|
|
2611
2611
|
);
|
|
2612
2612
|
this.observeSectionIndexTransforms();
|
|
2613
2613
|
this.applyFontFamilies(fontFamiliesJson);
|
|
2614
|
-
this.
|
|
2614
|
+
this.applyValidatedSnapshot(this.snapshot);
|
|
2615
2615
|
}
|
|
2616
2616
|
|
|
2617
2617
|
private validateStickyInset(value = 0): number {
|
|
@@ -2703,6 +2703,10 @@ export class NativeListWebEngine {
|
|
|
2703
2703
|
return next;
|
|
2704
2704
|
});
|
|
2705
2705
|
if (!validated) return;
|
|
2706
|
+
this.applyValidatedSnapshot(validated);
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
private applyValidatedSnapshot(validated: NativeListSnapshot) {
|
|
2706
2710
|
this.pressedHelpElement = undefined;
|
|
2707
2711
|
this.invalidateActionAnchor('snapshot');
|
|
2708
2712
|
const transition = validated.structuralTransition;
|