@onekeyfe/react-native-native-list 6.7.0-alpha.324 → 6.7.0-alpha.335

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +1 -1
  2. package/docs/SPEC.md +405 -11
  3. package/ios/HybridNativeList.swift +11 -3
  4. package/ios/RNCNativeListView.swift +10 -6
  5. package/ios/tests/NativeListLifecycleTests.swift +28 -0
  6. package/lib/module/NativeList.js +4 -2
  7. package/lib/module/NativeList.web.js +140 -29
  8. package/lib/module/ScrollEdgeEffect.js +8 -0
  9. package/lib/module/index.js +1 -0
  10. package/lib/module/validation.js +143 -34
  11. package/lib/module/web/NativeListWebEngine.js +356 -62
  12. package/lib/module/web/templates/ActivityRowRenderer.js +484 -5
  13. package/lib/module/web/templates/MarketRowRenderer.js +8 -3
  14. package/lib/module/web/templates/MarketTableRowRenderer.js +577 -0
  15. package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
  16. package/lib/module/web/templates/RowRendererRegistry.js +5 -3
  17. package/lib/module/web/templates/SectionHeaderRowRenderer.js +34 -1
  18. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +10 -6
  19. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -2
  20. package/lib/nitrogen/generated/android/c++/JNativeListScrollEdgeEffect.hpp +61 -0
  21. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +3 -3
  22. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +1 -1
  23. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollEdgeEffect.kt +24 -0
  24. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +3 -0
  25. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +8 -4
  26. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +4 -4
  27. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -1
  28. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +3 -3
  29. package/lib/nitrogen/generated/ios/swift/NativeListScrollEdgeEffect.swift +44 -0
  30. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -2
  31. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +5 -2
  32. package/lib/nitrogen/generated/shared/c++/NativeListScrollEdgeEffect.hpp +80 -0
  33. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -2
  34. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +4 -3
  35. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +1 -1
  36. package/lib/typescript/src/NativeList.nitro.d.ts +2 -1
  37. package/lib/typescript/src/NativeList.types.d.ts +14 -3
  38. package/lib/typescript/src/NativeList.web.d.ts +2 -2
  39. package/lib/typescript/src/ScrollEdgeEffect.d.ts +5 -0
  40. package/lib/typescript/src/index.d.ts +1 -0
  41. package/lib/typescript/src/models.d.ts +71 -1
  42. package/lib/typescript/src/web/NativeListWebEngine.d.ts +26 -1
  43. package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
  44. package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
  45. package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
  46. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +1 -1
  47. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
  48. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +10 -6
  49. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -2
  50. package/nitrogen/generated/android/c++/JNativeListScrollEdgeEffect.hpp +61 -0
  51. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +3 -3
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +1 -1
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollEdgeEffect.kt +24 -0
  54. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +3 -0
  55. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +8 -4
  56. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +4 -4
  57. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -1
  58. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +3 -3
  59. package/nitrogen/generated/ios/swift/NativeListScrollEdgeEffect.swift +44 -0
  60. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -2
  61. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +5 -2
  62. package/nitrogen/generated/shared/c++/NativeListScrollEdgeEffect.hpp +80 -0
  63. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -2
  64. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +4 -3
  65. package/nitrogen/generated/shared/json/NativeListConfig.json +1 -1
  66. package/package.json +3 -3
  67. package/react-native-native-list.podspec +4 -1
  68. package/src/NativeList.nitro.ts +3 -1
  69. package/src/NativeList.tsx +6 -2
  70. package/src/NativeList.types.ts +15 -3
  71. package/src/NativeList.web.tsx +191 -38
  72. package/src/ScrollEdgeEffect.ts +4 -0
  73. package/src/index.ts +2 -0
  74. package/src/models.ts +93 -0
  75. package/src/validation.ts +348 -58
  76. package/src/web/NativeListWebEngine.ts +603 -95
  77. package/src/web/templates/ActivityRowRenderer.ts +723 -7
  78. package/src/web/templates/MarketRowRenderer.ts +19 -3
  79. package/src/web/templates/MarketTableRowRenderer.ts +755 -0
  80. package/src/web/templates/MediaTileRowRenderer.ts +313 -5
  81. package/src/web/templates/RowRendererRegistry.ts +10 -5
  82. package/src/web/templates/SectionHeaderRowRenderer.ts +42 -1
@@ -2,8 +2,9 @@
2
2
 
3
3
  import { createElement, tagSlot, markActionAnchorSource } from "./RowElements.js";
4
4
  import { RowVisualStyle } from "./RowVisual.js";
5
+ import { applyTextWeight, applyValueSegments } from "./RowText.js";
5
6
  const views = new WeakMap();
6
- function bind(body, row, primitives) {
7
+ function bindLegacy(body, row, primitives) {
7
8
  const v = views.get(body);
8
9
  v.primitives = primitives;
9
10
  body.style.cssText = '';
@@ -45,7 +46,7 @@ function bind(body, row, primitives) {
45
46
  v.actions.appendChild(button);
46
47
  });
47
48
  }
48
- function create(document, row, primitives) {
49
+ function createLegacy(document, row, primitives) {
49
50
  const body = createElement(document, 'div', 'ok-native-list-row ok-native-list-standard');
50
51
  body.dataset.nlRenderer = 'activity';
51
52
  const column = createElement(document, 'span', 'ok-native-list-flex');
@@ -69,10 +70,10 @@ function create(document, row, primitives) {
69
70
  visualKey: '',
70
71
  primitives
71
72
  });
72
- bind(body, row, primitives);
73
+ bindLegacy(body, row, primitives);
73
74
  return body;
74
75
  }
75
- function recycle(body) {
76
+ function recycleLegacy(body) {
76
77
  const v = views.get(body);
77
78
  if (!v) return;
78
79
  v.visuals.forEach(node => {
@@ -84,12 +85,490 @@ function recycle(body) {
84
85
  v.visualKey = '';
85
86
  v.actions.replaceChildren();
86
87
  }
88
+ const histories = new WeakMap();
89
+ const isHistory = row => row.presentation !== undefined || row.amounts !== undefined;
90
+ const ellipsis = 'min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;';
91
+ function valueText(node, text, segments, size, line, weight) {
92
+ node.textContent = text ?? '';
93
+ applyTextWeight(node, weight);
94
+ applyValueSegments(node, segments, size, line, weight);
95
+ }
96
+ function createHistory(body, primitives) {
97
+ const document = body.ownerDocument;
98
+ const node = name => createElement(document, 'div', `ok-native-list-history-${name}`);
99
+ const content = node('content');
100
+ const identity = node('identity');
101
+ const visual = node('visual');
102
+ const text = node('text');
103
+ const titleLine = node('title-line');
104
+ const title = tagSlot(node('title'), 'title');
105
+ const badges = node('badges');
106
+ const description = node('description');
107
+ description.dataset.nlSlot = 'description';
108
+ const descriptionTime = createElement(document, 'span');
109
+ const descriptionDot = createElement(document, 'span', undefined, '•');
110
+ const descriptionAddress = createElement(document, 'button');
111
+ descriptionAddress.type = 'button';
112
+ description.append(descriptionTime, descriptionDot, descriptionAddress);
113
+ const amounts = node('amounts');
114
+ const fee = node('fee');
115
+ const feeLabel = node('fee-label');
116
+ const feeValues = node('fee-values');
117
+ const feePrimary = node('fee-primary');
118
+ const feeSecondary = node('fee-secondary');
119
+ const actions = node('actions');
120
+ titleLine.append(title, badges);
121
+ text.append(titleLine, description);
122
+ identity.append(visual, text);
123
+ feeValues.append(feePrimary, feeSecondary);
124
+ fee.append(feeLabel, feeValues);
125
+ content.append(identity, amounts, fee);
126
+ body.replaceChildren(content, actions);
127
+ const v = {
128
+ content,
129
+ identity,
130
+ visual,
131
+ text,
132
+ titleLine,
133
+ title,
134
+ badges,
135
+ description,
136
+ descriptionTime,
137
+ descriptionDot,
138
+ descriptionAddress,
139
+ amounts,
140
+ amountRows: new Map(),
141
+ fee,
142
+ feeLabel,
143
+ feeValues,
144
+ feePrimary,
145
+ feeSecondary,
146
+ actions,
147
+ actionButtons: new Map(),
148
+ visualKey: '',
149
+ visuals: [],
150
+ primitives
151
+ };
152
+ histories.set(body, v);
153
+ return v;
154
+ }
155
+ const historyIconPaths = {
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
+ };
167
+ function historyIcon(node, source, size) {
168
+ const name = source?.kind === 'icon' ? source.name : source?.kind === 'token' ? source.fallbackIcon?.name : undefined;
169
+ const paths = name && historyIconPaths[name];
170
+ if (!paths) return;
171
+ const placeholder = node.querySelector('.ok-native-list-visual-fallback');
172
+ if (!placeholder && source && 'image' in source && source.image) return;
173
+ const fallback = placeholder ?? node;
174
+ Object.assign(fallback.style, {
175
+ display: 'flex',
176
+ alignItems: 'center',
177
+ justifyContent: 'center',
178
+ width: '100%',
179
+ height: '100%'
180
+ });
181
+ 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.createElementNS('http://www.w3.org/2000/svg', 'svg');
183
+ svg.setAttribute('viewBox', '0 0 24 24');
184
+ svg.setAttribute('width', String(size));
185
+ 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
+ fallback.replaceChildren(svg);
195
+ }
196
+ function bindHistory(body, row, primitives) {
197
+ const v = histories.get(body) ?? createHistory(body, primitives);
198
+ v.primitives = primitives;
199
+ const table = row.presentation === 'table';
200
+ const footer = Boolean(row.footerActions?.length);
201
+ body.className = 'ok-native-list-row ok-native-list-history';
202
+ body.style.cssText = '';
203
+ body.removeAttribute('data-nl-container-background');
204
+ body.removeAttribute('data-nl-container-border');
205
+ Object.assign(body.style, {
206
+ display: 'flex',
207
+ flexDirection: 'column',
208
+ alignItems: 'stretch',
209
+ justifyContent: 'flex-start',
210
+ width: 'calc(100% - 16px)',
211
+ margin: '0 8px',
212
+ padding: `${table ? 12 : 8}px 12px`,
213
+ height: !table && !footer && row.height !== 60 ? 'calc(100% - 8px)' : '100%',
214
+ borderRadius: '12px',
215
+ gap: '8px'
216
+ });
217
+ Object.assign(v.content.style, {
218
+ display: 'flex',
219
+ alignItems: 'center',
220
+ gap: '12px',
221
+ minWidth: '0',
222
+ width: '100%'
223
+ });
224
+ Object.assign(v.identity.style, {
225
+ display: 'flex',
226
+ alignItems: 'center',
227
+ gap: '12px',
228
+ minWidth: '0',
229
+ flex: '1 1 0'
230
+ });
231
+ Object.assign(v.visual.style, {
232
+ position: 'relative',
233
+ width: '40px',
234
+ height: '40px',
235
+ flex: '0 0 40px'
236
+ });
237
+ const visualKey = JSON.stringify([row.key, row.leading, row.secondaryLeading]);
238
+ if (v.visualKey !== visualKey) {
239
+ Array.from(v.visual.children).forEach(n => primitives.dispose(n));
240
+ v.visual.replaceChildren();
241
+ v.visuals = [];
242
+ const sources = [row.leading, row.secondaryLeading].filter(Boolean);
243
+ sources.forEach(source => {
244
+ const visual = primitives.visual(source);
245
+ if (!visual) return;
246
+ historyIcon(visual, source, table || sources.length > 1 ? 24 : 28);
247
+ const retained = {
248
+ node: visual,
249
+ style: new RowVisualStyle(visual),
250
+ background: visual.style.background,
251
+ loaded: false
252
+ };
253
+ // Only placeholder-backed sources restore their frame background on load.
254
+ const image = source && 'image' in source ? source.image : undefined;
255
+ if (image?.loadingStrategy && image.loadingStrategy !== 'none') {
256
+ visual.querySelector('.ok-native-list-visual-main')?.addEventListener('load', () => {
257
+ retained.background = source && 'backgroundColor' in source && source.backgroundColor ? source.backgroundColor : 'transparent';
258
+ retained.loaded = true;
259
+ });
260
+ }
261
+ v.visuals.push(retained);
262
+ v.visual.append(visual);
263
+ });
264
+ v.visualKey = visualKey;
265
+ }
266
+ const sources = [row.leading, row.secondaryLeading].filter(Boolean);
267
+ v.visuals.forEach((retained, index) => {
268
+ const {
269
+ node: visual,
270
+ style,
271
+ background,
272
+ loaded
273
+ } = retained;
274
+ const source = sources[index];
275
+ const previousToken = visual.querySelector(':scope > .ok-native-list-history-token');
276
+ if (previousToken) {
277
+ visual.append(...Array.from(previousToken.children));
278
+ previousToken.remove();
279
+ }
280
+ const currentFallback = visual.querySelector(':scope > .ok-native-list-visual-fallback:not(.ok-native-list-visual-corner)');
281
+ if (currentFallback && retained.fallback !== currentFallback) {
282
+ retained.fallback = currentFallback;
283
+ retained.fallbackStyle = new RowVisualStyle(currentFallback);
284
+ }
285
+ // A terminal image error creates a new fallback node after the factory bind.
286
+ retained.fallbackStyle?.restore();
287
+ const size = sources.length > 1 ? index ? 28 : 24 : 40;
288
+ style.apply(row.style?.image, size, size, 0);
289
+ Object.assign(visual.style, {
290
+ background,
291
+ position: '',
292
+ left: '',
293
+ top: ''
294
+ });
295
+ const svg = visual.querySelector('.ok-native-list-visual-fallback > svg');
296
+ if (svg) {
297
+ const iconSize = String(table || sources.length > 1 ? 24 : 28);
298
+ svg.setAttribute('width', iconSize);
299
+ svg.setAttribute('height', iconSize);
300
+ }
301
+ Object.assign(visual.style, {
302
+ display: 'inline-flex',
303
+ alignItems: 'center',
304
+ justifyContent: 'center'
305
+ });
306
+ if (sources.length > 1) Object.assign(visual.style, {
307
+ position: 'absolute',
308
+ left: index ? '12px' : '0',
309
+ top: index ? '12px' : '0',
310
+ border: index ? '2px solid var(--nl-row)' : '0',
311
+ boxSizing: 'border-box'
312
+ });
313
+ if (!table && sources.length > 1) {
314
+ const token = visual.ownerDocument.createElement('span');
315
+ token.className = 'ok-native-list-history-token';
316
+ Object.assign(token.style, {
317
+ display: 'flex',
318
+ alignItems: 'center',
319
+ justifyContent: 'center',
320
+ position: 'relative',
321
+ width: '24px',
322
+ height: '24px',
323
+ flex: '0 0 24px',
324
+ borderRadius: 'inherit',
325
+ boxSizing: 'border-box',
326
+ overflow: 'hidden',
327
+ background: source && 'backgroundColor' in source ? source.backgroundColor ?? '' : '',
328
+ border: source && 'borderColor' in source && source.borderColor ? `1px solid ${source.borderColor}` : '0'
329
+ });
330
+ token.append(...Array.from(visual.children).filter(child => !child.classList.contains('ok-native-list-visual-corner')));
331
+ const fallback = token.querySelector(':scope > .ok-native-list-visual-fallback');
332
+ if (fallback) {
333
+ fallback.style.width = '24px';
334
+ fallback.style.height = '24px';
335
+ fallback.style.flexShrink = '0';
336
+ }
337
+ const mainImage = token.querySelector(':scope > .ok-native-list-visual-main');
338
+ if (mainImage) {
339
+ mainImage.style.width = '100%';
340
+ mainImage.style.height = '100%';
341
+ }
342
+ visual.append(token);
343
+ }
344
+ if (table) {
345
+ visual.style.background = loaded ? background : source && 'backgroundColor' in source && source.backgroundColor ? source.backgroundColor : 'var(--nl-strong)';
346
+ const borderColor = source && 'borderColor' in source && source.borderColor ? source.borderColor : 'var(--nl-separator)';
347
+ visual.style.border = `1px solid ${borderColor}`;
348
+ visual.style.boxSizing = 'border-box';
349
+ } else if (sources.length === 1 && source?.kind === 'token') {
350
+ visual.style.border = source.borderColor ? `1px solid ${source.borderColor}` : '0';
351
+ visual.style.boxSizing = 'border-box';
352
+ const mainImage = visual.querySelector(':scope > .ok-native-list-visual-main');
353
+ if (mainImage) {
354
+ mainImage.style.width = '100%';
355
+ mainImage.style.height = '100%';
356
+ }
357
+ }
358
+ });
359
+ Object.assign(v.text.style, {
360
+ minWidth: '0',
361
+ flex: '1 1 auto',
362
+ display: 'flex',
363
+ flexDirection: 'column',
364
+ gap: table ? '4px' : '0'
365
+ });
366
+ Object.assign(v.titleLine.style, {
367
+ display: 'flex',
368
+ alignItems: 'center',
369
+ minWidth: '0'
370
+ });
371
+ v.title.style.cssText = ellipsis + `font-size:${table ? 14 : 16}px;line-height:${table ? 20 : 24}px;font-weight:500;`;
372
+ v.title.textContent = row.title;
373
+ applyTextWeight(v.title, 500);
374
+ if (row.style?.title) primitives.textStyle(v.title, row.style.title);
375
+ v.badges.style.cssText = 'display:flex;flex:0 0 auto;gap:8px;margin-left:8px';
376
+ v.badges.replaceChildren();
377
+ for (const badge of row.badges ?? []) {
378
+ const element = createElement(body.ownerDocument, 'span', 'ok-native-list-badge', badge.text);
379
+ element.dataset.tone = badge.tone ?? '';
380
+ element.style.cssText = 'height:20px;font-size:12px;line-height:16px;padding:2px 8px;border-radius:4px;box-sizing:border-box';
381
+ applyTextWeight(element, 500);
382
+ if (badge.tone === 'neutral') Object.assign(element.style, {
383
+ background: 'var(--nl-strong)',
384
+ color: 'var(--nl-secondary)'
385
+ });
386
+ if (badge.tone === 'warning') Object.assign(element.style, {
387
+ background: 'var(--nl-caution-background,color-mix(in srgb,var(--nl-caution) 12%,transparent))',
388
+ color: 'var(--nl-caution)'
389
+ });
390
+ v.badges.append(element);
391
+ }
392
+ v.badges.style.display = row.badges?.length ? 'flex' : 'none';
393
+ v.description.style.cssText = ellipsis + 'display:flex;max-width:100%;color:var(--nl-secondary);font-family:inherit;font-size:14px;line-height:20px;font-weight:400;font-variant-numeric:tabular-nums;';
394
+ applyTextWeight(v.description, 400);
395
+ const split = row.description?.indexOf(' • ') ?? -1;
396
+ v.descriptionTime.textContent = split >= 0 ? row.description.slice(0, split) : '';
397
+ v.descriptionTime.style.display = split >= 0 ? 'inline' : 'none';
398
+ v.descriptionTime.style.flexShrink = '0';
399
+ v.descriptionDot.style.cssText = `flex-shrink:0;margin:0 4px;display:${split >= 0 ? 'inline' : 'none'}`;
400
+ v.descriptionAddress.style.cssText = ellipsis + 'appearance:none;display:block;max-width:100%;border:0;padding:0;background:transparent;text-align:left;color:inherit;font:inherit;font-variant-numeric:inherit;';
401
+ v.descriptionAddress.textContent = split >= 0 ? row.description.slice(split + 3) : row.description ?? '';
402
+ v.description.style.display = row.description ? 'flex' : 'none';
403
+ v.descriptionAddress.tabIndex = row.descriptionActionKey ? 0 : -1;
404
+ if (row.descriptionActionKey) {
405
+ v.descriptionAddress.dataset.nativeListAction = row.descriptionActionKey;
406
+ markActionAnchorSource(v.descriptionAddress, 'description');
407
+ v.descriptionAddress.style.cursor = 'pointer';
408
+ } else {
409
+ delete v.descriptionAddress.dataset.nativeListAction;
410
+ delete v.descriptionAddress.dataset.nativeListAnchorSource;
411
+ v.descriptionAddress.style.cursor = 'inherit';
412
+ }
413
+ if (row.style?.description) primitives.textStyle(v.description, row.style.description);
414
+ v.description.style.display = row.description ? 'flex' : 'none';
415
+ Object.assign(v.amounts.style, {
416
+ display: 'flex',
417
+ flexDirection: 'column',
418
+ minWidth: '0',
419
+ gap: table ? '4px' : '0',
420
+ flex: table ? '1 1 0' : '0 1 auto',
421
+ maxWidth: table ? '50%' : '50%',
422
+ alignItems: table ? 'stretch' : 'flex-end',
423
+ alignSelf: table ? 'stretch' : 'center'
424
+ });
425
+ const amountKeys = new Set();
426
+ for (const amount of row.amounts ?? []) {
427
+ amountKeys.add(amount.key);
428
+ let view = v.amountRows.get(amount.key);
429
+ if (!view) {
430
+ const element = createElement(body.ownerDocument, 'div');
431
+ const primary = tagSlot(createElement(body.ownerDocument, 'span'), 'primaryAmount');
432
+ const secondary = tagSlot(createElement(body.ownerDocument, 'span'), 'secondaryAmount');
433
+ element.append(primary, secondary);
434
+ view = {
435
+ element,
436
+ primary,
437
+ secondary,
438
+ visualKey: ''
439
+ };
440
+ v.amountRows.set(amount.key, view);
441
+ }
442
+ view.element.style.cssText = `display:flex;align-items:center;gap:4px;min-width:0;max-width:100%;${table ? '' : 'justify-content:flex-end;'}`;
443
+ const secondary = amount.tone === 'secondary';
444
+ const size = table || secondary ? 14 : 16;
445
+ const line = table || secondary ? 20 : 24;
446
+ const weight = table || secondary ? 400 : 500;
447
+ view.primary.style.cssText = ellipsis + `font-size:${size}px;line-height:${line}px;font-weight:${weight};color:${amount.tone === 'positive' ? 'var(--nl-positive)' : amount.tone === 'negative' ? 'var(--nl-negative)' : secondary ? 'var(--nl-secondary)' : 'var(--nl-primary)'};`;
448
+ valueText(view.primary, amount.text, amount.textSegments, size, line, weight);
449
+ const roleStyle = secondary ? row.style?.secondaryAmount : row.style?.primaryAmount;
450
+ if (roleStyle) primitives.textStyle(view.primary, roleStyle);
451
+ view.secondary.style.cssText = ellipsis + 'font-size:14px;line-height:20px;font-weight:400;color:var(--nl-secondary);';
452
+ valueText(view.secondary, amount.secondaryText, amount.secondaryTextSegments, 14, 20, 400);
453
+ view.secondary.hidden = !table || !amount.secondaryText;
454
+ const amountVisualKey = JSON.stringify(table ? amount.leading : undefined);
455
+ if (view.visualKey !== amountVisualKey) {
456
+ if (view.visual) {
457
+ primitives.dispose(view.visual);
458
+ view.visual.remove();
459
+ }
460
+ view.visual = table ? primitives.visual(amount.leading) : undefined;
461
+ if (view.visual) {
462
+ new RowVisualStyle(view.visual).apply({
463
+ width: 20,
464
+ height: 20
465
+ }, 20, 20, 0);
466
+ historyIcon(view.visual, amount.leading, 16);
467
+ if (amount.leading?.kind === 'token' && amount.leading.image) {
468
+ view.visual.style.border = amount.leading.borderColor ? `1px solid ${amount.leading.borderColor}` : '0';
469
+ view.visual.style.boxSizing = 'border-box';
470
+ }
471
+ view.element.prepend(view.visual);
472
+ }
473
+ view.visualKey = amountVisualKey;
474
+ }
475
+ v.amounts.append(view.element);
476
+ }
477
+ for (const [key, view] of v.amountRows) {
478
+ if (!amountKeys.has(key)) {
479
+ if (view.visual) primitives.dispose(view.visual);
480
+ view.element.remove();
481
+ v.amountRows.delete(key);
482
+ }
483
+ }
484
+ v.fee.style.cssText = 'display:flex;flex-direction:column;flex:.6 1 0;min-width:0;gap:4px';
485
+ v.fee.hidden = !table || !row.fee;
486
+ v.fee.style.display = table && row.fee ? 'flex' : 'none';
487
+ v.fee.style.opacity = row.fee?.hidden ? '0' : '1';
488
+ v.feeLabel.style.cssText = 'font-size:14px;line-height:20px;color:var(--nl-secondary);';
489
+ v.feeLabel.textContent = row.fee?.label ?? '';
490
+ applyTextWeight(v.feeLabel, 400);
491
+ v.feeValues.style.cssText = 'display:flex;align-items:center;gap:4px;min-width:0';
492
+ v.feePrimary.style.cssText = ellipsis + 'font-size:14px;line-height:20px;font-weight:400;';
493
+ v.feeSecondary.style.cssText = ellipsis + 'font-size:14px;line-height:20px;font-weight:400;color:var(--nl-secondary);';
494
+ valueText(v.feePrimary, row.fee?.primary, row.fee?.primaryTextSegments, 14, 20, 400);
495
+ valueText(v.feeSecondary, row.fee?.secondary, row.fee?.secondaryTextSegments, 14, 20, 400);
496
+ v.actions.style.cssText = 'display:flex;gap:12px;padding-left:52px;padding-bottom:4px;';
497
+ v.actions.style.display = footer ? 'flex' : 'none';
498
+ const actionKeys = new Set();
499
+ for (const [index, action] of (row.footerActions ?? []).entries()) {
500
+ actionKeys.add(action.key);
501
+ let button = v.actionButtons.get(action.key);
502
+ if (!button) {
503
+ button = createElement(body.ownerDocument, 'button', 'ok-native-list-action-button');
504
+ button.type = 'button';
505
+ v.actionButtons.set(action.key, button);
506
+ }
507
+ if (button.textContent !== action.label) button.textContent = action.label;
508
+ button.toggleAttribute('disabled', Boolean(action.disabled));
509
+ button.dataset.nativeListAction = action.key;
510
+ markActionAnchorSource(button, 'footerAction', index);
511
+ button.style.cssText = 'font-family:inherit;font-size:14px;line-height:20px;font-weight:500;padding:4px 10px;border:1px solid transparent;border-radius:8px;background:var(--nl-strong);color:var(--nl-primary);white-space:nowrap;';
512
+ applyTextWeight(button, 500);
513
+ if (action.tone === 'primary') Object.assign(button.style, {
514
+ background: 'var(--nl-primary)',
515
+ color: 'var(--nl-inverse-text)'
516
+ });
517
+ if (v.actions.children[index] !== button) v.actions.insertBefore(button, v.actions.children[index] ?? null);
518
+ }
519
+ for (const [key, button] of v.actionButtons) {
520
+ if (!actionKeys.has(key)) {
521
+ button.remove();
522
+ v.actionButtons.delete(key);
523
+ }
524
+ }
525
+ }
526
+ function recycle(body) {
527
+ const v = histories.get(body);
528
+ if (v) {
529
+ Array.from(v.visual.children).forEach(n => v.primitives.dispose(n));
530
+ for (const view of v.amountRows.values()) if (view.visual) v.primitives.dispose(view.visual);
531
+ histories.delete(body);
532
+ }
533
+ recycleLegacy(body);
534
+ views.delete(body);
535
+ }
536
+ function bind(body, row, primitives) {
537
+ if (isHistory(row)) {
538
+ if (views.has(body)) {
539
+ recycleLegacy(body);
540
+ views.delete(body);
541
+ }
542
+ bindHistory(body, row, primitives);
543
+ } else {
544
+ if (histories.has(body)) recycle(body);
545
+ if (!views.has(body)) {
546
+ const initial = createLegacy(body.ownerDocument, row, primitives);
547
+ body.replaceChildren(...Array.from(initial.childNodes));
548
+ body.className = initial.className;
549
+ views.set(body, views.get(initial));
550
+ views.delete(initial);
551
+ }
552
+ bindLegacy(body, row, primitives);
553
+ }
554
+ }
555
+ function create(document, row, primitives) {
556
+ const body = document.createElement('div');
557
+ body.dataset.nlRenderer = 'activity';
558
+ bind(body, row, primitives);
559
+ return body;
560
+ }
87
561
  export const activityRowRenderer = {
88
562
  key: 'activity',
89
563
  create,
90
564
  bind,
91
565
  recycle,
92
- measure: (row, _width) => row.footerActions?.length ? 100 : 60,
566
+ measure: (row, _width) => {
567
+ if (!isHistory(row)) return row.footerActions?.length ? 100 : 60;
568
+ const extra = row.presentation === 'table' ? Math.max(0, (row.amounts?.length ?? 0) - 2) * 24 : 0;
569
+ if (row.footerActions?.length) return (row.presentation === 'table' ? 68 : 60) + extra + 42;
570
+ return 68 + extra;
571
+ },
93
572
  measureRendered: (_body, _row) => undefined
94
573
  };
95
574
  //# sourceMappingURL=ActivityRowRenderer.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 = '20px';
118
- image.style.height = '20px';
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 = '1 1 auto';
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';