@onekeyfe/react-native-native-list 6.7.0-58 → 6.7.0-59
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/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +15 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +60 -0
- 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/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -0
- package/docs/ROW_TEMPLATES.md +4 -1
- package/docs/SPEC.md +55 -0
- package/ios/NativeListActivityDetailsView.swift +13 -5
- package/ios/NativeListResolvedText.swift +15 -4
- package/ios/NativeListTextLabel.swift +106 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +270 -0
- package/lib/module/validation.js +19 -2
- package/lib/module/web/templates/ActivityRowRenderer.js +29 -23
- package/lib/typescript/src/models.d.ts +9 -1
- package/package.json +1 -1
- package/src/models.ts +9 -0
- package/src/validation.ts +34 -0
- package/src/web/templates/ActivityRowRenderer.ts +42 -32
|
@@ -168,9 +168,10 @@ type HistoryViews = {
|
|
|
168
168
|
title: HTMLElement;
|
|
169
169
|
badges: HTMLElement;
|
|
170
170
|
description: HTMLElement;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
/** Description text before the action, or nothing. */
|
|
172
|
+
descriptionPrefix: HTMLElement;
|
|
173
|
+
/** Description text that opens the action; the whole text without one. */
|
|
174
|
+
descriptionAction: HTMLButtonElement;
|
|
174
175
|
amounts: HTMLElement;
|
|
175
176
|
amountRows: Map<string, AmountViews>;
|
|
176
177
|
fee: HTMLElement;
|
|
@@ -196,6 +197,8 @@ const isHistory = (row: ActivityRow) =>
|
|
|
196
197
|
row.presentation !== undefined || row.amounts !== undefined;
|
|
197
198
|
const ellipsis =
|
|
198
199
|
'min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;';
|
|
200
|
+
/** Width a description prefix always leaves for the action text after it. */
|
|
201
|
+
const descriptionActionReserve = '3em';
|
|
199
202
|
function valueText(
|
|
200
203
|
node: HTMLElement,
|
|
201
204
|
text: string | undefined,
|
|
@@ -221,14 +224,13 @@ function createHistory(body: HTMLElement, primitives: RowPrimitives) {
|
|
|
221
224
|
const badges = node('badges');
|
|
222
225
|
const description = node('description');
|
|
223
226
|
description.dataset.nlSlot = 'description';
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
const descriptionAddress = createElement(
|
|
227
|
+
const descriptionPrefix = createElement(document, 'span');
|
|
228
|
+
const descriptionAction = createElement(
|
|
227
229
|
document,
|
|
228
230
|
'button'
|
|
229
231
|
) as HTMLButtonElement;
|
|
230
|
-
|
|
231
|
-
description.append(
|
|
232
|
+
descriptionAction.type = 'button';
|
|
233
|
+
description.append(descriptionPrefix, descriptionAction);
|
|
232
234
|
const amounts = node('amounts');
|
|
233
235
|
const fee = node('fee');
|
|
234
236
|
const feeLabel = node('fee-label');
|
|
@@ -252,9 +254,8 @@ function createHistory(body: HTMLElement, primitives: RowPrimitives) {
|
|
|
252
254
|
title,
|
|
253
255
|
badges,
|
|
254
256
|
description,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
descriptionAddress,
|
|
257
|
+
descriptionPrefix,
|
|
258
|
+
descriptionAction,
|
|
258
259
|
amounts,
|
|
259
260
|
amountRows: new Map(),
|
|
260
261
|
fee,
|
|
@@ -579,29 +580,38 @@ function bindHistory(
|
|
|
579
580
|
ellipsis +
|
|
580
581
|
'display:flex;max-width:100%;color:var(--nl-secondary);font-family:inherit;font-size:14px;line-height:20px;font-weight:400;font-variant-numeric:tabular-nums;';
|
|
581
582
|
applyTextWeight(v.description, 400);
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
583
|
+
// The caller states where the action text starts; the string is not parsed.
|
|
584
|
+
const description = row.description ?? '';
|
|
585
|
+
const actionStart = row.descriptionActionKey
|
|
586
|
+
? Math.min(Math.max(row.descriptionActionStart ?? 0, 0), description.length)
|
|
587
|
+
: 0;
|
|
588
|
+
const actionText = description.slice(actionStart);
|
|
589
|
+
const boundAction =
|
|
590
|
+
row.descriptionActionKey && actionText ? row.descriptionActionKey : '';
|
|
591
|
+
// `pre` keeps the space a prefix ends with; a line break stays a space.
|
|
592
|
+
v.descriptionPrefix.textContent = description
|
|
593
|
+
.slice(0, actionStart)
|
|
594
|
+
.replace(/\r\n|[\r\n]/g, ' ');
|
|
595
|
+
// The prefix keeps its width and the action truncates first, as the tail of
|
|
596
|
+
// the one native label does. A prefix wider than the row is capped instead,
|
|
597
|
+
// or it would squeeze the action to nothing and leave no pointer target.
|
|
598
|
+
v.descriptionPrefix.style.cssText = `${ellipsis}flex-shrink:0;max-width:${
|
|
599
|
+
actionText ? `calc(100% - ${descriptionActionReserve})` : '100%'
|
|
600
|
+
};white-space:pre;display:${actionStart > 0 ? 'block' : 'none'}`;
|
|
601
|
+
v.descriptionAction.style.cssText = `${ellipsis}appearance:none;max-width:100%;border:0;padding:0;background:transparent;text-align:left;color:inherit;font:inherit;font-variant-numeric:inherit;display:${
|
|
602
|
+
actionText ? 'block' : 'none'
|
|
603
|
+
};`;
|
|
604
|
+
v.descriptionAction.textContent = actionText;
|
|
595
605
|
v.description.style.display = row.description ? 'flex' : 'none';
|
|
596
|
-
v.
|
|
597
|
-
if (
|
|
598
|
-
v.
|
|
599
|
-
markActionAnchorSource(v.
|
|
600
|
-
v.
|
|
606
|
+
v.descriptionAction.tabIndex = boundAction ? 0 : -1;
|
|
607
|
+
if (boundAction) {
|
|
608
|
+
v.descriptionAction.dataset.nativeListAction = boundAction;
|
|
609
|
+
markActionAnchorSource(v.descriptionAction, 'description');
|
|
610
|
+
v.descriptionAction.style.cursor = 'pointer';
|
|
601
611
|
} else {
|
|
602
|
-
delete v.
|
|
603
|
-
delete v.
|
|
604
|
-
v.
|
|
612
|
+
delete v.descriptionAction.dataset.nativeListAction;
|
|
613
|
+
delete v.descriptionAction.dataset.nativeListAnchorSource;
|
|
614
|
+
v.descriptionAction.style.cursor = 'inherit';
|
|
605
615
|
}
|
|
606
616
|
if (row.style?.description)
|
|
607
617
|
primitives.textStyle(v.description, row.style.description);
|