@onekeyfe/react-native-native-list 6.7.0-5 → 6.7.0-50

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 +312 -375
  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 +1978 -136
  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 +1232 -16
  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 +1093 -59
  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 +2915 -4
  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 +236 -38
  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 +12 -31
  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 +439 -91
  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 +29 -59
  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,17 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  import { useNativeListFontFamiliesJson } from "./fonts.js";
4
- import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
4
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
5
5
  import { OneKeyImageCache, OneKeyImageCachePolicy } from '@onekeyfe/react-native-image';
6
6
  import { NativeAvatarPrefetchModel, NativeAvatarPrefetchQueue } from "./avatarPrefetch.js";
7
7
  import { Platform, View } from 'react-native';
8
8
  import { callback, getHostComponent } from 'react-native-nitro-modules';
9
9
  import { isSelectableRow } from "./selection.js";
10
10
  import { normalizeIndexScroll, normalizeKeyScroll, normalizePositionScroll, resolveLocationIndex, scrollFailure, validateOffset } from "./scrolling.js";
11
- import { applyRowPatches, serializePatches, serializeSnapshot } from "./validation.js";
11
+ import { applyOwnedNativePatches, captureNativeListInput, containNativeListInput, emptyNativeListSnapshot, ownValidatedNativeSnapshot, validateSnapshot } from "./validation.js";
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  const NativeListConfig = require('../nitrogen/generated/shared/json/NativeListConfig.json');
14
14
  const NativeListHost = getHostComponent('NativeList', () => NativeListConfig);
15
+ const clearedStructuralTransitionSettled = {
16
+ f: undefined
17
+ };
18
+ const disclosureSlotMeasurementStyle = {
19
+ alignSelf: 'stretch'
20
+ };
15
21
  export function preloadNativeListAvatarImages(sources) {
16
22
  return OneKeyImageCache.preload(sources.map(source => ({
17
23
  uri: source.uri,
@@ -27,10 +33,14 @@ function parsePayload(payloadJson) {
27
33
  return JSON.parse(payloadJson);
28
34
  }
29
35
  export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
30
- snapshot,
36
+ snapshot: inputSnapshot,
31
37
  listHeader,
32
38
  listFooter,
33
39
  listEmpty,
40
+ listSidecar,
41
+ listExpandedContent,
42
+ listStructureToggle,
43
+ sidecarLayout,
34
44
  topOverlay,
35
45
  topScrollEdgeEffect,
36
46
  scrollPositionThresholds,
@@ -46,6 +56,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
46
56
  onReorder,
47
57
  onEndReached,
48
58
  onVisibleRangeChanged,
59
+ onStructuralTransitionSettled,
49
60
  onScrollPositionThresholdChange,
50
61
  onRefresh,
51
62
  onScrollToIndexFailed,
@@ -55,16 +66,133 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
55
66
  initialScrollViewOffset,
56
67
  ...viewProps
57
68
  }, forwardedRef) {
69
+ const snapshotRef = useRef(emptyNativeListSnapshot());
70
+ const needsNativeSnapshotRef = useRef(false);
71
+ const renderedSnapshotRef = useRef(undefined);
72
+ const initializedSnapshot = useRef(false);
73
+ const pendingDisclosureSnapshotRef = useRef(undefined);
74
+ const previousPropInputRef = useRef(inputSnapshot);
75
+ const [pendingDisclosureRevision, setPendingDisclosureRevision] = useState(0);
76
+ const disclosureSlotMounts = useRef({
77
+ expandedPresent: false,
78
+ togglePresent: false,
79
+ expandedEpoch: 0,
80
+ toggleEpoch: 0
81
+ });
82
+ const expandedPresent = listExpandedContent != null;
83
+ const togglePresent = listStructureToggle != null;
84
+ if (disclosureSlotMounts.current.expandedPresent !== expandedPresent) {
85
+ disclosureSlotMounts.current.expandedPresent = expandedPresent;
86
+ disclosureSlotMounts.current.expandedEpoch += 1;
87
+ }
88
+ if (disclosureSlotMounts.current.togglePresent !== togglePresent) {
89
+ disclosureSlotMounts.current.togglePresent = togglePresent;
90
+ disclosureSlotMounts.current.toggleEpoch += 1;
91
+ }
92
+ const expandedEpoch = disclosureSlotMounts.current.expandedEpoch;
93
+ const toggleEpoch = disclosureSlotMounts.current.toggleEpoch;
94
+ const iosHeaderPresent = Platform.OS === 'ios' && listHeader != null;
95
+ const [slotMeasurements, setSlotMeasurements] = useState({
96
+ heights: [0, 0, 0, 0, 0, 0],
97
+ readyEpochs: [-1, -1, -1, -1, -1, -1],
98
+ iosHeaderPresent,
99
+ headerEpoch: 0
100
+ });
101
+ if (slotMeasurements.iosHeaderPresent !== iosHeaderPresent) {
102
+ setSlotMeasurements({
103
+ ...slotMeasurements,
104
+ iosHeaderPresent,
105
+ headerEpoch: slotMeasurements.headerEpoch + 1
106
+ });
107
+ }
108
+ const headerEpoch = slotMeasurements.headerEpoch;
109
+ const hasSidecar = listSidecar !== undefined;
110
+ const sidecarWidth = sidecarLayout?.width;
111
+ const sidecarGap = sidecarLayout?.gap;
112
+ const sidecarMaxContentWidth = sidecarLayout?.maxContentWidth;
113
+ const hasContainerSlots = Boolean(listHeader || listEmpty || listFooter || listSidecar || listExpandedContent || listStructureToggle);
114
+ const validateContainerConfiguration = useCallback(accepted => {
115
+ if (hasContainerSlots && accepted.layout.orientation === 'horizontal') throw new Error('NativeList container slots require vertical orientation');
116
+ if (hasSidecar !== (sidecarWidth !== undefined)) throw new Error('listSidecar and sidecarLayout must be supplied together');
117
+ if (sidecarWidth !== undefined) {
118
+ const width = sidecarWidth;
119
+ const gap = sidecarGap ?? NaN;
120
+ const maxContentWidth = sidecarMaxContentWidth ?? NaN;
121
+ if (accepted.layout.kind !== 'linear' || !Number.isFinite(width) || width <= 0 || !Number.isFinite(gap) || gap < 0 || !Number.isFinite(maxContentWidth) || maxContentWidth <= width + gap) throw new Error('Invalid NativeList sidecar layout');
122
+ }
123
+ }, [hasContainerSlots, hasSidecar, sidecarWidth, sidecarGap, sidecarMaxContentWidth]);
124
+ const prepareSnapshot = useCallback(next => {
125
+ const accepted = validateSnapshot(captureNativeListInput(next));
126
+ validateContainerConfiguration(accepted);
127
+ return ownValidatedNativeSnapshot(accepted);
128
+ }, [validateContainerConfiguration]);
129
+ const expandedReadyEpoch = slotMeasurements.readyEpochs[4];
130
+ const toggleReadyEpoch = slotMeasurements.readyEpochs[5];
131
+ const snapshot = useMemo(() => {
132
+ // Imperative pending snapshots use this revision to retry the readiness gate.
133
+ // eslint-disable-next-line no-void -- Reading this revision invalidates the readiness memo.
134
+ void pendingDisclosureRevision;
135
+ const propReplaced = previousPropInputRef.current !== inputSnapshot;
136
+ previousPropInputRef.current = inputSnapshot;
137
+ const pending = pendingDisclosureSnapshotRef.current;
138
+ const retained = pending && !propReplaced && (pending.source === 'imperative' || pending.input === inputSnapshot) && pending.expandedEpoch === expandedEpoch && pending.toggleEpoch === toggleEpoch ? pending : undefined;
139
+ const candidate = retained?.owned ?? (!propReplaced && initializedSnapshot.current ? renderedSnapshotRef.current ?? snapshotRef.current : containNativeListInput(() => prepareSnapshot(inputSnapshot)) ?? snapshotRef.current);
140
+ const acceptedCandidate = !propReplaced && initializedSnapshot.current ? containNativeListInput(() => {
141
+ validateContainerConfiguration(candidate);
142
+ return candidate;
143
+ }) : candidate;
144
+ if (!acceptedCandidate) {
145
+ pendingDisclosureSnapshotRef.current = undefined;
146
+ return renderedSnapshotRef.current ?? snapshotRef.current;
147
+ }
148
+ const transitionId = acceptedCandidate.structuralTransition?.id;
149
+ const newDisclosureCommand = initializedSnapshot.current && acceptedCandidate.disclosure !== undefined && transitionId !== undefined && transitionId !== snapshotRef.current.structuralTransition?.id;
150
+ if (newDisclosureCommand && (expandedPresent && expandedReadyEpoch !== expandedEpoch || togglePresent && toggleReadyEpoch !== toggleEpoch)) {
151
+ pendingDisclosureSnapshotRef.current = retained ?? {
152
+ source: 'prop',
153
+ input: inputSnapshot,
154
+ owned: acceptedCandidate,
155
+ expandedEpoch,
156
+ toggleEpoch
157
+ };
158
+ return snapshotRef.current;
159
+ }
160
+ pendingDisclosureSnapshotRef.current = undefined;
161
+ return acceptedCandidate;
162
+ }, [inputSnapshot, prepareSnapshot, validateContainerConfiguration, expandedPresent, togglePresent, expandedEpoch, toggleEpoch, expandedReadyEpoch, toggleReadyEpoch, pendingDisclosureRevision]);
163
+ renderedSnapshotRef.current = snapshot;
58
164
  const fontFamiliesJson = useNativeListFontFamiliesJson();
59
- const [slotHeights, setSlotHeights] = useState([0, 0, 0]);
165
+ const slotHeights = slotMeasurements.heights;
166
+ const [viewportWidth, setViewportWidth] = useState(0);
60
167
  const [topOverlayHeight, setTopOverlayHeight] = useState(0);
61
168
  const hasTopOverlay = Platform?.OS === 'ios' && parseInt(String(Platform.Version), 10) >= 26 && (topScrollEdgeEffect === 'hard' || topScrollEdgeEffect === 'soft') && topOverlay != null;
62
- const containerSlotHeightsJson = JSON.stringify(slotHeights);
63
- const slotInset = snapshot.layout.contentPaddingHorizontal ?? snapshot.layout.contentPadding ?? 0;
64
- if (snapshot.layout.orientation === 'horizontal' && (listHeader || listEmpty || listFooter)) {
65
- throw new Error('NativeList container slots require vertical orientation');
66
- }
67
- const slotContents = [listHeader, listEmpty, listFooter];
169
+ const containerSlotHeightsJson = JSON.stringify(Platform.OS === 'ios' && (!iosHeaderPresent || slotMeasurements.readyEpochs[0] !== headerEpoch) ? [iosHeaderPresent ? null : 0, ...slotHeights.slice(1)] : slotHeights);
170
+ const defaultSlotInset = snapshot.layout.contentPaddingHorizontal ?? snapshot.layout.contentPadding ?? 0;
171
+ const bandWidth = sidecarLayout ? Math.min(viewportWidth, sidecarLayout.maxContentWidth) : 0;
172
+ const slotInset = sidecarLayout ? Math.max(0, (viewportWidth - bandWidth) / 2) + defaultSlotInset : defaultSlotInset;
173
+ const sidecarSpace = sidecarLayout ? sidecarLayout.width + sidecarLayout.gap : 0;
174
+ const slotContents = [listHeader, listEmpty, listFooter, listSidecar, listExpandedContent, listStructureToggle];
175
+ const recordSlotLayout = (index, height, epoch) => {
176
+ if (index === 4 && epoch !== disclosureSlotMounts.current.expandedEpoch || index === 5 && epoch !== disclosureSlotMounts.current.toggleEpoch) {
177
+ return;
178
+ }
179
+ setSlotMeasurements(previous => {
180
+ if (index === 0 && epoch !== previous.headerEpoch) return previous;
181
+ if (previous.heights[index] === height && previous.readyEpochs[index] === epoch) {
182
+ return previous;
183
+ }
184
+ const heights = [...previous.heights];
185
+ const readyEpochs = [...previous.readyEpochs];
186
+ heights[index] = height;
187
+ readyEpochs[index] = epoch;
188
+ return {
189
+ ...previous,
190
+ heights,
191
+ readyEpochs
192
+ };
193
+ });
194
+ };
195
+ const sidecarLayoutJson = sidecarLayout ? JSON.stringify(sidecarLayout) : '';
68
196
  const normalizedKeyboardShouldPersistTaps = keyboardShouldPersistTaps === true ? 'always' : keyboardShouldPersistTaps === false ? 'never' : keyboardShouldPersistTaps;
69
197
  const nativeRef = useRef(null);
70
198
  const callbacksRef = useRef({
@@ -74,6 +202,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
74
202
  onReorder,
75
203
  onEndReached,
76
204
  onVisibleRangeChanged,
205
+ onStructuralTransitionSettled,
77
206
  onScrollPositionThresholdChange,
78
207
  onRefresh,
79
208
  onScrollToIndexFailed
@@ -85,11 +214,12 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
85
214
  onReorder,
86
215
  onEndReached,
87
216
  onVisibleRangeChanged,
217
+ onStructuralTransitionSettled,
88
218
  onScrollPositionThresholdChange,
89
219
  onRefresh,
90
220
  onScrollToIndexFailed
91
221
  };
92
- const scrollPositionThresholdsJson = useMemo(() => {
222
+ const scrollPositionThresholdsJson = useMemo(() => containNativeListInput(() => {
93
223
  if (!scrollPositionThresholds || scrollPositionThresholds.enabled === false) return '';
94
224
  const {
95
225
  start,
@@ -102,15 +232,18 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
102
232
  start,
103
233
  end
104
234
  });
105
- }, [scrollPositionThresholds]);
106
- const snapshotJson = useMemo(() => serializeSnapshot(snapshot), [snapshot]);
107
- const snapshotRef = useRef(snapshot);
235
+ }) ?? '', [scrollPositionThresholds]);
236
+ const snapshotJson = useMemo(() => JSON.stringify(snapshot), [snapshot]);
108
237
  const previousSnapshotJsonRef = useRef(snapshotJson);
109
238
  const snapshotChanged = previousSnapshotJsonRef.current !== snapshotJson;
110
239
  if (snapshotChanged) {
111
240
  snapshotRef.current = snapshot;
112
241
  previousSnapshotJsonRef.current = snapshotJson;
113
242
  }
243
+ if (!initializedSnapshot.current) {
244
+ snapshotRef.current = snapshot;
245
+ initializedSnapshot.current = true;
246
+ }
114
247
  // OneKey patch: range events already cross the bridge only when row indices
115
248
  // change. Prefetch is optional work; scrolling and visible loads stay native.
116
249
  const avatarQueueRef = useRef(null);
@@ -142,7 +275,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
142
275
  useEffect(() => {
143
276
  updateAvatarPrefetchRef.current();
144
277
  }, [snapshot]);
145
- const initialScrollRef = useRef(initialScrollIndex === undefined && initialScrollKey === undefined ? undefined : initialScrollIndex !== undefined ? normalizeIndexScroll({
278
+ const initialScrollRef = useRef(containNativeListInput(() => initialScrollIndex === undefined && initialScrollKey === undefined ? undefined : initialScrollIndex !== undefined ? normalizeIndexScroll({
146
279
  index: initialScrollIndex,
147
280
  animated: false,
148
281
  viewPosition: initialScrollViewPosition,
@@ -154,7 +287,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
154
287
  viewPosition: initialScrollViewPosition,
155
288
  viewOffset: initialScrollViewOffset
156
289
  }, 'start')
157
- });
290
+ }));
158
291
  const didApplyInitialScroll = useRef(false);
159
292
  const emitIndexFailure = (index, reason) => {
160
293
  callbacksRef.current.onScrollToIndexFailed?.(scrollFailure(snapshotRef.current.rows, index, reason));
@@ -180,39 +313,79 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
180
313
  applyInitialScrollCallbackRef.current = applyInitialScroll;
181
314
  useImperativeHandle(forwardedRef, () => ({
182
315
  applySnapshot(nextSnapshot) {
183
- const nextSnapshotJson = serializeSnapshot(nextSnapshot);
184
- nativeRef.current?.applySnapshot(nextSnapshotJson);
185
- snapshotRef.current = nextSnapshot;
186
- if (nativeRef.current && avatarLifecycle.current !== 'unmounted') {
187
- avatarModelRef.current?.replaceSnapshot(nextSnapshot.rows);
316
+ const accepted = containNativeListInput(() => prepareSnapshot(nextSnapshot));
317
+ if (!accepted) return;
318
+ const transitionId = accepted.structuralTransition?.id;
319
+ const waitsForSlots = accepted.disclosure !== undefined && transitionId !== undefined && transitionId !== snapshotRef.current.structuralTransition?.id && (expandedPresent && slotMeasurements.readyEpochs[4] !== expandedEpoch || togglePresent && slotMeasurements.readyEpochs[5] !== toggleEpoch);
320
+ if (waitsForSlots) {
321
+ pendingDisclosureSnapshotRef.current = {
322
+ source: 'imperative',
323
+ input: nextSnapshot,
324
+ owned: accepted,
325
+ expandedEpoch,
326
+ toggleEpoch
327
+ };
328
+ setPendingDisclosureRevision(value => value + 1);
329
+ return;
330
+ }
331
+ pendingDisclosureSnapshotRef.current = undefined;
332
+ const native = nativeRef.current;
333
+ if (native) native.applySnapshot(JSON.stringify(accepted));
334
+ snapshotRef.current = accepted;
335
+ needsNativeSnapshotRef.current = !native;
336
+ if (native && avatarLifecycle.current !== 'unmounted') {
337
+ avatarModelRef.current?.replaceSnapshot(accepted.rows);
188
338
  updateAvatarPrefetchRef.current();
189
339
  }
190
340
  },
191
341
  applyPatches(patches) {
192
- if (patches.length === 0) return;
193
- const nextSnapshot = applyRowPatches(snapshotRef.current, patches);
342
+ const pending = pendingDisclosureSnapshotRef.current;
343
+ const accepted = containNativeListInput(() => applyOwnedNativePatches(pending?.owned ?? snapshotRef.current, patches));
344
+ if (!accepted || accepted.patches.length === 0) return;
345
+ const nextSnapshot = accepted.snapshot;
346
+ if (pending) {
347
+ pendingDisclosureSnapshotRef.current = {
348
+ ...pending,
349
+ owned: nextSnapshot
350
+ };
351
+ return;
352
+ }
194
353
  const native = nativeRef.current;
195
- const dispatch = native ? () => {
196
- native.applyPatches(serializePatches(patches));
354
+ if (!native) {
197
355
  snapshotRef.current = nextSnapshot;
198
- } : undefined;
356
+ needsNativeSnapshotRef.current = true;
357
+ return;
358
+ }
359
+ const dispatch = () => {
360
+ native.applyPatches(accepted.json);
361
+ snapshotRef.current = nextSnapshot;
362
+ };
199
363
  if (avatarLifecycle.current === 'unmounted') {
200
364
  dispatch?.();
201
365
  return;
202
366
  }
203
- if (avatarModelRef.current?.applyPatches(patches, dispatch)) updateAvatarPrefetchRef.current();
367
+ if (avatarModelRef.current?.applyPatches(accepted.patches, dispatch)) updateAvatarPrefetchRef.current();
204
368
  },
205
369
  reconcileSelection(selectedKeys) {
206
- nativeRef.current?.reconcileSelection(JSON.stringify(selectedKeys));
207
- const current = snapshotRef.current;
208
- if (current.selection && (current.selection.mode !== 'single' || selectedKeys.length <= 1) && selectedKeys.every(key => current.rows.some(row => row.key === key && isSelectableRow(row)))) {
209
- snapshotRef.current = {
370
+ const capturedKeys = captureNativeListInput(selectedKeys);
371
+ const pending = pendingDisclosureSnapshotRef.current;
372
+ if (!pending) nativeRef.current?.reconcileSelection(JSON.stringify(capturedKeys));
373
+ const current = pending?.owned ?? snapshotRef.current;
374
+ if (current.selection && (current.selection.mode !== 'single' || capturedKeys.length <= 1) && capturedKeys.every(key => current.rows.some(row => row.key === key && isSelectableRow(row)))) {
375
+ const next = {
210
376
  ...current,
211
377
  selection: {
212
378
  ...current.selection,
213
- selectedKeys
379
+ selectedKeys: capturedKeys
214
380
  }
215
381
  };
382
+ if (pending) pendingDisclosureSnapshotRef.current = {
383
+ ...pending,
384
+ owned: next
385
+ };else {
386
+ snapshotRef.current = next;
387
+ if (!nativeRef.current) needsNativeSnapshotRef.current = true;
388
+ }
216
389
  }
217
390
  },
218
391
  scrollToKey(paramsOrKey, animated, alignment) {
@@ -267,7 +440,16 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
267
440
  }));
268
441
  const nativeCallbacks = useMemo(() => ({
269
442
  hybridRef: callback(ref => {
443
+ const previous = nativeRef.current;
270
444
  nativeRef.current = ref;
445
+ if (needsNativeSnapshotRef.current || previous && previous !== ref) {
446
+ // The parent can publish values before Fabric delivers the host.
447
+ const latest = snapshotRef.current;
448
+ ref.applySnapshot(JSON.stringify(latest));
449
+ needsNativeSnapshotRef.current = false;
450
+ avatarModelRef.current?.replaceSnapshot(latest.rows);
451
+ updateAvatarPrefetchRef.current();
452
+ }
271
453
  applyInitialScrollCallbackRef.current();
272
454
  }),
273
455
  onRowAction: callback(payloadJson => {
@@ -319,14 +501,23 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
319
501
  };
320
502
  updateAvatarPrefetchRef.current();
321
503
  callbacksRef.current.onVisibleRangeChanged?.(payload);
504
+ }),
505
+ onStructuralTransitionSettled: callback(payloadJson => {
506
+ callbacksRef.current.onStructuralTransitionSettled?.(parsePayload(payloadJson));
322
507
  })
323
508
  }), []);
324
509
  return /*#__PURE__*/_jsxs(NativeListHost, {
325
510
  ...viewProps,
511
+ onLayout: event => {
512
+ setViewportWidth(event.nativeEvent.layout.width);
513
+ viewProps.onLayout?.(event);
514
+ },
326
515
  ...nativeCallbacks,
516
+ onStructuralTransitionSettled: onStructuralTransitionSettled ? nativeCallbacks.onStructuralTransitionSettled : clearedStructuralTransitionSettled,
327
517
  fontFamiliesJson: fontFamiliesJson,
328
518
  snapshotJson: snapshotJson,
329
519
  containerSlotHeightsJson: containerSlotHeightsJson,
520
+ sidecarLayoutJson: sidecarLayoutJson,
330
521
  topScrollEdgeEffect: hasTopOverlay ? topScrollEdgeEffect ?? 'none' : 'none',
331
522
  topOverlayHeight: hasTopOverlay ? topOverlayHeight : 0,
332
523
  scrollPositionThresholdsJson: scrollPositionThresholdsJson,
@@ -336,16 +527,23 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
336
527
  collapsable: false,
337
528
  style: {
338
529
  position: 'absolute',
339
- left: slotInset,
340
- right: slotInset,
530
+ start: index === 3 ? 0 : slotInset,
531
+ end: index === 3 ? undefined : slotInset + sidecarSpace,
532
+ width: index === 3 ? sidecarLayout?.width : undefined,
341
533
  top: 0
342
534
  },
343
535
  onLayout: event => {
344
- const height = Math.ceil(event.nativeEvent.layout.height);
345
- setSlotHeights(previous => previous[index] === height ? previous : previous.map((value, slot) => slot === index ? height : value));
536
+ if (index < 4) {
537
+ recordSlotLayout(index, Math.ceil(event.nativeEvent.layout.height), index === 0 ? headerEpoch : 0);
538
+ }
346
539
  },
347
- children: content
348
- }, index)), hasTopOverlay ? /*#__PURE__*/_jsx(View, {
540
+ children: index >= 4 ? /*#__PURE__*/_jsx(View, {
541
+ collapsable: false,
542
+ style: disclosureSlotMeasurementStyle,
543
+ onLayout: event => recordSlotLayout(index, Math.ceil(event.nativeEvent.layout.height), index === 4 ? expandedEpoch : toggleEpoch),
544
+ children: content
545
+ }, index === 4 ? `expanded-${expandedEpoch}` : `toggle-${toggleEpoch}`) : content
546
+ }, index === 0 && Platform.OS === 'ios' ? `header-${headerEpoch}` : index)), hasTopOverlay ? /*#__PURE__*/_jsx(View, {
349
547
  collapsable: false,
350
548
  style: {
351
549
  position: 'absolute',