@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.
- package/README.md +312 -379
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +15 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +3 -87
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +60 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +3 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +5 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +75 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +25 -19
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -0
- package/docs/ROW_TEMPLATES.md +12 -12
- package/docs/SPEC.md +226 -110
- package/docs/STYLE_SPEC.md +7 -0
- package/ios/NativeListActivityDetailsView.swift +13 -5
- package/ios/NativeListIdentityRenderer.swift +6 -94
- package/ios/NativeListMediaPlaceholderView.swift +189 -0
- package/ios/NativeListMediaTileRenderer.swift +13 -13
- package/ios/NativeListResolvedText.swift +15 -4
- package/ios/NativeListTextLabel.swift +106 -0
- package/ios/RNCNativeListView.swift +129 -32
- package/ios/tests/NativeListActivityPresentationTests.swift +270 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +0 -95
- package/ios/tests/NativeListLifecycleTests.swift +369 -40
- package/ios/tests/NativeListMediaVisibilityTests.swift +16 -7
- package/lib/module/NativeList.js +17 -4
- package/lib/module/NativeList.web.js +3 -1
- package/lib/module/models.js +0 -2
- package/lib/module/validation.js +54 -71
- package/lib/module/web/NativeListGeneratedIcons.js +1 -0
- package/lib/module/web/NativeListWebEngine.js +13 -11
- package/lib/module/web/templates/ActivityRowRenderer.js +29 -23
- package/lib/module/web/templates/DataRowRenderer.js +54 -1
- package/lib/module/web/templates/IdentityRowRenderer.js +3 -92
- package/lib/module/web/templates/MediaTileRowRenderer.js +84 -15
- package/lib/typescript/src/models.d.ts +19 -22
- package/package.json +1 -1
- package/scripts/generate-icons.test.mjs +1 -0
- package/scripts/native-list-icons.json +1 -1
- package/src/NativeList.tsx +25 -4
- package/src/NativeList.web.tsx +1 -1
- package/src/models.ts +18 -23
- package/src/validation.ts +89 -113
- package/src/web/NativeListGeneratedIcons.ts +1 -0
- package/src/web/NativeListWebEngine.ts +16 -11
- package/src/web/templates/ActivityRowRenderer.ts +42 -32
- package/src/web/templates/DataRowRenderer.ts +76 -1
- package/src/web/templates/IdentityRowRenderer.ts +3 -141
- package/src/web/templates/MediaTileRowRenderer.ts +90 -15
- package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentLayout.kt +0 -49
- package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentsView.kt +0 -105
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListTitleSegmentLayoutTest.kt +0 -80
- package/ios/NativeListTitleSegmentLayout.swift +0 -45
- package/ios/NativeListTitleSegmentsLabel.swift +0 -80
package/src/validation.ts
CHANGED
|
@@ -1344,105 +1344,29 @@ function assertButtonGroup(
|
|
|
1344
1344
|
});
|
|
1345
1345
|
}
|
|
1346
1346
|
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
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);
|
|
1347
|
+
// A passive label: its text and two caller colors, with no action or style slot.
|
|
1348
|
+
function assertWebLeadingBadge(value: unknown, path: string): void {
|
|
1349
|
+
if (value === undefined) return;
|
|
1350
|
+
const badge = protocolObject(value, path);
|
|
1396
1351
|
assertUnknownKeys(
|
|
1397
|
-
|
|
1398
|
-
['
|
|
1352
|
+
badge,
|
|
1353
|
+
['text', 'textColor', 'backgroundColor'],
|
|
1399
1354
|
path,
|
|
1400
|
-
'
|
|
1355
|
+
'web leading badge key'
|
|
1401
1356
|
);
|
|
1402
|
-
const { name, tintColor, accessibilityLabel } = icon;
|
|
1403
|
-
if (typeof name !== 'string' || !name.trim())
|
|
1404
|
-
fail(`${path}.name`, 'must be non-blank');
|
|
1405
1357
|
if (
|
|
1406
|
-
|
|
1407
|
-
|
|
1358
|
+
typeof badge.text !== 'string' ||
|
|
1359
|
+
!badge.text.trim() ||
|
|
1360
|
+
badge.text.length > MAX_TEXT_LENGTH
|
|
1408
1361
|
)
|
|
1409
|
-
fail(`${path}.
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
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;
|
|
1362
|
+
fail(`${path}.text`, 'must be non-blank within the text limit');
|
|
1363
|
+
for (const field of ['textColor', 'backgroundColor']) {
|
|
1364
|
+
const color = badge[field];
|
|
1365
|
+
if (
|
|
1366
|
+
typeof color !== 'string' ||
|
|
1367
|
+
!/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(color)
|
|
1368
|
+
)
|
|
1369
|
+
fail(`${path}.${field}`, 'must be #RRGGBB or #RRGGBBAA');
|
|
1446
1370
|
}
|
|
1447
1371
|
}
|
|
1448
1372
|
|
|
@@ -1723,6 +1647,11 @@ function assertVisual(row: RowModel, path: string): void {
|
|
|
1723
1647
|
});
|
|
1724
1648
|
}
|
|
1725
1649
|
|
|
1650
|
+
/** The type half of the `descriptionActionStart` contract; the range needs the row. */
|
|
1651
|
+
function isDescriptionActionStart(value: unknown): value is number {
|
|
1652
|
+
return Number.isSafeInteger(value) && (value as number) >= 0;
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1726
1655
|
function assertActivity(row: Partial<ActivityRow>, path: string): void {
|
|
1727
1656
|
if (row.hideLeading !== undefined && typeof row.hideLeading !== 'boolean')
|
|
1728
1657
|
fail(`${path}.hideLeading`, 'must be boolean');
|
|
@@ -1735,6 +1664,11 @@ function assertActivity(row: Partial<ActivityRow>, path: string): void {
|
|
|
1735
1664
|
fail(`${path}.presentation`, 'must be stacked or table');
|
|
1736
1665
|
if (row.descriptionActionKey !== undefined)
|
|
1737
1666
|
assertKey(row.descriptionActionKey, `${path}.descriptionActionKey`);
|
|
1667
|
+
if (
|
|
1668
|
+
row.descriptionActionStart !== undefined &&
|
|
1669
|
+
!isDescriptionActionStart(row.descriptionActionStart)
|
|
1670
|
+
)
|
|
1671
|
+
fail(`${path}.descriptionActionStart`, 'must be a non-negative integer');
|
|
1738
1672
|
if ((row.amounts?.length ?? 0) > 32)
|
|
1739
1673
|
fail(`${path}.amounts`, 'supports at most 32 amount lines');
|
|
1740
1674
|
const amountKeys = new Set<string>();
|
|
@@ -1936,7 +1870,6 @@ function assertRow(
|
|
|
1936
1870
|
);
|
|
1937
1871
|
});
|
|
1938
1872
|
assertIdentityExtras(row, path);
|
|
1939
|
-
assertIdentityTitleRuns(row, path);
|
|
1940
1873
|
assertText(row.subtitle, `${path}.subtitle`);
|
|
1941
1874
|
// OneKey patch: selector text segments truncate independently.
|
|
1942
1875
|
row.subtitleSegments?.forEach((segment, segmentIndex) => {
|
|
@@ -2002,6 +1935,13 @@ function assertRow(
|
|
|
2002
1935
|
break;
|
|
2003
1936
|
case 'activity':
|
|
2004
1937
|
assertActivity(row, path);
|
|
1938
|
+
// Checked on the complete row only: a patch may carry the offset
|
|
1939
|
+
// without the description it points into.
|
|
1940
|
+
if ((row.descriptionActionStart ?? 0) > (row.description?.length ?? 0))
|
|
1941
|
+
fail(
|
|
1942
|
+
`${path}.descriptionActionStart`,
|
|
1943
|
+
'must not exceed the description length'
|
|
1944
|
+
);
|
|
2005
1945
|
break;
|
|
2006
1946
|
case 'message':
|
|
2007
1947
|
if (
|
|
@@ -2025,6 +1965,10 @@ function assertRow(
|
|
|
2025
1965
|
assertKey(column.key, `${path}.columns[${columnIndex}].key`);
|
|
2026
1966
|
assertText(column.text, `${path}.columns[${columnIndex}].text`);
|
|
2027
1967
|
assertIdentityExtras(column, `${path}.columns[${columnIndex}]`);
|
|
1968
|
+
assertWebLeadingBadge(
|
|
1969
|
+
column.webLeadingBadge,
|
|
1970
|
+
`${path}.columns[${columnIndex}].webLeadingBadge`
|
|
1971
|
+
);
|
|
2028
1972
|
for (const field of [
|
|
2029
1973
|
'textSegments',
|
|
2030
1974
|
'secondaryTextSegments',
|
|
@@ -2519,8 +2463,6 @@ const ROW_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
|
2519
2463
|
'titleIcon',
|
|
2520
2464
|
'secondaryTitleIcon',
|
|
2521
2465
|
'titleImage',
|
|
2522
|
-
'titleSegments',
|
|
2523
|
-
'titleLeadingIcon',
|
|
2524
2466
|
'subtitle',
|
|
2525
2467
|
'tertiary',
|
|
2526
2468
|
'tertiaryTone',
|
|
@@ -2554,6 +2496,7 @@ const ROW_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
|
2554
2496
|
'presentation',
|
|
2555
2497
|
'fee',
|
|
2556
2498
|
'descriptionActionKey',
|
|
2499
|
+
'descriptionActionStart',
|
|
2557
2500
|
'footerActions',
|
|
2558
2501
|
],
|
|
2559
2502
|
message: [
|
|
@@ -2698,8 +2641,6 @@ const PATCH_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
|
2698
2641
|
'titleIcon',
|
|
2699
2642
|
'secondaryTitleIcon',
|
|
2700
2643
|
'titleImage',
|
|
2701
|
-
'titleSegments',
|
|
2702
|
-
'titleLeadingIcon',
|
|
2703
2644
|
'subtitle',
|
|
2704
2645
|
'tertiary',
|
|
2705
2646
|
'tertiaryTone',
|
|
@@ -2723,6 +2664,7 @@ const PATCH_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
|
2723
2664
|
'amounts',
|
|
2724
2665
|
'fee',
|
|
2725
2666
|
'descriptionActionKey',
|
|
2667
|
+
'descriptionActionStart',
|
|
2726
2668
|
'footerActions',
|
|
2727
2669
|
],
|
|
2728
2670
|
message: [
|
|
@@ -2831,7 +2773,6 @@ function protocolKey(value: unknown, path: string): void {
|
|
|
2831
2773
|
const PROTOCOL_ARRAY_FIELDS = new Set([
|
|
2832
2774
|
'columns',
|
|
2833
2775
|
'titleSuffixes',
|
|
2834
|
-
'titleSegments',
|
|
2835
2776
|
'cells',
|
|
2836
2777
|
'points',
|
|
2837
2778
|
'images',
|
|
@@ -3073,10 +3014,7 @@ function assertRowProtocol(row: RowModel, path: string): void {
|
|
|
3073
3014
|
if (row.height !== undefined && row.height < 0)
|
|
3074
3015
|
fail(`${path}.height`, 'must be non-negative');
|
|
3075
3016
|
if (row.type === 'identity') {
|
|
3076
|
-
if (isDevelopment())
|
|
3077
|
-
assertIdentityExtras(row, path);
|
|
3078
|
-
assertIdentityTitleRuns(row, path);
|
|
3079
|
-
}
|
|
3017
|
+
if (isDevelopment()) assertIdentityExtras(row, path);
|
|
3080
3018
|
if (row.titleSuffixes !== undefined && !Array.isArray(row.titleSuffixes))
|
|
3081
3019
|
fail(`${path}.titleSuffixes`, 'must be an array');
|
|
3082
3020
|
row.titleSuffixes?.forEach((suffix, index) => {
|
|
@@ -3140,7 +3078,13 @@ function assertRowProtocol(row: RowModel, path: string): void {
|
|
|
3140
3078
|
row.columns.forEach((column, index) => {
|
|
3141
3079
|
const columnPath = `${path}.columns[${index}]`;
|
|
3142
3080
|
protocolObject(column, columnPath);
|
|
3143
|
-
if (isDevelopment())
|
|
3081
|
+
if (isDevelopment()) {
|
|
3082
|
+
assertIdentityExtras(column, columnPath);
|
|
3083
|
+
assertWebLeadingBadge(
|
|
3084
|
+
column.webLeadingBadge,
|
|
3085
|
+
`${columnPath}.webLeadingBadge`
|
|
3086
|
+
);
|
|
3087
|
+
}
|
|
3144
3088
|
});
|
|
3145
3089
|
if (isDevelopment())
|
|
3146
3090
|
assertTrailingAccessories(row.trailing, `${path}.trailing`);
|
|
@@ -3599,6 +3543,7 @@ const NESTED_DECORATION_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
|
3599
3543
|
'textSegments',
|
|
3600
3544
|
'titleIcon',
|
|
3601
3545
|
'secondaryTitleIcon',
|
|
3546
|
+
'webLeadingBadge',
|
|
3602
3547
|
'secondaryLeadingText',
|
|
3603
3548
|
'secondaryText',
|
|
3604
3549
|
'secondaryTextSegments',
|
|
@@ -3673,14 +3618,26 @@ const NESTED_DECORATION_FIELDS: Readonly<Record<string, readonly string[]>> = {
|
|
|
3673
3618
|
|
|
3674
3619
|
function sanitizeDecoration(value: unknown, field: string): unknown {
|
|
3675
3620
|
if (value === undefined || value === null) return undefined;
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3621
|
+
// All or nothing: a badge without valid text and both colors is dropped, and
|
|
3622
|
+
// only its three declared fields are kept.
|
|
3623
|
+
if (field === 'webLeadingBadge') {
|
|
3624
|
+
if (
|
|
3625
|
+
!isRecord(value) ||
|
|
3626
|
+
typeof value.text !== 'string' ||
|
|
3627
|
+
!value.text.trim() ||
|
|
3628
|
+
value.text.length > MAX_TEXT_LENGTH
|
|
3629
|
+
)
|
|
3630
|
+
return undefined;
|
|
3631
|
+
const { textColor, backgroundColor } = value;
|
|
3632
|
+
if (
|
|
3633
|
+
typeof textColor !== 'string' ||
|
|
3634
|
+
!/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(textColor) ||
|
|
3635
|
+
typeof backgroundColor !== 'string' ||
|
|
3636
|
+
!/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(backgroundColor)
|
|
3637
|
+
)
|
|
3638
|
+
return undefined;
|
|
3639
|
+
return { text: value.text, textColor, backgroundColor };
|
|
3640
|
+
}
|
|
3684
3641
|
if (
|
|
3685
3642
|
!Array.isArray(value) &&
|
|
3686
3643
|
[
|
|
@@ -4050,6 +4007,11 @@ function sanitizeRowForProduction(row: RowModel): RowModel {
|
|
|
4050
4007
|
delete next[field];
|
|
4051
4008
|
continue;
|
|
4052
4009
|
}
|
|
4010
|
+
if (field === 'descriptionActionStart') {
|
|
4011
|
+
// Renderers clamp an offset past the text; anything else has no meaning.
|
|
4012
|
+
if (!isDescriptionActionStart(value)) delete next[field];
|
|
4013
|
+
continue;
|
|
4014
|
+
}
|
|
4053
4015
|
if (field === 'parent' && isRecord(value))
|
|
4054
4016
|
next[field] = sanitizeRowForProduction(value as unknown as RowModel);
|
|
4055
4017
|
else if (field === 'children' && Array.isArray(value))
|
|
@@ -4496,6 +4458,10 @@ function assertPatchChanges(patch: PatchValues, index: number): void {
|
|
|
4496
4458
|
assertKey(column.key, `${path}.columns[${columnIndex}].key`);
|
|
4497
4459
|
assertText(column.text, `${path}.columns[${columnIndex}].text`);
|
|
4498
4460
|
assertIdentityExtras(column, `${path}.columns[${columnIndex}]`);
|
|
4461
|
+
assertWebLeadingBadge(
|
|
4462
|
+
column.webLeadingBadge,
|
|
4463
|
+
`${path}.columns[${columnIndex}].webLeadingBadge`
|
|
4464
|
+
);
|
|
4499
4465
|
for (const field of [
|
|
4500
4466
|
'textSegments',
|
|
4501
4467
|
'secondaryTextSegments',
|
|
@@ -4981,6 +4947,16 @@ function mergeAndValidateSingleRow(
|
|
|
4981
4947
|
)
|
|
4982
4948
|
changes.subtitle = null;
|
|
4983
4949
|
}
|
|
4950
|
+
// The offset points into one specific description string, so a patch that
|
|
4951
|
+
// replaces the description without restating it falls back to the default.
|
|
4952
|
+
if (
|
|
4953
|
+
previous.type === 'activity' &&
|
|
4954
|
+
'description' in changes &&
|
|
4955
|
+
changes.description !== previous.description &&
|
|
4956
|
+
!('descriptionActionStart' in changes) &&
|
|
4957
|
+
previous.descriptionActionStart !== undefined
|
|
4958
|
+
)
|
|
4959
|
+
changes.descriptionActionStart = null;
|
|
4984
4960
|
const merged = { ...previous } as unknown as Record<string, unknown>;
|
|
4985
4961
|
for (const [field, value] of Object.entries(changes)) {
|
|
4986
4962
|
if (value === null) delete merged[field];
|
|
@@ -18,6 +18,7 @@ export const nativeListGeneratedIcons: Readonly<Record<string, string>> = {
|
|
|
18
18
|
GasSolid: 'GasSolid',
|
|
19
19
|
GlobusOutline: 'GlobusOutline',
|
|
20
20
|
GoogleIllus: 'GoogleIllus',
|
|
21
|
+
InfoCircleOutline: 'InfoCircleOutline',
|
|
21
22
|
LockSolid: 'LockSolid',
|
|
22
23
|
PencilOutline: 'PencilOutline',
|
|
23
24
|
PlusLargeOutline: 'PlusLargeOutline',
|
|
@@ -418,6 +418,15 @@ function effectiveRows(snapshot: NativeListSnapshot): readonly RowModel[] {
|
|
|
418
418
|
return snapshot.emptyState ? [snapshot.emptyState] : [];
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
+
function isDarkBackground(color: string | undefined) {
|
|
422
|
+
const rgb = color ? /^#([0-9a-f]{6})/i.exec(color)?.[1] : undefined;
|
|
423
|
+
if (!rgb) return false;
|
|
424
|
+
const red = Number.parseInt(rgb.slice(0, 2), 16);
|
|
425
|
+
const green = Number.parseInt(rgb.slice(2, 4), 16);
|
|
426
|
+
const blue = Number.parseInt(rgb.slice(4, 6), 16);
|
|
427
|
+
return red * 299 + green * 587 + blue * 114 < 128_000;
|
|
428
|
+
}
|
|
429
|
+
|
|
421
430
|
function resolvedTheme(snapshot: NativeListSnapshot): NativeListTheme {
|
|
422
431
|
return { ...defaultTheme, ...snapshot.theme };
|
|
423
432
|
}
|
|
@@ -843,7 +852,7 @@ export const WEB_LIST_CSS = `
|
|
|
843
852
|
.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
853
|
.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
854
|
.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-
|
|
855
|
+
.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}
|
|
847
856
|
.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
857
|
.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
858
|
.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}
|
|
@@ -860,7 +869,7 @@ export const WEB_LIST_CSS = `
|
|
|
860
869
|
.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)}
|
|
861
870
|
.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}
|
|
862
871
|
.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)}
|
|
863
|
-
.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)}
|
|
872
|
+
.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)}
|
|
864
873
|
.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)}
|
|
865
874
|
.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}
|
|
866
875
|
.ok-native-list-item[data-native-list-row-press-enabled="true"]:active>.ok-native-list-history{background:var(--nl-selected)}
|
|
@@ -1311,15 +1320,8 @@ function createVisual(
|
|
|
1311
1320
|
'span',
|
|
1312
1321
|
'ok-native-list-image-skeleton'
|
|
1313
1322
|
);
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
if (rgb) {
|
|
1317
|
-
const red = Number.parseInt(rgb.slice(0, 2), 16);
|
|
1318
|
-
const green = Number.parseInt(rgb.slice(2, 4), 16);
|
|
1319
|
-
const blue = Number.parseInt(rgb.slice(4, 6), 16);
|
|
1320
|
-
if (red * 299 + green * 587 + blue * 114 < 128_000)
|
|
1321
|
-
skeleton.dataset.dark = 'true';
|
|
1322
|
-
}
|
|
1323
|
+
if (isDarkBackground(resolvedTheme(context.snapshot).background))
|
|
1324
|
+
skeleton.dataset.dark = 'true';
|
|
1323
1325
|
frame.appendChild(skeleton);
|
|
1324
1326
|
image.addEventListener('load', () => skeleton.remove(), { once: true });
|
|
1325
1327
|
image.addEventListener('error', () => skeleton.remove(), { once: true });
|
|
@@ -3165,6 +3167,9 @@ export class NativeListWebEngine {
|
|
|
3165
3167
|
'--nl-inverse': theme.inverseBackground,
|
|
3166
3168
|
'--nl-inverse-text': theme.inverseText,
|
|
3167
3169
|
'--nl-info': theme.info,
|
|
3170
|
+
'--nl-media-shine': isDarkBackground(theme.background)
|
|
3171
|
+
? 'rgba(255,255,255,0.07)'
|
|
3172
|
+
: 'rgba(255,255,255,0.75)',
|
|
3168
3173
|
};
|
|
3169
3174
|
Object.entries(values).forEach(([name, value]) => {
|
|
3170
3175
|
if (!value) return;
|
|
@@ -168,9 +168,10 @@ type HistoryViews = {
|
|
|
168
168
|
title: HTMLElement;
|
|
169
169
|
badges: HTMLElement;
|
|
170
170
|
description: HTMLElement;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
/** Description text before the action, or nothing. */
|
|
172
|
+
descriptionPrefix: HTMLElement;
|
|
173
|
+
/** Description text that opens the action; the whole text without one. */
|
|
174
|
+
descriptionAction: HTMLButtonElement;
|
|
174
175
|
amounts: HTMLElement;
|
|
175
176
|
amountRows: Map<string, AmountViews>;
|
|
176
177
|
fee: HTMLElement;
|
|
@@ -196,6 +197,8 @@ const isHistory = (row: ActivityRow) =>
|
|
|
196
197
|
row.presentation !== undefined || row.amounts !== undefined;
|
|
197
198
|
const ellipsis =
|
|
198
199
|
'min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;';
|
|
200
|
+
/** Width a description prefix always leaves for the action text after it. */
|
|
201
|
+
const descriptionActionReserve = '3em';
|
|
199
202
|
function valueText(
|
|
200
203
|
node: HTMLElement,
|
|
201
204
|
text: string | undefined,
|
|
@@ -221,14 +224,13 @@ function createHistory(body: HTMLElement, primitives: RowPrimitives) {
|
|
|
221
224
|
const badges = node('badges');
|
|
222
225
|
const description = node('description');
|
|
223
226
|
description.dataset.nlSlot = 'description';
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
const descriptionAddress = createElement(
|
|
227
|
+
const descriptionPrefix = createElement(document, 'span');
|
|
228
|
+
const descriptionAction = createElement(
|
|
227
229
|
document,
|
|
228
230
|
'button'
|
|
229
231
|
) as HTMLButtonElement;
|
|
230
|
-
|
|
231
|
-
description.append(
|
|
232
|
+
descriptionAction.type = 'button';
|
|
233
|
+
description.append(descriptionPrefix, descriptionAction);
|
|
232
234
|
const amounts = node('amounts');
|
|
233
235
|
const fee = node('fee');
|
|
234
236
|
const feeLabel = node('fee-label');
|
|
@@ -252,9 +254,8 @@ function createHistory(body: HTMLElement, primitives: RowPrimitives) {
|
|
|
252
254
|
title,
|
|
253
255
|
badges,
|
|
254
256
|
description,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
descriptionAddress,
|
|
257
|
+
descriptionPrefix,
|
|
258
|
+
descriptionAction,
|
|
258
259
|
amounts,
|
|
259
260
|
amountRows: new Map(),
|
|
260
261
|
fee,
|
|
@@ -579,29 +580,38 @@ function bindHistory(
|
|
|
579
580
|
ellipsis +
|
|
580
581
|
'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;';
|
|
581
582
|
applyTextWeight(v.description, 400);
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
583
|
+
// The caller states where the action text starts; the string is not parsed.
|
|
584
|
+
const description = row.description ?? '';
|
|
585
|
+
const actionStart = row.descriptionActionKey
|
|
586
|
+
? Math.min(Math.max(row.descriptionActionStart ?? 0, 0), description.length)
|
|
587
|
+
: 0;
|
|
588
|
+
const actionText = description.slice(actionStart);
|
|
589
|
+
const boundAction =
|
|
590
|
+
row.descriptionActionKey && actionText ? row.descriptionActionKey : '';
|
|
591
|
+
// `pre` keeps the space a prefix ends with; a line break stays a space.
|
|
592
|
+
v.descriptionPrefix.textContent = description
|
|
593
|
+
.slice(0, actionStart)
|
|
594
|
+
.replace(/\r\n|[\r\n]/g, ' ');
|
|
595
|
+
// The prefix keeps its width and the action truncates first, as the tail of
|
|
596
|
+
// the one native label does. A prefix wider than the row is capped instead,
|
|
597
|
+
// or it would squeeze the action to nothing and leave no pointer target.
|
|
598
|
+
v.descriptionPrefix.style.cssText = `${ellipsis}flex-shrink:0;max-width:${
|
|
599
|
+
actionText ? `calc(100% - ${descriptionActionReserve})` : '100%'
|
|
600
|
+
};white-space:pre;display:${actionStart > 0 ? 'block' : 'none'}`;
|
|
601
|
+
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:${
|
|
602
|
+
actionText ? 'block' : 'none'
|
|
603
|
+
};`;
|
|
604
|
+
v.descriptionAction.textContent = actionText;
|
|
595
605
|
v.description.style.display = row.description ? 'flex' : 'none';
|
|
596
|
-
v.
|
|
597
|
-
if (
|
|
598
|
-
v.
|
|
599
|
-
markActionAnchorSource(v.
|
|
600
|
-
v.
|
|
606
|
+
v.descriptionAction.tabIndex = boundAction ? 0 : -1;
|
|
607
|
+
if (boundAction) {
|
|
608
|
+
v.descriptionAction.dataset.nativeListAction = boundAction;
|
|
609
|
+
markActionAnchorSource(v.descriptionAction, 'description');
|
|
610
|
+
v.descriptionAction.style.cursor = 'pointer';
|
|
601
611
|
} else {
|
|
602
|
-
delete v.
|
|
603
|
-
delete v.
|
|
604
|
-
v.
|
|
612
|
+
delete v.descriptionAction.dataset.nativeListAction;
|
|
613
|
+
delete v.descriptionAction.dataset.nativeListAnchorSource;
|
|
614
|
+
v.descriptionAction.style.cursor = 'inherit';
|
|
605
615
|
}
|
|
606
616
|
if (row.style?.description)
|
|
607
617
|
primitives.textStyle(v.description, row.style.description);
|
|
@@ -11,6 +11,7 @@ type ColumnViews = {
|
|
|
11
11
|
body: HTMLElement;
|
|
12
12
|
primaryLine: HTMLElement;
|
|
13
13
|
primary: HTMLElement;
|
|
14
|
+
leadingBadge: HTMLElement;
|
|
14
15
|
titleIcons: HTMLElement;
|
|
15
16
|
badges: HTMLElement;
|
|
16
17
|
secondaryLine: HTMLElement;
|
|
@@ -43,6 +44,22 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
43
44
|
body.removeAttribute('data-nl-container-background');
|
|
44
45
|
body.removeAttribute('data-nl-container-border');
|
|
45
46
|
const style = row.style;
|
|
47
|
+
const isTokenTable =
|
|
48
|
+
row.index === undefined &&
|
|
49
|
+
!row.favorite &&
|
|
50
|
+
!row.checkbox &&
|
|
51
|
+
row.columns.length === 4 &&
|
|
52
|
+
row.columns[0]?.key === 'asset' &&
|
|
53
|
+
row.columns[1]?.key === 'balance' &&
|
|
54
|
+
row.columns[2]?.key === 'price' &&
|
|
55
|
+
row.columns[3]?.key === 'swapSpacer';
|
|
56
|
+
if (isTokenTable) {
|
|
57
|
+
// Match the legacy four equal columns, including the icon in the first.
|
|
58
|
+
body.style.display = 'grid';
|
|
59
|
+
body.style.gridTemplateColumns = 'repeat(4, minmax(0, 1fr))';
|
|
60
|
+
body.style.gap = '0';
|
|
61
|
+
}
|
|
62
|
+
|
|
46
63
|
if (style?.horizontalPadding !== undefined)
|
|
47
64
|
body.style.paddingInline = `${style.horizontalPadding}px`;
|
|
48
65
|
if (style?.verticalPadding !== undefined)
|
|
@@ -80,6 +97,9 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
80
97
|
style?.image?.height ?? 40,
|
|
81
98
|
(style?.leadingGap ?? 12) - 12
|
|
82
99
|
);
|
|
100
|
+
if (v.visual) v.visual.style.gridArea = isTokenTable ? '1 / 1' : '';
|
|
101
|
+
v.trailing.style.gridArea = isTokenTable ? '1 / 4' : '';
|
|
102
|
+
v.trailing.style.justifySelf = isTokenTable ? 'end' : '';
|
|
83
103
|
v.columns.forEach((cell, index) => {
|
|
84
104
|
const column = row.columns[index];
|
|
85
105
|
cell.body.hidden = !column;
|
|
@@ -92,6 +112,15 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
92
112
|
cell.body.hidden = false;
|
|
93
113
|
cell.body.style.flex = String(column.weight ?? 1);
|
|
94
114
|
cell.body.style.display = 'flex';
|
|
115
|
+
if (isTokenTable) {
|
|
116
|
+
cell.body.style.gridArea = `1 / ${index + 1}`;
|
|
117
|
+
if (index === 0 && v.visual) {
|
|
118
|
+
cell.body.style.marginInlineStart = `${
|
|
119
|
+
(style?.image?.width ?? 40) + (style?.leadingGap ?? 12)
|
|
120
|
+
}px`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
95
124
|
cell.body.dataset.align = column.alignment ?? 'start';
|
|
96
125
|
if (style?.lineGap !== undefined)
|
|
97
126
|
cell.body.style.rowGap = `${style.lineGap}px`;
|
|
@@ -109,6 +138,45 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
109
138
|
fontWeight(style?.columns?.fontWeight, 500)
|
|
110
139
|
);
|
|
111
140
|
if (style?.columns) primitives.textStyle(cell.primary, style.columns);
|
|
141
|
+
const leadingBadge = column.webLeadingBadge;
|
|
142
|
+
cell.leadingBadge.hidden = !leadingBadge;
|
|
143
|
+
cell.leadingBadge.style.cssText = '';
|
|
144
|
+
cell.leadingBadge.textContent = leadingBadge?.text ?? '';
|
|
145
|
+
if (leadingBadge) {
|
|
146
|
+
// The line spans the column so the badge cap is a share of the column
|
|
147
|
+
// rather than of the line's own content; justifyContent then carries
|
|
148
|
+
// the column alignment the shrink-to-fit line got from its cell.
|
|
149
|
+
cell.primaryLine.style.alignSelf = 'stretch';
|
|
150
|
+
cell.primaryLine.style.justifyContent =
|
|
151
|
+
column.alignment === 'end'
|
|
152
|
+
? 'flex-end'
|
|
153
|
+
: column.alignment === 'center'
|
|
154
|
+
? 'center'
|
|
155
|
+
: 'flex-start';
|
|
156
|
+
cell.primaryLine.style.gap = '8px';
|
|
157
|
+
// A long label truncates at half the column; the primary text keeps the
|
|
158
|
+
// rest and truncates after it, so neither can leave the column.
|
|
159
|
+
cell.leadingBadge.style.display = 'block';
|
|
160
|
+
cell.leadingBadge.style.boxSizing = 'border-box';
|
|
161
|
+
cell.leadingBadge.style.flexShrink = '0';
|
|
162
|
+
cell.leadingBadge.style.maxWidth = '50%';
|
|
163
|
+
cell.leadingBadge.style.overflow = 'hidden';
|
|
164
|
+
cell.leadingBadge.style.textOverflow = 'ellipsis';
|
|
165
|
+
cell.leadingBadge.style.whiteSpace = 'nowrap';
|
|
166
|
+
cell.leadingBadge.style.padding = '2px 6px';
|
|
167
|
+
cell.leadingBadge.style.borderRadius = '4px';
|
|
168
|
+
cell.leadingBadge.style.fontSize = '12px';
|
|
169
|
+
cell.leadingBadge.style.lineHeight = '16px';
|
|
170
|
+
cell.leadingBadge.style.fontWeight = '400';
|
|
171
|
+
cell.leadingBadge.style.fontFamily = 'var(--nl-font-regular)';
|
|
172
|
+
cell.leadingBadge.style.color = leadingBadge.textColor;
|
|
173
|
+
cell.leadingBadge.style.backgroundColor = leadingBadge.backgroundColor;
|
|
174
|
+
cell.leadingBadge.style.pointerEvents = 'none';
|
|
175
|
+
cell.primary.style.minWidth = '0';
|
|
176
|
+
cell.primary.style.overflow = 'hidden';
|
|
177
|
+
cell.primary.style.textOverflow = 'ellipsis';
|
|
178
|
+
cell.primary.style.whiteSpace = 'nowrap';
|
|
179
|
+
}
|
|
112
180
|
cell.titleIcons.replaceChildren();
|
|
113
181
|
if (column.titleIcon || column.secondaryTitleIcon) {
|
|
114
182
|
cell.primary.style.minWidth = '0';
|
|
@@ -210,10 +278,16 @@ function create(document: Document, row: DataRow, primitives: RowPrimitives) {
|
|
|
210
278
|
'ok-native-list-data-primary'
|
|
211
279
|
);
|
|
212
280
|
const primary = tagSlot(createElement(document, 'span'), 'columns');
|
|
281
|
+
const leadingBadge = createElement(
|
|
282
|
+
document,
|
|
283
|
+
'span',
|
|
284
|
+
'ok-native-list-data-leading-badge'
|
|
285
|
+
);
|
|
286
|
+
leadingBadge.hidden = true;
|
|
213
287
|
const titleIcons = createElement(document, 'span');
|
|
214
288
|
titleIcons.style.display = 'contents';
|
|
215
289
|
const badges = createElement(document, 'span');
|
|
216
|
-
primaryLine.append(primary, titleIcons, badges);
|
|
290
|
+
primaryLine.append(leadingBadge, primary, titleIcons, badges);
|
|
217
291
|
const secondaryLine = createElement(
|
|
218
292
|
document,
|
|
219
293
|
'span',
|
|
@@ -232,6 +306,7 @@ function create(document: Document, row: DataRow, primitives: RowPrimitives) {
|
|
|
232
306
|
body: cell,
|
|
233
307
|
primaryLine,
|
|
234
308
|
primary,
|
|
309
|
+
leadingBadge,
|
|
235
310
|
titleIcons,
|
|
236
311
|
badges,
|
|
237
312
|
secondaryLine,
|