@onekeyfe/react-native-native-list 6.7.0-alpha.475 → 6.8.0-3
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 +194 -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 +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 +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/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,64 +702,16 @@ 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
705
|
|
|
756
|
-
|
|
757
|
-
function
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
|
|
706
|
+
// A passive label: its text and two caller colors, with no action or style slot.
|
|
707
|
+
function assertWebLeadingBadge(value, path) {
|
|
708
|
+
if (value === undefined) return;
|
|
709
|
+
const badge = protocolObject(value, path);
|
|
710
|
+
assertUnknownKeys(badge, ['text', 'textColor', 'backgroundColor'], path, 'web leading badge key');
|
|
711
|
+
if (typeof badge.text !== 'string' || !badge.text.trim() || badge.text.length > MAX_TEXT_LENGTH) fail(`${path}.text`, 'must be non-blank within the text limit');
|
|
712
|
+
for (const field of ['textColor', 'backgroundColor']) {
|
|
713
|
+
const color = badge[field];
|
|
714
|
+
if (typeof color !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(color)) fail(`${path}.${field}`, 'must be #RRGGBB or #RRGGBBAA');
|
|
763
715
|
}
|
|
764
716
|
}
|
|
765
717
|
function assertIdentityExtras(row, path) {
|
|
@@ -874,12 +826,18 @@ function assertVisual(row, path) {
|
|
|
874
826
|
assertLeadingVisual(visual, `${path}.visual[${index}]`);
|
|
875
827
|
});
|
|
876
828
|
}
|
|
829
|
+
|
|
830
|
+
/** The type half of the `descriptionActionStart` contract; the range needs the row. */
|
|
831
|
+
function isDescriptionActionStart(value) {
|
|
832
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
833
|
+
}
|
|
877
834
|
function assertActivity(row, path) {
|
|
878
835
|
if (row.hideLeading !== undefined && typeof row.hideLeading !== 'boolean') fail(`${path}.hideLeading`, 'must be boolean');
|
|
879
836
|
assertText(row.title, `${path}.title`);
|
|
880
837
|
assertText(row.description, `${path}.description`);
|
|
881
838
|
if (row.presentation !== undefined && !['stacked', 'table'].includes(row.presentation)) fail(`${path}.presentation`, 'must be stacked or table');
|
|
882
839
|
if (row.descriptionActionKey !== undefined) assertKey(row.descriptionActionKey, `${path}.descriptionActionKey`);
|
|
840
|
+
if (row.descriptionActionStart !== undefined && !isDescriptionActionStart(row.descriptionActionStart)) fail(`${path}.descriptionActionStart`, 'must be a non-negative integer');
|
|
883
841
|
if ((row.amounts?.length ?? 0) > 32) fail(`${path}.amounts`, 'supports at most 32 amount lines');
|
|
884
842
|
const amountKeys = new Set();
|
|
885
843
|
row.amounts?.forEach((amount, index) => {
|
|
@@ -993,7 +951,6 @@ function assertRow(row, index, path = `rows[${index}]`) {
|
|
|
993
951
|
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
952
|
});
|
|
995
953
|
assertIdentityExtras(row, path);
|
|
996
|
-
assertIdentityTitleRuns(row, path);
|
|
997
954
|
assertText(row.subtitle, `${path}.subtitle`);
|
|
998
955
|
// OneKey patch: selector text segments truncate independently.
|
|
999
956
|
row.subtitleSegments?.forEach((segment, segmentIndex) => {
|
|
@@ -1023,6 +980,9 @@ function assertRow(row, index, path = `rows[${index}]`) {
|
|
|
1023
980
|
break;
|
|
1024
981
|
case 'activity':
|
|
1025
982
|
assertActivity(row, path);
|
|
983
|
+
// Checked on the complete row only: a patch may carry the offset
|
|
984
|
+
// without the description it points into.
|
|
985
|
+
if ((row.descriptionActionStart ?? 0) > (row.description?.length ?? 0)) fail(`${path}.descriptionActionStart`, 'must not exceed the description length');
|
|
1026
986
|
break;
|
|
1027
987
|
case 'message':
|
|
1028
988
|
if (row.presentation !== undefined && row.presentation !== 'inlineWarning') {
|
|
@@ -1043,6 +1003,7 @@ function assertRow(row, index, path = `rows[${index}]`) {
|
|
|
1043
1003
|
assertKey(column.key, `${path}.columns[${columnIndex}].key`);
|
|
1044
1004
|
assertText(column.text, `${path}.columns[${columnIndex}].text`);
|
|
1045
1005
|
assertIdentityExtras(column, `${path}.columns[${columnIndex}]`);
|
|
1006
|
+
assertWebLeadingBadge(column.webLeadingBadge, `${path}.columns[${columnIndex}].webLeadingBadge`);
|
|
1046
1007
|
for (const field of ['textSegments', 'secondaryTextSegments']) {
|
|
1047
1008
|
column[field]?.forEach((segment, segmentIndex) => {
|
|
1048
1009
|
assertText(segment.text, `${path}.columns[${columnIndex}].${field}[${segmentIndex}].text`);
|
|
@@ -1287,10 +1248,10 @@ function assertSnapshotContract(snapshot) {
|
|
|
1287
1248
|
}
|
|
1288
1249
|
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
1250
|
const ROW_FIELDS = {
|
|
1290
|
-
identity: [...COMMON_ROW_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'presentation', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', '
|
|
1251
|
+
identity: [...COMMON_ROW_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'presentation', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'titleLines', 'subtitleLines', 'badges', 'trailing', 'draggable'],
|
|
1291
1252
|
walletGroup: [...COMMON_ROW_FIELDS, 'parent', 'children', 'draggable'],
|
|
1292
1253
|
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'],
|
|
1254
|
+
activity: [...COMMON_ROW_FIELDS, 'leading', 'hideLeading', 'secondaryLeading', 'title', 'description', 'status', 'primaryAmount', 'secondaryAmount', 'amounts', 'badges', 'presentation', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
|
|
1294
1255
|
message: [...COMMON_ROW_FIELDS, 'presentation', 'unread', 'leading', 'title', 'body', 'bodyLines', 'time', 'thumbnail'],
|
|
1295
1256
|
dataRow: [...COMMON_ROW_FIELDS, 'leading', 'columns', 'trailing', 'checkbox', 'index', 'badge', 'badges', 'favorite', 'favoriteActive'],
|
|
1296
1257
|
market: [...COMMON_ROW_FIELDS, 'variant', 'webTable', 'metrics', 'leadingAction', 'leading', 'title', 'subtitle', 'subtitlePrefix', 'subtitleSegments', 'price', 'priceSegments', 'change', 'badges', 'pressActionKey', 'pressInActionKey', 'longPressActionKey', 'diagnostics'],
|
|
@@ -1303,9 +1264,9 @@ const ROW_FIELDS = {
|
|
|
1303
1264
|
};
|
|
1304
1265
|
const COMMON_PATCH_FIELDS = ['height', 'heightRounding', 'opacity', 'pressDisabled', 'revision', 'disabled', 'selected', 'accessibilityLabel', 'separator', 'style'];
|
|
1305
1266
|
const PATCH_FIELDS = {
|
|
1306
|
-
identity: [...COMMON_PATCH_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', '
|
|
1267
|
+
identity: [...COMMON_PATCH_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'subtitleLines', 'badges', 'trailing'],
|
|
1307
1268
|
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'],
|
|
1269
|
+
activity: [...COMMON_PATCH_FIELDS, 'presentation', 'leading', 'title', 'badges', 'status', 'hideLeading', 'secondaryLeading', 'description', 'primaryAmount', 'secondaryAmount', 'amounts', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
|
|
1309
1270
|
message: [...COMMON_PATCH_FIELDS, 'presentation', 'title', 'unread', 'body', 'bodyLines', 'time', 'thumbnail'],
|
|
1310
1271
|
dataRow: [...COMMON_PATCH_FIELDS, 'leading', 'badges', 'trailing', 'badge', 'columns', 'checkbox', 'index', 'favorite', 'favoriteActive'],
|
|
1311
1272
|
market: [...COMMON_PATCH_FIELDS, 'longPressActionKey', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'subtitle', 'badges', 'webTable', 'metrics', 'price', 'priceSegments', 'change', 'pressActionKey', 'pressInActionKey', 'diagnostics'],
|
|
@@ -1323,7 +1284,7 @@ function protocolObject(value, path) {
|
|
|
1323
1284
|
function protocolKey(value, path) {
|
|
1324
1285
|
if (typeof value !== 'string' || value.trim().length === 0) fail(path, 'must be a non-blank string');
|
|
1325
1286
|
}
|
|
1326
|
-
const PROTOCOL_ARRAY_FIELDS = new Set(['columns', 'titleSuffixes', '
|
|
1287
|
+
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
1288
|
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
1289
|
|
|
1329
1290
|
/** Validate only shapes that renderers dereference, not display budgets. */
|
|
@@ -1394,10 +1355,7 @@ function assertRowProtocol(row, path) {
|
|
|
1394
1355
|
}
|
|
1395
1356
|
if (row.height !== undefined && row.height < 0) fail(`${path}.height`, 'must be non-negative');
|
|
1396
1357
|
if (row.type === 'identity') {
|
|
1397
|
-
if (isDevelopment())
|
|
1398
|
-
assertIdentityExtras(row, path);
|
|
1399
|
-
assertIdentityTitleRuns(row, path);
|
|
1400
|
-
}
|
|
1358
|
+
if (isDevelopment()) assertIdentityExtras(row, path);
|
|
1401
1359
|
if (row.titleSuffixes !== undefined && !Array.isArray(row.titleSuffixes)) fail(`${path}.titleSuffixes`, 'must be an array');
|
|
1402
1360
|
row.titleSuffixes?.forEach((suffix, index) => {
|
|
1403
1361
|
protocolObject(suffix, `${path}.titleSuffixes[${index}]`);
|
|
@@ -1433,7 +1391,10 @@ function assertRowProtocol(row, path) {
|
|
|
1433
1391
|
row.columns.forEach((column, index) => {
|
|
1434
1392
|
const columnPath = `${path}.columns[${index}]`;
|
|
1435
1393
|
protocolObject(column, columnPath);
|
|
1436
|
-
if (isDevelopment())
|
|
1394
|
+
if (isDevelopment()) {
|
|
1395
|
+
assertIdentityExtras(column, columnPath);
|
|
1396
|
+
assertWebLeadingBadge(column.webLeadingBadge, `${columnPath}.webLeadingBadge`);
|
|
1397
|
+
}
|
|
1437
1398
|
});
|
|
1438
1399
|
if (isDevelopment()) assertTrailingAccessories(row.trailing, `${path}.trailing`);
|
|
1439
1400
|
}
|
|
@@ -1640,7 +1601,7 @@ function sanitizeImage(value) {
|
|
|
1640
1601
|
}
|
|
1641
1602
|
const NESTED_DECORATION_FIELDS = {
|
|
1642
1603
|
webTable: ['columns', 'cells', 'testID', 'draggable', 'contextMenuActionKey'],
|
|
1643
|
-
columns: ['key', 'text', 'textSegments', 'titleIcon', 'secondaryTitleIcon', 'secondaryLeadingText', 'secondaryText', 'secondaryTextSegments', 'weight', 'alignment', 'tone', 'secondaryTone', 'width', 'minWidth', 'flex', 'paddingStart', 'paddingEnd'],
|
|
1604
|
+
columns: ['key', 'text', 'textSegments', 'titleIcon', 'secondaryTitleIcon', 'webLeadingBadge', 'secondaryLeadingText', 'secondaryText', 'secondaryTextSegments', 'weight', 'alignment', 'tone', 'secondaryTone', 'width', 'minWidth', 'flex', 'paddingStart', 'paddingEnd'],
|
|
1644
1605
|
cells: ['key', 'kind', 'active', 'disabled', 'testID', 'hoverActionKey', 'actionKey', 'accessibilityLabel', 'leading', 'title', 'secondary', 'lineGap', 'secondaryBadges', 'hoverImages', 'hoverSecondary', 'hoverActionLabel', 'badges', 'primary', 'partGap', 'points', 'width', 'height', 'strokeColor', 'fillColor'],
|
|
1645
1606
|
badges: ['key', 'text', 'tone', 'iconName', 'icon', 'textColor', 'backgroundColor', 'actionKey', 'accessibilityLabel', 'style'],
|
|
1646
1607
|
overlays: ['position', 'size', 'width', 'height', 'padding', 'offset', 'offsetX', 'offsetY', 'image', 'fallbackIcon', 'name', 'text', 'fontWeight', 'tintColor', 'backgroundColor'],
|
|
@@ -1649,8 +1610,21 @@ const NESTED_DECORATION_FIELDS = {
|
|
|
1649
1610
|
};
|
|
1650
1611
|
function sanitizeDecoration(value, field) {
|
|
1651
1612
|
if (value === undefined || value === null) return undefined;
|
|
1652
|
-
|
|
1653
|
-
|
|
1613
|
+
// All or nothing: a badge without valid text and both colors is dropped, and
|
|
1614
|
+
// only its three declared fields are kept.
|
|
1615
|
+
if (field === 'webLeadingBadge') {
|
|
1616
|
+
if (!isRecord(value) || typeof value.text !== 'string' || !value.text.trim() || value.text.length > MAX_TEXT_LENGTH) return undefined;
|
|
1617
|
+
const {
|
|
1618
|
+
textColor,
|
|
1619
|
+
backgroundColor
|
|
1620
|
+
} = value;
|
|
1621
|
+
if (typeof textColor !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(textColor) || typeof backgroundColor !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(backgroundColor)) return undefined;
|
|
1622
|
+
return {
|
|
1623
|
+
text: value.text,
|
|
1624
|
+
textColor,
|
|
1625
|
+
backgroundColor
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1654
1628
|
if (!Array.isArray(value) && ['image', 'networkImage', 'thumbnail', 'source', 'images', 'hoverImages'].includes(field)) return sanitizeImage(value);
|
|
1655
1629
|
if (['titleImage', 'titleIcon', 'secondaryTitleIcon', 'fallbackIcon', 'cornerIcon', 'media'].includes(field) && !isRecord(value)) return undefined;
|
|
1656
1630
|
if (field === 'style' && typeof value !== 'string' && !isRecord(value)) return undefined;
|
|
@@ -1771,6 +1745,11 @@ function sanitizeRowForProduction(row) {
|
|
|
1771
1745
|
delete next[field];
|
|
1772
1746
|
continue;
|
|
1773
1747
|
}
|
|
1748
|
+
if (field === 'descriptionActionStart') {
|
|
1749
|
+
// Renderers clamp an offset past the text; anything else has no meaning.
|
|
1750
|
+
if (!isDescriptionActionStart(value)) delete next[field];
|
|
1751
|
+
continue;
|
|
1752
|
+
}
|
|
1774
1753
|
if (field === 'parent' && isRecord(value)) next[field] = sanitizeRowForProduction(value);else if (field === 'children' && Array.isArray(value)) next[field] = value.map(child => sanitizeRowForProduction(child));else {
|
|
1775
1754
|
const normalized = row.type === 'market' && field === 'metrics' ? sanitizeMarketMetrics(value) : sanitizeDecoration(value, field);
|
|
1776
1755
|
if (normalized === undefined) delete next[field];else next[field] = normalized;
|
|
@@ -2021,6 +2000,7 @@ function assertPatchChanges(patch, index) {
|
|
|
2021
2000
|
assertKey(column.key, `${path}.columns[${columnIndex}].key`);
|
|
2022
2001
|
assertText(column.text, `${path}.columns[${columnIndex}].text`);
|
|
2023
2002
|
assertIdentityExtras(column, `${path}.columns[${columnIndex}]`);
|
|
2003
|
+
assertWebLeadingBadge(column.webLeadingBadge, `${path}.columns[${columnIndex}].webLeadingBadge`);
|
|
2024
2004
|
for (const field of ['textSegments', 'secondaryTextSegments']) {
|
|
2025
2005
|
column[field]?.forEach((segment, segmentIndex) => {
|
|
2026
2006
|
assertText(segment.text, `${path}.columns[${columnIndex}].${field}[${segmentIndex}].text`);
|
|
@@ -2363,6 +2343,9 @@ function mergeAndValidateSingleRow(previous, patch, index) {
|
|
|
2363
2343
|
if (typeof changes.subtitle === 'string' && !('subtitleSegments' in changes) && previous.subtitleSegments !== undefined) changes.subtitleSegments = null;
|
|
2364
2344
|
if (Array.isArray(changes.subtitleSegments) && changes.subtitleSegments.length > 0 && !('subtitle' in changes) && previous.subtitle !== undefined) changes.subtitle = null;
|
|
2365
2345
|
}
|
|
2346
|
+
// The offset points into one specific description string, so a patch that
|
|
2347
|
+
// replaces the description without restating it falls back to the default.
|
|
2348
|
+
if (previous.type === 'activity' && 'description' in changes && changes.description !== previous.description && !('descriptionActionStart' in changes) && previous.descriptionActionStart !== undefined) changes.descriptionActionStart = null;
|
|
2366
2349
|
const merged = {
|
|
2367
2350
|
...previous
|
|
2368
2351
|
};
|
|
@@ -20,6 +20,7 @@ export const nativeListGeneratedIcons = {
|
|
|
20
20
|
GasSolid: 'GasSolid',
|
|
21
21
|
GlobusOutline: 'GlobusOutline',
|
|
22
22
|
GoogleIllus: 'GoogleIllus',
|
|
23
|
+
InfoCircleOutline: 'InfoCircleOutline',
|
|
23
24
|
LockSolid: 'LockSolid',
|
|
24
25
|
PencilOutline: 'PencilOutline',
|
|
25
26
|
PlusLargeOutline: 'PlusLargeOutline',
|
|
@@ -183,6 +183,14 @@ function effectiveRows(snapshot) {
|
|
|
183
183
|
if (snapshot.rows.length > 0) return snapshot.rows;
|
|
184
184
|
return snapshot.emptyState ? [snapshot.emptyState] : [];
|
|
185
185
|
}
|
|
186
|
+
function isDarkBackground(color) {
|
|
187
|
+
const rgb = color ? /^#([0-9a-f]{6})/i.exec(color)?.[1] : undefined;
|
|
188
|
+
if (!rgb) return false;
|
|
189
|
+
const red = Number.parseInt(rgb.slice(0, 2), 16);
|
|
190
|
+
const green = Number.parseInt(rgb.slice(2, 4), 16);
|
|
191
|
+
const blue = Number.parseInt(rgb.slice(4, 6), 16);
|
|
192
|
+
return red * 299 + green * 587 + blue * 114 < 128_000;
|
|
193
|
+
}
|
|
186
194
|
function resolvedTheme(snapshot) {
|
|
187
195
|
return {
|
|
188
196
|
...defaultTheme,
|
|
@@ -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 = '';
|
|
@@ -60,6 +76,40 @@ function bind(body, row, primitives) {
|
|
|
60
76
|
cell.primary.textContent = column.text;
|
|
61
77
|
applyValueSegments(cell.primary, column.textSegments, style?.columns?.fontSize ?? 14, style?.columns?.lineHeight ?? 20, fontWeight(style?.columns?.fontWeight, 500));
|
|
62
78
|
if (style?.columns) primitives.textStyle(cell.primary, style.columns);
|
|
79
|
+
const leadingBadge = column.webLeadingBadge;
|
|
80
|
+
cell.leadingBadge.hidden = !leadingBadge;
|
|
81
|
+
cell.leadingBadge.style.cssText = '';
|
|
82
|
+
cell.leadingBadge.textContent = leadingBadge?.text ?? '';
|
|
83
|
+
if (leadingBadge) {
|
|
84
|
+
// The line spans the column so the badge cap is a share of the column
|
|
85
|
+
// rather than of the line's own content; justifyContent then carries
|
|
86
|
+
// the column alignment the shrink-to-fit line got from its cell.
|
|
87
|
+
cell.primaryLine.style.alignSelf = 'stretch';
|
|
88
|
+
cell.primaryLine.style.justifyContent = column.alignment === 'end' ? 'flex-end' : column.alignment === 'center' ? 'center' : 'flex-start';
|
|
89
|
+
cell.primaryLine.style.gap = '8px';
|
|
90
|
+
// A long label truncates at half the column; the primary text keeps the
|
|
91
|
+
// rest and truncates after it, so neither can leave the column.
|
|
92
|
+
cell.leadingBadge.style.display = 'block';
|
|
93
|
+
cell.leadingBadge.style.boxSizing = 'border-box';
|
|
94
|
+
cell.leadingBadge.style.flexShrink = '0';
|
|
95
|
+
cell.leadingBadge.style.maxWidth = '50%';
|
|
96
|
+
cell.leadingBadge.style.overflow = 'hidden';
|
|
97
|
+
cell.leadingBadge.style.textOverflow = 'ellipsis';
|
|
98
|
+
cell.leadingBadge.style.whiteSpace = 'nowrap';
|
|
99
|
+
cell.leadingBadge.style.padding = '2px 6px';
|
|
100
|
+
cell.leadingBadge.style.borderRadius = '4px';
|
|
101
|
+
cell.leadingBadge.style.fontSize = '12px';
|
|
102
|
+
cell.leadingBadge.style.lineHeight = '16px';
|
|
103
|
+
cell.leadingBadge.style.fontWeight = '400';
|
|
104
|
+
cell.leadingBadge.style.fontFamily = 'var(--nl-font-regular)';
|
|
105
|
+
cell.leadingBadge.style.color = leadingBadge.textColor;
|
|
106
|
+
cell.leadingBadge.style.backgroundColor = leadingBadge.backgroundColor;
|
|
107
|
+
cell.leadingBadge.style.pointerEvents = 'none';
|
|
108
|
+
cell.primary.style.minWidth = '0';
|
|
109
|
+
cell.primary.style.overflow = 'hidden';
|
|
110
|
+
cell.primary.style.textOverflow = 'ellipsis';
|
|
111
|
+
cell.primary.style.whiteSpace = 'nowrap';
|
|
112
|
+
}
|
|
63
113
|
cell.titleIcons.replaceChildren();
|
|
64
114
|
if (column.titleIcon || column.secondaryTitleIcon) {
|
|
65
115
|
cell.primary.style.minWidth = '0';
|
|
@@ -118,10 +168,12 @@ function create(document, row, primitives) {
|
|
|
118
168
|
const cell = createElement(document, 'span', 'ok-native-list-data-cell');
|
|
119
169
|
const primaryLine = createElement(document, 'span', 'ok-native-list-data-primary');
|
|
120
170
|
const primary = tagSlot(createElement(document, 'span'), 'columns');
|
|
171
|
+
const leadingBadge = createElement(document, 'span', 'ok-native-list-data-leading-badge');
|
|
172
|
+
leadingBadge.hidden = true;
|
|
121
173
|
const titleIcons = createElement(document, 'span');
|
|
122
174
|
titleIcons.style.display = 'contents';
|
|
123
175
|
const badges = createElement(document, 'span');
|
|
124
|
-
primaryLine.append(primary, titleIcons, badges);
|
|
176
|
+
primaryLine.append(leadingBadge, primary, titleIcons, badges);
|
|
125
177
|
const secondaryLine = createElement(document, 'span', 'ok-native-list-data-secondary-line');
|
|
126
178
|
const secondary = Array.from({
|
|
127
179
|
length: 2
|
|
@@ -133,6 +185,7 @@ function create(document, row, primitives) {
|
|
|
133
185
|
body: cell,
|
|
134
186
|
primaryLine,
|
|
135
187
|
primary,
|
|
188
|
+
leadingBadge,
|
|
136
189
|
titleIcons,
|
|
137
190
|
badges,
|
|
138
191
|
secondaryLine,
|