@onekeyfe/react-native-native-list 6.7.0-2 → 6.7.0-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/SPEC.md +365 -9
- package/lib/module/NativeList.js +2 -0
- package/lib/module/NativeList.web.js +135 -29
- package/lib/module/validation.js +143 -34
- package/lib/module/web/NativeListWebEngine.js +353 -62
- package/lib/module/web/templates/ActivityRowRenderer.js +432 -5
- package/lib/module/web/templates/MarketRowRenderer.js +8 -3
- package/lib/module/web/templates/MarketTableRowRenderer.js +576 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
- package/lib/module/web/templates/RowRendererRegistry.js +5 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +34 -1
- package/lib/typescript/src/NativeList.types.d.ts +11 -1
- package/lib/typescript/src/NativeList.web.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +71 -1
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +26 -1
- package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
- package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
- package/package.json +3 -3
- package/src/NativeList.tsx +2 -0
- package/src/NativeList.types.ts +12 -1
- package/src/NativeList.web.tsx +183 -38
- package/src/models.ts +93 -0
- package/src/validation.ts +348 -58
- package/src/web/NativeListWebEngine.ts +600 -95
- package/src/web/templates/ActivityRowRenderer.ts +656 -7
- package/src/web/templates/MarketRowRenderer.ts +19 -3
- package/src/web/templates/MarketTableRowRenderer.ts +752 -0
- package/src/web/templates/MediaTileRowRenderer.ts +313 -5
- package/src/web/templates/RowRendererRegistry.ts +10 -5
- package/src/web/templates/SectionHeaderRowRenderer.ts +42 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const views = new WeakMap();
|
|
4
|
-
function
|
|
4
|
+
function bindLegacy(body, row, primitives) {
|
|
5
5
|
const v = views.get(body);
|
|
6
6
|
v.primitives = primitives;
|
|
7
7
|
const style = row.style;
|
|
@@ -73,7 +73,7 @@ function bind(body, row, primitives) {
|
|
|
73
73
|
body.appendChild(v.close);
|
|
74
74
|
} else v.close.remove();
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function createLegacy(document, row, primitives) {
|
|
77
77
|
const node = (tag, className, slot) => {
|
|
78
78
|
const n = document.createElement(tag);
|
|
79
79
|
n.className = className;
|
|
@@ -106,10 +106,10 @@ function create(document, row, primitives) {
|
|
|
106
106
|
imageKey: '',
|
|
107
107
|
networkKey: ''
|
|
108
108
|
});
|
|
109
|
-
|
|
109
|
+
bindLegacy(body, row, primitives);
|
|
110
110
|
return body;
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function recycleLegacy(body) {
|
|
113
113
|
const v = views.get(body);
|
|
114
114
|
if (!v) return;
|
|
115
115
|
[v.image, v.network].forEach(n => {
|
|
@@ -121,12 +121,267 @@ function recycle(body) {
|
|
|
121
121
|
v.image = v.network = undefined;
|
|
122
122
|
v.imageKey = v.networkKey = '';
|
|
123
123
|
}
|
|
124
|
+
const galleries = new WeakMap();
|
|
125
|
+
const isGalleryMedia = row => row.variant === 'gallery' && !row.image;
|
|
126
|
+
function clearGalleryMedia(v) {
|
|
127
|
+
v.epoch += 1;
|
|
128
|
+
v.frame.style.borderRadius = '10px';
|
|
129
|
+
if (!v.media) return;
|
|
130
|
+
v.media.onerror = null;
|
|
131
|
+
v.media.onload = null;
|
|
132
|
+
v.media.onloadeddata = null;
|
|
133
|
+
if (v.media.tagName === 'VIDEO') {
|
|
134
|
+
const video = v.media;
|
|
135
|
+
video.pause();
|
|
136
|
+
video.removeAttribute('src');
|
|
137
|
+
video.load();
|
|
138
|
+
} else v.media.removeAttribute('src');
|
|
139
|
+
v.media.remove();
|
|
140
|
+
v.media = undefined;
|
|
141
|
+
}
|
|
142
|
+
function initGallery(body, primitives) {
|
|
143
|
+
const document = body.ownerDocument;
|
|
144
|
+
const element = className => {
|
|
145
|
+
const node = document.createElement('div');
|
|
146
|
+
node.className = className;
|
|
147
|
+
return node;
|
|
148
|
+
};
|
|
149
|
+
const frame = element('ok-native-list-media-image');
|
|
150
|
+
const fallback = element('ok-native-list-media-fallback');
|
|
151
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
152
|
+
svg.setAttribute('viewBox', '0 0 24 24');
|
|
153
|
+
svg.setAttribute('width', '24');
|
|
154
|
+
svg.setAttribute('height', '24');
|
|
155
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
156
|
+
svg.setAttribute('fill', 'currentColor');
|
|
157
|
+
for (const d of ['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']) {
|
|
158
|
+
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
159
|
+
path.setAttribute('d', d);
|
|
160
|
+
path.setAttribute('fill-rule', 'evenodd');
|
|
161
|
+
svg.append(path);
|
|
162
|
+
}
|
|
163
|
+
fallback.append(svg);
|
|
164
|
+
Object.assign(fallback.style, {
|
|
165
|
+
position: 'absolute',
|
|
166
|
+
inset: '0',
|
|
167
|
+
display: 'flex',
|
|
168
|
+
alignItems: 'center',
|
|
169
|
+
justifyContent: 'center',
|
|
170
|
+
color: 'var(--nl-disabled)',
|
|
171
|
+
borderRadius: '10px',
|
|
172
|
+
background: 'var(--nl-strong)'
|
|
173
|
+
});
|
|
174
|
+
const metadata = element('ok-native-list-media-meta');
|
|
175
|
+
const subtitleLine = element('ok-native-list-media-subtitle-row');
|
|
176
|
+
const subtitle = element('ok-native-list-media-subtitle');
|
|
177
|
+
const title = element('ok-native-list-media-title');
|
|
178
|
+
const badge = element('ok-native-list-badge');
|
|
179
|
+
subtitle.dataset.nlSlot = 'subtitle';
|
|
180
|
+
title.dataset.nlSlot = 'title';
|
|
181
|
+
badge.dataset.nlSlot = 'badge';
|
|
182
|
+
subtitleLine.append(subtitle);
|
|
183
|
+
metadata.append(subtitleLine, title);
|
|
184
|
+
frame.append(fallback);
|
|
185
|
+
body.replaceChildren(frame, metadata);
|
|
186
|
+
const enter = () => {
|
|
187
|
+
frame.style.opacity = '0.8';
|
|
188
|
+
};
|
|
189
|
+
const leave = () => {
|
|
190
|
+
frame.style.opacity = '';
|
|
191
|
+
};
|
|
192
|
+
body.addEventListener('mouseenter', enter);
|
|
193
|
+
body.addEventListener('mouseleave', leave);
|
|
194
|
+
const v = {
|
|
195
|
+
frame,
|
|
196
|
+
fallback,
|
|
197
|
+
metadata,
|
|
198
|
+
subtitleLine,
|
|
199
|
+
subtitle,
|
|
200
|
+
title,
|
|
201
|
+
badge,
|
|
202
|
+
networkKey: '',
|
|
203
|
+
mediaKey: '',
|
|
204
|
+
epoch: 0,
|
|
205
|
+
primitives,
|
|
206
|
+
enter,
|
|
207
|
+
leave
|
|
208
|
+
};
|
|
209
|
+
galleries.set(body, v);
|
|
210
|
+
return v;
|
|
211
|
+
}
|
|
212
|
+
function bindGallery(body, row, primitives) {
|
|
213
|
+
const v = galleries.get(body) ?? initGallery(body, primitives);
|
|
214
|
+
v.primitives = primitives;
|
|
215
|
+
const style = row.style;
|
|
216
|
+
body.className = 'ok-native-list-row ok-native-list-media';
|
|
217
|
+
body.style.cssText = '';
|
|
218
|
+
body.removeAttribute('data-nl-container-background');
|
|
219
|
+
body.removeAttribute('data-nl-container-border');
|
|
220
|
+
Object.assign(body.style, {
|
|
221
|
+
display: 'block',
|
|
222
|
+
position: 'relative',
|
|
223
|
+
boxSizing: 'border-box',
|
|
224
|
+
padding: `${style?.verticalPadding ?? 10}px ${style?.horizontalPadding ?? 10}px`,
|
|
225
|
+
borderRadius: '16px',
|
|
226
|
+
background: 'transparent',
|
|
227
|
+
height: 'auto'
|
|
228
|
+
});
|
|
229
|
+
Object.assign(v.frame.style, {
|
|
230
|
+
position: 'relative',
|
|
231
|
+
width: '100%',
|
|
232
|
+
height: 'auto',
|
|
233
|
+
aspectRatio: '1',
|
|
234
|
+
borderRadius: v.media?.tagName === 'VIDEO' ? '0' : '10px',
|
|
235
|
+
overflow: 'hidden',
|
|
236
|
+
background: 'var(--nl-bg)'
|
|
237
|
+
});
|
|
238
|
+
v.metadata.style.paddingTop = `${style?.leadingGap ?? 8}px`;
|
|
239
|
+
v.subtitleLine.style.gap = '0px';
|
|
240
|
+
v.subtitle.style.cssText = 'font-size:12px;line-height:16px;font-weight:400;box-sizing:border-box;padding-right:8px';
|
|
241
|
+
v.title.style.cssText = 'font-size:16px;line-height:24px;font-weight:500';
|
|
242
|
+
v.subtitle.textContent = row.subtitle || '-';
|
|
243
|
+
v.title.textContent = row.title || '-';
|
|
244
|
+
if (style?.subtitle) primitives.textStyle(v.subtitle, style.subtitle);
|
|
245
|
+
if (style?.title) primitives.textStyle(v.title, style.title);
|
|
246
|
+
const mediaKey = JSON.stringify([row.key, row.media, row.imageState]);
|
|
247
|
+
if (v.mediaKey !== mediaKey) {
|
|
248
|
+
clearGalleryMedia(v);
|
|
249
|
+
v.mediaKey = mediaKey;
|
|
250
|
+
v.fallback.style.visibility = 'visible';
|
|
251
|
+
const epoch = v.epoch;
|
|
252
|
+
const source = row.media?.source;
|
|
253
|
+
const probe = attempt => {
|
|
254
|
+
if (v.epoch !== epoch) return;
|
|
255
|
+
const kind = row.media?.probeOrder[attempt];
|
|
256
|
+
if (!source?.uri || !kind) return;
|
|
257
|
+
const media = body.ownerDocument.createElement(kind === 'video' ? 'video' : 'img');
|
|
258
|
+
v.frame.style.borderRadius = kind === 'video' ? '0' : '10px';
|
|
259
|
+
Object.assign(media.style, {
|
|
260
|
+
display: 'block',
|
|
261
|
+
position: 'absolute',
|
|
262
|
+
inset: '0',
|
|
263
|
+
width: '100%',
|
|
264
|
+
height: '100%',
|
|
265
|
+
objectFit: source.contentFit === 'center' ? 'none' : source.contentFit ?? (kind === 'video' ? 'contain' : 'cover'),
|
|
266
|
+
borderRadius: kind === 'video' ? '0' : '10px',
|
|
267
|
+
pointerEvents: 'none'
|
|
268
|
+
});
|
|
269
|
+
media.setAttribute('aria-hidden', 'true');
|
|
270
|
+
if (media.tagName === 'VIDEO') {
|
|
271
|
+
const video = media;
|
|
272
|
+
video.muted = true;
|
|
273
|
+
video.autoplay = false;
|
|
274
|
+
video.controls = false;
|
|
275
|
+
video.playsInline = true;
|
|
276
|
+
video.preload = 'metadata';
|
|
277
|
+
video.tabIndex = -1;
|
|
278
|
+
} else {
|
|
279
|
+
media.alt = '';
|
|
280
|
+
media.decoding = 'async';
|
|
281
|
+
}
|
|
282
|
+
media.onerror = () => {
|
|
283
|
+
if (v.epoch !== epoch || v.media !== media) return;
|
|
284
|
+
media.onerror = null;
|
|
285
|
+
media.onload = null;
|
|
286
|
+
media.onloadeddata = null;
|
|
287
|
+
if (media.tagName === 'VIDEO') media.pause();
|
|
288
|
+
media.removeAttribute('src');
|
|
289
|
+
if (media.tagName === 'VIDEO') media.load();
|
|
290
|
+
media.remove();
|
|
291
|
+
v.media = undefined;
|
|
292
|
+
v.frame.style.borderRadius = '10px';
|
|
293
|
+
v.fallback.style.visibility = 'visible';
|
|
294
|
+
probe(attempt + 1);
|
|
295
|
+
};
|
|
296
|
+
const ready = () => {
|
|
297
|
+
if (v.epoch === epoch && v.media === media) v.fallback.style.visibility = 'hidden';
|
|
298
|
+
};
|
|
299
|
+
if (media.tagName === 'VIDEO') media.onloadeddata = ready;else media.onload = ready;
|
|
300
|
+
v.media = media;
|
|
301
|
+
v.frame.insertBefore(media, v.badge.parentNode === v.frame ? v.badge : null);
|
|
302
|
+
media.src = source.uri;
|
|
303
|
+
};
|
|
304
|
+
probe(0);
|
|
305
|
+
}
|
|
306
|
+
v.badge.textContent = row.badge?.text ?? '';
|
|
307
|
+
if (row.badge) {
|
|
308
|
+
Object.assign(v.badge.style, {
|
|
309
|
+
position: 'absolute',
|
|
310
|
+
right: '0',
|
|
311
|
+
bottom: '0',
|
|
312
|
+
boxSizing: 'content-box',
|
|
313
|
+
height: '20px',
|
|
314
|
+
padding: '0 8px',
|
|
315
|
+
border: '2px solid var(--nl-bg)',
|
|
316
|
+
borderRadius: '10px',
|
|
317
|
+
background: 'var(--nl-inverse)',
|
|
318
|
+
color: 'var(--nl-inverse-text)',
|
|
319
|
+
fontSize: '14px',
|
|
320
|
+
fontWeight: '500',
|
|
321
|
+
fontFamily: 'var(--nl-font-medium)',
|
|
322
|
+
lineHeight: '20px'
|
|
323
|
+
});
|
|
324
|
+
if (style?.badge) primitives.textStyle(v.badge, style.badge);
|
|
325
|
+
v.frame.append(v.badge);
|
|
326
|
+
} else v.badge.remove();
|
|
327
|
+
const networkKey = JSON.stringify(row.networkImage);
|
|
328
|
+
if (v.networkKey !== networkKey) {
|
|
329
|
+
if (v.network) {
|
|
330
|
+
primitives.dispose(v.network);
|
|
331
|
+
v.network.remove();
|
|
332
|
+
}
|
|
333
|
+
v.network = row.networkImage ? primitives.thumbnail(row.networkImage) : undefined;
|
|
334
|
+
if (v.network) {
|
|
335
|
+
v.network.className = 'ok-native-list-media-network';
|
|
336
|
+
v.subtitleLine.append(v.network);
|
|
337
|
+
}
|
|
338
|
+
v.networkKey = networkKey;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function recycle(body) {
|
|
342
|
+
const gallery = galleries.get(body);
|
|
343
|
+
if (gallery) {
|
|
344
|
+
clearGalleryMedia(gallery);
|
|
345
|
+
if (gallery.network) gallery.primitives.dispose(gallery.network);
|
|
346
|
+
body.removeEventListener('mouseenter', gallery.enter);
|
|
347
|
+
body.removeEventListener('mouseleave', gallery.leave);
|
|
348
|
+
galleries.delete(body);
|
|
349
|
+
}
|
|
350
|
+
recycleLegacy(body);
|
|
351
|
+
views.delete(body);
|
|
352
|
+
}
|
|
353
|
+
function bind(body, row, primitives) {
|
|
354
|
+
const gallery = isGalleryMedia(row);
|
|
355
|
+
if (gallery) {
|
|
356
|
+
if (views.has(body)) {
|
|
357
|
+
recycleLegacy(body);
|
|
358
|
+
views.delete(body);
|
|
359
|
+
}
|
|
360
|
+
bindGallery(body, row, primitives);
|
|
361
|
+
} else {
|
|
362
|
+
if (galleries.has(body)) recycle(body);
|
|
363
|
+
if (!views.has(body)) {
|
|
364
|
+
const initial = createLegacy(body.ownerDocument, row, primitives);
|
|
365
|
+
body.replaceChildren(...Array.from(initial.childNodes));
|
|
366
|
+
body.className = initial.className;
|
|
367
|
+
views.set(body, views.get(initial));
|
|
368
|
+
views.delete(initial);
|
|
369
|
+
}
|
|
370
|
+
bindLegacy(body, row, primitives);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function create(document, row, primitives) {
|
|
374
|
+
const body = document.createElement('div');
|
|
375
|
+
body.dataset.nlRenderer = 'mediaTile';
|
|
376
|
+
bind(body, row, primitives);
|
|
377
|
+
return body;
|
|
378
|
+
}
|
|
124
379
|
export const mediaTileRowRenderer = {
|
|
125
380
|
key: 'mediaTile',
|
|
126
381
|
create,
|
|
127
382
|
bind,
|
|
128
383
|
recycle,
|
|
129
|
-
measure: (
|
|
384
|
+
measure: (row, width) => isGalleryMedia(row) ? width + 48 : 244,
|
|
130
385
|
measureRendered: (_body, _row) => undefined
|
|
131
386
|
};
|
|
132
387
|
//# sourceMappingURL=MediaTileRowRenderer.js.map
|
|
@@ -4,6 +4,7 @@ import { walletGroupRowRenderer } from "./WalletGroupRowRenderer.js";
|
|
|
4
4
|
import { identityRowRenderer } from "./IdentityRowRenderer.js";
|
|
5
5
|
import { sectionHeaderRowRenderer } from "./SectionHeaderRowRenderer.js";
|
|
6
6
|
import { marketRowRenderer } from "./MarketRowRenderer.js";
|
|
7
|
+
import { marketTableRowRenderer } from "./MarketTableRowRenderer.js";
|
|
7
8
|
import { metricCardRowRenderer } from "./MetricCardRowRenderer.js";
|
|
8
9
|
import { dataRowRenderer } from "./DataRowRenderer.js";
|
|
9
10
|
import { activityRowRenderer } from "./ActivityRowRenderer.js";
|
|
@@ -27,7 +28,7 @@ const factories = {
|
|
|
27
28
|
walletGroup: row => registration(walletGroupRowRenderer, row),
|
|
28
29
|
identity: row => registration(identityRowRenderer, row),
|
|
29
30
|
sectionHeader: row => registration(sectionHeaderRowRenderer, row),
|
|
30
|
-
market: row => registration(marketRowRenderer, row),
|
|
31
|
+
market: row => row.webTable ? registration(marketTableRowRenderer, row) : registration(marketRowRenderer, row),
|
|
31
32
|
metricCard: row => registration(metricCardRowRenderer, row),
|
|
32
33
|
dataRow: row => registration(dataRowRenderer, row),
|
|
33
34
|
activity: row => registration(activityRowRenderer, row),
|
|
@@ -42,6 +43,7 @@ const renderers = {
|
|
|
42
43
|
identity: identityRowRenderer,
|
|
43
44
|
sectionHeader: sectionHeaderRowRenderer,
|
|
44
45
|
market: marketRowRenderer,
|
|
46
|
+
marketTable: marketTableRowRenderer,
|
|
45
47
|
metricCard: metricCardRowRenderer,
|
|
46
48
|
dataRow: dataRowRenderer,
|
|
47
49
|
activity: activityRowRenderer,
|
|
@@ -59,11 +61,11 @@ export function rowRenderer(row) {
|
|
|
59
61
|
return factories[row.type](row);
|
|
60
62
|
}
|
|
61
63
|
export function rowRendererKey(row) {
|
|
62
|
-
return row.type;
|
|
64
|
+
return row.type === 'market' && row.webTable ? 'marketTable' : row.type;
|
|
63
65
|
}
|
|
64
66
|
export function recycleRowBody(body) {
|
|
65
67
|
const key = body.dataset.nlRenderer ?? '';
|
|
66
|
-
if (!
|
|
68
|
+
if (!Object.prototype.hasOwnProperty.call(renderers, key)) return false;
|
|
67
69
|
renderers[key].recycle(body);
|
|
68
70
|
return true;
|
|
69
71
|
}
|
|
@@ -73,7 +73,40 @@ function createSectionHeader(document, primitives, row) {
|
|
|
73
73
|
title.replaceChildren(text, dotted);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
if (row.variant === 'history' && row.titleLoading) {
|
|
77
|
+
const pendingLine = createElement(document, 'div');
|
|
78
|
+
pendingLine.style.cssText = 'display:flex;align-items:center;gap:8px;min-width:0;width:100%;height:20px';
|
|
79
|
+
const spinner = createElement(document, 'span');
|
|
80
|
+
spinner.setAttribute('role', 'progressbar');
|
|
81
|
+
spinner.setAttribute('aria-valuemin', '0');
|
|
82
|
+
spinner.setAttribute('aria-valuemax', '1');
|
|
83
|
+
spinner.style.cssText = 'display:block;width:20px;height:20px;flex:0 0 20px';
|
|
84
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
85
|
+
svg.setAttribute('viewBox', '0 0 32 32');
|
|
86
|
+
svg.setAttribute('class', 'ok-native-list-spinner');
|
|
87
|
+
svg.style.cssText = 'display:block;width:20px;height:20px;border:0;animation-duration:.75s';
|
|
88
|
+
for (const track of [true, false]) {
|
|
89
|
+
const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
90
|
+
for (const [name, value] of Object.entries({
|
|
91
|
+
cx: '16',
|
|
92
|
+
cy: '16',
|
|
93
|
+
r: '14',
|
|
94
|
+
fill: 'none',
|
|
95
|
+
'stroke-width': '4'
|
|
96
|
+
})) circle.setAttribute(name, value);
|
|
97
|
+
circle.style.stroke = row.style?.title?.color ?? 'var(--nl-secondary)';
|
|
98
|
+
if (track) circle.style.opacity = '.2';else {
|
|
99
|
+
circle.style.strokeDasharray = '80';
|
|
100
|
+
circle.style.strokeDashoffset = '60';
|
|
101
|
+
}
|
|
102
|
+
svg.appendChild(circle);
|
|
103
|
+
}
|
|
104
|
+
spinner.appendChild(svg);
|
|
105
|
+
title.style.textTransform = 'uppercase';
|
|
106
|
+
pendingLine.append(spinner, column);
|
|
107
|
+
body.style.height = 'calc(100% + 4px)';
|
|
108
|
+
body.appendChild(pendingLine);
|
|
109
|
+
} else body.appendChild(column);
|
|
77
110
|
if (row.value) {
|
|
78
111
|
const value = tagSlot(createElement(document, row.valueActionKey ? 'button' : 'span', row.valueActionKey ? 'ok-native-list-action-button ok-native-list-section-value' : 'ok-native-list-value ok-native-list-section-value', row.value), 'value');
|
|
79
112
|
applyValueSegments(value, row.valueSegments);
|
|
@@ -43,6 +43,12 @@ export type ScrollToIndexFailedInfo = Readonly<{
|
|
|
43
43
|
averageItemLength: number;
|
|
44
44
|
reason: 'index-out-of-range' | 'section-out-of-range' | 'item-out-of-range' | 'item-not-found';
|
|
45
45
|
}>;
|
|
46
|
+
/** Minimal DOM-free structural surface for an explicit Web scroll element. */
|
|
47
|
+
export type NativeListWebScrollHost = Readonly<{
|
|
48
|
+
clientWidth: number;
|
|
49
|
+
clientHeight: number;
|
|
50
|
+
scrollTop: number;
|
|
51
|
+
}>;
|
|
46
52
|
type InitialScrollProps = Readonly<{
|
|
47
53
|
initialScrollIndex?: never;
|
|
48
54
|
initialScrollKey?: never;
|
|
@@ -76,7 +82,7 @@ export type NativeListRef = Readonly<{
|
|
|
76
82
|
}>;
|
|
77
83
|
export type NativeListProps = Omit<ViewProps, 'children'> & Readonly<{
|
|
78
84
|
snapshot: NativeListSnapshot;
|
|
79
|
-
/**
|
|
85
|
+
/** Container-owned scroll content. Never rendered as a data row. */
|
|
80
86
|
listHeader?: ReactNode;
|
|
81
87
|
listFooter?: ReactNode;
|
|
82
88
|
listEmpty?: ReactNode;
|
|
@@ -86,6 +92,10 @@ export type NativeListProps = Omit<ViewProps, 'children'> & Readonly<{
|
|
|
86
92
|
topScrollEdgeEffect?: `${ScrollEdgeEffect}`;
|
|
87
93
|
/** Web only. Defaults to true and is ignored by the native host. */
|
|
88
94
|
webVirtualizationEnabled?: boolean;
|
|
95
|
+
/** Web only: undefined owns scrolling, null waits for a host element. */
|
|
96
|
+
webScrollHost?: NativeListWebScrollHost | null;
|
|
97
|
+
/** Web only: visible sticky chrome above the parent's list viewport. */
|
|
98
|
+
webStickyInset?: number;
|
|
89
99
|
/** Web only. Hosts the section index inside this container. */
|
|
90
100
|
webSectionIndexContainerRef?: RefObject<View | null>;
|
|
91
101
|
/** Defaults to `none`. `interactive` behaves as `none` on Android. */
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { NativeListProps } from './NativeList.types';
|
|
3
|
-
import type { ImageSource, NativeListSnapshot
|
|
3
|
+
import type { ImageSource, NativeListSnapshot } from './models';
|
|
4
4
|
export type { NativeListProps, NativeListRef } from './NativeList.types';
|
|
5
5
|
export type { ActionAnchorState, NativeListKeyboardDismissMode, NativeListKeyboardShouldPersistTaps, ScrollAlignment, ScrollPositionOptions, ScrollToEndParams, ScrollToIndexFailedInfo, ScrollToIndexParams, ScrollToItemParams, ScrollToKeyParams, ScrollToLocationParams, ScrollToOffsetParams, } from './NativeList.types';
|
|
6
6
|
export declare function preloadNativeListAvatarImages(sources: readonly ImageSource[]): Promise<boolean>;
|
|
7
7
|
export declare const NativeList: React.ForwardRefExoticComponent<NativeListProps & React.RefAttributes<Readonly<{
|
|
8
8
|
applySnapshot(snapshot: NativeListSnapshot): void;
|
|
9
|
-
applyPatches(patches: readonly RowPatch[]): void;
|
|
9
|
+
applyPatches(patches: readonly import("./models").RowPatch[]): void;
|
|
10
10
|
reconcileSelection(selectedKeys: readonly string[]): void;
|
|
11
11
|
scrollToKey: (paramsOrKey: import("./NativeList.types").ScrollToKeyParams | string, animated?: boolean, alignment?: import("./NativeList.types").ScrollAlignment) => void;
|
|
12
12
|
scrollToIndex: (paramsOrIndex: import("./NativeList.types").ScrollToIndexParams | number, animated?: boolean, alignment?: import("./NativeList.types").ScrollAlignment) => void;
|
|
@@ -22,6 +22,8 @@ export type ImageSource = Readonly<{
|
|
|
22
22
|
/** Defaults to `none` in NativeList; use `static` or `skeleton` to opt into loading UI. */
|
|
23
23
|
loadingStrategy?: ImageLoadingStrategy;
|
|
24
24
|
fallbackUri?: string;
|
|
25
|
+
/** Web-only ordered continuation; retries each source before advancing. */
|
|
26
|
+
fallbackUris?: readonly string[];
|
|
25
27
|
retryTimes?: number;
|
|
26
28
|
}>;
|
|
27
29
|
export type BadgeModel = Readonly<{
|
|
@@ -467,10 +469,69 @@ export type DataRow = RowBase & Readonly<{
|
|
|
467
469
|
favoriteActive?: boolean;
|
|
468
470
|
style?: DataRowStyle;
|
|
469
471
|
}>;
|
|
472
|
+
export type WebMarketTableColumn = Readonly<{
|
|
473
|
+
key: string;
|
|
474
|
+
width?: number;
|
|
475
|
+
minWidth?: number;
|
|
476
|
+
flex?: number;
|
|
477
|
+
alignment?: 'start' | 'center' | 'end';
|
|
478
|
+
paddingStart?: number;
|
|
479
|
+
paddingEnd?: number;
|
|
480
|
+
}>;
|
|
481
|
+
export type WebMarketTableText = Readonly<{
|
|
482
|
+
text: string;
|
|
483
|
+
segments?: readonly ValueTextSegment[];
|
|
484
|
+
tone?: TextTone;
|
|
485
|
+
style?: Pick<NativeListTextStyle, 'fontSize' | 'fontWeight' | 'lineHeight' | 'color'>;
|
|
486
|
+
}>;
|
|
487
|
+
export type WebMarketTableCell = Readonly<{
|
|
488
|
+
key: string;
|
|
489
|
+
}> & (Readonly<{
|
|
490
|
+
kind: 'favorite';
|
|
491
|
+
active: boolean;
|
|
492
|
+
disabled?: boolean;
|
|
493
|
+
testID?: string;
|
|
494
|
+
hoverActionKey?: string;
|
|
495
|
+
actionKey: string;
|
|
496
|
+
accessibilityLabel: string;
|
|
497
|
+
}> | Readonly<{
|
|
498
|
+
kind: 'asset';
|
|
499
|
+
leading: LeadingVisual;
|
|
500
|
+
title: WebMarketTableText;
|
|
501
|
+
secondary?: readonly WebMarketTableText[];
|
|
502
|
+
lineGap?: number;
|
|
503
|
+
secondaryBadges?: readonly Pick<MarketBadgeModel, 'key' | 'text' | 'style'>[];
|
|
504
|
+
hoverImages?: readonly (ImageSource | null)[];
|
|
505
|
+
hoverSecondary?: readonly WebMarketTableText[];
|
|
506
|
+
hoverActionKey?: string;
|
|
507
|
+
hoverActionLabel?: string;
|
|
508
|
+
badges?: readonly Pick<MarketBadgeModel, 'key' | 'text' | 'iconName' | 'icon' | 'textColor' | 'backgroundColor' | 'actionKey' | 'accessibilityLabel' | 'style'>[];
|
|
509
|
+
}> | Readonly<{
|
|
510
|
+
kind: 'text';
|
|
511
|
+
primary: readonly WebMarketTableText[];
|
|
512
|
+
partGap?: number;
|
|
513
|
+
secondary?: readonly WebMarketTableText[];
|
|
514
|
+
}> | Readonly<{
|
|
515
|
+
kind: 'sparkline';
|
|
516
|
+
points: readonly number[];
|
|
517
|
+
width: number;
|
|
518
|
+
height: number;
|
|
519
|
+
strokeColor: string;
|
|
520
|
+
fillColor: string;
|
|
521
|
+
}>);
|
|
522
|
+
export type WebMarketTablePresentation = Readonly<{
|
|
523
|
+
draggable?: boolean;
|
|
524
|
+
contextMenuActionKey?: string;
|
|
525
|
+
testID?: string;
|
|
526
|
+
columns: readonly WebMarketTableColumn[];
|
|
527
|
+
cells: readonly WebMarketTableCell[];
|
|
528
|
+
}>;
|
|
470
529
|
/** Native Market quote row. All values are already localized/formatted strings. */
|
|
471
530
|
export type MarketRow = RowBase & Readonly<{
|
|
472
531
|
type: 'market';
|
|
473
532
|
variant: 'token' | 'stock' | 'perp';
|
|
533
|
+
/** Web-only bounded table presentation; native reads the ordinary Market fields. */
|
|
534
|
+
webTable?: WebMarketTablePresentation;
|
|
474
535
|
leadingAction?: Extract<TrailingAccessory, {
|
|
475
536
|
kind: 'icon';
|
|
476
537
|
}>;
|
|
@@ -480,6 +541,8 @@ export type MarketRow = RowBase & Readonly<{
|
|
|
480
541
|
/** OneKey patch: localized name shrinks independently of the volume. */
|
|
481
542
|
subtitlePrefix?: Readonly<{
|
|
482
543
|
text: string;
|
|
544
|
+
/** Web-only anchored help for a truncated name. */
|
|
545
|
+
hoverActionKey?: string;
|
|
483
546
|
gap?: number;
|
|
484
547
|
maxWidth?: number;
|
|
485
548
|
style?: MarketTextStyle;
|
|
@@ -626,6 +689,8 @@ export type NativeListTheme = Readonly<{
|
|
|
626
689
|
rowPressedBackground?: string;
|
|
627
690
|
subduedBackground?: string;
|
|
628
691
|
strongBackground?: string;
|
|
692
|
+
/** Web-only background for a displayed declared image fallback. */
|
|
693
|
+
imageFallbackBackground?: string;
|
|
629
694
|
primaryText: string;
|
|
630
695
|
secondaryText: string;
|
|
631
696
|
disabledText?: string;
|
|
@@ -730,7 +795,7 @@ export type RowPatch = Readonly<{
|
|
|
730
795
|
}> | Readonly<{
|
|
731
796
|
type: 'market';
|
|
732
797
|
key: string;
|
|
733
|
-
changes: Partial<Pick<MarketRow, CommonPatchFields | 'leadingAction' | 'leading' | 'title' | 'subtitle' | 'subtitleSegments' | 'price' | 'priceSegments' | 'change' | 'badges' | 'pressActionKey' | 'pressInActionKey' | 'longPressActionKey' | 'diagnostics' | 'style'>>;
|
|
798
|
+
changes: Partial<Pick<MarketRow, CommonPatchFields | 'leadingAction' | 'leading' | 'title' | 'subtitle' | 'subtitleSegments' | 'price' | 'priceSegments' | 'change' | 'badges' | 'pressActionKey' | 'pressInActionKey' | 'longPressActionKey' | 'diagnostics' | 'webTable' | 'style'>>;
|
|
734
799
|
}> | Readonly<{
|
|
735
800
|
type: 'mediaTile';
|
|
736
801
|
key: string;
|
|
@@ -779,6 +844,11 @@ export type NativeListActionAnchor = Readonly<{
|
|
|
779
844
|
layoutDirection: 'ltr' | 'rtl';
|
|
780
845
|
}>;
|
|
781
846
|
export type RowActionEvent = Readonly<{
|
|
847
|
+
/** Web-only client/window CSS pixel pointer location. */
|
|
848
|
+
windowPoint?: Readonly<{
|
|
849
|
+
x: number;
|
|
850
|
+
y: number;
|
|
851
|
+
}>;
|
|
782
852
|
rowKey?: string;
|
|
783
853
|
actionKey: string;
|
|
784
854
|
sectionKey?: string;
|
|
@@ -83,7 +83,20 @@ export declare function isWebMarketQuotePatch(patch: RowPatch): boolean;
|
|
|
83
83
|
export declare function webMarketImageBindDeltaForPatches(patches: readonly RowPatch[]): 0 | 1;
|
|
84
84
|
export declare const WEB_LIST_CSS: string;
|
|
85
85
|
export declare function createRowBody(context: RenderContext, row: RowModel): HTMLElement;
|
|
86
|
+
export type NativeListWebScrollOptions = Readonly<{
|
|
87
|
+
scrollHost?: HTMLElement;
|
|
88
|
+
contentBounds?: HTMLElement;
|
|
89
|
+
stickyInset?: number;
|
|
90
|
+
ownsRefresh?: boolean;
|
|
91
|
+
}>;
|
|
86
92
|
export declare class NativeListWebEngine {
|
|
93
|
+
private readonly externalScrollHost;
|
|
94
|
+
private readonly ownsRefresh;
|
|
95
|
+
private readonly pullTarget;
|
|
96
|
+
private readonly contentBounds;
|
|
97
|
+
private externalStickyInset;
|
|
98
|
+
private externalOrigin;
|
|
99
|
+
private externalGeometryCache;
|
|
87
100
|
private readonly document;
|
|
88
101
|
private readonly root;
|
|
89
102
|
private readonly viewportFrame;
|
|
@@ -144,13 +157,19 @@ export declare class NativeListWebEngine {
|
|
|
144
157
|
private measuredRendererHeights;
|
|
145
158
|
private notifyScrollCommandAccepted;
|
|
146
159
|
private readonly handlePagerScrollCommandCancel;
|
|
147
|
-
constructor(host: HTMLElement, snapshot: NativeListSnapshot, callbacks: NativeListWebCallbacks, virtualizationEnabled?: boolean, sectionIndexContainer?: HTMLElement | null, fontFamiliesJson?: string);
|
|
160
|
+
constructor(host: HTMLElement, snapshot: NativeListSnapshot, callbacks: NativeListWebCallbacks, virtualizationEnabled?: boolean, sectionIndexContainer?: HTMLElement | null, fontFamiliesJson?: string, scrollOptions?: NativeListWebScrollOptions);
|
|
161
|
+
private validateStickyInset;
|
|
162
|
+
setStickyInset(value?: number): void;
|
|
163
|
+
private externalGeometry;
|
|
164
|
+
private readExternalGeometry;
|
|
148
165
|
private fontFamiliesJson;
|
|
149
166
|
private applyFontFamilies;
|
|
150
167
|
setFontFamiliesJson(json: string): void;
|
|
151
168
|
updateCallbacks(callbacks: NativeListWebCallbacks): void;
|
|
152
169
|
setVirtualizationEnabled(enabled: boolean): void;
|
|
153
170
|
applySnapshot(snapshot: NativeListSnapshot): void;
|
|
171
|
+
currentContentHeight(): number;
|
|
172
|
+
currentSnapshot(): NativeListSnapshot;
|
|
154
173
|
applyPatches(patches: readonly RowPatch[]): void;
|
|
155
174
|
reconcileSelection(keys: readonly string[]): void;
|
|
156
175
|
scrollToIndex(index: number, scroll: NormalizedPositionScroll): void;
|
|
@@ -169,6 +188,8 @@ export declare class NativeListWebEngine {
|
|
|
169
188
|
* renders exactly as before. See docs/STYLE_SPEC.md §5.
|
|
170
189
|
*/
|
|
171
190
|
private applyListStyle;
|
|
191
|
+
private computeLayout;
|
|
192
|
+
private writeExternalHeight;
|
|
172
193
|
private recomputeLayout;
|
|
173
194
|
private updateAvatarWindow;
|
|
174
195
|
private renderWindow;
|
|
@@ -197,6 +218,7 @@ export declare class NativeListWebEngine {
|
|
|
197
218
|
private collapsiblePagerInsets;
|
|
198
219
|
private verticalScrollMetrics;
|
|
199
220
|
private handleCollapsiblePagerInsetsChanged;
|
|
221
|
+
private writeExternalOffset;
|
|
200
222
|
private scrollToAbsoluteOffset;
|
|
201
223
|
private performPendingScroll;
|
|
202
224
|
private rowAtElement;
|
|
@@ -211,8 +233,10 @@ export declare class NativeListWebEngine {
|
|
|
211
233
|
private emitActionAnchorInvalidated;
|
|
212
234
|
private handleRowPress;
|
|
213
235
|
private cancelMarketPointer;
|
|
236
|
+
private handleMarketContextMenu;
|
|
214
237
|
private handleMarketPointerDown;
|
|
215
238
|
private handleMarketPointerMove;
|
|
239
|
+
private handleMarketTouchMove;
|
|
216
240
|
private handleMarketPointerEnd;
|
|
217
241
|
private handleTitlePointerOver;
|
|
218
242
|
private handleTitlePointerOut;
|
|
@@ -222,6 +246,7 @@ export declare class NativeListWebEngine {
|
|
|
222
246
|
private moveKeyboardReorder;
|
|
223
247
|
private finishKeyboardReorder;
|
|
224
248
|
private cancelKeyboardReorder;
|
|
249
|
+
private handleExternalScroll;
|
|
225
250
|
private handleScroll;
|
|
226
251
|
private handleWindowResize;
|
|
227
252
|
private scheduleFrame;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { ActivityRow } from '../../models';
|
|
2
2
|
import { type RowPrimitives } from './RowVisual';
|
|
3
|
-
declare function bind(body: HTMLElement, row: ActivityRow, primitives: RowPrimitives): void;
|
|
4
|
-
declare function create(document: Document, row: ActivityRow, primitives: RowPrimitives): HTMLElement;
|
|
5
3
|
declare function recycle(body: HTMLElement): void;
|
|
4
|
+
declare function bind(body: HTMLElement, row: ActivityRow, primitives: RowPrimitives): void;
|
|
5
|
+
declare function create(document: Document, row: ActivityRow, primitives: RowPrimitives): HTMLDivElement;
|
|
6
6
|
export declare const activityRowRenderer: {
|
|
7
7
|
key: "activity";
|
|
8
8
|
create: typeof create;
|
|
9
9
|
bind: typeof bind;
|
|
10
10
|
recycle: typeof recycle;
|
|
11
|
-
measure: (row: ActivityRow, _width: number) =>
|
|
11
|
+
measure: (row: ActivityRow, _width: number) => number;
|
|
12
12
|
measureRendered: (_body: HTMLElement, _row: ActivityRow) => number | undefined;
|
|
13
13
|
};
|
|
14
14
|
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MarketRow } from '../../models';
|
|
2
|
+
import type { RowPrimitives } from './RowVisual';
|
|
3
|
+
export declare function canPatchMarketTableValues(previous: MarketRow, next: MarketRow): boolean;
|
|
4
|
+
declare function bind(body: HTMLElement, row: MarketRow, primitives: RowPrimitives): void;
|
|
5
|
+
declare function create(document: Document, row: MarketRow, primitives: RowPrimitives): HTMLElement;
|
|
6
|
+
export declare function updateMarketTableValues(element: HTMLElement, row: MarketRow): void;
|
|
7
|
+
export declare const marketTableRowRenderer: {
|
|
8
|
+
key: string;
|
|
9
|
+
appliesSizePreset: () => boolean;
|
|
10
|
+
create: typeof create;
|
|
11
|
+
bind: typeof bind;
|
|
12
|
+
measure: () => number;
|
|
13
|
+
measureRendered: () => undefined;
|
|
14
|
+
recycle: (body: HTMLElement) => void;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=MarketTableRowRenderer.d.ts.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { MediaTileRow } from '../../models';
|
|
2
2
|
import type { RowPrimitives } from './RowVisual';
|
|
3
|
-
declare function bind(body: HTMLElement, row: MediaTileRow, primitives: RowPrimitives): void;
|
|
4
|
-
declare function create(document: Document, row: MediaTileRow, primitives: RowPrimitives): HTMLElement;
|
|
5
3
|
declare function recycle(body: HTMLElement): void;
|
|
4
|
+
declare function bind(body: HTMLElement, row: MediaTileRow, primitives: RowPrimitives): void;
|
|
5
|
+
declare function create(document: Document, row: MediaTileRow, primitives: RowPrimitives): HTMLDivElement;
|
|
6
6
|
export declare const mediaTileRowRenderer: {
|
|
7
7
|
key: "mediaTile";
|
|
8
8
|
create: typeof create;
|
|
9
9
|
bind: typeof bind;
|
|
10
10
|
recycle: typeof recycle;
|
|
11
|
-
measure: (
|
|
11
|
+
measure: (row: MediaTileRow, width: number) => number;
|
|
12
12
|
measureRendered: (_body: HTMLElement, _row: MediaTileRow) => number | undefined;
|
|
13
13
|
};
|
|
14
14
|
export {};
|