@onekeyfe/react-native-native-list 6.7.0-5 → 6.7.0-51
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 +312 -375
- 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 +1978 -136
- 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 +1232 -16
- 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 +1093 -59
- 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 +2915 -4
- 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 +236 -38
- 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 +12 -31
- 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 +439 -91
- 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 +29 -59
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { createNamedIcon } from '@onekeyfe/react-native-image/icon/dom';
|
|
3
4
|
import { createElement, tagSlot, markActionAnchorSource } from "./RowElements.js";
|
|
4
5
|
import { RowVisualStyle } from "./RowVisual.js";
|
|
5
6
|
import { applyTextWeight, applyValueSegments } from "./RowText.js";
|
|
@@ -22,13 +23,13 @@ function bindLegacy(body, row, primitives) {
|
|
|
22
23
|
node.hidden = !row[key];
|
|
23
24
|
if (style?.[key]) primitives.textStyle(node, style[key]);
|
|
24
25
|
}
|
|
25
|
-
const visualKey = JSON.stringify([row.key, row.leading, row.secondaryLeading]);
|
|
26
|
+
const visualKey = JSON.stringify([row.key, row.hideLeading, row.leading, row.secondaryLeading]);
|
|
26
27
|
if (v.visualKey !== visualKey) {
|
|
27
28
|
v.visuals.forEach(node => {
|
|
28
29
|
primitives.dispose(node);
|
|
29
30
|
node.remove();
|
|
30
31
|
});
|
|
31
|
-
v.visuals = [row.leading, row.secondaryLeading].map(source => primitives.visual(source)).filter(node => !!node);
|
|
32
|
+
v.visuals = (row.hideLeading ? [] : [row.leading, row.secondaryLeading]).map(source => primitives.visual(source)).filter(node => !!node);
|
|
32
33
|
v.visuals.forEach(node => body.insertBefore(node, v.column));
|
|
33
34
|
v.visualStyles = v.visuals.map(node => new RowVisualStyle(node));
|
|
34
35
|
v.visualKey = visualKey;
|
|
@@ -152,22 +153,10 @@ function createHistory(body, primitives) {
|
|
|
152
153
|
histories.set(body, v);
|
|
153
154
|
return v;
|
|
154
155
|
}
|
|
155
|
-
const
|
|
156
|
-
ArrowTopOutline: ['M19.414 10 18 11.414l-5-5V21h-2V6.414l-5 5L4.586 10 12 2.586z'],
|
|
157
|
-
ArrowBottomOutline: ['m13 17.586 5-5L19.414 14 12 21.414 4.586 14 6 12.586l5 5V3h2z'],
|
|
158
|
-
SwitchHorOutline: ['m9.414 13-3 3H21v2H6.414l3 3L8 22.414 2.586 17 8 11.586zm12-6L16 12.414 14.586 11l3-3H3V6h14.586l-3-3L16 1.586z'],
|
|
159
|
-
CoinsOutline: ['M9 3a7 7 0 0 1 6.328 4.008 7 7 0 1 1-6.657 9.983A7 7 0 0 1 9 3m5.718 6.008a5 5 0 1 0 .566 9.985 5 5 0 0 0-.566-9.985M9 5a5 5 0 0 0-.941 9.91 7 7 0 0 1 5.11-7.667A4.99 4.99 0 0 0 8.999 5Z'],
|
|
160
|
-
ShieldCheckDoneOutline: ['M15.914 9.75 11 14.664 8.086 11.75 9.5 10.336l1.5 1.5 3.5-3.5z', 'M12.325 2.055 21 5.036v6.876c0 2.807-1.149 4.83-2.813 6.404-1.615 1.53-3.745 2.66-5.712 3.722l-.475.256-.475-.256c-1.967-1.061-4.097-2.192-5.713-3.722C4.15 16.741 3 14.72 3 11.912V5.036l8.675-2.981.325-.113zM5 6.463v5.45c0 2.165.851 3.686 2.188 4.951 1.275 1.208 2.965 2.154 4.812 3.154 1.847-1 3.537-1.946 4.813-3.154C18.148 15.6 19 14.078 19 11.912v-5.45l-7-2.405z'],
|
|
161
|
-
UnlockedOutline: ['M13 18h-2v-5h2z', 'M12 2a5 5 0 0 1 5 5h-2a3 3 0 0 0-6 0v2h11v13H4V9h3V7a5 5 0 0 1 5-5M6 20h12v-9H6z'],
|
|
162
|
-
Document2Outline: ['M12 16H8v-2h4zm4-4H8v-2h8zm0-4H8V6h8z', 'M20 22H4V2h16zM6 20h12V4H6z'],
|
|
163
|
-
CryptoCoinOutline: ['M11 16.387a4.5 4.5 0 0 1 0-8.775V6h2v1.613a4.5 4.5 0 0 1 2.856 2.067l-1.712 1.032a2.5 2.5 0 1 0 0 2.576l1.712 1.032A4.5 4.5 0 0 1 13 16.386V18h-2z', 'M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10m-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0'],
|
|
164
|
-
ImageSquareWavesOutline: ['M14.25 7a2 2 0 1 1 0 4 2 2 0 0 1 0-4', 'M21 21H3V3h18zM5 16.414V19h12.586L14 15.414l-2 2-4-4zm0-2.828 3-3 4 4 2-2 5 5V5H5z'],
|
|
165
|
-
DotHorOutline: ['M6 14H2v-4h4zm8 0h-4v-4h4zm8 0h-4v-4h4z']
|
|
166
|
-
};
|
|
156
|
+
const historyIconNames = new Set(['ArrowTopOutline', 'ArrowBottomOutline', 'SwitchHorOutline', 'CoinsOutline', 'ShieldCheckDoneOutline', 'UnlockedOutline', 'Document2Outline', 'CryptoCoinOutline', 'ImageSquareWavesOutline', 'DotHorOutline']);
|
|
167
157
|
function historyIcon(node, source, size) {
|
|
168
158
|
const name = source?.kind === 'icon' ? source.name : source?.kind === 'token' ? source.fallbackIcon?.name : undefined;
|
|
169
|
-
|
|
170
|
-
if (!paths) return;
|
|
159
|
+
if (!name || !historyIconNames.has(name)) return;
|
|
171
160
|
const placeholder = node.querySelector('.ok-native-list-visual-fallback');
|
|
172
161
|
if (!placeholder && source && 'image' in source && source.image) return;
|
|
173
162
|
const fallback = placeholder ?? node;
|
|
@@ -179,18 +168,9 @@ function historyIcon(node, source, size) {
|
|
|
179
168
|
height: '100%'
|
|
180
169
|
});
|
|
181
170
|
if (source?.kind === 'icon' && source.tintColor) fallback.style.color = source.tintColor;else if (source && 'fallbackIcon' in source && source.fallbackIcon?.tintColor) fallback.style.color = source.fallbackIcon.tintColor;
|
|
182
|
-
const svg = node.ownerDocument
|
|
183
|
-
svg.setAttribute('viewBox', '0 0 24 24');
|
|
171
|
+
const svg = createNamedIcon(node.ownerDocument, name);
|
|
184
172
|
svg.setAttribute('width', String(size));
|
|
185
173
|
svg.setAttribute('height', String(size));
|
|
186
|
-
svg.setAttribute('fill', 'currentColor');
|
|
187
|
-
svg.setAttribute('aria-hidden', 'true');
|
|
188
|
-
for (const d of paths) {
|
|
189
|
-
const path = node.ownerDocument.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
190
|
-
path.setAttribute('d', d);
|
|
191
|
-
path.setAttribute('fill-rule', 'evenodd');
|
|
192
|
-
svg.append(path);
|
|
193
|
-
}
|
|
194
174
|
fallback.replaceChildren(svg);
|
|
195
175
|
}
|
|
196
176
|
function bindHistory(body, row, primitives) {
|
|
@@ -224,22 +204,23 @@ function bindHistory(body, row, primitives) {
|
|
|
224
204
|
Object.assign(v.identity.style, {
|
|
225
205
|
display: 'flex',
|
|
226
206
|
alignItems: 'center',
|
|
227
|
-
gap: '12px',
|
|
207
|
+
gap: row.hideLeading ? '0' : '12px',
|
|
228
208
|
minWidth: '0',
|
|
229
209
|
flex: '1 1 0'
|
|
230
210
|
});
|
|
231
211
|
Object.assign(v.visual.style, {
|
|
212
|
+
display: row.hideLeading ? 'none' : '',
|
|
232
213
|
position: 'relative',
|
|
233
214
|
width: '40px',
|
|
234
215
|
height: '40px',
|
|
235
216
|
flex: '0 0 40px'
|
|
236
217
|
});
|
|
237
|
-
const visualKey = JSON.stringify([row.key, row.leading, row.secondaryLeading]);
|
|
218
|
+
const visualKey = JSON.stringify([row.key, row.hideLeading, row.leading, row.secondaryLeading]);
|
|
238
219
|
if (v.visualKey !== visualKey) {
|
|
239
220
|
Array.from(v.visual.children).forEach(n => primitives.dispose(n));
|
|
240
221
|
v.visual.replaceChildren();
|
|
241
222
|
v.visuals = [];
|
|
242
|
-
const sources = [row.leading, row.secondaryLeading].filter(Boolean);
|
|
223
|
+
const sources = row.hideLeading ? [] : [row.leading, row.secondaryLeading].filter(Boolean);
|
|
243
224
|
sources.forEach(source => {
|
|
244
225
|
const visual = primitives.visual(source);
|
|
245
226
|
if (!visual) return;
|
|
@@ -263,7 +244,7 @@ function bindHistory(body, row, primitives) {
|
|
|
263
244
|
});
|
|
264
245
|
v.visualKey = visualKey;
|
|
265
246
|
}
|
|
266
|
-
const sources = [row.leading, row.secondaryLeading].filter(Boolean);
|
|
247
|
+
const sources = row.hideLeading ? [] : [row.leading, row.secondaryLeading].filter(Boolean);
|
|
267
248
|
v.visuals.forEach((retained, index) => {
|
|
268
249
|
const {
|
|
269
250
|
node: visual,
|
|
@@ -493,7 +474,7 @@ function bindHistory(body, row, primitives) {
|
|
|
493
474
|
v.feeSecondary.style.cssText = ellipsis + 'font-size:14px;line-height:20px;font-weight:400;color:var(--nl-secondary);';
|
|
494
475
|
valueText(v.feePrimary, row.fee?.primary, row.fee?.primaryTextSegments, 14, 20, 400);
|
|
495
476
|
valueText(v.feeSecondary, row.fee?.secondary, row.fee?.secondaryTextSegments, 14, 20, 400);
|
|
496
|
-
v.actions.style.cssText =
|
|
477
|
+
v.actions.style.cssText = `display:flex;gap:12px;padding-left:${row.hideLeading ? 0 : 52}px;padding-bottom:4px;`;
|
|
497
478
|
v.actions.style.display = footer ? 'flex' : 'none';
|
|
498
479
|
const actionKeys = new Set();
|
|
499
480
|
for (const [index, action] of (row.footerActions ?? []).entries()) {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { markActionAnchorSource } from "./RowElements.js";
|
|
4
|
+
function bind(body, row) {
|
|
5
|
+
body.replaceChildren();
|
|
6
|
+
body.className = 'ok-native-list-row ok-native-list-button-group';
|
|
7
|
+
body.removeAttribute('data-nl-container-background');
|
|
8
|
+
body.removeAttribute('data-nl-container-border');
|
|
9
|
+
row.buttons.forEach((descriptor, index) => {
|
|
10
|
+
const button = body.ownerDocument.createElement('button');
|
|
11
|
+
button.type = 'button';
|
|
12
|
+
button.className = 'ok-native-list-block-button';
|
|
13
|
+
button.dataset.nativeListAction = descriptor.actionKey;
|
|
14
|
+
button.dataset.nlButtonKey = descriptor.key;
|
|
15
|
+
button.dataset.nlSlot = `button-${index}`;
|
|
16
|
+
if (descriptor.testID) button.dataset.testid = descriptor.testID;
|
|
17
|
+
button.setAttribute('aria-label', descriptor.accessibilityLabel ?? descriptor.label);
|
|
18
|
+
button.disabled = Boolean(row.disabled || descriptor.disabled || descriptor.loading);
|
|
19
|
+
button.setAttribute('aria-busy', descriptor.loading ? 'true' : 'false');
|
|
20
|
+
markActionAnchorSource(button, 'buttonGroup', index);
|
|
21
|
+
const label = body.ownerDocument.createElement('span');
|
|
22
|
+
label.textContent = descriptor.label;
|
|
23
|
+
if (descriptor.loading) {
|
|
24
|
+
const spinner = body.ownerDocument.createElement('span');
|
|
25
|
+
spinner.className = 'ok-native-list-spinner';
|
|
26
|
+
spinner.setAttribute('role', 'progressbar');
|
|
27
|
+
button.appendChild(spinner);
|
|
28
|
+
}
|
|
29
|
+
button.appendChild(label);
|
|
30
|
+
body.appendChild(button);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function create(document, row, _primitives) {
|
|
34
|
+
const body = document.createElement('div');
|
|
35
|
+
body.dataset.nlRenderer = 'buttonGroup';
|
|
36
|
+
bind(body, row);
|
|
37
|
+
return body;
|
|
38
|
+
}
|
|
39
|
+
export const buttonGroupRowRenderer = {
|
|
40
|
+
key: 'buttonGroup',
|
|
41
|
+
create,
|
|
42
|
+
bind,
|
|
43
|
+
recycle: body => body.replaceChildren(),
|
|
44
|
+
measure: (_row, _width) => 64,
|
|
45
|
+
measureRendered: body => body.scrollHeight
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=ButtonGroupRowRenderer.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { createElement, tagSlot } from "./RowElements.js";
|
|
3
|
+
import { createElement, markActionAnchorSource, setData, tagSlot } from "./RowElements.js";
|
|
4
|
+
import { applyValueSegments, fontWeight } from "./RowText.js";
|
|
4
5
|
import { RowVisualStyle } from "./RowVisual.js";
|
|
5
6
|
const views = new WeakMap();
|
|
6
7
|
const tone = (value, fallback) => value === 'positive' ? 'var(--nl-positive)' : value === 'negative' ? 'var(--nl-negative)' : value === 'secondary' ? 'var(--nl-secondary)' : `var(--nl-${fallback})`;
|
|
@@ -16,6 +17,9 @@ function bind(body, row, primitives) {
|
|
|
16
17
|
v.controls.replaceChildren();
|
|
17
18
|
if (row.checkbox) v.controls.appendChild(primitives.accessory(row.key, row.checkbox, 0));
|
|
18
19
|
v.controls.style.display = 'contents';
|
|
20
|
+
v.trailing.replaceChildren();
|
|
21
|
+
row.trailing?.forEach((accessory, index) => v.trailing.appendChild(primitives.accessory(row.key, accessory, index)));
|
|
22
|
+
v.trailing.hidden = !row.trailing?.length;
|
|
19
23
|
v.index.style.cssText = '';
|
|
20
24
|
v.index.hidden = row.index === undefined;
|
|
21
25
|
v.index.textContent = String(row.index ?? '');
|
|
@@ -54,7 +58,26 @@ function bind(body, row, primitives) {
|
|
|
54
58
|
if (style?.titleBadgeGap !== undefined) cell.primaryLine.style.gap = `${style.titleBadgeGap}px`;
|
|
55
59
|
cell.primary.style.cssText = '';
|
|
56
60
|
cell.primary.textContent = column.text;
|
|
61
|
+
applyValueSegments(cell.primary, column.textSegments, style?.columns?.fontSize ?? 14, style?.columns?.lineHeight ?? 20, fontWeight(style?.columns?.fontWeight, 500));
|
|
57
62
|
if (style?.columns) primitives.textStyle(cell.primary, style.columns);
|
|
63
|
+
cell.titleIcons.replaceChildren();
|
|
64
|
+
if (column.titleIcon || column.secondaryTitleIcon) {
|
|
65
|
+
cell.primary.style.minWidth = '0';
|
|
66
|
+
cell.primary.style.overflow = 'hidden';
|
|
67
|
+
cell.primary.style.textOverflow = 'ellipsis';
|
|
68
|
+
cell.primary.style.whiteSpace = 'nowrap';
|
|
69
|
+
[column.titleIcon, column.secondaryTitleIcon].filter(icon => icon !== undefined).forEach(descriptor => {
|
|
70
|
+
const icon = primitives.iconAction(descriptor.name, undefined, undefined, descriptor.tintColor);
|
|
71
|
+
icon.className = 'ok-native-list-identity-title-icon';
|
|
72
|
+
if (descriptor.hoverActionKey) {
|
|
73
|
+
setData(icon, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
74
|
+
setData(icon, 'nativeListIconHelp', true);
|
|
75
|
+
markActionAnchorSource(icon, 'leadingAction');
|
|
76
|
+
}
|
|
77
|
+
if (descriptor.accessibilityLabel) icon.setAttribute('aria-label', descriptor.accessibilityLabel);else icon.setAttribute('aria-hidden', 'true');
|
|
78
|
+
cell.titleIcons.appendChild(icon);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
58
81
|
cell.badges.replaceChildren();
|
|
59
82
|
cell.badges.style.display = 'contents';
|
|
60
83
|
if (column.key === 'asset') row.badges?.forEach(badge => {
|
|
@@ -64,17 +87,22 @@ function bind(body, row, primitives) {
|
|
|
64
87
|
});
|
|
65
88
|
// Legacy Web layout: secondary leading text sits inline before the primary
|
|
66
89
|
// text; secondary text is a direct line below it, toned by secondaryTone.
|
|
67
|
-
|
|
68
|
-
|
|
90
|
+
const secondaryText = column.secondaryTextSegments?.length ? column.secondaryTextSegments.map(segment => segment.text).join('') : column.secondaryText;
|
|
91
|
+
cell.secondaryLine.style.display = secondaryText ? 'contents' : 'none';
|
|
92
|
+
[column.secondaryLeadingText, secondaryText].forEach((text, slot) => {
|
|
69
93
|
const label = cell.secondary[slot];
|
|
70
94
|
label.hidden = !text;
|
|
71
95
|
if (!text) label.remove();else if (slot === 0) cell.primaryLine.insertBefore(label, cell.primary);else cell.secondaryLine.appendChild(label);
|
|
72
96
|
label.style.cssText = '';
|
|
73
97
|
label.textContent = text ?? '';
|
|
98
|
+
if (slot === 1) {
|
|
99
|
+
applyValueSegments(label, column.secondaryTextSegments, style?.columnSecondary?.fontSize ?? 12, style?.columnSecondary?.lineHeight ?? 16, fontWeight(style?.columnSecondary?.fontWeight, 400));
|
|
100
|
+
}
|
|
74
101
|
if (slot === 1) label.style.color = tone(column.secondaryTone, 'secondary');
|
|
75
102
|
if (style?.columnSecondary) primitives.textStyle(label, style.columnSecondary);
|
|
76
103
|
});
|
|
77
104
|
});
|
|
105
|
+
body.appendChild(v.trailing);
|
|
78
106
|
}
|
|
79
107
|
function create(document, row, primitives) {
|
|
80
108
|
const body = createElement(document, 'div', 'ok-native-list-row ok-native-list-data');
|
|
@@ -82,6 +110,7 @@ function create(document, row, primitives) {
|
|
|
82
110
|
const index = tagSlot(createElement(document, 'span', 'ok-native-list-index'), 'index');
|
|
83
111
|
const favorite = createElement(document, 'span', 'ok-native-list-favorite');
|
|
84
112
|
const controls = createElement(document, 'span');
|
|
113
|
+
const trailing = createElement(document, 'span', 'ok-native-list-accessories');
|
|
85
114
|
body.append(controls, index, favorite);
|
|
86
115
|
const columns = Array.from({
|
|
87
116
|
length: 4
|
|
@@ -89,8 +118,10 @@ function create(document, row, primitives) {
|
|
|
89
118
|
const cell = createElement(document, 'span', 'ok-native-list-data-cell');
|
|
90
119
|
const primaryLine = createElement(document, 'span', 'ok-native-list-data-primary');
|
|
91
120
|
const primary = tagSlot(createElement(document, 'span'), 'columns');
|
|
121
|
+
const titleIcons = createElement(document, 'span');
|
|
122
|
+
titleIcons.style.display = 'contents';
|
|
92
123
|
const badges = createElement(document, 'span');
|
|
93
|
-
primaryLine.append(primary, badges);
|
|
124
|
+
primaryLine.append(primary, titleIcons, badges);
|
|
94
125
|
const secondaryLine = createElement(document, 'span', 'ok-native-list-data-secondary-line');
|
|
95
126
|
const secondary = Array.from({
|
|
96
127
|
length: 2
|
|
@@ -102,15 +133,18 @@ function create(document, row, primitives) {
|
|
|
102
133
|
body: cell,
|
|
103
134
|
primaryLine,
|
|
104
135
|
primary,
|
|
136
|
+
titleIcons,
|
|
105
137
|
badges,
|
|
106
138
|
secondaryLine,
|
|
107
139
|
secondary
|
|
108
140
|
};
|
|
109
141
|
});
|
|
142
|
+
body.appendChild(trailing);
|
|
110
143
|
views.set(body, {
|
|
111
144
|
favorite,
|
|
112
145
|
index,
|
|
113
146
|
controls,
|
|
147
|
+
trailing,
|
|
114
148
|
columns,
|
|
115
149
|
visualKey: '',
|
|
116
150
|
primitives
|
|
@@ -129,6 +163,7 @@ function recycle(body) {
|
|
|
129
163
|
v.visualStyle = undefined;
|
|
130
164
|
v.visualKey = '';
|
|
131
165
|
v.controls.replaceChildren();
|
|
166
|
+
v.trailing.replaceChildren();
|
|
132
167
|
}
|
|
133
168
|
export const dataRowRenderer = {
|
|
134
169
|
key: 'dataRow',
|
|
@@ -137,7 +172,7 @@ export const dataRowRenderer = {
|
|
|
137
172
|
recycle,
|
|
138
173
|
// Legacy presets: table rows without secondary text are 8 units shorter.
|
|
139
174
|
measure: (row, _width, layout) => {
|
|
140
|
-
const secondary = row.columns.some(column => column.secondaryText);
|
|
175
|
+
const secondary = row.columns.some(column => column.secondaryTextSegments?.length ? column.secondaryTextSegments.some(segment => segment.text.length > 0) : !!column.secondaryText);
|
|
141
176
|
return (secondary ? 60 : 56) + (layout === 'table' && !secondary ? -8 : 0);
|
|
142
177
|
},
|
|
143
178
|
measureRendered: (_body, _row) => undefined
|
|
@@ -100,6 +100,117 @@ function createIdentityRow(document, primitives, row) {
|
|
|
100
100
|
});
|
|
101
101
|
column.insertBefore(segments, titleElement.nextSibling);
|
|
102
102
|
}
|
|
103
|
+
if (row.titleIcon || row.secondaryTitleIcon || row.titleImage) {
|
|
104
|
+
const badgeLine = titleElement.querySelector(':scope > .ok-native-list-badges');
|
|
105
|
+
const titleText = createElement(document, 'span', 'ok-native-list-identity-title-text');
|
|
106
|
+
while (titleElement.firstChild && titleElement.firstChild !== badgeLine) titleText.appendChild(titleElement.firstChild);
|
|
107
|
+
titleElement.prepend(titleText);
|
|
108
|
+
// The title slot tag moves with the text. `applyTextLayout` writes the
|
|
109
|
+
// single-line clamp (`display: block`, nowrap, ellipsis) onto the slot
|
|
110
|
+
// element; left on this container it would undo the flex row below and
|
|
111
|
+
// leave the inline-flex glyph baseline-aligned above the title (OK-66402).
|
|
112
|
+
if (titleElement.hasAttribute('data-nl-slot')) {
|
|
113
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
114
|
+
tagSlot(titleText, 'title');
|
|
115
|
+
}
|
|
116
|
+
const icons = [row.titleIcon, row.secondaryTitleIcon].filter(icon => icon !== undefined).map(descriptor => {
|
|
117
|
+
const icon = primitives.iconAction(descriptor.name, undefined, undefined, descriptor.tintColor);
|
|
118
|
+
icon.className = 'ok-native-list-identity-title-icon';
|
|
119
|
+
if (descriptor.hoverActionKey) {
|
|
120
|
+
setData(icon, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
121
|
+
setData(icon, 'nativeListIconHelp', true);
|
|
122
|
+
markActionAnchorSource(icon, 'leadingAction');
|
|
123
|
+
}
|
|
124
|
+
if (descriptor.accessibilityLabel) icon.setAttribute('aria-label', descriptor.accessibilityLabel);else icon.setAttribute('aria-hidden', 'true');
|
|
125
|
+
return icon;
|
|
126
|
+
});
|
|
127
|
+
if (row.titleImage) {
|
|
128
|
+
const descriptor = row.titleImage;
|
|
129
|
+
const holder = createElement(document, 'span', 'ok-native-list-identity-title-image');
|
|
130
|
+
Object.assign(holder.style, {
|
|
131
|
+
flex: `0 0 ${descriptor.image.width}px`,
|
|
132
|
+
width: `${descriptor.image.width}px`,
|
|
133
|
+
height: `${descriptor.image.height}px`,
|
|
134
|
+
borderRadius: '50%',
|
|
135
|
+
overflow: 'hidden'
|
|
136
|
+
});
|
|
137
|
+
const image = primitives.thumbnail(descriptor.image);
|
|
138
|
+
if (image) {
|
|
139
|
+
Object.assign(image.style, {
|
|
140
|
+
width: '100%',
|
|
141
|
+
height: '100%',
|
|
142
|
+
borderRadius: 'inherit',
|
|
143
|
+
objectFit: descriptor.image.contentFit === 'center' ? 'none' : descriptor.image.contentFit ?? 'cover'
|
|
144
|
+
});
|
|
145
|
+
image.setAttribute('alt', '');
|
|
146
|
+
holder.appendChild(image);
|
|
147
|
+
}
|
|
148
|
+
if (descriptor.hoverActionKey) {
|
|
149
|
+
setData(holder, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
150
|
+
setData(holder, 'nativeListIconHelp', true);
|
|
151
|
+
markActionAnchorSource(holder, 'leadingAction');
|
|
152
|
+
}
|
|
153
|
+
if (descriptor.accessibilityLabel) {
|
|
154
|
+
holder.setAttribute('role', 'img');
|
|
155
|
+
holder.setAttribute('aria-label', descriptor.accessibilityLabel);
|
|
156
|
+
} else holder.setAttribute('aria-hidden', 'true');
|
|
157
|
+
icons.push(holder);
|
|
158
|
+
}
|
|
159
|
+
titleText.after(...icons);
|
|
160
|
+
titleElement.style.display = 'flex';
|
|
161
|
+
titleElement.style.alignItems = 'center';
|
|
162
|
+
titleElement.style.gap = '4px';
|
|
163
|
+
}
|
|
164
|
+
if (row.titleSuffixes?.length) {
|
|
165
|
+
const badges = titleElement.querySelector(':scope > .ok-native-list-badges');
|
|
166
|
+
let titleText = titleElement.querySelector(':scope > .ok-native-list-identity-title-text, :scope > [data-nl-slot="title"]');
|
|
167
|
+
if (!titleText) {
|
|
168
|
+
titleText = tagSlot(createElement(document, 'span', 'ok-native-list-identity-title-text'), 'title');
|
|
169
|
+
while (titleElement.firstChild && titleElement.firstChild !== badges) titleText.appendChild(titleElement.firstChild);
|
|
170
|
+
titleElement.prepend(titleText);
|
|
171
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
172
|
+
} else if (titleElement.hasAttribute('data-nl-slot')) {
|
|
173
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
174
|
+
tagSlot(titleText, 'title');
|
|
175
|
+
}
|
|
176
|
+
titleElement.style.display = 'flex';
|
|
177
|
+
titleElement.style.alignItems = 'center';
|
|
178
|
+
titleText.style.flex = '0 1 auto';
|
|
179
|
+
titleText.style.minWidth = 'min(80px, 100%)';
|
|
180
|
+
titleText.style.overflow = 'hidden';
|
|
181
|
+
titleText.style.textOverflow = 'ellipsis';
|
|
182
|
+
titleText.style.whiteSpace = 'nowrap';
|
|
183
|
+
row.titleSuffixes.forEach(suffix => {
|
|
184
|
+
const label = createElement(document, 'span', 'ok-native-list-identity-title-suffix', suffix.text);
|
|
185
|
+
label.style.flex = '0 1 auto';
|
|
186
|
+
label.style.minWidth = '0';
|
|
187
|
+
label.style.marginInlineStart = row.titleIcon || row.secondaryTitleIcon || row.titleImage ? '4px' : '8px';
|
|
188
|
+
label.style.maxWidth = suffix.maxWidth === undefined ? '' : `${suffix.maxWidth}px`;
|
|
189
|
+
label.style.overflow = 'hidden';
|
|
190
|
+
label.style.textOverflow = 'ellipsis';
|
|
191
|
+
label.style.whiteSpace = 'nowrap';
|
|
192
|
+
label.style.fontSize = '12px';
|
|
193
|
+
label.style.lineHeight = '16px';
|
|
194
|
+
label.style.fontWeight = '400';
|
|
195
|
+
label.style.fontFamily = 'var(--nl-font-regular)';
|
|
196
|
+
label.style.color = suffix.tone === 'disabled' ? 'var(--nl-disabled)' : 'var(--nl-secondary)';
|
|
197
|
+
titleElement.insertBefore(label, badges);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (row.badges?.length && !row.titleIcon && !row.secondaryTitleIcon && !row.titleImage) {
|
|
201
|
+
const titleText = titleElement.querySelector(':scope > [data-nl-slot="title"]');
|
|
202
|
+
const badges = titleElement.querySelector(':scope > .ok-native-list-badges');
|
|
203
|
+
titleElement.style.display = 'flex';
|
|
204
|
+
titleElement.style.alignItems = 'center';
|
|
205
|
+
if (titleText) {
|
|
206
|
+
titleText.style.flex = '0 1 auto';
|
|
207
|
+
titleText.style.minWidth = row.titleSuffixes?.length ? 'min(80px, 100%)' : '0';
|
|
208
|
+
}
|
|
209
|
+
if (badges) {
|
|
210
|
+
badges.style.flex = '0 1 auto';
|
|
211
|
+
badges.style.minWidth = '0';
|
|
212
|
+
}
|
|
213
|
+
}
|
|
103
214
|
if (presentation === 'walletSidebar' && row.badges?.length) {
|
|
104
215
|
const badges = createElement(document, 'span', 'ok-native-list-wallet-badges');
|
|
105
216
|
row.badges.forEach(badge => badges.appendChild(createBadge(document, badge)));
|
|
@@ -107,9 +218,12 @@ function createIdentityRow(document, primitives, row) {
|
|
|
107
218
|
}
|
|
108
219
|
for (const key of ['title', 'subtitle']) {
|
|
109
220
|
const lines = row.style?.[key]?.lines ?? row[`${key}Lines`];
|
|
110
|
-
if (lines !== undefined) column.querySelectorAll(`[data-nl-slot="${key}"]`).forEach(text =>
|
|
111
|
-
lines
|
|
112
|
-
|
|
221
|
+
if (lines !== undefined) column.querySelectorAll(`[data-nl-slot="${key}"]`).forEach(text => {
|
|
222
|
+
applyTextLayout(text, lines === 0 ? {} : {
|
|
223
|
+
lines
|
|
224
|
+
}, lines === 0 ? 0 : undefined);
|
|
225
|
+
if (key === 'subtitle') text.style.overflowWrap = lines === 1 ? '' : 'anywhere';
|
|
226
|
+
});
|
|
113
227
|
}
|
|
114
228
|
}
|
|
115
229
|
body.appendChild(column);
|
|
@@ -125,6 +239,17 @@ function applyIdentityStyle(body, row) {
|
|
|
125
239
|
if (box.verticalPadding !== undefined) body.style.paddingBlock = String(box.verticalPadding) + 'px';
|
|
126
240
|
const vertical = row.type === 'identity' && row.presentation === 'walletSidebar';
|
|
127
241
|
const leading = body.querySelector(':scope > .ok-native-list-visual, :scope > .ok-native-list-stacked');
|
|
242
|
+
if (row.style?.leadingContentMaxWidthRatio !== undefined && !vertical) {
|
|
243
|
+
const column = body.querySelector(':scope > .ok-native-list-flex');
|
|
244
|
+
const trailing = body.querySelector(':scope > .ok-native-list-accessories');
|
|
245
|
+
const visualWidth = leading ? row.style.image?.width ?? (row.presentation === 'accountSelector' || row.presentation === 'networkSelector' ? 32 : 40) : 0;
|
|
246
|
+
const gap = leading ? row.style.leadingGap ?? 12 : 0;
|
|
247
|
+
if (column) {
|
|
248
|
+
column.style.flex = '0 1 auto';
|
|
249
|
+
column.style.maxWidth = `calc(${row.style.leadingContentMaxWidthRatio * 100}% - ${visualWidth + gap}px)`;
|
|
250
|
+
}
|
|
251
|
+
if (trailing) trailing.style.marginInlineStart = 'auto';
|
|
252
|
+
}
|
|
128
253
|
const defaultGap = body.style.gap || (row.type === 'identity' && row.presentation === 'walletSidebar' ? '4px' : row.type === 'identity' && row.presentation === 'accountSelector' ? '8px' : '12px');
|
|
129
254
|
if (box.lineGap !== undefined) {
|
|
130
255
|
const targets = body.querySelectorAll(':scope > .ok-native-list-flex');
|
|
@@ -161,7 +286,7 @@ function applyIdentityStyle(body, row) {
|
|
|
161
286
|
// Clip the bitmap itself; decorations may extend beyond the visual slot.
|
|
162
287
|
leading.style.overflow = leading.matches('img') ? 'hidden' : 'visible';
|
|
163
288
|
}
|
|
164
|
-
const images = leading.matches('img') ? [leading] : leading.querySelectorAll(':scope > img, :scope > .ok-native-list-visual-fallback');
|
|
289
|
+
const images = leading.matches('img') ? [leading] : leading.querySelectorAll(':scope > img:not(.ok-native-list-visual-corner), :scope > .ok-native-list-visual-fallback:not(.ok-native-list-visual-corner)');
|
|
165
290
|
images.forEach(bitmap => {
|
|
166
291
|
if (bitmap !== leading) {
|
|
167
292
|
if (image.width !== undefined) bitmap.style.width = '100%';
|
|
@@ -185,8 +310,22 @@ function bind(body, row, primitives) {
|
|
|
185
310
|
const v = views.get(body);
|
|
186
311
|
v.primitives = primitives;
|
|
187
312
|
let used = false;
|
|
313
|
+
let usedTitleImage = false;
|
|
188
314
|
const next = createIdentityRow(body.ownerDocument, {
|
|
189
315
|
...primitives,
|
|
316
|
+
thumbnail: source => {
|
|
317
|
+
usedTitleImage = true;
|
|
318
|
+
const key = JSON.stringify([row.key, source]);
|
|
319
|
+
if (v.titleImage?.key !== key) {
|
|
320
|
+
if (v.titleImage) primitives.dispose(v.titleImage.node);
|
|
321
|
+
const node = primitives.thumbnail(source);
|
|
322
|
+
v.titleImage = node ? {
|
|
323
|
+
key,
|
|
324
|
+
node
|
|
325
|
+
} : undefined;
|
|
326
|
+
}
|
|
327
|
+
return v.titleImage?.node;
|
|
328
|
+
},
|
|
190
329
|
visual: (source, presentation) => {
|
|
191
330
|
used = true;
|
|
192
331
|
const key = JSON.stringify([row.key, source, presentation]);
|
|
@@ -211,6 +350,10 @@ function bind(body, row, primitives) {
|
|
|
211
350
|
primitives.dispose(v.visual.node);
|
|
212
351
|
v.visual = undefined;
|
|
213
352
|
}
|
|
353
|
+
if (!usedTitleImage && v.titleImage) {
|
|
354
|
+
primitives.dispose(v.titleImage.node);
|
|
355
|
+
v.titleImage = undefined;
|
|
356
|
+
}
|
|
214
357
|
body.replaceChildren(...Array.from(next.childNodes));
|
|
215
358
|
body.className = next.className;
|
|
216
359
|
body.style.cssText = next.style.cssText;
|
|
@@ -262,6 +405,7 @@ function bind(body, row, primitives) {
|
|
|
262
405
|
}
|
|
263
406
|
}
|
|
264
407
|
applyIdentityStyle(body, row);
|
|
408
|
+
body.style.height = row.contentHeight === 'auto' && !hasExplicitRowHeight(row) ? 'auto' : '100%';
|
|
265
409
|
}
|
|
266
410
|
function create(document, row, primitives) {
|
|
267
411
|
const body = document.createElement('div');
|
|
@@ -275,7 +419,11 @@ function create(document, row, primitives) {
|
|
|
275
419
|
function recycle(body) {
|
|
276
420
|
const v = views.get(body);
|
|
277
421
|
if (v?.visual) v.primitives.dispose(v.visual.node);
|
|
278
|
-
if (v) v.
|
|
422
|
+
if (v?.titleImage) v.primitives.dispose(v.titleImage.node);
|
|
423
|
+
if (v) {
|
|
424
|
+
v.visual = undefined;
|
|
425
|
+
v.titleImage = undefined;
|
|
426
|
+
}
|
|
279
427
|
body.replaceChildren();
|
|
280
428
|
}
|
|
281
429
|
export const identityRowRenderer = {
|
|
@@ -285,6 +433,10 @@ export const identityRowRenderer = {
|
|
|
285
433
|
recycle,
|
|
286
434
|
appliesSizePreset: row => !row.presentation,
|
|
287
435
|
measure: (row, _width) => row.presentation === 'walletSidebar' ? 68 + (row.badges?.length ? 24 : 0) : row.presentation === 'networkSelector' ? 47 : row.presentation === 'accountSelector' ? 58 : row.tertiary ? 72 : row.subtitle ? 60 : 56,
|
|
288
|
-
measureRendered: (
|
|
436
|
+
measureRendered: (body, row) => {
|
|
437
|
+
if (row.contentHeight !== 'auto' || hasExplicitRowHeight(row)) return undefined;
|
|
438
|
+
const height = body.offsetHeight;
|
|
439
|
+
return height > 0 ? height : undefined;
|
|
440
|
+
}
|
|
289
441
|
};
|
|
290
442
|
//# sourceMappingURL=IdentityRowRenderer.js.map
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { createNamedIcon } from '@onekeyfe/react-native-image/icon/dom';
|
|
3
4
|
import { createElement, markActionAnchorSource } from "./RowElements.js";
|
|
4
5
|
import { applyTextWeight, applyValueSegments } from "./RowText.js";
|
|
5
6
|
const views = new WeakMap();
|
|
6
7
|
const columnSignatures = new WeakMap();
|
|
7
8
|
let sparklineId = 0;
|
|
8
9
|
const svgNamespace = 'http://www.w3.org/2000/svg';
|
|
9
|
-
const outlineStar = 'm15.455 7.243 7.729 1.123-5.592 5.45 1.32 7.698L12 17.879l-6.911 3.635 1.32-7.698-5.592-5.45 7.728-1.123L12 .24zM9.872 9.071l-4.759.69 3.444 3.358-.814 4.738L12 15.62l.465.245 3.791 1.993-.813-4.739 3.443-3.357-4.758-.69L12 4.758z';
|
|
10
|
-
const solidStar = 'm15.405 7.313 7.84 1.034-5.735 5.443 1.44 7.774L12 17.793l-6.948 3.771 1.44-7.774L.756 8.347l7.839-1.034L12 .178z';
|
|
11
10
|
function columnsSignature(columns) {
|
|
12
11
|
let signature = columnSignatures.get(columns);
|
|
13
12
|
if (signature === undefined) {
|
|
@@ -113,17 +112,10 @@ function action(element, key, label, slot) {
|
|
|
113
112
|
flexShrink: '0'
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
|
-
function icon(document,
|
|
117
|
-
const svg = document
|
|
118
|
-
svg.setAttribute('viewBox', '0 0 24 24');
|
|
115
|
+
function icon(document, name, size) {
|
|
116
|
+
const svg = createNamedIcon(document, name);
|
|
119
117
|
svg.setAttribute('width', String(size));
|
|
120
118
|
svg.setAttribute('height', String(size));
|
|
121
|
-
svg.setAttribute('aria-hidden', 'true');
|
|
122
|
-
svg.setAttribute('fill', 'currentColor');
|
|
123
|
-
const path = document.createElementNS(svgNamespace, 'path');
|
|
124
|
-
path.setAttribute('d', d);
|
|
125
|
-
path.setAttribute('fill-rule', 'evenodd');
|
|
126
|
-
svg.appendChild(path);
|
|
127
119
|
return svg;
|
|
128
120
|
}
|
|
129
121
|
function drawSparkline(element, cell) {
|
|
@@ -203,11 +195,32 @@ function updateCell(view, cell, primitives, index) {
|
|
|
203
195
|
if (cell.kind === 'asset') {
|
|
204
196
|
const visualKey = JSON.stringify(cell.leading);
|
|
205
197
|
if (view.visualKey !== visualKey) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
198
|
+
const visualImageKey = JSON.stringify(cell.leading?.kind === 'token' ? {
|
|
199
|
+
...cell.leading,
|
|
200
|
+
overlays: undefined
|
|
201
|
+
} : cell.leading);
|
|
202
|
+
if (view.visual && cell.leading?.kind === 'token' && view.visualImageKey === visualImageKey) {
|
|
203
|
+
// Keep the main frame: its load/error callbacks own its visibility.
|
|
204
|
+
for (const overlay of view.visual.querySelectorAll(':scope > .ok-native-list-visual-overlay')) {
|
|
205
|
+
primitives.dispose(overlay);
|
|
206
|
+
overlay.remove();
|
|
207
|
+
}
|
|
208
|
+
const overlayVisual = primitives.visual({
|
|
209
|
+
kind: 'token',
|
|
210
|
+
overlays: cell.leading.overlays
|
|
211
|
+
});
|
|
212
|
+
if (overlayVisual) {
|
|
213
|
+
for (const overlay of overlayVisual.querySelectorAll(':scope > .ok-native-list-visual-overlay')) view.visual.appendChild(overlay);
|
|
214
|
+
primitives.dispose(overlayVisual);
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
if (view.visual) {
|
|
218
|
+
primitives.dispose(view.visual);
|
|
219
|
+
view.visual.remove();
|
|
220
|
+
}
|
|
221
|
+
view.visual = primitives.visual(cell.leading);
|
|
209
222
|
}
|
|
210
|
-
view.
|
|
223
|
+
view.visualImageKey = visualImageKey;
|
|
211
224
|
view.visualKey = visualKey;
|
|
212
225
|
if (view.visual) Object.assign(view.visual.style, {
|
|
213
226
|
width: '40px',
|
|
@@ -331,7 +344,7 @@ function updateCell(view, cell, primitives, index) {
|
|
|
331
344
|
}[badge.style?.fontWeight ?? 'regular']);
|
|
332
345
|
if (badge.actionKey) node.dataset.nativeListHoverAction = 'true';
|
|
333
346
|
node.textContent = '';
|
|
334
|
-
const svg = icon(document, '
|
|
347
|
+
const svg = icon(document, 'BadgeRecognizedSolid', 14);
|
|
335
348
|
node.appendChild(svg);
|
|
336
349
|
}
|
|
337
350
|
title.appendChild(node);
|
|
@@ -432,7 +445,7 @@ function updateCell(view, cell, primitives, index) {
|
|
|
432
445
|
action(button, cell.hoverActionKey, cell.hoverActionLabel ?? 'Copy address', index);
|
|
433
446
|
button.style.padding = '0';
|
|
434
447
|
button.style.color = 'var(--nl-icon-subdued)';
|
|
435
|
-
button.appendChild(icon(document, '
|
|
448
|
+
button.appendChild(icon(document, 'Copy3Outline', 14));
|
|
436
449
|
hoverFrame.appendChild(button);
|
|
437
450
|
}
|
|
438
451
|
track.appendChild(hoverFrame);
|
|
@@ -455,10 +468,14 @@ function updateCell(view, cell, primitives, index) {
|
|
|
455
468
|
button.style.color = cell.active ? 'var(--nl-accent)' : 'var(--nl-icon-subdued)';
|
|
456
469
|
let svg = button.querySelector('svg');
|
|
457
470
|
if (!svg) {
|
|
458
|
-
svg = icon(document, cell.active ?
|
|
471
|
+
svg = icon(document, cell.active ? 'StarSolid' : 'StarOutline', 16);
|
|
459
472
|
button.appendChild(svg);
|
|
460
473
|
}
|
|
461
|
-
|
|
474
|
+
const name = cell.active ? 'StarSolid' : 'StarOutline';
|
|
475
|
+
if (!svg.querySelector('use')?.getAttribute('href')?.endsWith(`#onekey-${name}`)) {
|
|
476
|
+
const replacement = icon(document, name, 16);
|
|
477
|
+
svg.replaceWith(replacement);
|
|
478
|
+
}
|
|
462
479
|
if (!button.parentElement) element.appendChild(button);
|
|
463
480
|
} else if (cell.kind === 'sparkline') drawSparkline(element, cell);else {
|
|
464
481
|
element.replaceChildren();
|