@onekeyfe/react-native-native-list 6.7.0-4 → 6.7.0-41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +250 -9
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +35 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +47 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +152 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -287
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +7 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
- package/docs/ROW_TEMPLATES.md +74 -13
- package/docs/SPEC.md +1206 -15
- package/docs/STYLE_SPEC.md +14 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +237 -51
- package/ios/NativeListActivityDetailsView.swift +30 -11
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +167 -30
- package/ios/NativeListDesignAssets.swift +13 -75
- package/ios/NativeListGeneratedIcons.swift +55 -0
- package/ios/NativeListIconBinding.swift +171 -0
- package/ios/NativeListIdentityRenderer.swift +256 -39
- package/ios/NativeListLeadingVisual.swift +127 -28
- package/ios/NativeListMarketRenderer.swift +120 -31
- package/ios/NativeListMediaPlaceholderView.swift +189 -0
- package/ios/NativeListMediaPreviewSlot.swift +122 -61
- package/ios/NativeListMediaTileRenderer.swift +15 -11
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListMetricCardRenderer.swift +4 -2
- package/ios/NativeListModels.swift +42 -2
- package/ios/NativeListRendererRegistry.swift +1 -0
- package/ios/NativeListResolvedText.swift +2 -1
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +100 -4
- package/ios/RNCNativeListView.swift +1053 -58
- package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
- package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
- package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
- package/ios/tests/NativeListLifecycleTests.swift +2819 -3
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/ios/tests/NativeListMediaVisibilityTests.swift +26 -1
- package/ios/tests/NativeListSharedIconTests.swift +236 -0
- package/lib/module/NativeList.js +221 -36
- package/lib/module/NativeList.web.js +167 -46
- package/lib/module/index.js +1 -1
- package/lib/module/models.js +3 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +1246 -48
- package/lib/module/web/NativeListGeneratedIcons.js +31 -0
- package/lib/module/web/NativeListWebEngine.js +513 -275
- package/lib/module/web/templates/ActivityRowRenderer.js +120 -87
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +40 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +158 -6
- package/lib/module/web/templates/MarketTableRowRenderer.js +36 -19
- package/lib/module/web/templates/MediaTileRowRenderer.js +84 -25
- package/lib/module/web/templates/MessageRowRenderer.js +18 -2
- package/lib/module/web/templates/RowContainerStyle.js +1 -0
- package/lib/module/web/templates/RowRendererRegistry.js +3 -0
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/lib/typescript/src/NativeList.d.ts +3 -3
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
- package/lib/typescript/src/NativeList.types.d.ts +20 -2
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +126 -17
- package/lib/typescript/src/validation.d.ts +20 -0
- package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +32 -1
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/package.json +16 -10
- package/react-native-native-list.podspec +2 -6
- package/scripts/generate-icons.mjs +150 -0
- package/scripts/generate-icons.test.mjs +288 -0
- package/scripts/native-list-icons.json +260 -0
- package/src/NativeList.nitro.ts +2 -0
- package/src/NativeList.tsx +416 -89
- package/src/NativeList.types.ts +24 -2
- package/src/NativeList.web.tsx +295 -89
- package/src/index.ts +2 -0
- package/src/models.ts +263 -144
- package/src/selection.ts +1 -0
- package/src/validation.ts +3013 -152
- package/src/web/NativeListGeneratedIcons.ts +28 -0
- package/src/web/NativeListWebEngine.ts +818 -343
- package/src/web/templates/ActivityRowRenderer.ts +178 -141
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +231 -6
- package/src/web/templates/MarketTableRowRenderer.ts +53 -33
- package/src/web/templates/MediaTileRowRenderer.ts +90 -28
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +11 -1
- package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
- package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
|
@@ -4,10 +4,13 @@ import { useNativeListFontFamiliesJson } from "./fonts.js";
|
|
|
4
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 { applyRowPatches, 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
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,14 +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,
|
|
28
|
+
snapshot: inputSnapshot,
|
|
26
29
|
listHeader,
|
|
27
30
|
listEmpty,
|
|
28
31
|
listFooter,
|
|
32
|
+
listExpandedContent,
|
|
33
|
+
listStructureToggle,
|
|
34
|
+
listSidecar,
|
|
35
|
+
sidecarLayout,
|
|
29
36
|
topOverlay: _topOverlay,
|
|
30
37
|
topScrollEdgeEffect: _topScrollEdgeEffect,
|
|
31
38
|
webScrollHost,
|
|
32
|
-
webStickyInset = 0,
|
|
39
|
+
webStickyInset: inputStickyInset = 0,
|
|
33
40
|
scrollPositionThresholds: _scrollPositionThresholds,
|
|
34
41
|
onScrollPositionThresholdChange: _onScrollPositionThresholdChange,
|
|
35
42
|
webVirtualizationEnabled = true,
|
|
@@ -42,6 +49,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
42
49
|
onReorder,
|
|
43
50
|
onEndReached,
|
|
44
51
|
onVisibleRangeChanged,
|
|
52
|
+
onStructuralTransitionSettled: _onStructuralTransitionSettled,
|
|
45
53
|
onRefresh,
|
|
46
54
|
onScrollToIndexFailed,
|
|
47
55
|
initialScrollIndex,
|
|
@@ -50,35 +58,39 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
50
58
|
initialScrollViewOffset,
|
|
51
59
|
...viewProps
|
|
52
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;
|
|
53
76
|
const fontFamiliesJson = useNativeListFontFamiliesJson();
|
|
54
77
|
const fontFamiliesJsonRef = useRef(fontFamiliesJson);
|
|
55
78
|
fontFamiliesJsonRef.current = fontFamiliesJson;
|
|
56
79
|
const hasEmptySlot = listEmpty !== undefined;
|
|
57
80
|
const hasEmptySlotRef = useRef(hasEmptySlot);
|
|
58
81
|
hasEmptySlotRef.current = hasEmptySlot;
|
|
59
|
-
const [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
padding: snapshot.layout.contentPaddingHorizontal ?? snapshot.layout.contentPadding ?? 0
|
|
63
|
-
}));
|
|
64
|
-
const synchronizeSlots = next => {
|
|
65
|
-
const hasRows = next.rows.length > 0;
|
|
66
|
-
const padding = next.layout.contentPaddingHorizontal ?? next.layout.contentPadding ?? 0;
|
|
67
|
-
const emptyBottomPadding = !hasRows && hasEmptySlotRef.current ? next.layout.contentPaddingBottom ?? next.layout.contentPadding ?? 0 : 0;
|
|
68
|
-
setSlotState(previous => previous.hasRows === hasRows && previous.padding === padding && previous.emptyBottomPadding === emptyBottomPadding ? previous : {
|
|
69
|
-
hasRows,
|
|
70
|
-
padding,
|
|
71
|
-
emptyBottomPadding
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
const normalizeWebSnapshot = (next, hasReactEmpty = hasEmptySlotRef.current, hasSlotLayout = useSlotLayoutRef.current) => {
|
|
82
|
+
const [viewportWidth, setViewportWidth] = useState(0);
|
|
83
|
+
const [sidecarHeight, setSidecarHeight] = useState(0);
|
|
84
|
+
const normalizeWebSnapshot = (next, hasReactEmpty = hasEmptySlotRef.current, hasSlotLayout = useSlotLayoutRef.current, validatedInThisRender = false) => {
|
|
75
85
|
if (hasSlotLayout && next.layout.orientation === 'horizontal') throw new Error('Web parent scrolling and container slots support vertical lists only');
|
|
76
86
|
const emptySlot = hasReactEmpty && next.rows.length === 0;
|
|
77
|
-
const
|
|
87
|
+
const normalized = emptySlot && next.emptyState !== undefined ? {
|
|
78
88
|
...next,
|
|
79
89
|
emptyState: undefined
|
|
80
|
-
} : next
|
|
81
|
-
|
|
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 ? {
|
|
82
94
|
...validated,
|
|
83
95
|
layout: {
|
|
84
96
|
...validated.layout,
|
|
@@ -91,20 +103,68 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
91
103
|
const [ownedScrollHost, setOwnedScrollHost] = useState(null);
|
|
92
104
|
const useSlotLayoutRef = useRef(false);
|
|
93
105
|
useSlotLayoutRef.current ||= webScrollHost !== undefined || listHeader !== undefined || listEmpty !== undefined || listFooter !== undefined;
|
|
106
|
+
useSlotLayoutRef.current ||= listSidecar !== undefined;
|
|
107
|
+
useSlotLayoutRef.current ||= listExpandedContent !== undefined || listStructureToggle !== undefined;
|
|
94
108
|
const useSlotLayout = useSlotLayoutRef.current;
|
|
95
109
|
const resolvedScrollHost = webScrollHost === undefined ? useSlotLayout ? ownedScrollHost : undefined : webScrollHost;
|
|
96
|
-
if (!Number.isFinite(webStickyInset) || webStickyInset < 0) throw new Error('webStickyInset must be finite and non-negative');
|
|
97
110
|
const engineRef = useRef(undefined);
|
|
98
111
|
const webVirtualizationEnabledRef = useRef(webVirtualizationEnabled);
|
|
99
112
|
webVirtualizationEnabledRef.current = webVirtualizationEnabled;
|
|
100
|
-
const validatedSnapshot = useMemo(() =>
|
|
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
|
+
};
|
|
101
156
|
const snapshotRef = useRef(validatedSnapshot);
|
|
102
157
|
const snapshotPropRef = useRef(validatedSnapshot);
|
|
103
158
|
// An imperative snapshot survives host mounting until the snapshot prop changes.
|
|
104
159
|
if (snapshotPropRef.current !== validatedSnapshot) {
|
|
105
160
|
snapshotPropRef.current = validatedSnapshot;
|
|
106
161
|
snapshotRef.current = validatedSnapshot;
|
|
107
|
-
|
|
162
|
+
acceptedSnapshotRef.current = validatedSnapshot;
|
|
163
|
+
synchronizeSlots(validatedSnapshot);
|
|
164
|
+
}
|
|
165
|
+
if (!initializedSnapshot.current) {
|
|
166
|
+
acceptedSnapshotRef.current = validatedSnapshot;
|
|
167
|
+
initializedSnapshot.current = true;
|
|
108
168
|
}
|
|
109
169
|
const appliedSnapshotRef = useRef(undefined);
|
|
110
170
|
const callbacksRef = useRef({});
|
|
@@ -118,7 +178,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
118
178
|
onRefresh,
|
|
119
179
|
onScrollToIndexFailed
|
|
120
180
|
};
|
|
121
|
-
const initialScrollRef = useRef(initialScrollIndex === undefined && initialScrollKey === undefined ? undefined : initialScrollIndex !== undefined ? normalizeIndexScroll({
|
|
181
|
+
const initialScrollRef = useRef(containNativeListInput(() => initialScrollIndex === undefined && initialScrollKey === undefined ? undefined : initialScrollIndex !== undefined ? normalizeIndexScroll({
|
|
122
182
|
index: initialScrollIndex,
|
|
123
183
|
animated: false,
|
|
124
184
|
viewPosition: initialScrollViewPosition,
|
|
@@ -130,7 +190,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
130
190
|
viewPosition: initialScrollViewPosition,
|
|
131
191
|
viewOffset: initialScrollViewOffset
|
|
132
192
|
}, 'start')
|
|
133
|
-
});
|
|
193
|
+
}));
|
|
134
194
|
const didApplyInitialScroll = useRef(false);
|
|
135
195
|
const scrollOptionsRef = useRef({
|
|
136
196
|
stickyInset: webStickyInset,
|
|
@@ -142,11 +202,12 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
142
202
|
};
|
|
143
203
|
useEffect(() => {
|
|
144
204
|
if (!host || resolvedScrollHost === null || useSlotLayout && !contentBounds) return;
|
|
145
|
-
const engine = new NativeListWebEngine(host, snapshotRef.current, callbacksRef.current, webVirtualizationEnabledRef.current, webSectionIndexContainerRef?.current, fontFamiliesJsonRef.current, {
|
|
205
|
+
const engine = containNativeListInput(() => new NativeListWebEngine(host, snapshotRef.current, callbacksRef.current, webVirtualizationEnabledRef.current, webSectionIndexContainerRef?.current, fontFamiliesJsonRef.current, {
|
|
146
206
|
scrollHost: resolvedScrollHost,
|
|
147
207
|
contentBounds: contentBounds ?? undefined,
|
|
148
208
|
...scrollOptionsRef.current
|
|
149
|
-
});
|
|
209
|
+
}));
|
|
210
|
+
if (!engine) return;
|
|
150
211
|
host.style.height = '';
|
|
151
212
|
engineRef.current = engine;
|
|
152
213
|
appliedSnapshotRef.current = snapshotRef.current;
|
|
@@ -185,20 +246,24 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
185
246
|
};
|
|
186
247
|
useImperativeHandle(forwardedRef, () => ({
|
|
187
248
|
applySnapshot(nextSnapshot) {
|
|
188
|
-
const next = normalizeWebSnapshot(nextSnapshot);
|
|
249
|
+
const next = containNativeListInput(() => normalizeWebSnapshot(nextSnapshot));
|
|
250
|
+
if (!next) return;
|
|
189
251
|
engineRef.current?.applySnapshot(next);
|
|
190
252
|
snapshotRef.current = next;
|
|
253
|
+
acceptedSnapshotRef.current = next;
|
|
191
254
|
appliedSnapshotRef.current = next;
|
|
192
|
-
synchronizeSlots(
|
|
255
|
+
synchronizeSlots(next);
|
|
193
256
|
},
|
|
194
257
|
applyPatches(patches) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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;
|
|
201
265
|
}
|
|
266
|
+
acceptedSnapshotRef.current = snapshotRef.current;
|
|
202
267
|
},
|
|
203
268
|
reconcileSelection(selectedKeys) {
|
|
204
269
|
engineRef.current?.reconcileSelection(selectedKeys);
|
|
@@ -263,16 +328,28 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
263
328
|
const setBoundsRef = useCallback(value => {
|
|
264
329
|
setContentBounds(value);
|
|
265
330
|
}, []);
|
|
331
|
+
const ownedScrollElementRef = useRef(null);
|
|
266
332
|
const setScrollHostRef = useCallback(value => {
|
|
267
|
-
|
|
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);
|
|
268
338
|
}, []);
|
|
269
339
|
if (!useSlotLayout) return /*#__PURE__*/_jsx(View, {
|
|
270
340
|
...viewProps,
|
|
271
341
|
ref: setHostRef
|
|
272
342
|
});
|
|
273
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;
|
|
274
351
|
const content = /*#__PURE__*/_jsxs(View, {
|
|
275
|
-
ref: setBoundsRef,
|
|
352
|
+
ref: sidecarLayout ? undefined : setBoundsRef,
|
|
276
353
|
style: {
|
|
277
354
|
position: 'relative',
|
|
278
355
|
flexShrink: 0,
|
|
@@ -295,15 +372,59 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
295
372
|
paddingBottom: slotState.emptyBottomPadding
|
|
296
373
|
},
|
|
297
374
|
children: listEmpty
|
|
298
|
-
}) : null,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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]
|
|
303
394
|
}) : null]
|
|
304
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;
|
|
305
422
|
return /*#__PURE__*/_jsx(View, {
|
|
306
423
|
...viewProps,
|
|
424
|
+
onLayout: event => {
|
|
425
|
+
setViewportWidth(event.nativeEvent.layout.width);
|
|
426
|
+
viewProps.onLayout?.(event);
|
|
427
|
+
},
|
|
307
428
|
style: [viewProps.style, {
|
|
308
429
|
position: 'relative',
|
|
309
430
|
minHeight: 0
|
|
@@ -315,8 +436,8 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
315
436
|
inset: 0,
|
|
316
437
|
overflow: 'scroll'
|
|
317
438
|
},
|
|
318
|
-
children:
|
|
319
|
-
}) :
|
|
439
|
+
children: scrollContent
|
|
440
|
+
}) : scrollContent
|
|
320
441
|
});
|
|
321
442
|
});
|
|
322
443
|
//# sourceMappingURL=NativeList.web.js.map
|
package/lib/module/index.js
CHANGED
|
@@ -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";
|
package/lib/module/models.js
CHANGED
|
@@ -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
|
package/lib/module/selection.js
CHANGED
|
@@ -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 {
|