@onekeyfe/react-native-native-list 6.7.0-16 → 6.7.0-17

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.
Files changed (115) hide show
  1. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
  2. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +240 -11
  3. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +7 -4
  4. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +6 -3
  5. package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
  6. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
  7. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +87 -7
  8. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +177 -1
  9. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +43 -14
  10. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +33 -2
  12. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +22 -0
  13. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
  14. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
  16. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
  17. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
  18. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1877 -41
  19. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +1 -0
  20. package/docs/ROW_TEMPLATES.md +60 -9
  21. package/docs/SPEC.md +401 -5
  22. package/docs/STYLE_SPEC.md +6 -0
  23. package/ios/HybridNativeList.swift +17 -2
  24. package/ios/NativeListAccessoryStack.swift +227 -39
  25. package/ios/NativeListActivityDetailsView.swift +18 -8
  26. package/ios/NativeListActivityRenderer.swift +8 -2
  27. package/ios/NativeListButtonGroupRenderer.swift +89 -0
  28. package/ios/NativeListDataRowRenderer.swift +155 -27
  29. package/ios/NativeListDesignAssets.swift +3 -0
  30. package/ios/NativeListIdentityRenderer.swift +166 -30
  31. package/ios/NativeListLeadingVisual.swift +49 -14
  32. package/ios/NativeListMessageRenderer.swift +34 -1
  33. package/ios/NativeListModels.swift +42 -2
  34. package/ios/NativeListRendererRegistry.swift +1 -0
  35. package/ios/NativeListResolvedText.swift +2 -1
  36. package/ios/NativeListRowHost.swift +14 -0
  37. package/ios/NativeListSectionHeaderRenderer.swift +88 -0
  38. package/ios/RNCNativeListView.swift +984 -53
  39. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
  40. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
  41. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
  42. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
  43. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
  44. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
  45. package/ios/tests/NativeListActivityPresentationTests.swift +56 -0
  46. package/ios/tests/NativeListLifecycleTests.swift +2494 -3
  47. package/lib/module/NativeList.js +171 -28
  48. package/lib/module/NativeList.web.js +54 -4
  49. package/lib/module/models.js +1 -0
  50. package/lib/module/selection.js +1 -1
  51. package/lib/module/validation.js +331 -8
  52. package/lib/module/web/NativeListWebEngine.js +503 -18
  53. package/lib/module/web/templates/ActivityRowRenderer.js +8 -7
  54. package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
  55. package/lib/module/web/templates/DataRowRenderer.js +40 -5
  56. package/lib/module/web/templates/IdentityRowRenderer.js +90 -4
  57. package/lib/module/web/templates/MessageRowRenderer.js +18 -2
  58. package/lib/module/web/templates/RowContainerStyle.js +1 -0
  59. package/lib/module/web/templates/RowRendererRegistry.js +3 -0
  60. package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
  61. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  62. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  63. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  64. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  65. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  66. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  67. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  68. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  69. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  70. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  71. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  72. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  73. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  74. package/lib/typescript/src/NativeList.d.ts +1 -1
  75. package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
  76. package/lib/typescript/src/NativeList.types.d.ts +18 -0
  77. package/lib/typescript/src/index.d.ts +1 -1
  78. package/lib/typescript/src/models.d.ts +105 -9
  79. package/lib/typescript/src/validation.d.ts +10 -0
  80. package/lib/typescript/src/web/NativeListWebEngine.d.ts +31 -0
  81. package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
  82. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
  83. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
  84. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  85. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  86. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  87. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  88. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  89. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  90. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  91. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  92. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  93. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  94. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  95. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  96. package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  97. package/package.json +3 -3
  98. package/react-native-native-list.podspec +1 -0
  99. package/src/NativeList.nitro.ts +2 -0
  100. package/src/NativeList.tsx +307 -44
  101. package/src/NativeList.types.ts +22 -0
  102. package/src/NativeList.web.tsx +75 -8
  103. package/src/index.ts +1 -0
  104. package/src/models.ts +117 -3
  105. package/src/selection.ts +1 -0
  106. package/src/validation.ts +742 -6
  107. package/src/web/NativeListWebEngine.ts +798 -19
  108. package/src/web/templates/ActivityRowRenderer.ts +14 -6
  109. package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
  110. package/src/web/templates/DataRowRenderer.ts +93 -20
  111. package/src/web/templates/IdentityRowRenderer.ts +150 -5
  112. package/src/web/templates/MessageRowRenderer.ts +23 -7
  113. package/src/web/templates/RowContainerStyle.ts +2 -0
  114. package/src/web/templates/RowRendererRegistry.ts +11 -1
  115. package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
@@ -32,7 +32,11 @@ import type {
32
32
  EndReachedEvent,
33
33
  VisibleRangeChangedEvent,
34
34
  } from './models';
35
- import type { NativeListProps, NativeListRef } from './NativeList.types';
35
+ import type {
36
+ NativeListProps,
37
+ NativeListRef,
38
+ StructuralTransitionSettledEvent,
39
+ } from './NativeList.types';
36
40
  import { isSelectableRow } from './selection';
37
41
  import {
38
42
  normalizeIndexScroll,
@@ -44,15 +48,19 @@ import {
44
48
  type NormalizedPositionScroll,
45
49
  } from './scrolling';
46
50
  import {
47
- applyRowPatches,
51
+ applyOwnedNativePatches,
52
+ captureNativeListInput,
48
53
  containNativeListInput,
49
54
  emptyNativeListSnapshot,
50
- serializePatches,
51
- validatePatches,
55
+ ownValidatedNativeSnapshot,
52
56
  validateSnapshot,
53
57
  } from './validation';
54
58
 
55
- export type { NativeListProps, NativeListRef } from './NativeList.types';
59
+ export type {
60
+ NativeListProps,
61
+ NativeListRef,
62
+ StructuralTransitionSettledEvent,
63
+ } from './NativeList.types';
56
64
  export type {
57
65
  ActionAnchorState,
58
66
  NativeListKeyboardDismissMode,
@@ -74,6 +82,7 @@ const NativeListHost = getHostComponent<
74
82
  NativeListNativeProps,
75
83
  NativeListMethods
76
84
  >('NativeList', () => NativeListConfig);
85
+ const disclosureSlotMeasurementStyle = { alignSelf: 'stretch' } as const;
77
86
 
78
87
  export function preloadNativeListAvatarImages(
79
88
  sources: readonly ImageSource[]
@@ -107,6 +116,10 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
107
116
  listHeader,
108
117
  listFooter,
109
118
  listEmpty,
119
+ listSidecar,
120
+ listExpandedContent,
121
+ listStructureToggle,
122
+ sidecarLayout,
110
123
  topOverlay,
111
124
  topScrollEdgeEffect,
112
125
  scrollPositionThresholds,
@@ -122,6 +135,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
122
135
  onReorder,
123
136
  onEndReached,
124
137
  onVisibleRangeChanged,
138
+ onStructuralTransitionSettled,
125
139
  onScrollPositionThresholdChange,
126
140
  onRefresh,
127
141
  onScrollToIndexFailed,
@@ -134,27 +148,171 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
134
148
  forwardedRef
135
149
  ) {
136
150
  const snapshotRef = useRef<NativeListSnapshot>(emptyNativeListSnapshot());
151
+ const renderedSnapshotRef = useRef<NativeListSnapshot | undefined>(
152
+ undefined
153
+ );
137
154
  const initializedSnapshot = useRef(false);
138
- const hasContainerSlots = Boolean(listHeader || listEmpty || listFooter);
139
- const prepareSnapshot = useCallback(
140
- (next: NativeListSnapshot) => {
141
- const accepted = validateSnapshot(next);
155
+ const pendingDisclosureSnapshotRef = useRef<
156
+ | {
157
+ source: 'prop' | 'imperative';
158
+ input: NativeListSnapshot;
159
+ owned: NativeListSnapshot;
160
+ expandedEpoch: number;
161
+ toggleEpoch: number;
162
+ }
163
+ | undefined
164
+ >(undefined);
165
+ const previousPropInputRef = useRef(inputSnapshot);
166
+ const [pendingDisclosureRevision, setPendingDisclosureRevision] =
167
+ useState(0);
168
+ const disclosureSlotMounts = useRef({
169
+ expandedPresent: false,
170
+ togglePresent: false,
171
+ expandedEpoch: 0,
172
+ toggleEpoch: 0,
173
+ });
174
+ const expandedPresent = listExpandedContent != null;
175
+ const togglePresent = listStructureToggle != null;
176
+ if (disclosureSlotMounts.current.expandedPresent !== expandedPresent) {
177
+ disclosureSlotMounts.current.expandedPresent = expandedPresent;
178
+ disclosureSlotMounts.current.expandedEpoch += 1;
179
+ }
180
+ if (disclosureSlotMounts.current.togglePresent !== togglePresent) {
181
+ disclosureSlotMounts.current.togglePresent = togglePresent;
182
+ disclosureSlotMounts.current.toggleEpoch += 1;
183
+ }
184
+ const expandedEpoch = disclosureSlotMounts.current.expandedEpoch;
185
+ const toggleEpoch = disclosureSlotMounts.current.toggleEpoch;
186
+ const [slotMeasurements, setSlotMeasurements] = useState({
187
+ heights: [0, 0, 0, 0, 0, 0],
188
+ readyEpochs: [-1, -1, -1, -1, -1, -1],
189
+ });
190
+ const hasSidecar = listSidecar !== undefined;
191
+ const sidecarWidth = sidecarLayout?.width;
192
+ const sidecarGap = sidecarLayout?.gap;
193
+ const sidecarMaxContentWidth = sidecarLayout?.maxContentWidth;
194
+ const hasContainerSlots = Boolean(
195
+ listHeader ||
196
+ listEmpty ||
197
+ listFooter ||
198
+ listSidecar ||
199
+ listExpandedContent ||
200
+ listStructureToggle
201
+ );
202
+ const validateContainerConfiguration = useCallback(
203
+ (accepted: NativeListSnapshot) => {
142
204
  if (hasContainerSlots && accepted.layout.orientation === 'horizontal')
143
205
  throw new Error(
144
206
  'NativeList container slots require vertical orientation'
145
207
  );
146
- return accepted;
208
+ if (hasSidecar !== (sidecarWidth !== undefined))
209
+ throw new Error(
210
+ 'listSidecar and sidecarLayout must be supplied together'
211
+ );
212
+ if (sidecarWidth !== undefined) {
213
+ const width = sidecarWidth;
214
+ const gap = sidecarGap ?? NaN;
215
+ const maxContentWidth = sidecarMaxContentWidth ?? NaN;
216
+ if (
217
+ accepted.layout.kind !== 'linear' ||
218
+ !Number.isFinite(width) ||
219
+ width <= 0 ||
220
+ !Number.isFinite(gap) ||
221
+ gap < 0 ||
222
+ !Number.isFinite(maxContentWidth) ||
223
+ maxContentWidth <= width + gap
224
+ )
225
+ throw new Error('Invalid NativeList sidecar layout');
226
+ }
147
227
  },
148
- [hasContainerSlots]
228
+ [
229
+ hasContainerSlots,
230
+ hasSidecar,
231
+ sidecarWidth,
232
+ sidecarGap,
233
+ sidecarMaxContentWidth,
234
+ ]
149
235
  );
150
- const snapshot = useMemo(
151
- () =>
152
- containNativeListInput(() => prepareSnapshot(inputSnapshot)) ??
153
- snapshotRef.current,
154
- [inputSnapshot, prepareSnapshot]
236
+ const prepareSnapshot = useCallback(
237
+ (next: NativeListSnapshot) => {
238
+ const accepted = validateSnapshot(captureNativeListInput(next));
239
+ validateContainerConfiguration(accepted);
240
+ return ownValidatedNativeSnapshot(accepted);
241
+ },
242
+ [validateContainerConfiguration]
155
243
  );
244
+ const expandedReadyEpoch = slotMeasurements.readyEpochs[4];
245
+ const toggleReadyEpoch = slotMeasurements.readyEpochs[5];
246
+ const snapshot = useMemo(() => {
247
+ // Imperative pending snapshots use this revision to retry the readiness gate.
248
+ // eslint-disable-next-line no-void -- Reading this revision invalidates the readiness memo.
249
+ void pendingDisclosureRevision;
250
+ const propReplaced = previousPropInputRef.current !== inputSnapshot;
251
+ previousPropInputRef.current = inputSnapshot;
252
+ const pending = pendingDisclosureSnapshotRef.current;
253
+ const retained =
254
+ pending &&
255
+ !propReplaced &&
256
+ (pending.source === 'imperative' || pending.input === inputSnapshot) &&
257
+ pending.expandedEpoch === expandedEpoch &&
258
+ pending.toggleEpoch === toggleEpoch
259
+ ? pending
260
+ : undefined;
261
+ const candidate =
262
+ retained?.owned ??
263
+ (!propReplaced && initializedSnapshot.current
264
+ ? renderedSnapshotRef.current ?? snapshotRef.current
265
+ : containNativeListInput(() => prepareSnapshot(inputSnapshot)) ??
266
+ snapshotRef.current);
267
+ const acceptedCandidate =
268
+ !propReplaced && initializedSnapshot.current
269
+ ? containNativeListInput(() => {
270
+ validateContainerConfiguration(candidate);
271
+ return candidate;
272
+ })
273
+ : candidate;
274
+ if (!acceptedCandidate) {
275
+ pendingDisclosureSnapshotRef.current = undefined;
276
+ return renderedSnapshotRef.current ?? snapshotRef.current;
277
+ }
278
+ const transitionId = acceptedCandidate.structuralTransition?.id;
279
+ const newDisclosureCommand =
280
+ initializedSnapshot.current &&
281
+ acceptedCandidate.disclosure !== undefined &&
282
+ transitionId !== undefined &&
283
+ transitionId !== snapshotRef.current.structuralTransition?.id;
284
+ if (
285
+ newDisclosureCommand &&
286
+ ((expandedPresent && expandedReadyEpoch !== expandedEpoch) ||
287
+ (togglePresent && toggleReadyEpoch !== toggleEpoch))
288
+ ) {
289
+ pendingDisclosureSnapshotRef.current = retained ?? {
290
+ source: 'prop',
291
+ input: inputSnapshot,
292
+ owned: acceptedCandidate,
293
+ expandedEpoch,
294
+ toggleEpoch,
295
+ };
296
+ return snapshotRef.current;
297
+ }
298
+ pendingDisclosureSnapshotRef.current = undefined;
299
+ return acceptedCandidate;
300
+ }, [
301
+ inputSnapshot,
302
+ prepareSnapshot,
303
+ validateContainerConfiguration,
304
+ expandedPresent,
305
+ togglePresent,
306
+ expandedEpoch,
307
+ toggleEpoch,
308
+ expandedReadyEpoch,
309
+ toggleReadyEpoch,
310
+ pendingDisclosureRevision,
311
+ ]);
312
+ renderedSnapshotRef.current = snapshot;
156
313
  const fontFamiliesJson = useNativeListFontFamiliesJson();
157
- const [slotHeights, setSlotHeights] = useState([0, 0, 0]);
314
+ const slotHeights = slotMeasurements.heights;
315
+ const [viewportWidth, setViewportWidth] = useState(0);
158
316
  const [topOverlayHeight, setTopOverlayHeight] = useState(0);
159
317
  const hasTopOverlay =
160
318
  Platform?.OS === 'ios' &&
@@ -162,11 +320,51 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
162
320
  (topScrollEdgeEffect === 'hard' || topScrollEdgeEffect === 'soft') &&
163
321
  topOverlay != null;
164
322
  const containerSlotHeightsJson = JSON.stringify(slotHeights);
165
- const slotInset =
323
+ const defaultSlotInset =
166
324
  snapshot.layout.contentPaddingHorizontal ??
167
325
  snapshot.layout.contentPadding ??
168
326
  0;
169
- const slotContents = [listHeader, listEmpty, listFooter];
327
+ const bandWidth = sidecarLayout
328
+ ? Math.min(viewportWidth, sidecarLayout.maxContentWidth)
329
+ : 0;
330
+ const slotInset = sidecarLayout
331
+ ? Math.max(0, (viewportWidth - bandWidth) / 2)
332
+ : defaultSlotInset;
333
+ const sidecarSpace = sidecarLayout
334
+ ? sidecarLayout.width + sidecarLayout.gap
335
+ : 0;
336
+ const slotContents = [
337
+ listHeader,
338
+ listEmpty,
339
+ listFooter,
340
+ listSidecar,
341
+ listExpandedContent,
342
+ listStructureToggle,
343
+ ];
344
+ const recordSlotLayout = (index: number, height: number, epoch: number) => {
345
+ if (
346
+ (index === 4 && epoch !== disclosureSlotMounts.current.expandedEpoch) ||
347
+ (index === 5 && epoch !== disclosureSlotMounts.current.toggleEpoch)
348
+ ) {
349
+ return;
350
+ }
351
+ setSlotMeasurements((previous) => {
352
+ if (
353
+ previous.heights[index] === height &&
354
+ previous.readyEpochs[index] === epoch
355
+ ) {
356
+ return previous;
357
+ }
358
+ const heights = [...previous.heights];
359
+ const readyEpochs = [...previous.readyEpochs];
360
+ heights[index] = height;
361
+ readyEpochs[index] = epoch;
362
+ return { heights, readyEpochs };
363
+ });
364
+ };
365
+ const sidecarLayoutJson = sidecarLayout
366
+ ? JSON.stringify(sidecarLayout)
367
+ : '';
170
368
  const normalizedKeyboardShouldPersistTaps =
171
369
  keyboardShouldPersistTaps === true
172
370
  ? 'always'
@@ -181,6 +379,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
181
379
  onReorder,
182
380
  onEndReached,
183
381
  onVisibleRangeChanged,
382
+ onStructuralTransitionSettled,
184
383
  onScrollPositionThresholdChange,
185
384
  onRefresh,
186
385
  onScrollToIndexFailed,
@@ -192,6 +391,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
192
391
  onReorder,
193
392
  onEndReached,
194
393
  onVisibleRangeChanged,
394
+ onStructuralTransitionSettled,
195
395
  onScrollPositionThresholdChange,
196
396
  onRefresh,
197
397
  onScrollToIndexFailed,
@@ -367,6 +567,26 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
367
567
  prepareSnapshot(nextSnapshot)
368
568
  );
369
569
  if (!accepted) return;
570
+ const transitionId = accepted.structuralTransition?.id;
571
+ const waitsForSlots =
572
+ accepted.disclosure !== undefined &&
573
+ transitionId !== undefined &&
574
+ transitionId !== snapshotRef.current.structuralTransition?.id &&
575
+ ((expandedPresent &&
576
+ slotMeasurements.readyEpochs[4] !== expandedEpoch) ||
577
+ (togglePresent && slotMeasurements.readyEpochs[5] !== toggleEpoch));
578
+ if (waitsForSlots) {
579
+ pendingDisclosureSnapshotRef.current = {
580
+ source: 'imperative',
581
+ input: nextSnapshot,
582
+ owned: accepted,
583
+ expandedEpoch,
584
+ toggleEpoch,
585
+ };
586
+ setPendingDisclosureRevision((value) => value + 1);
587
+ return;
588
+ }
589
+ pendingDisclosureSnapshotRef.current = undefined;
370
590
  const nextSnapshotJson = JSON.stringify(accepted);
371
591
  nativeRef.current?.applySnapshot(nextSnapshotJson);
372
592
  snapshotRef.current = accepted;
@@ -376,16 +596,22 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
376
596
  }
377
597
  },
378
598
  applyPatches(patches) {
379
- const accepted = containNativeListInput(() => {
380
- const normalized = validatePatches(patches);
381
- return {
382
- patches: normalized,
383
- snapshot: applyRowPatches(snapshotRef.current, normalized),
384
- json: serializePatches(normalized),
385
- };
386
- });
599
+ const pending = pendingDisclosureSnapshotRef.current;
600
+ const accepted = containNativeListInput(() =>
601
+ applyOwnedNativePatches(
602
+ pending?.owned ?? snapshotRef.current,
603
+ patches
604
+ )
605
+ );
387
606
  if (!accepted || accepted.patches.length === 0) return;
388
607
  const nextSnapshot = accepted.snapshot;
608
+ if (pending) {
609
+ pendingDisclosureSnapshotRef.current = {
610
+ ...pending,
611
+ owned: nextSnapshot,
612
+ };
613
+ return;
614
+ }
389
615
  const native = nativeRef.current;
390
616
  const dispatch = native
391
617
  ? () => {
@@ -401,19 +627,25 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
401
627
  updateAvatarPrefetchRef.current();
402
628
  },
403
629
  reconcileSelection(selectedKeys) {
404
- nativeRef.current?.reconcileSelection(JSON.stringify(selectedKeys));
405
- const current = snapshotRef.current;
630
+ const capturedKeys = captureNativeListInput(selectedKeys);
631
+ const pending = pendingDisclosureSnapshotRef.current;
632
+ if (!pending)
633
+ nativeRef.current?.reconcileSelection(JSON.stringify(capturedKeys));
634
+ const current = pending?.owned ?? snapshotRef.current;
406
635
  if (
407
636
  current.selection &&
408
- (current.selection.mode !== 'single' || selectedKeys.length <= 1) &&
409
- selectedKeys.every((key) =>
637
+ (current.selection.mode !== 'single' || capturedKeys.length <= 1) &&
638
+ capturedKeys.every((key) =>
410
639
  current.rows.some((row) => row.key === key && isSelectableRow(row))
411
640
  )
412
641
  ) {
413
- snapshotRef.current = {
642
+ const next = {
414
643
  ...current,
415
- selection: { ...current.selection, selectedKeys },
644
+ selection: { ...current.selection, selectedKeys: capturedKeys },
416
645
  };
646
+ if (pending)
647
+ pendingDisclosureSnapshotRef.current = { ...pending, owned: next };
648
+ else snapshotRef.current = next;
417
649
  }
418
650
  },
419
651
  scrollToKey(paramsOrKey, animated, alignment) {
@@ -546,6 +778,11 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
546
778
  updateAvatarPrefetchRef.current();
547
779
  callbacksRef.current.onVisibleRangeChanged?.(payload);
548
780
  }),
781
+ onStructuralTransitionSettled: callback((payloadJson: string) => {
782
+ callbacksRef.current.onStructuralTransitionSettled?.(
783
+ parsePayload<StructuralTransitionSettledEvent>(payloadJson)
784
+ );
785
+ }),
549
786
  }),
550
787
  []
551
788
  );
@@ -553,10 +790,15 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
553
790
  return (
554
791
  <NativeListHost
555
792
  {...viewProps}
793
+ onLayout={(event) => {
794
+ setViewportWidth(event.nativeEvent.layout.width);
795
+ viewProps.onLayout?.(event);
796
+ }}
556
797
  {...nativeCallbacks}
557
798
  fontFamiliesJson={fontFamiliesJson}
558
799
  snapshotJson={snapshotJson}
559
800
  containerSlotHeightsJson={containerSlotHeightsJson}
801
+ sidecarLayoutJson={sidecarLayoutJson}
560
802
  topScrollEdgeEffect={
561
803
  hasTopOverlay ? topScrollEdgeEffect ?? 'none' : 'none'
562
804
  }
@@ -571,22 +813,43 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
571
813
  collapsable={false}
572
814
  style={{
573
815
  position: 'absolute',
574
- left: slotInset,
575
- right: slotInset,
816
+ start: index === 3 ? 0 : slotInset,
817
+ end: index === 3 ? undefined : slotInset + sidecarSpace,
818
+ width: index === 3 ? sidecarLayout?.width : undefined,
576
819
  top: 0,
577
820
  }}
578
821
  onLayout={(event) => {
579
- const height = Math.ceil(event.nativeEvent.layout.height);
580
- setSlotHeights((previous) =>
581
- previous[index] === height
582
- ? previous
583
- : previous.map((value, slot) =>
584
- slot === index ? height : value
585
- )
586
- );
822
+ if (index < 4) {
823
+ recordSlotLayout(
824
+ index,
825
+ Math.ceil(event.nativeEvent.layout.height),
826
+ 0
827
+ );
828
+ }
587
829
  }}
588
830
  >
589
- {content}
831
+ {index >= 4 ? (
832
+ <View
833
+ key={
834
+ index === 4
835
+ ? `expanded-${expandedEpoch}`
836
+ : `toggle-${toggleEpoch}`
837
+ }
838
+ collapsable={false}
839
+ style={disclosureSlotMeasurementStyle}
840
+ onLayout={(event) =>
841
+ recordSlotLayout(
842
+ index,
843
+ Math.ceil(event.nativeEvent.layout.height),
844
+ index === 4 ? expandedEpoch : toggleEpoch
845
+ )
846
+ }
847
+ >
848
+ {content}
849
+ </View>
850
+ ) : (
851
+ content
852
+ )}
590
853
  </View>
591
854
  ))}
592
855
  {hasTopOverlay ? (
@@ -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. */
@@ -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;
@@ -93,6 +93,10 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
93
93
  listHeader,
94
94
  listEmpty,
95
95
  listFooter,
96
+ listExpandedContent: _listExpandedContent,
97
+ listStructureToggle: _listStructureToggle,
98
+ listSidecar,
99
+ sidecarLayout,
96
100
  topOverlay: _topOverlay,
97
101
  topScrollEdgeEffect: _topScrollEdgeEffect,
98
102
  webScrollHost,
@@ -109,6 +113,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
109
113
  onReorder,
110
114
  onEndReached,
111
115
  onVisibleRangeChanged,
116
+ onStructuralTransitionSettled: _onStructuralTransitionSettled,
112
117
  onRefresh,
113
118
  onScrollToIndexFailed,
114
119
  initialScrollIndex,
@@ -156,6 +161,8 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
156
161
  snapshot.layout.contentPadding ??
157
162
  0,
158
163
  }));
164
+ const [viewportWidth, setViewportWidth] = useState(0);
165
+ const [sidecarHeight, setSidecarHeight] = useState(0);
159
166
  const synchronizeSlots = (next: NativeListSnapshot) => {
160
167
  const hasRows = next.rows.length > 0;
161
168
  const padding =
@@ -205,6 +212,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
205
212
  listHeader !== undefined ||
206
213
  listEmpty !== undefined ||
207
214
  listFooter !== undefined;
215
+ useSlotLayoutRef.current ||= listSidecar !== undefined;
208
216
  const useSlotLayout = useSlotLayoutRef.current;
209
217
  const resolvedScrollHost =
210
218
  webScrollHost === undefined
@@ -217,10 +225,27 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
217
225
  webVirtualizationEnabledRef.current = webVirtualizationEnabled;
218
226
  const validatedSnapshot = useMemo(
219
227
  () =>
220
- containNativeListInput(() =>
221
- normalizeWebSnapshot(snapshot, hasEmptySlot, useSlotLayout)
222
- ) ?? acceptedSnapshotRef.current,
223
- [snapshot, hasEmptySlot, useSlotLayout]
228
+ containNativeListInput(() => {
229
+ if ((listSidecar !== undefined) !== (sidecarLayout !== undefined))
230
+ throw new Error(
231
+ 'listSidecar and sidecarLayout must be supplied together'
232
+ );
233
+ if (sidecarLayout) {
234
+ const { width, gap, maxContentWidth } = sidecarLayout;
235
+ if (
236
+ snapshot.layout.kind !== 'linear' ||
237
+ !Number.isFinite(width) ||
238
+ width <= 0 ||
239
+ !Number.isFinite(gap) ||
240
+ gap < 0 ||
241
+ !Number.isFinite(maxContentWidth) ||
242
+ maxContentWidth <= width + gap
243
+ )
244
+ throw new Error('Invalid NativeList sidecar layout');
245
+ }
246
+ return normalizeWebSnapshot(snapshot, hasEmptySlot, useSlotLayout);
247
+ }) ?? acceptedSnapshotRef.current,
248
+ [snapshot, hasEmptySlot, useSlotLayout, listSidecar, sidecarLayout]
224
249
  );
225
250
  const snapshotRef = useRef(validatedSnapshot);
226
251
  const snapshotPropRef = useRef(validatedSnapshot);
@@ -500,7 +525,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
500
525
  const padding = slotState.padding;
501
526
  const content = (
502
527
  <View
503
- ref={setBoundsRef}
528
+ ref={sidecarLayout ? undefined : setBoundsRef}
504
529
  style={{ position: 'relative', flexShrink: 0, minWidth: 0 }}
505
530
  >
506
531
  {listHeader !== undefined ? (
@@ -518,13 +543,55 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
518
543
  </View>
519
544
  ) : null}
520
545
  {listFooter !== undefined ? (
521
- <View style={{ paddingHorizontal: padding }}>{listFooter}</View>
546
+ <View
547
+ testID="native-list-footer-slot"
548
+ style={{ paddingHorizontal: padding }}
549
+ >
550
+ {listFooter}
551
+ </View>
522
552
  ) : null}
523
553
  </View>
524
554
  );
555
+ const bandWidth = sidecarLayout
556
+ ? Math.min(viewportWidth, sidecarLayout.maxContentWidth)
557
+ : 0;
558
+ const sidecarMargin = Math.max(0, (viewportWidth - bandWidth) / 2);
559
+ const leftWidth = Math.max(
560
+ 0,
561
+ bandWidth - (sidecarLayout?.width ?? 0) - (sidecarLayout?.gap ?? 0)
562
+ );
563
+ const scrollContent = sidecarLayout ? (
564
+ <View
565
+ ref={setBoundsRef}
566
+ style={{ position: 'relative', minHeight: sidecarHeight }}
567
+ >
568
+ <View style={{ marginStart: sidecarMargin, width: leftWidth }}>
569
+ {content}
570
+ </View>
571
+ <View
572
+ style={{
573
+ position: 'absolute',
574
+ end: sidecarMargin,
575
+ top: 0,
576
+ width: sidecarLayout.width,
577
+ }}
578
+ onLayout={(event) =>
579
+ setSidecarHeight(event.nativeEvent.layout.height)
580
+ }
581
+ >
582
+ {listSidecar}
583
+ </View>
584
+ </View>
585
+ ) : (
586
+ content
587
+ );
525
588
  return (
526
589
  <View
527
590
  {...viewProps}
591
+ onLayout={(event) => {
592
+ setViewportWidth(event.nativeEvent.layout.width);
593
+ viewProps.onLayout?.(event);
594
+ }}
528
595
  style={[viewProps.style, { position: 'relative', minHeight: 0 }]}
529
596
  >
530
597
  {webScrollHost === undefined ? (
@@ -532,10 +599,10 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
532
599
  ref={setScrollHostRef}
533
600
  style={{ position: 'absolute', inset: 0, overflow: 'scroll' }}
534
601
  >
535
- {content}
602
+ {scrollContent}
536
603
  </View>
537
604
  ) : (
538
- content
605
+ scrollContent
539
606
  )}
540
607
  </View>
541
608
  );
package/src/index.ts CHANGED
@@ -14,6 +14,7 @@ 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 {