@onekeyfe/react-native-native-list 6.7.0-2 → 6.7.0-21

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 (148) 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 +245 -9
  3. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +35 -7
  4. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
  5. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
  6. package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
  7. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
  8. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
  9. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
  10. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +147 -33
  11. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
  12. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
  13. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
  14. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +51 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
  16. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -0
  17. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
  18. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
  19. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
  20. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
  21. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
  22. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
  23. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
  24. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
  25. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
  26. package/docs/ROW_TEMPLATES.md +70 -11
  27. package/docs/SPEC.md +1235 -20
  28. package/docs/STYLE_SPEC.md +6 -0
  29. package/ios/HybridNativeList.swift +21 -2
  30. package/ios/NativeListAccessoryStack.swift +235 -39
  31. package/ios/NativeListActivityDetailsView.swift +30 -11
  32. package/ios/NativeListActivityRenderer.swift +8 -2
  33. package/ios/NativeListButtonGroupRenderer.swift +89 -0
  34. package/ios/NativeListDataRowRenderer.swift +155 -27
  35. package/ios/NativeListDesignAssets.swift +9 -0
  36. package/ios/NativeListIdentityRenderer.swift +239 -31
  37. package/ios/NativeListLeadingVisual.swift +119 -22
  38. package/ios/NativeListMarketRenderer.swift +113 -18
  39. package/ios/NativeListMessageRenderer.swift +34 -1
  40. package/ios/NativeListModels.swift +42 -2
  41. package/ios/NativeListRendererRegistry.swift +1 -0
  42. package/ios/NativeListResolvedText.swift +2 -1
  43. package/ios/NativeListRowHost.swift +14 -0
  44. package/ios/NativeListSectionHeaderRenderer.swift +88 -0
  45. package/ios/RNCNativeListView.swift +1052 -58
  46. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
  47. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
  48. package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/Contents.json +1 -0
  49. package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/icon.svg +1 -0
  50. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/Contents.json +1 -0
  51. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/icon.svg +1 -0
  52. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
  53. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
  54. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/Contents.json +1 -0
  55. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/icon.svg +1 -0
  56. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
  57. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
  58. package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/Contents.json +1 -0
  59. package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/icon.svg +1 -0
  60. package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/Contents.json +1 -0
  61. package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/icon.svg +1 -0
  62. package/ios/tests/NativeListAccessoryStackTests.swift +89 -0
  63. package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
  64. package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
  65. package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
  66. package/ios/tests/NativeListLifecycleTests.swift +2789 -3
  67. package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
  68. package/lib/module/NativeList.js +223 -36
  69. package/lib/module/NativeList.web.js +260 -33
  70. package/lib/module/index.js +1 -1
  71. package/lib/module/models.js +3 -0
  72. package/lib/module/selection.js +1 -1
  73. package/lib/module/validation.js +1386 -81
  74. package/lib/module/web/NativeListWebEngine.js +914 -80
  75. package/lib/module/web/templates/ActivityRowRenderer.js +487 -7
  76. package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
  77. package/lib/module/web/templates/DataRowRenderer.js +40 -5
  78. package/lib/module/web/templates/IdentityRowRenderer.js +145 -5
  79. package/lib/module/web/templates/MarketRowRenderer.js +8 -3
  80. package/lib/module/web/templates/MarketTableRowRenderer.js +577 -0
  81. package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
  82. package/lib/module/web/templates/MessageRowRenderer.js +18 -2
  83. package/lib/module/web/templates/RowContainerStyle.js +1 -0
  84. package/lib/module/web/templates/RowRendererRegistry.js +8 -3
  85. package/lib/module/web/templates/SectionHeaderRowRenderer.js +70 -3
  86. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  87. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  88. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  89. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  90. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  91. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  92. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  93. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  94. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  95. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  96. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  97. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  98. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  99. package/lib/typescript/src/NativeList.d.ts +3 -3
  100. package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
  101. package/lib/typescript/src/NativeList.types.d.ts +29 -1
  102. package/lib/typescript/src/NativeList.web.d.ts +2 -2
  103. package/lib/typescript/src/index.d.ts +2 -2
  104. package/lib/typescript/src/models.d.ts +196 -17
  105. package/lib/typescript/src/validation.d.ts +20 -0
  106. package/lib/typescript/src/web/NativeListWebEngine.d.ts +58 -1
  107. package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
  108. package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
  109. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
  110. package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
  111. package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
  112. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +10 -4
  113. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
  114. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  115. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  116. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  117. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  118. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  119. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  120. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  121. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  122. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  123. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  124. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  125. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  126. package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  127. package/package.json +3 -3
  128. package/react-native-native-list.podspec +1 -0
  129. package/src/NativeList.nitro.ts +2 -0
  130. package/src/NativeList.tsx +418 -89
  131. package/src/NativeList.types.ts +34 -1
  132. package/src/NativeList.web.tsx +417 -66
  133. package/src/index.ts +2 -0
  134. package/src/models.ts +355 -143
  135. package/src/selection.ts +1 -0
  136. package/src/validation.ts +3315 -166
  137. package/src/web/NativeListWebEngine.ts +1473 -113
  138. package/src/web/templates/ActivityRowRenderer.ts +732 -8
  139. package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
  140. package/src/web/templates/DataRowRenderer.ts +93 -20
  141. package/src/web/templates/IdentityRowRenderer.ts +217 -6
  142. package/src/web/templates/MarketRowRenderer.ts +19 -3
  143. package/src/web/templates/MarketTableRowRenderer.ts +755 -0
  144. package/src/web/templates/MediaTileRowRenderer.ts +313 -5
  145. package/src/web/templates/MessageRowRenderer.ts +23 -7
  146. package/src/web/templates/RowContainerStyle.ts +2 -0
  147. package/src/web/templates/RowRendererRegistry.ts +21 -6
  148. package/src/web/templates/SectionHeaderRowRenderer.ts +89 -5
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  import { useNativeListFontFamiliesJson } from "./fonts.js";
4
- import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
4
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
5
5
  import { View } from 'react-native';
6
6
  import { normalizeIndexScroll, normalizeKeyScroll, normalizePositionScroll, resolveLocationIndex, scrollFailure, validateOffset } from "./scrolling.js";
7
- import { serializePatches, validateSnapshot } from "./validation.js";
7
+ import { applyRowPatches, containNativeListInput, emptyNativeListSnapshot, validateSnapshot } from "./validation.js";
8
8
  import { NativeListWebEngine } from "./web/NativeListWebEngine.js";
9
9
  import { acquireNativeListAvatar, canonicalNativeListAvatarUri } from "./web/NativeListWebAvatarCache.js";
10
- import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ const collapsedExpandedContentStyle = {
12
+ display: 'none'
13
+ };
11
14
  export function preloadNativeListAvatarImages(sources) {
12
15
  if (typeof document === 'undefined') return Promise.resolve(false);
13
16
  const uris = [...new Set(sources.map(source => canonicalNativeListAvatarUri(source.uri)).filter(uri => uri !== undefined))];
@@ -22,12 +25,18 @@ export function preloadNativeListAvatarImages(sources) {
22
25
  }))).then(results => results.every(Boolean));
23
26
  }
24
27
  export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
25
- snapshot,
26
- listHeader: _listHeader,
27
- listEmpty: _listEmpty,
28
- listFooter: _listFooter,
28
+ snapshot: inputSnapshot,
29
+ listHeader,
30
+ listEmpty,
31
+ listFooter,
32
+ listExpandedContent,
33
+ listStructureToggle,
34
+ listSidecar,
35
+ sidecarLayout,
29
36
  topOverlay: _topOverlay,
30
37
  topScrollEdgeEffect: _topScrollEdgeEffect,
38
+ webScrollHost,
39
+ webStickyInset: inputStickyInset = 0,
31
40
  scrollPositionThresholds: _scrollPositionThresholds,
32
41
  onScrollPositionThresholdChange: _onScrollPositionThresholdChange,
33
42
  webVirtualizationEnabled = true,
@@ -40,6 +49,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
40
49
  onReorder,
41
50
  onEndReached,
42
51
  onVisibleRangeChanged,
52
+ onStructuralTransitionSettled: _onStructuralTransitionSettled,
43
53
  onRefresh,
44
54
  onScrollToIndexFailed,
45
55
  initialScrollIndex,
@@ -48,23 +58,114 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
48
58
  initialScrollViewOffset,
49
59
  ...viewProps
50
60
  }, forwardedRef) {
61
+ const acceptedSnapshotRef = useRef(emptyNativeListSnapshot());
62
+ const initializedSnapshot = useRef(false);
63
+ const webStickyInset = useMemo(() => containNativeListInput(() => {
64
+ if (!Number.isFinite(inputStickyInset) || inputStickyInset < 0) throw new Error('webStickyInset must be finite and non-negative');
65
+ return inputStickyInset;
66
+ }) ?? 0, [inputStickyInset]);
67
+ // Freshness is limited to this component invocation; later renders revalidate.
68
+ let freshlyValidatedSnapshot;
69
+ const preparedSnapshot = useMemo(() => {
70
+ const prepared = containNativeListInput(() => validateSnapshot(inputSnapshot));
71
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- The value is intentionally render-local.
72
+ freshlyValidatedSnapshot = prepared;
73
+ return prepared;
74
+ }, [inputSnapshot]);
75
+ const snapshot = preparedSnapshot ?? acceptedSnapshotRef.current;
51
76
  const fontFamiliesJson = useNativeListFontFamiliesJson();
52
77
  const fontFamiliesJsonRef = useRef(fontFamiliesJson);
53
78
  fontFamiliesJsonRef.current = fontFamiliesJson;
79
+ const hasEmptySlot = listEmpty !== undefined;
80
+ const hasEmptySlotRef = useRef(hasEmptySlot);
81
+ hasEmptySlotRef.current = hasEmptySlot;
82
+ const [viewportWidth, setViewportWidth] = useState(0);
83
+ const [sidecarHeight, setSidecarHeight] = useState(0);
84
+ const normalizeWebSnapshot = (next, hasReactEmpty = hasEmptySlotRef.current, hasSlotLayout = useSlotLayoutRef.current, validatedInThisRender = false) => {
85
+ if (hasSlotLayout && next.layout.orientation === 'horizontal') throw new Error('Web parent scrolling and container slots support vertical lists only');
86
+ const emptySlot = hasReactEmpty && next.rows.length === 0;
87
+ const normalized = emptySlot && next.emptyState !== undefined ? {
88
+ ...next,
89
+ emptyState: undefined
90
+ } : next;
91
+ const validated = validatedInThisRender ? normalized : validateSnapshot(normalized);
92
+ // Preserve an already normalized fallback's identity across rerenders.
93
+ return emptySlot && validated.layout.contentPaddingBottom !== 0 ? {
94
+ ...validated,
95
+ layout: {
96
+ ...validated.layout,
97
+ contentPaddingBottom: 0
98
+ }
99
+ } : validated;
100
+ };
54
101
  const [host, setHost] = useState(null);
102
+ const [contentBounds, setContentBounds] = useState(null);
103
+ const [ownedScrollHost, setOwnedScrollHost] = useState(null);
104
+ const useSlotLayoutRef = useRef(false);
105
+ useSlotLayoutRef.current ||= webScrollHost !== undefined || listHeader !== undefined || listEmpty !== undefined || listFooter !== undefined;
106
+ useSlotLayoutRef.current ||= listSidecar !== undefined;
107
+ useSlotLayoutRef.current ||= listExpandedContent !== undefined || listStructureToggle !== undefined;
108
+ const useSlotLayout = useSlotLayoutRef.current;
109
+ const resolvedScrollHost = webScrollHost === undefined ? useSlotLayout ? ownedScrollHost : undefined : webScrollHost;
55
110
  const engineRef = useRef(undefined);
56
111
  const webVirtualizationEnabledRef = useRef(webVirtualizationEnabled);
57
112
  webVirtualizationEnabledRef.current = webVirtualizationEnabled;
58
- const validatedSnapshot = useMemo(() => validateSnapshot(snapshot), [snapshot]);
113
+ const validatedSnapshot = useMemo(() => containNativeListInput(() => {
114
+ if (listSidecar !== undefined !== (sidecarLayout !== undefined)) throw new Error('listSidecar and sidecarLayout must be supplied together');
115
+ if (sidecarLayout) {
116
+ const {
117
+ width,
118
+ gap,
119
+ maxContentWidth
120
+ } = sidecarLayout;
121
+ if (snapshot.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
+ return normalizeWebSnapshot(snapshot, hasEmptySlot, useSlotLayout, preparedSnapshot !== undefined && preparedSnapshot === freshlyValidatedSnapshot);
124
+ }) ?? acceptedSnapshotRef.current,
125
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- Preserve the existing memo dependencies; freshness is render-local.
126
+ [snapshot, hasEmptySlot, useSlotLayout, listSidecar, sidecarLayout]);
127
+ const [slotState, setSlotState] = useState(() => ({
128
+ hasRows: validatedSnapshot.rows.length > 0,
129
+ emptyBottomPadding: !validatedSnapshot.rows.length && hasEmptySlot ? validatedSnapshot.layout.contentPaddingBottom ?? validatedSnapshot.layout.contentPadding ?? 0 : 0,
130
+ padding: validatedSnapshot.layout.contentPaddingHorizontal ?? validatedSnapshot.layout.contentPadding ?? 0,
131
+ disclosurePresent: validatedSnapshot.disclosure !== undefined,
132
+ disclosureExpanded: validatedSnapshot.disclosure?.expanded === true,
133
+ hasExpandedContent: validatedSnapshot.disclosure?.expanded === true,
134
+ expandedTrailingInset: validatedSnapshot.disclosure?.expandedTrailingInset ?? 0
135
+ }));
136
+ const synchronizeSlots = next => {
137
+ const hasRows = next.rows.length > 0;
138
+ const padding = next.layout.contentPaddingHorizontal ?? next.layout.contentPadding ?? 0;
139
+ const emptyBottomPadding = !hasRows && hasEmptySlotRef.current ? next.layout.contentPaddingBottom ?? next.layout.contentPadding ?? 0 : 0;
140
+ const disclosurePresent = next.disclosure !== undefined;
141
+ const disclosureExpanded = next.disclosure?.expanded === true;
142
+ const expandedTrailingInset = next.disclosure?.expandedTrailingInset ?? 0;
143
+ setSlotState(previous => {
144
+ const hasExpandedContent = previous.hasExpandedContent || disclosureExpanded;
145
+ return previous.hasRows === hasRows && previous.padding === padding && previous.emptyBottomPadding === emptyBottomPadding && previous.disclosurePresent === disclosurePresent && previous.disclosureExpanded === disclosureExpanded && previous.hasExpandedContent === hasExpandedContent && previous.expandedTrailingInset === expandedTrailingInset ? previous : {
146
+ hasRows,
147
+ padding,
148
+ emptyBottomPadding,
149
+ disclosurePresent,
150
+ disclosureExpanded,
151
+ hasExpandedContent,
152
+ expandedTrailingInset
153
+ };
154
+ });
155
+ };
59
156
  const snapshotRef = useRef(validatedSnapshot);
60
157
  const snapshotPropRef = useRef(validatedSnapshot);
61
158
  // An imperative snapshot survives host mounting until the snapshot prop changes.
62
159
  if (snapshotPropRef.current !== validatedSnapshot) {
63
160
  snapshotPropRef.current = validatedSnapshot;
64
161
  snapshotRef.current = validatedSnapshot;
162
+ acceptedSnapshotRef.current = validatedSnapshot;
163
+ synchronizeSlots(validatedSnapshot);
164
+ }
165
+ if (!initializedSnapshot.current) {
166
+ acceptedSnapshotRef.current = validatedSnapshot;
167
+ initializedSnapshot.current = true;
65
168
  }
66
- // OneKey patch: React refs can be ready before the DOM engine is mounted.
67
- const pendingPatchesRef = useRef(undefined);
68
169
  const appliedSnapshotRef = useRef(undefined);
69
170
  const callbacksRef = useRef({});
70
171
  callbacksRef.current = {
@@ -77,7 +178,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
77
178
  onRefresh,
78
179
  onScrollToIndexFailed
79
180
  };
80
- const initialScrollRef = useRef(initialScrollIndex === undefined && initialScrollKey === undefined ? undefined : initialScrollIndex !== undefined ? normalizeIndexScroll({
181
+ const initialScrollRef = useRef(containNativeListInput(() => initialScrollIndex === undefined && initialScrollKey === undefined ? undefined : initialScrollIndex !== undefined ? normalizeIndexScroll({
81
182
  index: initialScrollIndex,
82
183
  animated: false,
83
184
  viewPosition: initialScrollViewPosition,
@@ -89,26 +190,42 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
89
190
  viewPosition: initialScrollViewPosition,
90
191
  viewOffset: initialScrollViewOffset
91
192
  }, 'start')
92
- });
193
+ }));
93
194
  const didApplyInitialScroll = useRef(false);
195
+ const scrollOptionsRef = useRef({
196
+ stickyInset: webStickyInset,
197
+ ownsRefresh: webScrollHost === undefined
198
+ });
199
+ scrollOptionsRef.current = {
200
+ stickyInset: webStickyInset,
201
+ ownsRefresh: webScrollHost === undefined
202
+ };
94
203
  useEffect(() => {
95
- if (!host) return;
96
- const engine = new NativeListWebEngine(host, snapshotRef.current, callbacksRef.current, webVirtualizationEnabledRef.current, webSectionIndexContainerRef?.current, fontFamiliesJsonRef.current);
204
+ if (!host || resolvedScrollHost === null || useSlotLayout && !contentBounds) return;
205
+ const engine = containNativeListInput(() => new NativeListWebEngine(host, snapshotRef.current, callbacksRef.current, webVirtualizationEnabledRef.current, webSectionIndexContainerRef?.current, fontFamiliesJsonRef.current, {
206
+ scrollHost: resolvedScrollHost,
207
+ contentBounds: contentBounds ?? undefined,
208
+ ...scrollOptionsRef.current
209
+ }));
210
+ if (!engine) return;
211
+ host.style.height = '';
97
212
  engineRef.current = engine;
98
213
  appliedSnapshotRef.current = snapshotRef.current;
99
- const pending = pendingPatchesRef.current;
100
- pendingPatchesRef.current = undefined;
101
- if (pending?.snapshot === snapshotRef.current) pending.batches.forEach(patches => engine.applyPatches(patches));
102
214
  const initial = initialScrollRef.current;
103
215
  if (initial && !didApplyInitialScroll.current) {
104
216
  didApplyInitialScroll.current = true;
105
217
  if (initial.index !== undefined) engine.scrollToIndex(initial.index, initial.scroll);else if (initial.key !== undefined) engine.scrollToKey(initial.key, initial.scroll);
106
218
  }
107
219
  return () => {
220
+ // Keep the paused tab in normal flow until its engine is restored.
221
+ host.style.height = `${engine.currentContentHeight()}px`;
108
222
  engine.destroy();
109
223
  if (engineRef.current === engine) engineRef.current = undefined;
110
224
  };
111
- }, [host, webSectionIndexContainerRef]);
225
+ }, [host, webSectionIndexContainerRef, resolvedScrollHost, contentBounds, useSlotLayout]);
226
+ useEffect(() => {
227
+ engineRef.current?.setStickyInset(webStickyInset);
228
+ }, [webStickyInset]);
112
229
  useEffect(() => {
113
230
  engineRef.current?.setFontFamiliesJson(fontFamiliesJson);
114
231
  }, [fontFamiliesJson]);
@@ -118,7 +235,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
118
235
  useEffect(() => {
119
236
  engineRef.current?.updateCallbacks(callbacksRef.current);
120
237
  });
121
- useEffect(() => {
238
+ useLayoutEffect(() => {
122
239
  const engine = engineRef.current;
123
240
  if (!engine || appliedSnapshotRef.current === validatedSnapshot) return;
124
241
  engine.applySnapshot(validatedSnapshot);
@@ -129,24 +246,24 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
129
246
  };
130
247
  useImperativeHandle(forwardedRef, () => ({
131
248
  applySnapshot(nextSnapshot) {
132
- const next = validateSnapshot(nextSnapshot);
133
- pendingPatchesRef.current = undefined;
249
+ const next = containNativeListInput(() => normalizeWebSnapshot(nextSnapshot));
250
+ if (!next) return;
251
+ engineRef.current?.applySnapshot(next);
134
252
  snapshotRef.current = next;
253
+ acceptedSnapshotRef.current = next;
135
254
  appliedSnapshotRef.current = next;
136
- engineRef.current?.applySnapshot(next);
255
+ synchronizeSlots(next);
137
256
  },
138
257
  applyPatches(patches) {
139
- if (patches.length > 0) {
140
- serializePatches(patches);
141
- // engineRef.current?.applyPatches(patches);
142
- if (engineRef.current) engineRef.current.applyPatches(patches);else {
143
- if (pendingPatchesRef.current?.snapshot !== snapshotRef.current) pendingPatchesRef.current = {
144
- snapshot: snapshotRef.current,
145
- batches: []
146
- };
147
- pendingPatchesRef.current.batches.push(patches);
148
- }
258
+ const engine = engineRef.current;
259
+ if (engine) {
260
+ engine.applyPatches(patches);
261
+ snapshotRef.current = engine.currentSnapshot();
262
+ } else {
263
+ const next = containNativeListInput(() => applyRowPatches(snapshotRef.current, patches));
264
+ if (next) snapshotRef.current = next;
149
265
  }
266
+ acceptedSnapshotRef.current = snapshotRef.current;
150
267
  },
151
268
  reconcileSelection(selectedKeys) {
152
269
  engineRef.current?.reconcileSelection(selectedKeys);
@@ -208,9 +325,119 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
208
325
  const setHostRef = useCallback(value => {
209
326
  setHost(value);
210
327
  }, []);
211
- return /*#__PURE__*/_jsx(View, {
328
+ const setBoundsRef = useCallback(value => {
329
+ setContentBounds(value);
330
+ }, []);
331
+ const ownedScrollElementRef = useRef(null);
332
+ const setScrollHostRef = useCallback(value => {
333
+ const element = value;
334
+ if (ownedScrollElementRef.current !== element) ownedScrollElementRef.current?.removeAttribute('data-collapsible-pager-scroll');
335
+ element?.setAttribute('data-collapsible-pager-scroll', 'true');
336
+ ownedScrollElementRef.current = element;
337
+ setOwnedScrollHost(element);
338
+ }, []);
339
+ if (!useSlotLayout) return /*#__PURE__*/_jsx(View, {
212
340
  ...viewProps,
213
341
  ref: setHostRef
214
342
  });
343
+ const padding = slotState.padding;
344
+ const footerBandStyle = {
345
+ paddingHorizontal: padding
346
+ };
347
+ const trailingInsetStyle = {
348
+ height: slotState.disclosureExpanded ? slotState.expandedTrailingInset : 0
349
+ };
350
+ const hasFooterBand = listFooter !== undefined || listExpandedContent !== undefined || listStructureToggle !== undefined;
351
+ const content = /*#__PURE__*/_jsxs(View, {
352
+ ref: sidecarLayout ? undefined : setBoundsRef,
353
+ style: {
354
+ position: 'relative',
355
+ flexShrink: 0,
356
+ minWidth: 0
357
+ },
358
+ children: [listHeader !== undefined ? /*#__PURE__*/_jsx(View, {
359
+ style: {
360
+ paddingHorizontal: padding
361
+ },
362
+ children: listHeader
363
+ }) : null, /*#__PURE__*/_jsx(View, {
364
+ ref: setHostRef,
365
+ style: {
366
+ flexShrink: 0,
367
+ minWidth: 0
368
+ }
369
+ }), !slotState.hasRows && hasEmptySlot ? /*#__PURE__*/_jsx(View, {
370
+ style: {
371
+ paddingHorizontal: padding,
372
+ paddingBottom: slotState.emptyBottomPadding
373
+ },
374
+ children: listEmpty
375
+ }) : null, hasFooterBand ? /*#__PURE__*/_jsxs(View, {
376
+ testID: "native-list-footer-slot",
377
+ style: footerBandStyle,
378
+ children: [listExpandedContent !== undefined && slotState.hasExpandedContent ? /*#__PURE__*/_jsx(View, {
379
+ testID: "native-list-expanded-content-slot",
380
+ "aria-hidden": !slotState.disclosureExpanded,
381
+ pointerEvents: slotState.disclosureExpanded ? 'auto' : 'none',
382
+ style: slotState.disclosureExpanded ? undefined : collapsedExpandedContentStyle,
383
+ children: listExpandedContent
384
+ }) : null, listStructureToggle !== undefined ? /*#__PURE__*/_jsx(View, {
385
+ testID: "native-list-structure-toggle-slot",
386
+ "aria-hidden": !slotState.disclosurePresent,
387
+ pointerEvents: slotState.disclosurePresent ? 'auto' : 'none',
388
+ style: slotState.disclosurePresent ? undefined : collapsedExpandedContentStyle,
389
+ children: listStructureToggle
390
+ }) : null, slotState.expandedTrailingInset > 0 && (listExpandedContent !== undefined || listStructureToggle !== undefined) ? /*#__PURE__*/_jsx(View, {
391
+ testID: "native-list-trailing-inset-slot",
392
+ style: trailingInsetStyle
393
+ }) : null, listFooter]
394
+ }) : null]
395
+ });
396
+ const bandWidth = sidecarLayout ? Math.min(viewportWidth, sidecarLayout.maxContentWidth) : 0;
397
+ const sidecarMargin = Math.max(0, (viewportWidth - bandWidth) / 2);
398
+ const leftWidth = Math.max(0, bandWidth - (sidecarLayout?.width ?? 0) - (sidecarLayout?.gap ?? 0));
399
+ const scrollContent = sidecarLayout ? /*#__PURE__*/_jsxs(View, {
400
+ ref: setBoundsRef,
401
+ style: {
402
+ position: 'relative',
403
+ minHeight: sidecarHeight
404
+ },
405
+ children: [/*#__PURE__*/_jsx(View, {
406
+ style: {
407
+ marginStart: sidecarMargin,
408
+ width: leftWidth
409
+ },
410
+ children: content
411
+ }), /*#__PURE__*/_jsx(View, {
412
+ style: {
413
+ position: 'absolute',
414
+ end: sidecarMargin,
415
+ top: 0,
416
+ width: sidecarLayout.width
417
+ },
418
+ onLayout: event => setSidecarHeight(event.nativeEvent.layout.height),
419
+ children: listSidecar
420
+ })]
421
+ }) : content;
422
+ return /*#__PURE__*/_jsx(View, {
423
+ ...viewProps,
424
+ onLayout: event => {
425
+ setViewportWidth(event.nativeEvent.layout.width);
426
+ viewProps.onLayout?.(event);
427
+ },
428
+ style: [viewProps.style, {
429
+ position: 'relative',
430
+ minHeight: 0
431
+ }],
432
+ children: webScrollHost === undefined ? /*#__PURE__*/_jsx(View, {
433
+ ref: setScrollHostRef,
434
+ style: {
435
+ position: 'absolute',
436
+ inset: 0,
437
+ overflow: 'scroll'
438
+ },
439
+ children: scrollContent
440
+ }) : scrollContent
441
+ });
215
442
  });
216
443
  //# sourceMappingURL=NativeList.web.js.map
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  export { NativeList, preloadNativeListAvatarImages } from './NativeList';
4
- export { applyRowPatches, serializePatches, serializeSnapshot, validatePatches, validateSnapshot } from "./validation.js";
4
+ export { applyRowPatches, planNativeListPatches, serializePatches, serializeSnapshot, validatePatches, validateSnapshot } from "./validation.js";
5
5
  export { checkboxStateForKeys, checkboxStateForSection, isSelectableRow, reduceSelection, selectionStateFromSnapshot } from "./selection.js";
6
6
  export { configureNativeListFonts } from "./fonts.js";
7
7
  export { ScrollEdgeEffect } from "./ScrollEdgeEffect.js";
@@ -24,6 +24,7 @@ export const ROW_BOX_STYLE_KEYS_BY_TYPE = {
24
24
  metricCard: ['horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'image'],
25
25
  sectionHeader: ['horizontalPadding', 'verticalPadding', 'lineGap', 'trailingGap'],
26
26
  action: ['horizontalPadding', 'verticalPadding', 'leadingGap', 'trailingGap', 'image'],
27
+ buttonGroup: [],
27
28
  system: ['horizontalPadding', 'verticalPadding', 'lineGap']
28
29
  };
29
30
 
@@ -53,4 +54,6 @@ export const ROW_BOX_STYLE_KEYS_BY_TYPE = {
53
54
  // type CommonPatchFields = 'revision' | 'disabled' | 'selected' | 'separator';
54
55
  // OneKey patch: balance patches also refresh the existing row's spoken content.
55
56
  // type CommonPatchFields = 'revision' | 'disabled' | 'selected' | 'separator' | 'height' | 'heightRounding' | 'opacity' | 'pressDisabled';
57
+
58
+ /** Null removes optional fields; undefined leaves the existing value unchanged. */
56
59
  //# sourceMappingURL=models.js.map
@@ -4,7 +4,7 @@ export function isSelectableRow(row) {
4
4
  return !row.disabled && (row.type === 'identity' || row.type === 'rail' || row.type === 'activity' || row.type === 'message' || row.type === 'dataRow' || row.type === 'mediaTile' || row.type === 'metricCard');
5
5
  }
6
6
  export function isRowPressEnabled(row) {
7
- return !row.disabled && !row.pressDisabled && (row.type !== 'system' || row.variant === 'retry');
7
+ return !row.disabled && !row.pressDisabled && row.type !== 'buttonGroup' && (row.type !== 'system' || row.variant === 'retry');
8
8
  }
9
9
  function deltaBetween(before, after, source, sourceKey) {
10
10
  return {