@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.
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +245 -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/NativeListIdentityRenderer.kt +225 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +147 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- 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 +51 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -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 +70 -11
- package/docs/SPEC.md +1235 -20
- package/docs/STYLE_SPEC.md +6 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +235 -39
- package/ios/NativeListActivityDetailsView.swift +30 -11
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +155 -27
- package/ios/NativeListDesignAssets.swift +9 -0
- package/ios/NativeListIdentityRenderer.swift +239 -31
- package/ios/NativeListLeadingVisual.swift +119 -22
- package/ios/NativeListMarketRenderer.swift +113 -18
- package/ios/NativeListMessageRenderer.swift +34 -1
- 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 +88 -0
- package/ios/RNCNativeListView.swift +1052 -58
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/icon.svg +1 -0
- package/ios/tests/NativeListAccessoryStackTests.swift +89 -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 +2789 -3
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/lib/module/NativeList.js +223 -36
- package/lib/module/NativeList.web.js +260 -33
- 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 +1386 -81
- package/lib/module/web/NativeListWebEngine.js +914 -80
- package/lib/module/web/templates/ActivityRowRenderer.js +487 -7
- 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 +145 -5
- package/lib/module/web/templates/MarketRowRenderer.js +8 -3
- package/lib/module/web/templates/MarketTableRowRenderer.js +577 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
- 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 +8 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +70 -3
- 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 +29 -1
- package/lib/typescript/src/NativeList.web.d.ts +2 -2
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +196 -17
- package/lib/typescript/src/validation.d.ts +20 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +58 -1
- package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
- 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/MarketTableRowRenderer.d.ts +17 -0
- package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +10 -4
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
- 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 +3 -3
- package/react-native-native-list.podspec +1 -0
- package/src/NativeList.nitro.ts +2 -0
- package/src/NativeList.tsx +418 -89
- package/src/NativeList.types.ts +34 -1
- package/src/NativeList.web.tsx +417 -66
- package/src/index.ts +2 -0
- package/src/models.ts +355 -143
- package/src/selection.ts +1 -0
- package/src/validation.ts +3315 -166
- package/src/web/NativeListWebEngine.ts +1473 -113
- package/src/web/templates/ActivityRowRenderer.ts +732 -8
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +217 -6
- package/src/web/templates/MarketRowRenderer.ts +19 -3
- package/src/web/templates/MarketTableRowRenderer.ts +755 -0
- package/src/web/templates/MediaTileRowRenderer.ts +313 -5
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +21 -6
- package/src/web/templates/SectionHeaderRowRenderer.ts +89 -5
|
@@ -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,109 @@ 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
|
+
const icons = [row.titleIcon, row.secondaryTitleIcon].filter(icon => icon !== undefined).map(descriptor => {
|
|
109
|
+
const icon = primitives.iconAction(descriptor.name, undefined, undefined, descriptor.tintColor);
|
|
110
|
+
icon.className = 'ok-native-list-identity-title-icon';
|
|
111
|
+
if (descriptor.hoverActionKey) {
|
|
112
|
+
setData(icon, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
113
|
+
setData(icon, 'nativeListIconHelp', true);
|
|
114
|
+
markActionAnchorSource(icon, 'leadingAction');
|
|
115
|
+
}
|
|
116
|
+
if (descriptor.accessibilityLabel) icon.setAttribute('aria-label', descriptor.accessibilityLabel);else icon.setAttribute('aria-hidden', 'true');
|
|
117
|
+
return icon;
|
|
118
|
+
});
|
|
119
|
+
if (row.titleImage) {
|
|
120
|
+
const descriptor = row.titleImage;
|
|
121
|
+
const holder = createElement(document, 'span', 'ok-native-list-identity-title-image');
|
|
122
|
+
Object.assign(holder.style, {
|
|
123
|
+
flex: `0 0 ${descriptor.image.width}px`,
|
|
124
|
+
width: `${descriptor.image.width}px`,
|
|
125
|
+
height: `${descriptor.image.height}px`,
|
|
126
|
+
borderRadius: '50%',
|
|
127
|
+
overflow: 'hidden'
|
|
128
|
+
});
|
|
129
|
+
const image = primitives.thumbnail(descriptor.image);
|
|
130
|
+
if (image) {
|
|
131
|
+
Object.assign(image.style, {
|
|
132
|
+
width: '100%',
|
|
133
|
+
height: '100%',
|
|
134
|
+
borderRadius: 'inherit',
|
|
135
|
+
objectFit: descriptor.image.contentFit === 'center' ? 'none' : descriptor.image.contentFit ?? 'cover'
|
|
136
|
+
});
|
|
137
|
+
image.setAttribute('alt', '');
|
|
138
|
+
holder.appendChild(image);
|
|
139
|
+
}
|
|
140
|
+
if (descriptor.hoverActionKey) {
|
|
141
|
+
setData(holder, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
142
|
+
setData(holder, 'nativeListIconHelp', true);
|
|
143
|
+
markActionAnchorSource(holder, 'leadingAction');
|
|
144
|
+
}
|
|
145
|
+
if (descriptor.accessibilityLabel) {
|
|
146
|
+
holder.setAttribute('role', 'img');
|
|
147
|
+
holder.setAttribute('aria-label', descriptor.accessibilityLabel);
|
|
148
|
+
} else holder.setAttribute('aria-hidden', 'true');
|
|
149
|
+
icons.push(holder);
|
|
150
|
+
}
|
|
151
|
+
titleText.after(...icons);
|
|
152
|
+
titleElement.style.display = 'flex';
|
|
153
|
+
titleElement.style.alignItems = 'center';
|
|
154
|
+
titleElement.style.gap = '4px';
|
|
155
|
+
}
|
|
156
|
+
if (row.titleSuffixes?.length) {
|
|
157
|
+
const badges = titleElement.querySelector(':scope > .ok-native-list-badges');
|
|
158
|
+
let titleText = titleElement.querySelector(':scope > .ok-native-list-identity-title-text, :scope > [data-nl-slot="title"]');
|
|
159
|
+
if (!titleText) {
|
|
160
|
+
titleText = tagSlot(createElement(document, 'span', 'ok-native-list-identity-title-text'), 'title');
|
|
161
|
+
while (titleElement.firstChild && titleElement.firstChild !== badges) titleText.appendChild(titleElement.firstChild);
|
|
162
|
+
titleElement.prepend(titleText);
|
|
163
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
164
|
+
} else if (titleElement.hasAttribute('data-nl-slot')) {
|
|
165
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
166
|
+
tagSlot(titleText, 'title');
|
|
167
|
+
}
|
|
168
|
+
titleElement.style.display = 'flex';
|
|
169
|
+
titleElement.style.alignItems = 'center';
|
|
170
|
+
titleText.style.flex = '0 1 auto';
|
|
171
|
+
titleText.style.minWidth = 'min(80px, 100%)';
|
|
172
|
+
titleText.style.overflow = 'hidden';
|
|
173
|
+
titleText.style.textOverflow = 'ellipsis';
|
|
174
|
+
titleText.style.whiteSpace = 'nowrap';
|
|
175
|
+
row.titleSuffixes.forEach(suffix => {
|
|
176
|
+
const label = createElement(document, 'span', 'ok-native-list-identity-title-suffix', suffix.text);
|
|
177
|
+
label.style.flex = '0 1 auto';
|
|
178
|
+
label.style.minWidth = '0';
|
|
179
|
+
label.style.marginInlineStart = row.titleIcon || row.secondaryTitleIcon || row.titleImage ? '4px' : '8px';
|
|
180
|
+
label.style.maxWidth = suffix.maxWidth === undefined ? '' : `${suffix.maxWidth}px`;
|
|
181
|
+
label.style.overflow = 'hidden';
|
|
182
|
+
label.style.textOverflow = 'ellipsis';
|
|
183
|
+
label.style.whiteSpace = 'nowrap';
|
|
184
|
+
label.style.fontSize = '12px';
|
|
185
|
+
label.style.lineHeight = '16px';
|
|
186
|
+
label.style.fontWeight = '400';
|
|
187
|
+
label.style.fontFamily = 'var(--nl-font-regular)';
|
|
188
|
+
label.style.color = suffix.tone === 'disabled' ? 'var(--nl-disabled)' : 'var(--nl-secondary)';
|
|
189
|
+
titleElement.insertBefore(label, badges);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
if (row.badges?.length && !row.titleIcon && !row.secondaryTitleIcon && !row.titleImage) {
|
|
193
|
+
const titleText = titleElement.querySelector(':scope > [data-nl-slot="title"]');
|
|
194
|
+
const badges = titleElement.querySelector(':scope > .ok-native-list-badges');
|
|
195
|
+
titleElement.style.display = 'flex';
|
|
196
|
+
titleElement.style.alignItems = 'center';
|
|
197
|
+
if (titleText) {
|
|
198
|
+
titleText.style.flex = '0 1 auto';
|
|
199
|
+
titleText.style.minWidth = row.titleSuffixes?.length ? 'min(80px, 100%)' : '0';
|
|
200
|
+
}
|
|
201
|
+
if (badges) {
|
|
202
|
+
badges.style.flex = '0 1 auto';
|
|
203
|
+
badges.style.minWidth = '0';
|
|
204
|
+
}
|
|
205
|
+
}
|
|
103
206
|
if (presentation === 'walletSidebar' && row.badges?.length) {
|
|
104
207
|
const badges = createElement(document, 'span', 'ok-native-list-wallet-badges');
|
|
105
208
|
row.badges.forEach(badge => badges.appendChild(createBadge(document, badge)));
|
|
@@ -107,9 +210,9 @@ function createIdentityRow(document, primitives, row) {
|
|
|
107
210
|
}
|
|
108
211
|
for (const key of ['title', 'subtitle']) {
|
|
109
212
|
const lines = row.style?.[key]?.lines ?? row[`${key}Lines`];
|
|
110
|
-
if (lines !== undefined) column.querySelectorAll(`[data-nl-slot="${key}"]`).forEach(text => applyTextLayout(text, {
|
|
213
|
+
if (lines !== undefined) column.querySelectorAll(`[data-nl-slot="${key}"]`).forEach(text => applyTextLayout(text, lines === 0 ? {} : {
|
|
111
214
|
lines
|
|
112
|
-
}));
|
|
215
|
+
}, lines === 0 ? 0 : undefined));
|
|
113
216
|
}
|
|
114
217
|
}
|
|
115
218
|
body.appendChild(column);
|
|
@@ -125,6 +228,17 @@ function applyIdentityStyle(body, row) {
|
|
|
125
228
|
if (box.verticalPadding !== undefined) body.style.paddingBlock = String(box.verticalPadding) + 'px';
|
|
126
229
|
const vertical = row.type === 'identity' && row.presentation === 'walletSidebar';
|
|
127
230
|
const leading = body.querySelector(':scope > .ok-native-list-visual, :scope > .ok-native-list-stacked');
|
|
231
|
+
if (row.style?.leadingContentMaxWidthRatio !== undefined && !vertical) {
|
|
232
|
+
const column = body.querySelector(':scope > .ok-native-list-flex');
|
|
233
|
+
const trailing = body.querySelector(':scope > .ok-native-list-accessories');
|
|
234
|
+
const visualWidth = leading ? row.style.image?.width ?? (row.presentation === 'accountSelector' || row.presentation === 'networkSelector' ? 32 : 40) : 0;
|
|
235
|
+
const gap = leading ? row.style.leadingGap ?? 12 : 0;
|
|
236
|
+
if (column) {
|
|
237
|
+
column.style.flex = '0 1 auto';
|
|
238
|
+
column.style.maxWidth = `calc(${row.style.leadingContentMaxWidthRatio * 100}% - ${visualWidth + gap}px)`;
|
|
239
|
+
}
|
|
240
|
+
if (trailing) trailing.style.marginInlineStart = 'auto';
|
|
241
|
+
}
|
|
128
242
|
const defaultGap = body.style.gap || (row.type === 'identity' && row.presentation === 'walletSidebar' ? '4px' : row.type === 'identity' && row.presentation === 'accountSelector' ? '8px' : '12px');
|
|
129
243
|
if (box.lineGap !== undefined) {
|
|
130
244
|
const targets = body.querySelectorAll(':scope > .ok-native-list-flex');
|
|
@@ -161,7 +275,7 @@ function applyIdentityStyle(body, row) {
|
|
|
161
275
|
// Clip the bitmap itself; decorations may extend beyond the visual slot.
|
|
162
276
|
leading.style.overflow = leading.matches('img') ? 'hidden' : 'visible';
|
|
163
277
|
}
|
|
164
|
-
const images = leading.matches('img') ? [leading] : leading.querySelectorAll(':scope > img, :scope > .ok-native-list-visual-fallback');
|
|
278
|
+
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
279
|
images.forEach(bitmap => {
|
|
166
280
|
if (bitmap !== leading) {
|
|
167
281
|
if (image.width !== undefined) bitmap.style.width = '100%';
|
|
@@ -185,8 +299,22 @@ function bind(body, row, primitives) {
|
|
|
185
299
|
const v = views.get(body);
|
|
186
300
|
v.primitives = primitives;
|
|
187
301
|
let used = false;
|
|
302
|
+
let usedTitleImage = false;
|
|
188
303
|
const next = createIdentityRow(body.ownerDocument, {
|
|
189
304
|
...primitives,
|
|
305
|
+
thumbnail: source => {
|
|
306
|
+
usedTitleImage = true;
|
|
307
|
+
const key = JSON.stringify([row.key, source]);
|
|
308
|
+
if (v.titleImage?.key !== key) {
|
|
309
|
+
if (v.titleImage) primitives.dispose(v.titleImage.node);
|
|
310
|
+
const node = primitives.thumbnail(source);
|
|
311
|
+
v.titleImage = node ? {
|
|
312
|
+
key,
|
|
313
|
+
node
|
|
314
|
+
} : undefined;
|
|
315
|
+
}
|
|
316
|
+
return v.titleImage?.node;
|
|
317
|
+
},
|
|
190
318
|
visual: (source, presentation) => {
|
|
191
319
|
used = true;
|
|
192
320
|
const key = JSON.stringify([row.key, source, presentation]);
|
|
@@ -211,6 +339,10 @@ function bind(body, row, primitives) {
|
|
|
211
339
|
primitives.dispose(v.visual.node);
|
|
212
340
|
v.visual = undefined;
|
|
213
341
|
}
|
|
342
|
+
if (!usedTitleImage && v.titleImage) {
|
|
343
|
+
primitives.dispose(v.titleImage.node);
|
|
344
|
+
v.titleImage = undefined;
|
|
345
|
+
}
|
|
214
346
|
body.replaceChildren(...Array.from(next.childNodes));
|
|
215
347
|
body.className = next.className;
|
|
216
348
|
body.style.cssText = next.style.cssText;
|
|
@@ -275,7 +407,11 @@ function create(document, row, primitives) {
|
|
|
275
407
|
function recycle(body) {
|
|
276
408
|
const v = views.get(body);
|
|
277
409
|
if (v?.visual) v.primitives.dispose(v.visual.node);
|
|
278
|
-
if (v) v.
|
|
410
|
+
if (v?.titleImage) v.primitives.dispose(v.titleImage.node);
|
|
411
|
+
if (v) {
|
|
412
|
+
v.visual = undefined;
|
|
413
|
+
v.titleImage = undefined;
|
|
414
|
+
}
|
|
279
415
|
body.replaceChildren();
|
|
280
416
|
}
|
|
281
417
|
export const identityRowRenderer = {
|
|
@@ -285,6 +421,10 @@ export const identityRowRenderer = {
|
|
|
285
421
|
recycle,
|
|
286
422
|
appliesSizePreset: row => !row.presentation,
|
|
287
423
|
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: (
|
|
424
|
+
measureRendered: (body, row) => {
|
|
425
|
+
if (row.contentHeight !== 'auto' || hasExplicitRowHeight(row)) return undefined;
|
|
426
|
+
const height = body.getBoundingClientRect().height;
|
|
427
|
+
return height > 0 ? height : undefined;
|
|
428
|
+
}
|
|
289
429
|
};
|
|
290
430
|
//# sourceMappingURL=IdentityRowRenderer.js.map
|
|
@@ -114,8 +114,8 @@ function createMarketRow(document, primitives, row) {
|
|
|
114
114
|
}
|
|
115
115
|
image.style.objectFit = style?.image?.contentFit === 'center' ? 'none' : style?.image?.contentFit ?? image.style.objectFit;
|
|
116
116
|
} else {
|
|
117
|
-
image.style.width = '
|
|
118
|
-
image.style.height = '
|
|
117
|
+
image.style.width = String(row.leading.kind === 'token' ? row.leading.networkImage?.width ?? 16 : 16) + 'px';
|
|
118
|
+
image.style.height = String(row.leading.kind === 'token' ? row.leading.networkImage?.height ?? 16 : 16) + 'px';
|
|
119
119
|
if (borderColor) {
|
|
120
120
|
image.style.right = '-5px';
|
|
121
121
|
image.style.bottom = '-5px';
|
|
@@ -187,8 +187,13 @@ function createMarketRow(document, primitives, row) {
|
|
|
187
187
|
weight: 400,
|
|
188
188
|
alignment: 'start'
|
|
189
189
|
});
|
|
190
|
+
if (row.subtitlePrefix.hoverActionKey) {
|
|
191
|
+
prefix.dataset.nativeListHoverAction = row.subtitlePrefix.hoverActionKey;
|
|
192
|
+
prefix.dataset.nativeListAnchorSource = 'row';
|
|
193
|
+
prefix.tabIndex = 0;
|
|
194
|
+
}
|
|
190
195
|
prefix.style.display = 'block';
|
|
191
|
-
prefix.style.flex = '
|
|
196
|
+
prefix.style.flex = '0 1 auto';
|
|
192
197
|
prefix.style.minWidth = '0';
|
|
193
198
|
prefix.style.overflow = 'hidden';
|
|
194
199
|
prefix.style.textOverflow = 'ellipsis';
|