@onekeyfe/react-native-native-list 6.7.0-alpha.466 → 6.8.0-10

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 (46) 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/NativeListMediaPlaceholderView.kt +244 -0
  4. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
  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/NativeListResolvedText.kt +5 -1
  8. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +75 -0
  9. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +25 -19
  10. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -0
  11. package/docs/ROW_TEMPLATES.md +11 -4
  12. package/docs/SPEC.md +296 -20
  13. package/docs/STYLE_SPEC.md +12 -0
  14. package/ios/NativeListActivityDetailsView.swift +13 -5
  15. package/ios/NativeListMediaPlaceholderView.swift +189 -0
  16. package/ios/NativeListMediaPreviewSlot.swift +122 -61
  17. package/ios/NativeListMediaTileRenderer.swift +13 -13
  18. package/ios/NativeListResolvedText.swift +15 -4
  19. package/ios/NativeListTextLabel.swift +106 -0
  20. package/ios/RNCNativeListView.swift +129 -32
  21. package/ios/tests/NativeListActivityPresentationTests.swift +270 -0
  22. package/ios/tests/NativeListLifecycleTests.swift +369 -40
  23. package/ios/tests/NativeListMediaVisibilityTests.swift +41 -7
  24. package/lib/module/NativeList.js +17 -4
  25. package/lib/module/NativeList.web.js +3 -1
  26. package/lib/module/validation.js +53 -4
  27. package/lib/module/web/NativeListGeneratedIcons.js +1 -0
  28. package/lib/module/web/NativeListWebEngine.js +13 -11
  29. package/lib/module/web/templates/ActivityRowRenderer.js +29 -23
  30. package/lib/module/web/templates/DataRowRenderer.js +54 -1
  31. package/lib/module/web/templates/IdentityRowRenderer.js +3 -1
  32. package/lib/module/web/templates/MediaTileRowRenderer.js +84 -15
  33. package/lib/typescript/src/models.d.ts +18 -1
  34. package/package.json +1 -1
  35. package/scripts/generate-icons.test.mjs +1 -0
  36. package/scripts/native-list-icons.json +1 -1
  37. package/src/NativeList.tsx +25 -4
  38. package/src/NativeList.web.tsx +1 -1
  39. package/src/models.ts +18 -0
  40. package/src/validation.ts +96 -1
  41. package/src/web/NativeListGeneratedIcons.ts +1 -0
  42. package/src/web/NativeListWebEngine.ts +16 -11
  43. package/src/web/templates/ActivityRowRenderer.ts +42 -32
  44. package/src/web/templates/DataRowRenderer.ts +76 -1
  45. package/src/web/templates/IdentityRowRenderer.ts +3 -3
  46. package/src/web/templates/MediaTileRowRenderer.ts +90 -15
@@ -91,10 +91,21 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
91
91
  }
92
92
  const expandedEpoch = disclosureSlotMounts.current.expandedEpoch;
93
93
  const toggleEpoch = disclosureSlotMounts.current.toggleEpoch;
94
+ const iosHeaderPresent = Platform.OS === 'ios' && listHeader != null;
94
95
  const [slotMeasurements, setSlotMeasurements] = useState({
95
96
  heights: [0, 0, 0, 0, 0, 0],
96
- readyEpochs: [-1, -1, -1, -1, -1, -1]
97
+ readyEpochs: [-1, -1, -1, -1, -1, -1],
98
+ iosHeaderPresent,
99
+ headerEpoch: 0
97
100
  });
101
+ if (slotMeasurements.iosHeaderPresent !== iosHeaderPresent) {
102
+ setSlotMeasurements({
103
+ ...slotMeasurements,
104
+ iosHeaderPresent,
105
+ headerEpoch: slotMeasurements.headerEpoch + 1
106
+ });
107
+ }
108
+ const headerEpoch = slotMeasurements.headerEpoch;
98
109
  const hasSidecar = listSidecar !== undefined;
99
110
  const sidecarWidth = sidecarLayout?.width;
100
111
  const sidecarGap = sidecarLayout?.gap;
@@ -155,7 +166,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
155
166
  const [viewportWidth, setViewportWidth] = useState(0);
156
167
  const [topOverlayHeight, setTopOverlayHeight] = useState(0);
157
168
  const hasTopOverlay = Platform?.OS === 'ios' && parseInt(String(Platform.Version), 10) >= 26 && (topScrollEdgeEffect === 'hard' || topScrollEdgeEffect === 'soft') && topOverlay != null;
158
- const containerSlotHeightsJson = JSON.stringify(slotHeights);
169
+ const containerSlotHeightsJson = JSON.stringify(Platform.OS === 'ios' && (!iosHeaderPresent || slotMeasurements.readyEpochs[0] !== headerEpoch) ? [iosHeaderPresent ? null : 0, ...slotHeights.slice(1)] : slotHeights);
159
170
  const defaultSlotInset = snapshot.layout.contentPaddingHorizontal ?? snapshot.layout.contentPadding ?? 0;
160
171
  const bandWidth = sidecarLayout ? Math.min(viewportWidth, sidecarLayout.maxContentWidth) : 0;
161
172
  const slotInset = sidecarLayout ? Math.max(0, (viewportWidth - bandWidth) / 2) + defaultSlotInset : defaultSlotInset;
@@ -166,6 +177,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
166
177
  return;
167
178
  }
168
179
  setSlotMeasurements(previous => {
180
+ if (index === 0 && epoch !== previous.headerEpoch) return previous;
169
181
  if (previous.heights[index] === height && previous.readyEpochs[index] === epoch) {
170
182
  return previous;
171
183
  }
@@ -174,6 +186,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
174
186
  heights[index] = height;
175
187
  readyEpochs[index] = epoch;
176
188
  return {
189
+ ...previous,
177
190
  heights,
178
191
  readyEpochs
179
192
  };
@@ -521,7 +534,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
521
534
  },
522
535
  onLayout: event => {
523
536
  if (index < 4) {
524
- recordSlotLayout(index, Math.ceil(event.nativeEvent.layout.height), 0);
537
+ recordSlotLayout(index, Math.ceil(event.nativeEvent.layout.height), index === 0 ? headerEpoch : 0);
525
538
  }
526
539
  },
527
540
  children: index >= 4 ? /*#__PURE__*/_jsx(View, {
@@ -530,7 +543,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
530
543
  onLayout: event => recordSlotLayout(index, Math.ceil(event.nativeEvent.layout.height), index === 4 ? expandedEpoch : toggleEpoch),
531
544
  children: content
532
545
  }, index === 4 ? `expanded-${expandedEpoch}` : `toggle-${toggleEpoch}`) : content
533
- }, index)), hasTopOverlay ? /*#__PURE__*/_jsx(View, {
546
+ }, index === 0 && Platform.OS === 'ios' ? `header-${headerEpoch}` : index)), hasTopOverlay ? /*#__PURE__*/_jsx(View, {
534
547
  collapsable: false,
535
548
  style: {
536
549
  position: 'absolute',
@@ -385,7 +385,9 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
385
385
  testID: "native-list-structure-toggle-slot",
386
386
  "aria-hidden": !slotState.disclosurePresent,
387
387
  pointerEvents: slotState.disclosurePresent ? 'auto' : 'none',
388
- style: slotState.disclosurePresent ? undefined : collapsedExpandedContentStyle,
388
+ style: slotState.disclosurePresent ? {
389
+ marginHorizontal: -padding
390
+ } : collapsedExpandedContentStyle,
389
391
  children: listStructureToggle
390
392
  }) : null, slotState.expandedTrailingInset > 0 && (listExpandedContent !== undefined || listStructureToggle !== undefined) ? /*#__PURE__*/_jsx(View, {
391
393
  testID: "native-list-trailing-inset-slot",
@@ -702,6 +702,18 @@ function assertButtonGroup(row, path) {
702
702
  }
703
703
  });
704
704
  }
705
+
706
+ // A passive label: its text and two caller colors, with no action or style slot.
707
+ function assertWebLeadingBadge(value, path) {
708
+ if (value === undefined) return;
709
+ const badge = protocolObject(value, path);
710
+ assertUnknownKeys(badge, ['text', 'textColor', 'backgroundColor'], path, 'web leading badge key');
711
+ if (typeof badge.text !== 'string' || !badge.text.trim() || badge.text.length > MAX_TEXT_LENGTH) fail(`${path}.text`, 'must be non-blank within the text limit');
712
+ for (const field of ['textColor', 'backgroundColor']) {
713
+ const color = badge[field];
714
+ if (typeof color !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(color)) fail(`${path}.${field}`, 'must be #RRGGBB or #RRGGBBAA');
715
+ }
716
+ }
705
717
  function assertIdentityExtras(row, path) {
706
718
  for (const field of ['titleIcon', 'secondaryTitleIcon']) {
707
719
  const titleIcon = row[field];
@@ -814,12 +826,18 @@ function assertVisual(row, path) {
814
826
  assertLeadingVisual(visual, `${path}.visual[${index}]`);
815
827
  });
816
828
  }
829
+
830
+ /** The type half of the `descriptionActionStart` contract; the range needs the row. */
831
+ function isDescriptionActionStart(value) {
832
+ return Number.isSafeInteger(value) && value >= 0;
833
+ }
817
834
  function assertActivity(row, path) {
818
835
  if (row.hideLeading !== undefined && typeof row.hideLeading !== 'boolean') fail(`${path}.hideLeading`, 'must be boolean');
819
836
  assertText(row.title, `${path}.title`);
820
837
  assertText(row.description, `${path}.description`);
821
838
  if (row.presentation !== undefined && !['stacked', 'table'].includes(row.presentation)) fail(`${path}.presentation`, 'must be stacked or table');
822
839
  if (row.descriptionActionKey !== undefined) assertKey(row.descriptionActionKey, `${path}.descriptionActionKey`);
840
+ if (row.descriptionActionStart !== undefined && !isDescriptionActionStart(row.descriptionActionStart)) fail(`${path}.descriptionActionStart`, 'must be a non-negative integer');
823
841
  if ((row.amounts?.length ?? 0) > 32) fail(`${path}.amounts`, 'supports at most 32 amount lines');
824
842
  const amountKeys = new Set();
825
843
  row.amounts?.forEach((amount, index) => {
@@ -962,6 +980,9 @@ function assertRow(row, index, path = `rows[${index}]`) {
962
980
  break;
963
981
  case 'activity':
964
982
  assertActivity(row, path);
983
+ // Checked on the complete row only: a patch may carry the offset
984
+ // without the description it points into.
985
+ if ((row.descriptionActionStart ?? 0) > (row.description?.length ?? 0)) fail(`${path}.descriptionActionStart`, 'must not exceed the description length');
965
986
  break;
966
987
  case 'message':
967
988
  if (row.presentation !== undefined && row.presentation !== 'inlineWarning') {
@@ -982,6 +1003,7 @@ function assertRow(row, index, path = `rows[${index}]`) {
982
1003
  assertKey(column.key, `${path}.columns[${columnIndex}].key`);
983
1004
  assertText(column.text, `${path}.columns[${columnIndex}].text`);
984
1005
  assertIdentityExtras(column, `${path}.columns[${columnIndex}]`);
1006
+ assertWebLeadingBadge(column.webLeadingBadge, `${path}.columns[${columnIndex}].webLeadingBadge`);
985
1007
  for (const field of ['textSegments', 'secondaryTextSegments']) {
986
1008
  column[field]?.forEach((segment, segmentIndex) => {
987
1009
  assertText(segment.text, `${path}.columns[${columnIndex}].${field}[${segmentIndex}].text`);
@@ -1229,7 +1251,7 @@ const ROW_FIELDS = {
1229
1251
  identity: [...COMMON_ROW_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'presentation', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'titleLines', 'subtitleLines', 'badges', 'trailing', 'draggable'],
1230
1252
  walletGroup: [...COMMON_ROW_FIELDS, 'parent', 'children', 'draggable'],
1231
1253
  rail: [...COMMON_ROW_FIELDS, 'visual', 'title', 'status', 'badge', 'draggable'],
1232
- activity: [...COMMON_ROW_FIELDS, 'leading', 'hideLeading', 'secondaryLeading', 'title', 'description', 'status', 'primaryAmount', 'secondaryAmount', 'amounts', 'badges', 'presentation', 'fee', 'descriptionActionKey', 'footerActions'],
1254
+ activity: [...COMMON_ROW_FIELDS, 'leading', 'hideLeading', 'secondaryLeading', 'title', 'description', 'status', 'primaryAmount', 'secondaryAmount', 'amounts', 'badges', 'presentation', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
1233
1255
  message: [...COMMON_ROW_FIELDS, 'presentation', 'unread', 'leading', 'title', 'body', 'bodyLines', 'time', 'thumbnail'],
1234
1256
  dataRow: [...COMMON_ROW_FIELDS, 'leading', 'columns', 'trailing', 'checkbox', 'index', 'badge', 'badges', 'favorite', 'favoriteActive'],
1235
1257
  market: [...COMMON_ROW_FIELDS, 'variant', 'webTable', 'metrics', 'leadingAction', 'leading', 'title', 'subtitle', 'subtitlePrefix', 'subtitleSegments', 'price', 'priceSegments', 'change', 'badges', 'pressActionKey', 'pressInActionKey', 'longPressActionKey', 'diagnostics'],
@@ -1244,7 +1266,7 @@ const COMMON_PATCH_FIELDS = ['height', 'heightRounding', 'opacity', 'pressDisabl
1244
1266
  const PATCH_FIELDS = {
1245
1267
  identity: [...COMMON_PATCH_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'subtitleLines', 'badges', 'trailing'],
1246
1268
  rail: [...COMMON_PATCH_FIELDS, 'title', 'visual', 'status', 'badge'],
1247
- activity: [...COMMON_PATCH_FIELDS, 'presentation', 'leading', 'title', 'badges', 'status', 'hideLeading', 'secondaryLeading', 'description', 'primaryAmount', 'secondaryAmount', 'amounts', 'fee', 'descriptionActionKey', 'footerActions'],
1269
+ activity: [...COMMON_PATCH_FIELDS, 'presentation', 'leading', 'title', 'badges', 'status', 'hideLeading', 'secondaryLeading', 'description', 'primaryAmount', 'secondaryAmount', 'amounts', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
1248
1270
  message: [...COMMON_PATCH_FIELDS, 'presentation', 'title', 'unread', 'body', 'bodyLines', 'time', 'thumbnail'],
1249
1271
  dataRow: [...COMMON_PATCH_FIELDS, 'leading', 'badges', 'trailing', 'badge', 'columns', 'checkbox', 'index', 'favorite', 'favoriteActive'],
1250
1272
  market: [...COMMON_PATCH_FIELDS, 'longPressActionKey', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'subtitle', 'badges', 'webTable', 'metrics', 'price', 'priceSegments', 'change', 'pressActionKey', 'pressInActionKey', 'diagnostics'],
@@ -1369,7 +1391,10 @@ function assertRowProtocol(row, path) {
1369
1391
  row.columns.forEach((column, index) => {
1370
1392
  const columnPath = `${path}.columns[${index}]`;
1371
1393
  protocolObject(column, columnPath);
1372
- if (isDevelopment()) assertIdentityExtras(column, columnPath);
1394
+ if (isDevelopment()) {
1395
+ assertIdentityExtras(column, columnPath);
1396
+ assertWebLeadingBadge(column.webLeadingBadge, `${columnPath}.webLeadingBadge`);
1397
+ }
1373
1398
  });
1374
1399
  if (isDevelopment()) assertTrailingAccessories(row.trailing, `${path}.trailing`);
1375
1400
  }
@@ -1576,7 +1601,7 @@ function sanitizeImage(value) {
1576
1601
  }
1577
1602
  const NESTED_DECORATION_FIELDS = {
1578
1603
  webTable: ['columns', 'cells', 'testID', 'draggable', 'contextMenuActionKey'],
1579
- columns: ['key', 'text', 'textSegments', 'titleIcon', 'secondaryTitleIcon', 'secondaryLeadingText', 'secondaryText', 'secondaryTextSegments', 'weight', 'alignment', 'tone', 'secondaryTone', 'width', 'minWidth', 'flex', 'paddingStart', 'paddingEnd'],
1604
+ columns: ['key', 'text', 'textSegments', 'titleIcon', 'secondaryTitleIcon', 'webLeadingBadge', 'secondaryLeadingText', 'secondaryText', 'secondaryTextSegments', 'weight', 'alignment', 'tone', 'secondaryTone', 'width', 'minWidth', 'flex', 'paddingStart', 'paddingEnd'],
1580
1605
  cells: ['key', 'kind', 'active', 'disabled', 'testID', 'hoverActionKey', 'actionKey', 'accessibilityLabel', 'leading', 'title', 'secondary', 'lineGap', 'secondaryBadges', 'hoverImages', 'hoverSecondary', 'hoverActionLabel', 'badges', 'primary', 'partGap', 'points', 'width', 'height', 'strokeColor', 'fillColor'],
1581
1606
  badges: ['key', 'text', 'tone', 'iconName', 'icon', 'textColor', 'backgroundColor', 'actionKey', 'accessibilityLabel', 'style'],
1582
1607
  overlays: ['position', 'size', 'width', 'height', 'padding', 'offset', 'offsetX', 'offsetY', 'image', 'fallbackIcon', 'name', 'text', 'fontWeight', 'tintColor', 'backgroundColor'],
@@ -1585,6 +1610,21 @@ const NESTED_DECORATION_FIELDS = {
1585
1610
  };
1586
1611
  function sanitizeDecoration(value, field) {
1587
1612
  if (value === undefined || value === null) return undefined;
1613
+ // All or nothing: a badge without valid text and both colors is dropped, and
1614
+ // only its three declared fields are kept.
1615
+ if (field === 'webLeadingBadge') {
1616
+ if (!isRecord(value) || typeof value.text !== 'string' || !value.text.trim() || value.text.length > MAX_TEXT_LENGTH) return undefined;
1617
+ const {
1618
+ textColor,
1619
+ backgroundColor
1620
+ } = value;
1621
+ if (typeof textColor !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(textColor) || typeof backgroundColor !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(backgroundColor)) return undefined;
1622
+ return {
1623
+ text: value.text,
1624
+ textColor,
1625
+ backgroundColor
1626
+ };
1627
+ }
1588
1628
  if (!Array.isArray(value) && ['image', 'networkImage', 'thumbnail', 'source', 'images', 'hoverImages'].includes(field)) return sanitizeImage(value);
1589
1629
  if (['titleImage', 'titleIcon', 'secondaryTitleIcon', 'fallbackIcon', 'cornerIcon', 'media'].includes(field) && !isRecord(value)) return undefined;
1590
1630
  if (field === 'style' && typeof value !== 'string' && !isRecord(value)) return undefined;
@@ -1705,6 +1745,11 @@ function sanitizeRowForProduction(row) {
1705
1745
  delete next[field];
1706
1746
  continue;
1707
1747
  }
1748
+ if (field === 'descriptionActionStart') {
1749
+ // Renderers clamp an offset past the text; anything else has no meaning.
1750
+ if (!isDescriptionActionStart(value)) delete next[field];
1751
+ continue;
1752
+ }
1708
1753
  if (field === 'parent' && isRecord(value)) next[field] = sanitizeRowForProduction(value);else if (field === 'children' && Array.isArray(value)) next[field] = value.map(child => sanitizeRowForProduction(child));else {
1709
1754
  const normalized = row.type === 'market' && field === 'metrics' ? sanitizeMarketMetrics(value) : sanitizeDecoration(value, field);
1710
1755
  if (normalized === undefined) delete next[field];else next[field] = normalized;
@@ -1955,6 +2000,7 @@ function assertPatchChanges(patch, index) {
1955
2000
  assertKey(column.key, `${path}.columns[${columnIndex}].key`);
1956
2001
  assertText(column.text, `${path}.columns[${columnIndex}].text`);
1957
2002
  assertIdentityExtras(column, `${path}.columns[${columnIndex}]`);
2003
+ assertWebLeadingBadge(column.webLeadingBadge, `${path}.columns[${columnIndex}].webLeadingBadge`);
1958
2004
  for (const field of ['textSegments', 'secondaryTextSegments']) {
1959
2005
  column[field]?.forEach((segment, segmentIndex) => {
1960
2006
  assertText(segment.text, `${path}.columns[${columnIndex}].${field}[${segmentIndex}].text`);
@@ -2297,6 +2343,9 @@ function mergeAndValidateSingleRow(previous, patch, index) {
2297
2343
  if (typeof changes.subtitle === 'string' && !('subtitleSegments' in changes) && previous.subtitleSegments !== undefined) changes.subtitleSegments = null;
2298
2344
  if (Array.isArray(changes.subtitleSegments) && changes.subtitleSegments.length > 0 && !('subtitle' in changes) && previous.subtitle !== undefined) changes.subtitle = null;
2299
2345
  }
2346
+ // The offset points into one specific description string, so a patch that
2347
+ // replaces the description without restating it falls back to the default.
2348
+ if (previous.type === 'activity' && 'description' in changes && changes.description !== previous.description && !('descriptionActionStart' in changes) && previous.descriptionActionStart !== undefined) changes.descriptionActionStart = null;
2300
2349
  const merged = {
2301
2350
  ...previous
2302
2351
  };
@@ -20,6 +20,7 @@ export const nativeListGeneratedIcons = {
20
20
  GasSolid: 'GasSolid',
21
21
  GlobusOutline: 'GlobusOutline',
22
22
  GoogleIllus: 'GoogleIllus',
23
+ InfoCircleOutline: 'InfoCircleOutline',
23
24
  LockSolid: 'LockSolid',
24
25
  PencilOutline: 'PencilOutline',
25
26
  PlusLargeOutline: 'PlusLargeOutline',
@@ -183,6 +183,14 @@ function effectiveRows(snapshot) {
183
183
  if (snapshot.rows.length > 0) return snapshot.rows;
184
184
  return snapshot.emptyState ? [snapshot.emptyState] : [];
185
185
  }
186
+ function isDarkBackground(color) {
187
+ const rgb = color ? /^#([0-9a-f]{6})/i.exec(color)?.[1] : undefined;
188
+ if (!rgb) return false;
189
+ const red = Number.parseInt(rgb.slice(0, 2), 16);
190
+ const green = Number.parseInt(rgb.slice(2, 4), 16);
191
+ const blue = Number.parseInt(rgb.slice(4, 6), 16);
192
+ return red * 299 + green * 587 + blue * 114 < 128_000;
193
+ }
186
194
  function resolvedTheme(snapshot) {
187
195
  return {
188
196
  ...defaultTheme,
@@ -482,7 +490,7 @@ export const WEB_LIST_CSS = `
482
490
  .ok-native-list-account-action-row{justify-content:flex-start;gap:12px;padding:0 12px}.ok-native-list-account-action-row .ok-native-list-action-title{color:var(--nl-secondary);font-size:16px;line-height:24px;font-weight:400;font-family:var(--nl-font-regular)}
483
491
  .ok-native-list-system{justify-content:center;padding:8px 12px;background:var(--nl-bg);color:var(--nl-secondary);cursor:default}.ok-native-list-system[data-variant="retry"],.ok-native-list-system[data-variant="noMatch"],.ok-native-list-system[data-variant="end"]{justify-content:flex-start}.ok-native-list-system[data-variant="retry"]{cursor:pointer}
484
492
  .ok-native-list-rail{padding:4px;gap:6px;border-radius:8px}.ok-native-list-rail .ok-native-list-visual{width:20px;height:20px;flex-basis:20px}.ok-native-list-rail .ok-native-list-visual>img,.ok-native-list-rail .ok-native-list-visual-main{width:20px;height:20px}.ok-native-list-rail-title{font-size:12px;font-weight:500;white-space:nowrap;font-family:var(--nl-font-medium)}
485
- .ok-native-list-media{display:block;padding:0 5px;background:transparent;border-radius:16px}.ok-native-list-media-image{display:block;width:100%;aspect-ratio:1;border-radius:10px;background:var(--nl-strong);object-fit:cover}.ok-native-list-media-image[data-state="empty"]{background:transparent}.ok-native-list-media-image[data-state="error"]{display:flex;align-items:center;justify-content:center;color:var(--nl-icon-subdued);font-size:24px}.ok-native-list-media-meta{padding-top:7px}.ok-native-list-media-subtitle-row{display:flex;align-items:center;gap:6px}.ok-native-list-media-subtitle{flex:1;min-width:0;font-size:12px;color:var(--nl-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ok-native-list-media-network{width:14px;height:14px;border-radius:50%}.ok-native-list-media-title{font-size:16px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:var(--nl-font-medium)}.ok-native-list-media-close{position:absolute;right:9px;top:4px;border:0;background:color-mix(in srgb,var(--nl-inverse) 72%,transparent);color:var(--nl-inverse-text);width:24px;height:24px;border-radius:50%;cursor:pointer;font:18px/20px var(--nl-font-regular)}
493
+ .ok-native-list-media{display:block;padding:0 5px;background:transparent;border-radius:16px}.ok-native-list-media-image{display:block;width:100%;aspect-ratio:1;border-radius:10px;background:var(--nl-strong);object-fit:cover}.ok-native-list-media-image[data-state="empty"]{background:transparent}.ok-native-list-media-image[data-state="error"]{display:flex;align-items:center;justify-content:center;color:var(--nl-icon-subdued);font-size:24px}.ok-native-list-media-meta{padding-top:7px}.ok-native-list-media-subtitle-row{display:flex;align-items:center;gap:6px}.ok-native-list-media-subtitle{flex:1;min-width:0;font-size:12px;color:var(--nl-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ok-native-list-media-network{width:14px;height:14px;border-radius:50%}.ok-native-list-media-title{font-size:16px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:var(--nl-font-medium)}.ok-native-list-media-fallback{position:absolute;inset:0;overflow:hidden;border-radius:10px;background:var(--nl-strong);color:color-mix(in srgb,var(--nl-disabled) 70%,transparent)}.ok-native-list-media-fallback::after{content:"";position:absolute;inset:0;border-radius:inherit;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--nl-separator) 60%,transparent);pointer-events:none}.ok-native-list-media-sheen,.ok-native-list-media-hatch,.ok-native-list-media-glyph{position:absolute;inset:0;pointer-events:none}.ok-native-list-media-glyph{display:none;align-items:center;justify-content:center}.ok-native-list-media-glyph svg{width:28%;max-width:44px;height:auto}.ok-native-list-media-fallback[data-state="loading"] .ok-native-list-media-glyph[data-glyph="loading"],.ok-native-list-media-fallback[data-state="failed"] .ok-native-list-media-glyph[data-glyph="failed"]{display:flex}.ok-native-list-media-sheen{display:none;overflow:hidden}.ok-native-list-media-fallback[data-state="loading"] .ok-native-list-media-sheen{display:block}.ok-native-list-media-sheen::before{content:"";position:absolute;top:-50%;bottom:-50%;left:0;width:60%;background:linear-gradient(100deg,transparent 0%,var(--nl-media-shine,rgba(255,255,255,.75)) 50%,transparent 100%);transform:translateX(-135%) skewX(-12deg);animation:ok-native-list-media-sweep 1.6s cubic-bezier(.4,0,.2,1) infinite;animation-delay:var(--nl-media-sweep-delay,0s)}@keyframes ok-native-list-media-sweep{0%{transform:translateX(-135%) skewX(-12deg)}70%,100%{transform:translateX(220%) skewX(-12deg)}}.ok-native-list-media-hatch{display:none;background-image:repeating-linear-gradient(135deg,color-mix(in srgb,var(--nl-primary) 4.5%,transparent) 0 1px,transparent 1px 7px);-webkit-mask-image:radial-gradient(circle at 50% 50%,transparent 0 22%,#000 70%);mask-image:radial-gradient(circle at 50% 50%,transparent 0 22%,#000 70%)}.ok-native-list-media-fallback[data-state="failed"] .ok-native-list-media-hatch{display:block}@media(prefers-reduced-motion:reduce){.ok-native-list-media-sheen::before{animation:none;transform:translateX(60%) skewX(-12deg);opacity:.6}}.ok-native-list-media-close{position:absolute;right:9px;top:4px;border:0;background:color-mix(in srgb,var(--nl-inverse) 72%,transparent);color:var(--nl-inverse-text);width:24px;height:24px;border-radius:50%;cursor:pointer;font:18px/20px var(--nl-font-regular)}
486
494
  .ok-native-list-metric{display:flex;flex-direction:column;align-items:flex-start;padding:12px;border-radius:12px;gap:5px;background:var(--nl-row)}.ok-native-list-metric-value{font-size:22px;line-height:28px;font-weight:700;font-family:var(--nl-font-bold)}.ok-native-list-composite{display:flex;flex-direction:column;align-items:stretch;padding:14px;border-radius:12px;gap:12px;background:var(--nl-subdued)}.ok-native-list-composite-heading{font-size:14px;letter-spacing:1px;color:var(--nl-secondary)}.ok-native-list-composite-row{display:flex;gap:12px}.ok-native-list-composite-cell{flex:1;min-width:0}.ok-native-list-composite-cell[data-shaded="true"]{padding:10px;border-radius:10px;background:color-mix(in srgb,var(--nl-primary) 5%,transparent)}.ok-native-list-composite-value{font-size:18px;font-weight:600;font-family:var(--nl-font-semibold)}.ok-native-list-divider{height:1px;background:var(--nl-separator)}.ok-native-list-progress{height:4px;border-radius:2px;overflow:hidden;background:var(--nl-negative)}.ok-native-list-progress>span{display:block;height:100%;border-radius:2px;background:var(--nl-positive)}
487
495
  .ok-native-list-data{padding:6px 12px}.ok-native-list-index{flex:0 0 28px;color:var(--nl-secondary);font-size:13px}.ok-native-list-favorite{flex:0 0 24px;color:var(--nl-icon-subdued);font-size:22px}.ok-native-list-favorite[data-active="true"]{color:var(--nl-accent)}.ok-native-list-data-cell{display:flex;flex-direction:column;min-width:0}.ok-native-list-data-cell[data-align="center"]{align-items:center}.ok-native-list-data-cell[data-align="end"]{align-items:flex-end}.ok-native-list-data-primary{display:flex;align-items:center;gap:5px;max-width:100%;font-size:16px;font-weight:500;white-space:nowrap;font-family:var(--nl-font-medium)}.ok-native-list-unread{width:7px;height:7px;flex:0 0 7px;border-radius:50%;background:var(--nl-accent)}.ok-native-list-thumbnail{width:64px;height:64px;border-radius:10px;object-fit:cover}
488
496
  .ok-native-list-item[data-native-list-row-press-enabled="true"]:active>.ok-native-list-history{background:var(--nl-selected)}
@@ -494,7 +502,7 @@ export const WEB_LIST_CSS = `
494
502
  .ok-native-list-index-preview{position:absolute;z-index:8;right:40px;top:50%;display:flex;width:48px;height:48px;align-items:center;justify-content:center;transform:translateY(-50%) scale(.92);border-radius:14px;background:var(--nl-inverse);color:var(--nl-inverse-text);font-size:22px;font-weight:600;opacity:0;pointer-events:none;transition:opacity .15s ease,transform .15s ease;font-family:var(--nl-font-semibold)}.ok-native-list-index-preview[data-visible="true"]{opacity:1;transform:translateY(-50%) scale(1)}
495
503
  .ok-native-list-row.ok-native-list-market-skeleton{padding:12px 20px;gap:0}.ok-native-list-skeleton-left{display:flex;align-items:center;gap:12px;flex:1}.ok-native-list-skeleton-text{display:flex;flex-direction:column;gap:4px}.ok-native-list-skeleton-right{display:flex;align-items:center;gap:8px}.ok-native-list-skeleton-mark{display:block;flex-shrink:0;border-radius:8px;animation:ok-native-list-skeleton 1.5s linear infinite alternate}@keyframes ok-native-list-skeleton{from{background-color:var(--nl-skeleton-base)}to{background-color:var(--nl-skeleton-highlight)}}.ok-native-list-market-spinner{display:block;width:20px;height:20px;flex-shrink:0;color:var(--nl-icon);animation:ok-native-list-spin .75s linear infinite}
496
504
  @media (prefers-reduced-motion:reduce){.ok-native-list-index-preview,.ok-native-list-refresh{transition:none}.ok-native-list-spinner,.ok-native-list-market-spinner{animation:none}.ok-native-list-skeleton-mark{animation:none;background:var(--nl-skeleton-base)}}
497
- .ok-native-list-footer{flex:0 0 auto;min-height:0}.ok-native-list-sticky{position:absolute;z-index:4;left:0;right:0;top:0;pointer-events:auto;box-shadow:0 1px 0 var(--nl-separator)}.ok-native-list-viewport-frame:has(>.ok-native-list-index-rail:not([hidden]))>.ok-native-list-viewport,.ok-native-list-viewport-frame[data-section-index-visible="true"]>.ok-native-list-viewport{scrollbar-width:none}.ok-native-list-viewport-frame:has(>.ok-native-list-index-rail:not([hidden]))>.ok-native-list-viewport::-webkit-scrollbar,.ok-native-list-viewport-frame[data-section-index-visible="true"]>.ok-native-list-viewport::-webkit-scrollbar{display:none}.ok-native-list-index-rail{position:absolute;z-index:6;top:0;right:0;bottom:0;width:${SECTION_INDEX_RAIL_WIDTH}px;touch-action:none;cursor:pointer;font-family:var(--nl-font-regular);font-synthesis:none}.ok-native-list-index-rail[hidden]{display:none}.ok-native-list-index-button{appearance:none;position:absolute;left:15px;display:flex;width:14px;height:14px;align-items:center;justify-content:center;padding:0;transform:translateY(-50%);border:0;border-radius:7px;background:transparent;color:var(--nl-disabled);font-size:10px;font-weight:400;line-height:1;cursor:pointer;opacity:.5;transition:opacity .15s ease;font-family:var(--nl-font-regular)}.ok-native-list-index-rail:hover .ok-native-list-index-button,.ok-native-list-index-rail:focus-within .ok-native-list-index-button,.ok-native-list-index-button[data-active="true"]{opacity:1}.ok-native-list-index-button[data-active="true"]{background:var(--nl-positive);color:var(--nl-inverse-text);font-weight:500;font-family:var(--nl-font-medium)}.ok-native-list-index-button:focus-visible{outline:2px solid var(--nl-positive);outline-offset:1px}
505
+ .ok-native-list-footer{flex:0 0 auto;min-height:0}.ok-native-list-sticky{position:absolute;z-index:4;left:0;right:0;top:0;pointer-events:auto}.ok-native-list-viewport-frame:has(>.ok-native-list-index-rail:not([hidden]))>.ok-native-list-viewport,.ok-native-list-viewport-frame[data-section-index-visible="true"]>.ok-native-list-viewport{scrollbar-width:none}.ok-native-list-viewport-frame:has(>.ok-native-list-index-rail:not([hidden]))>.ok-native-list-viewport::-webkit-scrollbar,.ok-native-list-viewport-frame[data-section-index-visible="true"]>.ok-native-list-viewport::-webkit-scrollbar{display:none}.ok-native-list-index-rail{position:absolute;z-index:6;top:0;right:0;bottom:0;width:${SECTION_INDEX_RAIL_WIDTH}px;touch-action:none;cursor:pointer;font-family:var(--nl-font-regular);font-synthesis:none}.ok-native-list-index-rail[hidden]{display:none}.ok-native-list-index-button{appearance:none;position:absolute;left:15px;display:flex;width:14px;height:14px;align-items:center;justify-content:center;padding:0;transform:translateY(-50%);border:0;border-radius:7px;background:transparent;color:var(--nl-disabled);font-size:10px;font-weight:400;line-height:1;cursor:pointer;opacity:.5;transition:opacity .15s ease;font-family:var(--nl-font-regular)}.ok-native-list-index-rail:hover .ok-native-list-index-button,.ok-native-list-index-rail:focus-within .ok-native-list-index-button,.ok-native-list-index-button[data-active="true"]{opacity:1}.ok-native-list-index-button[data-active="true"]{background:var(--nl-positive);color:var(--nl-inverse-text);font-weight:500;font-family:var(--nl-font-medium)}.ok-native-list-index-button:focus-visible{outline:2px solid var(--nl-positive);outline-offset:1px}
498
506
  .ok-native-list-refresh{position:absolute;z-index:7;left:50%;top:8px;display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;background:var(--nl-inverse);color:var(--nl-inverse-text);font-size:12px;opacity:0;transform:translate(-50%,-16px);transition:opacity .15s ease,transform .15s ease;pointer-events:none}.ok-native-list-refresh[data-visible="true"]{opacity:1;transform:translate(-50%,0)}
499
507
  .ok-native-list-warning{height:auto;display:flex;flex-direction:column;align-items:stretch;gap:4px;padding:14px 12px;border-top:1px solid;border-bottom:1px solid;box-sizing:border-box;cursor:default}.ok-native-list-warning-title,.ok-native-list-warning-message{font-size:14px;line-height:20px;white-space:normal;overflow-wrap:anywhere}.ok-native-list-warning-title{font-weight:500;color:var(--nl-primary);font-family:var(--nl-font-medium)}.ok-native-list-warning-message{font-weight:400;color:var(--nl-secondary);font-family:var(--nl-font-regular)}
500
508
  .ok-native-list-subtitle-segments{display:flex;align-items:center;min-width:0;max-width:100%;height:20px}.ok-native-list-subtitle-segments>.ok-native-list-secondary{flex:0 1 auto;min-width:0}.ok-native-list-subtitle-dot{flex:0 0 4px;width:4px;height:4px;margin:0 6px;border-radius:50%;background:var(--nl-disabled)}.ok-native-list-wallet-row>.ok-native-list-flex{flex:0 1 auto;width:100%;align-items:center}.ok-native-list-wallet-badges{display:flex;gap:4px;justify-content:center;margin-top:4px;height:20px;max-width:100%}.ok-native-list-wallet-badges>.ok-native-list-badge{background:var(--nl-strong);color:var(--nl-secondary);font-size:12px;line-height:16px;height:20px;box-sizing:border-box;padding:2px 4px}.ok-native-list-visual-overlay{position:absolute;display:flex;align-items:center;justify-content:center;box-sizing:border-box;border-radius:50%;overflow:hidden;line-height:1;font-size:10px}.ok-native-list-visual-overlay img,.ok-native-list-visual-overlay svg{width:100%;height:100%;object-fit:contain}/* OneKey patch: selector controls follow their original semantic colors and geometry. */
@@ -808,14 +816,7 @@ function createVisual(context, visual, selectorPresentation) {
808
816
  if (selectorPresentation) paintSelectorImageBackground(image, frame);
809
817
  if (source?.loadingStrategy === 'skeleton' && !(image.complete && image.naturalWidth > 0)) {
810
818
  const skeleton = createElement(context.document, 'span', 'ok-native-list-image-skeleton');
811
- const background = resolvedTheme(context.snapshot).background;
812
- const rgb = /^#([0-9a-f]{6})/i.exec(background)?.[1];
813
- if (rgb) {
814
- const red = Number.parseInt(rgb.slice(0, 2), 16);
815
- const green = Number.parseInt(rgb.slice(2, 4), 16);
816
- const blue = Number.parseInt(rgb.slice(4, 6), 16);
817
- if (red * 299 + green * 587 + blue * 114 < 128_000) skeleton.dataset.dark = 'true';
818
- }
819
+ if (isDarkBackground(resolvedTheme(context.snapshot).background)) skeleton.dataset.dark = 'true';
819
820
  frame.appendChild(skeleton);
820
821
  image.addEventListener('load', () => skeleton.remove(), {
821
822
  once: true
@@ -1966,7 +1967,8 @@ export class NativeListWebEngine {
1966
1967
  '--nl-critical': theme.criticalBackground,
1967
1968
  '--nl-inverse': theme.inverseBackground,
1968
1969
  '--nl-inverse-text': theme.inverseText,
1969
- '--nl-info': theme.info
1970
+ '--nl-info': theme.info,
1971
+ '--nl-media-shine': isDarkBackground(theme.background) ? 'rgba(255,255,255,0.07)' : 'rgba(255,255,255,0.75)'
1970
1972
  };
1971
1973
  Object.entries(values).forEach(([name, value]) => {
1972
1974
  if (!value) return;
@@ -89,6 +89,8 @@ function recycleLegacy(body) {
89
89
  const histories = new WeakMap();
90
90
  const isHistory = row => row.presentation !== undefined || row.amounts !== undefined;
91
91
  const ellipsis = 'min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;';
92
+ /** Width a description prefix always leaves for the action text after it. */
93
+ const descriptionActionReserve = '3em';
92
94
  function valueText(node, text, segments, size, line, weight) {
93
95
  node.textContent = text ?? '';
94
96
  applyTextWeight(node, weight);
@@ -106,11 +108,10 @@ function createHistory(body, primitives) {
106
108
  const badges = node('badges');
107
109
  const description = node('description');
108
110
  description.dataset.nlSlot = 'description';
109
- const descriptionTime = createElement(document, 'span');
110
- const descriptionDot = createElement(document, 'span', undefined, '•');
111
- const descriptionAddress = createElement(document, 'button');
112
- descriptionAddress.type = 'button';
113
- description.append(descriptionTime, descriptionDot, descriptionAddress);
111
+ const descriptionPrefix = createElement(document, 'span');
112
+ const descriptionAction = createElement(document, 'button');
113
+ descriptionAction.type = 'button';
114
+ description.append(descriptionPrefix, descriptionAction);
114
115
  const amounts = node('amounts');
115
116
  const fee = node('fee');
116
117
  const feeLabel = node('fee-label');
@@ -134,9 +135,8 @@ function createHistory(body, primitives) {
134
135
  title,
135
136
  badges,
136
137
  description,
137
- descriptionTime,
138
- descriptionDot,
139
- descriptionAddress,
138
+ descriptionPrefix,
139
+ descriptionAction,
140
140
  amounts,
141
141
  amountRows: new Map(),
142
142
  fee,
@@ -373,23 +373,29 @@ function bindHistory(body, row, primitives) {
373
373
  v.badges.style.display = row.badges?.length ? 'flex' : 'none';
374
374
  v.description.style.cssText = ellipsis + 'display:flex;max-width:100%;color:var(--nl-secondary);font-family:inherit;font-size:14px;line-height:20px;font-weight:400;font-variant-numeric:tabular-nums;';
375
375
  applyTextWeight(v.description, 400);
376
- const split = row.description?.indexOf(' • ') ?? -1;
377
- v.descriptionTime.textContent = split >= 0 ? row.description.slice(0, split) : '';
378
- v.descriptionTime.style.display = split >= 0 ? 'inline' : 'none';
379
- v.descriptionTime.style.flexShrink = '0';
380
- v.descriptionDot.style.cssText = `flex-shrink:0;margin:0 4px;display:${split >= 0 ? 'inline' : 'none'}`;
381
- v.descriptionAddress.style.cssText = ellipsis + 'appearance:none;display:block;max-width:100%;border:0;padding:0;background:transparent;text-align:left;color:inherit;font:inherit;font-variant-numeric:inherit;';
382
- v.descriptionAddress.textContent = split >= 0 ? row.description.slice(split + 3) : row.description ?? '';
376
+ // The caller states where the action text starts; the string is not parsed.
377
+ const description = row.description ?? '';
378
+ const actionStart = row.descriptionActionKey ? Math.min(Math.max(row.descriptionActionStart ?? 0, 0), description.length) : 0;
379
+ const actionText = description.slice(actionStart);
380
+ const boundAction = row.descriptionActionKey && actionText ? row.descriptionActionKey : '';
381
+ // `pre` keeps the space a prefix ends with; a line break stays a space.
382
+ v.descriptionPrefix.textContent = description.slice(0, actionStart).replace(/\r\n|[\r\n]/g, ' ');
383
+ // The prefix keeps its width and the action truncates first, as the tail of
384
+ // the one native label does. A prefix wider than the row is capped instead,
385
+ // or it would squeeze the action to nothing and leave no pointer target.
386
+ v.descriptionPrefix.style.cssText = `${ellipsis}flex-shrink:0;max-width:${actionText ? `calc(100% - ${descriptionActionReserve})` : '100%'};white-space:pre;display:${actionStart > 0 ? 'block' : 'none'}`;
387
+ v.descriptionAction.style.cssText = `${ellipsis}appearance:none;max-width:100%;border:0;padding:0;background:transparent;text-align:left;color:inherit;font:inherit;font-variant-numeric:inherit;display:${actionText ? 'block' : 'none'};`;
388
+ v.descriptionAction.textContent = actionText;
383
389
  v.description.style.display = row.description ? 'flex' : 'none';
384
- v.descriptionAddress.tabIndex = row.descriptionActionKey ? 0 : -1;
385
- if (row.descriptionActionKey) {
386
- v.descriptionAddress.dataset.nativeListAction = row.descriptionActionKey;
387
- markActionAnchorSource(v.descriptionAddress, 'description');
388
- v.descriptionAddress.style.cursor = 'pointer';
390
+ v.descriptionAction.tabIndex = boundAction ? 0 : -1;
391
+ if (boundAction) {
392
+ v.descriptionAction.dataset.nativeListAction = boundAction;
393
+ markActionAnchorSource(v.descriptionAction, 'description');
394
+ v.descriptionAction.style.cursor = 'pointer';
389
395
  } else {
390
- delete v.descriptionAddress.dataset.nativeListAction;
391
- delete v.descriptionAddress.dataset.nativeListAnchorSource;
392
- v.descriptionAddress.style.cursor = 'inherit';
396
+ delete v.descriptionAction.dataset.nativeListAction;
397
+ delete v.descriptionAction.dataset.nativeListAnchorSource;
398
+ v.descriptionAction.style.cursor = 'inherit';
393
399
  }
394
400
  if (row.style?.description) primitives.textStyle(v.description, row.style.description);
395
401
  v.description.style.display = row.description ? 'flex' : 'none';
@@ -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,
@@ -269,7 +269,9 @@ function applyIdentityStyle(body, row) {
269
269
  }
270
270
  if (box.trailingGap !== undefined) {
271
271
  const gap = String(box.trailingGap) + 'px';
272
- 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 => {
273
275
  trailing.style.gap = gap;
274
276
  });
275
277
  }