@onekeyfe/react-native-native-list 6.7.0-2 → 6.7.0-20

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 (144) hide show
  1. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
  2. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +245 -9
  3. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +7 -4
  4. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +29 -3
  5. package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
  6. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
  7. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +87 -7
  8. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +193 -10
  9. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +147 -33
  10. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +145 -2
  12. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +51 -0
  13. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
  14. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
  16. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
  17. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
  18. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1920 -109
  19. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +29 -0
  20. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
  21. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
  22. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
  23. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
  24. package/docs/ROW_TEMPLATES.md +60 -9
  25. package/docs/SPEC.md +1004 -17
  26. package/docs/STYLE_SPEC.md +6 -0
  27. package/ios/HybridNativeList.swift +21 -2
  28. package/ios/NativeListAccessoryStack.swift +235 -39
  29. package/ios/NativeListActivityDetailsView.swift +18 -8
  30. package/ios/NativeListActivityRenderer.swift +8 -2
  31. package/ios/NativeListButtonGroupRenderer.swift +89 -0
  32. package/ios/NativeListDataRowRenderer.swift +155 -27
  33. package/ios/NativeListDesignAssets.swift +9 -0
  34. package/ios/NativeListIdentityRenderer.swift +191 -30
  35. package/ios/NativeListLeadingVisual.swift +119 -22
  36. package/ios/NativeListMessageRenderer.swift +34 -1
  37. package/ios/NativeListModels.swift +42 -2
  38. package/ios/NativeListRendererRegistry.swift +1 -0
  39. package/ios/NativeListResolvedText.swift +2 -1
  40. package/ios/NativeListRowHost.swift +14 -0
  41. package/ios/NativeListSectionHeaderRenderer.swift +88 -0
  42. package/ios/RNCNativeListView.swift +1031 -55
  43. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
  44. package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
  45. package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/Contents.json +1 -0
  46. package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/icon.svg +1 -0
  47. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/Contents.json +1 -0
  48. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/icon.svg +1 -0
  49. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
  50. package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
  51. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/Contents.json +1 -0
  52. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/icon.svg +1 -0
  53. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
  54. package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
  55. package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/Contents.json +1 -0
  56. package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/icon.svg +1 -0
  57. package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/Contents.json +1 -0
  58. package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/icon.svg +1 -0
  59. package/ios/tests/NativeListAccessoryStackTests.swift +89 -0
  60. package/ios/tests/NativeListActivityPresentationTests.swift +56 -0
  61. package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
  62. package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
  63. package/ios/tests/NativeListLifecycleTests.swift +2720 -3
  64. package/lib/module/NativeList.js +200 -32
  65. package/lib/module/NativeList.web.js +262 -32
  66. package/lib/module/index.js +1 -1
  67. package/lib/module/models.js +1 -0
  68. package/lib/module/selection.js +1 -1
  69. package/lib/module/validation.js +776 -52
  70. package/lib/module/web/NativeListWebEngine.js +919 -79
  71. package/lib/module/web/templates/ActivityRowRenderer.js +487 -7
  72. package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
  73. package/lib/module/web/templates/DataRowRenderer.js +40 -5
  74. package/lib/module/web/templates/IdentityRowRenderer.js +90 -4
  75. package/lib/module/web/templates/MarketRowRenderer.js +8 -3
  76. package/lib/module/web/templates/MarketTableRowRenderer.js +577 -0
  77. package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
  78. package/lib/module/web/templates/MessageRowRenderer.js +18 -2
  79. package/lib/module/web/templates/RowContainerStyle.js +1 -0
  80. package/lib/module/web/templates/RowRendererRegistry.js +8 -3
  81. package/lib/module/web/templates/SectionHeaderRowRenderer.js +70 -3
  82. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  83. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  84. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  85. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  86. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  87. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  88. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  89. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  90. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  91. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  92. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  93. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  94. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  95. package/lib/typescript/src/NativeList.d.ts +3 -3
  96. package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
  97. package/lib/typescript/src/NativeList.types.d.ts +29 -1
  98. package/lib/typescript/src/NativeList.web.d.ts +2 -2
  99. package/lib/typescript/src/index.d.ts +2 -2
  100. package/lib/typescript/src/models.d.ts +176 -10
  101. package/lib/typescript/src/validation.d.ts +15 -0
  102. package/lib/typescript/src/web/NativeListWebEngine.d.ts +58 -1
  103. package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
  104. package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
  105. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
  106. package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
  107. package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
  108. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +10 -4
  109. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
  110. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
  111. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
  112. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
  113. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
  114. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
  115. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
  116. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
  117. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
  118. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
  119. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
  120. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
  121. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
  122. package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
  123. package/package.json +3 -3
  124. package/react-native-native-list.podspec +1 -0
  125. package/src/NativeList.nitro.ts +2 -0
  126. package/src/NativeList.tsx +391 -82
  127. package/src/NativeList.types.ts +34 -1
  128. package/src/NativeList.web.tsx +420 -65
  129. package/src/index.ts +2 -0
  130. package/src/models.ts +210 -3
  131. package/src/selection.ts +1 -0
  132. package/src/validation.ts +1635 -76
  133. package/src/web/NativeListWebEngine.ts +1476 -112
  134. package/src/web/templates/ActivityRowRenderer.ts +732 -8
  135. package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
  136. package/src/web/templates/DataRowRenderer.ts +93 -20
  137. package/src/web/templates/IdentityRowRenderer.ts +150 -5
  138. package/src/web/templates/MarketRowRenderer.ts +19 -3
  139. package/src/web/templates/MarketTableRowRenderer.ts +755 -0
  140. package/src/web/templates/MediaTileRowRenderer.ts +313 -5
  141. package/src/web/templates/MessageRowRenderer.ts +23 -7
  142. package/src/web/templates/RowContainerStyle.ts +2 -0
  143. package/src/web/templates/RowRendererRegistry.ts +21 -6
  144. package/src/web/templates/SectionHeaderRowRenderer.ts +89 -5
@@ -15,7 +15,11 @@ type Views = {
15
15
  primitives: RowPrimitives;
16
16
  };
17
17
  const views = new WeakMap<HTMLElement, Views>();
18
- function bind(body: HTMLElement, row: MediaTileRow, primitives: RowPrimitives) {
18
+ function bindLegacy(
19
+ body: HTMLElement,
20
+ row: MediaTileRow,
21
+ primitives: RowPrimitives
22
+ ) {
19
23
  const v = views.get(body)!;
20
24
  v.primitives = primitives;
21
25
  const style = row.style;
@@ -114,7 +118,7 @@ function bind(body: HTMLElement, row: MediaTileRow, primitives: RowPrimitives) {
114
118
  body.appendChild(v.close);
115
119
  } else v.close.remove();
116
120
  }
117
- function create(
121
+ function createLegacy(
118
122
  document: Document,
119
123
  row: MediaTileRow,
120
124
  primitives: RowPrimitives
@@ -154,10 +158,10 @@ function create(
154
158
  imageKey: '',
155
159
  networkKey: '',
156
160
  });
157
- bind(body, row, primitives);
161
+ bindLegacy(body, row, primitives);
158
162
  return body;
159
163
  }
160
- function recycle(body: HTMLElement) {
164
+ function recycleLegacy(body: HTMLElement) {
161
165
  const v = views.get(body);
162
166
  if (!v) return;
163
167
  [v.image, v.network].forEach((n) => {
@@ -169,12 +173,316 @@ function recycle(body: HTMLElement) {
169
173
  v.image = v.network = undefined;
170
174
  v.imageKey = v.networkKey = '';
171
175
  }
176
+ type GalleryViews = {
177
+ frame: HTMLElement;
178
+ media?: HTMLImageElement | HTMLVideoElement;
179
+ fallback: HTMLElement;
180
+ metadata: HTMLElement;
181
+ subtitleLine: HTMLElement;
182
+ subtitle: HTMLElement;
183
+ title: HTMLElement;
184
+ badge: HTMLElement;
185
+ network?: HTMLElement;
186
+ networkKey: string;
187
+ mediaKey: string;
188
+ epoch: number;
189
+ primitives: RowPrimitives;
190
+ enter: () => void;
191
+ leave: () => void;
192
+ };
193
+ const galleries = new WeakMap<HTMLElement, GalleryViews>();
194
+ const isGalleryMedia = (row: MediaTileRow) =>
195
+ row.variant === 'gallery' && (!row.image || (!!row.media && !row.imageState));
196
+
197
+ function clearGalleryMedia(v: GalleryViews) {
198
+ v.epoch += 1;
199
+ v.frame.style.borderRadius = '10px';
200
+ if (!v.media) return;
201
+ v.media.onerror = null;
202
+ v.media.onload = null;
203
+ v.media.onloadeddata = null;
204
+ if (v.media.tagName === 'VIDEO') {
205
+ const video = v.media as HTMLVideoElement;
206
+ video.pause();
207
+ video.removeAttribute('src');
208
+ video.load();
209
+ } else v.media.removeAttribute('src');
210
+ v.media.remove();
211
+ v.media = undefined;
212
+ }
213
+
214
+ function initGallery(body: HTMLElement, primitives: RowPrimitives) {
215
+ const document = body.ownerDocument;
216
+ const element = (className: string) => {
217
+ const node = document.createElement('div');
218
+ node.className = className;
219
+ return node;
220
+ };
221
+ const frame = element('ok-native-list-media-image');
222
+ const fallback = element('ok-native-list-media-fallback');
223
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
224
+ svg.setAttribute('viewBox', '0 0 24 24');
225
+ svg.setAttribute('width', '24');
226
+ svg.setAttribute('height', '24');
227
+ svg.setAttribute('aria-hidden', 'true');
228
+ svg.setAttribute('fill', 'currentColor');
229
+ for (const d of [
230
+ 'M14.25 7a2 2 0 1 1 0 4 2 2 0 0 1 0-4',
231
+ 'M21 21H3V3h18zM5 16.414V19h12.586L14 15.414l-2 2-4-4zm0-2.828 3-3 4 4 2-2 5 5V5H5z',
232
+ ]) {
233
+ const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
234
+ path.setAttribute('d', d);
235
+ path.setAttribute('fill-rule', 'evenodd');
236
+ svg.append(path);
237
+ }
238
+ fallback.append(svg);
239
+ Object.assign(fallback.style, {
240
+ position: 'absolute',
241
+ inset: '0',
242
+ display: 'flex',
243
+ alignItems: 'center',
244
+ justifyContent: 'center',
245
+ color: 'var(--nl-disabled)',
246
+ borderRadius: '10px',
247
+ background: 'var(--nl-strong)',
248
+ });
249
+ const metadata = element('ok-native-list-media-meta');
250
+ const subtitleLine = element('ok-native-list-media-subtitle-row');
251
+ const subtitle = element('ok-native-list-media-subtitle');
252
+ const title = element('ok-native-list-media-title');
253
+ const badge = element('ok-native-list-badge');
254
+ subtitle.dataset.nlSlot = 'subtitle';
255
+ title.dataset.nlSlot = 'title';
256
+ badge.dataset.nlSlot = 'badge';
257
+ subtitleLine.append(subtitle);
258
+ metadata.append(subtitleLine, title);
259
+ frame.append(fallback);
260
+ body.replaceChildren(frame, metadata);
261
+ const enter = () => {
262
+ frame.style.opacity = '0.8';
263
+ };
264
+ const leave = () => {
265
+ frame.style.opacity = '';
266
+ };
267
+ body.addEventListener('mouseenter', enter);
268
+ body.addEventListener('mouseleave', leave);
269
+ const v: GalleryViews = {
270
+ frame,
271
+ fallback,
272
+ metadata,
273
+ subtitleLine,
274
+ subtitle,
275
+ title,
276
+ badge,
277
+ networkKey: '',
278
+ mediaKey: '',
279
+ epoch: 0,
280
+ primitives,
281
+ enter,
282
+ leave,
283
+ };
284
+ galleries.set(body, v);
285
+ return v;
286
+ }
287
+
288
+ function bindGallery(
289
+ body: HTMLElement,
290
+ row: MediaTileRow,
291
+ primitives: RowPrimitives
292
+ ) {
293
+ const v = galleries.get(body) ?? initGallery(body, primitives);
294
+ v.primitives = primitives;
295
+ const style = row.style;
296
+ body.className = 'ok-native-list-row ok-native-list-media';
297
+ body.style.cssText = '';
298
+ body.removeAttribute('data-nl-container-background');
299
+ body.removeAttribute('data-nl-container-border');
300
+ Object.assign(body.style, {
301
+ display: 'block',
302
+ position: 'relative',
303
+ boxSizing: 'border-box',
304
+ padding: `${style?.verticalPadding ?? 10}px ${
305
+ style?.horizontalPadding ?? 10
306
+ }px`,
307
+ borderRadius: '16px',
308
+ background: 'transparent',
309
+ height: 'auto',
310
+ });
311
+ Object.assign(v.frame.style, {
312
+ position: 'relative',
313
+ width: '100%',
314
+ height: 'auto',
315
+ aspectRatio: '1',
316
+ borderRadius: v.media?.tagName === 'VIDEO' ? '0' : '10px',
317
+ overflow: 'hidden',
318
+ background: 'var(--nl-bg)',
319
+ });
320
+ v.metadata.style.paddingTop = `${style?.leadingGap ?? 8}px`;
321
+ v.subtitleLine.style.gap = '0px';
322
+ v.subtitle.style.cssText =
323
+ 'font-size:12px;line-height:16px;font-weight:400;box-sizing:border-box;padding-right:8px';
324
+ v.title.style.cssText = 'font-size:16px;line-height:24px;font-weight:500';
325
+ v.subtitle.textContent = row.subtitle || '-';
326
+ v.title.textContent = row.title || '-';
327
+ if (style?.subtitle) primitives.textStyle(v.subtitle, style.subtitle);
328
+ if (style?.title) primitives.textStyle(v.title, style.title);
329
+ const mediaKey = JSON.stringify([row.key, row.media, row.imageState]);
330
+ if (v.mediaKey !== mediaKey) {
331
+ clearGalleryMedia(v);
332
+ v.mediaKey = mediaKey;
333
+ v.fallback.style.visibility = 'visible';
334
+ const epoch = v.epoch;
335
+ const source = row.imageState ? undefined : row.media?.source;
336
+ const probe = (attempt: number) => {
337
+ if (v.epoch !== epoch) return;
338
+ const kind = row.media?.probeOrder[attempt];
339
+ if (!source?.uri || !kind) return;
340
+ const media = body.ownerDocument.createElement(
341
+ kind === 'video' ? 'video' : 'img'
342
+ );
343
+ v.frame.style.borderRadius = kind === 'video' ? '0' : '10px';
344
+ Object.assign(media.style, {
345
+ display: 'block',
346
+ position: 'absolute',
347
+ inset: '0',
348
+ width: '100%',
349
+ height: '100%',
350
+ objectFit:
351
+ source.contentFit === 'center'
352
+ ? 'none'
353
+ : source.contentFit ?? (kind === 'video' ? 'contain' : 'cover'),
354
+ borderRadius: kind === 'video' ? '0' : '10px',
355
+ pointerEvents: 'none',
356
+ });
357
+ media.setAttribute('aria-hidden', 'true');
358
+ if (media.tagName === 'VIDEO') {
359
+ const video = media as HTMLVideoElement;
360
+ video.muted = true;
361
+ video.autoplay = false;
362
+ video.controls = false;
363
+ video.playsInline = true;
364
+ video.preload = 'metadata';
365
+ video.tabIndex = -1;
366
+ } else {
367
+ (media as HTMLImageElement).alt = '';
368
+ (media as HTMLImageElement).decoding = 'async';
369
+ }
370
+ media.onerror = () => {
371
+ if (v.epoch !== epoch || v.media !== media) return;
372
+ media.onerror = null;
373
+ media.onload = null;
374
+ media.onloadeddata = null;
375
+ if (media.tagName === 'VIDEO') (media as HTMLVideoElement).pause();
376
+ media.removeAttribute('src');
377
+ if (media.tagName === 'VIDEO') (media as HTMLVideoElement).load();
378
+ media.remove();
379
+ v.media = undefined;
380
+ v.frame.style.borderRadius = '10px';
381
+ v.fallback.style.visibility = 'visible';
382
+ probe(attempt + 1);
383
+ };
384
+ const ready = () => {
385
+ if (v.epoch === epoch && v.media === media)
386
+ v.fallback.style.visibility = 'hidden';
387
+ };
388
+ if (media.tagName === 'VIDEO') media.onloadeddata = ready;
389
+ else media.onload = ready;
390
+ v.media = media;
391
+ v.frame.insertBefore(
392
+ media,
393
+ v.badge.parentNode === v.frame ? v.badge : null
394
+ );
395
+ media.src = source.uri;
396
+ };
397
+ probe(0);
398
+ }
399
+ v.badge.textContent = row.badge?.text ?? '';
400
+ if (row.badge) {
401
+ Object.assign(v.badge.style, {
402
+ position: 'absolute',
403
+ right: '0',
404
+ bottom: '0',
405
+ boxSizing: 'content-box',
406
+ height: '20px',
407
+ padding: '0 8px',
408
+ border: '2px solid var(--nl-bg)',
409
+ borderRadius: '10px',
410
+ background: 'var(--nl-inverse)',
411
+ color: 'var(--nl-inverse-text)',
412
+ fontSize: '14px',
413
+ fontWeight: '500',
414
+ fontFamily: 'var(--nl-font-medium)',
415
+ lineHeight: '20px',
416
+ });
417
+ if (style?.badge) primitives.textStyle(v.badge, style.badge);
418
+ v.frame.append(v.badge);
419
+ } else v.badge.remove();
420
+ const networkKey = JSON.stringify(row.networkImage);
421
+ if (v.networkKey !== networkKey) {
422
+ if (v.network) {
423
+ primitives.dispose(v.network);
424
+ v.network.remove();
425
+ }
426
+ v.network = row.networkImage
427
+ ? primitives.thumbnail(row.networkImage)
428
+ : undefined;
429
+ if (v.network) {
430
+ v.network.className = 'ok-native-list-media-network';
431
+ v.subtitleLine.append(v.network);
432
+ }
433
+ v.networkKey = networkKey;
434
+ }
435
+ }
436
+
437
+ function recycle(body: HTMLElement) {
438
+ const gallery = galleries.get(body);
439
+ if (gallery) {
440
+ clearGalleryMedia(gallery);
441
+ if (gallery.network) gallery.primitives.dispose(gallery.network);
442
+ body.removeEventListener('mouseenter', gallery.enter);
443
+ body.removeEventListener('mouseleave', gallery.leave);
444
+ galleries.delete(body);
445
+ }
446
+ recycleLegacy(body);
447
+ views.delete(body);
448
+ }
449
+ function bind(body: HTMLElement, row: MediaTileRow, primitives: RowPrimitives) {
450
+ const gallery = isGalleryMedia(row);
451
+ if (gallery) {
452
+ if (views.has(body)) {
453
+ recycleLegacy(body);
454
+ views.delete(body);
455
+ }
456
+ bindGallery(body, row, primitives);
457
+ } else {
458
+ if (galleries.has(body)) recycle(body);
459
+ if (!views.has(body)) {
460
+ const initial = createLegacy(body.ownerDocument, row, primitives);
461
+ body.replaceChildren(...Array.from(initial.childNodes));
462
+ body.className = initial.className;
463
+ views.set(body, views.get(initial)!);
464
+ views.delete(initial);
465
+ }
466
+ bindLegacy(body, row, primitives);
467
+ }
468
+ }
469
+ function create(
470
+ document: Document,
471
+ row: MediaTileRow,
472
+ primitives: RowPrimitives
473
+ ) {
474
+ const body = document.createElement('div');
475
+ body.dataset.nlRenderer = 'mediaTile';
476
+ bind(body, row, primitives);
477
+ return body;
478
+ }
172
479
  export const mediaTileRowRenderer = {
173
480
  key: 'mediaTile' as const,
174
481
  create,
175
482
  bind,
176
483
  recycle,
177
- measure: (_row: MediaTileRow, _width: number) => 244,
484
+ measure: (row: MediaTileRow, width: number) =>
485
+ isGalleryMedia(row) ? width + 48 : 244,
178
486
  measureRendered: (
179
487
  _body: HTMLElement,
180
488
  _row: MediaTileRow
@@ -4,10 +4,8 @@ import type { MessageRow, NativeListTextStyle } from '../../models';
4
4
 
5
5
  type Text = Readonly<{
6
6
  value: string;
7
- style: Required<
8
- Pick<NativeListTextStyle, 'fontSize' | 'lineHeight' | 'lines'>
9
- > &
10
- NativeListTextStyle;
7
+ style: Required<Pick<NativeListTextStyle, 'fontSize' | 'lineHeight'>> &
8
+ Omit<NativeListTextStyle, 'lines'> & { lines: 0 | 1 | 2 | 3 };
11
9
  }>;
12
10
  export function resolveMessageRow(row: MessageRow) {
13
11
  const text = (
@@ -15,7 +13,7 @@ export function resolveMessageRow(row: MessageRow) {
15
13
  style: NativeListTextStyle | undefined,
16
14
  fontSize: number,
17
15
  lineHeight: number,
18
- lines: 1 | 2 | 3,
16
+ lines: 0 | 1 | 2 | 3,
19
17
  color: string,
20
18
  fontWeight: NativeListTextStyle['fontWeight'] = 'regular'
21
19
  ): Text => ({
@@ -117,6 +115,9 @@ export function bindMessageRow(
117
115
  body.style.cssText = '';
118
116
  body.removeAttribute('data-nl-container-background');
119
117
  body.removeAttribute('data-nl-container-border');
118
+ if (row.presentation === 'inlineWarning')
119
+ body.setAttribute('data-nl-inline-warning', 'true');
120
+ else body.removeAttribute('data-nl-inline-warning');
120
121
  body.style.padding = `${resolved.verticalPadding}px ${resolved.horizontalPadding}px`;
121
122
  body.style.height = resolved.automaticHeight ? 'auto' : '100%';
122
123
  views.column.style.cssText = '';
@@ -128,7 +129,19 @@ export function bindMessageRow(
128
129
  ] as const) {
129
130
  view.style.cssText = '';
130
131
  view.textContent = text.value;
131
- primitives.textStyle(view, text.style);
132
+ const { lines, ...textStyle } = text.style;
133
+ primitives.textStyle(
134
+ view,
135
+ lines === 0 ? textStyle : { ...textStyle, lines }
136
+ );
137
+ if (lines === 0) {
138
+ view.style.whiteSpace = 'pre-wrap';
139
+ view.style.overflow = 'visible';
140
+ view.style.textOverflow = 'clip';
141
+ view.style.maxHeight = 'none';
142
+ view.style.removeProperty('-webkit-line-clamp');
143
+ view.style.removeProperty('-webkit-box-orient');
144
+ }
132
145
  }
133
146
  views.unread.style.cssText = '';
134
147
  if (row.body) {
@@ -258,7 +271,10 @@ export function measureMessageRow(
258
271
  ),
259
272
  0
260
273
  );
261
- return Math.min(text.style.lines, lines) * text.style.lineHeight;
274
+ return (
275
+ (text.style.lines === 0 ? lines : Math.min(text.style.lines, lines)) *
276
+ text.style.lineHeight
277
+ );
262
278
  };
263
279
  const timeWidth = Math.min(
264
280
  availableWidth / 3,
@@ -88,6 +88,8 @@ export function applyRowContainerStyle(body: HTMLElement, row: RowModel): void {
88
88
  }
89
89
  if (container.cornerRadius !== undefined)
90
90
  set(body, 'border-radius', `${container.cornerRadius}px`);
91
+ if (row.type === 'message' && row.presentation === 'inlineWarning')
92
+ set(body, 'border-radius', '0px');
91
93
  if (container.borderWidth !== undefined) {
92
94
  // Paint above member backgrounds without changing the content box or hit targets.
93
95
  body.setAttribute('data-nl-container-border', 'true');
@@ -5,6 +5,7 @@ import { identityRowRenderer } from './IdentityRowRenderer';
5
5
  import { sectionHeaderRowRenderer } from './SectionHeaderRowRenderer';
6
6
  import type { MarketRow } from '../../models';
7
7
  import { marketRowRenderer } from './MarketRowRenderer';
8
+ import { marketTableRowRenderer } from './MarketTableRowRenderer';
8
9
  import type { MetricCardRow } from '../../models';
9
10
  import { metricCardRowRenderer } from './MetricCardRowRenderer';
10
11
  import type { DataRow } from '../../models';
@@ -15,8 +16,15 @@ import type { SystemRow } from '../../models';
15
16
  import { systemRowRenderer } from './SystemRowRenderer';
16
17
  import type { ActionRow } from '../../models';
17
18
  import { actionRowRenderer } from './ActionRowRenderer';
19
+ import { buttonGroupRowRenderer } from './ButtonGroupRowRenderer';
18
20
  import { mediaTileRowRenderer } from './MediaTileRowRenderer';
19
- import type { MessageRow, RailRow, MediaTileRow, RowModel } from '../../models';
21
+ import type {
22
+ ButtonGroupRow,
23
+ MessageRow,
24
+ RailRow,
25
+ MediaTileRow,
26
+ RowModel,
27
+ } from '../../models';
20
28
  import { messageRowRenderer } from './MessageRowRenderer';
21
29
  import type { RowPrimitives } from './RowVisual';
22
30
  import { railRowRenderer } from './RailRowRenderer';
@@ -59,7 +67,10 @@ const factories = {
59
67
  registration(identityRowRenderer, row as IdentityRow),
60
68
  sectionHeader: (row: RowModel) =>
61
69
  registration(sectionHeaderRowRenderer, row as SectionHeaderRow),
62
- market: (row: RowModel) => registration(marketRowRenderer, row as MarketRow),
70
+ market: (row: RowModel) =>
71
+ (row as MarketRow).webTable
72
+ ? registration(marketTableRowRenderer, row as MarketRow)
73
+ : registration(marketRowRenderer, row as MarketRow),
63
74
  metricCard: (row: RowModel) =>
64
75
  registration(metricCardRowRenderer, row as MetricCardRow),
65
76
  dataRow: (row: RowModel) => registration(dataRowRenderer, row as DataRow),
@@ -67,6 +78,8 @@ const factories = {
67
78
  registration(activityRowRenderer, row as ActivityRow),
68
79
  system: (row: RowModel) => registration(systemRowRenderer, row as SystemRow),
69
80
  action: (row: RowModel) => registration(actionRowRenderer, row as ActionRow),
81
+ buttonGroup: (row: RowModel) =>
82
+ registration(buttonGroupRowRenderer, row as ButtonGroupRow),
70
83
  message: (row: RowModel) =>
71
84
  registration(messageRowRenderer, row as MessageRow),
72
85
  rail: (row: RowModel) => registration(railRowRenderer, row as RailRow),
@@ -81,16 +94,18 @@ const renderers = {
81
94
  identity: identityRowRenderer,
82
95
  sectionHeader: sectionHeaderRowRenderer,
83
96
  market: marketRowRenderer,
97
+ marketTable: marketTableRowRenderer,
84
98
  metricCard: metricCardRowRenderer,
85
99
  dataRow: dataRowRenderer,
86
100
  activity: activityRowRenderer,
87
101
  system: systemRowRenderer,
88
102
  action: actionRowRenderer,
103
+ buttonGroup: buttonGroupRowRenderer,
89
104
  message: messageRowRenderer,
90
105
  rail: railRowRenderer,
91
106
  mediaTile: mediaTileRowRenderer,
92
107
  };
93
- export type RowRendererKey = RowModel['type'];
108
+ export type RowRendererKey = RowModel['type'] | 'marketTable';
94
109
  const isRegistered = (key: string): key is keyof typeof factories =>
95
110
  Object.prototype.hasOwnProperty.call(factories, key);
96
111
 
@@ -101,11 +116,11 @@ export function rowRenderer(row: RowModel) {
101
116
  return factories[row.type](row);
102
117
  }
103
118
  export function rowRendererKey(row: RowModel): RowRendererKey {
104
- return row.type;
119
+ return row.type === 'market' && row.webTable ? 'marketTable' : row.type;
105
120
  }
106
121
  export function recycleRowBody(body: HTMLElement): boolean {
107
122
  const key = body.dataset.nlRenderer ?? '';
108
- if (!isRegistered(key)) return false;
109
- renderers[key].recycle(body);
123
+ if (!Object.prototype.hasOwnProperty.call(renderers, key)) return false;
124
+ renderers[key as RowRendererKey].recycle(body);
110
125
  return true;
111
126
  }
@@ -1,6 +1,6 @@
1
1
  import { applyTextWeight } from './RowText';
2
2
  import { applyTabularNumbers, hasExplicitRowHeight } from './RowElements';
3
- import type { SectionHeaderRow } from '../../models';
3
+ import type { RowTextHelp, SectionHeaderRow } from '../../models';
4
4
  import {
5
5
  createElement,
6
6
  setData,
@@ -10,6 +10,21 @@ import {
10
10
  } from './RowElements';
11
11
  import { applyValueSegments } from './RowText';
12
12
  import type { RowPrimitives } from './RowVisual';
13
+
14
+ function bindHelp(target: HTMLElement, help: RowTextHelp) {
15
+ markActionAnchorSource(target, 'trailingAccessory', 0);
16
+ if (help.presentation === 'tooltip') {
17
+ setData(target, 'nativeListHoverAction', help.actionKey);
18
+ setData(target, 'nativeListIconHelp', true);
19
+ } else {
20
+ setData(target, 'nativeListAction', help.actionKey);
21
+ target.setAttribute('role', 'button');
22
+ }
23
+ if (help.underline === 'dashed') {
24
+ target.style.textDecoration = 'underline dashed';
25
+ target.style.textUnderlineOffset = '4px';
26
+ }
27
+ }
13
28
  function createSectionHeader(
14
29
  document: Document,
15
30
  primitives: RowPrimitives,
@@ -36,6 +51,16 @@ function createSectionHeader(
36
51
  const column = createTextColumn(document, row.title, row.subtitle);
37
52
  const title = column.firstElementChild as HTMLElement;
38
53
  title.classList.add('ok-native-list-section-title');
54
+ if (row.leadingBadge) {
55
+ const badge = createElement(
56
+ document,
57
+ 'span',
58
+ 'ok-native-list-badge',
59
+ row.leadingBadge.text
60
+ );
61
+ if (row.leadingBadge.tone) setData(badge, 'tone', row.leadingBadge.tone);
62
+ body.appendChild(badge);
63
+ }
39
64
  if (row.titleActionKey) {
40
65
  setData(title, 'nativeListAction', row.titleActionKey);
41
66
  markActionAnchorSource(title, 'leadingAction');
@@ -50,6 +75,12 @@ function createSectionHeader(
50
75
  }
51
76
  if (row.titleActionOnHover) setData(title, 'nativeListHoverAction', true);
52
77
  }
78
+ if (row.style?.titleDecoration === 'none')
79
+ title.style.textDecoration = 'none';
80
+ if (row.style?.titleDecoration === 'dashed') {
81
+ title.style.textDecoration = 'underline dashed';
82
+ title.style.textUnderlineOffset = '4px';
83
+ }
53
84
  if (row.presentation === 'networkSelector' && hasExplicitRowHeight(row)) {
54
85
  body.style.padding =
55
86
  row.variant === 'summary' ? '24px 12px 20px' : '0 12px';
@@ -114,13 +145,56 @@ function createSectionHeader(
114
145
  title.replaceChildren(text, dotted);
115
146
  }
116
147
  }
117
- body.appendChild(column);
148
+ if (row.variant === 'history' && row.titleLoading) {
149
+ const pendingLine = createElement(document, 'div');
150
+ pendingLine.style.cssText =
151
+ 'display:flex;align-items:center;gap:8px;min-width:0;width:100%;height:20px';
152
+ const spinner = createElement(document, 'span');
153
+ spinner.setAttribute('role', 'progressbar');
154
+ spinner.setAttribute('aria-valuemin', '0');
155
+ spinner.setAttribute('aria-valuemax', '1');
156
+ spinner.style.cssText =
157
+ 'display:block;width:20px;height:20px;flex:0 0 20px';
158
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
159
+ svg.setAttribute('viewBox', '0 0 32 32');
160
+ svg.setAttribute('class', 'ok-native-list-spinner');
161
+ svg.style.cssText =
162
+ 'display:block;width:20px;height:20px;border:0;animation-duration:.75s';
163
+ for (const track of [true, false]) {
164
+ const circle = document.createElementNS(
165
+ 'http://www.w3.org/2000/svg',
166
+ 'circle'
167
+ );
168
+ for (const [name, value] of Object.entries({
169
+ cx: '16',
170
+ cy: '16',
171
+ r: '14',
172
+ fill: 'none',
173
+ 'stroke-width': '4',
174
+ }))
175
+ circle.setAttribute(name, value);
176
+ circle.style.stroke = row.style?.title?.color ?? 'var(--nl-secondary)';
177
+ if (track) circle.style.opacity = '.2';
178
+ else {
179
+ circle.style.strokeDasharray = '80';
180
+ circle.style.strokeDashoffset = '60';
181
+ }
182
+ svg.appendChild(circle);
183
+ }
184
+ spinner.appendChild(svg);
185
+ title.style.textTransform = 'uppercase';
186
+ pendingLine.append(spinner, column);
187
+ body.style.height = 'calc(100% + 4px)';
188
+ body.appendChild(pendingLine);
189
+ } else body.appendChild(column);
118
190
  if (row.value) {
119
191
  const value = tagSlot(
120
192
  createElement(
121
193
  document,
122
- row.valueActionKey ? 'button' : 'span',
123
- row.valueActionKey
194
+ row.valueActionKey || row.valueHelp?.presentation === 'popover'
195
+ ? 'button'
196
+ : 'span',
197
+ row.valueActionKey || row.valueHelp?.presentation === 'popover'
124
198
  ? 'ok-native-list-action-button ok-native-list-section-value'
125
199
  : 'ok-native-list-value ok-native-list-section-value',
126
200
  row.value
@@ -145,7 +219,17 @@ function createSectionHeader(
145
219
  setData(value, 'nativeListAction', row.valueActionKey);
146
220
  markActionAnchorSource(value, 'trailingAccessory', 0);
147
221
  }
148
- body.appendChild(value);
222
+ if (row.valueHelp) bindHelp(value, row.valueHelp);
223
+ if (row.style?.valuePlacement === 'afterTitle') {
224
+ value.style.marginLeft = '0';
225
+ value.style.flexShrink = '0';
226
+ value.style.alignSelf = 'center';
227
+ title.insertAdjacentElement('afterend', value);
228
+ column.style.flexDirection = 'row';
229
+ column.style.alignItems = 'center';
230
+ column.style.justifyContent = 'flex-start';
231
+ column.style.gap = '8px';
232
+ } else body.appendChild(value);
149
233
  }
150
234
  if (row.valueIcon) {
151
235
  const valueIcon = primitives.iconAction(