@onekeyfe/react-native-native-list 6.7.0-3 → 6.7.0-30
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
|
@@ -100,6 +100,117 @@ function createIdentityRow(document, primitives, row) {
|
|
|
100
100
|
});
|
|
101
101
|
column.insertBefore(segments, titleElement.nextSibling);
|
|
102
102
|
}
|
|
103
|
+
if (row.titleIcon || row.secondaryTitleIcon || row.titleImage) {
|
|
104
|
+
const badgeLine = titleElement.querySelector(':scope > .ok-native-list-badges');
|
|
105
|
+
const titleText = createElement(document, 'span', 'ok-native-list-identity-title-text');
|
|
106
|
+
while (titleElement.firstChild && titleElement.firstChild !== badgeLine) titleText.appendChild(titleElement.firstChild);
|
|
107
|
+
titleElement.prepend(titleText);
|
|
108
|
+
// The title slot tag moves with the text. `applyTextLayout` writes the
|
|
109
|
+
// single-line clamp (`display: block`, nowrap, ellipsis) onto the slot
|
|
110
|
+
// element; left on this container it would undo the flex row below and
|
|
111
|
+
// leave the inline-flex glyph baseline-aligned above the title (OK-66402).
|
|
112
|
+
if (titleElement.hasAttribute('data-nl-slot')) {
|
|
113
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
114
|
+
tagSlot(titleText, 'title');
|
|
115
|
+
}
|
|
116
|
+
const icons = [row.titleIcon, row.secondaryTitleIcon].filter(icon => icon !== undefined).map(descriptor => {
|
|
117
|
+
const icon = primitives.iconAction(descriptor.name, undefined, undefined, descriptor.tintColor);
|
|
118
|
+
icon.className = 'ok-native-list-identity-title-icon';
|
|
119
|
+
if (descriptor.hoverActionKey) {
|
|
120
|
+
setData(icon, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
121
|
+
setData(icon, 'nativeListIconHelp', true);
|
|
122
|
+
markActionAnchorSource(icon, 'leadingAction');
|
|
123
|
+
}
|
|
124
|
+
if (descriptor.accessibilityLabel) icon.setAttribute('aria-label', descriptor.accessibilityLabel);else icon.setAttribute('aria-hidden', 'true');
|
|
125
|
+
return icon;
|
|
126
|
+
});
|
|
127
|
+
if (row.titleImage) {
|
|
128
|
+
const descriptor = row.titleImage;
|
|
129
|
+
const holder = createElement(document, 'span', 'ok-native-list-identity-title-image');
|
|
130
|
+
Object.assign(holder.style, {
|
|
131
|
+
flex: `0 0 ${descriptor.image.width}px`,
|
|
132
|
+
width: `${descriptor.image.width}px`,
|
|
133
|
+
height: `${descriptor.image.height}px`,
|
|
134
|
+
borderRadius: '50%',
|
|
135
|
+
overflow: 'hidden'
|
|
136
|
+
});
|
|
137
|
+
const image = primitives.thumbnail(descriptor.image);
|
|
138
|
+
if (image) {
|
|
139
|
+
Object.assign(image.style, {
|
|
140
|
+
width: '100%',
|
|
141
|
+
height: '100%',
|
|
142
|
+
borderRadius: 'inherit',
|
|
143
|
+
objectFit: descriptor.image.contentFit === 'center' ? 'none' : descriptor.image.contentFit ?? 'cover'
|
|
144
|
+
});
|
|
145
|
+
image.setAttribute('alt', '');
|
|
146
|
+
holder.appendChild(image);
|
|
147
|
+
}
|
|
148
|
+
if (descriptor.hoverActionKey) {
|
|
149
|
+
setData(holder, 'nativeListHoverAction', descriptor.hoverActionKey);
|
|
150
|
+
setData(holder, 'nativeListIconHelp', true);
|
|
151
|
+
markActionAnchorSource(holder, 'leadingAction');
|
|
152
|
+
}
|
|
153
|
+
if (descriptor.accessibilityLabel) {
|
|
154
|
+
holder.setAttribute('role', 'img');
|
|
155
|
+
holder.setAttribute('aria-label', descriptor.accessibilityLabel);
|
|
156
|
+
} else holder.setAttribute('aria-hidden', 'true');
|
|
157
|
+
icons.push(holder);
|
|
158
|
+
}
|
|
159
|
+
titleText.after(...icons);
|
|
160
|
+
titleElement.style.display = 'flex';
|
|
161
|
+
titleElement.style.alignItems = 'center';
|
|
162
|
+
titleElement.style.gap = '4px';
|
|
163
|
+
}
|
|
164
|
+
if (row.titleSuffixes?.length) {
|
|
165
|
+
const badges = titleElement.querySelector(':scope > .ok-native-list-badges');
|
|
166
|
+
let titleText = titleElement.querySelector(':scope > .ok-native-list-identity-title-text, :scope > [data-nl-slot="title"]');
|
|
167
|
+
if (!titleText) {
|
|
168
|
+
titleText = tagSlot(createElement(document, 'span', 'ok-native-list-identity-title-text'), 'title');
|
|
169
|
+
while (titleElement.firstChild && titleElement.firstChild !== badges) titleText.appendChild(titleElement.firstChild);
|
|
170
|
+
titleElement.prepend(titleText);
|
|
171
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
172
|
+
} else if (titleElement.hasAttribute('data-nl-slot')) {
|
|
173
|
+
titleElement.removeAttribute('data-nl-slot');
|
|
174
|
+
tagSlot(titleText, 'title');
|
|
175
|
+
}
|
|
176
|
+
titleElement.style.display = 'flex';
|
|
177
|
+
titleElement.style.alignItems = 'center';
|
|
178
|
+
titleText.style.flex = '0 1 auto';
|
|
179
|
+
titleText.style.minWidth = 'min(80px, 100%)';
|
|
180
|
+
titleText.style.overflow = 'hidden';
|
|
181
|
+
titleText.style.textOverflow = 'ellipsis';
|
|
182
|
+
titleText.style.whiteSpace = 'nowrap';
|
|
183
|
+
row.titleSuffixes.forEach(suffix => {
|
|
184
|
+
const label = createElement(document, 'span', 'ok-native-list-identity-title-suffix', suffix.text);
|
|
185
|
+
label.style.flex = '0 1 auto';
|
|
186
|
+
label.style.minWidth = '0';
|
|
187
|
+
label.style.marginInlineStart = row.titleIcon || row.secondaryTitleIcon || row.titleImage ? '4px' : '8px';
|
|
188
|
+
label.style.maxWidth = suffix.maxWidth === undefined ? '' : `${suffix.maxWidth}px`;
|
|
189
|
+
label.style.overflow = 'hidden';
|
|
190
|
+
label.style.textOverflow = 'ellipsis';
|
|
191
|
+
label.style.whiteSpace = 'nowrap';
|
|
192
|
+
label.style.fontSize = '12px';
|
|
193
|
+
label.style.lineHeight = '16px';
|
|
194
|
+
label.style.fontWeight = '400';
|
|
195
|
+
label.style.fontFamily = 'var(--nl-font-regular)';
|
|
196
|
+
label.style.color = suffix.tone === 'disabled' ? 'var(--nl-disabled)' : 'var(--nl-secondary)';
|
|
197
|
+
titleElement.insertBefore(label, badges);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (row.badges?.length && !row.titleIcon && !row.secondaryTitleIcon && !row.titleImage) {
|
|
201
|
+
const titleText = titleElement.querySelector(':scope > [data-nl-slot="title"]');
|
|
202
|
+
const badges = titleElement.querySelector(':scope > .ok-native-list-badges');
|
|
203
|
+
titleElement.style.display = 'flex';
|
|
204
|
+
titleElement.style.alignItems = 'center';
|
|
205
|
+
if (titleText) {
|
|
206
|
+
titleText.style.flex = '0 1 auto';
|
|
207
|
+
titleText.style.minWidth = row.titleSuffixes?.length ? 'min(80px, 100%)' : '0';
|
|
208
|
+
}
|
|
209
|
+
if (badges) {
|
|
210
|
+
badges.style.flex = '0 1 auto';
|
|
211
|
+
badges.style.minWidth = '0';
|
|
212
|
+
}
|
|
213
|
+
}
|
|
103
214
|
if (presentation === 'walletSidebar' && row.badges?.length) {
|
|
104
215
|
const badges = createElement(document, 'span', 'ok-native-list-wallet-badges');
|
|
105
216
|
row.badges.forEach(badge => badges.appendChild(createBadge(document, badge)));
|
|
@@ -107,9 +218,12 @@ function createIdentityRow(document, primitives, row) {
|
|
|
107
218
|
}
|
|
108
219
|
for (const key of ['title', 'subtitle']) {
|
|
109
220
|
const lines = row.style?.[key]?.lines ?? row[`${key}Lines`];
|
|
110
|
-
if (lines !== undefined) column.querySelectorAll(`[data-nl-slot="${key}"]`).forEach(text =>
|
|
111
|
-
lines
|
|
112
|
-
|
|
221
|
+
if (lines !== undefined) column.querySelectorAll(`[data-nl-slot="${key}"]`).forEach(text => {
|
|
222
|
+
applyTextLayout(text, lines === 0 ? {} : {
|
|
223
|
+
lines
|
|
224
|
+
}, lines === 0 ? 0 : undefined);
|
|
225
|
+
if (key === 'subtitle') text.style.overflowWrap = lines === 1 ? '' : 'anywhere';
|
|
226
|
+
});
|
|
113
227
|
}
|
|
114
228
|
}
|
|
115
229
|
body.appendChild(column);
|
|
@@ -125,6 +239,17 @@ function applyIdentityStyle(body, row) {
|
|
|
125
239
|
if (box.verticalPadding !== undefined) body.style.paddingBlock = String(box.verticalPadding) + 'px';
|
|
126
240
|
const vertical = row.type === 'identity' && row.presentation === 'walletSidebar';
|
|
127
241
|
const leading = body.querySelector(':scope > .ok-native-list-visual, :scope > .ok-native-list-stacked');
|
|
242
|
+
if (row.style?.leadingContentMaxWidthRatio !== undefined && !vertical) {
|
|
243
|
+
const column = body.querySelector(':scope > .ok-native-list-flex');
|
|
244
|
+
const trailing = body.querySelector(':scope > .ok-native-list-accessories');
|
|
245
|
+
const visualWidth = leading ? row.style.image?.width ?? (row.presentation === 'accountSelector' || row.presentation === 'networkSelector' ? 32 : 40) : 0;
|
|
246
|
+
const gap = leading ? row.style.leadingGap ?? 12 : 0;
|
|
247
|
+
if (column) {
|
|
248
|
+
column.style.flex = '0 1 auto';
|
|
249
|
+
column.style.maxWidth = `calc(${row.style.leadingContentMaxWidthRatio * 100}% - ${visualWidth + gap}px)`;
|
|
250
|
+
}
|
|
251
|
+
if (trailing) trailing.style.marginInlineStart = 'auto';
|
|
252
|
+
}
|
|
128
253
|
const defaultGap = body.style.gap || (row.type === 'identity' && row.presentation === 'walletSidebar' ? '4px' : row.type === 'identity' && row.presentation === 'accountSelector' ? '8px' : '12px');
|
|
129
254
|
if (box.lineGap !== undefined) {
|
|
130
255
|
const targets = body.querySelectorAll(':scope > .ok-native-list-flex');
|
|
@@ -161,7 +286,7 @@ function applyIdentityStyle(body, row) {
|
|
|
161
286
|
// Clip the bitmap itself; decorations may extend beyond the visual slot.
|
|
162
287
|
leading.style.overflow = leading.matches('img') ? 'hidden' : 'visible';
|
|
163
288
|
}
|
|
164
|
-
const images = leading.matches('img') ? [leading] : leading.querySelectorAll(':scope > img, :scope > .ok-native-list-visual-fallback');
|
|
289
|
+
const images = leading.matches('img') ? [leading] : leading.querySelectorAll(':scope > img:not(.ok-native-list-visual-corner), :scope > .ok-native-list-visual-fallback:not(.ok-native-list-visual-corner)');
|
|
165
290
|
images.forEach(bitmap => {
|
|
166
291
|
if (bitmap !== leading) {
|
|
167
292
|
if (image.width !== undefined) bitmap.style.width = '100%';
|
|
@@ -185,8 +310,22 @@ function bind(body, row, primitives) {
|
|
|
185
310
|
const v = views.get(body);
|
|
186
311
|
v.primitives = primitives;
|
|
187
312
|
let used = false;
|
|
313
|
+
let usedTitleImage = false;
|
|
188
314
|
const next = createIdentityRow(body.ownerDocument, {
|
|
189
315
|
...primitives,
|
|
316
|
+
thumbnail: source => {
|
|
317
|
+
usedTitleImage = true;
|
|
318
|
+
const key = JSON.stringify([row.key, source]);
|
|
319
|
+
if (v.titleImage?.key !== key) {
|
|
320
|
+
if (v.titleImage) primitives.dispose(v.titleImage.node);
|
|
321
|
+
const node = primitives.thumbnail(source);
|
|
322
|
+
v.titleImage = node ? {
|
|
323
|
+
key,
|
|
324
|
+
node
|
|
325
|
+
} : undefined;
|
|
326
|
+
}
|
|
327
|
+
return v.titleImage?.node;
|
|
328
|
+
},
|
|
190
329
|
visual: (source, presentation) => {
|
|
191
330
|
used = true;
|
|
192
331
|
const key = JSON.stringify([row.key, source, presentation]);
|
|
@@ -211,6 +350,10 @@ function bind(body, row, primitives) {
|
|
|
211
350
|
primitives.dispose(v.visual.node);
|
|
212
351
|
v.visual = undefined;
|
|
213
352
|
}
|
|
353
|
+
if (!usedTitleImage && v.titleImage) {
|
|
354
|
+
primitives.dispose(v.titleImage.node);
|
|
355
|
+
v.titleImage = undefined;
|
|
356
|
+
}
|
|
214
357
|
body.replaceChildren(...Array.from(next.childNodes));
|
|
215
358
|
body.className = next.className;
|
|
216
359
|
body.style.cssText = next.style.cssText;
|
|
@@ -262,6 +405,7 @@ function bind(body, row, primitives) {
|
|
|
262
405
|
}
|
|
263
406
|
}
|
|
264
407
|
applyIdentityStyle(body, row);
|
|
408
|
+
body.style.height = row.contentHeight === 'auto' && !hasExplicitRowHeight(row) ? 'auto' : '100%';
|
|
265
409
|
}
|
|
266
410
|
function create(document, row, primitives) {
|
|
267
411
|
const body = document.createElement('div');
|
|
@@ -275,7 +419,11 @@ function create(document, row, primitives) {
|
|
|
275
419
|
function recycle(body) {
|
|
276
420
|
const v = views.get(body);
|
|
277
421
|
if (v?.visual) v.primitives.dispose(v.visual.node);
|
|
278
|
-
if (v) v.
|
|
422
|
+
if (v?.titleImage) v.primitives.dispose(v.titleImage.node);
|
|
423
|
+
if (v) {
|
|
424
|
+
v.visual = undefined;
|
|
425
|
+
v.titleImage = undefined;
|
|
426
|
+
}
|
|
279
427
|
body.replaceChildren();
|
|
280
428
|
}
|
|
281
429
|
export const identityRowRenderer = {
|
|
@@ -285,6 +433,10 @@ export const identityRowRenderer = {
|
|
|
285
433
|
recycle,
|
|
286
434
|
appliesSizePreset: row => !row.presentation,
|
|
287
435
|
measure: (row, _width) => row.presentation === 'walletSidebar' ? 68 + (row.badges?.length ? 24 : 0) : row.presentation === 'networkSelector' ? 47 : row.presentation === 'accountSelector' ? 58 : row.tertiary ? 72 : row.subtitle ? 60 : 56,
|
|
288
|
-
measureRendered: (
|
|
436
|
+
measureRendered: (body, row) => {
|
|
437
|
+
if (row.contentHeight !== 'auto' || hasExplicitRowHeight(row)) return undefined;
|
|
438
|
+
const height = body.offsetHeight;
|
|
439
|
+
return height > 0 ? height : undefined;
|
|
440
|
+
}
|
|
289
441
|
};
|
|
290
442
|
//# sourceMappingURL=IdentityRowRenderer.js.map
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { createNamedIcon } from '@onekeyfe/react-native-image/icon/dom';
|
|
3
4
|
import { createElement, markActionAnchorSource } from "./RowElements.js";
|
|
4
5
|
import { applyTextWeight, applyValueSegments } from "./RowText.js";
|
|
5
6
|
const views = new WeakMap();
|
|
6
7
|
const columnSignatures = new WeakMap();
|
|
7
8
|
let sparklineId = 0;
|
|
8
9
|
const svgNamespace = 'http://www.w3.org/2000/svg';
|
|
9
|
-
const outlineStar = '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';
|
|
10
|
-
const solidStar = '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';
|
|
11
10
|
function columnsSignature(columns) {
|
|
12
11
|
let signature = columnSignatures.get(columns);
|
|
13
12
|
if (signature === undefined) {
|
|
@@ -113,17 +112,10 @@ function action(element, key, label, slot) {
|
|
|
113
112
|
flexShrink: '0'
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
|
-
function icon(document,
|
|
117
|
-
const svg = document
|
|
118
|
-
svg.setAttribute('viewBox', '0 0 24 24');
|
|
115
|
+
function icon(document, name, size) {
|
|
116
|
+
const svg = createNamedIcon(document, name);
|
|
119
117
|
svg.setAttribute('width', String(size));
|
|
120
118
|
svg.setAttribute('height', String(size));
|
|
121
|
-
svg.setAttribute('aria-hidden', 'true');
|
|
122
|
-
svg.setAttribute('fill', 'currentColor');
|
|
123
|
-
const path = document.createElementNS(svgNamespace, 'path');
|
|
124
|
-
path.setAttribute('d', d);
|
|
125
|
-
path.setAttribute('fill-rule', 'evenodd');
|
|
126
|
-
svg.appendChild(path);
|
|
127
119
|
return svg;
|
|
128
120
|
}
|
|
129
121
|
function drawSparkline(element, cell) {
|
|
@@ -203,11 +195,32 @@ function updateCell(view, cell, primitives, index) {
|
|
|
203
195
|
if (cell.kind === 'asset') {
|
|
204
196
|
const visualKey = JSON.stringify(cell.leading);
|
|
205
197
|
if (view.visualKey !== visualKey) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
198
|
+
const visualImageKey = JSON.stringify(cell.leading?.kind === 'token' ? {
|
|
199
|
+
...cell.leading,
|
|
200
|
+
overlays: undefined
|
|
201
|
+
} : cell.leading);
|
|
202
|
+
if (view.visual && cell.leading?.kind === 'token' && view.visualImageKey === visualImageKey) {
|
|
203
|
+
// Keep the main frame: its load/error callbacks own its visibility.
|
|
204
|
+
for (const overlay of view.visual.querySelectorAll(':scope > .ok-native-list-visual-overlay')) {
|
|
205
|
+
primitives.dispose(overlay);
|
|
206
|
+
overlay.remove();
|
|
207
|
+
}
|
|
208
|
+
const overlayVisual = primitives.visual({
|
|
209
|
+
kind: 'token',
|
|
210
|
+
overlays: cell.leading.overlays
|
|
211
|
+
});
|
|
212
|
+
if (overlayVisual) {
|
|
213
|
+
for (const overlay of overlayVisual.querySelectorAll(':scope > .ok-native-list-visual-overlay')) view.visual.appendChild(overlay);
|
|
214
|
+
primitives.dispose(overlayVisual);
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
if (view.visual) {
|
|
218
|
+
primitives.dispose(view.visual);
|
|
219
|
+
view.visual.remove();
|
|
220
|
+
}
|
|
221
|
+
view.visual = primitives.visual(cell.leading);
|
|
209
222
|
}
|
|
210
|
-
view.
|
|
223
|
+
view.visualImageKey = visualImageKey;
|
|
211
224
|
view.visualKey = visualKey;
|
|
212
225
|
if (view.visual) Object.assign(view.visual.style, {
|
|
213
226
|
width: '40px',
|
|
@@ -239,6 +252,7 @@ function updateCell(view, cell, primitives, index) {
|
|
|
239
252
|
view.resting?.replaceChildren(...(cell.secondary ?? []).map(part => textPart(document, part, true)));
|
|
240
253
|
if (view.hover) {
|
|
241
254
|
const button = view.hover.querySelector('button');
|
|
255
|
+
view.hover.parentElement?.querySelector('button')?.setAttribute('aria-label', cell.hoverActionLabel ?? 'Copy address');
|
|
242
256
|
for (const child of [...view.hover.children]) if (child !== button) child.remove();
|
|
243
257
|
for (const part of cell.hoverSecondary ?? []) view.hover.insertBefore(textPart(document, part, true), button);
|
|
244
258
|
}
|
|
@@ -330,7 +344,7 @@ function updateCell(view, cell, primitives, index) {
|
|
|
330
344
|
}[badge.style?.fontWeight ?? 'regular']);
|
|
331
345
|
if (badge.actionKey) node.dataset.nativeListHoverAction = 'true';
|
|
332
346
|
node.textContent = '';
|
|
333
|
-
const svg = icon(document, '
|
|
347
|
+
const svg = icon(document, 'BadgeRecognizedSolid', 14);
|
|
334
348
|
node.appendChild(svg);
|
|
335
349
|
}
|
|
336
350
|
title.appendChild(node);
|
|
@@ -431,7 +445,7 @@ function updateCell(view, cell, primitives, index) {
|
|
|
431
445
|
action(button, cell.hoverActionKey, cell.hoverActionLabel ?? 'Copy address', index);
|
|
432
446
|
button.style.padding = '0';
|
|
433
447
|
button.style.color = 'var(--nl-icon-subdued)';
|
|
434
|
-
button.appendChild(icon(document, '
|
|
448
|
+
button.appendChild(icon(document, 'Copy3Outline', 14));
|
|
435
449
|
hoverFrame.appendChild(button);
|
|
436
450
|
}
|
|
437
451
|
track.appendChild(hoverFrame);
|
|
@@ -454,10 +468,14 @@ function updateCell(view, cell, primitives, index) {
|
|
|
454
468
|
button.style.color = cell.active ? 'var(--nl-accent)' : 'var(--nl-icon-subdued)';
|
|
455
469
|
let svg = button.querySelector('svg');
|
|
456
470
|
if (!svg) {
|
|
457
|
-
svg = icon(document, cell.active ?
|
|
471
|
+
svg = icon(document, cell.active ? 'StarSolid' : 'StarOutline', 16);
|
|
458
472
|
button.appendChild(svg);
|
|
459
473
|
}
|
|
460
|
-
|
|
474
|
+
const name = cell.active ? 'StarSolid' : 'StarOutline';
|
|
475
|
+
if (!svg.querySelector('use')?.getAttribute('href')?.endsWith(`#onekey-${name}`)) {
|
|
476
|
+
const replacement = icon(document, name, 16);
|
|
477
|
+
svg.replaceWith(replacement);
|
|
478
|
+
}
|
|
461
479
|
if (!button.parentElement) element.appendChild(button);
|
|
462
480
|
} else if (cell.kind === 'sparkline') drawSparkline(element, cell);else {
|
|
463
481
|
element.replaceChildren();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { createNamedIcon } from '@onekeyfe/react-native-image/icon/dom';
|
|
3
4
|
const views = new WeakMap();
|
|
4
5
|
function bindLegacy(body, row, primitives) {
|
|
5
6
|
const v = views.get(body);
|
|
@@ -122,7 +123,7 @@ function recycleLegacy(body) {
|
|
|
122
123
|
v.imageKey = v.networkKey = '';
|
|
123
124
|
}
|
|
124
125
|
const galleries = new WeakMap();
|
|
125
|
-
const isGalleryMedia = row => row.variant === 'gallery' && !row.image;
|
|
126
|
+
const isGalleryMedia = row => row.variant === 'gallery' && (!row.image || !!row.media && !row.imageState);
|
|
126
127
|
function clearGalleryMedia(v) {
|
|
127
128
|
v.epoch += 1;
|
|
128
129
|
v.frame.style.borderRadius = '10px';
|
|
@@ -148,18 +149,7 @@ function initGallery(body, primitives) {
|
|
|
148
149
|
};
|
|
149
150
|
const frame = element('ok-native-list-media-image');
|
|
150
151
|
const fallback = element('ok-native-list-media-fallback');
|
|
151
|
-
const svg = document
|
|
152
|
-
svg.setAttribute('viewBox', '0 0 24 24');
|
|
153
|
-
svg.setAttribute('width', '24');
|
|
154
|
-
svg.setAttribute('height', '24');
|
|
155
|
-
svg.setAttribute('aria-hidden', 'true');
|
|
156
|
-
svg.setAttribute('fill', 'currentColor');
|
|
157
|
-
for (const d of ['M14.25 7a2 2 0 1 1 0 4 2 2 0 0 1 0-4', 'M21 21H3V3h18zM5 16.414V19h12.586L14 15.414l-2 2-4-4zm0-2.828 3-3 4 4 2-2 5 5V5H5z']) {
|
|
158
|
-
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
159
|
-
path.setAttribute('d', d);
|
|
160
|
-
path.setAttribute('fill-rule', 'evenodd');
|
|
161
|
-
svg.append(path);
|
|
162
|
-
}
|
|
152
|
+
const svg = createNamedIcon(document, 'ImageSquareWavesOutline');
|
|
163
153
|
fallback.append(svg);
|
|
164
154
|
Object.assign(fallback.style, {
|
|
165
155
|
position: 'absolute',
|
|
@@ -249,7 +239,7 @@ function bindGallery(body, row, primitives) {
|
|
|
249
239
|
v.mediaKey = mediaKey;
|
|
250
240
|
v.fallback.style.visibility = 'visible';
|
|
251
241
|
const epoch = v.epoch;
|
|
252
|
-
const source = row.media?.source;
|
|
242
|
+
const source = row.imageState ? undefined : row.media?.source;
|
|
253
243
|
const probe = attempt => {
|
|
254
244
|
if (v.epoch !== epoch) return;
|
|
255
245
|
const kind = row.media?.probeOrder[attempt];
|
|
@@ -46,6 +46,7 @@ export function bindMessageRow(body, row, primitives) {
|
|
|
46
46
|
body.style.cssText = '';
|
|
47
47
|
body.removeAttribute('data-nl-container-background');
|
|
48
48
|
body.removeAttribute('data-nl-container-border');
|
|
49
|
+
if (row.presentation === 'inlineWarning') body.setAttribute('data-nl-inline-warning', 'true');else body.removeAttribute('data-nl-inline-warning');
|
|
49
50
|
body.style.padding = `${resolved.verticalPadding}px ${resolved.horizontalPadding}px`;
|
|
50
51
|
body.style.height = resolved.automaticHeight ? 'auto' : '100%';
|
|
51
52
|
views.column.style.cssText = '';
|
|
@@ -53,7 +54,22 @@ export function bindMessageRow(body, row, primitives) {
|
|
|
53
54
|
for (const [view, text] of [[views.title, resolved.title], [views.body, resolved.body], [views.time, resolved.time]]) {
|
|
54
55
|
view.style.cssText = '';
|
|
55
56
|
view.textContent = text.value;
|
|
56
|
-
|
|
57
|
+
const {
|
|
58
|
+
lines,
|
|
59
|
+
...textStyle
|
|
60
|
+
} = text.style;
|
|
61
|
+
primitives.textStyle(view, lines === 0 ? textStyle : {
|
|
62
|
+
...textStyle,
|
|
63
|
+
lines
|
|
64
|
+
});
|
|
65
|
+
if (lines === 0) {
|
|
66
|
+
view.style.whiteSpace = 'pre-wrap';
|
|
67
|
+
view.style.overflow = 'visible';
|
|
68
|
+
view.style.textOverflow = 'clip';
|
|
69
|
+
view.style.maxHeight = 'none';
|
|
70
|
+
view.style.removeProperty('-webkit-line-clamp');
|
|
71
|
+
view.style.removeProperty('-webkit-box-orient');
|
|
72
|
+
}
|
|
57
73
|
}
|
|
58
74
|
views.unread.style.cssText = '';
|
|
59
75
|
if (row.body) {
|
|
@@ -143,7 +159,7 @@ export function measureMessageRow(row, availableWidth) {
|
|
|
143
159
|
if (!text.value) return 0;
|
|
144
160
|
const value = text.style.lines === 1 ? text.value.replace(/\r\n|[\r\n]/g, ' ') : text.value;
|
|
145
161
|
const lines = value.split(/\r\n|[\r\n]/).reduce((total, line) => total + Math.max(1, Math.ceil(Array.from(line).reduce((sum, char) => sum + (char.charCodeAt(0) > 255 ? text.style.fontSize : text.style.fontSize / 2), 0) / Math.max(1, width))), 0);
|
|
146
|
-
return Math.min(text.style.lines, lines) * text.style.lineHeight;
|
|
162
|
+
return (text.style.lines === 0 ? lines : Math.min(text.style.lines, lines)) * text.style.lineHeight;
|
|
147
163
|
};
|
|
148
164
|
const timeWidth = Math.min(availableWidth / 3, Math.max(0, r.time.value.length * r.time.style.fontSize / 2));
|
|
149
165
|
const textWidth = availableWidth - r.horizontalPadding * 2 - (row.leading ? r.imageWidth + r.leadingGap : 0) - (row.thumbnail ? 76 : 0) - (row.unread ? 19 : 0) - timeWidth - 12;
|
|
@@ -66,6 +66,7 @@ export function applyRowContainerStyle(body, row) {
|
|
|
66
66
|
body.style.removeProperty('background-color');
|
|
67
67
|
}
|
|
68
68
|
if (container.cornerRadius !== undefined) set(body, 'border-radius', `${container.cornerRadius}px`);
|
|
69
|
+
if (row.type === 'message' && row.presentation === 'inlineWarning') set(body, 'border-radius', '0px');
|
|
69
70
|
if (container.borderWidth !== undefined) {
|
|
70
71
|
// Paint above member backgrounds without changing the content box or hit targets.
|
|
71
72
|
body.setAttribute('data-nl-container-border', 'true');
|
|
@@ -10,6 +10,7 @@ import { dataRowRenderer } from "./DataRowRenderer.js";
|
|
|
10
10
|
import { activityRowRenderer } from "./ActivityRowRenderer.js";
|
|
11
11
|
import { systemRowRenderer } from "./SystemRowRenderer.js";
|
|
12
12
|
import { actionRowRenderer } from "./ActionRowRenderer.js";
|
|
13
|
+
import { buttonGroupRowRenderer } from "./ButtonGroupRowRenderer.js";
|
|
13
14
|
import { mediaTileRowRenderer } from "./MediaTileRowRenderer.js";
|
|
14
15
|
import { messageRowRenderer } from "./MessageRowRenderer.js";
|
|
15
16
|
import { railRowRenderer } from "./RailRowRenderer.js";
|
|
@@ -34,6 +35,7 @@ const factories = {
|
|
|
34
35
|
activity: row => registration(activityRowRenderer, row),
|
|
35
36
|
system: row => registration(systemRowRenderer, row),
|
|
36
37
|
action: row => registration(actionRowRenderer, row),
|
|
38
|
+
buttonGroup: row => registration(buttonGroupRowRenderer, row),
|
|
37
39
|
message: row => registration(messageRowRenderer, row),
|
|
38
40
|
rail: row => registration(railRowRenderer, row),
|
|
39
41
|
mediaTile: row => registration(mediaTileRowRenderer, row)
|
|
@@ -49,6 +51,7 @@ const renderers = {
|
|
|
49
51
|
activity: activityRowRenderer,
|
|
50
52
|
system: systemRowRenderer,
|
|
51
53
|
action: actionRowRenderer,
|
|
54
|
+
buttonGroup: buttonGroupRowRenderer,
|
|
52
55
|
message: messageRowRenderer,
|
|
53
56
|
rail: railRowRenderer,
|
|
54
57
|
mediaTile: mediaTileRowRenderer
|
|
@@ -4,6 +4,20 @@ import { applyTextWeight } from "./RowText.js";
|
|
|
4
4
|
import { applyTabularNumbers, hasExplicitRowHeight } from "./RowElements.js";
|
|
5
5
|
import { createElement, setData, tagSlot, markActionAnchorSource, createTextColumn } from "./RowElements.js";
|
|
6
6
|
import { applyValueSegments } from "./RowText.js";
|
|
7
|
+
function bindHelp(target, help) {
|
|
8
|
+
markActionAnchorSource(target, 'trailingAccessory', 0);
|
|
9
|
+
if (help.presentation === 'tooltip') {
|
|
10
|
+
setData(target, 'nativeListHoverAction', help.actionKey);
|
|
11
|
+
setData(target, 'nativeListIconHelp', true);
|
|
12
|
+
} else {
|
|
13
|
+
setData(target, 'nativeListAction', help.actionKey);
|
|
14
|
+
target.setAttribute('role', 'button');
|
|
15
|
+
}
|
|
16
|
+
if (help.underline === 'dashed') {
|
|
17
|
+
target.style.textDecoration = 'underline dashed';
|
|
18
|
+
target.style.textUnderlineOffset = '4px';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
7
21
|
function createSectionHeader(document, primitives, row) {
|
|
8
22
|
const body = createElement(document, 'div', 'ok-native-list-row ok-native-list-section');
|
|
9
23
|
setData(body, 'variant', row.variant);
|
|
@@ -17,6 +31,11 @@ function createSectionHeader(document, primitives, row) {
|
|
|
17
31
|
const column = createTextColumn(document, row.title, row.subtitle);
|
|
18
32
|
const title = column.firstElementChild;
|
|
19
33
|
title.classList.add('ok-native-list-section-title');
|
|
34
|
+
if (row.leadingBadge) {
|
|
35
|
+
const badge = createElement(document, 'span', 'ok-native-list-badge', row.leadingBadge.text);
|
|
36
|
+
if (row.leadingBadge.tone) setData(badge, 'tone', row.leadingBadge.tone);
|
|
37
|
+
body.appendChild(badge);
|
|
38
|
+
}
|
|
20
39
|
if (row.titleActionKey) {
|
|
21
40
|
setData(title, 'nativeListAction', row.titleActionKey);
|
|
22
41
|
markActionAnchorSource(title, 'leadingAction');
|
|
@@ -31,6 +50,11 @@ function createSectionHeader(document, primitives, row) {
|
|
|
31
50
|
}
|
|
32
51
|
if (row.titleActionOnHover) setData(title, 'nativeListHoverAction', true);
|
|
33
52
|
}
|
|
53
|
+
if (row.style?.titleDecoration === 'none') title.style.textDecoration = 'none';
|
|
54
|
+
if (row.style?.titleDecoration === 'dashed') {
|
|
55
|
+
title.style.textDecoration = 'underline dashed';
|
|
56
|
+
title.style.textUnderlineOffset = '4px';
|
|
57
|
+
}
|
|
34
58
|
if (row.presentation === 'networkSelector' && hasExplicitRowHeight(row)) {
|
|
35
59
|
body.style.padding = row.variant === 'summary' ? '24px 12px 20px' : '0 12px';
|
|
36
60
|
body.style.backgroundColor = 'var(--nl-bg)';
|
|
@@ -108,7 +132,7 @@ function createSectionHeader(document, primitives, row) {
|
|
|
108
132
|
body.appendChild(pendingLine);
|
|
109
133
|
} else body.appendChild(column);
|
|
110
134
|
if (row.value) {
|
|
111
|
-
const value = tagSlot(createElement(document, row.valueActionKey ? 'button' : 'span', row.valueActionKey ? 'ok-native-list-action-button ok-native-list-section-value' : 'ok-native-list-value ok-native-list-section-value', row.value), 'value');
|
|
135
|
+
const value = tagSlot(createElement(document, row.valueActionKey || row.valueHelp?.presentation === 'popover' ? 'button' : 'span', row.valueActionKey || row.valueHelp?.presentation === 'popover' ? 'ok-native-list-action-button ok-native-list-section-value' : 'ok-native-list-value ok-native-list-section-value', row.value), 'value');
|
|
112
136
|
applyValueSegments(value, row.valueSegments);
|
|
113
137
|
if (row.presentation === 'networkSelector' && hasExplicitRowHeight(row)) {
|
|
114
138
|
value.style.fontFamily = 'inherit';
|
|
@@ -127,7 +151,17 @@ function createSectionHeader(document, primitives, row) {
|
|
|
127
151
|
setData(value, 'nativeListAction', row.valueActionKey);
|
|
128
152
|
markActionAnchorSource(value, 'trailingAccessory', 0);
|
|
129
153
|
}
|
|
130
|
-
|
|
154
|
+
if (row.valueHelp) bindHelp(value, row.valueHelp);
|
|
155
|
+
if (row.style?.valuePlacement === 'afterTitle') {
|
|
156
|
+
value.style.marginLeft = '0';
|
|
157
|
+
value.style.flexShrink = '0';
|
|
158
|
+
value.style.alignSelf = 'center';
|
|
159
|
+
title.insertAdjacentElement('afterend', value);
|
|
160
|
+
column.style.flexDirection = 'row';
|
|
161
|
+
column.style.alignItems = 'center';
|
|
162
|
+
column.style.justifyContent = 'flex-start';
|
|
163
|
+
column.style.gap = '8px';
|
|
164
|
+
} else body.appendChild(value);
|
|
131
165
|
}
|
|
132
166
|
if (row.valueIcon) {
|
|
133
167
|
const valueIcon = primitives.iconAction(row.valueIcon.name, row.valueIcon.actionKey, row.valueIcon.disabled, row.valueIcon.tintColor);
|
|
@@ -88,6 +88,15 @@ namespace margelo::nitro::nativelist {
|
|
|
88
88
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* containerSlotHeightsJson */)>("setContainerSlotHeightsJson");
|
|
89
89
|
method(_javaPart, jni::make_jstring(containerSlotHeightsJson));
|
|
90
90
|
}
|
|
91
|
+
std::string JHybridNativeListSpec::getSidecarLayoutJson() {
|
|
92
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getSidecarLayoutJson");
|
|
93
|
+
auto __result = method(_javaPart);
|
|
94
|
+
return __result->toStdString();
|
|
95
|
+
}
|
|
96
|
+
void JHybridNativeListSpec::setSidecarLayoutJson(const std::string& sidecarLayoutJson) {
|
|
97
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* sidecarLayoutJson */)>("setSidecarLayoutJson");
|
|
98
|
+
method(_javaPart, jni::make_jstring(sidecarLayoutJson));
|
|
99
|
+
}
|
|
91
100
|
NativeListScrollEdgeEffect JHybridNativeListSpec::getTopScrollEdgeEffect() {
|
|
92
101
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JNativeListScrollEdgeEffect>()>("getTopScrollEdgeEffect");
|
|
93
102
|
auto __result = method(_javaPart);
|
|
@@ -252,6 +261,23 @@ namespace margelo::nitro::nativelist {
|
|
|
252
261
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onVisibleRangeChanged */)>("setOnVisibleRangeChanged_cxx");
|
|
253
262
|
method(_javaPart, onVisibleRangeChanged.has_value() ? JFunc_void_std__string_cxx::fromCpp(onVisibleRangeChanged.value()) : nullptr);
|
|
254
263
|
}
|
|
264
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnStructuralTransitionSettled() {
|
|
265
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnStructuralTransitionSettled_cxx");
|
|
266
|
+
auto __result = method(_javaPart);
|
|
267
|
+
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
|
|
268
|
+
if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
|
|
269
|
+
auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
|
|
270
|
+
return downcast->cthis()->getFunction();
|
|
271
|
+
} else {
|
|
272
|
+
auto __resultRef = jni::make_global(__result);
|
|
273
|
+
return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
|
|
274
|
+
}
|
|
275
|
+
}()) : std::nullopt;
|
|
276
|
+
}
|
|
277
|
+
void JHybridNativeListSpec::setOnStructuralTransitionSettled(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onStructuralTransitionSettled) {
|
|
278
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onStructuralTransitionSettled */)>("setOnStructuralTransitionSettled_cxx");
|
|
279
|
+
method(_javaPart, onStructuralTransitionSettled.has_value() ? JFunc_void_std__string_cxx::fromCpp(onStructuralTransitionSettled.value()) : nullptr);
|
|
280
|
+
}
|
|
255
281
|
|
|
256
282
|
// Methods
|
|
257
283
|
void JHybridNativeListSpec::applySnapshot(const std::string& snapshotJson) {
|
|
@@ -56,6 +56,8 @@ namespace margelo::nitro::nativelist {
|
|
|
56
56
|
void setFontFamiliesJson(const std::string& fontFamiliesJson) override;
|
|
57
57
|
std::string getContainerSlotHeightsJson() override;
|
|
58
58
|
void setContainerSlotHeightsJson(const std::string& containerSlotHeightsJson) override;
|
|
59
|
+
std::string getSidecarLayoutJson() override;
|
|
60
|
+
void setSidecarLayoutJson(const std::string& sidecarLayoutJson) override;
|
|
59
61
|
NativeListScrollEdgeEffect getTopScrollEdgeEffect() override;
|
|
60
62
|
void setTopScrollEdgeEffect(NativeListScrollEdgeEffect topScrollEdgeEffect) override;
|
|
61
63
|
double getTopOverlayHeight() override;
|
|
@@ -80,6 +82,8 @@ namespace margelo::nitro::nativelist {
|
|
|
80
82
|
void setOnEndReached(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onEndReached) override;
|
|
81
83
|
std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnVisibleRangeChanged() override;
|
|
82
84
|
void setOnVisibleRangeChanged(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onVisibleRangeChanged) override;
|
|
85
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnStructuralTransitionSettled() override;
|
|
86
|
+
void setOnStructuralTransitionSettled(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onStructuralTransitionSettled) override;
|
|
83
87
|
|
|
84
88
|
public:
|
|
85
89
|
// Methods
|
|
@@ -68,6 +68,11 @@ void JHybridNativeListStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
|
|
|
68
68
|
: !newProps->containerSlotHeightsJson.hasSameValue(oldProps->containerSlotHeightsJson)) {
|
|
69
69
|
hybridView->setContainerSlotHeightsJson(newProps->containerSlotHeightsJson.get());
|
|
70
70
|
}
|
|
71
|
+
if (oldProps == nullptr
|
|
72
|
+
? newProps->sidecarLayoutJson.isProvided()
|
|
73
|
+
: !newProps->sidecarLayoutJson.hasSameValue(oldProps->sidecarLayoutJson)) {
|
|
74
|
+
hybridView->setSidecarLayoutJson(newProps->sidecarLayoutJson.get());
|
|
75
|
+
}
|
|
71
76
|
if (oldProps == nullptr
|
|
72
77
|
? newProps->topScrollEdgeEffect.isProvided()
|
|
73
78
|
: !newProps->topScrollEdgeEffect.hasSameValue(oldProps->topScrollEdgeEffect)) {
|
|
@@ -128,6 +133,11 @@ void JHybridNativeListStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
|
|
|
128
133
|
: !newProps->onVisibleRangeChanged.hasSameValue(oldProps->onVisibleRangeChanged)) {
|
|
129
134
|
hybridView->setOnVisibleRangeChanged(newProps->onVisibleRangeChanged.get());
|
|
130
135
|
}
|
|
136
|
+
if (oldProps == nullptr
|
|
137
|
+
? newProps->onStructuralTransitionSettled.isProvided()
|
|
138
|
+
: !newProps->onStructuralTransitionSettled.hasSameValue(oldProps->onStructuralTransitionSettled)) {
|
|
139
|
+
hybridView->setOnStructuralTransitionSettled(newProps->onStructuralTransitionSettled.get());
|
|
140
|
+
}
|
|
131
141
|
|
|
132
142
|
// Update hybridRef if it changed
|
|
133
143
|
if (oldProps == nullptr
|
package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt
CHANGED
|
@@ -45,6 +45,12 @@ abstract class HybridNativeListSpec: HybridView() {
|
|
|
45
45
|
@set:Keep
|
|
46
46
|
abstract var containerSlotHeightsJson: String
|
|
47
47
|
|
|
48
|
+
@get:DoNotStrip
|
|
49
|
+
@get:Keep
|
|
50
|
+
@set:DoNotStrip
|
|
51
|
+
@set:Keep
|
|
52
|
+
abstract var sidecarLayoutJson: String
|
|
53
|
+
|
|
48
54
|
@get:DoNotStrip
|
|
49
55
|
@get:Keep
|
|
50
56
|
@set:DoNotStrip
|
|
@@ -172,6 +178,20 @@ abstract class HybridNativeListSpec: HybridView() {
|
|
|
172
178
|
set(value) {
|
|
173
179
|
onVisibleRangeChanged = value?.let { it }
|
|
174
180
|
}
|
|
181
|
+
|
|
182
|
+
abstract var onStructuralTransitionSettled: ((payloadJson: String) -> Unit)?
|
|
183
|
+
|
|
184
|
+
private var onStructuralTransitionSettled_cxx: Func_void_std__string?
|
|
185
|
+
@Keep
|
|
186
|
+
@DoNotStrip
|
|
187
|
+
get() {
|
|
188
|
+
return onStructuralTransitionSettled?.let { Func_void_std__string_java(it) }
|
|
189
|
+
}
|
|
190
|
+
@Keep
|
|
191
|
+
@DoNotStrip
|
|
192
|
+
set(value) {
|
|
193
|
+
onStructuralTransitionSettled = value?.let { it }
|
|
194
|
+
}
|
|
175
195
|
|
|
176
196
|
// Methods
|
|
177
197
|
@DoNotStrip
|