@onekeyfe/react-native-native-list 6.7.0-1 → 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/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +1 -1
- package/docs/SPEC.md +380 -11
- package/ios/HybridNativeList.swift +11 -3
- package/ios/RNCNativeListView.swift +10 -6
- package/ios/tests/NativeListLifecycleTests.swift +28 -0
- package/lib/module/NativeList.js +4 -2
- package/lib/module/NativeList.web.js +135 -29
- package/lib/module/ScrollEdgeEffect.js +8 -0
- package/lib/module/index.js +1 -0
- 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/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +10 -6
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -2
- package/lib/nitrogen/generated/android/c++/JNativeListScrollEdgeEffect.hpp +61 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +3 -3
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +1 -1
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollEdgeEffect.kt +24 -0
- package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +3 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +8 -4
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +4 -4
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -1
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +3 -3
- package/lib/nitrogen/generated/ios/swift/NativeListScrollEdgeEffect.swift +44 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -2
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +5 -2
- package/lib/nitrogen/generated/shared/c++/NativeListScrollEdgeEffect.hpp +80 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +4 -3
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +1 -1
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -1
- package/lib/typescript/src/NativeList.types.d.ts +14 -3
- package/lib/typescript/src/NativeList.web.d.ts +2 -2
- package/lib/typescript/src/ScrollEdgeEffect.d.ts +5 -0
- package/lib/typescript/src/index.d.ts +1 -0
- 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/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +10 -6
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -2
- package/nitrogen/generated/android/c++/JNativeListScrollEdgeEffect.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +3 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollEdgeEffect.kt +24 -0
- package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +8 -4
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +4 -4
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +3 -3
- package/nitrogen/generated/ios/swift/NativeListScrollEdgeEffect.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -2
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +5 -2
- package/nitrogen/generated/shared/c++/NativeListScrollEdgeEffect.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -2
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +4 -3
- package/nitrogen/generated/shared/json/NativeListConfig.json +1 -1
- package/package.json +3 -3
- package/react-native-native-list.podspec +4 -1
- package/src/NativeList.nitro.ts +3 -1
- package/src/NativeList.tsx +6 -2
- package/src/NativeList.types.ts +15 -3
- package/src/NativeList.web.tsx +183 -38
- package/src/ScrollEdgeEffect.ts +4 -0
- package/src/index.ts +2 -0
- 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
|
@@ -15,7 +15,11 @@ type Views = {
|
|
|
15
15
|
primitives: RowPrimitives;
|
|
16
16
|
};
|
|
17
17
|
const views = new WeakMap<HTMLElement, Views>();
|
|
18
|
-
function
|
|
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
|
|
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
|
-
|
|
161
|
+
bindLegacy(body, row, primitives);
|
|
158
162
|
return body;
|
|
159
163
|
}
|
|
160
|
-
function
|
|
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;
|
|
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.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: (
|
|
484
|
+
measure: (row: MediaTileRow, width: number) =>
|
|
485
|
+
isGalleryMedia(row) ? width + 48 : 244,
|
|
178
486
|
measureRendered: (
|
|
179
487
|
_body: HTMLElement,
|
|
180
488
|
_row: MediaTileRow
|
|
@@ -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';
|
|
@@ -59,7 +60,10 @@ const factories = {
|
|
|
59
60
|
registration(identityRowRenderer, row as IdentityRow),
|
|
60
61
|
sectionHeader: (row: RowModel) =>
|
|
61
62
|
registration(sectionHeaderRowRenderer, row as SectionHeaderRow),
|
|
62
|
-
market: (row: RowModel) =>
|
|
63
|
+
market: (row: RowModel) =>
|
|
64
|
+
(row as MarketRow).webTable
|
|
65
|
+
? registration(marketTableRowRenderer, row as MarketRow)
|
|
66
|
+
: registration(marketRowRenderer, row as MarketRow),
|
|
63
67
|
metricCard: (row: RowModel) =>
|
|
64
68
|
registration(metricCardRowRenderer, row as MetricCardRow),
|
|
65
69
|
dataRow: (row: RowModel) => registration(dataRowRenderer, row as DataRow),
|
|
@@ -81,6 +85,7 @@ const renderers = {
|
|
|
81
85
|
identity: identityRowRenderer,
|
|
82
86
|
sectionHeader: sectionHeaderRowRenderer,
|
|
83
87
|
market: marketRowRenderer,
|
|
88
|
+
marketTable: marketTableRowRenderer,
|
|
84
89
|
metricCard: metricCardRowRenderer,
|
|
85
90
|
dataRow: dataRowRenderer,
|
|
86
91
|
activity: activityRowRenderer,
|
|
@@ -90,7 +95,7 @@ const renderers = {
|
|
|
90
95
|
rail: railRowRenderer,
|
|
91
96
|
mediaTile: mediaTileRowRenderer,
|
|
92
97
|
};
|
|
93
|
-
export type RowRendererKey = RowModel['type'];
|
|
98
|
+
export type RowRendererKey = RowModel['type'] | 'marketTable';
|
|
94
99
|
const isRegistered = (key: string): key is keyof typeof factories =>
|
|
95
100
|
Object.prototype.hasOwnProperty.call(factories, key);
|
|
96
101
|
|
|
@@ -101,11 +106,11 @@ export function rowRenderer(row: RowModel) {
|
|
|
101
106
|
return factories[row.type](row);
|
|
102
107
|
}
|
|
103
108
|
export function rowRendererKey(row: RowModel): RowRendererKey {
|
|
104
|
-
return row.type;
|
|
109
|
+
return row.type === 'market' && row.webTable ? 'marketTable' : row.type;
|
|
105
110
|
}
|
|
106
111
|
export function recycleRowBody(body: HTMLElement): boolean {
|
|
107
112
|
const key = body.dataset.nlRenderer ?? '';
|
|
108
|
-
if (!
|
|
109
|
-
renderers[key].recycle(body);
|
|
113
|
+
if (!Object.prototype.hasOwnProperty.call(renderers, key)) return false;
|
|
114
|
+
renderers[key as RowRendererKey].recycle(body);
|
|
110
115
|
return true;
|
|
111
116
|
}
|
|
@@ -114,7 +114,48 @@ function createSectionHeader(
|
|
|
114
114
|
title.replaceChildren(text, dotted);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
if (row.variant === 'history' && row.titleLoading) {
|
|
118
|
+
const pendingLine = createElement(document, 'div');
|
|
119
|
+
pendingLine.style.cssText =
|
|
120
|
+
'display:flex;align-items:center;gap:8px;min-width:0;width:100%;height:20px';
|
|
121
|
+
const spinner = createElement(document, 'span');
|
|
122
|
+
spinner.setAttribute('role', 'progressbar');
|
|
123
|
+
spinner.setAttribute('aria-valuemin', '0');
|
|
124
|
+
spinner.setAttribute('aria-valuemax', '1');
|
|
125
|
+
spinner.style.cssText =
|
|
126
|
+
'display:block;width:20px;height:20px;flex:0 0 20px';
|
|
127
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
128
|
+
svg.setAttribute('viewBox', '0 0 32 32');
|
|
129
|
+
svg.setAttribute('class', 'ok-native-list-spinner');
|
|
130
|
+
svg.style.cssText =
|
|
131
|
+
'display:block;width:20px;height:20px;border:0;animation-duration:.75s';
|
|
132
|
+
for (const track of [true, false]) {
|
|
133
|
+
const circle = document.createElementNS(
|
|
134
|
+
'http://www.w3.org/2000/svg',
|
|
135
|
+
'circle'
|
|
136
|
+
);
|
|
137
|
+
for (const [name, value] of Object.entries({
|
|
138
|
+
cx: '16',
|
|
139
|
+
cy: '16',
|
|
140
|
+
r: '14',
|
|
141
|
+
fill: 'none',
|
|
142
|
+
'stroke-width': '4',
|
|
143
|
+
}))
|
|
144
|
+
circle.setAttribute(name, value);
|
|
145
|
+
circle.style.stroke = row.style?.title?.color ?? 'var(--nl-secondary)';
|
|
146
|
+
if (track) circle.style.opacity = '.2';
|
|
147
|
+
else {
|
|
148
|
+
circle.style.strokeDasharray = '80';
|
|
149
|
+
circle.style.strokeDashoffset = '60';
|
|
150
|
+
}
|
|
151
|
+
svg.appendChild(circle);
|
|
152
|
+
}
|
|
153
|
+
spinner.appendChild(svg);
|
|
154
|
+
title.style.textTransform = 'uppercase';
|
|
155
|
+
pendingLine.append(spinner, column);
|
|
156
|
+
body.style.height = 'calc(100% + 4px)';
|
|
157
|
+
body.appendChild(pendingLine);
|
|
158
|
+
} else body.appendChild(column);
|
|
118
159
|
if (row.value) {
|
|
119
160
|
const value = tagSlot(
|
|
120
161
|
createElement(
|