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

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/src/models.ts CHANGED
@@ -513,6 +513,19 @@ 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
+
516
529
  export type IdentityRow = RowBase &
517
530
  Readonly<{
518
531
  type: 'identity';
@@ -544,6 +557,14 @@ export type IdentityRow = RowBase &
544
557
  }>;
545
558
  /** Web-only additional help icon after titleIcon. */
546
559
  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
+ }>;
547
568
  /** Circular image after title icons; image dimensions must be square, 1...40. */
548
569
  titleImage?: Readonly<{
549
570
  image: ImageSource;
@@ -1093,6 +1114,8 @@ export type RowPatch =
1093
1114
  | 'titleIcon'
1094
1115
  | 'secondaryTitleIcon'
1095
1116
  | 'titleImage'
1117
+ | 'titleSegments'
1118
+ | 'titleLeadingIcon'
1096
1119
  | 'subtitle'
1097
1120
  | 'subtitleLines'
1098
1121
  | 'contentHeight'
package/src/validation.ts CHANGED
@@ -1344,6 +1344,108 @@ function assertButtonGroup(
1344
1344
  });
1345
1345
  }
1346
1346
 
1347
+ const MAX_TITLE_SEGMENTS = 4;
1348
+ const HEX_COLOR_PATTERN = /^#[0-9a-f]{6}([0-9a-f]{2})?$/i;
1349
+
1350
+ function assertTitleSegments(value: unknown, path: string): void {
1351
+ if (
1352
+ !Array.isArray(value) ||
1353
+ value.length === 0 ||
1354
+ value.length > MAX_TITLE_SEGMENTS
1355
+ )
1356
+ fail(path, `must hold 1...${MAX_TITLE_SEGMENTS} segments`);
1357
+ let shrinking = 0;
1358
+ value.forEach((item: unknown, index) => {
1359
+ const segmentPath = `${path}[${index}]`;
1360
+ const segment = protocolObject(item, segmentPath);
1361
+ assertUnknownKeys(
1362
+ segment,
1363
+ ['text', 'tone', 'fontWeight', 'shrink', 'maxWidthRatio'],
1364
+ segmentPath,
1365
+ 'title segment key'
1366
+ );
1367
+ const { text, tone, fontWeight, shrink, maxWidthRatio } = segment;
1368
+ if (typeof text !== 'string' || !text.trim())
1369
+ fail(`${segmentPath}.text`, 'must be non-blank');
1370
+ assertText(text, `${segmentPath}.text`);
1371
+ if (tone !== undefined && tone !== 'primary' && tone !== 'secondary')
1372
+ fail(`${segmentPath}.tone`, 'must be primary or secondary');
1373
+ if (
1374
+ fontWeight !== undefined &&
1375
+ fontWeight !== 'regular' &&
1376
+ fontWeight !== 'medium'
1377
+ )
1378
+ fail(`${segmentPath}.fontWeight`, 'must be regular or medium');
1379
+ if (shrink !== undefined && typeof shrink !== 'boolean')
1380
+ fail(`${segmentPath}.shrink`, 'must be a boolean');
1381
+ if (shrink) shrinking += 1;
1382
+ if (
1383
+ maxWidthRatio !== undefined &&
1384
+ (typeof maxWidthRatio !== 'number' ||
1385
+ !Number.isFinite(maxWidthRatio) ||
1386
+ maxWidthRatio <= 0 ||
1387
+ maxWidthRatio > 1)
1388
+ )
1389
+ fail(`${segmentPath}.maxWidthRatio`, 'must be finite within (0, 1]');
1390
+ });
1391
+ if (shrinking > 1) fail(path, 'allows at most one shrinking segment');
1392
+ }
1393
+
1394
+ function assertTitleLeadingIcon(value: unknown, path: string): void {
1395
+ const icon = protocolObject(value, path);
1396
+ assertUnknownKeys(
1397
+ icon,
1398
+ ['name', 'tintColor', 'accessibilityLabel'],
1399
+ path,
1400
+ 'title leading icon key'
1401
+ );
1402
+ const { name, tintColor, accessibilityLabel } = icon;
1403
+ if (typeof name !== 'string' || !name.trim())
1404
+ fail(`${path}.name`, 'must be non-blank');
1405
+ if (
1406
+ tintColor !== undefined &&
1407
+ (typeof tintColor !== 'string' || !HEX_COLOR_PATTERN.test(tintColor))
1408
+ )
1409
+ fail(`${path}.tintColor`, 'must be #RRGGBB or #RRGGBBAA');
1410
+ if (
1411
+ accessibilityLabel !== undefined &&
1412
+ typeof accessibilityLabel !== 'string'
1413
+ )
1414
+ fail(`${path}.accessibilityLabel`, 'must be a string');
1415
+ }
1416
+
1417
+ function assertIdentityTitleRuns(
1418
+ row: Pick<
1419
+ IdentityRow,
1420
+ 'titleSegments' | 'titleLeadingIcon' | 'titleMatch' | 'presentation'
1421
+ >,
1422
+ path: string
1423
+ ): void {
1424
+ if (row.titleSegments !== undefined) {
1425
+ assertTitleSegments(row.titleSegments, `${path}.titleSegments`);
1426
+ // titleMatch ranges index `title`, which the runs replace on screen.
1427
+ if (row.titleMatch?.length)
1428
+ fail(`${path}.titleMatch`, 'cannot be combined with titleSegments');
1429
+ if (row.presentation === 'walletSidebar')
1430
+ fail(`${path}.titleSegments`, 'is not supported with walletSidebar');
1431
+ }
1432
+ if (row.titleLeadingIcon !== undefined) {
1433
+ assertTitleLeadingIcon(row.titleLeadingIcon, `${path}.titleLeadingIcon`);
1434
+ if (row.presentation === 'walletSidebar')
1435
+ fail(`${path}.titleLeadingIcon`, 'is not supported with walletSidebar');
1436
+ }
1437
+ }
1438
+
1439
+ /** Production keeps decorative title runs only when they pass the rules. */
1440
+ function passesTitleRunRules(check: () => void): boolean {
1441
+ try {
1442
+ check();
1443
+ return true;
1444
+ } catch {
1445
+ return false;
1446
+ }
1447
+ }
1448
+
1347
1449
  function assertIdentityExtras(
1348
1450
  row: Pick<
1349
1451
  IdentityRow,
@@ -1834,6 +1936,7 @@ function assertRow(
1834
1936
  );
1835
1937
  });
1836
1938
  assertIdentityExtras(row, path);
1939
+ assertIdentityTitleRuns(row, path);
1837
1940
  assertText(row.subtitle, `${path}.subtitle`);
1838
1941
  // OneKey patch: selector text segments truncate independently.
1839
1942
  row.subtitleSegments?.forEach((segment, segmentIndex) => {
@@ -2416,6 +2519,8 @@ const ROW_FIELDS: Readonly<Record<string, readonly string[]>> = {
2416
2519
  'titleIcon',
2417
2520
  'secondaryTitleIcon',
2418
2521
  'titleImage',
2522
+ 'titleSegments',
2523
+ 'titleLeadingIcon',
2419
2524
  'subtitle',
2420
2525
  'tertiary',
2421
2526
  'tertiaryTone',
@@ -2593,6 +2698,8 @@ const PATCH_FIELDS: Readonly<Record<string, readonly string[]>> = {
2593
2698
  'titleIcon',
2594
2699
  'secondaryTitleIcon',
2595
2700
  'titleImage',
2701
+ 'titleSegments',
2702
+ 'titleLeadingIcon',
2596
2703
  'subtitle',
2597
2704
  'tertiary',
2598
2705
  'tertiaryTone',
@@ -2724,6 +2831,7 @@ function protocolKey(value: unknown, path: string): void {
2724
2831
  const PROTOCOL_ARRAY_FIELDS = new Set([
2725
2832
  'columns',
2726
2833
  'titleSuffixes',
2834
+ 'titleSegments',
2727
2835
  'cells',
2728
2836
  'points',
2729
2837
  'images',
@@ -2965,7 +3073,10 @@ function assertRowProtocol(row: RowModel, path: string): void {
2965
3073
  if (row.height !== undefined && row.height < 0)
2966
3074
  fail(`${path}.height`, 'must be non-negative');
2967
3075
  if (row.type === 'identity') {
2968
- if (isDevelopment()) assertIdentityExtras(row, path);
3076
+ if (isDevelopment()) {
3077
+ assertIdentityExtras(row, path);
3078
+ assertIdentityTitleRuns(row, path);
3079
+ }
2969
3080
  if (row.titleSuffixes !== undefined && !Array.isArray(row.titleSuffixes))
2970
3081
  fail(`${path}.titleSuffixes`, 'must be an array');
2971
3082
  row.titleSuffixes?.forEach((suffix, index) => {
@@ -3562,6 +3673,14 @@ const NESTED_DECORATION_FIELDS: Readonly<Record<string, readonly string[]>> = {
3562
3673
 
3563
3674
  function sanitizeDecoration(value: unknown, field: string): unknown {
3564
3675
  if (value === undefined || value === null) return undefined;
3676
+ if (field === 'titleSegments')
3677
+ return passesTitleRunRules(() => assertTitleSegments(value, field))
3678
+ ? value
3679
+ : undefined;
3680
+ if (field === 'titleLeadingIcon')
3681
+ return passesTitleRunRules(() => assertTitleLeadingIcon(value, field))
3682
+ ? value
3683
+ : undefined;
3565
3684
  if (
3566
3685
  !Array.isArray(value) &&
3567
3686
  [
@@ -843,7 +843,7 @@ export const WEB_LIST_CSS = `
843
843
  .ok-native-list-trailing-button{appearance:none;box-sizing:border-box;flex:0 0 auto;padding:4px 10px;border:1px solid transparent;border-radius:9999px;background:var(--nl-button-bg,var(--nl-strong));color:var(--nl-button-text,var(--nl-primary));font:500 14px/20px var(--nl-font-medium);white-space:nowrap;cursor:default}.ok-native-list-trailing-button:hover:not(:disabled){background:var(--nl-button-hover,var(--nl-strong))}.ok-native-list-trailing-button:active:not(:disabled){background:var(--nl-button-pressed,var(--nl-pressed))}.ok-native-list-trailing-button:focus-visible{outline:2px solid var(--nl-button-focus,var(--nl-accent))}.ok-native-list-trailing-button:disabled{opacity:.4;cursor:default}
844
844
  .ok-native-list-icon-button.ok-native-list-tertiary-icon{box-sizing:border-box;flex:0 0 38px;width:38px;height:38px;margin:-7px;padding:6px;border:1px solid transparent;border-radius:9999px;color:var(--nl-icon-subdued);background:transparent}.ok-native-list-icon-button.ok-native-list-tertiary-icon:hover:not(:disabled){background:var(--nl-hover)}.ok-native-list-icon-button.ok-native-list-tertiary-icon:active:not(:disabled){background:var(--nl-pressed)}.ok-native-list-icon-button.ok-native-list-tertiary-icon:disabled{opacity:.4;cursor:default}
845
845
  .ok-native-list-icon-button.ok-native-list-tertiary-icon:focus-visible:not(:disabled){outline:2px solid var(--nl-accent)}
846
- .ok-native-list-identity-title-icon{flex:0 0 20px;width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;color:var(--nl-icon);font-size:20px}.ok-native-list-identity-title-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
846
+ .ok-native-list-identity-title-icon{flex:0 0 20px;width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;color:var(--nl-icon);font-size:20px}.ok-native-list-identity-title-leading-icon{flex:0 0 16px;width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--nl-icon-subdued);font-size:16px}.ok-native-list-identity-title-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
847
847
  .ok-native-list-account-row .ok-native-list-visual,.ok-native-list-account-action-row .ok-native-list-visual{width:32px;height:32px;flex-basis:32px}.ok-native-list-account-row .ok-native-list-visual>img,.ok-native-list-account-row .ok-native-list-visual-main,.ok-native-list-account-action-row .ok-native-list-visual>img,.ok-native-list-account-action-row .ok-native-list-visual-main{width:32px;height:32px}.ok-native-list-account-row .ok-native-list-visual>.ok-native-list-visual-corner{width:20px;height:20px;padding:2px}.ok-native-list-account-action-row .ok-native-list-visual{border-radius:8px!important}.ok-native-list-wallet-row .ok-native-list-title{color:var(--nl-secondary);font-size:12px;line-height:16px;font-weight:400;font-family:var(--nl-font-regular)}.ok-native-list-item[data-native-list-selected="true"]>.ok-native-list-wallet-row .ok-native-list-title{color:var(--nl-primary)}.ok-native-list-account-row .ok-native-list-title{font-size:16px;line-height:20px;font-weight:400;font-family:var(--nl-font-regular)}.ok-native-list-account-row .ok-native-list-secondary{font-size:14px;line-height:20px;font-weight:400;font-family:var(--nl-font-regular)}
848
848
  .ok-native-list-flex{display:flex;flex:1;min-width:0;flex-direction:column;justify-content:center}.ok-native-list-title{font-size:15px;line-height:20px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:var(--nl-font-semibold)}.ok-native-list-secondary{font-size:13px;line-height:18px;color:var(--nl-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ok-native-list-tertiary{color:var(--nl-secondary)}.ok-native-list-info{color:var(--nl-info)}
849
849
  .ok-native-list-identity-row .ok-native-list-title,.ok-native-list-identity-row .ok-native-list-amounts>span:first-child{font-size:16px;line-height:20px}.ok-native-list-identity-row .ok-native-list-secondary{font-size:14px;line-height:20px}
@@ -872,7 +872,7 @@ export const WEB_LIST_CSS = `
872
872
  .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)}
873
873
  .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}
874
874
  @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)}}
875
- .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}
875
+ .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}
876
876
  .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)}
877
877
  .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)}
878
878
  .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. */
@@ -30,6 +30,79 @@ function toneColor(
30
30
  if (tone === 'secondary') return 'var(--nl-secondary)';
31
31
  return fallback === 'secondary' ? 'var(--nl-secondary)' : 'var(--nl-primary)';
32
32
  }
33
+ // Hidden from sight, still read: the runs themselves are hidden from
34
+ // assistive technology in favor of `title`.
35
+ const VISUALLY_HIDDEN: Partial<CSSStyleDeclaration> = {
36
+ position: 'absolute',
37
+ width: '1px',
38
+ height: '1px',
39
+ overflow: 'hidden',
40
+ clip: 'rect(0 0 0 0)',
41
+ whiteSpace: 'nowrap',
42
+ };
43
+ function appendTitleRuns(
44
+ document: Document,
45
+ target: HTMLElement,
46
+ row: IdentityRow
47
+ ): void {
48
+ const runs = createElement(
49
+ document,
50
+ 'span',
51
+ 'ok-native-list-identity-title-runs'
52
+ );
53
+ runs.setAttribute('aria-hidden', 'true');
54
+ Object.assign(runs.style, {
55
+ display: 'flex',
56
+ flex: '1 1 auto',
57
+ minWidth: '0',
58
+ maxWidth: '100%',
59
+ overflow: 'hidden',
60
+ });
61
+ row.titleSegments?.forEach((segment) => {
62
+ const run = createElement(
63
+ document,
64
+ 'span',
65
+ 'ok-native-list-identity-title-run',
66
+ segment.text
67
+ );
68
+ // Only the shrinking run gives up width; a cap is a share of the line.
69
+ Object.assign(run.style, {
70
+ flex: segment.shrink ? '0 1 auto' : '0 0 auto',
71
+ minWidth: segment.shrink ? '0' : '',
72
+ maxWidth:
73
+ segment.maxWidthRatio === undefined
74
+ ? ''
75
+ : `${segment.maxWidthRatio * 100}%`,
76
+ overflow: 'hidden',
77
+ textOverflow: 'ellipsis',
78
+ whiteSpace: 'pre',
79
+ });
80
+ if (segment.tone)
81
+ run.style.color =
82
+ segment.tone === 'secondary'
83
+ ? 'var(--nl-secondary)'
84
+ : 'var(--nl-primary)';
85
+ if (segment.fontWeight === 'medium') {
86
+ run.style.fontWeight = '500';
87
+ run.style.fontFamily = 'var(--nl-font-medium)';
88
+ } else if (segment.fontWeight === 'regular') {
89
+ run.style.fontWeight = '400';
90
+ run.style.fontFamily = 'var(--nl-font-regular)';
91
+ }
92
+ setData(run, 'tone', segment.tone);
93
+ runs.appendChild(run);
94
+ });
95
+ const spoken = createElement(
96
+ document,
97
+ 'span',
98
+ 'ok-native-list-identity-title-spoken',
99
+ row.title
100
+ );
101
+ Object.assign(spoken.style, VISUALLY_HIDDEN);
102
+ target.replaceChildren(runs, spoken);
103
+ target.style.display = 'flex';
104
+ target.style.minWidth = '0';
105
+ }
33
106
  function appendAccessories(
34
107
  parent: HTMLElement,
35
108
  document: Document,
@@ -195,6 +268,18 @@ function createIdentityRow(
195
268
  fragment.appendChild(document.createTextNode(row.title.slice(offset)));
196
269
  textTarget.prepend(fragment);
197
270
  }
271
+ // The runs replace the plain title, except where `title` itself is
272
+ // highlighted or shown in the wallet sidebar.
273
+ const hasTitleRuns =
274
+ !!row.titleSegments?.length &&
275
+ presentation !== 'walletSidebar' &&
276
+ !row.titleMatch?.length;
277
+ if (hasTitleRuns) {
278
+ const textTarget =
279
+ titleElement.querySelector<HTMLElement>('[data-nl-slot="title"]') ??
280
+ titleElement;
281
+ appendTitleRuns(document, textTarget, row);
282
+ }
198
283
  if (row.subtitleSegments?.length) {
199
284
  column.querySelector('.ok-native-list-secondary')?.remove();
200
285
  const segments = createElement(
@@ -391,6 +476,58 @@ function createIdentityRow(
391
476
  badges.style.minWidth = '0';
392
477
  }
393
478
  }
479
+ if (hasTitleRuns) {
480
+ // The runs fill what the title line leaves, so a ratio is a share of
481
+ // that width and title accessories sit at the line's end.
482
+ const runs = titleElement.querySelector<HTMLElement>(
483
+ '.ok-native-list-identity-title-runs'
484
+ );
485
+ for (
486
+ let node = runs?.parentElement;
487
+ node && node !== titleElement;
488
+ node = node.parentElement
489
+ ) {
490
+ node.style.display = 'flex';
491
+ node.style.flex = '1 1 auto';
492
+ node.style.minWidth = '0';
493
+ }
494
+ titleElement.style.display = 'flex';
495
+ titleElement.style.alignItems = 'center';
496
+ }
497
+ if (row.titleLeadingIcon && presentation !== 'walletSidebar') {
498
+ const descriptor = row.titleLeadingIcon;
499
+ if (titleElement.hasAttribute('data-nl-slot')) {
500
+ // Keep the glyph out of the title slot that text styles apply to.
501
+ const titleText = tagSlot(
502
+ createElement(document, 'span', 'ok-native-list-identity-title-text'),
503
+ 'title'
504
+ );
505
+ while (titleElement.firstChild)
506
+ titleText.appendChild(titleElement.firstChild);
507
+ if (hasTitleRuns) {
508
+ titleText.style.display = 'flex';
509
+ titleText.style.minWidth = '0';
510
+ }
511
+ titleElement.removeAttribute('data-nl-slot');
512
+ titleElement.appendChild(titleText);
513
+ }
514
+ const icon = primitives.iconAction(
515
+ descriptor.name,
516
+ undefined,
517
+ undefined,
518
+ descriptor.tintColor
519
+ );
520
+ icon.className = 'ok-native-list-identity-title-leading-icon';
521
+ if (descriptor.accessibilityLabel)
522
+ icon.setAttribute('aria-label', descriptor.accessibilityLabel);
523
+ else icon.setAttribute('aria-hidden', 'true');
524
+ titleElement.style.display = 'flex';
525
+ titleElement.style.alignItems = 'center';
526
+ // 6px to the title, whatever gap the title line already has.
527
+ const lineGap = Number.parseFloat(titleElement.style.gap || '0') || 0;
528
+ icon.style.marginInlineEnd = `${Math.max(0, 6 - lineGap)}px`;
529
+ titleElement.prepend(icon);
530
+ }
394
531
  if (presentation === 'walletSidebar' && row.badges?.length) {
395
532
  const badges = createElement(
396
533
  document,
@@ -403,6 +540,7 @@ function createIdentityRow(
403
540
  column.appendChild(badges);
404
541
  }
405
542
  for (const key of ['title', 'subtitle'] as const) {
543
+ if (key === 'title' && hasTitleRuns) continue;
406
544
  const lines = row.style?.[key]?.lines ?? row[`${key}Lines`];
407
545
  if (lines !== undefined)
408
546
  column