@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
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ButtonGroupRow } from '../../models';
|
|
2
|
+
import { markActionAnchorSource } from './RowElements';
|
|
3
|
+
import type { RowPrimitives } from './RowVisual';
|
|
4
|
+
|
|
5
|
+
function bind(body: HTMLElement, row: ButtonGroupRow) {
|
|
6
|
+
body.replaceChildren();
|
|
7
|
+
body.className = 'ok-native-list-row ok-native-list-button-group';
|
|
8
|
+
body.removeAttribute('data-nl-container-background');
|
|
9
|
+
body.removeAttribute('data-nl-container-border');
|
|
10
|
+
row.buttons.forEach((descriptor, index) => {
|
|
11
|
+
const button = body.ownerDocument.createElement('button');
|
|
12
|
+
button.type = 'button';
|
|
13
|
+
button.className = 'ok-native-list-block-button';
|
|
14
|
+
button.dataset.nativeListAction = descriptor.actionKey;
|
|
15
|
+
button.dataset.nlButtonKey = descriptor.key;
|
|
16
|
+
button.dataset.nlSlot = `button-${index}`;
|
|
17
|
+
if (descriptor.testID) button.dataset.testid = descriptor.testID;
|
|
18
|
+
button.setAttribute(
|
|
19
|
+
'aria-label',
|
|
20
|
+
descriptor.accessibilityLabel ?? descriptor.label
|
|
21
|
+
);
|
|
22
|
+
button.disabled = Boolean(
|
|
23
|
+
row.disabled || descriptor.disabled || descriptor.loading
|
|
24
|
+
);
|
|
25
|
+
button.setAttribute('aria-busy', descriptor.loading ? 'true' : 'false');
|
|
26
|
+
markActionAnchorSource(button, 'buttonGroup', index);
|
|
27
|
+
const label = body.ownerDocument.createElement('span');
|
|
28
|
+
label.textContent = descriptor.label;
|
|
29
|
+
if (descriptor.loading) {
|
|
30
|
+
const spinner = body.ownerDocument.createElement('span');
|
|
31
|
+
spinner.className = 'ok-native-list-spinner';
|
|
32
|
+
spinner.setAttribute('role', 'progressbar');
|
|
33
|
+
button.appendChild(spinner);
|
|
34
|
+
}
|
|
35
|
+
button.appendChild(label);
|
|
36
|
+
body.appendChild(button);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function create(
|
|
41
|
+
document: Document,
|
|
42
|
+
row: ButtonGroupRow,
|
|
43
|
+
_primitives: RowPrimitives
|
|
44
|
+
) {
|
|
45
|
+
const body = document.createElement('div');
|
|
46
|
+
body.dataset.nlRenderer = 'buttonGroup';
|
|
47
|
+
bind(body, row);
|
|
48
|
+
return body;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const buttonGroupRowRenderer = {
|
|
52
|
+
key: 'buttonGroup' as const,
|
|
53
|
+
create,
|
|
54
|
+
bind,
|
|
55
|
+
recycle: (body: HTMLElement) => body.replaceChildren(),
|
|
56
|
+
measure: (_row: ButtonGroupRow, _width: number) => 64,
|
|
57
|
+
measureRendered: (body: HTMLElement) => body.scrollHeight,
|
|
58
|
+
};
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { DataRow, TextTone } from '../../models';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createElement,
|
|
4
|
+
markActionAnchorSource,
|
|
5
|
+
setData,
|
|
6
|
+
tagSlot,
|
|
7
|
+
} from './RowElements';
|
|
8
|
+
import { applyValueSegments, fontWeight } from './RowText';
|
|
3
9
|
import { RowVisualStyle, type RowPrimitives } from './RowVisual';
|
|
4
10
|
type ColumnViews = {
|
|
5
11
|
body: HTMLElement;
|
|
6
12
|
primaryLine: HTMLElement;
|
|
7
13
|
primary: HTMLElement;
|
|
14
|
+
titleIcons: HTMLElement;
|
|
8
15
|
badges: HTMLElement;
|
|
9
16
|
secondaryLine: HTMLElement;
|
|
10
17
|
secondary: HTMLElement[];
|
|
@@ -13,6 +20,7 @@ type Views = {
|
|
|
13
20
|
favorite: HTMLElement;
|
|
14
21
|
index: HTMLElement;
|
|
15
22
|
controls: HTMLElement;
|
|
23
|
+
trailing: HTMLElement;
|
|
16
24
|
columns: ColumnViews[];
|
|
17
25
|
visual?: HTMLElement;
|
|
18
26
|
visualStyle?: RowVisualStyle;
|
|
@@ -43,6 +51,11 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
43
51
|
if (row.checkbox)
|
|
44
52
|
v.controls.appendChild(primitives.accessory(row.key, row.checkbox, 0));
|
|
45
53
|
v.controls.style.display = 'contents';
|
|
54
|
+
v.trailing.replaceChildren();
|
|
55
|
+
row.trailing?.forEach((accessory, index) =>
|
|
56
|
+
v.trailing.appendChild(primitives.accessory(row.key, accessory, index))
|
|
57
|
+
);
|
|
58
|
+
v.trailing.hidden = !row.trailing?.length;
|
|
46
59
|
v.index.style.cssText = '';
|
|
47
60
|
v.index.hidden = row.index === undefined;
|
|
48
61
|
v.index.textContent = String(row.index ?? '');
|
|
@@ -88,7 +101,41 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
88
101
|
cell.primaryLine.style.gap = `${style.titleBadgeGap}px`;
|
|
89
102
|
cell.primary.style.cssText = '';
|
|
90
103
|
cell.primary.textContent = column.text;
|
|
104
|
+
applyValueSegments(
|
|
105
|
+
cell.primary,
|
|
106
|
+
column.textSegments,
|
|
107
|
+
style?.columns?.fontSize ?? 14,
|
|
108
|
+
style?.columns?.lineHeight ?? 20,
|
|
109
|
+
fontWeight(style?.columns?.fontWeight, 500)
|
|
110
|
+
);
|
|
91
111
|
if (style?.columns) primitives.textStyle(cell.primary, style.columns);
|
|
112
|
+
cell.titleIcons.replaceChildren();
|
|
113
|
+
if (column.titleIcon || column.secondaryTitleIcon) {
|
|
114
|
+
cell.primary.style.minWidth = '0';
|
|
115
|
+
cell.primary.style.overflow = 'hidden';
|
|
116
|
+
cell.primary.style.textOverflow = 'ellipsis';
|
|
117
|
+
cell.primary.style.whiteSpace = 'nowrap';
|
|
118
|
+
[column.titleIcon, column.secondaryTitleIcon]
|
|
119
|
+
.filter((icon): icon is NonNullable<typeof icon> => icon !== undefined)
|
|
120
|
+
.forEach((descriptor) => {
|
|
121
|
+
const icon = primitives.iconAction(
|
|
122
|
+
descriptor.name,
|
|
123
|
+
undefined,
|
|
124
|
+
undefined,
|
|
125
|
+
descriptor.tintColor
|
|
126
|
+
);
|
|
127
|
+
icon.className = 'ok-native-list-identity-title-icon';
|
|
128
|
+
if (descriptor.hoverActionKey) {
|
|
129
|
+
setData(icon, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
130
|
+
setData(icon, 'nativeListIconHelp', true);
|
|
131
|
+
markActionAnchorSource(icon, 'leadingAction');
|
|
132
|
+
}
|
|
133
|
+
if (descriptor.accessibilityLabel)
|
|
134
|
+
icon.setAttribute('aria-label', descriptor.accessibilityLabel);
|
|
135
|
+
else icon.setAttribute('aria-hidden', 'true');
|
|
136
|
+
cell.titleIcons.appendChild(icon);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
92
139
|
cell.badges.replaceChildren();
|
|
93
140
|
cell.badges.style.display = 'contents';
|
|
94
141
|
if (column.key === 'asset')
|
|
@@ -107,25 +154,34 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
107
154
|
});
|
|
108
155
|
// Legacy Web layout: secondary leading text sits inline before the primary
|
|
109
156
|
// text; secondary text is a direct line below it, toned by secondaryTone.
|
|
110
|
-
|
|
111
|
-
? '
|
|
112
|
-
:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
157
|
+
const secondaryText = column.secondaryTextSegments?.length
|
|
158
|
+
? column.secondaryTextSegments.map((segment) => segment.text).join('')
|
|
159
|
+
: column.secondaryText;
|
|
160
|
+
cell.secondaryLine.style.display = secondaryText ? 'contents' : 'none';
|
|
161
|
+
[column.secondaryLeadingText, secondaryText].forEach((text, slot) => {
|
|
162
|
+
const label = cell.secondary[slot]!;
|
|
163
|
+
label.hidden = !text;
|
|
164
|
+
if (!text) label.remove();
|
|
165
|
+
else if (slot === 0) cell.primaryLine.insertBefore(label, cell.primary);
|
|
166
|
+
else cell.secondaryLine.appendChild(label);
|
|
167
|
+
label.style.cssText = '';
|
|
168
|
+
label.textContent = text ?? '';
|
|
169
|
+
if (slot === 1) {
|
|
170
|
+
applyValueSegments(
|
|
171
|
+
label,
|
|
172
|
+
column.secondaryTextSegments,
|
|
173
|
+
style?.columnSecondary?.fontSize ?? 12,
|
|
174
|
+
style?.columnSecondary?.lineHeight ?? 16,
|
|
175
|
+
fontWeight(style?.columnSecondary?.fontWeight, 400)
|
|
176
|
+
);
|
|
126
177
|
}
|
|
127
|
-
|
|
178
|
+
if (slot === 1)
|
|
179
|
+
label.style.color = tone(column.secondaryTone, 'secondary');
|
|
180
|
+
if (style?.columnSecondary)
|
|
181
|
+
primitives.textStyle(label, style.columnSecondary);
|
|
182
|
+
});
|
|
128
183
|
});
|
|
184
|
+
body.appendChild(v.trailing);
|
|
129
185
|
}
|
|
130
186
|
function create(document: Document, row: DataRow, primitives: RowPrimitives) {
|
|
131
187
|
const body = createElement(
|
|
@@ -140,6 +196,11 @@ function create(document: Document, row: DataRow, primitives: RowPrimitives) {
|
|
|
140
196
|
);
|
|
141
197
|
const favorite = createElement(document, 'span', 'ok-native-list-favorite');
|
|
142
198
|
const controls = createElement(document, 'span');
|
|
199
|
+
const trailing = createElement(
|
|
200
|
+
document,
|
|
201
|
+
'span',
|
|
202
|
+
'ok-native-list-accessories'
|
|
203
|
+
);
|
|
143
204
|
body.append(controls, index, favorite);
|
|
144
205
|
const columns = Array.from({ length: 4 }, () => {
|
|
145
206
|
const cell = createElement(document, 'span', 'ok-native-list-data-cell');
|
|
@@ -149,8 +210,10 @@ function create(document: Document, row: DataRow, primitives: RowPrimitives) {
|
|
|
149
210
|
'ok-native-list-data-primary'
|
|
150
211
|
);
|
|
151
212
|
const primary = tagSlot(createElement(document, 'span'), 'columns');
|
|
213
|
+
const titleIcons = createElement(document, 'span');
|
|
214
|
+
titleIcons.style.display = 'contents';
|
|
152
215
|
const badges = createElement(document, 'span');
|
|
153
|
-
primaryLine.append(primary, badges);
|
|
216
|
+
primaryLine.append(primary, titleIcons, badges);
|
|
154
217
|
const secondaryLine = createElement(
|
|
155
218
|
document,
|
|
156
219
|
'span',
|
|
@@ -169,15 +232,18 @@ function create(document: Document, row: DataRow, primitives: RowPrimitives) {
|
|
|
169
232
|
body: cell,
|
|
170
233
|
primaryLine,
|
|
171
234
|
primary,
|
|
235
|
+
titleIcons,
|
|
172
236
|
badges,
|
|
173
237
|
secondaryLine,
|
|
174
238
|
secondary,
|
|
175
239
|
};
|
|
176
240
|
});
|
|
241
|
+
body.appendChild(trailing);
|
|
177
242
|
views.set(body, {
|
|
178
243
|
favorite,
|
|
179
244
|
index,
|
|
180
245
|
controls,
|
|
246
|
+
trailing,
|
|
181
247
|
columns,
|
|
182
248
|
visualKey: '',
|
|
183
249
|
primitives,
|
|
@@ -196,6 +262,7 @@ function recycle(body: HTMLElement) {
|
|
|
196
262
|
v.visualStyle = undefined;
|
|
197
263
|
v.visualKey = '';
|
|
198
264
|
v.controls.replaceChildren();
|
|
265
|
+
v.trailing.replaceChildren();
|
|
199
266
|
}
|
|
200
267
|
export const dataRowRenderer = {
|
|
201
268
|
key: 'dataRow' as const,
|
|
@@ -204,7 +271,13 @@ export const dataRowRenderer = {
|
|
|
204
271
|
recycle,
|
|
205
272
|
// Legacy presets: table rows without secondary text are 8 units shorter.
|
|
206
273
|
measure: (row: DataRow, _width: number, layout?: string) => {
|
|
207
|
-
const secondary = row.columns.some((column) =>
|
|
274
|
+
const secondary = row.columns.some((column) =>
|
|
275
|
+
column.secondaryTextSegments?.length
|
|
276
|
+
? column.secondaryTextSegments.some(
|
|
277
|
+
(segment) => segment.text.length > 0
|
|
278
|
+
)
|
|
279
|
+
: !!column.secondaryText
|
|
280
|
+
);
|
|
208
281
|
return (secondary ? 60 : 56) + (layout === 'table' && !secondary ? -8 : 0);
|
|
209
282
|
},
|
|
210
283
|
measureRendered: (_body: HTMLElement, _row: DataRow): number | undefined =>
|
|
@@ -226,6 +226,163 @@ function createIdentityRow(
|
|
|
226
226
|
});
|
|
227
227
|
column.insertBefore(segments, titleElement.nextSibling);
|
|
228
228
|
}
|
|
229
|
+
if (row.titleIcon || row.secondaryTitleIcon || row.titleImage) {
|
|
230
|
+
const badgeLine = titleElement.querySelector<HTMLElement>(
|
|
231
|
+
':scope > .ok-native-list-badges'
|
|
232
|
+
);
|
|
233
|
+
const titleText = createElement(
|
|
234
|
+
document,
|
|
235
|
+
'span',
|
|
236
|
+
'ok-native-list-identity-title-text'
|
|
237
|
+
);
|
|
238
|
+
while (titleElement.firstChild && titleElement.firstChild !== badgeLine)
|
|
239
|
+
titleText.appendChild(titleElement.firstChild);
|
|
240
|
+
titleElement.prepend(titleText);
|
|
241
|
+
const icons = [row.titleIcon, row.secondaryTitleIcon]
|
|
242
|
+
.filter((icon): icon is NonNullable<typeof icon> => icon !== undefined)
|
|
243
|
+
.map((descriptor) => {
|
|
244
|
+
const icon = primitives.iconAction(
|
|
245
|
+
descriptor.name,
|
|
246
|
+
undefined,
|
|
247
|
+
undefined,
|
|
248
|
+
descriptor.tintColor
|
|
249
|
+
);
|
|
250
|
+
icon.className = 'ok-native-list-identity-title-icon';
|
|
251
|
+
if (descriptor.hoverActionKey) {
|
|
252
|
+
setData(icon, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
253
|
+
setData(icon, 'nativeListIconHelp', true);
|
|
254
|
+
markActionAnchorSource(icon, 'leadingAction');
|
|
255
|
+
}
|
|
256
|
+
if (descriptor.accessibilityLabel)
|
|
257
|
+
icon.setAttribute('aria-label', descriptor.accessibilityLabel);
|
|
258
|
+
else icon.setAttribute('aria-hidden', 'true');
|
|
259
|
+
return icon;
|
|
260
|
+
});
|
|
261
|
+
if (row.titleImage) {
|
|
262
|
+
const descriptor = row.titleImage;
|
|
263
|
+
const holder = createElement(
|
|
264
|
+
document,
|
|
265
|
+
'span',
|
|
266
|
+
'ok-native-list-identity-title-image'
|
|
267
|
+
);
|
|
268
|
+
Object.assign(holder.style, {
|
|
269
|
+
flex: `0 0 ${descriptor.image.width}px`,
|
|
270
|
+
width: `${descriptor.image.width}px`,
|
|
271
|
+
height: `${descriptor.image.height}px`,
|
|
272
|
+
borderRadius: '50%',
|
|
273
|
+
overflow: 'hidden',
|
|
274
|
+
});
|
|
275
|
+
const image = primitives.thumbnail(descriptor.image);
|
|
276
|
+
if (image) {
|
|
277
|
+
Object.assign(image.style, {
|
|
278
|
+
width: '100%',
|
|
279
|
+
height: '100%',
|
|
280
|
+
borderRadius: 'inherit',
|
|
281
|
+
objectFit:
|
|
282
|
+
descriptor.image.contentFit === 'center'
|
|
283
|
+
? 'none'
|
|
284
|
+
: descriptor.image.contentFit ?? 'cover',
|
|
285
|
+
});
|
|
286
|
+
image.setAttribute('alt', '');
|
|
287
|
+
holder.appendChild(image);
|
|
288
|
+
}
|
|
289
|
+
if (descriptor.hoverActionKey) {
|
|
290
|
+
setData(holder, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
291
|
+
setData(holder, 'nativeListIconHelp', true);
|
|
292
|
+
markActionAnchorSource(holder, 'leadingAction');
|
|
293
|
+
}
|
|
294
|
+
if (descriptor.accessibilityLabel) {
|
|
295
|
+
holder.setAttribute('role', 'img');
|
|
296
|
+
holder.setAttribute('aria-label', descriptor.accessibilityLabel);
|
|
297
|
+
} else holder.setAttribute('aria-hidden', 'true');
|
|
298
|
+
icons.push(holder);
|
|
299
|
+
}
|
|
300
|
+
titleText.after(...icons);
|
|
301
|
+
titleElement.style.display = 'flex';
|
|
302
|
+
titleElement.style.alignItems = 'center';
|
|
303
|
+
titleElement.style.gap = '4px';
|
|
304
|
+
}
|
|
305
|
+
if (row.titleSuffixes?.length) {
|
|
306
|
+
const badges = titleElement.querySelector(
|
|
307
|
+
':scope > .ok-native-list-badges'
|
|
308
|
+
);
|
|
309
|
+
let titleText = titleElement.querySelector<HTMLElement>(
|
|
310
|
+
':scope > .ok-native-list-identity-title-text, :scope > [data-nl-slot="title"]'
|
|
311
|
+
);
|
|
312
|
+
if (!titleText) {
|
|
313
|
+
titleText = tagSlot(
|
|
314
|
+
createElement(document, 'span', 'ok-native-list-identity-title-text'),
|
|
315
|
+
'title'
|
|
316
|
+
);
|
|
317
|
+
while (titleElement.firstChild && titleElement.firstChild !== badges)
|
|
318
|
+
titleText.appendChild(titleElement.firstChild);
|
|
319
|
+
titleElement.prepend(titleText);
|
|
320
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
321
|
+
} else if (titleElement.hasAttribute('data-nl-slot')) {
|
|
322
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
323
|
+
tagSlot(titleText, 'title');
|
|
324
|
+
}
|
|
325
|
+
titleElement.style.display = 'flex';
|
|
326
|
+
titleElement.style.alignItems = 'center';
|
|
327
|
+
titleText.style.flex = '0 1 auto';
|
|
328
|
+
titleText.style.minWidth = 'min(80px, 100%)';
|
|
329
|
+
titleText.style.overflow = 'hidden';
|
|
330
|
+
titleText.style.textOverflow = 'ellipsis';
|
|
331
|
+
titleText.style.whiteSpace = 'nowrap';
|
|
332
|
+
row.titleSuffixes.forEach((suffix) => {
|
|
333
|
+
const label = createElement(
|
|
334
|
+
document,
|
|
335
|
+
'span',
|
|
336
|
+
'ok-native-list-identity-title-suffix',
|
|
337
|
+
suffix.text
|
|
338
|
+
);
|
|
339
|
+
label.style.flex = '0 1 auto';
|
|
340
|
+
label.style.minWidth = '0';
|
|
341
|
+
label.style.marginInlineStart =
|
|
342
|
+
row.titleIcon || row.secondaryTitleIcon || row.titleImage
|
|
343
|
+
? '4px'
|
|
344
|
+
: '8px';
|
|
345
|
+
label.style.maxWidth =
|
|
346
|
+
suffix.maxWidth === undefined ? '' : `${suffix.maxWidth}px`;
|
|
347
|
+
label.style.overflow = 'hidden';
|
|
348
|
+
label.style.textOverflow = 'ellipsis';
|
|
349
|
+
label.style.whiteSpace = 'nowrap';
|
|
350
|
+
label.style.fontSize = '12px';
|
|
351
|
+
label.style.lineHeight = '16px';
|
|
352
|
+
label.style.fontWeight = '400';
|
|
353
|
+
label.style.fontFamily = 'var(--nl-font-regular)';
|
|
354
|
+
label.style.color =
|
|
355
|
+
suffix.tone === 'disabled'
|
|
356
|
+
? 'var(--nl-disabled)'
|
|
357
|
+
: 'var(--nl-secondary)';
|
|
358
|
+
titleElement.insertBefore(label, badges);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
if (
|
|
362
|
+
row.badges?.length &&
|
|
363
|
+
!row.titleIcon &&
|
|
364
|
+
!row.secondaryTitleIcon &&
|
|
365
|
+
!row.titleImage
|
|
366
|
+
) {
|
|
367
|
+
const titleText = titleElement.querySelector<HTMLElement>(
|
|
368
|
+
':scope > [data-nl-slot="title"]'
|
|
369
|
+
);
|
|
370
|
+
const badges = titleElement.querySelector<HTMLElement>(
|
|
371
|
+
':scope > .ok-native-list-badges'
|
|
372
|
+
);
|
|
373
|
+
titleElement.style.display = 'flex';
|
|
374
|
+
titleElement.style.alignItems = 'center';
|
|
375
|
+
if (titleText) {
|
|
376
|
+
titleText.style.flex = '0 1 auto';
|
|
377
|
+
titleText.style.minWidth = row.titleSuffixes?.length
|
|
378
|
+
? 'min(80px, 100%)'
|
|
379
|
+
: '0';
|
|
380
|
+
}
|
|
381
|
+
if (badges) {
|
|
382
|
+
badges.style.flex = '0 1 auto';
|
|
383
|
+
badges.style.minWidth = '0';
|
|
384
|
+
}
|
|
385
|
+
}
|
|
229
386
|
if (presentation === 'walletSidebar' && row.badges?.length) {
|
|
230
387
|
const badges = createElement(
|
|
231
388
|
document,
|
|
@@ -242,7 +399,13 @@ function createIdentityRow(
|
|
|
242
399
|
if (lines !== undefined)
|
|
243
400
|
column
|
|
244
401
|
.querySelectorAll<HTMLElement>(`[data-nl-slot="${key}"]`)
|
|
245
|
-
.forEach((text) =>
|
|
402
|
+
.forEach((text) =>
|
|
403
|
+
applyTextLayout(
|
|
404
|
+
text,
|
|
405
|
+
lines === 0 ? {} : { lines },
|
|
406
|
+
lines === 0 ? 0 : undefined
|
|
407
|
+
)
|
|
408
|
+
);
|
|
246
409
|
}
|
|
247
410
|
}
|
|
248
411
|
body.appendChild(column);
|
|
@@ -272,6 +435,29 @@ function applyIdentityStyle(body: HTMLElement, row: IdentityRow) {
|
|
|
272
435
|
const leading = body.querySelector<HTMLElement>(
|
|
273
436
|
':scope > .ok-native-list-visual, :scope > .ok-native-list-stacked'
|
|
274
437
|
);
|
|
438
|
+
if (row.style?.leadingContentMaxWidthRatio !== undefined && !vertical) {
|
|
439
|
+
const column = body.querySelector<HTMLElement>(
|
|
440
|
+
':scope > .ok-native-list-flex'
|
|
441
|
+
);
|
|
442
|
+
const trailing = body.querySelector<HTMLElement>(
|
|
443
|
+
':scope > .ok-native-list-accessories'
|
|
444
|
+
);
|
|
445
|
+
const visualWidth = leading
|
|
446
|
+
? row.style.image?.width ??
|
|
447
|
+
(row.presentation === 'accountSelector' ||
|
|
448
|
+
row.presentation === 'networkSelector'
|
|
449
|
+
? 32
|
|
450
|
+
: 40)
|
|
451
|
+
: 0;
|
|
452
|
+
const gap = leading ? row.style.leadingGap ?? 12 : 0;
|
|
453
|
+
if (column) {
|
|
454
|
+
column.style.flex = '0 1 auto';
|
|
455
|
+
column.style.maxWidth = `calc(${
|
|
456
|
+
row.style.leadingContentMaxWidthRatio * 100
|
|
457
|
+
}% - ${visualWidth + gap}px)`;
|
|
458
|
+
}
|
|
459
|
+
if (trailing) trailing.style.marginInlineStart = 'auto';
|
|
460
|
+
}
|
|
275
461
|
const defaultGap =
|
|
276
462
|
body.style.gap ||
|
|
277
463
|
(row.type === 'identity' && row.presentation === 'walletSidebar'
|
|
@@ -343,7 +529,7 @@ function applyIdentityStyle(body: HTMLElement, row: IdentityRow) {
|
|
|
343
529
|
const images = leading.matches('img')
|
|
344
530
|
? [leading]
|
|
345
531
|
: leading.querySelectorAll<HTMLElement>(
|
|
346
|
-
':scope > img, :scope > .ok-native-list-visual-fallback'
|
|
532
|
+
':scope > img:not(.ok-native-list-visual-corner), :scope > .ok-native-list-visual-fallback:not(.ok-native-list-visual-corner)'
|
|
347
533
|
);
|
|
348
534
|
images.forEach((bitmap) => {
|
|
349
535
|
if (bitmap !== leading) {
|
|
@@ -373,6 +559,7 @@ type Views = {
|
|
|
373
559
|
node: HTMLElement;
|
|
374
560
|
defaults: RowVisualStyle;
|
|
375
561
|
};
|
|
562
|
+
titleImage?: { key: string; node: HTMLElement };
|
|
376
563
|
primitives: RowPrimitives;
|
|
377
564
|
};
|
|
378
565
|
const views = new WeakMap<HTMLElement, Views>();
|
|
@@ -380,10 +567,21 @@ function bind(body: HTMLElement, row: IdentityRow, primitives: RowPrimitives) {
|
|
|
380
567
|
const v = views.get(body)!;
|
|
381
568
|
v.primitives = primitives;
|
|
382
569
|
let used = false;
|
|
570
|
+
let usedTitleImage = false;
|
|
383
571
|
const next = createIdentityRow(
|
|
384
572
|
body.ownerDocument,
|
|
385
573
|
{
|
|
386
574
|
...primitives,
|
|
575
|
+
thumbnail: (source) => {
|
|
576
|
+
usedTitleImage = true;
|
|
577
|
+
const key = JSON.stringify([row.key, source]);
|
|
578
|
+
if (v.titleImage?.key !== key) {
|
|
579
|
+
if (v.titleImage) primitives.dispose(v.titleImage.node);
|
|
580
|
+
const node = primitives.thumbnail(source);
|
|
581
|
+
v.titleImage = node ? { key, node } : undefined;
|
|
582
|
+
}
|
|
583
|
+
return v.titleImage?.node;
|
|
584
|
+
},
|
|
387
585
|
visual: (source, presentation) => {
|
|
388
586
|
used = true;
|
|
389
587
|
const key = JSON.stringify([row.key, source, presentation]);
|
|
@@ -410,6 +608,10 @@ function bind(body: HTMLElement, row: IdentityRow, primitives: RowPrimitives) {
|
|
|
410
608
|
primitives.dispose(v.visual.node);
|
|
411
609
|
v.visual = undefined;
|
|
412
610
|
}
|
|
611
|
+
if (!usedTitleImage && v.titleImage) {
|
|
612
|
+
primitives.dispose(v.titleImage.node);
|
|
613
|
+
v.titleImage = undefined;
|
|
614
|
+
}
|
|
413
615
|
body.replaceChildren(...Array.from(next.childNodes));
|
|
414
616
|
body.className = next.className;
|
|
415
617
|
body.style.cssText = next.style.cssText;
|
|
@@ -500,7 +702,11 @@ function create(
|
|
|
500
702
|
function recycle(body: HTMLElement) {
|
|
501
703
|
const v = views.get(body);
|
|
502
704
|
if (v?.visual) v.primitives.dispose(v.visual.node);
|
|
503
|
-
if (v) v.
|
|
705
|
+
if (v?.titleImage) v.primitives.dispose(v.titleImage.node);
|
|
706
|
+
if (v) {
|
|
707
|
+
v.visual = undefined;
|
|
708
|
+
v.titleImage = undefined;
|
|
709
|
+
}
|
|
504
710
|
body.replaceChildren();
|
|
505
711
|
}
|
|
506
712
|
export const identityRowRenderer = {
|
|
@@ -522,7 +728,12 @@ export const identityRowRenderer = {
|
|
|
522
728
|
? 60
|
|
523
729
|
: 56,
|
|
524
730
|
measureRendered: (
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
): number | undefined =>
|
|
731
|
+
body: HTMLElement,
|
|
732
|
+
row: IdentityRow
|
|
733
|
+
): number | undefined => {
|
|
734
|
+
if (row.contentHeight !== 'auto' || hasExplicitRowHeight(row))
|
|
735
|
+
return undefined;
|
|
736
|
+
const height = body.getBoundingClientRect().height;
|
|
737
|
+
return height > 0 ? height : undefined;
|
|
738
|
+
},
|
|
528
739
|
};
|
|
@@ -198,8 +198,18 @@ function createMarketRow(
|
|
|
198
198
|
? 'none'
|
|
199
199
|
: style?.image?.contentFit ?? image.style.objectFit;
|
|
200
200
|
} else {
|
|
201
|
-
image.style.width =
|
|
202
|
-
|
|
201
|
+
image.style.width =
|
|
202
|
+
String(
|
|
203
|
+
row.leading.kind === 'token'
|
|
204
|
+
? row.leading.networkImage?.width ?? 16
|
|
205
|
+
: 16
|
|
206
|
+
) + 'px';
|
|
207
|
+
image.style.height =
|
|
208
|
+
String(
|
|
209
|
+
row.leading.kind === 'token'
|
|
210
|
+
? row.leading.networkImage?.height ?? 16
|
|
211
|
+
: 16
|
|
212
|
+
) + 'px';
|
|
203
213
|
if (borderColor) {
|
|
204
214
|
image.style.right = '-5px';
|
|
205
215
|
image.style.bottom = '-5px';
|
|
@@ -314,8 +324,14 @@ function createMarketRow(
|
|
|
314
324
|
weight: 400,
|
|
315
325
|
alignment: 'start',
|
|
316
326
|
});
|
|
327
|
+
if (row.subtitlePrefix.hoverActionKey) {
|
|
328
|
+
prefix.dataset.nativeListHoverAction =
|
|
329
|
+
row.subtitlePrefix.hoverActionKey;
|
|
330
|
+
prefix.dataset.nativeListAnchorSource = 'row';
|
|
331
|
+
prefix.tabIndex = 0;
|
|
332
|
+
}
|
|
317
333
|
prefix.style.display = 'block';
|
|
318
|
-
prefix.style.flex = '
|
|
334
|
+
prefix.style.flex = '0 1 auto';
|
|
319
335
|
prefix.style.minWidth = '0';
|
|
320
336
|
prefix.style.overflow = 'hidden';
|
|
321
337
|
prefix.style.textOverflow = 'ellipsis';
|