@onekeyfe/react-native-native-list 6.7.0-alpha.475 → 6.8.0-11

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 (54) hide show
  1. package/README.md +312 -379
  2. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +15 -6
  3. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +3 -87
  4. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
  5. package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
  6. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +60 -0
  7. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +3 -6
  8. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +5 -1
  9. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +75 -0
  10. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +25 -19
  11. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -0
  12. package/docs/ROW_TEMPLATES.md +12 -12
  13. package/docs/SPEC.md +226 -110
  14. package/docs/STYLE_SPEC.md +7 -0
  15. package/ios/NativeListActivityDetailsView.swift +13 -5
  16. package/ios/NativeListIdentityRenderer.swift +6 -94
  17. package/ios/NativeListMediaPlaceholderView.swift +189 -0
  18. package/ios/NativeListMediaTileRenderer.swift +13 -13
  19. package/ios/NativeListResolvedText.swift +15 -4
  20. package/ios/NativeListTextLabel.swift +106 -0
  21. package/ios/RNCNativeListView.swift +129 -32
  22. package/ios/tests/NativeListActivityPresentationTests.swift +270 -0
  23. package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +0 -95
  24. package/ios/tests/NativeListLifecycleTests.swift +369 -40
  25. package/ios/tests/NativeListMediaVisibilityTests.swift +16 -7
  26. package/lib/module/NativeList.js +17 -4
  27. package/lib/module/NativeList.web.js +3 -1
  28. package/lib/module/models.js +0 -2
  29. package/lib/module/validation.js +54 -71
  30. package/lib/module/web/NativeListGeneratedIcons.js +1 -0
  31. package/lib/module/web/NativeListWebEngine.js +13 -11
  32. package/lib/module/web/templates/ActivityRowRenderer.js +29 -23
  33. package/lib/module/web/templates/DataRowRenderer.js +54 -1
  34. package/lib/module/web/templates/IdentityRowRenderer.js +3 -92
  35. package/lib/module/web/templates/MediaTileRowRenderer.js +84 -15
  36. package/lib/typescript/src/models.d.ts +19 -22
  37. package/package.json +1 -1
  38. package/scripts/generate-icons.test.mjs +1 -0
  39. package/scripts/native-list-icons.json +1 -1
  40. package/src/NativeList.tsx +25 -4
  41. package/src/NativeList.web.tsx +1 -1
  42. package/src/models.ts +18 -23
  43. package/src/validation.ts +89 -113
  44. package/src/web/NativeListGeneratedIcons.ts +1 -0
  45. package/src/web/NativeListWebEngine.ts +16 -11
  46. package/src/web/templates/ActivityRowRenderer.ts +42 -32
  47. package/src/web/templates/DataRowRenderer.ts +76 -1
  48. package/src/web/templates/IdentityRowRenderer.ts +3 -141
  49. package/src/web/templates/MediaTileRowRenderer.ts +90 -15
  50. package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentLayout.kt +0 -49
  51. package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentsView.kt +0 -105
  52. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListTitleSegmentLayoutTest.kt +0 -80
  53. package/ios/NativeListTitleSegmentLayout.swift +0 -45
  54. package/ios/NativeListTitleSegmentsLabel.swift +0 -80
@@ -12,6 +12,13 @@ function bind(body, row, primitives) {
12
12
  body.removeAttribute('data-nl-container-background');
13
13
  body.removeAttribute('data-nl-container-border');
14
14
  const style = row.style;
15
+ const isTokenTable = row.index === undefined && !row.favorite && !row.checkbox && row.columns.length === 4 && row.columns[0]?.key === 'asset' && row.columns[1]?.key === 'balance' && row.columns[2]?.key === 'price' && row.columns[3]?.key === 'swapSpacer';
16
+ if (isTokenTable) {
17
+ // Match the legacy four equal columns, including the icon in the first.
18
+ body.style.display = 'grid';
19
+ body.style.gridTemplateColumns = 'repeat(4, minmax(0, 1fr))';
20
+ body.style.gap = '0';
21
+ }
15
22
  if (style?.horizontalPadding !== undefined) body.style.paddingInline = `${style.horizontalPadding}px`;
16
23
  if (style?.verticalPadding !== undefined) body.style.paddingBlock = `${style.verticalPadding}px`;
17
24
  v.controls.replaceChildren();
@@ -39,6 +46,9 @@ function bind(body, row, primitives) {
39
46
  v.visualKey = visualKey;
40
47
  }
41
48
  v.visualStyle?.apply(style?.image, style?.image?.width ?? 40, style?.image?.height ?? 40, (style?.leadingGap ?? 12) - 12);
49
+ if (v.visual) v.visual.style.gridArea = isTokenTable ? '1 / 1' : '';
50
+ v.trailing.style.gridArea = isTokenTable ? '1 / 4' : '';
51
+ v.trailing.style.justifySelf = isTokenTable ? 'end' : '';
42
52
  v.columns.forEach((cell, index) => {
43
53
  const column = row.columns[index];
44
54
  cell.body.hidden = !column;
@@ -51,6 +61,12 @@ function bind(body, row, primitives) {
51
61
  cell.body.hidden = false;
52
62
  cell.body.style.flex = String(column.weight ?? 1);
53
63
  cell.body.style.display = 'flex';
64
+ if (isTokenTable) {
65
+ cell.body.style.gridArea = `1 / ${index + 1}`;
66
+ if (index === 0 && v.visual) {
67
+ cell.body.style.marginInlineStart = `${(style?.image?.width ?? 40) + (style?.leadingGap ?? 12)}px`;
68
+ }
69
+ }
54
70
  cell.body.dataset.align = column.alignment ?? 'start';
55
71
  if (style?.lineGap !== undefined) cell.body.style.rowGap = `${style.lineGap}px`;
56
72
  cell.primaryLine.style.cssText = '';
@@ -60,6 +76,40 @@ function bind(body, row, primitives) {
60
76
  cell.primary.textContent = column.text;
61
77
  applyValueSegments(cell.primary, column.textSegments, style?.columns?.fontSize ?? 14, style?.columns?.lineHeight ?? 20, fontWeight(style?.columns?.fontWeight, 500));
62
78
  if (style?.columns) primitives.textStyle(cell.primary, style.columns);
79
+ const leadingBadge = column.webLeadingBadge;
80
+ cell.leadingBadge.hidden = !leadingBadge;
81
+ cell.leadingBadge.style.cssText = '';
82
+ cell.leadingBadge.textContent = leadingBadge?.text ?? '';
83
+ if (leadingBadge) {
84
+ // The line spans the column so the badge cap is a share of the column
85
+ // rather than of the line's own content; justifyContent then carries
86
+ // the column alignment the shrink-to-fit line got from its cell.
87
+ cell.primaryLine.style.alignSelf = 'stretch';
88
+ cell.primaryLine.style.justifyContent = column.alignment === 'end' ? 'flex-end' : column.alignment === 'center' ? 'center' : 'flex-start';
89
+ cell.primaryLine.style.gap = '8px';
90
+ // A long label truncates at half the column; the primary text keeps the
91
+ // rest and truncates after it, so neither can leave the column.
92
+ cell.leadingBadge.style.display = 'block';
93
+ cell.leadingBadge.style.boxSizing = 'border-box';
94
+ cell.leadingBadge.style.flexShrink = '0';
95
+ cell.leadingBadge.style.maxWidth = '50%';
96
+ cell.leadingBadge.style.overflow = 'hidden';
97
+ cell.leadingBadge.style.textOverflow = 'ellipsis';
98
+ cell.leadingBadge.style.whiteSpace = 'nowrap';
99
+ cell.leadingBadge.style.padding = '2px 6px';
100
+ cell.leadingBadge.style.borderRadius = '4px';
101
+ cell.leadingBadge.style.fontSize = '12px';
102
+ cell.leadingBadge.style.lineHeight = '16px';
103
+ cell.leadingBadge.style.fontWeight = '400';
104
+ cell.leadingBadge.style.fontFamily = 'var(--nl-font-regular)';
105
+ cell.leadingBadge.style.color = leadingBadge.textColor;
106
+ cell.leadingBadge.style.backgroundColor = leadingBadge.backgroundColor;
107
+ cell.leadingBadge.style.pointerEvents = 'none';
108
+ cell.primary.style.minWidth = '0';
109
+ cell.primary.style.overflow = 'hidden';
110
+ cell.primary.style.textOverflow = 'ellipsis';
111
+ cell.primary.style.whiteSpace = 'nowrap';
112
+ }
63
113
  cell.titleIcons.replaceChildren();
64
114
  if (column.titleIcon || column.secondaryTitleIcon) {
65
115
  cell.primary.style.minWidth = '0';
@@ -118,10 +168,12 @@ function create(document, row, primitives) {
118
168
  const cell = createElement(document, 'span', 'ok-native-list-data-cell');
119
169
  const primaryLine = createElement(document, 'span', 'ok-native-list-data-primary');
120
170
  const primary = tagSlot(createElement(document, 'span'), 'columns');
171
+ const leadingBadge = createElement(document, 'span', 'ok-native-list-data-leading-badge');
172
+ leadingBadge.hidden = true;
121
173
  const titleIcons = createElement(document, 'span');
122
174
  titleIcons.style.display = 'contents';
123
175
  const badges = createElement(document, 'span');
124
- primaryLine.append(primary, titleIcons, badges);
176
+ primaryLine.append(leadingBadge, primary, titleIcons, badges);
125
177
  const secondaryLine = createElement(document, 'span', 'ok-native-list-data-secondary-line');
126
178
  const secondary = Array.from({
127
179
  length: 2
@@ -133,6 +185,7 @@ function create(document, row, primitives) {
133
185
  body: cell,
134
186
  primaryLine,
135
187
  primary,
188
+ leadingBadge,
136
189
  titleIcons,
137
190
  badges,
138
191
  secondaryLine,
@@ -11,54 +11,6 @@ function toneColor(tone, fallback) {
11
11
  if (tone === 'secondary') return 'var(--nl-secondary)';
12
12
  return fallback === 'secondary' ? 'var(--nl-secondary)' : 'var(--nl-primary)';
13
13
  }
14
- // Hidden from sight, still read: the runs themselves are hidden from
15
- // assistive technology in favor of `title`.
16
- const VISUALLY_HIDDEN = {
17
- position: 'absolute',
18
- width: '1px',
19
- height: '1px',
20
- overflow: 'hidden',
21
- clip: 'rect(0 0 0 0)',
22
- whiteSpace: 'nowrap'
23
- };
24
- function appendTitleRuns(document, target, row) {
25
- const runs = createElement(document, 'span', 'ok-native-list-identity-title-runs');
26
- runs.setAttribute('aria-hidden', 'true');
27
- Object.assign(runs.style, {
28
- display: 'flex',
29
- flex: '1 1 auto',
30
- minWidth: '0',
31
- maxWidth: '100%',
32
- overflow: 'hidden'
33
- });
34
- row.titleSegments?.forEach(segment => {
35
- const run = createElement(document, 'span', 'ok-native-list-identity-title-run', segment.text);
36
- // Only the shrinking run gives up width; a cap is a share of the line.
37
- Object.assign(run.style, {
38
- flex: segment.shrink ? '0 1 auto' : '0 0 auto',
39
- minWidth: segment.shrink ? '0' : '',
40
- maxWidth: segment.maxWidthRatio === undefined ? '' : `${segment.maxWidthRatio * 100}%`,
41
- overflow: 'hidden',
42
- textOverflow: 'ellipsis',
43
- whiteSpace: 'pre'
44
- });
45
- if (segment.tone) run.style.color = segment.tone === 'secondary' ? 'var(--nl-secondary)' : 'var(--nl-primary)';
46
- if (segment.fontWeight === 'medium') {
47
- run.style.fontWeight = '500';
48
- run.style.fontFamily = 'var(--nl-font-medium)';
49
- } else if (segment.fontWeight === 'regular') {
50
- run.style.fontWeight = '400';
51
- run.style.fontFamily = 'var(--nl-font-regular)';
52
- }
53
- setData(run, 'tone', segment.tone);
54
- runs.appendChild(run);
55
- });
56
- const spoken = createElement(document, 'span', 'ok-native-list-identity-title-spoken', row.title);
57
- Object.assign(spoken.style, VISUALLY_HIDDEN);
58
- target.replaceChildren(runs, spoken);
59
- target.style.display = 'flex';
60
- target.style.minWidth = '0';
61
- }
62
14
  function appendAccessories(parent, document, primitives, row, accessories) {
63
15
  if (!accessories?.length) return;
64
16
  const container = createElement(document, 'span', 'ok-native-list-accessories');
@@ -134,13 +86,6 @@ function createIdentityRow(document, primitives, row) {
134
86
  fragment.appendChild(document.createTextNode(row.title.slice(offset)));
135
87
  textTarget.prepend(fragment);
136
88
  }
137
- // The runs replace the plain title, except where `title` itself is
138
- // highlighted or shown in the wallet sidebar.
139
- const hasTitleRuns = !!row.titleSegments?.length && presentation !== 'walletSidebar' && !row.titleMatch?.length;
140
- if (hasTitleRuns) {
141
- const textTarget = titleElement.querySelector('[data-nl-slot="title"]') ?? titleElement;
142
- appendTitleRuns(document, textTarget, row);
143
- }
144
89
  if (row.subtitleSegments?.length) {
145
90
  column.querySelector('.ok-native-list-secondary')?.remove();
146
91
  const segments = createElement(document, 'span', 'ok-native-list-subtitle-segments');
@@ -266,48 +211,12 @@ function createIdentityRow(document, primitives, row) {
266
211
  badges.style.minWidth = '0';
267
212
  }
268
213
  }
269
- if (hasTitleRuns) {
270
- // The runs fill what the title line leaves, so a ratio is a share of
271
- // that width and title accessories sit at the line's end.
272
- const runs = titleElement.querySelector('.ok-native-list-identity-title-runs');
273
- for (let node = runs?.parentElement; node && node !== titleElement; node = node.parentElement) {
274
- node.style.display = 'flex';
275
- node.style.flex = '1 1 auto';
276
- node.style.minWidth = '0';
277
- }
278
- titleElement.style.display = 'flex';
279
- titleElement.style.alignItems = 'center';
280
- }
281
- if (row.titleLeadingIcon && presentation !== 'walletSidebar') {
282
- const descriptor = row.titleLeadingIcon;
283
- if (titleElement.hasAttribute('data-nl-slot')) {
284
- // Keep the glyph out of the title slot that text styles apply to.
285
- const titleText = tagSlot(createElement(document, 'span', 'ok-native-list-identity-title-text'), 'title');
286
- while (titleElement.firstChild) titleText.appendChild(titleElement.firstChild);
287
- if (hasTitleRuns) {
288
- titleText.style.display = 'flex';
289
- titleText.style.minWidth = '0';
290
- }
291
- titleElement.removeAttribute('data-nl-slot');
292
- titleElement.appendChild(titleText);
293
- }
294
- const icon = primitives.iconAction(descriptor.name, undefined, undefined, descriptor.tintColor);
295
- icon.className = 'ok-native-list-identity-title-leading-icon';
296
- if (descriptor.accessibilityLabel) icon.setAttribute('aria-label', descriptor.accessibilityLabel);else icon.setAttribute('aria-hidden', 'true');
297
- titleElement.style.display = 'flex';
298
- titleElement.style.alignItems = 'center';
299
- // 6px to the title, whatever gap the title line already has.
300
- const lineGap = Number.parseFloat(titleElement.style.gap || '0') || 0;
301
- icon.style.marginInlineEnd = `${Math.max(0, 6 - lineGap)}px`;
302
- titleElement.prepend(icon);
303
- }
304
214
  if (presentation === 'walletSidebar' && row.badges?.length) {
305
215
  const badges = createElement(document, 'span', 'ok-native-list-wallet-badges');
306
216
  row.badges.forEach(badge => badges.appendChild(createBadge(document, badge)));
307
217
  column.appendChild(badges);
308
218
  }
309
219
  for (const key of ['title', 'subtitle']) {
310
- if (key === 'title' && hasTitleRuns) continue;
311
220
  const lines = row.style?.[key]?.lines ?? row[`${key}Lines`];
312
221
  if (lines !== undefined) column.querySelectorAll(`[data-nl-slot="${key}"]`).forEach(text => {
313
222
  applyTextLayout(text, lines === 0 ? {} : {
@@ -360,7 +269,9 @@ function applyIdentityStyle(body, row) {
360
269
  }
361
270
  if (box.trailingGap !== undefined) {
362
271
  const gap = String(box.trailingGap) + 'px';
363
- body.querySelectorAll('.ok-native-list-accessories, .ok-native-list-amounts').forEach(trailing => {
272
+ // The accessory row only. A value pair is one accessory whose two lines
273
+ // are a flex column, so a gap there would push the lines apart.
274
+ body.querySelectorAll('.ok-native-list-accessories').forEach(trailing => {
364
275
  trailing.style.gap = gap;
365
276
  });
366
277
  }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- import { createNamedIcon } from '@onekeyfe/react-native-image/icon/dom';
4
3
  const views = new WeakMap();
5
4
  function bindLegacy(body, row, primitives) {
6
5
  const v = views.get(body);
@@ -123,6 +122,79 @@ function recycleLegacy(body) {
123
122
  v.imageKey = v.networkKey = '';
124
123
  }
125
124
  const galleries = new WeakMap();
125
+ const SVG_NS = 'http://www.w3.org/2000/svg';
126
+ let glyphMaskId = 0;
127
+
128
+ /**
129
+ * Placeholder glyphs share one 24pt geometry with the iOS and Android renderers:
130
+ * a rounded frame with a sun and a ridge; the failed glyph adds a slash and cuts
131
+ * a gap into the frame around it.
132
+ */
133
+ function createMediaGlyph(document, state) {
134
+ const svg = document.createElementNS(SVG_NS, 'svg');
135
+ svg.setAttribute('viewBox', '0 0 24 24');
136
+ svg.setAttribute('fill', 'none');
137
+ svg.setAttribute('stroke', 'currentColor');
138
+ svg.setAttribute('stroke-width', '1.5');
139
+ svg.setAttribute('stroke-linecap', 'round');
140
+ svg.setAttribute('stroke-linejoin', 'round');
141
+ svg.setAttribute('aria-hidden', 'true');
142
+ const shape = (tag, attributes) => {
143
+ const node = document.createElementNS(SVG_NS, tag);
144
+ Object.entries(attributes).forEach(([key, value]) => node.setAttribute(key, value));
145
+ return node;
146
+ };
147
+ const picture = shape('g', {});
148
+ picture.append(shape('rect', {
149
+ x: '3',
150
+ y: '3',
151
+ width: '18',
152
+ height: '18',
153
+ rx: '4'
154
+ }), shape('circle', {
155
+ cx: '9',
156
+ cy: '9',
157
+ r: '1.6'
158
+ }), shape('path', {
159
+ d: 'M5 20.5L14.5 11L21 17.5'
160
+ }));
161
+ if (state === 'failed') {
162
+ glyphMaskId += 1;
163
+ const id = `ok-native-list-media-cut-${glyphMaskId}`;
164
+ const mask = shape('mask', {
165
+ id,
166
+ maskUnits: 'userSpaceOnUse'
167
+ });
168
+ mask.append(shape('rect', {
169
+ x: '0',
170
+ y: '0',
171
+ width: '24',
172
+ height: '24',
173
+ fill: '#fff',
174
+ stroke: 'none'
175
+ }), shape('path', {
176
+ d: 'M2.6 -0.6L24.6 21.4L21.4 24.6L-0.6 2.6Z',
177
+ fill: '#000',
178
+ stroke: 'none'
179
+ }));
180
+ picture.setAttribute('mask', `url(#${id})`);
181
+ svg.append(mask, picture, shape('path', {
182
+ d: 'M3 3L21 21'
183
+ }));
184
+ } else svg.append(picture);
185
+ const wrap = document.createElement('div');
186
+ wrap.className = 'ok-native-list-media-glyph';
187
+ wrap.dataset.glyph = state;
188
+ wrap.append(svg);
189
+ return wrap;
190
+ }
191
+ const SWEEP_PERIOD_MS = 1600;
192
+ function setPlaceholderState(v, state) {
193
+ v.fallback.dataset.state = state;
194
+ if (state === 'loading')
195
+ // Keep every loading tile on one sweep phase, including recycled rows.
196
+ v.fallback.style.setProperty('--nl-media-sweep-delay', `-${Math.round(performance.now() % SWEEP_PERIOD_MS)}ms`);
197
+ }
126
198
  const isGalleryMedia = row => row.variant === 'gallery' && (!row.image || !!row.media && !row.imageState);
127
199
  function clearGalleryMedia(v) {
128
200
  v.epoch += 1;
@@ -149,18 +221,7 @@ function initGallery(body, primitives) {
149
221
  };
150
222
  const frame = element('ok-native-list-media-image');
151
223
  const fallback = element('ok-native-list-media-fallback');
152
- const svg = createNamedIcon(document, 'ImageSquareWavesOutline');
153
- fallback.append(svg);
154
- Object.assign(fallback.style, {
155
- position: 'absolute',
156
- inset: '0',
157
- display: 'flex',
158
- alignItems: 'center',
159
- justifyContent: 'center',
160
- color: 'var(--nl-disabled)',
161
- borderRadius: '10px',
162
- background: 'var(--nl-strong)'
163
- });
224
+ fallback.append(element('ok-native-list-media-hatch'), element('ok-native-list-media-sheen'), createMediaGlyph(document, 'loading'), createMediaGlyph(document, 'failed'));
164
225
  const metadata = element('ok-native-list-media-meta');
165
226
  const subtitleLine = element('ok-native-list-media-subtitle-row');
166
227
  const subtitle = element('ok-native-list-media-subtitle');
@@ -240,10 +301,14 @@ function bindGallery(body, row, primitives) {
240
301
  v.fallback.style.visibility = 'visible';
241
302
  const epoch = v.epoch;
242
303
  const source = row.imageState ? undefined : row.media?.source;
304
+ setPlaceholderState(v, source?.uri && row.media?.probeOrder.length ? 'loading' : 'failed');
243
305
  const probe = attempt => {
244
306
  if (v.epoch !== epoch) return;
245
307
  const kind = row.media?.probeOrder[attempt];
246
- if (!source?.uri || !kind) return;
308
+ if (!source?.uri || !kind) {
309
+ setPlaceholderState(v, 'failed');
310
+ return;
311
+ }
247
312
  const media = body.ownerDocument.createElement(kind === 'video' ? 'video' : 'img');
248
313
  v.frame.style.borderRadius = kind === 'video' ? '0' : '10px';
249
314
  Object.assign(media.style, {
@@ -284,7 +349,11 @@ function bindGallery(body, row, primitives) {
284
349
  probe(attempt + 1);
285
350
  };
286
351
  const ready = () => {
287
- if (v.epoch === epoch && v.media === media) v.fallback.style.visibility = 'hidden';
352
+ if (v.epoch === epoch && v.media === media) {
353
+ v.fallback.style.visibility = 'hidden';
354
+ // Stops the sweep animation behind the picture.
355
+ setPlaceholderState(v, 'loaded');
356
+ }
288
357
  };
289
358
  if (media.tagName === 'VIDEO') media.onloadeddata = ready;else media.onload = ready;
290
359
  v.media = media;
@@ -394,18 +394,6 @@ export type RowBase = Readonly<{
394
394
  accessibilityLabel?: string;
395
395
  separator?: boolean;
396
396
  }>;
397
- /** One run of an identity title line; see docs/SPEC.md. */
398
- export type IdentityTitleSegment = Readonly<{
399
- text: string;
400
- /** Omitted: the title color. */
401
- tone?: 'primary' | 'secondary';
402
- /** Omitted: the title weight. */
403
- fontWeight?: 'regular' | 'medium';
404
- /** The one run that gives up width when the line is too narrow. */
405
- shrink?: boolean;
406
- /** Caps the run at this fraction of the title line, within (0, 1]. */
407
- maxWidthRatio?: number;
408
- }>;
409
397
  export type IdentityRow = RowBase & Readonly<{
410
398
  type: 'identity';
411
399
  /** Opt in to content-based height; explicit row/container height still wins. */
@@ -440,14 +428,6 @@ export type IdentityRow = RowBase & Readonly<{
440
428
  }>;
441
429
  /** Web-only additional help icon after titleIcon. */
442
430
  secondaryTitleIcon?: IdentityRow['titleIcon'];
443
- /** Runs drawn in place of `title`, which stays the spoken label. */
444
- titleSegments?: readonly IdentityTitleSegment[];
445
- /** 16-point glyph before the title; decorative unless labelled. */
446
- titleLeadingIcon?: Readonly<{
447
- name: string;
448
- tintColor?: string;
449
- accessibilityLabel?: string;
450
- }>;
451
431
  /** Circular image after title icons; image dimensions must be square, 1...40. */
452
432
  titleImage?: Readonly<{
453
433
  image: ImageSource;
@@ -513,6 +493,14 @@ export type ActivityRow = RowBase & Readonly<{
513
493
  hidden?: boolean;
514
494
  }>;
515
495
  descriptionActionKey?: string;
496
+ /**
497
+ * UTF-16 offset into `description` where the text that opens
498
+ * `descriptionActionKey` starts; the text before it stays plain. An integer
499
+ * in `0...description.length`: `0`, the default, makes the whole
500
+ * description the action and `description.length` leaves no action text.
501
+ * Ignored without `descriptionActionKey`.
502
+ */
503
+ descriptionActionStart?: number;
516
504
  footerActions?: readonly FooterAction[];
517
505
  style?: ActivityRowStyle;
518
506
  }>;
@@ -536,6 +524,15 @@ export type DataColumn = Readonly<{
536
524
  textSegments?: readonly ValueTextSegment[];
537
525
  titleIcon?: IdentityRow['titleIcon'];
538
526
  secondaryTitleIcon?: IdentityRow['titleIcon'];
527
+ /**
528
+ * Web-only passive label before the primary column text. The caller supplies
529
+ * both colors as #RRGGBB or #RRGGBBAA; native renderers ignore the field.
530
+ */
531
+ webLeadingBadge?: Readonly<{
532
+ text: string;
533
+ textColor: string;
534
+ backgroundColor: string;
535
+ }>;
539
536
  secondaryLeadingText?: string;
540
537
  secondaryText?: string;
541
538
  secondaryTextSegments?: readonly ValueTextSegment[];
@@ -900,7 +897,7 @@ export type PatchClearableChanges<Row, Keys extends keyof Row> = Readonly<{
900
897
  export type RowPatch = Readonly<{
901
898
  type: 'identity';
902
899
  key: string;
903
- changes: PatchClearableChanges<IdentityRow, CommonPatchFields | 'title' | 'titleSuffixes' | 'titleIcon' | 'secondaryTitleIcon' | 'titleImage' | 'titleSegments' | 'titleLeadingIcon' | 'subtitle' | 'subtitleLines' | 'contentHeight' | 'longPressActionKey' | 'tertiary' | 'tertiaryTone' | 'badges' | 'trailing' | 'leading' | 'leadingAction' | 'titleMatch' | 'titleActionKey' | 'titleActionOnHover' | 'subtitleSegments'>;
900
+ changes: PatchClearableChanges<IdentityRow, CommonPatchFields | 'title' | 'titleSuffixes' | 'titleIcon' | 'secondaryTitleIcon' | 'titleImage' | 'subtitle' | 'subtitleLines' | 'contentHeight' | 'longPressActionKey' | 'tertiary' | 'tertiaryTone' | 'badges' | 'trailing' | 'leading' | 'leadingAction' | 'titleMatch' | 'titleActionKey' | 'titleActionOnHover' | 'subtitleSegments'>;
904
901
  }> | Readonly<{
905
902
  type: 'rail';
906
903
  key: string;
@@ -908,7 +905,7 @@ export type RowPatch = Readonly<{
908
905
  }> | Readonly<{
909
906
  type: 'activity';
910
907
  key: string;
911
- changes: PatchClearableChanges<ActivityRow, CommonPatchFields | 'title' | 'description' | 'status' | 'amounts' | 'badges' | 'presentation' | 'fee' | 'descriptionActionKey' | 'primaryAmount' | 'secondaryAmount' | 'leading' | 'hideLeading' | 'secondaryLeading' | 'footerActions'>;
908
+ changes: PatchClearableChanges<ActivityRow, CommonPatchFields | 'title' | 'description' | 'status' | 'amounts' | 'badges' | 'presentation' | 'fee' | 'descriptionActionKey' | 'descriptionActionStart' | 'primaryAmount' | 'secondaryAmount' | 'leading' | 'hideLeading' | 'secondaryLeading' | 'footerActions'>;
912
909
  }> | Readonly<{
913
910
  type: 'message';
914
911
  key: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-native-list",
3
- "version": "6.7.0-alpha.475",
3
+ "version": "6.8.0-11",
4
4
  "description": "Template-driven native RecyclerView and UICollectionView for React Native",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
@@ -124,6 +124,7 @@ const migrationCoverage = {
124
124
  'GasSolid',
125
125
  'GlobusOutline',
126
126
  'GoogleIllus',
127
+ 'InfoCircleOutline',
127
128
  'LockSolid',
128
129
  'PencilOutline',
129
130
  'PlusLargeOutline',
@@ -158,7 +158,7 @@
158
158
  {
159
159
  "name": "InfoCircleOutline",
160
160
  "source": "outline/info-circle.svg",
161
- "platforms": ["ios", "android"],
161
+ "platforms": ["ios", "android", "web"],
162
162
  "rendering": "template"
163
163
  },
164
164
  {
@@ -185,10 +185,21 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
185
185
  }
186
186
  const expandedEpoch = disclosureSlotMounts.current.expandedEpoch;
187
187
  const toggleEpoch = disclosureSlotMounts.current.toggleEpoch;
188
+ const iosHeaderPresent = Platform.OS === 'ios' && listHeader != null;
188
189
  const [slotMeasurements, setSlotMeasurements] = useState({
189
190
  heights: [0, 0, 0, 0, 0, 0],
190
191
  readyEpochs: [-1, -1, -1, -1, -1, -1],
192
+ iosHeaderPresent,
193
+ headerEpoch: 0,
191
194
  });
195
+ if (slotMeasurements.iosHeaderPresent !== iosHeaderPresent) {
196
+ setSlotMeasurements({
197
+ ...slotMeasurements,
198
+ iosHeaderPresent,
199
+ headerEpoch: slotMeasurements.headerEpoch + 1,
200
+ });
201
+ }
202
+ const headerEpoch = slotMeasurements.headerEpoch;
192
203
  const hasSidecar = listSidecar !== undefined;
193
204
  const sidecarWidth = sidecarLayout?.width;
194
205
  const sidecarGap = sidecarLayout?.gap;
@@ -321,7 +332,12 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
321
332
  parseInt(String(Platform.Version), 10) >= 26 &&
322
333
  (topScrollEdgeEffect === 'hard' || topScrollEdgeEffect === 'soft') &&
323
334
  topOverlay != null;
324
- const containerSlotHeightsJson = JSON.stringify(slotHeights);
335
+ const containerSlotHeightsJson = JSON.stringify(
336
+ Platform.OS === 'ios' &&
337
+ (!iosHeaderPresent || slotMeasurements.readyEpochs[0] !== headerEpoch)
338
+ ? [iosHeaderPresent ? null : 0, ...slotHeights.slice(1)]
339
+ : slotHeights
340
+ );
325
341
  const defaultSlotInset =
326
342
  snapshot.layout.contentPaddingHorizontal ??
327
343
  snapshot.layout.contentPadding ??
@@ -351,6 +367,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
351
367
  return;
352
368
  }
353
369
  setSlotMeasurements((previous) => {
370
+ if (index === 0 && epoch !== previous.headerEpoch) return previous;
354
371
  if (
355
372
  previous.heights[index] === height &&
356
373
  previous.readyEpochs[index] === epoch
@@ -361,7 +378,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
361
378
  const readyEpochs = [...previous.readyEpochs];
362
379
  heights[index] = height;
363
380
  readyEpochs[index] = epoch;
364
- return { heights, readyEpochs };
381
+ return { ...previous, heights, readyEpochs };
365
382
  });
366
383
  };
367
384
  const sidecarLayoutJson = sidecarLayout
@@ -835,7 +852,11 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
835
852
  >
836
853
  {slotContents.map((content, index) => (
837
854
  <View
838
- key={index}
855
+ key={
856
+ index === 0 && Platform.OS === 'ios'
857
+ ? `header-${headerEpoch}`
858
+ : index
859
+ }
839
860
  collapsable={false}
840
861
  style={{
841
862
  position: 'absolute',
@@ -849,7 +870,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
849
870
  recordSlotLayout(
850
871
  index,
851
872
  Math.ceil(event.nativeEvent.layout.height),
852
- 0
873
+ index === 0 ? headerEpoch : 0
853
874
  );
854
875
  }
855
876
  }}
@@ -617,7 +617,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
617
617
  pointerEvents={slotState.disclosurePresent ? 'auto' : 'none'}
618
618
  style={
619
619
  slotState.disclosurePresent
620
- ? undefined
620
+ ? { marginHorizontal: -padding }
621
621
  : collapsedExpandedContentStyle
622
622
  }
623
623
  >
package/src/models.ts CHANGED
@@ -513,19 +513,6 @@ export type RowBase = Readonly<{
513
513
  separator?: boolean;
514
514
  }>;
515
515
 
516
- /** One run of an identity title line; see docs/SPEC.md. */
517
- export type IdentityTitleSegment = Readonly<{
518
- text: string;
519
- /** Omitted: the title color. */
520
- tone?: 'primary' | 'secondary';
521
- /** Omitted: the title weight. */
522
- fontWeight?: 'regular' | 'medium';
523
- /** The one run that gives up width when the line is too narrow. */
524
- shrink?: boolean;
525
- /** Caps the run at this fraction of the title line, within (0, 1]. */
526
- maxWidthRatio?: number;
527
- }>;
528
-
529
516
  export type IdentityRow = RowBase &
530
517
  Readonly<{
531
518
  type: 'identity';
@@ -557,14 +544,6 @@ export type IdentityRow = RowBase &
557
544
  }>;
558
545
  /** Web-only additional help icon after titleIcon. */
559
546
  secondaryTitleIcon?: IdentityRow['titleIcon'];
560
- /** Runs drawn in place of `title`, which stays the spoken label. */
561
- titleSegments?: readonly IdentityTitleSegment[];
562
- /** 16-point glyph before the title; decorative unless labelled. */
563
- titleLeadingIcon?: Readonly<{
564
- name: string;
565
- tintColor?: string;
566
- accessibilityLabel?: string;
567
- }>;
568
547
  /** Circular image after title icons; image dimensions must be square, 1...40. */
569
548
  titleImage?: Readonly<{
570
549
  image: ImageSource;
@@ -637,6 +616,14 @@ export type ActivityRow = RowBase &
637
616
  hidden?: boolean;
638
617
  }>;
639
618
  descriptionActionKey?: string;
619
+ /**
620
+ * UTF-16 offset into `description` where the text that opens
621
+ * `descriptionActionKey` starts; the text before it stays plain. An integer
622
+ * in `0...description.length`: `0`, the default, makes the whole
623
+ * description the action and `description.length` leaves no action text.
624
+ * Ignored without `descriptionActionKey`.
625
+ */
626
+ descriptionActionStart?: number;
640
627
  footerActions?: readonly FooterAction[];
641
628
  style?: ActivityRowStyle;
642
629
  }>;
@@ -663,6 +650,15 @@ export type DataColumn = Readonly<{
663
650
  textSegments?: readonly ValueTextSegment[];
664
651
  titleIcon?: IdentityRow['titleIcon'];
665
652
  secondaryTitleIcon?: IdentityRow['titleIcon'];
653
+ /**
654
+ * Web-only passive label before the primary column text. The caller supplies
655
+ * both colors as #RRGGBB or #RRGGBBAA; native renderers ignore the field.
656
+ */
657
+ webLeadingBadge?: Readonly<{
658
+ text: string;
659
+ textColor: string;
660
+ backgroundColor: string;
661
+ }>;
666
662
  secondaryLeadingText?: string;
667
663
  secondaryText?: string;
668
664
  secondaryTextSegments?: readonly ValueTextSegment[];
@@ -1114,8 +1110,6 @@ export type RowPatch =
1114
1110
  | 'titleIcon'
1115
1111
  | 'secondaryTitleIcon'
1116
1112
  | 'titleImage'
1117
- | 'titleSegments'
1118
- | 'titleLeadingIcon'
1119
1113
  | 'subtitle'
1120
1114
  | 'subtitleLines'
1121
1115
  | 'contentHeight'
@@ -1154,6 +1148,7 @@ export type RowPatch =
1154
1148
  | 'presentation'
1155
1149
  | 'fee'
1156
1150
  | 'descriptionActionKey'
1151
+ | 'descriptionActionStart'
1157
1152
  | 'primaryAmount'
1158
1153
  | 'secondaryAmount'
1159
1154
  | 'leading'