@onekeyfe/react-native-native-list 6.7.0-3 → 6.7.0-31
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 +4 -0
- 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 +35 -7
- 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/NativeListMediaPreviewSlot.kt +66 -31
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +1 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -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 +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -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 +70 -11
- package/docs/SPEC.md +1170 -13
- package/docs/STYLE_SPEC.md +11 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +237 -51
- package/ios/NativeListActivityDetailsView.swift +30 -11
- 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/NativeListMediaPreviewSlot.swift +122 -61
- package/ios/NativeListMediaTileRenderer.swift +7 -3
- 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 +2 -1
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +100 -4
- package/ios/RNCNativeListView.swift +1052 -58
- package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
- package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
- package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
- package/ios/tests/NativeListLifecycleTests.swift +2798 -3
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/ios/tests/NativeListMediaVisibilityTests.swift +26 -1
- package/ios/tests/NativeListSharedIconTests.swift +236 -0
- package/lib/module/NativeList.js +221 -36
- package/lib/module/NativeList.web.js +167 -46
- 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 +1246 -48
- package/lib/module/web/NativeListGeneratedIcons.js +31 -0
- package/lib/module/web/NativeListWebEngine.js +513 -274
- package/lib/module/web/templates/ActivityRowRenderer.js +120 -87
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +40 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +158 -6
- package/lib/module/web/templates/MarketTableRowRenderer.js +37 -19
- package/lib/module/web/templates/MediaTileRowRenderer.js +4 -14
- 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 +126 -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 +416 -89
- package/src/NativeList.types.ts +24 -2
- package/src/NativeList.web.tsx +295 -89
- package/src/index.ts +2 -0
- package/src/models.ts +263 -144
- package/src/selection.ts +1 -0
- package/src/validation.ts +3013 -152
- package/src/web/NativeListGeneratedIcons.ts +28 -0
- package/src/web/NativeListWebEngine.ts +816 -343
- package/src/web/templates/ActivityRowRenderer.ts +178 -141
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +231 -6
- package/src/web/templates/MarketTableRowRenderer.ts +56 -33
- package/src/web/templates/MediaTileRowRenderer.ts +4 -17
- 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
|
@@ -226,6 +226,171 @@ function createIdentityRow(
|
|
|
226
226
|
});
|
|
227
227
|
column.insertBefore(segments, titleElement.nextSibling);
|
|
228
228
|
}
|
|
229
|
+
if (row.titleIcon || row.secondaryTitleIcon || row.titleImage) {
|
|
230
|
+
const badgeLine = titleElement.querySelector<HTMLElement>(
|
|
231
|
+
':scope > .ok-native-list-badges'
|
|
232
|
+
);
|
|
233
|
+
const titleText = createElement(
|
|
234
|
+
document,
|
|
235
|
+
'span',
|
|
236
|
+
'ok-native-list-identity-title-text'
|
|
237
|
+
);
|
|
238
|
+
while (titleElement.firstChild && titleElement.firstChild !== badgeLine)
|
|
239
|
+
titleText.appendChild(titleElement.firstChild);
|
|
240
|
+
titleElement.prepend(titleText);
|
|
241
|
+
// The title slot tag moves with the text. `applyTextLayout` writes the
|
|
242
|
+
// single-line clamp (`display: block`, nowrap, ellipsis) onto the slot
|
|
243
|
+
// element; left on this container it would undo the flex row below and
|
|
244
|
+
// leave the inline-flex glyph baseline-aligned above the title (OK-66402).
|
|
245
|
+
if (titleElement.hasAttribute('data-nl-slot')) {
|
|
246
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
247
|
+
tagSlot(titleText, 'title');
|
|
248
|
+
}
|
|
249
|
+
const icons = [row.titleIcon, row.secondaryTitleIcon]
|
|
250
|
+
.filter((icon): icon is NonNullable<typeof icon> => icon !== undefined)
|
|
251
|
+
.map((descriptor) => {
|
|
252
|
+
const icon = primitives.iconAction(
|
|
253
|
+
descriptor.name,
|
|
254
|
+
undefined,
|
|
255
|
+
undefined,
|
|
256
|
+
descriptor.tintColor
|
|
257
|
+
);
|
|
258
|
+
icon.className = 'ok-native-list-identity-title-icon';
|
|
259
|
+
if (descriptor.hoverActionKey) {
|
|
260
|
+
setData(icon, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
261
|
+
setData(icon, 'nativeListIconHelp', true);
|
|
262
|
+
markActionAnchorSource(icon, 'leadingAction');
|
|
263
|
+
}
|
|
264
|
+
if (descriptor.accessibilityLabel)
|
|
265
|
+
icon.setAttribute('aria-label', descriptor.accessibilityLabel);
|
|
266
|
+
else icon.setAttribute('aria-hidden', 'true');
|
|
267
|
+
return icon;
|
|
268
|
+
});
|
|
269
|
+
if (row.titleImage) {
|
|
270
|
+
const descriptor = row.titleImage;
|
|
271
|
+
const holder = createElement(
|
|
272
|
+
document,
|
|
273
|
+
'span',
|
|
274
|
+
'ok-native-list-identity-title-image'
|
|
275
|
+
);
|
|
276
|
+
Object.assign(holder.style, {
|
|
277
|
+
flex: `0 0 ${descriptor.image.width}px`,
|
|
278
|
+
width: `${descriptor.image.width}px`,
|
|
279
|
+
height: `${descriptor.image.height}px`,
|
|
280
|
+
borderRadius: '50%',
|
|
281
|
+
overflow: 'hidden',
|
|
282
|
+
});
|
|
283
|
+
const image = primitives.thumbnail(descriptor.image);
|
|
284
|
+
if (image) {
|
|
285
|
+
Object.assign(image.style, {
|
|
286
|
+
width: '100%',
|
|
287
|
+
height: '100%',
|
|
288
|
+
borderRadius: 'inherit',
|
|
289
|
+
objectFit:
|
|
290
|
+
descriptor.image.contentFit === 'center'
|
|
291
|
+
? 'none'
|
|
292
|
+
: descriptor.image.contentFit ?? 'cover',
|
|
293
|
+
});
|
|
294
|
+
image.setAttribute('alt', '');
|
|
295
|
+
holder.appendChild(image);
|
|
296
|
+
}
|
|
297
|
+
if (descriptor.hoverActionKey) {
|
|
298
|
+
setData(holder, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
299
|
+
setData(holder, 'nativeListIconHelp', true);
|
|
300
|
+
markActionAnchorSource(holder, 'leadingAction');
|
|
301
|
+
}
|
|
302
|
+
if (descriptor.accessibilityLabel) {
|
|
303
|
+
holder.setAttribute('role', 'img');
|
|
304
|
+
holder.setAttribute('aria-label', descriptor.accessibilityLabel);
|
|
305
|
+
} else holder.setAttribute('aria-hidden', 'true');
|
|
306
|
+
icons.push(holder);
|
|
307
|
+
}
|
|
308
|
+
titleText.after(...icons);
|
|
309
|
+
titleElement.style.display = 'flex';
|
|
310
|
+
titleElement.style.alignItems = 'center';
|
|
311
|
+
titleElement.style.gap = '4px';
|
|
312
|
+
}
|
|
313
|
+
if (row.titleSuffixes?.length) {
|
|
314
|
+
const badges = titleElement.querySelector(
|
|
315
|
+
':scope > .ok-native-list-badges'
|
|
316
|
+
);
|
|
317
|
+
let titleText = titleElement.querySelector<HTMLElement>(
|
|
318
|
+
':scope > .ok-native-list-identity-title-text, :scope > [data-nl-slot="title"]'
|
|
319
|
+
);
|
|
320
|
+
if (!titleText) {
|
|
321
|
+
titleText = tagSlot(
|
|
322
|
+
createElement(document, 'span', 'ok-native-list-identity-title-text'),
|
|
323
|
+
'title'
|
|
324
|
+
);
|
|
325
|
+
while (titleElement.firstChild && titleElement.firstChild !== badges)
|
|
326
|
+
titleText.appendChild(titleElement.firstChild);
|
|
327
|
+
titleElement.prepend(titleText);
|
|
328
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
329
|
+
} else if (titleElement.hasAttribute('data-nl-slot')) {
|
|
330
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
331
|
+
tagSlot(titleText, 'title');
|
|
332
|
+
}
|
|
333
|
+
titleElement.style.display = 'flex';
|
|
334
|
+
titleElement.style.alignItems = 'center';
|
|
335
|
+
titleText.style.flex = '0 1 auto';
|
|
336
|
+
titleText.style.minWidth = 'min(80px, 100%)';
|
|
337
|
+
titleText.style.overflow = 'hidden';
|
|
338
|
+
titleText.style.textOverflow = 'ellipsis';
|
|
339
|
+
titleText.style.whiteSpace = 'nowrap';
|
|
340
|
+
row.titleSuffixes.forEach((suffix) => {
|
|
341
|
+
const label = createElement(
|
|
342
|
+
document,
|
|
343
|
+
'span',
|
|
344
|
+
'ok-native-list-identity-title-suffix',
|
|
345
|
+
suffix.text
|
|
346
|
+
);
|
|
347
|
+
label.style.flex = '0 1 auto';
|
|
348
|
+
label.style.minWidth = '0';
|
|
349
|
+
label.style.marginInlineStart =
|
|
350
|
+
row.titleIcon || row.secondaryTitleIcon || row.titleImage
|
|
351
|
+
? '4px'
|
|
352
|
+
: '8px';
|
|
353
|
+
label.style.maxWidth =
|
|
354
|
+
suffix.maxWidth === undefined ? '' : `${suffix.maxWidth}px`;
|
|
355
|
+
label.style.overflow = 'hidden';
|
|
356
|
+
label.style.textOverflow = 'ellipsis';
|
|
357
|
+
label.style.whiteSpace = 'nowrap';
|
|
358
|
+
label.style.fontSize = '12px';
|
|
359
|
+
label.style.lineHeight = '16px';
|
|
360
|
+
label.style.fontWeight = '400';
|
|
361
|
+
label.style.fontFamily = 'var(--nl-font-regular)';
|
|
362
|
+
label.style.color =
|
|
363
|
+
suffix.tone === 'disabled'
|
|
364
|
+
? 'var(--nl-disabled)'
|
|
365
|
+
: 'var(--nl-secondary)';
|
|
366
|
+
titleElement.insertBefore(label, badges);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
if (
|
|
370
|
+
row.badges?.length &&
|
|
371
|
+
!row.titleIcon &&
|
|
372
|
+
!row.secondaryTitleIcon &&
|
|
373
|
+
!row.titleImage
|
|
374
|
+
) {
|
|
375
|
+
const titleText = titleElement.querySelector<HTMLElement>(
|
|
376
|
+
':scope > [data-nl-slot="title"]'
|
|
377
|
+
);
|
|
378
|
+
const badges = titleElement.querySelector<HTMLElement>(
|
|
379
|
+
':scope > .ok-native-list-badges'
|
|
380
|
+
);
|
|
381
|
+
titleElement.style.display = 'flex';
|
|
382
|
+
titleElement.style.alignItems = 'center';
|
|
383
|
+
if (titleText) {
|
|
384
|
+
titleText.style.flex = '0 1 auto';
|
|
385
|
+
titleText.style.minWidth = row.titleSuffixes?.length
|
|
386
|
+
? 'min(80px, 100%)'
|
|
387
|
+
: '0';
|
|
388
|
+
}
|
|
389
|
+
if (badges) {
|
|
390
|
+
badges.style.flex = '0 1 auto';
|
|
391
|
+
badges.style.minWidth = '0';
|
|
392
|
+
}
|
|
393
|
+
}
|
|
229
394
|
if (presentation === 'walletSidebar' && row.badges?.length) {
|
|
230
395
|
const badges = createElement(
|
|
231
396
|
document,
|
|
@@ -242,7 +407,15 @@ function createIdentityRow(
|
|
|
242
407
|
if (lines !== undefined)
|
|
243
408
|
column
|
|
244
409
|
.querySelectorAll<HTMLElement>(`[data-nl-slot="${key}"]`)
|
|
245
|
-
.forEach((text) =>
|
|
410
|
+
.forEach((text) => {
|
|
411
|
+
applyTextLayout(
|
|
412
|
+
text,
|
|
413
|
+
lines === 0 ? {} : { lines },
|
|
414
|
+
lines === 0 ? 0 : undefined
|
|
415
|
+
);
|
|
416
|
+
if (key === 'subtitle')
|
|
417
|
+
text.style.overflowWrap = lines === 1 ? '' : 'anywhere';
|
|
418
|
+
});
|
|
246
419
|
}
|
|
247
420
|
}
|
|
248
421
|
body.appendChild(column);
|
|
@@ -272,6 +445,29 @@ function applyIdentityStyle(body: HTMLElement, row: IdentityRow) {
|
|
|
272
445
|
const leading = body.querySelector<HTMLElement>(
|
|
273
446
|
':scope > .ok-native-list-visual, :scope > .ok-native-list-stacked'
|
|
274
447
|
);
|
|
448
|
+
if (row.style?.leadingContentMaxWidthRatio !== undefined && !vertical) {
|
|
449
|
+
const column = body.querySelector<HTMLElement>(
|
|
450
|
+
':scope > .ok-native-list-flex'
|
|
451
|
+
);
|
|
452
|
+
const trailing = body.querySelector<HTMLElement>(
|
|
453
|
+
':scope > .ok-native-list-accessories'
|
|
454
|
+
);
|
|
455
|
+
const visualWidth = leading
|
|
456
|
+
? row.style.image?.width ??
|
|
457
|
+
(row.presentation === 'accountSelector' ||
|
|
458
|
+
row.presentation === 'networkSelector'
|
|
459
|
+
? 32
|
|
460
|
+
: 40)
|
|
461
|
+
: 0;
|
|
462
|
+
const gap = leading ? row.style.leadingGap ?? 12 : 0;
|
|
463
|
+
if (column) {
|
|
464
|
+
column.style.flex = '0 1 auto';
|
|
465
|
+
column.style.maxWidth = `calc(${
|
|
466
|
+
row.style.leadingContentMaxWidthRatio * 100
|
|
467
|
+
}% - ${visualWidth + gap}px)`;
|
|
468
|
+
}
|
|
469
|
+
if (trailing) trailing.style.marginInlineStart = 'auto';
|
|
470
|
+
}
|
|
275
471
|
const defaultGap =
|
|
276
472
|
body.style.gap ||
|
|
277
473
|
(row.type === 'identity' && row.presentation === 'walletSidebar'
|
|
@@ -343,7 +539,7 @@ function applyIdentityStyle(body: HTMLElement, row: IdentityRow) {
|
|
|
343
539
|
const images = leading.matches('img')
|
|
344
540
|
? [leading]
|
|
345
541
|
: leading.querySelectorAll<HTMLElement>(
|
|
346
|
-
':scope > img, :scope > .ok-native-list-visual-fallback'
|
|
542
|
+
':scope > img:not(.ok-native-list-visual-corner), :scope > .ok-native-list-visual-fallback:not(.ok-native-list-visual-corner)'
|
|
347
543
|
);
|
|
348
544
|
images.forEach((bitmap) => {
|
|
349
545
|
if (bitmap !== leading) {
|
|
@@ -373,6 +569,7 @@ type Views = {
|
|
|
373
569
|
node: HTMLElement;
|
|
374
570
|
defaults: RowVisualStyle;
|
|
375
571
|
};
|
|
572
|
+
titleImage?: { key: string; node: HTMLElement };
|
|
376
573
|
primitives: RowPrimitives;
|
|
377
574
|
};
|
|
378
575
|
const views = new WeakMap<HTMLElement, Views>();
|
|
@@ -380,10 +577,21 @@ function bind(body: HTMLElement, row: IdentityRow, primitives: RowPrimitives) {
|
|
|
380
577
|
const v = views.get(body)!;
|
|
381
578
|
v.primitives = primitives;
|
|
382
579
|
let used = false;
|
|
580
|
+
let usedTitleImage = false;
|
|
383
581
|
const next = createIdentityRow(
|
|
384
582
|
body.ownerDocument,
|
|
385
583
|
{
|
|
386
584
|
...primitives,
|
|
585
|
+
thumbnail: (source) => {
|
|
586
|
+
usedTitleImage = true;
|
|
587
|
+
const key = JSON.stringify([row.key, source]);
|
|
588
|
+
if (v.titleImage?.key !== key) {
|
|
589
|
+
if (v.titleImage) primitives.dispose(v.titleImage.node);
|
|
590
|
+
const node = primitives.thumbnail(source);
|
|
591
|
+
v.titleImage = node ? { key, node } : undefined;
|
|
592
|
+
}
|
|
593
|
+
return v.titleImage?.node;
|
|
594
|
+
},
|
|
387
595
|
visual: (source, presentation) => {
|
|
388
596
|
used = true;
|
|
389
597
|
const key = JSON.stringify([row.key, source, presentation]);
|
|
@@ -410,6 +618,10 @@ function bind(body: HTMLElement, row: IdentityRow, primitives: RowPrimitives) {
|
|
|
410
618
|
primitives.dispose(v.visual.node);
|
|
411
619
|
v.visual = undefined;
|
|
412
620
|
}
|
|
621
|
+
if (!usedTitleImage && v.titleImage) {
|
|
622
|
+
primitives.dispose(v.titleImage.node);
|
|
623
|
+
v.titleImage = undefined;
|
|
624
|
+
}
|
|
413
625
|
body.replaceChildren(...Array.from(next.childNodes));
|
|
414
626
|
body.className = next.className;
|
|
415
627
|
body.style.cssText = next.style.cssText;
|
|
@@ -485,6 +697,10 @@ function bind(body: HTMLElement, row: IdentityRow, primitives: RowPrimitives) {
|
|
|
485
697
|
}
|
|
486
698
|
|
|
487
699
|
applyIdentityStyle(body, row);
|
|
700
|
+
body.style.height =
|
|
701
|
+
row.contentHeight === 'auto' && !hasExplicitRowHeight(row)
|
|
702
|
+
? 'auto'
|
|
703
|
+
: '100%';
|
|
488
704
|
}
|
|
489
705
|
function create(
|
|
490
706
|
document: Document,
|
|
@@ -500,7 +716,11 @@ function create(
|
|
|
500
716
|
function recycle(body: HTMLElement) {
|
|
501
717
|
const v = views.get(body);
|
|
502
718
|
if (v?.visual) v.primitives.dispose(v.visual.node);
|
|
503
|
-
if (v) v.
|
|
719
|
+
if (v?.titleImage) v.primitives.dispose(v.titleImage.node);
|
|
720
|
+
if (v) {
|
|
721
|
+
v.visual = undefined;
|
|
722
|
+
v.titleImage = undefined;
|
|
723
|
+
}
|
|
504
724
|
body.replaceChildren();
|
|
505
725
|
}
|
|
506
726
|
export const identityRowRenderer = {
|
|
@@ -522,7 +742,12 @@ export const identityRowRenderer = {
|
|
|
522
742
|
? 60
|
|
523
743
|
: 56,
|
|
524
744
|
measureRendered: (
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
): number | undefined =>
|
|
745
|
+
body: HTMLElement,
|
|
746
|
+
row: IdentityRow
|
|
747
|
+
): number | undefined => {
|
|
748
|
+
if (row.contentHeight !== 'auto' || hasExplicitRowHeight(row))
|
|
749
|
+
return undefined;
|
|
750
|
+
const height = body.offsetHeight;
|
|
751
|
+
return height > 0 ? height : undefined;
|
|
752
|
+
},
|
|
528
753
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createNamedIcon } from '@onekeyfe/react-native-image/icon/dom';
|
|
1
2
|
import type {
|
|
2
3
|
MarketRow,
|
|
3
4
|
WebMarketTableCell,
|
|
@@ -14,6 +15,7 @@ type CellViews = {
|
|
|
14
15
|
signature: string;
|
|
15
16
|
visual?: HTMLElement;
|
|
16
17
|
visualKey?: string;
|
|
18
|
+
visualImageKey?: string;
|
|
17
19
|
title?: HTMLElement;
|
|
18
20
|
resting?: HTMLElement;
|
|
19
21
|
hover?: HTMLElement;
|
|
@@ -26,10 +28,6 @@ const views = new WeakMap<HTMLElement, Views>();
|
|
|
26
28
|
const columnSignatures = new WeakMap<readonly WebMarketTableColumn[], string>();
|
|
27
29
|
let sparklineId = 0;
|
|
28
30
|
const svgNamespace = 'http://www.w3.org/2000/svg';
|
|
29
|
-
const outlineStar =
|
|
30
|
-
'm15.455 7.243 7.729 1.123-5.592 5.45 1.32 7.698L12 17.879l-6.911 3.635 1.32-7.698-5.592-5.45 7.728-1.123L12 .24zM9.872 9.071l-4.759.69 3.444 3.358-.814 4.738L12 15.62l.465.245 3.791 1.993-.813-4.739 3.443-3.357-4.758-.69L12 4.758z';
|
|
31
|
-
const solidStar =
|
|
32
|
-
'm15.405 7.313 7.84 1.034-5.735 5.443 1.44 7.774L12 17.793l-6.948 3.771 1.44-7.774L.756 8.347l7.839-1.034L12 .178z';
|
|
33
31
|
function columnsSignature(columns: readonly WebMarketTableColumn[]) {
|
|
34
32
|
let signature = columnSignatures.get(columns);
|
|
35
33
|
if (signature === undefined) {
|
|
@@ -176,19 +174,13 @@ function action(
|
|
|
176
174
|
flexShrink: '0',
|
|
177
175
|
});
|
|
178
176
|
}
|
|
179
|
-
function icon(document: Document,
|
|
180
|
-
const svg = document
|
|
181
|
-
svg.setAttribute('viewBox', '0 0 24 24');
|
|
177
|
+
function icon(document: Document, name: string, size: number): SVGSVGElement {
|
|
178
|
+
const svg = createNamedIcon(document, name);
|
|
182
179
|
svg.setAttribute('width', String(size));
|
|
183
180
|
svg.setAttribute('height', String(size));
|
|
184
|
-
svg.setAttribute('aria-hidden', 'true');
|
|
185
|
-
svg.setAttribute('fill', 'currentColor');
|
|
186
|
-
const path = document.createElementNS(svgNamespace, 'path');
|
|
187
|
-
path.setAttribute('d', d);
|
|
188
|
-
path.setAttribute('fill-rule', 'evenodd');
|
|
189
|
-
svg.appendChild(path);
|
|
190
181
|
return svg;
|
|
191
182
|
}
|
|
183
|
+
|
|
192
184
|
function drawSparkline(
|
|
193
185
|
element: HTMLElement,
|
|
194
186
|
cell: Extract<WebMarketTableCell, { kind: 'sparkline' }>
|
|
@@ -287,11 +279,42 @@ function updateCell(
|
|
|
287
279
|
if (cell.kind === 'asset') {
|
|
288
280
|
const visualKey = JSON.stringify(cell.leading);
|
|
289
281
|
if (view.visualKey !== visualKey) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
282
|
+
const visualImageKey = JSON.stringify(
|
|
283
|
+
cell.leading?.kind === 'token'
|
|
284
|
+
? { ...cell.leading, overlays: undefined }
|
|
285
|
+
: cell.leading
|
|
286
|
+
);
|
|
287
|
+
if (
|
|
288
|
+
view.visual &&
|
|
289
|
+
cell.leading?.kind === 'token' &&
|
|
290
|
+
view.visualImageKey === visualImageKey
|
|
291
|
+
) {
|
|
292
|
+
// Keep the main frame: its load/error callbacks own its visibility.
|
|
293
|
+
for (const overlay of view.visual.querySelectorAll<HTMLElement>(
|
|
294
|
+
':scope > .ok-native-list-visual-overlay'
|
|
295
|
+
)) {
|
|
296
|
+
primitives.dispose(overlay);
|
|
297
|
+
overlay.remove();
|
|
298
|
+
}
|
|
299
|
+
const overlayVisual = primitives.visual({
|
|
300
|
+
kind: 'token',
|
|
301
|
+
overlays: cell.leading.overlays,
|
|
302
|
+
});
|
|
303
|
+
if (overlayVisual) {
|
|
304
|
+
for (const overlay of overlayVisual.querySelectorAll<HTMLElement>(
|
|
305
|
+
':scope > .ok-native-list-visual-overlay'
|
|
306
|
+
))
|
|
307
|
+
view.visual.appendChild(overlay);
|
|
308
|
+
primitives.dispose(overlayVisual);
|
|
309
|
+
}
|
|
310
|
+
} else {
|
|
311
|
+
if (view.visual) {
|
|
312
|
+
primitives.dispose(view.visual);
|
|
313
|
+
view.visual.remove();
|
|
314
|
+
}
|
|
315
|
+
view.visual = primitives.visual(cell.leading);
|
|
293
316
|
}
|
|
294
|
-
view.
|
|
317
|
+
view.visualImageKey = visualImageKey;
|
|
295
318
|
view.visualKey = visualKey;
|
|
296
319
|
if (view.visual)
|
|
297
320
|
Object.assign(view.visual.style, {
|
|
@@ -344,6 +367,9 @@ function updateCell(
|
|
|
344
367
|
);
|
|
345
368
|
if (view.hover) {
|
|
346
369
|
const button = view.hover.querySelector('button');
|
|
370
|
+
view.hover.parentElement
|
|
371
|
+
?.querySelector('button')
|
|
372
|
+
?.setAttribute('aria-label', cell.hoverActionLabel ?? 'Copy address');
|
|
347
373
|
for (const child of [...view.hover.children])
|
|
348
374
|
if (child !== button) child.remove();
|
|
349
375
|
for (const part of cell.hoverSecondary ?? [])
|
|
@@ -450,11 +476,7 @@ function updateCell(
|
|
|
450
476
|
);
|
|
451
477
|
if (badge.actionKey) node.dataset.nativeListHoverAction = 'true';
|
|
452
478
|
node.textContent = '';
|
|
453
|
-
const svg = icon(
|
|
454
|
-
document,
|
|
455
|
-
'M9.483 11.458v3.5h-1v-3.5z M10.467 2.698a2.03 2.03 0 0 1 3.065 0l1.358 1.564a.03.03 0 0 0 .028.01l2.046-.325a2.03 2.03 0 0 1 2.347 1.971l.037 2.07q0 .016.014.026l1.776 1.066a2.03 2.03 0 0 1 .532 3.019l-1.304 1.609a.03.03 0 0 0-.005.03l.675 1.956a2.03 2.03 0 0 1-1.533 2.656l-2.033.394a.03.03 0 0 0-.023.019l-.741 1.933a2.03 2.03 0 0 1-2.88 1.05l-1.811-1.006a.03.03 0 0 0-.03 0l-1.811 1.005a2.03 2.03 0 0 1-2.88-1.049l-.742-1.933a.03.03 0 0 0-.023-.019l-2.033-.394a2.03 2.03 0 0 1-1.532-2.656l.675-1.957a.03.03 0 0 0-.005-.029l-1.304-1.61a2.03 2.03 0 0 1 .532-3.018l1.776-1.066a.03.03 0 0 0 .014-.026l.035-2.07a2.03 2.03 0 0 1 2.349-1.97l2.045.324a.03.03 0 0 0 .028-.01zm1.516 3.76a.5.5 0 0 0-.447.276l-1.861 3.724H8.483a1 1 0 0 0-1 1v3.5a1 1 0 0 0 1 1h6.692a2 2 0 0 0 1.981-1.73l.341-2.5a2 2 0 0 0-1.982-2.27h-1.939l.197-1.269a1.5 1.5 0 0 0-1.481-1.731z',
|
|
456
|
-
14
|
|
457
|
-
);
|
|
479
|
+
const svg = icon(document, 'BadgeRecognizedSolid', 14);
|
|
458
480
|
node.appendChild(svg);
|
|
459
481
|
}
|
|
460
482
|
title.appendChild(node);
|
|
@@ -575,13 +597,7 @@ function updateCell(
|
|
|
575
597
|
);
|
|
576
598
|
button.style.padding = '0';
|
|
577
599
|
button.style.color = 'var(--nl-icon-subdued)';
|
|
578
|
-
button.appendChild(
|
|
579
|
-
icon(
|
|
580
|
-
document,
|
|
581
|
-
'M21 17h-4v4H3V7h4V3h14zM5 19h10V9H5zM9 7h8v8h2V5H9z',
|
|
582
|
-
14
|
|
583
|
-
)
|
|
584
|
-
);
|
|
600
|
+
button.appendChild(icon(document, 'Copy3Outline', 14));
|
|
585
601
|
hoverFrame.appendChild(button);
|
|
586
602
|
}
|
|
587
603
|
track.appendChild(hoverFrame);
|
|
@@ -610,12 +626,19 @@ function updateCell(
|
|
|
610
626
|
: 'var(--nl-icon-subdued)';
|
|
611
627
|
let svg = button.querySelector('svg');
|
|
612
628
|
if (!svg) {
|
|
613
|
-
svg = icon(document, cell.active ?
|
|
629
|
+
svg = icon(document, cell.active ? 'StarSolid' : 'StarOutline', 16);
|
|
614
630
|
button.appendChild(svg);
|
|
615
631
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
632
|
+
const name = cell.active ? 'StarSolid' : 'StarOutline';
|
|
633
|
+
if (
|
|
634
|
+
!svg
|
|
635
|
+
.querySelector('use')
|
|
636
|
+
?.getAttribute('href')
|
|
637
|
+
?.endsWith(`#onekey-${name}`)
|
|
638
|
+
) {
|
|
639
|
+
const replacement = icon(document, name, 16);
|
|
640
|
+
svg.replaceWith(replacement);
|
|
641
|
+
}
|
|
619
642
|
if (!button.parentElement) element.appendChild(button);
|
|
620
643
|
} else if (cell.kind === 'sparkline') drawSparkline(element, cell);
|
|
621
644
|
else {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createNamedIcon } from '@onekeyfe/react-native-image/icon/dom';
|
|
1
2
|
import type { MediaTileRow, NativeListTextStyle } from '../../models';
|
|
2
3
|
import type { RowPrimitives } from './RowVisual';
|
|
3
4
|
|
|
@@ -192,7 +193,7 @@ type GalleryViews = {
|
|
|
192
193
|
};
|
|
193
194
|
const galleries = new WeakMap<HTMLElement, GalleryViews>();
|
|
194
195
|
const isGalleryMedia = (row: MediaTileRow) =>
|
|
195
|
-
row.variant === 'gallery' && !row.image;
|
|
196
|
+
row.variant === 'gallery' && (!row.image || (!!row.media && !row.imageState));
|
|
196
197
|
|
|
197
198
|
function clearGalleryMedia(v: GalleryViews) {
|
|
198
199
|
v.epoch += 1;
|
|
@@ -220,21 +221,7 @@ function initGallery(body: HTMLElement, primitives: RowPrimitives) {
|
|
|
220
221
|
};
|
|
221
222
|
const frame = element('ok-native-list-media-image');
|
|
222
223
|
const fallback = element('ok-native-list-media-fallback');
|
|
223
|
-
const svg = document
|
|
224
|
-
svg.setAttribute('viewBox', '0 0 24 24');
|
|
225
|
-
svg.setAttribute('width', '24');
|
|
226
|
-
svg.setAttribute('height', '24');
|
|
227
|
-
svg.setAttribute('aria-hidden', 'true');
|
|
228
|
-
svg.setAttribute('fill', 'currentColor');
|
|
229
|
-
for (const d of [
|
|
230
|
-
'M14.25 7a2 2 0 1 1 0 4 2 2 0 0 1 0-4',
|
|
231
|
-
'M21 21H3V3h18zM5 16.414V19h12.586L14 15.414l-2 2-4-4zm0-2.828 3-3 4 4 2-2 5 5V5H5z',
|
|
232
|
-
]) {
|
|
233
|
-
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
234
|
-
path.setAttribute('d', d);
|
|
235
|
-
path.setAttribute('fill-rule', 'evenodd');
|
|
236
|
-
svg.append(path);
|
|
237
|
-
}
|
|
224
|
+
const svg = createNamedIcon(document, 'ImageSquareWavesOutline');
|
|
238
225
|
fallback.append(svg);
|
|
239
226
|
Object.assign(fallback.style, {
|
|
240
227
|
position: 'absolute',
|
|
@@ -332,7 +319,7 @@ function bindGallery(
|
|
|
332
319
|
v.mediaKey = mediaKey;
|
|
333
320
|
v.fallback.style.visibility = 'visible';
|
|
334
321
|
const epoch = v.epoch;
|
|
335
|
-
const source = row.media?.source;
|
|
322
|
+
const source = row.imageState ? undefined : row.media?.source;
|
|
336
323
|
const probe = (attempt: number) => {
|
|
337
324
|
if (v.epoch !== epoch) return;
|
|
338
325
|
const kind = row.media?.probeOrder[attempt];
|
|
@@ -4,10 +4,8 @@ import type { MessageRow, NativeListTextStyle } from '../../models';
|
|
|
4
4
|
|
|
5
5
|
type Text = Readonly<{
|
|
6
6
|
value: string;
|
|
7
|
-
style: Required<
|
|
8
|
-
|
|
9
|
-
> &
|
|
10
|
-
NativeListTextStyle;
|
|
7
|
+
style: Required<Pick<NativeListTextStyle, 'fontSize' | 'lineHeight'>> &
|
|
8
|
+
Omit<NativeListTextStyle, 'lines'> & { lines: 0 | 1 | 2 | 3 };
|
|
11
9
|
}>;
|
|
12
10
|
export function resolveMessageRow(row: MessageRow) {
|
|
13
11
|
const text = (
|
|
@@ -15,7 +13,7 @@ export function resolveMessageRow(row: MessageRow) {
|
|
|
15
13
|
style: NativeListTextStyle | undefined,
|
|
16
14
|
fontSize: number,
|
|
17
15
|
lineHeight: number,
|
|
18
|
-
lines: 1 | 2 | 3,
|
|
16
|
+
lines: 0 | 1 | 2 | 3,
|
|
19
17
|
color: string,
|
|
20
18
|
fontWeight: NativeListTextStyle['fontWeight'] = 'regular'
|
|
21
19
|
): Text => ({
|
|
@@ -117,6 +115,9 @@ export function bindMessageRow(
|
|
|
117
115
|
body.style.cssText = '';
|
|
118
116
|
body.removeAttribute('data-nl-container-background');
|
|
119
117
|
body.removeAttribute('data-nl-container-border');
|
|
118
|
+
if (row.presentation === 'inlineWarning')
|
|
119
|
+
body.setAttribute('data-nl-inline-warning', 'true');
|
|
120
|
+
else body.removeAttribute('data-nl-inline-warning');
|
|
120
121
|
body.style.padding = `${resolved.verticalPadding}px ${resolved.horizontalPadding}px`;
|
|
121
122
|
body.style.height = resolved.automaticHeight ? 'auto' : '100%';
|
|
122
123
|
views.column.style.cssText = '';
|
|
@@ -128,7 +129,19 @@ export function bindMessageRow(
|
|
|
128
129
|
] as const) {
|
|
129
130
|
view.style.cssText = '';
|
|
130
131
|
view.textContent = text.value;
|
|
131
|
-
|
|
132
|
+
const { lines, ...textStyle } = text.style;
|
|
133
|
+
primitives.textStyle(
|
|
134
|
+
view,
|
|
135
|
+
lines === 0 ? textStyle : { ...textStyle, lines }
|
|
136
|
+
);
|
|
137
|
+
if (lines === 0) {
|
|
138
|
+
view.style.whiteSpace = 'pre-wrap';
|
|
139
|
+
view.style.overflow = 'visible';
|
|
140
|
+
view.style.textOverflow = 'clip';
|
|
141
|
+
view.style.maxHeight = 'none';
|
|
142
|
+
view.style.removeProperty('-webkit-line-clamp');
|
|
143
|
+
view.style.removeProperty('-webkit-box-orient');
|
|
144
|
+
}
|
|
132
145
|
}
|
|
133
146
|
views.unread.style.cssText = '';
|
|
134
147
|
if (row.body) {
|
|
@@ -258,7 +271,10 @@ export function measureMessageRow(
|
|
|
258
271
|
),
|
|
259
272
|
0
|
|
260
273
|
);
|
|
261
|
-
return
|
|
274
|
+
return (
|
|
275
|
+
(text.style.lines === 0 ? lines : Math.min(text.style.lines, lines)) *
|
|
276
|
+
text.style.lineHeight
|
|
277
|
+
);
|
|
262
278
|
};
|
|
263
279
|
const timeWidth = Math.min(
|
|
264
280
|
availableWidth / 3,
|
|
@@ -88,6 +88,8 @@ export function applyRowContainerStyle(body: HTMLElement, row: RowModel): void {
|
|
|
88
88
|
}
|
|
89
89
|
if (container.cornerRadius !== undefined)
|
|
90
90
|
set(body, 'border-radius', `${container.cornerRadius}px`);
|
|
91
|
+
if (row.type === 'message' && row.presentation === 'inlineWarning')
|
|
92
|
+
set(body, 'border-radius', '0px');
|
|
91
93
|
if (container.borderWidth !== undefined) {
|
|
92
94
|
// Paint above member backgrounds without changing the content box or hit targets.
|
|
93
95
|
body.setAttribute('data-nl-container-border', 'true');
|
|
@@ -16,8 +16,15 @@ import type { SystemRow } from '../../models';
|
|
|
16
16
|
import { systemRowRenderer } from './SystemRowRenderer';
|
|
17
17
|
import type { ActionRow } from '../../models';
|
|
18
18
|
import { actionRowRenderer } from './ActionRowRenderer';
|
|
19
|
+
import { buttonGroupRowRenderer } from './ButtonGroupRowRenderer';
|
|
19
20
|
import { mediaTileRowRenderer } from './MediaTileRowRenderer';
|
|
20
|
-
import type {
|
|
21
|
+
import type {
|
|
22
|
+
ButtonGroupRow,
|
|
23
|
+
MessageRow,
|
|
24
|
+
RailRow,
|
|
25
|
+
MediaTileRow,
|
|
26
|
+
RowModel,
|
|
27
|
+
} from '../../models';
|
|
21
28
|
import { messageRowRenderer } from './MessageRowRenderer';
|
|
22
29
|
import type { RowPrimitives } from './RowVisual';
|
|
23
30
|
import { railRowRenderer } from './RailRowRenderer';
|
|
@@ -71,6 +78,8 @@ const factories = {
|
|
|
71
78
|
registration(activityRowRenderer, row as ActivityRow),
|
|
72
79
|
system: (row: RowModel) => registration(systemRowRenderer, row as SystemRow),
|
|
73
80
|
action: (row: RowModel) => registration(actionRowRenderer, row as ActionRow),
|
|
81
|
+
buttonGroup: (row: RowModel) =>
|
|
82
|
+
registration(buttonGroupRowRenderer, row as ButtonGroupRow),
|
|
74
83
|
message: (row: RowModel) =>
|
|
75
84
|
registration(messageRowRenderer, row as MessageRow),
|
|
76
85
|
rail: (row: RowModel) => registration(railRowRenderer, row as RailRow),
|
|
@@ -91,6 +100,7 @@ const renderers = {
|
|
|
91
100
|
activity: activityRowRenderer,
|
|
92
101
|
system: systemRowRenderer,
|
|
93
102
|
action: actionRowRenderer,
|
|
103
|
+
buttonGroup: buttonGroupRowRenderer,
|
|
94
104
|
message: messageRowRenderer,
|
|
95
105
|
rail: railRowRenderer,
|
|
96
106
|
mediaTile: mediaTileRowRenderer,
|