@onekeyfe/react-native-native-list 6.7.0-alpha.475 → 6.8.0-2
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 +9 -11
- package/docs/SPEC.md +188 -108
- 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 +50 -7
- package/ios/tests/NativeListActivityPresentationTests.swift +270 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +0 -95
- package/ios/tests/NativeListLifecycleTests.swift +176 -16
- 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 +23 -72
- package/lib/module/web/NativeListWebEngine.js +13 -11
- package/lib/module/web/templates/ActivityRowRenderer.js +29 -23
- package/lib/module/web/templates/DataRowRenderer.js +16 -0
- 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 +10 -22
- package/package.json +1 -1
- package/src/NativeList.tsx +25 -4
- package/src/NativeList.web.tsx +1 -1
- package/src/models.ts +9 -23
- package/src/validation.ts +35 -120
- package/src/web/NativeListWebEngine.ts +16 -11
- package/src/web/templates/ActivityRowRenderer.ts +42 -32
- package/src/web/templates/DataRowRenderer.ts +28 -0
- 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/lib/module/NativeList.js
CHANGED
|
@@ -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 ?
|
|
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",
|
package/lib/module/models.js
CHANGED
|
@@ -39,8 +39,6 @@ export const ROW_BOX_STYLE_KEYS_BY_TYPE = {
|
|
|
39
39
|
|
|
40
40
|
// OneKey patch: preserve compact very-small-balance digit runs.
|
|
41
41
|
|
|
42
|
-
/** One run of an identity title line; see docs/SPEC.md. */
|
|
43
|
-
|
|
44
42
|
/** Native Market quote row. All values are already localized/formatted strings. */
|
|
45
43
|
|
|
46
44
|
/** Compact KPI card for dashboards and grids. */
|
package/lib/module/validation.js
CHANGED
|
@@ -702,66 +702,6 @@ function assertButtonGroup(row, path) {
|
|
|
702
702
|
}
|
|
703
703
|
});
|
|
704
704
|
}
|
|
705
|
-
const MAX_TITLE_SEGMENTS = 4;
|
|
706
|
-
const HEX_COLOR_PATTERN = /^#[0-9a-f]{6}([0-9a-f]{2})?$/i;
|
|
707
|
-
function assertTitleSegments(value, path) {
|
|
708
|
-
if (!Array.isArray(value) || value.length === 0 || value.length > MAX_TITLE_SEGMENTS) fail(path, `must hold 1...${MAX_TITLE_SEGMENTS} segments`);
|
|
709
|
-
let shrinking = 0;
|
|
710
|
-
value.forEach((item, index) => {
|
|
711
|
-
const segmentPath = `${path}[${index}]`;
|
|
712
|
-
const segment = protocolObject(item, segmentPath);
|
|
713
|
-
assertUnknownKeys(segment, ['text', 'tone', 'fontWeight', 'shrink', 'maxWidthRatio'], segmentPath, 'title segment key');
|
|
714
|
-
const {
|
|
715
|
-
text,
|
|
716
|
-
tone,
|
|
717
|
-
fontWeight,
|
|
718
|
-
shrink,
|
|
719
|
-
maxWidthRatio
|
|
720
|
-
} = segment;
|
|
721
|
-
if (typeof text !== 'string' || !text.trim()) fail(`${segmentPath}.text`, 'must be non-blank');
|
|
722
|
-
assertText(text, `${segmentPath}.text`);
|
|
723
|
-
if (tone !== undefined && tone !== 'primary' && tone !== 'secondary') fail(`${segmentPath}.tone`, 'must be primary or secondary');
|
|
724
|
-
if (fontWeight !== undefined && fontWeight !== 'regular' && fontWeight !== 'medium') fail(`${segmentPath}.fontWeight`, 'must be regular or medium');
|
|
725
|
-
if (shrink !== undefined && typeof shrink !== 'boolean') fail(`${segmentPath}.shrink`, 'must be a boolean');
|
|
726
|
-
if (shrink) shrinking += 1;
|
|
727
|
-
if (maxWidthRatio !== undefined && (typeof maxWidthRatio !== 'number' || !Number.isFinite(maxWidthRatio) || maxWidthRatio <= 0 || maxWidthRatio > 1)) fail(`${segmentPath}.maxWidthRatio`, 'must be finite within (0, 1]');
|
|
728
|
-
});
|
|
729
|
-
if (shrinking > 1) fail(path, 'allows at most one shrinking segment');
|
|
730
|
-
}
|
|
731
|
-
function assertTitleLeadingIcon(value, path) {
|
|
732
|
-
const icon = protocolObject(value, path);
|
|
733
|
-
assertUnknownKeys(icon, ['name', 'tintColor', 'accessibilityLabel'], path, 'title leading icon key');
|
|
734
|
-
const {
|
|
735
|
-
name,
|
|
736
|
-
tintColor,
|
|
737
|
-
accessibilityLabel
|
|
738
|
-
} = icon;
|
|
739
|
-
if (typeof name !== 'string' || !name.trim()) fail(`${path}.name`, 'must be non-blank');
|
|
740
|
-
if (tintColor !== undefined && (typeof tintColor !== 'string' || !HEX_COLOR_PATTERN.test(tintColor))) fail(`${path}.tintColor`, 'must be #RRGGBB or #RRGGBBAA');
|
|
741
|
-
if (accessibilityLabel !== undefined && typeof accessibilityLabel !== 'string') fail(`${path}.accessibilityLabel`, 'must be a string');
|
|
742
|
-
}
|
|
743
|
-
function assertIdentityTitleRuns(row, path) {
|
|
744
|
-
if (row.titleSegments !== undefined) {
|
|
745
|
-
assertTitleSegments(row.titleSegments, `${path}.titleSegments`);
|
|
746
|
-
// titleMatch ranges index `title`, which the runs replace on screen.
|
|
747
|
-
if (row.titleMatch?.length) fail(`${path}.titleMatch`, 'cannot be combined with titleSegments');
|
|
748
|
-
if (row.presentation === 'walletSidebar') fail(`${path}.titleSegments`, 'is not supported with walletSidebar');
|
|
749
|
-
}
|
|
750
|
-
if (row.titleLeadingIcon !== undefined) {
|
|
751
|
-
assertTitleLeadingIcon(row.titleLeadingIcon, `${path}.titleLeadingIcon`);
|
|
752
|
-
if (row.presentation === 'walletSidebar') fail(`${path}.titleLeadingIcon`, 'is not supported with walletSidebar');
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
/** Production keeps decorative title runs only when they pass the rules. */
|
|
757
|
-
function passesTitleRunRules(check) {
|
|
758
|
-
try {
|
|
759
|
-
check();
|
|
760
|
-
return true;
|
|
761
|
-
} catch {
|
|
762
|
-
return false;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
705
|
function assertIdentityExtras(row, path) {
|
|
766
706
|
for (const field of ['titleIcon', 'secondaryTitleIcon']) {
|
|
767
707
|
const titleIcon = row[field];
|
|
@@ -874,12 +814,18 @@ function assertVisual(row, path) {
|
|
|
874
814
|
assertLeadingVisual(visual, `${path}.visual[${index}]`);
|
|
875
815
|
});
|
|
876
816
|
}
|
|
817
|
+
|
|
818
|
+
/** The type half of the `descriptionActionStart` contract; the range needs the row. */
|
|
819
|
+
function isDescriptionActionStart(value) {
|
|
820
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
821
|
+
}
|
|
877
822
|
function assertActivity(row, path) {
|
|
878
823
|
if (row.hideLeading !== undefined && typeof row.hideLeading !== 'boolean') fail(`${path}.hideLeading`, 'must be boolean');
|
|
879
824
|
assertText(row.title, `${path}.title`);
|
|
880
825
|
assertText(row.description, `${path}.description`);
|
|
881
826
|
if (row.presentation !== undefined && !['stacked', 'table'].includes(row.presentation)) fail(`${path}.presentation`, 'must be stacked or table');
|
|
882
827
|
if (row.descriptionActionKey !== undefined) assertKey(row.descriptionActionKey, `${path}.descriptionActionKey`);
|
|
828
|
+
if (row.descriptionActionStart !== undefined && !isDescriptionActionStart(row.descriptionActionStart)) fail(`${path}.descriptionActionStart`, 'must be a non-negative integer');
|
|
883
829
|
if ((row.amounts?.length ?? 0) > 32) fail(`${path}.amounts`, 'supports at most 32 amount lines');
|
|
884
830
|
const amountKeys = new Set();
|
|
885
831
|
row.amounts?.forEach((amount, index) => {
|
|
@@ -993,7 +939,6 @@ function assertRow(row, index, path = `rows[${index}]`) {
|
|
|
993
939
|
if (suffix.maxWidth !== undefined && (!Number.isFinite(suffix.maxWidth) || suffix.maxWidth < 0 || suffix.maxWidth > 4096)) fail(`${path}.titleSuffixes[${index}].maxWidth`, 'must be finite within 0...4096');
|
|
994
940
|
});
|
|
995
941
|
assertIdentityExtras(row, path);
|
|
996
|
-
assertIdentityTitleRuns(row, path);
|
|
997
942
|
assertText(row.subtitle, `${path}.subtitle`);
|
|
998
943
|
// OneKey patch: selector text segments truncate independently.
|
|
999
944
|
row.subtitleSegments?.forEach((segment, segmentIndex) => {
|
|
@@ -1023,6 +968,9 @@ function assertRow(row, index, path = `rows[${index}]`) {
|
|
|
1023
968
|
break;
|
|
1024
969
|
case 'activity':
|
|
1025
970
|
assertActivity(row, path);
|
|
971
|
+
// Checked on the complete row only: a patch may carry the offset
|
|
972
|
+
// without the description it points into.
|
|
973
|
+
if ((row.descriptionActionStart ?? 0) > (row.description?.length ?? 0)) fail(`${path}.descriptionActionStart`, 'must not exceed the description length');
|
|
1026
974
|
break;
|
|
1027
975
|
case 'message':
|
|
1028
976
|
if (row.presentation !== undefined && row.presentation !== 'inlineWarning') {
|
|
@@ -1287,10 +1235,10 @@ function assertSnapshotContract(snapshot) {
|
|
|
1287
1235
|
}
|
|
1288
1236
|
const COMMON_ROW_FIELDS = ['height', 'heightRounding', 'testID', 'opacity', 'backgroundColor', 'backgroundFullWidth', 'pressDisabled', 'key', 'revision', 'sectionKey', 'groupId', 'groupPosition', 'size', 'density', 'disabled', 'selected', 'accessibilityLabel', 'separator', 'type', 'style'];
|
|
1289
1237
|
const ROW_FIELDS = {
|
|
1290
|
-
identity: [...COMMON_ROW_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'presentation', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', '
|
|
1238
|
+
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'],
|
|
1291
1239
|
walletGroup: [...COMMON_ROW_FIELDS, 'parent', 'children', 'draggable'],
|
|
1292
1240
|
rail: [...COMMON_ROW_FIELDS, 'visual', 'title', 'status', 'badge', 'draggable'],
|
|
1293
|
-
activity: [...COMMON_ROW_FIELDS, 'leading', 'hideLeading', 'secondaryLeading', 'title', 'description', 'status', 'primaryAmount', 'secondaryAmount', 'amounts', 'badges', 'presentation', 'fee', 'descriptionActionKey', 'footerActions'],
|
|
1241
|
+
activity: [...COMMON_ROW_FIELDS, 'leading', 'hideLeading', 'secondaryLeading', 'title', 'description', 'status', 'primaryAmount', 'secondaryAmount', 'amounts', 'badges', 'presentation', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
|
|
1294
1242
|
message: [...COMMON_ROW_FIELDS, 'presentation', 'unread', 'leading', 'title', 'body', 'bodyLines', 'time', 'thumbnail'],
|
|
1295
1243
|
dataRow: [...COMMON_ROW_FIELDS, 'leading', 'columns', 'trailing', 'checkbox', 'index', 'badge', 'badges', 'favorite', 'favoriteActive'],
|
|
1296
1244
|
market: [...COMMON_ROW_FIELDS, 'variant', 'webTable', 'metrics', 'leadingAction', 'leading', 'title', 'subtitle', 'subtitlePrefix', 'subtitleSegments', 'price', 'priceSegments', 'change', 'badges', 'pressActionKey', 'pressInActionKey', 'longPressActionKey', 'diagnostics'],
|
|
@@ -1303,9 +1251,9 @@ const ROW_FIELDS = {
|
|
|
1303
1251
|
};
|
|
1304
1252
|
const COMMON_PATCH_FIELDS = ['height', 'heightRounding', 'opacity', 'pressDisabled', 'revision', 'disabled', 'selected', 'accessibilityLabel', 'separator', 'style'];
|
|
1305
1253
|
const PATCH_FIELDS = {
|
|
1306
|
-
identity: [...COMMON_PATCH_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', '
|
|
1254
|
+
identity: [...COMMON_PATCH_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'subtitleLines', 'badges', 'trailing'],
|
|
1307
1255
|
rail: [...COMMON_PATCH_FIELDS, 'title', 'visual', 'status', 'badge'],
|
|
1308
|
-
activity: [...COMMON_PATCH_FIELDS, 'presentation', 'leading', 'title', 'badges', 'status', 'hideLeading', 'secondaryLeading', 'description', 'primaryAmount', 'secondaryAmount', 'amounts', 'fee', 'descriptionActionKey', 'footerActions'],
|
|
1256
|
+
activity: [...COMMON_PATCH_FIELDS, 'presentation', 'leading', 'title', 'badges', 'status', 'hideLeading', 'secondaryLeading', 'description', 'primaryAmount', 'secondaryAmount', 'amounts', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
|
|
1309
1257
|
message: [...COMMON_PATCH_FIELDS, 'presentation', 'title', 'unread', 'body', 'bodyLines', 'time', 'thumbnail'],
|
|
1310
1258
|
dataRow: [...COMMON_PATCH_FIELDS, 'leading', 'badges', 'trailing', 'badge', 'columns', 'checkbox', 'index', 'favorite', 'favoriteActive'],
|
|
1311
1259
|
market: [...COMMON_PATCH_FIELDS, 'longPressActionKey', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'subtitle', 'badges', 'webTable', 'metrics', 'price', 'priceSegments', 'change', 'pressActionKey', 'pressInActionKey', 'diagnostics'],
|
|
@@ -1323,7 +1271,7 @@ function protocolObject(value, path) {
|
|
|
1323
1271
|
function protocolKey(value, path) {
|
|
1324
1272
|
if (typeof value !== 'string' || value.trim().length === 0) fail(path, 'must be a non-blank string');
|
|
1325
1273
|
}
|
|
1326
|
-
const PROTOCOL_ARRAY_FIELDS = new Set(['columns', 'titleSuffixes', '
|
|
1274
|
+
const PROTOCOL_ARRAY_FIELDS = new Set(['columns', 'titleSuffixes', 'cells', 'points', 'images', 'overlays', 'badges', 'trailing', 'footerActions', 'buttons', 'amounts', 'metrics', 'children', 'subtitleSegments', 'titleMatch', 'selectedKeys', 'segments', 'hoverSecondary', 'hoverImages', 'secondaryBadges', 'fallbackUris', 'probeOrder', 'priceSegments', 'textSegments', 'secondaryTextSegments', 'primaryTextSegments']);
|
|
1327
1275
|
const PROTOCOL_NUMBER_FIELDS = new Set(['leadingContentMaxWidthRatio', 'height', 'width', 'fontSize', 'lineHeight', 'opacity', 'offsetY', 'offsetX', 'cornerRadius', 'borderWidth', 'horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'titleBadgeGap', 'trailingGap', 'start', 'end', 'padding', 'offset', 'overscan', 'minWidth', 'flex', 'paddingStart', 'paddingEnd', 'changeWidth', 'changeHeight', 'changeCornerRadius', 'contentTrailingGap', 'subtitleTrailingPadding', 'partGap', 'contentPadding', 'contentPaddingHorizontal', 'contentPaddingTop', 'contentPaddingBottom', 'itemSpacing', 'gridColumns']);
|
|
1328
1276
|
|
|
1329
1277
|
/** Validate only shapes that renderers dereference, not display budgets. */
|
|
@@ -1394,10 +1342,7 @@ function assertRowProtocol(row, path) {
|
|
|
1394
1342
|
}
|
|
1395
1343
|
if (row.height !== undefined && row.height < 0) fail(`${path}.height`, 'must be non-negative');
|
|
1396
1344
|
if (row.type === 'identity') {
|
|
1397
|
-
if (isDevelopment())
|
|
1398
|
-
assertIdentityExtras(row, path);
|
|
1399
|
-
assertIdentityTitleRuns(row, path);
|
|
1400
|
-
}
|
|
1345
|
+
if (isDevelopment()) assertIdentityExtras(row, path);
|
|
1401
1346
|
if (row.titleSuffixes !== undefined && !Array.isArray(row.titleSuffixes)) fail(`${path}.titleSuffixes`, 'must be an array');
|
|
1402
1347
|
row.titleSuffixes?.forEach((suffix, index) => {
|
|
1403
1348
|
protocolObject(suffix, `${path}.titleSuffixes[${index}]`);
|
|
@@ -1649,8 +1594,6 @@ const NESTED_DECORATION_FIELDS = {
|
|
|
1649
1594
|
};
|
|
1650
1595
|
function sanitizeDecoration(value, field) {
|
|
1651
1596
|
if (value === undefined || value === null) return undefined;
|
|
1652
|
-
if (field === 'titleSegments') return passesTitleRunRules(() => assertTitleSegments(value, field)) ? value : undefined;
|
|
1653
|
-
if (field === 'titleLeadingIcon') return passesTitleRunRules(() => assertTitleLeadingIcon(value, field)) ? value : undefined;
|
|
1654
1597
|
if (!Array.isArray(value) && ['image', 'networkImage', 'thumbnail', 'source', 'images', 'hoverImages'].includes(field)) return sanitizeImage(value);
|
|
1655
1598
|
if (['titleImage', 'titleIcon', 'secondaryTitleIcon', 'fallbackIcon', 'cornerIcon', 'media'].includes(field) && !isRecord(value)) return undefined;
|
|
1656
1599
|
if (field === 'style' && typeof value !== 'string' && !isRecord(value)) return undefined;
|
|
@@ -1771,6 +1714,11 @@ function sanitizeRowForProduction(row) {
|
|
|
1771
1714
|
delete next[field];
|
|
1772
1715
|
continue;
|
|
1773
1716
|
}
|
|
1717
|
+
if (field === 'descriptionActionStart') {
|
|
1718
|
+
// Renderers clamp an offset past the text; anything else has no meaning.
|
|
1719
|
+
if (!isDescriptionActionStart(value)) delete next[field];
|
|
1720
|
+
continue;
|
|
1721
|
+
}
|
|
1774
1722
|
if (field === 'parent' && isRecord(value)) next[field] = sanitizeRowForProduction(value);else if (field === 'children' && Array.isArray(value)) next[field] = value.map(child => sanitizeRowForProduction(child));else {
|
|
1775
1723
|
const normalized = row.type === 'market' && field === 'metrics' ? sanitizeMarketMetrics(value) : sanitizeDecoration(value, field);
|
|
1776
1724
|
if (normalized === undefined) delete next[field];else next[field] = normalized;
|
|
@@ -2363,6 +2311,9 @@ function mergeAndValidateSingleRow(previous, patch, index) {
|
|
|
2363
2311
|
if (typeof changes.subtitle === 'string' && !('subtitleSegments' in changes) && previous.subtitleSegments !== undefined) changes.subtitleSegments = null;
|
|
2364
2312
|
if (Array.isArray(changes.subtitleSegments) && changes.subtitleSegments.length > 0 && !('subtitle' in changes) && previous.subtitle !== undefined) changes.subtitle = null;
|
|
2365
2313
|
}
|
|
2314
|
+
// The offset points into one specific description string, so a patch that
|
|
2315
|
+
// replaces the description without restating it falls back to the default.
|
|
2316
|
+
if (previous.type === 'activity' && 'description' in changes && changes.description !== previous.description && !('descriptionActionStart' in changes) && previous.descriptionActionStart !== undefined) changes.descriptionActionStart = null;
|
|
2366
2317
|
const merged = {
|
|
2367
2318
|
...previous
|
|
2368
2319
|
};
|
|
@@ -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,
|
|
@@ -465,7 +473,7 @@ export const WEB_LIST_CSS = `
|
|
|
465
473
|
.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}
|
|
466
474
|
.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}
|
|
467
475
|
.ok-native-list-icon-button.ok-native-list-tertiary-icon:focus-visible:not(:disabled){outline:2px solid var(--nl-accent)}
|
|
468
|
-
.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-
|
|
476
|
+
.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}
|
|
469
477
|
.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)}
|
|
470
478
|
.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)}
|
|
471
479
|
.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}
|
|
@@ -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)}
|
|
@@ -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
|
-
|
|
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
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
138
|
-
|
|
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
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
v.
|
|
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.
|
|
385
|
-
if (
|
|
386
|
-
v.
|
|
387
|
-
markActionAnchorSource(v.
|
|
388
|
-
v.
|
|
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.
|
|
391
|
-
delete v.
|
|
392
|
-
v.
|
|
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 = '';
|
|
@@ -11,54 +11,6 @@ function toneColor(tone, fallback) {
|
|
|
11
11
|
if (tone === 'secondary') return 'var(--nl-secondary)';
|
|
12
12
|
return fallback === 'secondary' ? 'var(--nl-secondary)' : 'var(--nl-primary)';
|
|
13
13
|
}
|
|
14
|
-
// Hidden from sight, still read: the runs themselves are hidden from
|
|
15
|
-
// assistive technology in favor of `title`.
|
|
16
|
-
const VISUALLY_HIDDEN = {
|
|
17
|
-
position: 'absolute',
|
|
18
|
-
width: '1px',
|
|
19
|
-
height: '1px',
|
|
20
|
-
overflow: 'hidden',
|
|
21
|
-
clip: 'rect(0 0 0 0)',
|
|
22
|
-
whiteSpace: 'nowrap'
|
|
23
|
-
};
|
|
24
|
-
function appendTitleRuns(document, target, row) {
|
|
25
|
-
const runs = createElement(document, 'span', 'ok-native-list-identity-title-runs');
|
|
26
|
-
runs.setAttribute('aria-hidden', 'true');
|
|
27
|
-
Object.assign(runs.style, {
|
|
28
|
-
display: 'flex',
|
|
29
|
-
flex: '1 1 auto',
|
|
30
|
-
minWidth: '0',
|
|
31
|
-
maxWidth: '100%',
|
|
32
|
-
overflow: 'hidden'
|
|
33
|
-
});
|
|
34
|
-
row.titleSegments?.forEach(segment => {
|
|
35
|
-
const run = createElement(document, 'span', 'ok-native-list-identity-title-run', segment.text);
|
|
36
|
-
// Only the shrinking run gives up width; a cap is a share of the line.
|
|
37
|
-
Object.assign(run.style, {
|
|
38
|
-
flex: segment.shrink ? '0 1 auto' : '0 0 auto',
|
|
39
|
-
minWidth: segment.shrink ? '0' : '',
|
|
40
|
-
maxWidth: segment.maxWidthRatio === undefined ? '' : `${segment.maxWidthRatio * 100}%`,
|
|
41
|
-
overflow: 'hidden',
|
|
42
|
-
textOverflow: 'ellipsis',
|
|
43
|
-
whiteSpace: 'pre'
|
|
44
|
-
});
|
|
45
|
-
if (segment.tone) run.style.color = segment.tone === 'secondary' ? 'var(--nl-secondary)' : 'var(--nl-primary)';
|
|
46
|
-
if (segment.fontWeight === 'medium') {
|
|
47
|
-
run.style.fontWeight = '500';
|
|
48
|
-
run.style.fontFamily = 'var(--nl-font-medium)';
|
|
49
|
-
} else if (segment.fontWeight === 'regular') {
|
|
50
|
-
run.style.fontWeight = '400';
|
|
51
|
-
run.style.fontFamily = 'var(--nl-font-regular)';
|
|
52
|
-
}
|
|
53
|
-
setData(run, 'tone', segment.tone);
|
|
54
|
-
runs.appendChild(run);
|
|
55
|
-
});
|
|
56
|
-
const spoken = createElement(document, 'span', 'ok-native-list-identity-title-spoken', row.title);
|
|
57
|
-
Object.assign(spoken.style, VISUALLY_HIDDEN);
|
|
58
|
-
target.replaceChildren(runs, spoken);
|
|
59
|
-
target.style.display = 'flex';
|
|
60
|
-
target.style.minWidth = '0';
|
|
61
|
-
}
|
|
62
14
|
function appendAccessories(parent, document, primitives, row, accessories) {
|
|
63
15
|
if (!accessories?.length) return;
|
|
64
16
|
const container = createElement(document, 'span', 'ok-native-list-accessories');
|
|
@@ -134,13 +86,6 @@ function createIdentityRow(document, primitives, row) {
|
|
|
134
86
|
fragment.appendChild(document.createTextNode(row.title.slice(offset)));
|
|
135
87
|
textTarget.prepend(fragment);
|
|
136
88
|
}
|
|
137
|
-
// The runs replace the plain title, except where `title` itself is
|
|
138
|
-
// highlighted or shown in the wallet sidebar.
|
|
139
|
-
const hasTitleRuns = !!row.titleSegments?.length && presentation !== 'walletSidebar' && !row.titleMatch?.length;
|
|
140
|
-
if (hasTitleRuns) {
|
|
141
|
-
const textTarget = titleElement.querySelector('[data-nl-slot="title"]') ?? titleElement;
|
|
142
|
-
appendTitleRuns(document, textTarget, row);
|
|
143
|
-
}
|
|
144
89
|
if (row.subtitleSegments?.length) {
|
|
145
90
|
column.querySelector('.ok-native-list-secondary')?.remove();
|
|
146
91
|
const segments = createElement(document, 'span', 'ok-native-list-subtitle-segments');
|
|
@@ -266,48 +211,12 @@ function createIdentityRow(document, primitives, row) {
|
|
|
266
211
|
badges.style.minWidth = '0';
|
|
267
212
|
}
|
|
268
213
|
}
|
|
269
|
-
if (hasTitleRuns) {
|
|
270
|
-
// The runs fill what the title line leaves, so a ratio is a share of
|
|
271
|
-
// that width and title accessories sit at the line's end.
|
|
272
|
-
const runs = titleElement.querySelector('.ok-native-list-identity-title-runs');
|
|
273
|
-
for (let node = runs?.parentElement; node && node !== titleElement; node = node.parentElement) {
|
|
274
|
-
node.style.display = 'flex';
|
|
275
|
-
node.style.flex = '1 1 auto';
|
|
276
|
-
node.style.minWidth = '0';
|
|
277
|
-
}
|
|
278
|
-
titleElement.style.display = 'flex';
|
|
279
|
-
titleElement.style.alignItems = 'center';
|
|
280
|
-
}
|
|
281
|
-
if (row.titleLeadingIcon && presentation !== 'walletSidebar') {
|
|
282
|
-
const descriptor = row.titleLeadingIcon;
|
|
283
|
-
if (titleElement.hasAttribute('data-nl-slot')) {
|
|
284
|
-
// Keep the glyph out of the title slot that text styles apply to.
|
|
285
|
-
const titleText = tagSlot(createElement(document, 'span', 'ok-native-list-identity-title-text'), 'title');
|
|
286
|
-
while (titleElement.firstChild) titleText.appendChild(titleElement.firstChild);
|
|
287
|
-
if (hasTitleRuns) {
|
|
288
|
-
titleText.style.display = 'flex';
|
|
289
|
-
titleText.style.minWidth = '0';
|
|
290
|
-
}
|
|
291
|
-
titleElement.removeAttribute('data-nl-slot');
|
|
292
|
-
titleElement.appendChild(titleText);
|
|
293
|
-
}
|
|
294
|
-
const icon = primitives.iconAction(descriptor.name, undefined, undefined, descriptor.tintColor);
|
|
295
|
-
icon.className = 'ok-native-list-identity-title-leading-icon';
|
|
296
|
-
if (descriptor.accessibilityLabel) icon.setAttribute('aria-label', descriptor.accessibilityLabel);else icon.setAttribute('aria-hidden', 'true');
|
|
297
|
-
titleElement.style.display = 'flex';
|
|
298
|
-
titleElement.style.alignItems = 'center';
|
|
299
|
-
// 6px to the title, whatever gap the title line already has.
|
|
300
|
-
const lineGap = Number.parseFloat(titleElement.style.gap || '0') || 0;
|
|
301
|
-
icon.style.marginInlineEnd = `${Math.max(0, 6 - lineGap)}px`;
|
|
302
|
-
titleElement.prepend(icon);
|
|
303
|
-
}
|
|
304
214
|
if (presentation === 'walletSidebar' && row.badges?.length) {
|
|
305
215
|
const badges = createElement(document, 'span', 'ok-native-list-wallet-badges');
|
|
306
216
|
row.badges.forEach(badge => badges.appendChild(createBadge(document, badge)));
|
|
307
217
|
column.appendChild(badges);
|
|
308
218
|
}
|
|
309
219
|
for (const key of ['title', 'subtitle']) {
|
|
310
|
-
if (key === 'title' && hasTitleRuns) continue;
|
|
311
220
|
const lines = row.style?.[key]?.lines ?? row[`${key}Lines`];
|
|
312
221
|
if (lines !== undefined) column.querySelectorAll(`[data-nl-slot="${key}"]`).forEach(text => {
|
|
313
222
|
applyTextLayout(text, lines === 0 ? {} : {
|
|
@@ -360,7 +269,9 @@ function applyIdentityStyle(body, row) {
|
|
|
360
269
|
}
|
|
361
270
|
if (box.trailingGap !== undefined) {
|
|
362
271
|
const gap = String(box.trailingGap) + 'px';
|
|
363
|
-
|
|
272
|
+
// The accessory row only. A value pair is one accessory whose two lines
|
|
273
|
+
// are a flex column, so a gap there would push the lines apart.
|
|
274
|
+
body.querySelectorAll('.ok-native-list-accessories').forEach(trailing => {
|
|
364
275
|
trailing.style.gap = gap;
|
|
365
276
|
});
|
|
366
277
|
}
|