@onekeyfe/react-native-native-list 6.7.0-4 → 6.7.0-40

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 (214) hide show
  1. package/README.md +4 -0
  2. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
  3. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +250 -9
  4. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +35 -7
  5. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
  6. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
  7. package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
  8. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
  9. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
  10. package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +47 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
  12. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +152 -33
  13. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
  14. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
  16. package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
  17. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
  18. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
  19. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -287
  20. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
  21. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +7 -0
  22. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
  23. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
  24. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
  25. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
  26. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
  27. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
  28. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
  29. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
  30. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
  31. package/docs/ROW_TEMPLATES.md +74 -13
  32. package/docs/SPEC.md +1206 -15
  33. package/docs/STYLE_SPEC.md +14 -0
  34. package/ios/HybridNativeList.swift +21 -2
  35. package/ios/NativeListAccessoryStack.swift +237 -51
  36. package/ios/NativeListActivityDetailsView.swift +30 -11
  37. package/ios/NativeListActivityRenderer.swift +8 -2
  38. package/ios/NativeListButtonGroupRenderer.swift +89 -0
  39. package/ios/NativeListDataRowRenderer.swift +167 -30
  40. package/ios/NativeListDesignAssets.swift +13 -75
  41. package/ios/NativeListGeneratedIcons.swift +55 -0
  42. package/ios/NativeListIconBinding.swift +171 -0
  43. package/ios/NativeListIdentityRenderer.swift +256 -39
  44. package/ios/NativeListLeadingVisual.swift +127 -28
  45. package/ios/NativeListMarketRenderer.swift +120 -31
  46. package/ios/NativeListMediaPlaceholderView.swift +189 -0
  47. package/ios/NativeListMediaPreviewSlot.swift +122 -61
  48. package/ios/NativeListMediaTileRenderer.swift +15 -11
  49. package/ios/NativeListMessageRenderer.swift +34 -1
  50. package/ios/NativeListMetricCardRenderer.swift +4 -2
  51. package/ios/NativeListModels.swift +42 -2
  52. package/ios/NativeListRendererRegistry.swift +1 -0
  53. package/ios/NativeListResolvedText.swift +2 -1
  54. package/ios/NativeListRowHost.swift +14 -0
  55. package/ios/NativeListSectionHeaderRenderer.swift +100 -4
  56. package/ios/RNCNativeListView.swift +1053 -58
  57. package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
  58. package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
  59. package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
  60. package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
  61. package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
  62. package/ios/tests/NativeListLifecycleTests.swift +2819 -3
  63. package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
  64. package/ios/tests/NativeListMediaVisibilityTests.swift +26 -1
  65. package/ios/tests/NativeListSharedIconTests.swift +236 -0
  66. package/lib/module/NativeList.js +221 -36
  67. package/lib/module/NativeList.web.js +167 -46
  68. package/lib/module/index.js +1 -1
  69. package/lib/module/models.js +3 -0
  70. package/lib/module/selection.js +1 -1
  71. package/lib/module/validation.js +1246 -48
  72. package/lib/module/web/NativeListGeneratedIcons.js +31 -0
  73. package/lib/module/web/NativeListWebEngine.js +513 -275
  74. package/lib/module/web/templates/ActivityRowRenderer.js +120 -87
  75. package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
  76. package/lib/module/web/templates/DataRowRenderer.js +40 -5
  77. package/lib/module/web/templates/IdentityRowRenderer.js +158 -6
  78. package/lib/module/web/templates/MarketTableRowRenderer.js +36 -19
  79. package/lib/module/web/templates/MediaTileRowRenderer.js +84 -25
  80. package/lib/module/web/templates/MessageRowRenderer.js +18 -2
  81. package/lib/module/web/templates/RowContainerStyle.js +1 -0
  82. package/lib/module/web/templates/RowRendererRegistry.js +3 -0
  83. package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
  84. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  85. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  86. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  87. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  88. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  89. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  90. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  91. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  92. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  93. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  94. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  95. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  96. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  97. package/lib/typescript/src/NativeList.d.ts +3 -3
  98. package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
  99. package/lib/typescript/src/NativeList.types.d.ts +20 -2
  100. package/lib/typescript/src/index.d.ts +2 -2
  101. package/lib/typescript/src/models.d.ts +126 -17
  102. package/lib/typescript/src/validation.d.ts +20 -0
  103. package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
  104. package/lib/typescript/src/web/NativeListWebEngine.d.ts +32 -1
  105. package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
  106. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
  107. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
  108. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  109. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  110. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  111. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  112. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  113. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  114. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  115. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  116. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  117. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  118. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  119. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  120. package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  121. package/package.json +16 -10
  122. package/react-native-native-list.podspec +2 -6
  123. package/scripts/generate-icons.mjs +150 -0
  124. package/scripts/generate-icons.test.mjs +288 -0
  125. package/scripts/native-list-icons.json +260 -0
  126. package/src/NativeList.nitro.ts +2 -0
  127. package/src/NativeList.tsx +416 -89
  128. package/src/NativeList.types.ts +24 -2
  129. package/src/NativeList.web.tsx +295 -89
  130. package/src/index.ts +2 -0
  131. package/src/models.ts +263 -144
  132. package/src/selection.ts +1 -0
  133. package/src/validation.ts +3013 -152
  134. package/src/web/NativeListGeneratedIcons.ts +28 -0
  135. package/src/web/NativeListWebEngine.ts +818 -343
  136. package/src/web/templates/ActivityRowRenderer.ts +178 -141
  137. package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
  138. package/src/web/templates/DataRowRenderer.ts +93 -20
  139. package/src/web/templates/IdentityRowRenderer.ts +231 -6
  140. package/src/web/templates/MarketTableRowRenderer.ts +53 -33
  141. package/src/web/templates/MediaTileRowRenderer.ts +90 -28
  142. package/src/web/templates/MessageRowRenderer.ts +23 -7
  143. package/src/web/templates/RowContainerStyle.ts +2 -0
  144. package/src/web/templates/RowRendererRegistry.ts +11 -1
  145. package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
  146. package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
  147. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
  148. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
  149. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
  150. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
  151. package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
  152. package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
  153. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
  154. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
  155. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
  156. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
  157. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
  158. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
  159. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
  160. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
  161. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
  162. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
  163. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
  164. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
  165. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
  166. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
  167. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
  168. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
  169. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
  170. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
  171. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
  172. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
  173. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
  174. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
  175. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
  176. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
  177. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
  178. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
  179. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
  180. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
  181. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
  182. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
  183. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
  184. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
  185. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
  186. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
  187. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
  188. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
  189. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
  190. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
  191. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
  192. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
  193. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
  194. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
  195. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
  196. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
  197. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
  198. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
  199. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
  200. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
  201. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
  202. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
  203. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
  204. package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
  205. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
  206. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
  207. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
  208. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
  209. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
  210. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
  211. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
  212. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
  213. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
  214. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
@@ -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,13 +25,18 @@ import type {
24
25
  import type {
25
26
  ActionAnchorInvalidatedEvent,
26
27
  ImageSource,
28
+ NativeListSnapshot,
27
29
  RowActionEvent,
28
30
  SelectionDeltaEvent,
29
31
  ReorderEvent,
30
32
  EndReachedEvent,
31
33
  VisibleRangeChangedEvent,
32
34
  } from './models';
33
- import type { NativeListProps, NativeListRef } from './NativeList.types';
35
+ import type {
36
+ NativeListProps,
37
+ NativeListRef,
38
+ StructuralTransitionSettledEvent,
39
+ } from './NativeList.types';
34
40
  import { isSelectableRow } from './selection';
35
41
  import {
36
42
  normalizeIndexScroll,
@@ -42,12 +48,19 @@ import {
42
48
  type NormalizedPositionScroll,
43
49
  } from './scrolling';
44
50
  import {
45
- applyRowPatches,
46
- serializePatches,
47
- serializeSnapshot,
51
+ applyOwnedNativePatches,
52
+ captureNativeListInput,
53
+ containNativeListInput,
54
+ emptyNativeListSnapshot,
55
+ ownValidatedNativeSnapshot,
56
+ validateSnapshot,
48
57
  } from './validation';
49
58
 
50
- export type { NativeListProps, NativeListRef } from './NativeList.types';
59
+ export type {
60
+ NativeListProps,
61
+ NativeListRef,
62
+ StructuralTransitionSettledEvent,
63
+ } from './NativeList.types';
51
64
  export type {
52
65
  ActionAnchorState,
53
66
  NativeListKeyboardDismissMode,
@@ -69,6 +82,8 @@ const NativeListHost = getHostComponent<
69
82
  NativeListNativeProps,
70
83
  NativeListMethods
71
84
  >('NativeList', () => NativeListConfig);
85
+ const clearedStructuralTransitionSettled = { f: undefined } as const;
86
+ const disclosureSlotMeasurementStyle = { alignSelf: 'stretch' } as const;
72
87
 
73
88
  export function preloadNativeListAvatarImages(
74
89
  sources: readonly ImageSource[]
@@ -98,10 +113,14 @@ function parsePayload<T>(payloadJson: string): T {
98
113
  export const NativeList = forwardRef<NativeListRef, NativeListProps>(
99
114
  function NativeList(
100
115
  {
101
- snapshot,
116
+ snapshot: inputSnapshot,
102
117
  listHeader,
103
118
  listFooter,
104
119
  listEmpty,
120
+ listSidecar,
121
+ listExpandedContent,
122
+ listStructureToggle,
123
+ sidecarLayout,
105
124
  topOverlay,
106
125
  topScrollEdgeEffect,
107
126
  scrollPositionThresholds,
@@ -117,6 +136,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
117
136
  onReorder,
118
137
  onEndReached,
119
138
  onVisibleRangeChanged,
139
+ onStructuralTransitionSettled,
120
140
  onScrollPositionThresholdChange,
121
141
  onRefresh,
122
142
  onScrollToIndexFailed,
@@ -128,8 +148,173 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
128
148
  },
129
149
  forwardedRef
130
150
  ) {
151
+ const snapshotRef = useRef<NativeListSnapshot>(emptyNativeListSnapshot());
152
+ const needsNativeSnapshotRef = useRef(false);
153
+ const renderedSnapshotRef = useRef<NativeListSnapshot | undefined>(
154
+ undefined
155
+ );
156
+ const initializedSnapshot = useRef(false);
157
+ const pendingDisclosureSnapshotRef = useRef<
158
+ | {
159
+ source: 'prop' | 'imperative';
160
+ input: NativeListSnapshot;
161
+ owned: NativeListSnapshot;
162
+ expandedEpoch: number;
163
+ toggleEpoch: number;
164
+ }
165
+ | undefined
166
+ >(undefined);
167
+ const previousPropInputRef = useRef(inputSnapshot);
168
+ const [pendingDisclosureRevision, setPendingDisclosureRevision] =
169
+ useState(0);
170
+ const disclosureSlotMounts = useRef({
171
+ expandedPresent: false,
172
+ togglePresent: false,
173
+ expandedEpoch: 0,
174
+ toggleEpoch: 0,
175
+ });
176
+ const expandedPresent = listExpandedContent != null;
177
+ const togglePresent = listStructureToggle != null;
178
+ if (disclosureSlotMounts.current.expandedPresent !== expandedPresent) {
179
+ disclosureSlotMounts.current.expandedPresent = expandedPresent;
180
+ disclosureSlotMounts.current.expandedEpoch += 1;
181
+ }
182
+ if (disclosureSlotMounts.current.togglePresent !== togglePresent) {
183
+ disclosureSlotMounts.current.togglePresent = togglePresent;
184
+ disclosureSlotMounts.current.toggleEpoch += 1;
185
+ }
186
+ const expandedEpoch = disclosureSlotMounts.current.expandedEpoch;
187
+ const toggleEpoch = disclosureSlotMounts.current.toggleEpoch;
188
+ const [slotMeasurements, setSlotMeasurements] = useState({
189
+ heights: [0, 0, 0, 0, 0, 0],
190
+ readyEpochs: [-1, -1, -1, -1, -1, -1],
191
+ });
192
+ const hasSidecar = listSidecar !== undefined;
193
+ const sidecarWidth = sidecarLayout?.width;
194
+ const sidecarGap = sidecarLayout?.gap;
195
+ const sidecarMaxContentWidth = sidecarLayout?.maxContentWidth;
196
+ const hasContainerSlots = Boolean(
197
+ listHeader ||
198
+ listEmpty ||
199
+ listFooter ||
200
+ listSidecar ||
201
+ listExpandedContent ||
202
+ listStructureToggle
203
+ );
204
+ const validateContainerConfiguration = useCallback(
205
+ (accepted: NativeListSnapshot) => {
206
+ if (hasContainerSlots && accepted.layout.orientation === 'horizontal')
207
+ throw new Error(
208
+ 'NativeList container slots require vertical orientation'
209
+ );
210
+ if (hasSidecar !== (sidecarWidth !== undefined))
211
+ throw new Error(
212
+ 'listSidecar and sidecarLayout must be supplied together'
213
+ );
214
+ if (sidecarWidth !== undefined) {
215
+ const width = sidecarWidth;
216
+ const gap = sidecarGap ?? NaN;
217
+ const maxContentWidth = sidecarMaxContentWidth ?? NaN;
218
+ if (
219
+ accepted.layout.kind !== 'linear' ||
220
+ !Number.isFinite(width) ||
221
+ width <= 0 ||
222
+ !Number.isFinite(gap) ||
223
+ gap < 0 ||
224
+ !Number.isFinite(maxContentWidth) ||
225
+ maxContentWidth <= width + gap
226
+ )
227
+ throw new Error('Invalid NativeList sidecar layout');
228
+ }
229
+ },
230
+ [
231
+ hasContainerSlots,
232
+ hasSidecar,
233
+ sidecarWidth,
234
+ sidecarGap,
235
+ sidecarMaxContentWidth,
236
+ ]
237
+ );
238
+ const prepareSnapshot = useCallback(
239
+ (next: NativeListSnapshot) => {
240
+ const accepted = validateSnapshot(captureNativeListInput(next));
241
+ validateContainerConfiguration(accepted);
242
+ return ownValidatedNativeSnapshot(accepted);
243
+ },
244
+ [validateContainerConfiguration]
245
+ );
246
+ const expandedReadyEpoch = slotMeasurements.readyEpochs[4];
247
+ const toggleReadyEpoch = slotMeasurements.readyEpochs[5];
248
+ const snapshot = useMemo(() => {
249
+ // Imperative pending snapshots use this revision to retry the readiness gate.
250
+ // eslint-disable-next-line no-void -- Reading this revision invalidates the readiness memo.
251
+ void pendingDisclosureRevision;
252
+ const propReplaced = previousPropInputRef.current !== inputSnapshot;
253
+ previousPropInputRef.current = inputSnapshot;
254
+ const pending = pendingDisclosureSnapshotRef.current;
255
+ const retained =
256
+ pending &&
257
+ !propReplaced &&
258
+ (pending.source === 'imperative' || pending.input === inputSnapshot) &&
259
+ pending.expandedEpoch === expandedEpoch &&
260
+ pending.toggleEpoch === toggleEpoch
261
+ ? pending
262
+ : undefined;
263
+ const candidate =
264
+ retained?.owned ??
265
+ (!propReplaced && initializedSnapshot.current
266
+ ? renderedSnapshotRef.current ?? snapshotRef.current
267
+ : containNativeListInput(() => prepareSnapshot(inputSnapshot)) ??
268
+ snapshotRef.current);
269
+ const acceptedCandidate =
270
+ !propReplaced && initializedSnapshot.current
271
+ ? containNativeListInput(() => {
272
+ validateContainerConfiguration(candidate);
273
+ return candidate;
274
+ })
275
+ : candidate;
276
+ if (!acceptedCandidate) {
277
+ pendingDisclosureSnapshotRef.current = undefined;
278
+ return renderedSnapshotRef.current ?? snapshotRef.current;
279
+ }
280
+ const transitionId = acceptedCandidate.structuralTransition?.id;
281
+ const newDisclosureCommand =
282
+ initializedSnapshot.current &&
283
+ acceptedCandidate.disclosure !== undefined &&
284
+ transitionId !== undefined &&
285
+ transitionId !== snapshotRef.current.structuralTransition?.id;
286
+ if (
287
+ newDisclosureCommand &&
288
+ ((expandedPresent && expandedReadyEpoch !== expandedEpoch) ||
289
+ (togglePresent && toggleReadyEpoch !== toggleEpoch))
290
+ ) {
291
+ pendingDisclosureSnapshotRef.current = retained ?? {
292
+ source: 'prop',
293
+ input: inputSnapshot,
294
+ owned: acceptedCandidate,
295
+ expandedEpoch,
296
+ toggleEpoch,
297
+ };
298
+ return snapshotRef.current;
299
+ }
300
+ pendingDisclosureSnapshotRef.current = undefined;
301
+ return acceptedCandidate;
302
+ }, [
303
+ inputSnapshot,
304
+ prepareSnapshot,
305
+ validateContainerConfiguration,
306
+ expandedPresent,
307
+ togglePresent,
308
+ expandedEpoch,
309
+ toggleEpoch,
310
+ expandedReadyEpoch,
311
+ toggleReadyEpoch,
312
+ pendingDisclosureRevision,
313
+ ]);
314
+ renderedSnapshotRef.current = snapshot;
131
315
  const fontFamiliesJson = useNativeListFontFamiliesJson();
132
- const [slotHeights, setSlotHeights] = useState([0, 0, 0]);
316
+ const slotHeights = slotMeasurements.heights;
317
+ const [viewportWidth, setViewportWidth] = useState(0);
133
318
  const [topOverlayHeight, setTopOverlayHeight] = useState(0);
134
319
  const hasTopOverlay =
135
320
  Platform?.OS === 'ios' &&
@@ -137,19 +322,51 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
137
322
  (topScrollEdgeEffect === 'hard' || topScrollEdgeEffect === 'soft') &&
138
323
  topOverlay != null;
139
324
  const containerSlotHeightsJson = JSON.stringify(slotHeights);
140
- const slotInset =
325
+ const defaultSlotInset =
141
326
  snapshot.layout.contentPaddingHorizontal ??
142
327
  snapshot.layout.contentPadding ??
143
328
  0;
144
- if (
145
- snapshot.layout.orientation === 'horizontal' &&
146
- (listHeader || listEmpty || listFooter)
147
- ) {
148
- throw new Error(
149
- 'NativeList container slots require vertical orientation'
150
- );
151
- }
152
- const slotContents = [listHeader, listEmpty, listFooter];
329
+ const bandWidth = sidecarLayout
330
+ ? Math.min(viewportWidth, sidecarLayout.maxContentWidth)
331
+ : 0;
332
+ const slotInset = sidecarLayout
333
+ ? Math.max(0, (viewportWidth - bandWidth) / 2) + defaultSlotInset
334
+ : defaultSlotInset;
335
+ const sidecarSpace = sidecarLayout
336
+ ? sidecarLayout.width + sidecarLayout.gap
337
+ : 0;
338
+ const slotContents = [
339
+ listHeader,
340
+ listEmpty,
341
+ listFooter,
342
+ listSidecar,
343
+ listExpandedContent,
344
+ listStructureToggle,
345
+ ];
346
+ const recordSlotLayout = (index: number, height: number, epoch: number) => {
347
+ if (
348
+ (index === 4 && epoch !== disclosureSlotMounts.current.expandedEpoch) ||
349
+ (index === 5 && epoch !== disclosureSlotMounts.current.toggleEpoch)
350
+ ) {
351
+ return;
352
+ }
353
+ setSlotMeasurements((previous) => {
354
+ if (
355
+ previous.heights[index] === height &&
356
+ previous.readyEpochs[index] === epoch
357
+ ) {
358
+ return previous;
359
+ }
360
+ const heights = [...previous.heights];
361
+ const readyEpochs = [...previous.readyEpochs];
362
+ heights[index] = height;
363
+ readyEpochs[index] = epoch;
364
+ return { heights, readyEpochs };
365
+ });
366
+ };
367
+ const sidecarLayoutJson = sidecarLayout
368
+ ? JSON.stringify(sidecarLayout)
369
+ : '';
153
370
  const normalizedKeyboardShouldPersistTaps =
154
371
  keyboardShouldPersistTaps === true
155
372
  ? 'always'
@@ -164,6 +381,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
164
381
  onReorder,
165
382
  onEndReached,
166
383
  onVisibleRangeChanged,
384
+ onStructuralTransitionSettled,
167
385
  onScrollPositionThresholdChange,
168
386
  onRefresh,
169
387
  onScrollToIndexFailed,
@@ -175,37 +393,45 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
175
393
  onReorder,
176
394
  onEndReached,
177
395
  onVisibleRangeChanged,
396
+ onStructuralTransitionSettled,
178
397
  onScrollPositionThresholdChange,
179
398
  onRefresh,
180
399
  onScrollToIndexFailed,
181
400
  };
182
- const scrollPositionThresholdsJson = useMemo(() => {
183
- if (
184
- !scrollPositionThresholds ||
185
- scrollPositionThresholds.enabled === false
186
- )
187
- return '';
188
- const { start, end } = scrollPositionThresholds;
189
- if (
190
- !Number.isFinite(start) ||
191
- !Number.isFinite(end) ||
192
- start < 0 ||
193
- end <= start
194
- ) {
195
- throw new Error(
196
- 'scrollPositionThresholds requires 0 <= start < end and finite values'
197
- );
198
- }
199
- return JSON.stringify({ start, end });
200
- }, [scrollPositionThresholds]);
201
- const snapshotJson = useMemo(() => serializeSnapshot(snapshot), [snapshot]);
202
- const snapshotRef = useRef(snapshot);
401
+ const scrollPositionThresholdsJson = useMemo(
402
+ () =>
403
+ containNativeListInput(() => {
404
+ if (
405
+ !scrollPositionThresholds ||
406
+ scrollPositionThresholds.enabled === false
407
+ )
408
+ return '';
409
+ const { start, end } = scrollPositionThresholds;
410
+ if (
411
+ !Number.isFinite(start) ||
412
+ !Number.isFinite(end) ||
413
+ start < 0 ||
414
+ end <= start
415
+ ) {
416
+ throw new Error(
417
+ 'scrollPositionThresholds requires 0 <= start < end and finite values'
418
+ );
419
+ }
420
+ return JSON.stringify({ start, end });
421
+ }) ?? '',
422
+ [scrollPositionThresholds]
423
+ );
424
+ const snapshotJson = useMemo(() => JSON.stringify(snapshot), [snapshot]);
203
425
  const previousSnapshotJsonRef = useRef(snapshotJson);
204
426
  const snapshotChanged = previousSnapshotJsonRef.current !== snapshotJson;
205
427
  if (snapshotChanged) {
206
428
  snapshotRef.current = snapshot;
207
429
  previousSnapshotJsonRef.current = snapshotJson;
208
430
  }
431
+ if (!initializedSnapshot.current) {
432
+ snapshotRef.current = snapshot;
433
+ initializedSnapshot.current = true;
434
+ }
209
435
  // OneKey patch: range events already cross the bridge only when row indices
210
436
  // change. Prefetch is optional work; scrolling and visible loads stay native.
211
437
  const avatarQueueRef = useRef<NativeAvatarPrefetchQueue | null>(null);
@@ -260,26 +486,28 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
260
486
  }>
261
487
  | undefined
262
488
  >(
263
- initialScrollIndex === undefined && initialScrollKey === undefined
264
- ? undefined
265
- : initialScrollIndex !== undefined
266
- ? normalizeIndexScroll({
267
- index: initialScrollIndex,
268
- animated: false,
269
- viewPosition: initialScrollViewPosition,
270
- viewOffset: initialScrollViewOffset,
271
- })
272
- : {
273
- key: initialScrollKey,
274
- scroll: normalizePositionScroll(
275
- {
276
- animated: false,
277
- viewPosition: initialScrollViewPosition,
278
- viewOffset: initialScrollViewOffset,
279
- },
280
- 'start'
281
- ),
282
- }
489
+ containNativeListInput(() =>
490
+ initialScrollIndex === undefined && initialScrollKey === undefined
491
+ ? undefined
492
+ : initialScrollIndex !== undefined
493
+ ? normalizeIndexScroll({
494
+ index: initialScrollIndex,
495
+ animated: false,
496
+ viewPosition: initialScrollViewPosition,
497
+ viewOffset: initialScrollViewOffset,
498
+ })
499
+ : {
500
+ key: initialScrollKey,
501
+ scroll: normalizePositionScroll(
502
+ {
503
+ animated: false,
504
+ viewPosition: initialScrollViewPosition,
505
+ viewOffset: initialScrollViewOffset,
506
+ },
507
+ 'start'
508
+ ),
509
+ }
510
+ )
283
511
  );
284
512
  const didApplyInitialScroll = useRef(false);
285
513
 
@@ -337,45 +565,96 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
337
565
 
338
566
  useImperativeHandle(forwardedRef, () => ({
339
567
  applySnapshot(nextSnapshot) {
340
- const nextSnapshotJson = serializeSnapshot(nextSnapshot);
341
- nativeRef.current?.applySnapshot(nextSnapshotJson);
342
- snapshotRef.current = nextSnapshot;
343
- if (nativeRef.current && avatarLifecycle.current !== 'unmounted') {
344
- avatarModelRef.current?.replaceSnapshot(nextSnapshot.rows);
568
+ const accepted = containNativeListInput(() =>
569
+ prepareSnapshot(nextSnapshot)
570
+ );
571
+ if (!accepted) return;
572
+ const transitionId = accepted.structuralTransition?.id;
573
+ const waitsForSlots =
574
+ accepted.disclosure !== undefined &&
575
+ transitionId !== undefined &&
576
+ transitionId !== snapshotRef.current.structuralTransition?.id &&
577
+ ((expandedPresent &&
578
+ slotMeasurements.readyEpochs[4] !== expandedEpoch) ||
579
+ (togglePresent && slotMeasurements.readyEpochs[5] !== toggleEpoch));
580
+ if (waitsForSlots) {
581
+ pendingDisclosureSnapshotRef.current = {
582
+ source: 'imperative',
583
+ input: nextSnapshot,
584
+ owned: accepted,
585
+ expandedEpoch,
586
+ toggleEpoch,
587
+ };
588
+ setPendingDisclosureRevision((value) => value + 1);
589
+ return;
590
+ }
591
+ pendingDisclosureSnapshotRef.current = undefined;
592
+ const native = nativeRef.current;
593
+ if (native) native.applySnapshot(JSON.stringify(accepted));
594
+ snapshotRef.current = accepted;
595
+ needsNativeSnapshotRef.current = !native;
596
+ if (native && avatarLifecycle.current !== 'unmounted') {
597
+ avatarModelRef.current?.replaceSnapshot(accepted.rows);
345
598
  updateAvatarPrefetchRef.current();
346
599
  }
347
600
  },
348
601
  applyPatches(patches) {
349
- if (patches.length === 0) return;
350
- const nextSnapshot = applyRowPatches(snapshotRef.current, patches);
602
+ const pending = pendingDisclosureSnapshotRef.current;
603
+ const accepted = containNativeListInput(() =>
604
+ applyOwnedNativePatches(
605
+ pending?.owned ?? snapshotRef.current,
606
+ patches
607
+ )
608
+ );
609
+ if (!accepted || accepted.patches.length === 0) return;
610
+ const nextSnapshot = accepted.snapshot;
611
+ if (pending) {
612
+ pendingDisclosureSnapshotRef.current = {
613
+ ...pending,
614
+ owned: nextSnapshot,
615
+ };
616
+ return;
617
+ }
351
618
  const native = nativeRef.current;
352
- const dispatch = native
353
- ? () => {
354
- native.applyPatches(serializePatches(patches));
355
- snapshotRef.current = nextSnapshot;
356
- }
357
- : undefined;
619
+ if (!native) {
620
+ snapshotRef.current = nextSnapshot;
621
+ needsNativeSnapshotRef.current = true;
622
+ return;
623
+ }
624
+ const dispatch = () => {
625
+ native.applyPatches(accepted.json);
626
+ snapshotRef.current = nextSnapshot;
627
+ };
358
628
  if (avatarLifecycle.current === 'unmounted') {
359
629
  dispatch?.();
360
630
  return;
361
631
  }
362
- if (avatarModelRef.current?.applyPatches(patches, dispatch))
632
+ if (avatarModelRef.current?.applyPatches(accepted.patches, dispatch))
363
633
  updateAvatarPrefetchRef.current();
364
634
  },
365
635
  reconcileSelection(selectedKeys) {
366
- nativeRef.current?.reconcileSelection(JSON.stringify(selectedKeys));
367
- const current = snapshotRef.current;
636
+ const capturedKeys = captureNativeListInput(selectedKeys);
637
+ const pending = pendingDisclosureSnapshotRef.current;
638
+ if (!pending)
639
+ nativeRef.current?.reconcileSelection(JSON.stringify(capturedKeys));
640
+ const current = pending?.owned ?? snapshotRef.current;
368
641
  if (
369
642
  current.selection &&
370
- (current.selection.mode !== 'single' || selectedKeys.length <= 1) &&
371
- selectedKeys.every((key) =>
643
+ (current.selection.mode !== 'single' || capturedKeys.length <= 1) &&
644
+ capturedKeys.every((key) =>
372
645
  current.rows.some((row) => row.key === key && isSelectableRow(row))
373
646
  )
374
647
  ) {
375
- snapshotRef.current = {
648
+ const next = {
376
649
  ...current,
377
- selection: { ...current.selection, selectedKeys },
650
+ selection: { ...current.selection, selectedKeys: capturedKeys },
378
651
  };
652
+ if (pending)
653
+ pendingDisclosureSnapshotRef.current = { ...pending, owned: next };
654
+ else {
655
+ snapshotRef.current = next;
656
+ if (!nativeRef.current) needsNativeSnapshotRef.current = true;
657
+ }
379
658
  }
380
659
  },
381
660
  scrollToKey(paramsOrKey, animated, alignment) {
@@ -441,7 +720,19 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
441
720
  const nativeCallbacks = useMemo(
442
721
  () => ({
443
722
  hybridRef: callback((ref: NativeListMethods) => {
723
+ const previous = nativeRef.current;
444
724
  nativeRef.current = ref;
725
+ if (
726
+ needsNativeSnapshotRef.current ||
727
+ (previous && previous !== ref)
728
+ ) {
729
+ // The parent can publish values before Fabric delivers the host.
730
+ const latest = snapshotRef.current;
731
+ ref.applySnapshot(JSON.stringify(latest));
732
+ needsNativeSnapshotRef.current = false;
733
+ avatarModelRef.current?.replaceSnapshot(latest.rows);
734
+ updateAvatarPrefetchRef.current();
735
+ }
445
736
  applyInitialScrollCallbackRef.current();
446
737
  }),
447
738
  onRowAction: callback((payloadJson: string) => {
@@ -508,6 +799,11 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
508
799
  updateAvatarPrefetchRef.current();
509
800
  callbacksRef.current.onVisibleRangeChanged?.(payload);
510
801
  }),
802
+ onStructuralTransitionSettled: callback((payloadJson: string) => {
803
+ callbacksRef.current.onStructuralTransitionSettled?.(
804
+ parsePayload<StructuralTransitionSettledEvent>(payloadJson)
805
+ );
806
+ }),
511
807
  }),
512
808
  []
513
809
  );
@@ -515,10 +811,20 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
515
811
  return (
516
812
  <NativeListHost
517
813
  {...viewProps}
814
+ onLayout={(event) => {
815
+ setViewportWidth(event.nativeEvent.layout.width);
816
+ viewProps.onLayout?.(event);
817
+ }}
518
818
  {...nativeCallbacks}
819
+ onStructuralTransitionSettled={
820
+ onStructuralTransitionSettled
821
+ ? nativeCallbacks.onStructuralTransitionSettled
822
+ : clearedStructuralTransitionSettled
823
+ }
519
824
  fontFamiliesJson={fontFamiliesJson}
520
825
  snapshotJson={snapshotJson}
521
826
  containerSlotHeightsJson={containerSlotHeightsJson}
827
+ sidecarLayoutJson={sidecarLayoutJson}
522
828
  topScrollEdgeEffect={
523
829
  hasTopOverlay ? topScrollEdgeEffect ?? 'none' : 'none'
524
830
  }
@@ -533,22 +839,43 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
533
839
  collapsable={false}
534
840
  style={{
535
841
  position: 'absolute',
536
- left: slotInset,
537
- right: slotInset,
842
+ start: index === 3 ? 0 : slotInset,
843
+ end: index === 3 ? undefined : slotInset + sidecarSpace,
844
+ width: index === 3 ? sidecarLayout?.width : undefined,
538
845
  top: 0,
539
846
  }}
540
847
  onLayout={(event) => {
541
- const height = Math.ceil(event.nativeEvent.layout.height);
542
- setSlotHeights((previous) =>
543
- previous[index] === height
544
- ? previous
545
- : previous.map((value, slot) =>
546
- slot === index ? height : value
547
- )
548
- );
848
+ if (index < 4) {
849
+ recordSlotLayout(
850
+ index,
851
+ Math.ceil(event.nativeEvent.layout.height),
852
+ 0
853
+ );
854
+ }
549
855
  }}
550
856
  >
551
- {content}
857
+ {index >= 4 ? (
858
+ <View
859
+ key={
860
+ index === 4
861
+ ? `expanded-${expandedEpoch}`
862
+ : `toggle-${toggleEpoch}`
863
+ }
864
+ collapsable={false}
865
+ style={disclosureSlotMeasurementStyle}
866
+ onLayout={(event) =>
867
+ recordSlotLayout(
868
+ index,
869
+ Math.ceil(event.nativeEvent.layout.height),
870
+ index === 4 ? expandedEpoch : toggleEpoch
871
+ )
872
+ }
873
+ >
874
+ {content}
875
+ </View>
876
+ ) : (
877
+ content
878
+ )}
552
879
  </View>
553
880
  ))}
554
881
  {hasTopOverlay ? (