@onekeyfe/react-native-native-list 6.7.0-6 → 6.7.0-61
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 -375
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +250 -9
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +50 -13
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +47 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +152 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +209 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -287
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +7 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +8 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +130 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1978 -136
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
- package/docs/ROW_TEMPLATES.md +78 -14
- package/docs/SPEC.md +1318 -16
- package/docs/STYLE_SPEC.md +18 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +237 -51
- package/ios/NativeListActivityDetailsView.swift +43 -16
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +167 -30
- package/ios/NativeListDesignAssets.swift +13 -75
- package/ios/NativeListGeneratedIcons.swift +55 -0
- package/ios/NativeListIconBinding.swift +171 -0
- package/ios/NativeListIdentityRenderer.swift +256 -39
- package/ios/NativeListLeadingVisual.swift +127 -28
- package/ios/NativeListMarketRenderer.swift +120 -31
- package/ios/NativeListMediaPlaceholderView.swift +189 -0
- package/ios/NativeListMediaPreviewSlot.swift +122 -61
- package/ios/NativeListMediaTileRenderer.swift +15 -11
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListMetricCardRenderer.swift +4 -2
- package/ios/NativeListModels.swift +42 -2
- package/ios/NativeListRendererRegistry.swift +1 -0
- package/ios/NativeListResolvedText.swift +17 -5
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +100 -4
- package/ios/NativeListTextLabel.swift +106 -0
- package/ios/RNCNativeListView.swift +1097 -60
- package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
- package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +423 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
- package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
- package/ios/tests/NativeListLifecycleTests.swift +2959 -4
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/ios/tests/NativeListMediaVisibilityTests.swift +41 -7
- package/ios/tests/NativeListSharedIconTests.swift +236 -0
- package/lib/module/NativeList.js +236 -38
- package/lib/module/NativeList.web.js +163 -45
- package/lib/module/index.js +1 -1
- package/lib/module/models.js +3 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +1263 -48
- package/lib/module/web/NativeListGeneratedIcons.js +31 -0
- package/lib/module/web/NativeListWebEngine.js +513 -275
- package/lib/module/web/templates/ActivityRowRenderer.js +41 -54
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +56 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +161 -7
- package/lib/module/web/templates/MarketTableRowRenderer.js +36 -19
- package/lib/module/web/templates/MediaTileRowRenderer.js +84 -25
- package/lib/module/web/templates/MessageRowRenderer.js +18 -2
- package/lib/module/web/templates/RowContainerStyle.js +1 -0
- package/lib/module/web/templates/RowRendererRegistry.js +3 -0
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/lib/typescript/src/NativeList.d.ts +3 -3
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
- package/lib/typescript/src/NativeList.types.d.ts +20 -2
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +134 -17
- package/lib/typescript/src/validation.d.ts +20 -0
- package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +32 -1
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/package.json +16 -10
- package/react-native-native-list.podspec +2 -6
- package/scripts/generate-icons.mjs +150 -0
- package/scripts/generate-icons.test.mjs +288 -0
- package/scripts/native-list-icons.json +260 -0
- package/src/NativeList.nitro.ts +2 -0
- package/src/NativeList.tsx +439 -91
- package/src/NativeList.types.ts +24 -2
- package/src/NativeList.web.tsx +286 -88
- package/src/index.ts +2 -0
- package/src/models.ts +272 -144
- package/src/selection.ts +1 -0
- package/src/validation.ts +3041 -146
- package/src/web/NativeListGeneratedIcons.ts +28 -0
- package/src/web/NativeListWebEngine.ts +818 -343
- package/src/web/templates/ActivityRowRenderer.ts +71 -91
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +121 -20
- package/src/web/templates/IdentityRowRenderer.ts +234 -9
- package/src/web/templates/MarketTableRowRenderer.ts +53 -33
- package/src/web/templates/MediaTileRowRenderer.ts +90 -28
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +11 -1
- package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
- package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createNamedIcon } from '@onekeyfe/react-native-image/icon/dom';
|
|
1
2
|
import type { ActivityAmount, ActivityRow, LeadingVisual } from '../../models';
|
|
2
3
|
import { createElement, tagSlot, markActionAnchorSource } from './RowElements';
|
|
3
4
|
import { RowVisualStyle, type RowPrimitives } from './RowVisual';
|
|
@@ -47,6 +48,7 @@ function bindLegacy(
|
|
|
47
48
|
}
|
|
48
49
|
const visualKey = JSON.stringify([
|
|
49
50
|
row.key,
|
|
51
|
+
row.hideLeading,
|
|
50
52
|
row.leading,
|
|
51
53
|
row.secondaryLeading,
|
|
52
54
|
]);
|
|
@@ -55,7 +57,7 @@ function bindLegacy(
|
|
|
55
57
|
primitives.dispose(node);
|
|
56
58
|
node.remove();
|
|
57
59
|
});
|
|
58
|
-
v.visuals = [row.leading, row.secondaryLeading]
|
|
60
|
+
v.visuals = (row.hideLeading ? [] : [row.leading, row.secondaryLeading])
|
|
59
61
|
.map((source) => primitives.visual(source))
|
|
60
62
|
.filter((node): node is HTMLElement => !!node);
|
|
61
63
|
v.visuals.forEach((node) => body.insertBefore(node, v.column));
|
|
@@ -166,9 +168,10 @@ type HistoryViews = {
|
|
|
166
168
|
title: HTMLElement;
|
|
167
169
|
badges: HTMLElement;
|
|
168
170
|
description: HTMLElement;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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;
|
|
172
175
|
amounts: HTMLElement;
|
|
173
176
|
amountRows: Map<string, AmountViews>;
|
|
174
177
|
fee: HTMLElement;
|
|
@@ -194,6 +197,8 @@ const isHistory = (row: ActivityRow) =>
|
|
|
194
197
|
row.presentation !== undefined || row.amounts !== undefined;
|
|
195
198
|
const ellipsis =
|
|
196
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';
|
|
197
202
|
function valueText(
|
|
198
203
|
node: HTMLElement,
|
|
199
204
|
text: string | undefined,
|
|
@@ -219,14 +224,13 @@ function createHistory(body: HTMLElement, primitives: RowPrimitives) {
|
|
|
219
224
|
const badges = node('badges');
|
|
220
225
|
const description = node('description');
|
|
221
226
|
description.dataset.nlSlot = 'description';
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
const descriptionAddress = createElement(
|
|
227
|
+
const descriptionPrefix = createElement(document, 'span');
|
|
228
|
+
const descriptionAction = createElement(
|
|
225
229
|
document,
|
|
226
230
|
'button'
|
|
227
231
|
) as HTMLButtonElement;
|
|
228
|
-
|
|
229
|
-
description.append(
|
|
232
|
+
descriptionAction.type = 'button';
|
|
233
|
+
description.append(descriptionPrefix, descriptionAction);
|
|
230
234
|
const amounts = node('amounts');
|
|
231
235
|
const fee = node('fee');
|
|
232
236
|
const feeLabel = node('fee-label');
|
|
@@ -250,9 +254,8 @@ function createHistory(body: HTMLElement, primitives: RowPrimitives) {
|
|
|
250
254
|
title,
|
|
251
255
|
badges,
|
|
252
256
|
description,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
descriptionAddress,
|
|
257
|
+
descriptionPrefix,
|
|
258
|
+
descriptionAction,
|
|
256
259
|
amounts,
|
|
257
260
|
amountRows: new Map(),
|
|
258
261
|
fee,
|
|
@@ -269,41 +272,18 @@ function createHistory(body: HTMLElement, primitives: RowPrimitives) {
|
|
|
269
272
|
histories.set(body, v);
|
|
270
273
|
return v;
|
|
271
274
|
}
|
|
272
|
-
const
|
|
273
|
-
ArrowTopOutline
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
],
|
|
285
|
-
ShieldCheckDoneOutline: [
|
|
286
|
-
'M15.914 9.75 11 14.664 8.086 11.75 9.5 10.336l1.5 1.5 3.5-3.5z',
|
|
287
|
-
'M12.325 2.055 21 5.036v6.876c0 2.807-1.149 4.83-2.813 6.404-1.615 1.53-3.745 2.66-5.712 3.722l-.475.256-.475-.256c-1.967-1.061-4.097-2.192-5.713-3.722C4.15 16.741 3 14.72 3 11.912V5.036l8.675-2.981.325-.113zM5 6.463v5.45c0 2.165.851 3.686 2.188 4.951 1.275 1.208 2.965 2.154 4.812 3.154 1.847-1 3.537-1.946 4.813-3.154C18.148 15.6 19 14.078 19 11.912v-5.45l-7-2.405z',
|
|
288
|
-
],
|
|
289
|
-
UnlockedOutline: [
|
|
290
|
-
'M13 18h-2v-5h2z',
|
|
291
|
-
'M12 2a5 5 0 0 1 5 5h-2a3 3 0 0 0-6 0v2h11v13H4V9h3V7a5 5 0 0 1 5-5M6 20h12v-9H6z',
|
|
292
|
-
],
|
|
293
|
-
Document2Outline: [
|
|
294
|
-
'M12 16H8v-2h4zm4-4H8v-2h8zm0-4H8V6h8z',
|
|
295
|
-
'M20 22H4V2h16zM6 20h12V4H6z',
|
|
296
|
-
],
|
|
297
|
-
CryptoCoinOutline: [
|
|
298
|
-
'M11 16.387a4.5 4.5 0 0 1 0-8.775V6h2v1.613a4.5 4.5 0 0 1 2.856 2.067l-1.712 1.032a2.5 2.5 0 1 0 0 2.576l1.712 1.032A4.5 4.5 0 0 1 13 16.386V18h-2z',
|
|
299
|
-
'M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10m-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0',
|
|
300
|
-
],
|
|
301
|
-
ImageSquareWavesOutline: [
|
|
302
|
-
'M14.25 7a2 2 0 1 1 0 4 2 2 0 0 1 0-4',
|
|
303
|
-
'M21 21H3V3h18zM5 16.414V19h12.586L14 15.414l-2 2-4-4zm0-2.828 3-3 4 4 2-2 5 5V5H5z',
|
|
304
|
-
],
|
|
305
|
-
DotHorOutline: ['M6 14H2v-4h4zm8 0h-4v-4h4zm8 0h-4v-4h4z'],
|
|
306
|
-
};
|
|
275
|
+
const historyIconNames = new Set([
|
|
276
|
+
'ArrowTopOutline',
|
|
277
|
+
'ArrowBottomOutline',
|
|
278
|
+
'SwitchHorOutline',
|
|
279
|
+
'CoinsOutline',
|
|
280
|
+
'ShieldCheckDoneOutline',
|
|
281
|
+
'UnlockedOutline',
|
|
282
|
+
'Document2Outline',
|
|
283
|
+
'CryptoCoinOutline',
|
|
284
|
+
'ImageSquareWavesOutline',
|
|
285
|
+
'DotHorOutline',
|
|
286
|
+
]);
|
|
307
287
|
function historyIcon(
|
|
308
288
|
node: HTMLElement,
|
|
309
289
|
source: LeadingVisual | undefined,
|
|
@@ -315,8 +295,7 @@ function historyIcon(
|
|
|
315
295
|
: source?.kind === 'token'
|
|
316
296
|
? source.fallbackIcon?.name
|
|
317
297
|
: undefined;
|
|
318
|
-
|
|
319
|
-
if (!paths) return;
|
|
298
|
+
if (!name || !historyIconNames.has(name)) return;
|
|
320
299
|
const placeholder = node.querySelector<HTMLElement>(
|
|
321
300
|
'.ok-native-list-visual-fallback'
|
|
322
301
|
);
|
|
@@ -333,24 +312,9 @@ function historyIcon(
|
|
|
333
312
|
fallback.style.color = source.tintColor;
|
|
334
313
|
else if (source && 'fallbackIcon' in source && source.fallbackIcon?.tintColor)
|
|
335
314
|
fallback.style.color = source.fallbackIcon.tintColor;
|
|
336
|
-
const svg = node.ownerDocument
|
|
337
|
-
'http://www.w3.org/2000/svg',
|
|
338
|
-
'svg'
|
|
339
|
-
);
|
|
340
|
-
svg.setAttribute('viewBox', '0 0 24 24');
|
|
315
|
+
const svg = createNamedIcon(node.ownerDocument, name);
|
|
341
316
|
svg.setAttribute('width', String(size));
|
|
342
317
|
svg.setAttribute('height', String(size));
|
|
343
|
-
svg.setAttribute('fill', 'currentColor');
|
|
344
|
-
svg.setAttribute('aria-hidden', 'true');
|
|
345
|
-
for (const d of paths) {
|
|
346
|
-
const path = node.ownerDocument.createElementNS(
|
|
347
|
-
'http://www.w3.org/2000/svg',
|
|
348
|
-
'path'
|
|
349
|
-
);
|
|
350
|
-
path.setAttribute('d', d);
|
|
351
|
-
path.setAttribute('fill-rule', 'evenodd');
|
|
352
|
-
svg.append(path);
|
|
353
|
-
}
|
|
354
318
|
fallback.replaceChildren(svg);
|
|
355
319
|
}
|
|
356
320
|
function bindHistory(
|
|
@@ -389,11 +353,12 @@ function bindHistory(
|
|
|
389
353
|
Object.assign(v.identity.style, {
|
|
390
354
|
display: 'flex',
|
|
391
355
|
alignItems: 'center',
|
|
392
|
-
gap: '12px',
|
|
356
|
+
gap: row.hideLeading ? '0' : '12px',
|
|
393
357
|
minWidth: '0',
|
|
394
358
|
flex: '1 1 0',
|
|
395
359
|
});
|
|
396
360
|
Object.assign(v.visual.style, {
|
|
361
|
+
display: row.hideLeading ? 'none' : '',
|
|
397
362
|
position: 'relative',
|
|
398
363
|
width: '40px',
|
|
399
364
|
height: '40px',
|
|
@@ -401,6 +366,7 @@ function bindHistory(
|
|
|
401
366
|
});
|
|
402
367
|
const visualKey = JSON.stringify([
|
|
403
368
|
row.key,
|
|
369
|
+
row.hideLeading,
|
|
404
370
|
row.leading,
|
|
405
371
|
row.secondaryLeading,
|
|
406
372
|
]);
|
|
@@ -410,7 +376,9 @@ function bindHistory(
|
|
|
410
376
|
);
|
|
411
377
|
v.visual.replaceChildren();
|
|
412
378
|
v.visuals = [];
|
|
413
|
-
const sources =
|
|
379
|
+
const sources = row.hideLeading
|
|
380
|
+
? []
|
|
381
|
+
: [row.leading, row.secondaryLeading].filter(Boolean);
|
|
414
382
|
sources.forEach((source) => {
|
|
415
383
|
const visual = primitives.visual(source);
|
|
416
384
|
if (!visual) return;
|
|
@@ -439,7 +407,9 @@ function bindHistory(
|
|
|
439
407
|
});
|
|
440
408
|
v.visualKey = visualKey;
|
|
441
409
|
}
|
|
442
|
-
const sources =
|
|
410
|
+
const sources = row.hideLeading
|
|
411
|
+
? []
|
|
412
|
+
: [row.leading, row.secondaryLeading].filter(Boolean);
|
|
443
413
|
v.visuals.forEach((retained, index) => {
|
|
444
414
|
const { node: visual, style, background, loaded } = retained;
|
|
445
415
|
const source = sources[index];
|
|
@@ -610,29 +580,38 @@ function bindHistory(
|
|
|
610
580
|
ellipsis +
|
|
611
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;';
|
|
612
582
|
applyTextWeight(v.description, 400);
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
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;
|
|
626
605
|
v.description.style.display = row.description ? 'flex' : 'none';
|
|
627
|
-
v.
|
|
628
|
-
if (
|
|
629
|
-
v.
|
|
630
|
-
markActionAnchorSource(v.
|
|
631
|
-
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';
|
|
632
611
|
} else {
|
|
633
|
-
delete v.
|
|
634
|
-
delete v.
|
|
635
|
-
v.
|
|
612
|
+
delete v.descriptionAction.dataset.nativeListAction;
|
|
613
|
+
delete v.descriptionAction.dataset.nativeListAnchorSource;
|
|
614
|
+
v.descriptionAction.style.cursor = 'inherit';
|
|
636
615
|
}
|
|
637
616
|
if (row.style?.description)
|
|
638
617
|
primitives.textStyle(v.description, row.style.description);
|
|
@@ -773,8 +752,9 @@ function bindHistory(
|
|
|
773
752
|
20,
|
|
774
753
|
400
|
|
775
754
|
);
|
|
776
|
-
v.actions.style.cssText =
|
|
777
|
-
|
|
755
|
+
v.actions.style.cssText = `display:flex;gap:12px;padding-left:${
|
|
756
|
+
row.hideLeading ? 0 : 52
|
|
757
|
+
}px;padding-bottom:4px;`;
|
|
778
758
|
v.actions.style.display = footer ? 'flex' : 'none';
|
|
779
759
|
const actionKeys = new Set<string>();
|
|
780
760
|
for (const [index, action] of (row.footerActions ?? []).entries()) {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ButtonGroupRow } from '../../models';
|
|
2
|
+
import { markActionAnchorSource } from './RowElements';
|
|
3
|
+
import type { RowPrimitives } from './RowVisual';
|
|
4
|
+
|
|
5
|
+
function bind(body: HTMLElement, row: ButtonGroupRow) {
|
|
6
|
+
body.replaceChildren();
|
|
7
|
+
body.className = 'ok-native-list-row ok-native-list-button-group';
|
|
8
|
+
body.removeAttribute('data-nl-container-background');
|
|
9
|
+
body.removeAttribute('data-nl-container-border');
|
|
10
|
+
row.buttons.forEach((descriptor, index) => {
|
|
11
|
+
const button = body.ownerDocument.createElement('button');
|
|
12
|
+
button.type = 'button';
|
|
13
|
+
button.className = 'ok-native-list-block-button';
|
|
14
|
+
button.dataset.nativeListAction = descriptor.actionKey;
|
|
15
|
+
button.dataset.nlButtonKey = descriptor.key;
|
|
16
|
+
button.dataset.nlSlot = `button-${index}`;
|
|
17
|
+
if (descriptor.testID) button.dataset.testid = descriptor.testID;
|
|
18
|
+
button.setAttribute(
|
|
19
|
+
'aria-label',
|
|
20
|
+
descriptor.accessibilityLabel ?? descriptor.label
|
|
21
|
+
);
|
|
22
|
+
button.disabled = Boolean(
|
|
23
|
+
row.disabled || descriptor.disabled || descriptor.loading
|
|
24
|
+
);
|
|
25
|
+
button.setAttribute('aria-busy', descriptor.loading ? 'true' : 'false');
|
|
26
|
+
markActionAnchorSource(button, 'buttonGroup', index);
|
|
27
|
+
const label = body.ownerDocument.createElement('span');
|
|
28
|
+
label.textContent = descriptor.label;
|
|
29
|
+
if (descriptor.loading) {
|
|
30
|
+
const spinner = body.ownerDocument.createElement('span');
|
|
31
|
+
spinner.className = 'ok-native-list-spinner';
|
|
32
|
+
spinner.setAttribute('role', 'progressbar');
|
|
33
|
+
button.appendChild(spinner);
|
|
34
|
+
}
|
|
35
|
+
button.appendChild(label);
|
|
36
|
+
body.appendChild(button);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function create(
|
|
41
|
+
document: Document,
|
|
42
|
+
row: ButtonGroupRow,
|
|
43
|
+
_primitives: RowPrimitives
|
|
44
|
+
) {
|
|
45
|
+
const body = document.createElement('div');
|
|
46
|
+
body.dataset.nlRenderer = 'buttonGroup';
|
|
47
|
+
bind(body, row);
|
|
48
|
+
return body;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const buttonGroupRowRenderer = {
|
|
52
|
+
key: 'buttonGroup' as const,
|
|
53
|
+
create,
|
|
54
|
+
bind,
|
|
55
|
+
recycle: (body: HTMLElement) => body.replaceChildren(),
|
|
56
|
+
measure: (_row: ButtonGroupRow, _width: number) => 64,
|
|
57
|
+
measureRendered: (body: HTMLElement) => body.scrollHeight,
|
|
58
|
+
};
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { DataRow, TextTone } from '../../models';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createElement,
|
|
4
|
+
markActionAnchorSource,
|
|
5
|
+
setData,
|
|
6
|
+
tagSlot,
|
|
7
|
+
} from './RowElements';
|
|
8
|
+
import { applyValueSegments, fontWeight } from './RowText';
|
|
3
9
|
import { RowVisualStyle, type RowPrimitives } from './RowVisual';
|
|
4
10
|
type ColumnViews = {
|
|
5
11
|
body: HTMLElement;
|
|
6
12
|
primaryLine: HTMLElement;
|
|
7
13
|
primary: HTMLElement;
|
|
14
|
+
titleIcons: HTMLElement;
|
|
8
15
|
badges: HTMLElement;
|
|
9
16
|
secondaryLine: HTMLElement;
|
|
10
17
|
secondary: HTMLElement[];
|
|
@@ -13,6 +20,7 @@ type Views = {
|
|
|
13
20
|
favorite: HTMLElement;
|
|
14
21
|
index: HTMLElement;
|
|
15
22
|
controls: HTMLElement;
|
|
23
|
+
trailing: HTMLElement;
|
|
16
24
|
columns: ColumnViews[];
|
|
17
25
|
visual?: HTMLElement;
|
|
18
26
|
visualStyle?: RowVisualStyle;
|
|
@@ -35,6 +43,22 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
35
43
|
body.removeAttribute('data-nl-container-background');
|
|
36
44
|
body.removeAttribute('data-nl-container-border');
|
|
37
45
|
const style = row.style;
|
|
46
|
+
const isTokenTable =
|
|
47
|
+
row.index === undefined &&
|
|
48
|
+
!row.favorite &&
|
|
49
|
+
!row.checkbox &&
|
|
50
|
+
row.columns.length === 4 &&
|
|
51
|
+
row.columns[0]?.key === 'asset' &&
|
|
52
|
+
row.columns[1]?.key === 'balance' &&
|
|
53
|
+
row.columns[2]?.key === 'price' &&
|
|
54
|
+
row.columns[3]?.key === 'swapSpacer';
|
|
55
|
+
if (isTokenTable) {
|
|
56
|
+
// Match the legacy four equal columns, including the icon in the first.
|
|
57
|
+
body.style.display = 'grid';
|
|
58
|
+
body.style.gridTemplateColumns = 'repeat(4, minmax(0, 1fr))';
|
|
59
|
+
body.style.gap = '0';
|
|
60
|
+
}
|
|
61
|
+
|
|
38
62
|
if (style?.horizontalPadding !== undefined)
|
|
39
63
|
body.style.paddingInline = `${style.horizontalPadding}px`;
|
|
40
64
|
if (style?.verticalPadding !== undefined)
|
|
@@ -43,6 +67,11 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
43
67
|
if (row.checkbox)
|
|
44
68
|
v.controls.appendChild(primitives.accessory(row.key, row.checkbox, 0));
|
|
45
69
|
v.controls.style.display = 'contents';
|
|
70
|
+
v.trailing.replaceChildren();
|
|
71
|
+
row.trailing?.forEach((accessory, index) =>
|
|
72
|
+
v.trailing.appendChild(primitives.accessory(row.key, accessory, index))
|
|
73
|
+
);
|
|
74
|
+
v.trailing.hidden = !row.trailing?.length;
|
|
46
75
|
v.index.style.cssText = '';
|
|
47
76
|
v.index.hidden = row.index === undefined;
|
|
48
77
|
v.index.textContent = String(row.index ?? '');
|
|
@@ -67,6 +96,9 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
67
96
|
style?.image?.height ?? 40,
|
|
68
97
|
(style?.leadingGap ?? 12) - 12
|
|
69
98
|
);
|
|
99
|
+
if (v.visual) v.visual.style.gridArea = isTokenTable ? '1 / 1' : '';
|
|
100
|
+
v.trailing.style.gridArea = isTokenTable ? '1 / 4' : '';
|
|
101
|
+
v.trailing.style.justifySelf = isTokenTable ? 'end' : '';
|
|
70
102
|
v.columns.forEach((cell, index) => {
|
|
71
103
|
const column = row.columns[index];
|
|
72
104
|
cell.body.hidden = !column;
|
|
@@ -79,6 +111,15 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
79
111
|
cell.body.hidden = false;
|
|
80
112
|
cell.body.style.flex = String(column.weight ?? 1);
|
|
81
113
|
cell.body.style.display = 'flex';
|
|
114
|
+
if (isTokenTable) {
|
|
115
|
+
cell.body.style.gridArea = `1 / ${index + 1}`;
|
|
116
|
+
if (index === 0 && v.visual) {
|
|
117
|
+
cell.body.style.marginInlineStart = `${
|
|
118
|
+
(style?.image?.width ?? 40) + (style?.leadingGap ?? 12)
|
|
119
|
+
}px`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
82
123
|
cell.body.dataset.align = column.alignment ?? 'start';
|
|
83
124
|
if (style?.lineGap !== undefined)
|
|
84
125
|
cell.body.style.rowGap = `${style.lineGap}px`;
|
|
@@ -88,7 +129,41 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
88
129
|
cell.primaryLine.style.gap = `${style.titleBadgeGap}px`;
|
|
89
130
|
cell.primary.style.cssText = '';
|
|
90
131
|
cell.primary.textContent = column.text;
|
|
132
|
+
applyValueSegments(
|
|
133
|
+
cell.primary,
|
|
134
|
+
column.textSegments,
|
|
135
|
+
style?.columns?.fontSize ?? 14,
|
|
136
|
+
style?.columns?.lineHeight ?? 20,
|
|
137
|
+
fontWeight(style?.columns?.fontWeight, 500)
|
|
138
|
+
);
|
|
91
139
|
if (style?.columns) primitives.textStyle(cell.primary, style.columns);
|
|
140
|
+
cell.titleIcons.replaceChildren();
|
|
141
|
+
if (column.titleIcon || column.secondaryTitleIcon) {
|
|
142
|
+
cell.primary.style.minWidth = '0';
|
|
143
|
+
cell.primary.style.overflow = 'hidden';
|
|
144
|
+
cell.primary.style.textOverflow = 'ellipsis';
|
|
145
|
+
cell.primary.style.whiteSpace = 'nowrap';
|
|
146
|
+
[column.titleIcon, column.secondaryTitleIcon]
|
|
147
|
+
.filter((icon): icon is NonNullable<typeof icon> => icon !== undefined)
|
|
148
|
+
.forEach((descriptor) => {
|
|
149
|
+
const icon = primitives.iconAction(
|
|
150
|
+
descriptor.name,
|
|
151
|
+
undefined,
|
|
152
|
+
undefined,
|
|
153
|
+
descriptor.tintColor
|
|
154
|
+
);
|
|
155
|
+
icon.className = 'ok-native-list-identity-title-icon';
|
|
156
|
+
if (descriptor.hoverActionKey) {
|
|
157
|
+
setData(icon, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
158
|
+
setData(icon, 'nativeListIconHelp', true);
|
|
159
|
+
markActionAnchorSource(icon, 'leadingAction');
|
|
160
|
+
}
|
|
161
|
+
if (descriptor.accessibilityLabel)
|
|
162
|
+
icon.setAttribute('aria-label', descriptor.accessibilityLabel);
|
|
163
|
+
else icon.setAttribute('aria-hidden', 'true');
|
|
164
|
+
cell.titleIcons.appendChild(icon);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
92
167
|
cell.badges.replaceChildren();
|
|
93
168
|
cell.badges.style.display = 'contents';
|
|
94
169
|
if (column.key === 'asset')
|
|
@@ -107,25 +182,34 @@ function bind(body: HTMLElement, row: DataRow, primitives: RowPrimitives) {
|
|
|
107
182
|
});
|
|
108
183
|
// Legacy Web layout: secondary leading text sits inline before the primary
|
|
109
184
|
// text; secondary text is a direct line below it, toned by secondaryTone.
|
|
110
|
-
|
|
111
|
-
? '
|
|
112
|
-
:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
185
|
+
const secondaryText = column.secondaryTextSegments?.length
|
|
186
|
+
? column.secondaryTextSegments.map((segment) => segment.text).join('')
|
|
187
|
+
: column.secondaryText;
|
|
188
|
+
cell.secondaryLine.style.display = secondaryText ? 'contents' : 'none';
|
|
189
|
+
[column.secondaryLeadingText, secondaryText].forEach((text, slot) => {
|
|
190
|
+
const label = cell.secondary[slot]!;
|
|
191
|
+
label.hidden = !text;
|
|
192
|
+
if (!text) label.remove();
|
|
193
|
+
else if (slot === 0) cell.primaryLine.insertBefore(label, cell.primary);
|
|
194
|
+
else cell.secondaryLine.appendChild(label);
|
|
195
|
+
label.style.cssText = '';
|
|
196
|
+
label.textContent = text ?? '';
|
|
197
|
+
if (slot === 1) {
|
|
198
|
+
applyValueSegments(
|
|
199
|
+
label,
|
|
200
|
+
column.secondaryTextSegments,
|
|
201
|
+
style?.columnSecondary?.fontSize ?? 12,
|
|
202
|
+
style?.columnSecondary?.lineHeight ?? 16,
|
|
203
|
+
fontWeight(style?.columnSecondary?.fontWeight, 400)
|
|
204
|
+
);
|
|
126
205
|
}
|
|
127
|
-
|
|
206
|
+
if (slot === 1)
|
|
207
|
+
label.style.color = tone(column.secondaryTone, 'secondary');
|
|
208
|
+
if (style?.columnSecondary)
|
|
209
|
+
primitives.textStyle(label, style.columnSecondary);
|
|
210
|
+
});
|
|
128
211
|
});
|
|
212
|
+
body.appendChild(v.trailing);
|
|
129
213
|
}
|
|
130
214
|
function create(document: Document, row: DataRow, primitives: RowPrimitives) {
|
|
131
215
|
const body = createElement(
|
|
@@ -140,6 +224,11 @@ function create(document: Document, row: DataRow, primitives: RowPrimitives) {
|
|
|
140
224
|
);
|
|
141
225
|
const favorite = createElement(document, 'span', 'ok-native-list-favorite');
|
|
142
226
|
const controls = createElement(document, 'span');
|
|
227
|
+
const trailing = createElement(
|
|
228
|
+
document,
|
|
229
|
+
'span',
|
|
230
|
+
'ok-native-list-accessories'
|
|
231
|
+
);
|
|
143
232
|
body.append(controls, index, favorite);
|
|
144
233
|
const columns = Array.from({ length: 4 }, () => {
|
|
145
234
|
const cell = createElement(document, 'span', 'ok-native-list-data-cell');
|
|
@@ -149,8 +238,10 @@ function create(document: Document, row: DataRow, primitives: RowPrimitives) {
|
|
|
149
238
|
'ok-native-list-data-primary'
|
|
150
239
|
);
|
|
151
240
|
const primary = tagSlot(createElement(document, 'span'), 'columns');
|
|
241
|
+
const titleIcons = createElement(document, 'span');
|
|
242
|
+
titleIcons.style.display = 'contents';
|
|
152
243
|
const badges = createElement(document, 'span');
|
|
153
|
-
primaryLine.append(primary, badges);
|
|
244
|
+
primaryLine.append(primary, titleIcons, badges);
|
|
154
245
|
const secondaryLine = createElement(
|
|
155
246
|
document,
|
|
156
247
|
'span',
|
|
@@ -169,15 +260,18 @@ function create(document: Document, row: DataRow, primitives: RowPrimitives) {
|
|
|
169
260
|
body: cell,
|
|
170
261
|
primaryLine,
|
|
171
262
|
primary,
|
|
263
|
+
titleIcons,
|
|
172
264
|
badges,
|
|
173
265
|
secondaryLine,
|
|
174
266
|
secondary,
|
|
175
267
|
};
|
|
176
268
|
});
|
|
269
|
+
body.appendChild(trailing);
|
|
177
270
|
views.set(body, {
|
|
178
271
|
favorite,
|
|
179
272
|
index,
|
|
180
273
|
controls,
|
|
274
|
+
trailing,
|
|
181
275
|
columns,
|
|
182
276
|
visualKey: '',
|
|
183
277
|
primitives,
|
|
@@ -196,6 +290,7 @@ function recycle(body: HTMLElement) {
|
|
|
196
290
|
v.visualStyle = undefined;
|
|
197
291
|
v.visualKey = '';
|
|
198
292
|
v.controls.replaceChildren();
|
|
293
|
+
v.trailing.replaceChildren();
|
|
199
294
|
}
|
|
200
295
|
export const dataRowRenderer = {
|
|
201
296
|
key: 'dataRow' as const,
|
|
@@ -204,7 +299,13 @@ export const dataRowRenderer = {
|
|
|
204
299
|
recycle,
|
|
205
300
|
// Legacy presets: table rows without secondary text are 8 units shorter.
|
|
206
301
|
measure: (row: DataRow, _width: number, layout?: string) => {
|
|
207
|
-
const secondary = row.columns.some((column) =>
|
|
302
|
+
const secondary = row.columns.some((column) =>
|
|
303
|
+
column.secondaryTextSegments?.length
|
|
304
|
+
? column.secondaryTextSegments.some(
|
|
305
|
+
(segment) => segment.text.length > 0
|
|
306
|
+
)
|
|
307
|
+
: !!column.secondaryText
|
|
308
|
+
);
|
|
208
309
|
return (secondary ? 60 : 56) + (layout === 'table' && !secondary ? -8 : 0);
|
|
209
310
|
},
|
|
210
311
|
measureRendered: (_body: HTMLElement, _row: DataRow): number | undefined =>
|