@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
@@ -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 = '';
@@ -21,13 +22,13 @@ function bind(body, row, primitives) {
21
22
  node.hidden = !row[key];
22
23
  if (style?.[key]) primitives.textStyle(node, style[key]);
23
24
  }
24
- const visualKey = JSON.stringify([row.key, row.leading, row.secondaryLeading]);
25
+ const visualKey = JSON.stringify([row.key, row.hideLeading, row.leading, row.secondaryLeading]);
25
26
  if (v.visualKey !== visualKey) {
26
27
  v.visuals.forEach(node => {
27
28
  primitives.dispose(node);
28
29
  node.remove();
29
30
  });
30
- v.visuals = [row.leading, row.secondaryLeading].map(source => primitives.visual(source)).filter(node => !!node);
31
+ v.visuals = (row.hideLeading ? [] : [row.leading, row.secondaryLeading]).map(source => primitives.visual(source)).filter(node => !!node);
31
32
  v.visuals.forEach(node => body.insertBefore(node, v.column));
32
33
  v.visualStyles = v.visuals.map(node => new RowVisualStyle(node));
33
34
  v.visualKey = visualKey;
@@ -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,491 @@ 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: row.hideLeading ? '0' : '12px',
228
+ minWidth: '0',
229
+ flex: '1 1 0'
230
+ });
231
+ Object.assign(v.visual.style, {
232
+ display: row.hideLeading ? 'none' : '',
233
+ position: 'relative',
234
+ width: '40px',
235
+ height: '40px',
236
+ flex: '0 0 40px'
237
+ });
238
+ const visualKey = JSON.stringify([row.key, row.hideLeading, row.leading, row.secondaryLeading]);
239
+ if (v.visualKey !== visualKey) {
240
+ Array.from(v.visual.children).forEach(n => primitives.dispose(n));
241
+ v.visual.replaceChildren();
242
+ v.visuals = [];
243
+ const sources = row.hideLeading ? [] : [row.leading, row.secondaryLeading].filter(Boolean);
244
+ sources.forEach(source => {
245
+ const visual = primitives.visual(source);
246
+ if (!visual) return;
247
+ historyIcon(visual, source, table || sources.length > 1 ? 24 : 28);
248
+ const retained = {
249
+ node: visual,
250
+ style: new RowVisualStyle(visual),
251
+ background: visual.style.background,
252
+ loaded: false
253
+ };
254
+ // Only placeholder-backed sources restore their frame background on load.
255
+ const image = source && 'image' in source ? source.image : undefined;
256
+ if (image?.loadingStrategy && image.loadingStrategy !== 'none') {
257
+ visual.querySelector('.ok-native-list-visual-main')?.addEventListener('load', () => {
258
+ retained.background = source && 'backgroundColor' in source && source.backgroundColor ? source.backgroundColor : 'transparent';
259
+ retained.loaded = true;
260
+ });
261
+ }
262
+ v.visuals.push(retained);
263
+ v.visual.append(visual);
264
+ });
265
+ v.visualKey = visualKey;
266
+ }
267
+ const sources = row.hideLeading ? [] : [row.leading, row.secondaryLeading].filter(Boolean);
268
+ v.visuals.forEach((retained, index) => {
269
+ const {
270
+ node: visual,
271
+ style,
272
+ background,
273
+ loaded
274
+ } = retained;
275
+ const source = sources[index];
276
+ const previousToken = visual.querySelector(':scope > .ok-native-list-history-token');
277
+ if (previousToken) {
278
+ visual.append(...Array.from(previousToken.children));
279
+ previousToken.remove();
280
+ }
281
+ const currentFallback = visual.querySelector(':scope > .ok-native-list-visual-fallback:not(.ok-native-list-visual-corner)');
282
+ if (currentFallback && retained.fallback !== currentFallback) {
283
+ retained.fallback = currentFallback;
284
+ retained.fallbackStyle = new RowVisualStyle(currentFallback);
285
+ }
286
+ // A terminal image error creates a new fallback node after the factory bind.
287
+ retained.fallbackStyle?.restore();
288
+ const size = sources.length > 1 ? index ? 28 : 24 : 40;
289
+ style.apply(row.style?.image, size, size, 0);
290
+ Object.assign(visual.style, {
291
+ background,
292
+ position: '',
293
+ left: '',
294
+ top: ''
295
+ });
296
+ const svg = visual.querySelector('.ok-native-list-visual-fallback > svg');
297
+ if (svg) {
298
+ const iconSize = String(table || sources.length > 1 ? 24 : 28);
299
+ svg.setAttribute('width', iconSize);
300
+ svg.setAttribute('height', iconSize);
301
+ }
302
+ Object.assign(visual.style, {
303
+ display: 'inline-flex',
304
+ alignItems: 'center',
305
+ justifyContent: 'center'
306
+ });
307
+ if (sources.length > 1) Object.assign(visual.style, {
308
+ position: 'absolute',
309
+ left: index ? '12px' : '0',
310
+ top: index ? '12px' : '0',
311
+ border: index ? '2px solid var(--nl-row)' : '0',
312
+ boxSizing: 'border-box'
313
+ });
314
+ if (!table && sources.length > 1) {
315
+ const token = visual.ownerDocument.createElement('span');
316
+ token.className = 'ok-native-list-history-token';
317
+ Object.assign(token.style, {
318
+ display: 'flex',
319
+ alignItems: 'center',
320
+ justifyContent: 'center',
321
+ position: 'relative',
322
+ width: '24px',
323
+ height: '24px',
324
+ flex: '0 0 24px',
325
+ borderRadius: 'inherit',
326
+ boxSizing: 'border-box',
327
+ overflow: 'hidden',
328
+ background: source && 'backgroundColor' in source ? source.backgroundColor ?? '' : '',
329
+ border: source && 'borderColor' in source && source.borderColor ? `1px solid ${source.borderColor}` : '0'
330
+ });
331
+ token.append(...Array.from(visual.children).filter(child => !child.classList.contains('ok-native-list-visual-corner')));
332
+ const fallback = token.querySelector(':scope > .ok-native-list-visual-fallback');
333
+ if (fallback) {
334
+ fallback.style.width = '24px';
335
+ fallback.style.height = '24px';
336
+ fallback.style.flexShrink = '0';
337
+ }
338
+ const mainImage = token.querySelector(':scope > .ok-native-list-visual-main');
339
+ if (mainImage) {
340
+ mainImage.style.width = '100%';
341
+ mainImage.style.height = '100%';
342
+ }
343
+ visual.append(token);
344
+ }
345
+ if (table) {
346
+ visual.style.background = loaded ? background : source && 'backgroundColor' in source && source.backgroundColor ? source.backgroundColor : 'var(--nl-strong)';
347
+ const borderColor = source && 'borderColor' in source && source.borderColor ? source.borderColor : 'var(--nl-separator)';
348
+ visual.style.border = `1px solid ${borderColor}`;
349
+ visual.style.boxSizing = 'border-box';
350
+ } else if (sources.length === 1 && source?.kind === 'token') {
351
+ visual.style.border = source.borderColor ? `1px solid ${source.borderColor}` : '0';
352
+ visual.style.boxSizing = 'border-box';
353
+ const mainImage = visual.querySelector(':scope > .ok-native-list-visual-main');
354
+ if (mainImage) {
355
+ mainImage.style.width = '100%';
356
+ mainImage.style.height = '100%';
357
+ }
358
+ }
359
+ });
360
+ Object.assign(v.text.style, {
361
+ minWidth: '0',
362
+ flex: '1 1 auto',
363
+ display: 'flex',
364
+ flexDirection: 'column',
365
+ gap: table ? '4px' : '0'
366
+ });
367
+ Object.assign(v.titleLine.style, {
368
+ display: 'flex',
369
+ alignItems: 'center',
370
+ minWidth: '0'
371
+ });
372
+ v.title.style.cssText = ellipsis + `font-size:${table ? 14 : 16}px;line-height:${table ? 20 : 24}px;font-weight:500;`;
373
+ v.title.textContent = row.title;
374
+ applyTextWeight(v.title, 500);
375
+ if (row.style?.title) primitives.textStyle(v.title, row.style.title);
376
+ v.badges.style.cssText = 'display:flex;flex:0 0 auto;gap:8px;margin-left:8px';
377
+ v.badges.replaceChildren();
378
+ for (const badge of row.badges ?? []) {
379
+ const element = createElement(body.ownerDocument, 'span', 'ok-native-list-badge', badge.text);
380
+ element.dataset.tone = badge.tone ?? '';
381
+ element.style.cssText = 'height:20px;font-size:12px;line-height:16px;padding:2px 8px;border-radius:4px;box-sizing:border-box';
382
+ applyTextWeight(element, 500);
383
+ if (badge.tone === 'neutral') Object.assign(element.style, {
384
+ background: 'var(--nl-strong)',
385
+ color: 'var(--nl-secondary)'
386
+ });
387
+ if (badge.tone === 'warning') Object.assign(element.style, {
388
+ background: 'var(--nl-caution-background,color-mix(in srgb,var(--nl-caution) 12%,transparent))',
389
+ color: 'var(--nl-caution)'
390
+ });
391
+ v.badges.append(element);
392
+ }
393
+ v.badges.style.display = row.badges?.length ? 'flex' : 'none';
394
+ 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;';
395
+ applyTextWeight(v.description, 400);
396
+ const split = row.description?.indexOf(' • ') ?? -1;
397
+ v.descriptionTime.textContent = split >= 0 ? row.description.slice(0, split) : '';
398
+ v.descriptionTime.style.display = split >= 0 ? 'inline' : 'none';
399
+ v.descriptionTime.style.flexShrink = '0';
400
+ v.descriptionDot.style.cssText = `flex-shrink:0;margin:0 4px;display:${split >= 0 ? 'inline' : 'none'}`;
401
+ 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;';
402
+ v.descriptionAddress.textContent = split >= 0 ? row.description.slice(split + 3) : row.description ?? '';
403
+ v.description.style.display = row.description ? 'flex' : 'none';
404
+ v.descriptionAddress.tabIndex = row.descriptionActionKey ? 0 : -1;
405
+ if (row.descriptionActionKey) {
406
+ v.descriptionAddress.dataset.nativeListAction = row.descriptionActionKey;
407
+ markActionAnchorSource(v.descriptionAddress, 'description');
408
+ v.descriptionAddress.style.cursor = 'pointer';
409
+ } else {
410
+ delete v.descriptionAddress.dataset.nativeListAction;
411
+ delete v.descriptionAddress.dataset.nativeListAnchorSource;
412
+ v.descriptionAddress.style.cursor = 'inherit';
413
+ }
414
+ if (row.style?.description) primitives.textStyle(v.description, row.style.description);
415
+ v.description.style.display = row.description ? 'flex' : 'none';
416
+ Object.assign(v.amounts.style, {
417
+ display: 'flex',
418
+ flexDirection: 'column',
419
+ minWidth: '0',
420
+ gap: table ? '4px' : '0',
421
+ flex: table ? '1 1 0' : '0 1 auto',
422
+ maxWidth: table ? '50%' : '50%',
423
+ alignItems: table ? 'stretch' : 'flex-end',
424
+ alignSelf: table ? 'stretch' : 'center'
425
+ });
426
+ const amountKeys = new Set();
427
+ for (const amount of row.amounts ?? []) {
428
+ amountKeys.add(amount.key);
429
+ let view = v.amountRows.get(amount.key);
430
+ if (!view) {
431
+ const element = createElement(body.ownerDocument, 'div');
432
+ const primary = tagSlot(createElement(body.ownerDocument, 'span'), 'primaryAmount');
433
+ const secondary = tagSlot(createElement(body.ownerDocument, 'span'), 'secondaryAmount');
434
+ element.append(primary, secondary);
435
+ view = {
436
+ element,
437
+ primary,
438
+ secondary,
439
+ visualKey: ''
440
+ };
441
+ v.amountRows.set(amount.key, view);
442
+ }
443
+ view.element.style.cssText = `display:flex;align-items:center;gap:4px;min-width:0;max-width:100%;${table ? '' : 'justify-content:flex-end;'}`;
444
+ const secondary = amount.tone === 'secondary';
445
+ const size = table || secondary ? 14 : 16;
446
+ const line = table || secondary ? 20 : 24;
447
+ const weight = table || secondary ? 400 : 500;
448
+ 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)'};`;
449
+ valueText(view.primary, amount.text, amount.textSegments, size, line, weight);
450
+ const roleStyle = secondary ? row.style?.secondaryAmount : row.style?.primaryAmount;
451
+ if (roleStyle) primitives.textStyle(view.primary, roleStyle);
452
+ view.secondary.style.cssText = ellipsis + 'font-size:14px;line-height:20px;font-weight:400;color:var(--nl-secondary);';
453
+ valueText(view.secondary, amount.secondaryText, amount.secondaryTextSegments, 14, 20, 400);
454
+ view.secondary.hidden = !table || !amount.secondaryText;
455
+ const amountVisualKey = JSON.stringify(table ? amount.leading : undefined);
456
+ if (view.visualKey !== amountVisualKey) {
457
+ if (view.visual) {
458
+ primitives.dispose(view.visual);
459
+ view.visual.remove();
460
+ }
461
+ view.visual = table ? primitives.visual(amount.leading) : undefined;
462
+ if (view.visual) {
463
+ new RowVisualStyle(view.visual).apply({
464
+ width: 20,
465
+ height: 20
466
+ }, 20, 20, 0);
467
+ historyIcon(view.visual, amount.leading, 16);
468
+ if (amount.leading?.kind === 'token' && amount.leading.image) {
469
+ view.visual.style.border = amount.leading.borderColor ? `1px solid ${amount.leading.borderColor}` : '0';
470
+ view.visual.style.boxSizing = 'border-box';
471
+ }
472
+ view.element.prepend(view.visual);
473
+ }
474
+ view.visualKey = amountVisualKey;
475
+ }
476
+ v.amounts.append(view.element);
477
+ }
478
+ for (const [key, view] of v.amountRows) {
479
+ if (!amountKeys.has(key)) {
480
+ if (view.visual) primitives.dispose(view.visual);
481
+ view.element.remove();
482
+ v.amountRows.delete(key);
483
+ }
484
+ }
485
+ v.fee.style.cssText = 'display:flex;flex-direction:column;flex:.6 1 0;min-width:0;gap:4px';
486
+ v.fee.hidden = !table || !row.fee;
487
+ v.fee.style.display = table && row.fee ? 'flex' : 'none';
488
+ v.fee.style.opacity = row.fee?.hidden ? '0' : '1';
489
+ v.feeLabel.style.cssText = 'font-size:14px;line-height:20px;color:var(--nl-secondary);';
490
+ v.feeLabel.textContent = row.fee?.label ?? '';
491
+ applyTextWeight(v.feeLabel, 400);
492
+ v.feeValues.style.cssText = 'display:flex;align-items:center;gap:4px;min-width:0';
493
+ v.feePrimary.style.cssText = ellipsis + 'font-size:14px;line-height:20px;font-weight:400;';
494
+ v.feeSecondary.style.cssText = ellipsis + 'font-size:14px;line-height:20px;font-weight:400;color:var(--nl-secondary);';
495
+ valueText(v.feePrimary, row.fee?.primary, row.fee?.primaryTextSegments, 14, 20, 400);
496
+ valueText(v.feeSecondary, row.fee?.secondary, row.fee?.secondaryTextSegments, 14, 20, 400);
497
+ v.actions.style.cssText = `display:flex;gap:12px;padding-left:${row.hideLeading ? 0 : 52}px;padding-bottom:4px;`;
498
+ v.actions.style.display = footer ? 'flex' : 'none';
499
+ const actionKeys = new Set();
500
+ for (const [index, action] of (row.footerActions ?? []).entries()) {
501
+ actionKeys.add(action.key);
502
+ let button = v.actionButtons.get(action.key);
503
+ if (!button) {
504
+ button = createElement(body.ownerDocument, 'button', 'ok-native-list-action-button');
505
+ button.type = 'button';
506
+ v.actionButtons.set(action.key, button);
507
+ }
508
+ if (button.textContent !== action.label) button.textContent = action.label;
509
+ button.toggleAttribute('disabled', Boolean(action.disabled));
510
+ button.dataset.nativeListAction = action.key;
511
+ markActionAnchorSource(button, 'footerAction', index);
512
+ 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;';
513
+ applyTextWeight(button, 500);
514
+ if (action.tone === 'primary') Object.assign(button.style, {
515
+ background: 'var(--nl-primary)',
516
+ color: 'var(--nl-inverse-text)'
517
+ });
518
+ if (v.actions.children[index] !== button) v.actions.insertBefore(button, v.actions.children[index] ?? null);
519
+ }
520
+ for (const [key, button] of v.actionButtons) {
521
+ if (!actionKeys.has(key)) {
522
+ button.remove();
523
+ v.actionButtons.delete(key);
524
+ }
525
+ }
526
+ }
527
+ function recycle(body) {
528
+ const v = histories.get(body);
529
+ if (v) {
530
+ Array.from(v.visual.children).forEach(n => v.primitives.dispose(n));
531
+ for (const view of v.amountRows.values()) if (view.visual) v.primitives.dispose(view.visual);
532
+ histories.delete(body);
533
+ }
534
+ recycleLegacy(body);
535
+ views.delete(body);
536
+ }
537
+ function bind(body, row, primitives) {
538
+ if (isHistory(row)) {
539
+ if (views.has(body)) {
540
+ recycleLegacy(body);
541
+ views.delete(body);
542
+ }
543
+ bindHistory(body, row, primitives);
544
+ } else {
545
+ if (histories.has(body)) recycle(body);
546
+ if (!views.has(body)) {
547
+ const initial = createLegacy(body.ownerDocument, row, primitives);
548
+ body.replaceChildren(...Array.from(initial.childNodes));
549
+ body.className = initial.className;
550
+ views.set(body, views.get(initial));
551
+ views.delete(initial);
552
+ }
553
+ bindLegacy(body, row, primitives);
554
+ }
555
+ }
556
+ function create(document, row, primitives) {
557
+ const body = document.createElement('div');
558
+ body.dataset.nlRenderer = 'activity';
559
+ bind(body, row, primitives);
560
+ return body;
561
+ }
87
562
  export const activityRowRenderer = {
88
563
  key: 'activity',
89
564
  create,
90
565
  bind,
91
566
  recycle,
92
- measure: (row, _width) => row.footerActions?.length ? 100 : 60,
567
+ measure: (row, _width) => {
568
+ if (!isHistory(row)) return row.footerActions?.length ? 100 : 60;
569
+ const extra = row.presentation === 'table' ? Math.max(0, (row.amounts?.length ?? 0) - 2) * 24 : 0;
570
+ if (row.footerActions?.length) return (row.presentation === 'table' ? 68 : 60) + extra + 42;
571
+ return 68 + extra;
572
+ },
93
573
  measureRendered: (_body, _row) => undefined
94
574
  };
95
575
  //# sourceMappingURL=ActivityRowRenderer.js.map
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ import { markActionAnchorSource } from "./RowElements.js";
4
+ function bind(body, row) {
5
+ body.replaceChildren();
6
+ body.className = 'ok-native-list-row ok-native-list-button-group';
7
+ body.removeAttribute('data-nl-container-background');
8
+ body.removeAttribute('data-nl-container-border');
9
+ row.buttons.forEach((descriptor, index) => {
10
+ const button = body.ownerDocument.createElement('button');
11
+ button.type = 'button';
12
+ button.className = 'ok-native-list-block-button';
13
+ button.dataset.nativeListAction = descriptor.actionKey;
14
+ button.dataset.nlButtonKey = descriptor.key;
15
+ button.dataset.nlSlot = `button-${index}`;
16
+ if (descriptor.testID) button.dataset.testid = descriptor.testID;
17
+ button.setAttribute('aria-label', descriptor.accessibilityLabel ?? descriptor.label);
18
+ button.disabled = Boolean(row.disabled || descriptor.disabled || descriptor.loading);
19
+ button.setAttribute('aria-busy', descriptor.loading ? 'true' : 'false');
20
+ markActionAnchorSource(button, 'buttonGroup', index);
21
+ const label = body.ownerDocument.createElement('span');
22
+ label.textContent = descriptor.label;
23
+ if (descriptor.loading) {
24
+ const spinner = body.ownerDocument.createElement('span');
25
+ spinner.className = 'ok-native-list-spinner';
26
+ spinner.setAttribute('role', 'progressbar');
27
+ button.appendChild(spinner);
28
+ }
29
+ button.appendChild(label);
30
+ body.appendChild(button);
31
+ });
32
+ }
33
+ function create(document, row, _primitives) {
34
+ const body = document.createElement('div');
35
+ body.dataset.nlRenderer = 'buttonGroup';
36
+ bind(body, row);
37
+ return body;
38
+ }
39
+ export const buttonGroupRowRenderer = {
40
+ key: 'buttonGroup',
41
+ create,
42
+ bind,
43
+ recycle: body => body.replaceChildren(),
44
+ measure: (_row, _width) => 64,
45
+ measureRendered: body => body.scrollHeight
46
+ };
47
+ //# sourceMappingURL=ButtonGroupRowRenderer.js.map