@onekeyfe/react-native-native-list 6.7.0-1 → 6.7.0-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +1 -1
- package/docs/SPEC.md +449 -14
- package/ios/HybridNativeList.swift +11 -3
- package/ios/RNCNativeListView.swift +10 -6
- package/ios/tests/NativeListLifecycleTests.swift +28 -0
- package/lib/module/NativeList.js +42 -21
- package/lib/module/NativeList.web.js +163 -32
- package/lib/module/ScrollEdgeEffect.js +8 -0
- package/lib/module/index.js +1 -0
- package/lib/module/validation.js +358 -47
- package/lib/module/web/NativeListWebEngine.js +373 -67
- package/lib/module/web/templates/ActivityRowRenderer.js +484 -5
- package/lib/module/web/templates/MarketRowRenderer.js +8 -3
- package/lib/module/web/templates/MarketTableRowRenderer.js +577 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
- package/lib/module/web/templates/RowRendererRegistry.js +5 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +34 -1
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +10 -6
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -2
- package/lib/nitrogen/generated/android/c++/JNativeListScrollEdgeEffect.hpp +61 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +3 -3
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +1 -1
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollEdgeEffect.kt +24 -0
- package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +3 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +8 -4
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +4 -4
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -1
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +3 -3
- package/lib/nitrogen/generated/ios/swift/NativeListScrollEdgeEffect.swift +44 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -2
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +5 -2
- package/lib/nitrogen/generated/shared/c++/NativeListScrollEdgeEffect.hpp +80 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +4 -3
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +1 -1
- package/lib/typescript/src/NativeList.d.ts +2 -2
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -1
- package/lib/typescript/src/NativeList.types.d.ts +14 -3
- package/lib/typescript/src/NativeList.web.d.ts +2 -2
- package/lib/typescript/src/ScrollEdgeEffect.d.ts +5 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/models.d.ts +71 -1
- package/lib/typescript/src/validation.d.ts +3 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +26 -1
- package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
- package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +10 -6
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -2
- package/nitrogen/generated/android/c++/JNativeListScrollEdgeEffect.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +3 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollEdgeEffect.kt +24 -0
- package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +8 -4
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +4 -4
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +3 -3
- package/nitrogen/generated/ios/swift/NativeListScrollEdgeEffect.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -2
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +5 -2
- package/nitrogen/generated/shared/c++/NativeListScrollEdgeEffect.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -2
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +4 -3
- package/nitrogen/generated/shared/json/NativeListConfig.json +1 -1
- package/package.json +3 -3
- package/react-native-native-list.podspec +4 -1
- package/src/NativeList.nitro.ts +3 -1
- package/src/NativeList.tsx +102 -60
- package/src/NativeList.types.ts +15 -3
- package/src/NativeList.web.tsx +264 -65
- package/src/ScrollEdgeEffect.ts +4 -0
- package/src/index.ts +2 -0
- package/src/models.ts +93 -0
- package/src/validation.ts +785 -72
- package/src/web/NativeListWebEngine.ts +625 -100
- package/src/web/templates/ActivityRowRenderer.ts +723 -7
- package/src/web/templates/MarketRowRenderer.ts +19 -3
- package/src/web/templates/MarketTableRowRenderer.ts +755 -0
- package/src/web/templates/MediaTileRowRenderer.ts +313 -5
- package/src/web/templates/RowRendererRegistry.ts +10 -5
- package/src/web/templates/SectionHeaderRowRenderer.ts +42 -1
|
@@ -6,6 +6,10 @@ import {
|
|
|
6
6
|
import { hasExplicitRowHeight, rowSizeModifier } from './templates/RowElements';
|
|
7
7
|
import { applyTextStyleToSlot, applyValueSegments } from './templates/RowText';
|
|
8
8
|
import { setMarketQuoteContent } from './templates/MarketRowRenderer';
|
|
9
|
+
import {
|
|
10
|
+
canPatchMarketTableValues,
|
|
11
|
+
updateMarketTableValues,
|
|
12
|
+
} from './templates/MarketTableRowRenderer';
|
|
9
13
|
export {
|
|
10
14
|
resolveWebMarketLayoutStyle,
|
|
11
15
|
type WebMarketLayoutStyle,
|
|
@@ -56,7 +60,13 @@ import {
|
|
|
56
60
|
validateOffset,
|
|
57
61
|
type NormalizedPositionScroll,
|
|
58
62
|
} from '../scrolling';
|
|
59
|
-
import {
|
|
63
|
+
import {
|
|
64
|
+
applyRowPatches,
|
|
65
|
+
containNativeListInput,
|
|
66
|
+
emptyNativeListSnapshot,
|
|
67
|
+
validatePatches,
|
|
68
|
+
validateSnapshot,
|
|
69
|
+
} from '../validation';
|
|
60
70
|
import { avatarPrefetchWindow } from '../avatarPrefetch';
|
|
61
71
|
import {
|
|
62
72
|
acquireNativeListAvatar,
|
|
@@ -311,6 +321,7 @@ export function isWebRowReorderable(
|
|
|
311
321
|
if (row.type === 'rail' && row.draggable) return true;
|
|
312
322
|
if (row.type === 'identity' && row.draggable) return true;
|
|
313
323
|
if (row.type === 'walletGroup' && row.draggable) return true;
|
|
324
|
+
if (row.type === 'market' && row.webTable?.draggable) return true;
|
|
314
325
|
return (
|
|
315
326
|
(row.type === 'identity' || row.type === 'action') &&
|
|
316
327
|
Boolean(row.trailing?.some((accessory) => accessory.kind === 'drag'))
|
|
@@ -563,9 +574,7 @@ export function computeWebListLayout(
|
|
|
563
574
|
}
|
|
564
575
|
|
|
565
576
|
const columns = snapshot.layout.gridColumns ?? 2;
|
|
566
|
-
const itemWidth =
|
|
567
|
-
(availableWidth - spacing * (columns - 1)) / columns
|
|
568
|
-
);
|
|
577
|
+
const itemWidth = (availableWidth - spacing * (columns - 1)) / columns;
|
|
569
578
|
let y = padding.top;
|
|
570
579
|
let column = 0;
|
|
571
580
|
let bandStart = y;
|
|
@@ -789,12 +798,15 @@ export function webMarketImageBindDeltaForPatches(
|
|
|
789
798
|
|
|
790
799
|
// OneKey patch: selector names must shrink before the sidebar clips their contents.
|
|
791
800
|
export const WEB_LIST_CSS = `
|
|
801
|
+
.ok-native-list-table-secondary{display:block;min-width:0;overflow:clip}.ok-native-list-table-secondary-track{display:flex;flex-direction:column;transition:transform 100ms ease}.ok-native-list-market-table:focus-within .ok-native-list-table-secondary[data-has-hover="true"]>.ok-native-list-table-secondary-track{transform:translateY(calc(-1 * var(--nl-table-secondary-height)))}@media(hover:hover){.ok-native-list-market-table:hover .ok-native-list-table-secondary[data-has-hover="true"]>.ok-native-list-table-secondary-track{transform:translateY(calc(-1 * var(--nl-table-secondary-height)))}}.ok-native-list-market-table button:focus-visible{outline:2px solid var(--nl-accent);outline-offset:1px}.ok-native-list-market-table button:hover{opacity:.75}.ok-native-list-market-table button:active{opacity:.5}
|
|
802
|
+
|
|
792
803
|
[data-native-list-selector="walletSidebar"] .ok-native-list-title{max-width:100%;min-width:0}
|
|
793
|
-
.ok-native-list-root{--nl-bg:#f7f7f7;--nl-row:#fff;--nl-selected:#eaf2ff;--nl-pressed:#e8e8e8;--nl-subdued:#f9f9f9;--nl-strong:#0000000f;--nl-primary:#111;--nl-secondary:#6b7280;--nl-disabled:#8d8d8d;--nl-icon:#111;--nl-icon-subdued:#8d8d8d;--nl-separator:#e5e7eb;--nl-accent:#2f6bff;--nl-positive:#15803d;--nl-negative:#dc2626;--nl-critical:#feecec;--nl-inverse:#202020;--nl-inverse-text:#fcfcfc;--nl-info:#0d74ce;position:absolute;inset:0;display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden;background:var(--nl-bg);color:var(--nl-primary);font-family:var(--nl-font-regular)
|
|
804
|
+
.ok-native-list-root{--nl-bg:#f7f7f7;--nl-row:#fff;--nl-selected:#eaf2ff;--nl-pressed:#e8e8e8;--nl-subdued:#f9f9f9;--nl-strong:#0000000f;--nl-primary:#111;--nl-secondary:#6b7280;--nl-disabled:#8d8d8d;--nl-icon:#111;--nl-icon-subdued:#8d8d8d;--nl-separator:#e5e7eb;--nl-accent:#2f6bff;--nl-positive:#15803d;--nl-negative:#dc2626;--nl-critical:#feecec;--nl-inverse:#202020;--nl-inverse-text:#fcfcfc;--nl-info:#0d74ce;position:absolute;inset:0;display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden;background:var(--nl-bg);color:var(--nl-primary);font-synthesis:none;font-family:var(--nl-font-regular)}
|
|
794
805
|
.ok-native-list-viewport-frame{position:relative;flex:1;min-width:0;min-height:0;overflow:hidden}
|
|
795
806
|
.ok-native-list-viewport{position:absolute;inset:0;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;scrollbar-gutter:stable}
|
|
796
807
|
.ok-native-list-content{position:relative;min-width:100%;min-height:100%}
|
|
797
808
|
.ok-native-list-item{position:absolute;left:0;top:0;box-sizing:border-box;contain:layout paint style;outline:none}
|
|
809
|
+
.ok-native-list-item[data-native-list-media-gallery="true"]{pointer-events:none}.ok-native-list-item[data-native-list-media-gallery="true"]>.ok-native-list-media{pointer-events:auto}
|
|
798
810
|
.ok-native-list-row{width:100%;height:100%;box-sizing:border-box;display:flex;align-items:center;gap:12px;overflow:hidden;background:var(--nl-row);color:var(--nl-primary);cursor:default;user-select:none;-webkit-user-select:none}
|
|
799
811
|
.ok-native-list-item[data-table-alternate="true"]>.ok-native-list-row{background:var(--nl-bg)}
|
|
800
812
|
.ok-native-list-item[data-native-list-selected="true"]>.ok-native-list-row{background:var(--nl-selected)}
|
|
@@ -819,7 +831,7 @@ export const WEB_LIST_CSS = `
|
|
|
819
831
|
.ok-native-list-item[data-native-list-dragging="true"]>.ok-native-list-row>*{visibility:hidden}
|
|
820
832
|
.ok-native-list-item[data-native-list-dragging="true"]>.ok-native-list-wallet-group{border-color:transparent;background:var(--nl-pressed)}
|
|
821
833
|
.ok-native-list-item[data-native-list-dragging="true"]>.ok-native-list-wallet-group>*{visibility:hidden}
|
|
822
|
-
.ok-native-list-reorder-preview{position:fixed;left:0;top:0;z-index:100001;pointer-events:none;overflow:hidden;border-radius:12px;box-shadow:0 4px 24px rgba(0,0,0,.12);transform-origin:center;will-change:transform;font-
|
|
834
|
+
.ok-native-list-reorder-preview{position:fixed;left:0;top:0;z-index:100001;pointer-events:none;overflow:hidden;border-radius:12px;box-shadow:0 4px 24px rgba(0,0,0,.12);transform-origin:center;will-change:transform;font-family:var(--nl-font-regular);font-synthesis:none}
|
|
823
835
|
.ok-native-list-reorder-preview>.ok-native-list-row{background:var(--nl-pressed);cursor:grabbing}
|
|
824
836
|
.ok-native-list-reorder-preview[data-native-list-selected="true"]>.ok-native-list-row{background:var(--nl-selected)}
|
|
825
837
|
.ok-native-list-reorder-count{position:absolute;right:4px;bottom:4px;display:flex;align-items:center;justify-content:center;box-sizing:border-box;min-width:24px;height:24px;padding:0 6px;border:1px solid var(--nl-row);border-radius:12px;background:var(--nl-inverse);color:var(--nl-inverse-text);font-size:12px;line-height:22px;font-weight:600;font-family:var(--nl-font-semibold)}
|
|
@@ -832,29 +844,33 @@ export const WEB_LIST_CSS = `
|
|
|
832
844
|
.ok-native-list-item[data-group-position="single"]>.ok-native-list-row{border-radius:var(--nl-group-radius,12px)}
|
|
833
845
|
.ok-native-list-standard{padding:8px 12px}.ok-native-list-network-row{padding:0 12px}.ok-native-list-wallet-row{padding:4px 8px;flex-direction:column;justify-content:center;gap:4px}.ok-native-list-account-row{padding:4px 12px;gap:8px}
|
|
834
846
|
.ok-native-list-account-row .ok-native-list-visual,.ok-native-list-account-action-row .ok-native-list-visual{width:32px;height:32px;flex-basis:32px}.ok-native-list-account-row .ok-native-list-visual>img,.ok-native-list-account-row .ok-native-list-visual-main,.ok-native-list-account-action-row .ok-native-list-visual>img,.ok-native-list-account-action-row .ok-native-list-visual-main{width:32px;height:32px}.ok-native-list-account-row .ok-native-list-visual>.ok-native-list-visual-corner{width:20px;height:20px;padding:2px}.ok-native-list-account-action-row .ok-native-list-visual{border-radius:8px!important}.ok-native-list-wallet-row .ok-native-list-title{color:var(--nl-secondary);font-size:12px;line-height:16px;font-weight:400;font-family:var(--nl-font-regular)}.ok-native-list-item[data-native-list-selected="true"]>.ok-native-list-wallet-row .ok-native-list-title{color:var(--nl-primary)}.ok-native-list-account-row .ok-native-list-title{font-size:16px;line-height:20px;font-weight:400;font-family:var(--nl-font-regular)}.ok-native-list-account-row .ok-native-list-secondary{font-size:14px;line-height:20px;font-weight:400;font-family:var(--nl-font-regular)}
|
|
835
|
-
.ok-native-list-flex{display:flex;flex:1;min-width:0;flex-direction:column;justify-content:center}.ok-native-list-title{font-size:15px;line-height:20px;font-weight:600;
|
|
847
|
+
.ok-native-list-flex{display:flex;flex:1;min-width:0;flex-direction:column;justify-content:center}.ok-native-list-title{font-size:15px;line-height:20px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:var(--nl-font-semibold)}.ok-native-list-secondary{font-size:13px;line-height:18px;color:var(--nl-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ok-native-list-tertiary{color:var(--nl-secondary)}.ok-native-list-info{color:var(--nl-info)}
|
|
836
848
|
.ok-native-list-identity-row .ok-native-list-title,.ok-native-list-identity-row .ok-native-list-amounts>span:first-child{font-size:16px;line-height:20px}.ok-native-list-identity-row .ok-native-list-secondary{font-size:14px;line-height:20px}
|
|
837
|
-
.ok-native-list-value{font-size:14px;line-height:20px;font-weight:500;font-family:var(--nl-font-medium)
|
|
838
|
-
.ok-native-list-action-button{appearance:none;border:0;background:transparent;padding:2px;color:var(--nl-accent);font:600 12px/16px var(--nl-font-semibold)
|
|
839
|
-
.ok-native-list-visual{position:relative;flex:0 0 40px;width:40px;height:40px;border-radius:20px;overflow:visible;background:var(--nl-strong)}.ok-native-list-visual>img,.ok-native-list-visual-main{display:block;width:40px;height:40px;border-radius:inherit;object-fit:cover}.ok-native-list-visual-fallback{display:flex;width:100%;height:100%;align-items:center;justify-content:center;border-radius:inherit;color:var(--nl-primary);font-size:15px;font-weight:600;font-family:var(--nl-font-semibold)
|
|
840
|
-
.ok-native-list-accessories{display:flex;align-items:center;gap:10px;min-width:0}.ok-native-list-accessory{font-size:14px;color:var(--nl-primary);white-space:nowrap}.ok-native-list-accessory-secondary{color:var(--nl-secondary)}.ok-native-list-icon-button{display:inline-flex;align-items:center;justify-content:center;min-width:24px;height:24px;border:0;background:transparent;color:var(--nl-icon);font-size:20px;line-height:1;font-weight:500;font-family:var(--nl-font-medium)
|
|
849
|
+
.ok-native-list-value{font-size:14px;line-height:20px;font-weight:500;white-space:nowrap;font-family:var(--nl-font-medium)}.ok-native-list-time{font-size:11px;line-height:16px;color:var(--nl-secondary);align-self:flex-start}.ok-native-list-amounts{display:flex;flex-direction:column;align-items:flex-end;min-width:0}.ok-native-list-actions{display:flex;gap:16px;margin-top:6px}
|
|
850
|
+
.ok-native-list-action-button{appearance:none;border:0;background:transparent;padding:2px;color:var(--nl-accent);cursor:pointer;font:600 12px/16px var(--nl-font-semibold)}.ok-native-list-action-button[data-tone="danger"]{color:var(--nl-negative)}.ok-native-list-action-button:disabled{opacity:.5;cursor:default}
|
|
851
|
+
.ok-native-list-visual{position:relative;flex:0 0 40px;width:40px;height:40px;border-radius:20px;overflow:visible;background:var(--nl-strong)}.ok-native-list-visual>img,.ok-native-list-visual-main{display:block;width:40px;height:40px;border-radius:inherit;object-fit:cover}.ok-native-list-visual-fallback{display:flex;width:100%;height:100%;align-items:center;justify-content:center;border-radius:inherit;color:var(--nl-primary);font-size:15px;font-weight:600;overflow:hidden;font-family:var(--nl-font-semibold)}.ok-native-list-visual>.ok-native-list-visual-corner{position:absolute;right:-4px;bottom:-4px;width:18px;height:18px;padding:2px;border-radius:50%;background:var(--nl-row);object-fit:cover}.ok-native-list-stacked{display:flex;align-items:center;width:48px;flex-basis:48px}.ok-native-list-stacked img{width:28px;height:28px;border:2px solid var(--nl-row);border-radius:50%;object-fit:cover;margin-left:-10px}.ok-native-list-stacked img:first-child{margin-left:0}
|
|
852
|
+
.ok-native-list-accessories{display:flex;align-items:center;gap:10px;min-width:0}.ok-native-list-accessory{font-size:14px;color:var(--nl-primary);white-space:nowrap}.ok-native-list-accessory-secondary{color:var(--nl-secondary)}.ok-native-list-icon-button{display:inline-flex;align-items:center;justify-content:center;min-width:24px;height:24px;border:0;background:transparent;color:var(--nl-icon);font-size:20px;line-height:1;font-weight:500;cursor:pointer;font-family:var(--nl-font-medium)}.ok-native-list-checkbox{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;width:20px;height:20px;border:2px solid color-mix(in srgb,var(--nl-primary) 19%,transparent);border-radius:5px;background:var(--nl-row);cursor:pointer}.ok-native-list-checkbox[data-state="checked"],.ok-native-list-checkbox[data-state="indeterminate"]{border-color:transparent;background:var(--nl-primary)}.ok-native-list-checkbox[data-state="checked"]::after{content:"";width:6px;height:10px;margin-top:-2px;border-right:2px solid var(--nl-row);border-bottom:2px solid var(--nl-row);transform:rotate(45deg)}.ok-native-list-checkbox[data-state="indeterminate"]::after{content:"";width:8px;height:2px;border-radius:1px;background:var(--nl-row)}.ok-native-list-spinner{width:16px;height:16px;border:2px solid var(--nl-separator);border-top-color:var(--nl-primary);border-radius:50%;animation:ok-native-list-spin .8s linear infinite}@keyframes ok-native-list-spin{to{transform:rotate(360deg)}}
|
|
841
853
|
.ok-native-list-badge{display:inline-flex;align-items:center;max-width:100%;height:18px;padding:0 5px;border-radius:5px;background:color-mix(in srgb,var(--nl-accent) 12%,transparent);color:var(--nl-accent);font-size:11px;line-height:18px;white-space:nowrap}.ok-native-list-badge[data-tone="danger"]{background:var(--nl-critical);color:var(--nl-negative)}.ok-native-list-badges{display:inline-flex;gap:4px;margin-left:6px;vertical-align:middle}
|
|
842
|
-
.ok-native-list-section{padding:0 8px;background:var(--nl-bg);gap:8px}.ok-native-list-section[data-variant="summary"]{padding:0 20px}.ok-native-list-section[data-variant="gallery"]{padding:0 12px}.ok-native-list-section[data-variant="history"]{padding:0 8px}.ok-native-list-section-title{font-size:13px;line-height:18px;font-weight:700;
|
|
843
|
-
.ok-native-list-action-row{justify-content:space-between;padding:0 16px}.ok-native-list-action-title{font-size:15px;font-weight:600;
|
|
854
|
+
.ok-native-list-section{padding:0 8px;background:var(--nl-bg);gap:8px}.ok-native-list-section[data-variant="summary"]{padding:0 20px}.ok-native-list-section[data-variant="gallery"]{padding:0 12px}.ok-native-list-section[data-variant="history"]{padding:0 8px}.ok-native-list-section-title{font-size:13px;line-height:18px;font-weight:700;color:var(--nl-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:var(--nl-font-bold)}.ok-native-list-section[data-variant="summary"] .ok-native-list-section-title{font-size:16px;font-weight:500;color:var(--nl-primary);font-family:var(--nl-font-medium)}.ok-native-list-section[data-variant="gallery"] .ok-native-list-section-title{font-size:16px;color:var(--nl-primary)}.ok-native-list-section[data-variant="history"] .ok-native-list-section-title{font-size:12px;line-height:16px;letter-spacing:0.8px}.ok-native-list-section-value{margin-left:auto}
|
|
855
|
+
.ok-native-list-action-row{justify-content:space-between;padding:0 16px}.ok-native-list-action-title{font-size:15px;font-weight:600;color:var(--nl-accent);font-family:var(--nl-font-semibold)}.ok-native-list-action-title[data-tone="danger"]{color:var(--nl-negative)}
|
|
844
856
|
.ok-native-list-account-action-row{justify-content:flex-start;gap:12px;padding:0 12px}.ok-native-list-account-action-row .ok-native-list-action-title{color:var(--nl-secondary);font-size:16px;line-height:24px;font-weight:400;font-family:var(--nl-font-regular)}
|
|
845
857
|
.ok-native-list-system{justify-content:center;padding:8px 12px;background:var(--nl-bg);color:var(--nl-secondary);cursor:default}.ok-native-list-system[data-variant="retry"],.ok-native-list-system[data-variant="noMatch"],.ok-native-list-system[data-variant="end"]{justify-content:flex-start}.ok-native-list-system[data-variant="retry"]{cursor:pointer}
|
|
846
|
-
.ok-native-list-rail{padding:4px;gap:6px;border-radius:8px}.ok-native-list-rail .ok-native-list-visual{width:20px;height:20px;flex-basis:20px}.ok-native-list-rail .ok-native-list-visual>img,.ok-native-list-rail .ok-native-list-visual-main{width:20px;height:20px}.ok-native-list-rail-title{font-size:12px;font-weight:500;font-family:var(--nl-font-medium)
|
|
847
|
-
.ok-native-list-media{display:block;padding:0 5px;background:transparent;border-radius:16px}.ok-native-list-media-image{display:block;width:100%;aspect-ratio:1;border-radius:10px;background:var(--nl-strong);object-fit:cover}.ok-native-list-media-image[data-state="empty"]{background:transparent}.ok-native-list-media-image[data-state="error"]{display:flex;align-items:center;justify-content:center;color:var(--nl-icon-subdued);font-size:24px}.ok-native-list-media-meta{padding-top:7px}.ok-native-list-media-subtitle-row{display:flex;align-items:center;gap:6px}.ok-native-list-media-subtitle{flex:1;min-width:0;font-size:12px;color:var(--nl-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ok-native-list-media-network{width:14px;height:14px;border-radius:50%}.ok-native-list-media-title{font-size:16px;font-weight:500;
|
|
858
|
+
.ok-native-list-rail{padding:4px;gap:6px;border-radius:8px}.ok-native-list-rail .ok-native-list-visual{width:20px;height:20px;flex-basis:20px}.ok-native-list-rail .ok-native-list-visual>img,.ok-native-list-rail .ok-native-list-visual-main{width:20px;height:20px}.ok-native-list-rail-title{font-size:12px;font-weight:500;white-space:nowrap;font-family:var(--nl-font-medium)}
|
|
859
|
+
.ok-native-list-media{display:block;padding:0 5px;background:transparent;border-radius:16px}.ok-native-list-media-image{display:block;width:100%;aspect-ratio:1;border-radius:10px;background:var(--nl-strong);object-fit:cover}.ok-native-list-media-image[data-state="empty"]{background:transparent}.ok-native-list-media-image[data-state="error"]{display:flex;align-items:center;justify-content:center;color:var(--nl-icon-subdued);font-size:24px}.ok-native-list-media-meta{padding-top:7px}.ok-native-list-media-subtitle-row{display:flex;align-items:center;gap:6px}.ok-native-list-media-subtitle{flex:1;min-width:0;font-size:12px;color:var(--nl-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ok-native-list-media-network{width:14px;height:14px;border-radius:50%}.ok-native-list-media-title{font-size:16px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:var(--nl-font-medium)}.ok-native-list-media-close{position:absolute;right:9px;top:4px;border:0;background:color-mix(in srgb,var(--nl-inverse) 72%,transparent);color:var(--nl-inverse-text);width:24px;height:24px;border-radius:50%;cursor:pointer;font:18px/20px var(--nl-font-regular)}
|
|
848
860
|
.ok-native-list-metric{display:flex;flex-direction:column;align-items:flex-start;padding:12px;border-radius:12px;gap:5px;background:var(--nl-row)}.ok-native-list-metric-value{font-size:22px;line-height:28px;font-weight:700;font-family:var(--nl-font-bold)}.ok-native-list-composite{display:flex;flex-direction:column;align-items:stretch;padding:14px;border-radius:12px;gap:12px;background:var(--nl-subdued)}.ok-native-list-composite-heading{font-size:14px;letter-spacing:1px;color:var(--nl-secondary)}.ok-native-list-composite-row{display:flex;gap:12px}.ok-native-list-composite-cell{flex:1;min-width:0}.ok-native-list-composite-cell[data-shaded="true"]{padding:10px;border-radius:10px;background:color-mix(in srgb,var(--nl-primary) 5%,transparent)}.ok-native-list-composite-value{font-size:18px;font-weight:600;font-family:var(--nl-font-semibold)}.ok-native-list-divider{height:1px;background:var(--nl-separator)}.ok-native-list-progress{height:4px;border-radius:2px;overflow:hidden;background:var(--nl-negative)}.ok-native-list-progress>span{display:block;height:100%;border-radius:2px;background:var(--nl-positive)}
|
|
849
|
-
.ok-native-list-data{padding:6px 12px}.ok-native-list-index{flex:0 0 28px;color:var(--nl-secondary);font-size:13px}.ok-native-list-favorite{flex:0 0 24px;color:var(--nl-icon-subdued);font-size:22px}.ok-native-list-favorite[data-active="true"]{color:var(--nl-accent)}.ok-native-list-data-cell{display:flex;flex-direction:column;min-width:0}.ok-native-list-data-cell[data-align="center"]{align-items:center}.ok-native-list-data-cell[data-align="end"]{align-items:flex-end}.ok-native-list-data-primary{display:flex;align-items:center;gap:5px;max-width:100%;font-size:16px;font-weight:500;font-family:var(--nl-font-medium)
|
|
850
|
-
.ok-native-list-
|
|
861
|
+
.ok-native-list-data{padding:6px 12px}.ok-native-list-index{flex:0 0 28px;color:var(--nl-secondary);font-size:13px}.ok-native-list-favorite{flex:0 0 24px;color:var(--nl-icon-subdued);font-size:22px}.ok-native-list-favorite[data-active="true"]{color:var(--nl-accent)}.ok-native-list-data-cell{display:flex;flex-direction:column;min-width:0}.ok-native-list-data-cell[data-align="center"]{align-items:center}.ok-native-list-data-cell[data-align="end"]{align-items:flex-end}.ok-native-list-data-primary{display:flex;align-items:center;gap:5px;max-width:100%;font-size:16px;font-weight:500;white-space:nowrap;font-family:var(--nl-font-medium)}.ok-native-list-unread{width:7px;height:7px;flex:0 0 7px;border-radius:50%;background:var(--nl-accent)}.ok-native-list-thumbnail{width:64px;height:64px;border-radius:10px;object-fit:cover}
|
|
862
|
+
.ok-native-list-item[data-native-list-row-press-enabled="true"]:active>.ok-native-list-history{background:var(--nl-selected)}
|
|
863
|
+
.ok-native-list-root[data-native-list-parent-scroll="true"] .ok-native-list-item[data-native-list-row-press-enabled="true"]:active>.ok-native-list-market:not([data-variant="stock"]){opacity:.8}
|
|
864
|
+
.ok-native-list-root[data-native-list-parent-scroll="true"] .ok-native-list-item[data-native-list-row-press-enabled="true"]:active>.ok-native-list-market[data-variant="stock"]{background:var(--nl-selected)}
|
|
865
|
+
.ok-native-list-market-table .ok-native-list-visual-fallback>svg{width:28px;height:28px}
|
|
866
|
+
.ok-native-list-market{padding:12px 20px;gap:14px}.ok-native-list-market>.ok-native-list-visual{width:32px;height:32px;flex-basis:32px}.ok-native-list-market[data-variant="stock"]>.ok-native-list-visual{width:40px;height:40px;flex-basis:40px}.ok-native-list-market>.ok-native-list-visual>.ok-native-list-visual-main{width:100%;height:100%}.ok-native-list-market-main{display:flex;flex:1;min-width:0;flex-direction:column;justify-content:center}.ok-native-list-market-title-line{display:flex;align-items:center;min-width:0;gap:4px}.ok-native-list-market-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--nl-primary);font-size:16px;line-height:24px;font-weight:500;font-family:var(--nl-font-medium)}.ok-native-list-market-subtitle{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--nl-secondary);font-size:14px;line-height:20px;font-weight:400;font-family:var(--nl-font-regular)}.ok-native-list-market-badge{display:inline-flex;flex:0 0 auto;align-items:center;justify-content:center;box-sizing:border-box;max-width:72px;height:18px;padding:0 5px;border:0;border-radius:4px;background:var(--nl-strong);color:var(--nl-secondary);overflow:hidden;white-space:nowrap;font:500 11px/18px var(--nl-font-medium);font-variant-numeric:tabular-nums}.ok-native-list-market-badge img{width:14px;height:14px;object-fit:contain}.ok-native-list-market-trailing{display:flex;flex:0 0 auto;align-items:center;gap:8px}.ok-native-list-market-price{max-width:112px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:right;color:var(--nl-primary);font-size:16px;line-height:24px;font-weight:500;font-variant-numeric:tabular-nums;font-family:var(--nl-font-medium)}.ok-native-list-market-change{display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:80px;height:32px;border-radius:8px;color:#fff;background:#8d8d8d;font-size:14px;line-height:20px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;font-family:var(--nl-font-medium)}.ok-native-list-market-change[data-tone="positive"]{background:var(--nl-positive)}.ok-native-list-market-change[data-tone="negative"]{background:var(--nl-negative)}
|
|
851
867
|
.ok-native-list-market-badge>svg,.ok-native-list-market-badge>.ok-native-list-market-badge-icon>svg{display:block;width:16px;height:16px;flex:0 0 16px}.ok-native-list-system[data-native-list-presentation="market"]{box-sizing:border-box;padding:12px 20px}.ok-native-list-system[data-native-list-presentation="market"]>.ok-native-list-spinner{width:32px;height:32px}
|
|
852
|
-
.ok-native-list-index-preview{position:absolute;z-index:8;right:40px;top:50%;display:flex;width:48px;height:48px;align-items:center;justify-content:center;transform:translateY(-50%) scale(.92);border-radius:14px;background:var(--nl-inverse);color:var(--nl-inverse-text);font-size:22px;font-weight:600;
|
|
868
|
+
.ok-native-list-index-preview{position:absolute;z-index:8;right:40px;top:50%;display:flex;width:48px;height:48px;align-items:center;justify-content:center;transform:translateY(-50%) scale(.92);border-radius:14px;background:var(--nl-inverse);color:var(--nl-inverse-text);font-size:22px;font-weight:600;opacity:0;pointer-events:none;transition:opacity .15s ease,transform .15s ease;font-family:var(--nl-font-semibold)}.ok-native-list-index-preview[data-visible="true"]{opacity:1;transform:translateY(-50%) scale(1)}
|
|
853
869
|
.ok-native-list-row.ok-native-list-market-skeleton{padding:12px 20px;gap:0}.ok-native-list-skeleton-left{display:flex;align-items:center;gap:12px;flex:1}.ok-native-list-skeleton-text{display:flex;flex-direction:column;gap:4px}.ok-native-list-skeleton-right{display:flex;align-items:center;gap:8px}.ok-native-list-skeleton-mark{display:block;flex-shrink:0;border-radius:8px;animation:ok-native-list-skeleton 1.5s linear infinite alternate}@keyframes ok-native-list-skeleton{from{background-color:var(--nl-skeleton-base)}to{background-color:var(--nl-skeleton-highlight)}}.ok-native-list-market-spinner{display:block;width:20px;height:20px;flex-shrink:0;color:var(--nl-icon);animation:ok-native-list-spin .75s linear infinite}
|
|
854
870
|
@media (prefers-reduced-motion:reduce){.ok-native-list-index-preview,.ok-native-list-refresh{transition:none}.ok-native-list-spinner,.ok-native-list-market-spinner{animation:none}.ok-native-list-skeleton-mark{animation:none;background:var(--nl-skeleton-base)}}
|
|
855
|
-
.ok-native-list-footer{flex:0 0 auto;min-height:0}.ok-native-list-sticky{position:absolute;z-index:4;left:0;right:0;top:0;pointer-events:auto;box-shadow:0 1px 0 var(--nl-separator)}.ok-native-list-viewport-frame:has(>.ok-native-list-index-rail:not([hidden]))>.ok-native-list-viewport,.ok-native-list-viewport-frame[data-section-index-visible="true"]>.ok-native-list-viewport{scrollbar-width:none}.ok-native-list-viewport-frame:has(>.ok-native-list-index-rail:not([hidden]))>.ok-native-list-viewport::-webkit-scrollbar,.ok-native-list-viewport-frame[data-section-index-visible="true"]>.ok-native-list-viewport::-webkit-scrollbar{display:none}.ok-native-list-index-rail{position:absolute;z-index:6;top:0;right:0;bottom:0;width:${SECTION_INDEX_RAIL_WIDTH}px;touch-action:none;cursor:pointer;font-
|
|
871
|
+
.ok-native-list-footer{flex:0 0 auto;min-height:0}.ok-native-list-sticky{position:absolute;z-index:4;left:0;right:0;top:0;pointer-events:auto;box-shadow:0 1px 0 var(--nl-separator)}.ok-native-list-viewport-frame:has(>.ok-native-list-index-rail:not([hidden]))>.ok-native-list-viewport,.ok-native-list-viewport-frame[data-section-index-visible="true"]>.ok-native-list-viewport{scrollbar-width:none}.ok-native-list-viewport-frame:has(>.ok-native-list-index-rail:not([hidden]))>.ok-native-list-viewport::-webkit-scrollbar,.ok-native-list-viewport-frame[data-section-index-visible="true"]>.ok-native-list-viewport::-webkit-scrollbar{display:none}.ok-native-list-index-rail{position:absolute;z-index:6;top:0;right:0;bottom:0;width:${SECTION_INDEX_RAIL_WIDTH}px;touch-action:none;cursor:pointer;font-family:var(--nl-font-regular);font-synthesis:none}.ok-native-list-index-rail[hidden]{display:none}.ok-native-list-index-button{appearance:none;position:absolute;left:15px;display:flex;width:14px;height:14px;align-items:center;justify-content:center;padding:0;transform:translateY(-50%);border:0;border-radius:7px;background:transparent;color:var(--nl-disabled);font-size:10px;font-weight:400;line-height:1;cursor:pointer;opacity:.5;transition:opacity .15s ease;font-family:var(--nl-font-regular)}.ok-native-list-index-rail:hover .ok-native-list-index-button,.ok-native-list-index-rail:focus-within .ok-native-list-index-button,.ok-native-list-index-button[data-active="true"]{opacity:1}.ok-native-list-index-button[data-active="true"]{background:var(--nl-positive);color:var(--nl-inverse-text);font-weight:500;font-family:var(--nl-font-medium)}.ok-native-list-index-button:focus-visible{outline:2px solid var(--nl-positive);outline-offset:1px}
|
|
856
872
|
.ok-native-list-refresh{position:absolute;z-index:7;left:50%;top:8px;display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;background:var(--nl-inverse);color:var(--nl-inverse-text);font-size:12px;opacity:0;transform:translate(-50%,-16px);transition:opacity .15s ease,transform .15s ease;pointer-events:none}.ok-native-list-refresh[data-visible="true"]{opacity:1;transform:translate(-50%,0)}
|
|
857
|
-
.ok-native-list-warning{height:auto;display:flex;flex-direction:column;align-items:stretch;gap:4px;padding:14px 12px;border-top:1px solid;border-bottom:1px solid;box-sizing:border-box;cursor:default}.ok-native-list-warning-title,.ok-native-list-warning-message{font-size:14px;line-height:20px;white-space:normal;overflow-wrap:anywhere}.ok-native-list-warning-title{font-weight:500;
|
|
873
|
+
.ok-native-list-warning{height:auto;display:flex;flex-direction:column;align-items:stretch;gap:4px;padding:14px 12px;border-top:1px solid;border-bottom:1px solid;box-sizing:border-box;cursor:default}.ok-native-list-warning-title,.ok-native-list-warning-message{font-size:14px;line-height:20px;white-space:normal;overflow-wrap:anywhere}.ok-native-list-warning-title{font-weight:500;color:var(--nl-primary);font-family:var(--nl-font-medium)}.ok-native-list-warning-message{font-weight:400;color:var(--nl-secondary);font-family:var(--nl-font-regular)}
|
|
858
874
|
.ok-native-list-subtitle-segments{display:flex;align-items:center;min-width:0;max-width:100%;height:20px}.ok-native-list-subtitle-segments>.ok-native-list-secondary{flex:0 1 auto;min-width:0}.ok-native-list-subtitle-dot{flex:0 0 4px;width:4px;height:4px;margin:0 6px;border-radius:50%;background:var(--nl-disabled)}.ok-native-list-wallet-row>.ok-native-list-flex{flex:0 1 auto;width:100%;align-items:center}.ok-native-list-wallet-badges{display:flex;gap:4px;justify-content:center;margin-top:4px;height:20px;max-width:100%}.ok-native-list-wallet-badges>.ok-native-list-badge{background:var(--nl-strong);color:var(--nl-secondary);font-size:12px;line-height:16px;height:20px;box-sizing:border-box;padding:2px 4px}.ok-native-list-visual-overlay{position:absolute;display:flex;align-items:center;justify-content:center;box-sizing:border-box;border-radius:50%;overflow:hidden;line-height:1;font-size:10px}.ok-native-list-visual-overlay img,.ok-native-list-visual-overlay svg{width:100%;height:100%;object-fit:contain}/* OneKey patch: selector controls follow their original semantic colors and geometry. */
|
|
859
875
|
.ok-native-list-checkbox[data-selector="networkSelector"]{padding:0;border-radius:4px;border-color:var(--nl-checkbox-border,var(--nl-separator));background:var(--nl-checkbox-icon,var(--nl-inverse-text))}
|
|
860
876
|
.ok-native-list-checkbox[data-selector="networkSelector"]::after{display:none}
|
|
@@ -866,7 +882,7 @@ export const WEB_LIST_CSS = `
|
|
|
866
882
|
/* OneKey patch: selected group members use the same primary title color as standalone wallets. */
|
|
867
883
|
.ok-native-list-wallet-member[data-native-list-selected="true"]>.ok-native-list-wallet-row[data-native-list-selector="walletSidebar"] .ok-native-list-title{color:var(--nl-primary)}
|
|
868
884
|
.ok-native-list-wallet-row[data-native-list-selector="walletSidebar"] .ok-native-list-wallet-badges{height:18px}
|
|
869
|
-
.ok-native-list-wallet-row[data-native-list-selector="walletSidebar"] .ok-native-list-wallet-badges>.ok-native-list-badge{font-size:11px;line-height:14px;font-weight:400;
|
|
885
|
+
.ok-native-list-wallet-row[data-native-list-selector="walletSidebar"] .ok-native-list-wallet-badges>.ok-native-list-badge{font-size:11px;line-height:14px;font-weight:400;height:18px;padding:2px 6px;border-radius:4px;background:var(--nl-subdued);color:var(--nl-secondary);font-family:var(--nl-font-regular)}
|
|
870
886
|
.ok-native-list-wallet-row[data-native-list-selector="walletSidebar"] .ok-native-list-wallet-badges>.ok-native-list-badge[data-tone="warning"]{background:var(--nl-caution-background);color:var(--nl-caution)}
|
|
871
887
|
.ok-native-list-account-row[data-native-list-selector="accountSelector"] .ok-native-list-accessories>.ok-native-list-icon-button{box-sizing:border-box;flex:0 0 38px;width:38px;height:38px;margin:-7px;padding:7px}
|
|
872
888
|
.ok-native-list-account-row[data-native-list-selector="accountSelector"] .ok-native-list-accessories>.ok-native-list-icon-button[data-native-list-action]:not([data-native-list-account-control="createAddress"]):hover{background:var(--nl-strong);border-radius:50%}
|
|
@@ -956,10 +972,13 @@ function configureWebImageRetry(
|
|
|
956
972
|
const retryLimit = Number.isFinite(source.retryTimes)
|
|
957
973
|
? Math.max(0, Math.floor(source.retryTimes ?? 0))
|
|
958
974
|
: 0;
|
|
959
|
-
|
|
975
|
+
const orderedFallbacks = source.fallbackUris;
|
|
976
|
+
if (!fallbackUri && retryLimit === 0 && orderedFallbacks === undefined)
|
|
977
|
+
return;
|
|
960
978
|
const view = image.ownerDocument.defaultView;
|
|
961
979
|
let currentUri = initialUri;
|
|
962
980
|
let usedFallback = false;
|
|
981
|
+
let fallbackIndex = 0;
|
|
963
982
|
let retryCount = 0;
|
|
964
983
|
let retryTimer: number | undefined;
|
|
965
984
|
let disposed = false;
|
|
@@ -972,7 +991,25 @@ function configureWebImageRetry(
|
|
|
972
991
|
event.stopImmediatePropagation();
|
|
973
992
|
return;
|
|
974
993
|
}
|
|
975
|
-
if (
|
|
994
|
+
if (orderedFallbacks !== undefined && retryCount >= retryLimit) {
|
|
995
|
+
if (fallbackIndex >= orderedFallbacks.length) return;
|
|
996
|
+
let nextUri: string | undefined;
|
|
997
|
+
while (!nextUri && fallbackIndex < orderedFallbacks.length) {
|
|
998
|
+
nextUri = safeImageUri(orderedFallbacks[fallbackIndex++]);
|
|
999
|
+
}
|
|
1000
|
+
if (!nextUri) return;
|
|
1001
|
+
event.stopImmediatePropagation();
|
|
1002
|
+
retryCount = 0;
|
|
1003
|
+
currentUri = nextUri;
|
|
1004
|
+
image.src = currentUri;
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
if (
|
|
1008
|
+
orderedFallbacks === undefined &&
|
|
1009
|
+
fallbackUri &&
|
|
1010
|
+
!usedFallback &&
|
|
1011
|
+
fallbackUri !== currentUri
|
|
1012
|
+
) {
|
|
976
1013
|
event.stopImmediatePropagation();
|
|
977
1014
|
usedFallback = true;
|
|
978
1015
|
currentUri = fallbackUri;
|
|
@@ -1012,6 +1049,12 @@ function configureWebAvatar(
|
|
|
1012
1049
|
image.src = resolvedUri;
|
|
1013
1050
|
},
|
|
1014
1051
|
() => {
|
|
1052
|
+
if (source.fallbackUris !== undefined) {
|
|
1053
|
+
configureWebImageRetry(image, source, uri);
|
|
1054
|
+
const ImageEvent = image.ownerDocument.defaultView?.Event;
|
|
1055
|
+
if (ImageEvent) image.dispatchEvent(new ImageEvent('error'));
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1015
1058
|
const fallbackUri = source.fallbackUri
|
|
1016
1059
|
? safeImageUri(source.fallbackUri)
|
|
1017
1060
|
: undefined;
|
|
@@ -1144,6 +1187,23 @@ const selectorIcons: Readonly<
|
|
|
1144
1187
|
}>
|
|
1145
1188
|
>
|
|
1146
1189
|
> = {
|
|
1190
|
+
CryptoCoinOutline: {
|
|
1191
|
+
viewBox: '0 0 24 24',
|
|
1192
|
+
paths: [
|
|
1193
|
+
{
|
|
1194
|
+
d: 'M11 16.387a4.5 4.5 0 0 1 0-8.775V6h2v1.613a4.5 4.5 0 0 1 2.856 2.067l-1.712 1.032a2.5 2.5 0 1 0 0 2.576l1.712 1.032A4.5 4.5 0 0 1 13 16.386V18h-2z',
|
|
1195
|
+
fill: 'currentColor',
|
|
1196
|
+
fillRule: 'nonzero',
|
|
1197
|
+
opacity: 1,
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
d: 'M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10m-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0',
|
|
1201
|
+
fill: 'currentColor',
|
|
1202
|
+
fillRule: 'evenodd',
|
|
1203
|
+
opacity: 1,
|
|
1204
|
+
},
|
|
1205
|
+
],
|
|
1206
|
+
},
|
|
1147
1207
|
GlobusOutline: {
|
|
1148
1208
|
viewBox: '0 0 24 24',
|
|
1149
1209
|
paths: [
|
|
@@ -1577,6 +1637,8 @@ function createVisual(
|
|
|
1577
1637
|
if (fallbackIcon.tintColor)
|
|
1578
1638
|
fallback.style.color = fallbackIcon.tintColor;
|
|
1579
1639
|
}
|
|
1640
|
+
fallback.style.backgroundColor =
|
|
1641
|
+
'var(--nl-image-fallback-background, transparent)';
|
|
1580
1642
|
frame.prepend(fallback);
|
|
1581
1643
|
};
|
|
1582
1644
|
if (image) image.addEventListener('error', showFallback, { once: true });
|
|
@@ -1929,7 +1991,23 @@ export function createRowBody(
|
|
|
1929
1991
|
return rowRenderer(row).create(context.document, rendererPrimitives(context));
|
|
1930
1992
|
}
|
|
1931
1993
|
|
|
1994
|
+
export type NativeListWebScrollOptions = Readonly<{
|
|
1995
|
+
scrollHost?: HTMLElement;
|
|
1996
|
+
contentBounds?: HTMLElement;
|
|
1997
|
+
stickyInset?: number;
|
|
1998
|
+
ownsRefresh?: boolean;
|
|
1999
|
+
}>;
|
|
2000
|
+
|
|
1932
2001
|
export class NativeListWebEngine {
|
|
2002
|
+
private readonly externalScrollHost: HTMLElement | undefined;
|
|
2003
|
+
private readonly ownsRefresh: boolean;
|
|
2004
|
+
private readonly pullTarget: HTMLElement;
|
|
2005
|
+
private readonly contentBounds: HTMLElement | undefined;
|
|
2006
|
+
private externalStickyInset: number;
|
|
2007
|
+
private externalOrigin: number | undefined;
|
|
2008
|
+
private externalGeometryCache:
|
|
2009
|
+
| ReturnType<NativeListWebEngine['readExternalGeometry']>
|
|
2010
|
+
| undefined;
|
|
1933
2011
|
private readonly document: Document;
|
|
1934
2012
|
private readonly root: HTMLElement;
|
|
1935
2013
|
private readonly viewportFrame: HTMLElement;
|
|
@@ -1964,6 +2042,7 @@ export class NativeListWebEngine {
|
|
|
1964
2042
|
dataRow: [],
|
|
1965
2043
|
metricCard: [],
|
|
1966
2044
|
market: [],
|
|
2045
|
+
marketTable: [],
|
|
1967
2046
|
identity: [],
|
|
1968
2047
|
sectionHeader: [],
|
|
1969
2048
|
};
|
|
@@ -2009,6 +2088,8 @@ export class NativeListWebEngine {
|
|
|
2009
2088
|
private marketPointer:
|
|
2010
2089
|
| Readonly<{
|
|
2011
2090
|
pointerId: number;
|
|
2091
|
+
pointerType: string;
|
|
2092
|
+
compact: boolean;
|
|
2012
2093
|
rowKey: string;
|
|
2013
2094
|
startX: number;
|
|
2014
2095
|
startY: number;
|
|
@@ -2028,21 +2109,29 @@ export class NativeListWebEngine {
|
|
|
2028
2109
|
|
|
2029
2110
|
private notifyScrollCommandAccepted() {
|
|
2030
2111
|
if (this.destroyed) return;
|
|
2031
|
-
const
|
|
2112
|
+
const owner = this.externalScrollHost ?? this.viewport;
|
|
2113
|
+
const EventConstructor = owner.ownerDocument.defaultView?.Event;
|
|
2032
2114
|
if (EventConstructor)
|
|
2033
|
-
|
|
2115
|
+
owner.dispatchEvent(
|
|
2034
2116
|
new EventConstructor('ok-native-list-scroll-command-accepted')
|
|
2035
2117
|
);
|
|
2036
2118
|
}
|
|
2037
2119
|
|
|
2038
2120
|
private readonly handlePagerScrollCommandCancel = (event: Event) => {
|
|
2039
|
-
|
|
2121
|
+
const owner = this.externalScrollHost ?? this.viewport;
|
|
2122
|
+
if (this.destroyed || event.target !== owner) return;
|
|
2040
2123
|
this.pendingScroll = undefined;
|
|
2041
|
-
|
|
2042
|
-
left:
|
|
2043
|
-
top:
|
|
2124
|
+
const options: ScrollToOptions = {
|
|
2125
|
+
left: owner.scrollLeft,
|
|
2126
|
+
top: owner.scrollTop,
|
|
2044
2127
|
behavior: 'instant',
|
|
2045
|
-
}
|
|
2128
|
+
};
|
|
2129
|
+
if (this.externalScrollHost) {
|
|
2130
|
+
const scrollTo: (options: ScrollToOptions) => void =
|
|
2131
|
+
owner.ownerDocument.defaultView?.Element.prototype.scrollTo ??
|
|
2132
|
+
owner.scrollTo;
|
|
2133
|
+
scrollTo.call(owner, options);
|
|
2134
|
+
} else this.viewport.scrollTo(options);
|
|
2046
2135
|
};
|
|
2047
2136
|
|
|
2048
2137
|
constructor(
|
|
@@ -2051,10 +2140,35 @@ export class NativeListWebEngine {
|
|
|
2051
2140
|
callbacks: NativeListWebCallbacks,
|
|
2052
2141
|
virtualizationEnabled = true,
|
|
2053
2142
|
sectionIndexContainer?: HTMLElement | null,
|
|
2054
|
-
fontFamiliesJson = '{}'
|
|
2143
|
+
fontFamiliesJson = '{}',
|
|
2144
|
+
scrollOptions: NativeListWebScrollOptions = {}
|
|
2055
2145
|
) {
|
|
2146
|
+
if (
|
|
2147
|
+
scrollOptions.scrollHost &&
|
|
2148
|
+
(!(
|
|
2149
|
+
scrollOptions.scrollHost instanceof
|
|
2150
|
+
host.ownerDocument.defaultView!.HTMLElement
|
|
2151
|
+
) ||
|
|
2152
|
+
!scrollOptions.scrollHost.contains(host))
|
|
2153
|
+
)
|
|
2154
|
+
throw new Error(
|
|
2155
|
+
'webScrollHost must be an ancestor HTMLElement in the same document'
|
|
2156
|
+
);
|
|
2157
|
+
this.ownsRefresh = scrollOptions.ownsRefresh === true;
|
|
2158
|
+
if (
|
|
2159
|
+
scrollOptions.scrollHost &&
|
|
2160
|
+
snapshot.layout.orientation === 'horizontal'
|
|
2161
|
+
)
|
|
2162
|
+
throw new Error('External scrolling supports vertical lists only');
|
|
2163
|
+
this.externalScrollHost = scrollOptions.scrollHost;
|
|
2164
|
+
this.contentBounds = scrollOptions.contentBounds;
|
|
2165
|
+
this.externalStickyInset = this.validateStickyInset(
|
|
2166
|
+
scrollOptions.stickyInset
|
|
2167
|
+
);
|
|
2056
2168
|
this.document = host.ownerDocument;
|
|
2057
|
-
this.snapshot =
|
|
2169
|
+
this.snapshot =
|
|
2170
|
+
containNativeListInput(() => validateSnapshot(snapshot)) ??
|
|
2171
|
+
emptyNativeListSnapshot();
|
|
2058
2172
|
this.callbacks = callbacks;
|
|
2059
2173
|
this.virtualizationEnabled = virtualizationEnabled;
|
|
2060
2174
|
this.sectionIndexContainer = sectionIndexContainer ?? undefined;
|
|
@@ -2062,6 +2176,7 @@ export class NativeListWebEngine {
|
|
|
2062
2176
|
if (!host.style.position) host.style.position = 'relative';
|
|
2063
2177
|
|
|
2064
2178
|
this.root = createElement(this.document, 'div', 'ok-native-list-root');
|
|
2179
|
+
setData(this.root, 'nativeListParentScroll', !!this.externalScrollHost);
|
|
2065
2180
|
const style = this.document.createElement('style');
|
|
2066
2181
|
style.textContent = WEB_LIST_CSS;
|
|
2067
2182
|
this.viewportFrame = createElement(
|
|
@@ -2074,6 +2189,10 @@ export class NativeListWebEngine {
|
|
|
2074
2189
|
'div',
|
|
2075
2190
|
'ok-native-list-viewport'
|
|
2076
2191
|
);
|
|
2192
|
+
this.pullTarget =
|
|
2193
|
+
this.externalScrollHost && this.ownsRefresh
|
|
2194
|
+
? this.externalScrollHost
|
|
2195
|
+
: this.viewport;
|
|
2077
2196
|
this.viewport.setAttribute('role', 'list');
|
|
2078
2197
|
this.content = createElement(
|
|
2079
2198
|
this.document,
|
|
@@ -2120,25 +2239,58 @@ export class NativeListWebEngine {
|
|
|
2120
2239
|
);
|
|
2121
2240
|
this.root.append(style, this.viewportFrame, this.footer);
|
|
2122
2241
|
host.appendChild(this.root);
|
|
2242
|
+
if (this.externalScrollHost) {
|
|
2243
|
+
Object.assign(this.root.style, {
|
|
2244
|
+
position: 'relative',
|
|
2245
|
+
inset: 'auto',
|
|
2246
|
+
overflow: 'visible',
|
|
2247
|
+
flex: 'none',
|
|
2248
|
+
});
|
|
2249
|
+
Object.assign(this.viewportFrame.style, {
|
|
2250
|
+
overflow: 'visible',
|
|
2251
|
+
flex: 'none',
|
|
2252
|
+
});
|
|
2253
|
+
Object.assign(this.viewport.style, {
|
|
2254
|
+
position: 'relative',
|
|
2255
|
+
inset: 'auto',
|
|
2256
|
+
overflow: 'visible',
|
|
2257
|
+
scrollbarGutter: 'auto',
|
|
2258
|
+
});
|
|
2259
|
+
this.content.style.minHeight = '0';
|
|
2260
|
+
this.externalScrollHost.addEventListener(
|
|
2261
|
+
'scroll',
|
|
2262
|
+
this.handleExternalScroll,
|
|
2263
|
+
{
|
|
2264
|
+
passive: true,
|
|
2265
|
+
capture: true,
|
|
2266
|
+
}
|
|
2267
|
+
);
|
|
2268
|
+
}
|
|
2123
2269
|
|
|
2124
|
-
this.viewport.addEventListener(
|
|
2270
|
+
(this.externalScrollHost ?? this.viewport).addEventListener(
|
|
2125
2271
|
'ok-collapsible-pager-cancel-scroll-command',
|
|
2126
2272
|
this.handlePagerScrollCommandCancel
|
|
2127
2273
|
);
|
|
2128
2274
|
this.viewport.addEventListener('scroll', this.handleScroll, {
|
|
2129
2275
|
passive: true,
|
|
2130
2276
|
});
|
|
2131
|
-
this.viewport.addEventListener(
|
|
2277
|
+
(this.externalScrollHost ?? this.viewport).addEventListener(
|
|
2132
2278
|
'ok-collapsible-pager-insets-changed',
|
|
2133
2279
|
this.handleCollapsiblePagerInsetsChanged
|
|
2134
2280
|
);
|
|
2135
2281
|
this.root.addEventListener('click', this.handleClick);
|
|
2282
|
+
this.root.addEventListener('contextmenu', this.handleMarketContextMenu);
|
|
2136
2283
|
this.root.addEventListener('pointerdown', this.handleMarketPointerDown);
|
|
2137
2284
|
this.root.addEventListener('pointermove', this.handleMarketPointerMove);
|
|
2285
|
+
this.root.addEventListener('touchmove', this.handleMarketTouchMove, {
|
|
2286
|
+
passive: true,
|
|
2287
|
+
});
|
|
2138
2288
|
this.root.addEventListener('pointerup', this.handleMarketPointerEnd);
|
|
2139
2289
|
this.root.addEventListener('pointercancel', this.handleMarketPointerEnd);
|
|
2140
2290
|
// OneKey patch: preserve web tooltip hover for section titles.
|
|
2141
2291
|
this.root.addEventListener('pointerover', this.handleTitlePointerOver);
|
|
2292
|
+
this.root.addEventListener('focusin', this.handleTitlePointerOver);
|
|
2293
|
+
this.root.addEventListener('focusout', this.handleTitlePointerOut);
|
|
2142
2294
|
this.root.addEventListener('pointerout', this.handleTitlePointerOut);
|
|
2143
2295
|
this.root.addEventListener('keydown', this.handleKeyDown);
|
|
2144
2296
|
this.viewport.addEventListener(
|
|
@@ -2174,14 +2326,14 @@ export class NativeListWebEngine {
|
|
|
2174
2326
|
this.handleIndexPointerEnd
|
|
2175
2327
|
);
|
|
2176
2328
|
this.indexRail.addEventListener('click', this.handleIndexClick);
|
|
2177
|
-
this.
|
|
2329
|
+
this.pullTarget.addEventListener('pointerdown', this.handlePullStart, {
|
|
2178
2330
|
passive: true,
|
|
2179
2331
|
});
|
|
2180
|
-
this.
|
|
2332
|
+
this.pullTarget.addEventListener('pointermove', this.handlePullMove, {
|
|
2181
2333
|
passive: false,
|
|
2182
2334
|
});
|
|
2183
|
-
this.
|
|
2184
|
-
this.
|
|
2335
|
+
this.pullTarget.addEventListener('pointerup', this.handlePullEnd);
|
|
2336
|
+
this.pullTarget.addEventListener('pointercancel', this.handlePullEnd);
|
|
2185
2337
|
|
|
2186
2338
|
const ResizeObserverConstructor = this.document.defaultView?.ResizeObserver;
|
|
2187
2339
|
if (ResizeObserverConstructor) {
|
|
@@ -2189,17 +2341,78 @@ export class NativeListWebEngine {
|
|
|
2189
2341
|
this.recomputeLayout()
|
|
2190
2342
|
);
|
|
2191
2343
|
this.resizeObserver.observe(this.viewport);
|
|
2344
|
+
if (this.externalScrollHost) {
|
|
2345
|
+
this.resizeObserver.observe(this.externalScrollHost);
|
|
2346
|
+
let ancestor: HTMLElement | null = host;
|
|
2347
|
+
while (ancestor && ancestor !== this.externalScrollHost) {
|
|
2348
|
+
this.resizeObserver.observe(ancestor);
|
|
2349
|
+
for (const sibling of ancestor.parentElement?.children ?? []) {
|
|
2350
|
+
if (sibling instanceof this.document.defaultView!.HTMLElement)
|
|
2351
|
+
this.resizeObserver.observe(sibling);
|
|
2352
|
+
}
|
|
2353
|
+
ancestor = ancestor.parentElement;
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2192
2356
|
} else {
|
|
2193
2357
|
this.document.defaultView?.addEventListener(
|
|
2194
2358
|
'resize',
|
|
2195
2359
|
this.handleWindowResize
|
|
2196
2360
|
);
|
|
2197
2361
|
}
|
|
2362
|
+
this.document.fonts?.addEventListener(
|
|
2363
|
+
'loadingdone',
|
|
2364
|
+
this.handleWindowResize
|
|
2365
|
+
);
|
|
2198
2366
|
this.observeSectionIndexTransforms();
|
|
2199
2367
|
this.applyFontFamilies(fontFamiliesJson);
|
|
2200
2368
|
this.applySnapshot(this.snapshot);
|
|
2201
2369
|
}
|
|
2202
2370
|
|
|
2371
|
+
private validateStickyInset(value = 0): number {
|
|
2372
|
+
if (!Number.isFinite(value) || value < 0)
|
|
2373
|
+
throw new Error('webStickyInset must be finite and non-negative');
|
|
2374
|
+
return value;
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
setStickyInset(value = 0) {
|
|
2378
|
+
const next = this.validateStickyInset(value);
|
|
2379
|
+
if (next === this.externalStickyInset) return;
|
|
2380
|
+
this.externalStickyInset = next;
|
|
2381
|
+
this.recomputeLayout();
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
private externalGeometry() {
|
|
2385
|
+
return (this.externalGeometryCache ??= this.readExternalGeometry());
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
private readExternalGeometry() {
|
|
2389
|
+
const host = this.externalScrollHost!;
|
|
2390
|
+
const hostRect = host.getBoundingClientRect();
|
|
2391
|
+
const bodyRect = this.viewport.getBoundingClientRect();
|
|
2392
|
+
const boundsRect = (
|
|
2393
|
+
this.contentBounds ?? this.root
|
|
2394
|
+
).getBoundingClientRect();
|
|
2395
|
+
const top = hostRect.top + host.clientTop + this.externalStickyInset;
|
|
2396
|
+
const bottom = hostRect.top + host.clientTop + host.clientHeight;
|
|
2397
|
+
return {
|
|
2398
|
+
origin: bodyRect.top - hostRect.top - host.clientTop + host.scrollTop,
|
|
2399
|
+
containerOrigin:
|
|
2400
|
+
boundsRect.top - hostRect.top - host.clientTop + host.scrollTop,
|
|
2401
|
+
end: boundsRect.bottom - hostRect.top - host.clientTop + host.scrollTop,
|
|
2402
|
+
top,
|
|
2403
|
+
bottom,
|
|
2404
|
+
offset: top - bodyRect.top,
|
|
2405
|
+
viewportLength: Math.max(0, bottom - top),
|
|
2406
|
+
visible:
|
|
2407
|
+
bodyRect.width > 0 &&
|
|
2408
|
+
bodyRect.right > hostRect.left &&
|
|
2409
|
+
bodyRect.left < hostRect.right &&
|
|
2410
|
+
host.clientHeight > 0 &&
|
|
2411
|
+
boundsRect.bottom > top &&
|
|
2412
|
+
boundsRect.top < bottom,
|
|
2413
|
+
};
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2203
2416
|
private fontFamiliesJson = '{}';
|
|
2204
2417
|
|
|
2205
2418
|
private applyFontFamilies(json: string) {
|
|
@@ -2237,14 +2450,36 @@ export class NativeListWebEngine {
|
|
|
2237
2450
|
}
|
|
2238
2451
|
|
|
2239
2452
|
applySnapshot(snapshot: NativeListSnapshot) {
|
|
2240
|
-
const validated =
|
|
2453
|
+
const validated = containNativeListInput(() => {
|
|
2454
|
+
const next = validateSnapshot(snapshot);
|
|
2455
|
+
if (this.externalScrollHost && next.layout.orientation === 'horizontal')
|
|
2456
|
+
throw new Error('External scrolling supports vertical lists only');
|
|
2457
|
+
return next;
|
|
2458
|
+
});
|
|
2459
|
+
if (!validated) return;
|
|
2241
2460
|
this.invalidateActionAnchor('snapshot');
|
|
2242
2461
|
this.setSnapshot(validated);
|
|
2243
2462
|
}
|
|
2244
2463
|
|
|
2464
|
+
currentContentHeight(): number {
|
|
2465
|
+
return this.layout.contentHeight;
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
currentSnapshot(): NativeListSnapshot {
|
|
2469
|
+
return this.snapshot;
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2245
2472
|
applyPatches(patches: readonly RowPatch[]) {
|
|
2246
|
-
|
|
2247
|
-
|
|
2473
|
+
const accepted = containNativeListInput(() => {
|
|
2474
|
+
const normalized = validatePatches(patches);
|
|
2475
|
+
return {
|
|
2476
|
+
patches: normalized,
|
|
2477
|
+
snapshot: applyRowPatches(this.snapshot, normalized),
|
|
2478
|
+
};
|
|
2479
|
+
});
|
|
2480
|
+
if (!accepted || accepted.patches.length === 0) return;
|
|
2481
|
+
patches = accepted.patches;
|
|
2482
|
+
const next = accepted.snapshot;
|
|
2248
2483
|
const selection = new Set(this.selectedKeys);
|
|
2249
2484
|
patches.forEach((patch) => {
|
|
2250
2485
|
const selected =
|
|
@@ -2252,7 +2487,21 @@ export class NativeListWebEngine {
|
|
|
2252
2487
|
if (selected === true) selection.add(patch.key);
|
|
2253
2488
|
else if (selected === false) selection.delete(patch.key);
|
|
2254
2489
|
});
|
|
2255
|
-
|
|
2490
|
+
const tableValuesOnly = patches.every((patch) => {
|
|
2491
|
+
const index = this.rows.findIndex((row) => row.key === patch.key);
|
|
2492
|
+
const before = this.rows[index],
|
|
2493
|
+
after = next.rows[index];
|
|
2494
|
+
return (
|
|
2495
|
+
patch.type === 'market' &&
|
|
2496
|
+
before?.type === 'market' &&
|
|
2497
|
+
after?.type === 'market' &&
|
|
2498
|
+
Object.keys(patch.changes).every(
|
|
2499
|
+
(key) => MARKET_QUOTE_PATCH_FIELDS.has(key) || key === 'webTable'
|
|
2500
|
+
) &&
|
|
2501
|
+
canPatchMarketTableValues(before, after)
|
|
2502
|
+
);
|
|
2503
|
+
});
|
|
2504
|
+
if (webMarketImageBindDeltaForPatches(patches) === 0 || tableValuesOnly) {
|
|
2256
2505
|
this.snapshot = next;
|
|
2257
2506
|
this.rows = effectiveRows(next);
|
|
2258
2507
|
this.selectedKeys = selection;
|
|
@@ -2261,14 +2510,16 @@ export class NativeListWebEngine {
|
|
|
2261
2510
|
const row = this.rows[index];
|
|
2262
2511
|
const element = this.mounted.get(index);
|
|
2263
2512
|
if (row?.type === 'market' && element) {
|
|
2264
|
-
|
|
2513
|
+
if (row.webTable) updateMarketTableValues(element, row);
|
|
2514
|
+
else setMarketQuoteContent(element, row);
|
|
2265
2515
|
element.dataset.renderSignature = webRowRenderSignature(row);
|
|
2266
2516
|
}
|
|
2267
2517
|
if (
|
|
2268
2518
|
row?.type === 'market' &&
|
|
2269
2519
|
this.sticky.dataset.nativeListRowKey === row.key
|
|
2270
2520
|
) {
|
|
2271
|
-
|
|
2521
|
+
if (row.webTable) updateMarketTableValues(this.sticky, row);
|
|
2522
|
+
else setMarketQuoteContent(this.sticky, row);
|
|
2272
2523
|
this.sticky.dataset.renderSignature = webRowRenderSignature(row);
|
|
2273
2524
|
}
|
|
2274
2525
|
});
|
|
@@ -2332,7 +2583,10 @@ export class NativeListWebEngine {
|
|
|
2332
2583
|
this.pendingScroll = { kind: 'offset', offset, animated };
|
|
2333
2584
|
return;
|
|
2334
2585
|
}
|
|
2335
|
-
this.
|
|
2586
|
+
if (this.externalScrollHost) {
|
|
2587
|
+
const geometry = this.externalGeometry();
|
|
2588
|
+
this.writeExternalOffset(geometry.containerOrigin + offset, animated);
|
|
2589
|
+
} else this.scrollToAbsoluteOffset(offset, animated);
|
|
2336
2590
|
}
|
|
2337
2591
|
|
|
2338
2592
|
scrollToEnd(animated: boolean) {
|
|
@@ -2341,10 +2595,17 @@ export class NativeListWebEngine {
|
|
|
2341
2595
|
this.pendingScroll = { kind: 'end', animated };
|
|
2342
2596
|
return;
|
|
2343
2597
|
}
|
|
2344
|
-
this.
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2598
|
+
if (this.externalScrollHost) {
|
|
2599
|
+
const geometry = this.externalGeometry();
|
|
2600
|
+
this.writeExternalOffset(
|
|
2601
|
+
geometry.end - this.externalScrollHost.clientHeight,
|
|
2602
|
+
animated
|
|
2603
|
+
);
|
|
2604
|
+
} else
|
|
2605
|
+
this.scrollToAbsoluteOffset(
|
|
2606
|
+
Math.max(0, this.contentLength() - this.viewportLength()),
|
|
2607
|
+
animated
|
|
2608
|
+
);
|
|
2348
2609
|
}
|
|
2349
2610
|
|
|
2350
2611
|
scrollToLocation(
|
|
@@ -2410,28 +2671,41 @@ export class NativeListWebEngine {
|
|
|
2410
2671
|
if (this.reorderMovementTimer !== undefined)
|
|
2411
2672
|
this.document.defaultView?.clearTimeout(this.reorderMovementTimer);
|
|
2412
2673
|
this.resizeObserver?.disconnect();
|
|
2674
|
+
this.externalScrollHost?.removeEventListener(
|
|
2675
|
+
'scroll',
|
|
2676
|
+
this.handleExternalScroll,
|
|
2677
|
+
true
|
|
2678
|
+
);
|
|
2679
|
+
this.document.fonts?.removeEventListener(
|
|
2680
|
+
'loadingdone',
|
|
2681
|
+
this.handleWindowResize
|
|
2682
|
+
);
|
|
2413
2683
|
this.sectionIndexTransformObserver?.disconnect();
|
|
2414
2684
|
this.document.defaultView?.removeEventListener(
|
|
2415
2685
|
'resize',
|
|
2416
2686
|
this.handleWindowResize
|
|
2417
2687
|
);
|
|
2418
2688
|
this.pendingScroll = undefined;
|
|
2419
|
-
this.viewport.removeEventListener(
|
|
2689
|
+
(this.externalScrollHost ?? this.viewport).removeEventListener(
|
|
2420
2690
|
'ok-collapsible-pager-cancel-scroll-command',
|
|
2421
2691
|
this.handlePagerScrollCommandCancel
|
|
2422
2692
|
);
|
|
2423
2693
|
this.viewport.removeEventListener('scroll', this.handleScroll);
|
|
2424
|
-
this.viewport.removeEventListener(
|
|
2694
|
+
(this.externalScrollHost ?? this.viewport).removeEventListener(
|
|
2425
2695
|
'ok-collapsible-pager-insets-changed',
|
|
2426
2696
|
this.handleCollapsiblePagerInsetsChanged
|
|
2427
2697
|
);
|
|
2428
2698
|
this.root.removeEventListener('click', this.handleClick);
|
|
2699
|
+
this.root.removeEventListener('contextmenu', this.handleMarketContextMenu);
|
|
2429
2700
|
this.cancelMarketPointer();
|
|
2430
2701
|
this.root.removeEventListener('pointerdown', this.handleMarketPointerDown);
|
|
2431
2702
|
this.root.removeEventListener('pointermove', this.handleMarketPointerMove);
|
|
2703
|
+
this.root.removeEventListener('touchmove', this.handleMarketTouchMove);
|
|
2432
2704
|
this.root.removeEventListener('pointerup', this.handleMarketPointerEnd);
|
|
2433
2705
|
this.root.removeEventListener('pointercancel', this.handleMarketPointerEnd);
|
|
2434
2706
|
this.root.removeEventListener('pointerover', this.handleTitlePointerOver);
|
|
2707
|
+
this.root.removeEventListener('focusin', this.handleTitlePointerOver);
|
|
2708
|
+
this.root.removeEventListener('focusout', this.handleTitlePointerOut);
|
|
2435
2709
|
this.root.removeEventListener('pointerout', this.handleTitlePointerOut);
|
|
2436
2710
|
this.root.removeEventListener('keydown', this.handleKeyDown);
|
|
2437
2711
|
this.cancelPointerReorder(true);
|
|
@@ -2465,10 +2739,10 @@ export class NativeListWebEngine {
|
|
|
2465
2739
|
this.handleIndexPointerEnd
|
|
2466
2740
|
);
|
|
2467
2741
|
this.indexRail.removeEventListener('click', this.handleIndexClick);
|
|
2468
|
-
this.
|
|
2469
|
-
this.
|
|
2470
|
-
this.
|
|
2471
|
-
this.
|
|
2742
|
+
this.pullTarget.removeEventListener('pointerdown', this.handlePullStart);
|
|
2743
|
+
this.pullTarget.removeEventListener('pointermove', this.handlePullMove);
|
|
2744
|
+
this.pullTarget.removeEventListener('pointerup', this.handlePullEnd);
|
|
2745
|
+
this.pullTarget.removeEventListener('pointercancel', this.handlePullEnd);
|
|
2472
2746
|
const host = this.root.parentElement;
|
|
2473
2747
|
disposeWebImageRetries(this.root);
|
|
2474
2748
|
Object.values(this.pool).forEach((elements) =>
|
|
@@ -2514,6 +2788,8 @@ export class NativeListWebEngine {
|
|
|
2514
2788
|
'--nl-pressed': theme.rowPressedBackground,
|
|
2515
2789
|
'--nl-subdued': theme.subduedBackground,
|
|
2516
2790
|
'--nl-strong': theme.strongBackground,
|
|
2791
|
+
'--nl-image-fallback-background':
|
|
2792
|
+
theme.imageFallbackBackground ?? 'transparent',
|
|
2517
2793
|
'--nl-primary': theme.primaryText,
|
|
2518
2794
|
'--nl-secondary': theme.secondaryText,
|
|
2519
2795
|
'--nl-disabled': theme.disabledText,
|
|
@@ -2566,8 +2842,79 @@ export class NativeListWebEngine {
|
|
|
2566
2842
|
});
|
|
2567
2843
|
}
|
|
2568
2844
|
|
|
2845
|
+
private computeLayout(
|
|
2846
|
+
viewportWidth: number,
|
|
2847
|
+
viewportHeight: number
|
|
2848
|
+
): WebListLayout {
|
|
2849
|
+
const measuredSnapshot: NativeListSnapshot = {
|
|
2850
|
+
...this.snapshot,
|
|
2851
|
+
rows: this.snapshot.rows.map((row) =>
|
|
2852
|
+
row.style?.container?.height === undefined &&
|
|
2853
|
+
row.height === undefined &&
|
|
2854
|
+
this.measuredRendererHeights.get(row.key)?.signature ===
|
|
2855
|
+
webRowRenderSignature(row)
|
|
2856
|
+
? {
|
|
2857
|
+
...row,
|
|
2858
|
+
height: this.measuredRendererHeights.get(row.key)!.height,
|
|
2859
|
+
}
|
|
2860
|
+
: row
|
|
2861
|
+
),
|
|
2862
|
+
};
|
|
2863
|
+
let layout = computeWebListLayout(
|
|
2864
|
+
measuredSnapshot,
|
|
2865
|
+
viewportWidth,
|
|
2866
|
+
viewportHeight,
|
|
2867
|
+
this.reorderCompactKey
|
|
2868
|
+
);
|
|
2869
|
+
if (this.externalScrollHost) {
|
|
2870
|
+
const padding = paddingValues(this.snapshot);
|
|
2871
|
+
layout = {
|
|
2872
|
+
...layout,
|
|
2873
|
+
contentHeight:
|
|
2874
|
+
Math.max(
|
|
2875
|
+
padding.top,
|
|
2876
|
+
...layout.items.map((item) => item.y + item.height)
|
|
2877
|
+
) + padding.bottom,
|
|
2878
|
+
};
|
|
2879
|
+
}
|
|
2880
|
+
return layout;
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2883
|
+
private writeExternalHeight(height: number) {
|
|
2884
|
+
const value = String(height) + 'px';
|
|
2885
|
+
this.content.style.height = value;
|
|
2886
|
+
this.viewport.style.height = value;
|
|
2887
|
+
this.viewportFrame.style.height = value;
|
|
2888
|
+
this.root.style.height = value;
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2569
2891
|
private recomputeLayout = () => {
|
|
2570
2892
|
if (this.destroyed) return;
|
|
2893
|
+
const cachedWidth = this.lastViewportWidth;
|
|
2894
|
+
const cachedHeight = this.lastViewportHeight;
|
|
2895
|
+
const precomputedLayout =
|
|
2896
|
+
this.externalScrollHost && cachedWidth > 0 && cachedHeight > 0
|
|
2897
|
+
? this.computeLayout(cachedWidth, cachedHeight)
|
|
2898
|
+
: undefined;
|
|
2899
|
+
if (precomputedLayout) {
|
|
2900
|
+
// Commit appended row extent before measuring React-owned slot changes.
|
|
2901
|
+
this.writeExternalHeight(
|
|
2902
|
+
Math.max(this.layout.contentHeight, precomputedLayout.contentHeight)
|
|
2903
|
+
);
|
|
2904
|
+
}
|
|
2905
|
+
this.externalGeometryCache = undefined;
|
|
2906
|
+
if (this.externalScrollHost) {
|
|
2907
|
+
const geometry = this.externalGeometry();
|
|
2908
|
+
const previousOrigin = this.externalOrigin;
|
|
2909
|
+
this.externalOrigin = geometry.origin;
|
|
2910
|
+
if (
|
|
2911
|
+
previousOrigin !== undefined &&
|
|
2912
|
+
geometry.origin !== previousOrigin &&
|
|
2913
|
+
this.externalScrollHost.scrollTop > previousOrigin &&
|
|
2914
|
+
geometry.visible
|
|
2915
|
+
)
|
|
2916
|
+
this.externalScrollHost.scrollTop += geometry.origin - previousOrigin;
|
|
2917
|
+
}
|
|
2571
2918
|
const viewportWidth = this.viewport.clientWidth;
|
|
2572
2919
|
const viewportHeight =
|
|
2573
2920
|
this.snapshot.layout.orientation === 'horizontal'
|
|
@@ -2595,28 +2942,18 @@ export class NativeListWebEngine {
|
|
|
2595
2942
|
this.lastViewportWidth = viewportWidth;
|
|
2596
2943
|
this.lastViewportHeight = viewportHeight;
|
|
2597
2944
|
const previousHorizontal = this.layout.horizontal;
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
this.
|
|
2604
|
-
webRowRenderSignature(row)
|
|
2605
|
-
? {
|
|
2606
|
-
...row,
|
|
2607
|
-
height: this.measuredRendererHeights.get(row.key)!.height,
|
|
2608
|
-
}
|
|
2609
|
-
: row
|
|
2610
|
-
),
|
|
2611
|
-
};
|
|
2612
|
-
this.layout = computeWebListLayout(
|
|
2613
|
-
measuredSnapshot,
|
|
2614
|
-
viewportWidth,
|
|
2615
|
-
viewportHeight,
|
|
2616
|
-
this.reorderCompactKey
|
|
2617
|
-
);
|
|
2945
|
+
this.layout =
|
|
2946
|
+
precomputedLayout &&
|
|
2947
|
+
viewportWidth === cachedWidth &&
|
|
2948
|
+
viewportHeight === cachedHeight
|
|
2949
|
+
? precomputedLayout
|
|
2950
|
+
: this.computeLayout(viewportWidth, viewportHeight);
|
|
2618
2951
|
this.content.style.width = String(this.layout.contentWidth) + 'px';
|
|
2619
2952
|
this.content.style.height = String(this.layout.contentHeight) + 'px';
|
|
2953
|
+
if (this.externalScrollHost) {
|
|
2954
|
+
this.writeExternalHeight(this.layout.contentHeight);
|
|
2955
|
+
this.externalGeometryCache = undefined;
|
|
2956
|
+
}
|
|
2620
2957
|
this.renderSectionIndex(
|
|
2621
2958
|
this.viewport.clientHeight <= 0
|
|
2622
2959
|
? DEFAULT_VIEWPORT_HEIGHT
|
|
@@ -2632,6 +2969,11 @@ export class NativeListWebEngine {
|
|
|
2632
2969
|
};
|
|
2633
2970
|
|
|
2634
2971
|
private updateAvatarWindow() {
|
|
2972
|
+
if (this.externalScrollHost && !this.externalGeometry().visible) {
|
|
2973
|
+
this.avatarLeases.forEach((lease) => lease());
|
|
2974
|
+
this.avatarLeases.clear();
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2635
2977
|
const offset = this.currentOffset();
|
|
2636
2978
|
if (offset !== this.avatarOffset)
|
|
2637
2979
|
this.avatarDirection = Math.sign(offset - this.avatarOffset);
|
|
@@ -2688,13 +3030,16 @@ export class NativeListWebEngine {
|
|
|
2688
3030
|
private renderWindow() {
|
|
2689
3031
|
this.updateAvatarWindow();
|
|
2690
3032
|
const viewportLength = this.viewportLength();
|
|
2691
|
-
const visible =
|
|
2692
|
-
this.
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
3033
|
+
const visible =
|
|
3034
|
+
this.externalScrollHost && !this.externalGeometry().visible
|
|
3035
|
+
? []
|
|
3036
|
+
: webLayoutItemsForMount(
|
|
3037
|
+
this.layout,
|
|
3038
|
+
this.currentOffset(),
|
|
3039
|
+
viewportLength,
|
|
3040
|
+
this.virtualizationEnabled,
|
|
3041
|
+
viewportLength * OVERSCAN_VIEWPORTS
|
|
3042
|
+
);
|
|
2698
3043
|
const desired = new Set(visible.map((item) => item.index));
|
|
2699
3044
|
this.mounted.forEach((element, index) => {
|
|
2700
3045
|
const nextRow = this.rows[index];
|
|
@@ -2797,6 +3142,11 @@ export class NativeListWebEngine {
|
|
|
2797
3142
|
? 'ok-native-list-item ok-native-list-sticky'
|
|
2798
3143
|
: 'ok-native-list-item';
|
|
2799
3144
|
setData(element, 'nativeListRowKey', row.key);
|
|
3145
|
+
setData(
|
|
3146
|
+
element,
|
|
3147
|
+
'nativeListMediaGallery',
|
|
3148
|
+
row.type === 'mediaTile' && row.variant === 'gallery' ? 'true' : undefined
|
|
3149
|
+
);
|
|
2800
3150
|
setData(element, 'nativeListBindingEpoch', bindingEpoch);
|
|
2801
3151
|
setData(element, 'nativeListRowIndex', index);
|
|
2802
3152
|
setData(element, 'nativeListDisabled', Boolean(row.disabled));
|
|
@@ -3221,11 +3571,14 @@ export class NativeListWebEngine {
|
|
|
3221
3571
|
}
|
|
3222
3572
|
|
|
3223
3573
|
private updateVisibleState() {
|
|
3224
|
-
const visible =
|
|
3225
|
-
this.
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3574
|
+
const visible =
|
|
3575
|
+
this.externalScrollHost && !this.externalGeometry().visible
|
|
3576
|
+
? []
|
|
3577
|
+
: visibleWebLayoutItems(
|
|
3578
|
+
this.layout,
|
|
3579
|
+
this.currentOffset(),
|
|
3580
|
+
this.viewportLength()
|
|
3581
|
+
);
|
|
3229
3582
|
const first = visible[0];
|
|
3230
3583
|
const last = visible.at(-1);
|
|
3231
3584
|
const signature =
|
|
@@ -3295,6 +3648,8 @@ export class NativeListWebEngine {
|
|
|
3295
3648
|
this.sticky.style.right = 'auto';
|
|
3296
3649
|
this.sticky.style.width = String(item.width) + 'px';
|
|
3297
3650
|
this.sticky.style.height = String(item.height) + 'px';
|
|
3651
|
+
if (this.externalScrollHost)
|
|
3652
|
+
this.sticky.style.top = String(Math.max(0, this.currentOffset())) + 'px';
|
|
3298
3653
|
let nextIndex = -1;
|
|
3299
3654
|
for (let cursor = index + 1; cursor < this.rows.length; cursor += 1) {
|
|
3300
3655
|
const candidate = this.rows[cursor];
|
|
@@ -3333,6 +3688,7 @@ export class NativeListWebEngine {
|
|
|
3333
3688
|
|
|
3334
3689
|
private checkEndReached(lastVisibleIndex: number) {
|
|
3335
3690
|
if (
|
|
3691
|
+
(this.externalScrollHost && !this.externalGeometry().visible) ||
|
|
3336
3692
|
!this.snapshot.capabilities?.loadMore ||
|
|
3337
3693
|
this.reachedGeneration === this.snapshot.generation ||
|
|
3338
3694
|
this.rows.length === 0
|
|
@@ -3371,6 +3727,11 @@ export class NativeListWebEngine {
|
|
|
3371
3727
|
}
|
|
3372
3728
|
|
|
3373
3729
|
private canScroll(): boolean {
|
|
3730
|
+
if (this.externalScrollHost)
|
|
3731
|
+
return (
|
|
3732
|
+
this.viewport.clientWidth > 0 &&
|
|
3733
|
+
this.externalScrollHost.clientHeight > 0
|
|
3734
|
+
);
|
|
3374
3735
|
const viewportLength = this.layout.horizontal
|
|
3375
3736
|
? this.viewport.clientWidth
|
|
3376
3737
|
: this.viewport.clientHeight;
|
|
@@ -3381,11 +3742,19 @@ export class NativeListWebEngine {
|
|
|
3381
3742
|
if (this.layout.horizontal) {
|
|
3382
3743
|
return this.viewport.clientWidth || DEFAULT_VIEWPORT_WIDTH;
|
|
3383
3744
|
}
|
|
3745
|
+
if (this.externalScrollHost) return this.externalGeometry().viewportLength;
|
|
3384
3746
|
if (this.viewport.clientHeight <= 0) return DEFAULT_VIEWPORT_HEIGHT;
|
|
3385
3747
|
return Math.max(1, this.verticalScrollMetrics().viewportLength);
|
|
3386
3748
|
}
|
|
3387
3749
|
|
|
3388
3750
|
private contentLength(): number {
|
|
3751
|
+
if (this.externalScrollHost) {
|
|
3752
|
+
const geometry = this.externalGeometry();
|
|
3753
|
+
return Math.max(
|
|
3754
|
+
this.layout.contentHeight,
|
|
3755
|
+
geometry.end - geometry.origin
|
|
3756
|
+
);
|
|
3757
|
+
}
|
|
3389
3758
|
return this.layout.horizontal
|
|
3390
3759
|
? this.layout.contentWidth
|
|
3391
3760
|
: this.layout.contentHeight;
|
|
@@ -3401,6 +3770,8 @@ export class NativeListWebEngine {
|
|
|
3401
3770
|
header: number;
|
|
3402
3771
|
sticky: number;
|
|
3403
3772
|
}> {
|
|
3773
|
+
if (this.externalScrollHost)
|
|
3774
|
+
return { header: 0, sticky: this.externalStickyInset };
|
|
3404
3775
|
const readInset = (name: string) => {
|
|
3405
3776
|
const parsed = Number.parseFloat(
|
|
3406
3777
|
this.viewport.style.getPropertyValue(name)
|
|
@@ -3414,6 +3785,7 @@ export class NativeListWebEngine {
|
|
|
3414
3785
|
}
|
|
3415
3786
|
|
|
3416
3787
|
private verticalScrollMetrics(): WebCollapsiblePagerScrollMetrics {
|
|
3788
|
+
if (this.externalScrollHost) return this.externalGeometry();
|
|
3417
3789
|
const insets = this.collapsiblePagerInsets();
|
|
3418
3790
|
return resolveWebCollapsiblePagerScrollMetrics(
|
|
3419
3791
|
this.viewport.scrollTop,
|
|
@@ -3427,7 +3799,31 @@ export class NativeListWebEngine {
|
|
|
3427
3799
|
this.recomputeLayout();
|
|
3428
3800
|
};
|
|
3429
3801
|
|
|
3802
|
+
private writeExternalOffset(rawOffset: number, animated: boolean) {
|
|
3803
|
+
this.externalGeometryCache = undefined;
|
|
3804
|
+
const host = this.externalScrollHost!;
|
|
3805
|
+
const scrollTo: (options: ScrollToOptions) => void =
|
|
3806
|
+
host.ownerDocument.defaultView?.Element.prototype.scrollTo ??
|
|
3807
|
+
host.scrollTo;
|
|
3808
|
+
scrollTo.call(host, {
|
|
3809
|
+
top: Math.max(
|
|
3810
|
+
0,
|
|
3811
|
+
Math.min(host.scrollHeight - host.clientHeight, rawOffset)
|
|
3812
|
+
),
|
|
3813
|
+
behavior: animated ? 'smooth' : 'auto',
|
|
3814
|
+
});
|
|
3815
|
+
this.scheduleFrame();
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3430
3818
|
private scrollToAbsoluteOffset(offset: number, animated: boolean) {
|
|
3819
|
+
if (this.externalScrollHost) {
|
|
3820
|
+
const geometry = this.externalGeometry();
|
|
3821
|
+
this.writeExternalOffset(
|
|
3822
|
+
geometry.origin + offset - this.externalStickyInset,
|
|
3823
|
+
animated
|
|
3824
|
+
);
|
|
3825
|
+
return;
|
|
3826
|
+
}
|
|
3431
3827
|
const resolved = Math.min(
|
|
3432
3828
|
Math.max(0, offset),
|
|
3433
3829
|
Math.max(0, this.contentLength() - this.viewportLength())
|
|
@@ -3507,7 +3903,8 @@ export class NativeListWebEngine {
|
|
|
3507
3903
|
row: RowModel,
|
|
3508
3904
|
actionKey: string,
|
|
3509
3905
|
actionElement?: HTMLElement,
|
|
3510
|
-
rowElement?: HTMLElement
|
|
3906
|
+
rowElement?: HTMLElement,
|
|
3907
|
+
windowPoint?: RowActionEvent['windowPoint']
|
|
3511
3908
|
) {
|
|
3512
3909
|
const anchor =
|
|
3513
3910
|
actionElement && rowElement
|
|
@@ -3518,6 +3915,11 @@ export class NativeListWebEngine {
|
|
|
3518
3915
|
actionKey,
|
|
3519
3916
|
sectionKey: row.sectionKey,
|
|
3520
3917
|
anchor,
|
|
3918
|
+
...(windowPoint &&
|
|
3919
|
+
Number.isFinite(windowPoint.x) &&
|
|
3920
|
+
Number.isFinite(windowPoint.y)
|
|
3921
|
+
? { windowPoint }
|
|
3922
|
+
: {}),
|
|
3521
3923
|
});
|
|
3522
3924
|
}
|
|
3523
3925
|
|
|
@@ -3654,6 +4056,38 @@ export class NativeListWebEngine {
|
|
|
3654
4056
|
this.marketPointer = undefined;
|
|
3655
4057
|
}
|
|
3656
4058
|
|
|
4059
|
+
private handleMarketContextMenu = (event: MouseEvent) => {
|
|
4060
|
+
if (
|
|
4061
|
+
!(event.target instanceof Element) ||
|
|
4062
|
+
event.target.closest('[data-native-list-action]')
|
|
4063
|
+
)
|
|
4064
|
+
return;
|
|
4065
|
+
const element = event.target.closest<HTMLElement>(
|
|
4066
|
+
'[data-native-list-row-key]'
|
|
4067
|
+
);
|
|
4068
|
+
const row = this.rowAtElement(element);
|
|
4069
|
+
if (
|
|
4070
|
+
row?.type !== 'market' ||
|
|
4071
|
+
!row.webTable?.contextMenuActionKey ||
|
|
4072
|
+
!element ||
|
|
4073
|
+
!isRowPressEnabled(row)
|
|
4074
|
+
)
|
|
4075
|
+
return;
|
|
4076
|
+
event.preventDefault();
|
|
4077
|
+
this.cancelMarketPointer();
|
|
4078
|
+
markActionAnchorSource(element, 'row');
|
|
4079
|
+
const rect = element.getBoundingClientRect();
|
|
4080
|
+
this.emitRowAction(
|
|
4081
|
+
row,
|
|
4082
|
+
row.webTable.contextMenuActionKey,
|
|
4083
|
+
element,
|
|
4084
|
+
element,
|
|
4085
|
+
event.clientX || event.clientY
|
|
4086
|
+
? { x: event.clientX, y: event.clientY }
|
|
4087
|
+
: { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 }
|
|
4088
|
+
);
|
|
4089
|
+
};
|
|
4090
|
+
|
|
3657
4091
|
private handleMarketPointerDown = (event: PointerEvent) => {
|
|
3658
4092
|
if (event.button !== 0 || !(event.target instanceof Element)) return;
|
|
3659
4093
|
this.marketLongPressFired = false;
|
|
@@ -3673,16 +4107,35 @@ export class NativeListWebEngine {
|
|
|
3673
4107
|
);
|
|
3674
4108
|
if (!row.longPressActionKey || !rowElement) return;
|
|
3675
4109
|
markActionAnchorSource(rowElement, 'row');
|
|
4110
|
+
const bindingEpoch = rowElement.dataset.nativeListBindingEpoch;
|
|
3676
4111
|
const timer = this.document.defaultView?.setTimeout(() => {
|
|
3677
4112
|
const current = this.marketPointer;
|
|
3678
4113
|
if (!current || current.pointerId !== event.pointerId) return;
|
|
4114
|
+
const currentRow = this.rowAtElement(rowElement);
|
|
3679
4115
|
this.marketPointer = undefined;
|
|
4116
|
+
if (
|
|
4117
|
+
!rowElement.isConnected ||
|
|
4118
|
+
rowElement.dataset.nativeListBindingEpoch !== bindingEpoch ||
|
|
4119
|
+
currentRow?.key !== row.key ||
|
|
4120
|
+
currentRow.type !== 'market' ||
|
|
4121
|
+
!isRowPressEnabled(currentRow) ||
|
|
4122
|
+
!currentRow.longPressActionKey
|
|
4123
|
+
)
|
|
4124
|
+
return;
|
|
3680
4125
|
this.marketLongPressFired = true;
|
|
3681
|
-
this.emitRowAction(
|
|
4126
|
+
this.emitRowAction(
|
|
4127
|
+
currentRow,
|
|
4128
|
+
currentRow.longPressActionKey,
|
|
4129
|
+
rowElement,
|
|
4130
|
+
rowElement,
|
|
4131
|
+
{ x: event.clientX, y: event.clientY }
|
|
4132
|
+
);
|
|
3682
4133
|
}, MARKET_LONG_PRESS_MS);
|
|
3683
4134
|
if (timer === undefined) return;
|
|
3684
4135
|
this.marketPointer = {
|
|
3685
4136
|
pointerId: event.pointerId,
|
|
4137
|
+
pointerType: event.pointerType,
|
|
4138
|
+
compact: !row.webTable,
|
|
3686
4139
|
rowKey: row.key,
|
|
3687
4140
|
startX: event.clientX,
|
|
3688
4141
|
startY: event.clientY,
|
|
@@ -3693,9 +4146,41 @@ export class NativeListWebEngine {
|
|
|
3693
4146
|
private handleMarketPointerMove = (event: PointerEvent) => {
|
|
3694
4147
|
const state = this.marketPointer;
|
|
3695
4148
|
if (!state || state.pointerId !== event.pointerId) return;
|
|
4149
|
+
if (state.compact && state.pointerType === 'touch') return;
|
|
4150
|
+
const row = this.rows.find((item) => item.key === state.rowKey);
|
|
4151
|
+
const threshold =
|
|
4152
|
+
row?.type === 'market' && !row.webTable ? 3 : MARKET_MOVE_CANCEL_PX;
|
|
3696
4153
|
if (
|
|
3697
|
-
Math.abs(event.clientX - state.startX) >
|
|
3698
|
-
Math.abs(event.clientY - state.startY) >
|
|
4154
|
+
Math.abs(event.clientX - state.startX) > threshold ||
|
|
4155
|
+
Math.abs(event.clientY - state.startY) > threshold
|
|
4156
|
+
)
|
|
4157
|
+
this.cancelMarketPointer();
|
|
4158
|
+
};
|
|
4159
|
+
|
|
4160
|
+
private handleMarketTouchMove = (event: TouchEvent) => {
|
|
4161
|
+
const state = this.marketPointer;
|
|
4162
|
+
if (
|
|
4163
|
+
!state?.compact ||
|
|
4164
|
+
state.pointerType !== 'touch' ||
|
|
4165
|
+
!(event.target instanceof Element) ||
|
|
4166
|
+
event.target.closest<HTMLElement>('[data-native-list-row-key]')?.dataset
|
|
4167
|
+
.nativeListRowKey !== state.rowKey
|
|
4168
|
+
)
|
|
4169
|
+
return;
|
|
4170
|
+
if (event.touches.length > 1) {
|
|
4171
|
+
this.cancelMarketPointer();
|
|
4172
|
+
return;
|
|
4173
|
+
}
|
|
4174
|
+
const touch = event.touches[0] ?? event.changedTouches[0];
|
|
4175
|
+
if (
|
|
4176
|
+
!touch ||
|
|
4177
|
+
!Number.isFinite(touch.clientX) ||
|
|
4178
|
+
!Number.isFinite(touch.clientY)
|
|
4179
|
+
)
|
|
4180
|
+
return;
|
|
4181
|
+
if (
|
|
4182
|
+
Math.abs(touch.clientX - state.startX) > 3 ||
|
|
4183
|
+
Math.abs(touch.clientY - state.startY) > 3
|
|
3699
4184
|
)
|
|
3700
4185
|
this.cancelMarketPointer();
|
|
3701
4186
|
};
|
|
@@ -3706,7 +4191,7 @@ export class NativeListWebEngine {
|
|
|
3706
4191
|
};
|
|
3707
4192
|
|
|
3708
4193
|
// OneKey patch: hover opens the same anchored help action as native taps.
|
|
3709
|
-
private handleTitlePointerOver = (event: PointerEvent) => {
|
|
4194
|
+
private handleTitlePointerOver = (event: PointerEvent | FocusEvent) => {
|
|
3710
4195
|
const target = event.target;
|
|
3711
4196
|
if (!(target instanceof Element)) return;
|
|
3712
4197
|
const action = target.closest<HTMLElement>(
|
|
@@ -3718,6 +4203,11 @@ export class NativeListWebEngine {
|
|
|
3718
4203
|
action.contains(event.relatedTarget))
|
|
3719
4204
|
)
|
|
3720
4205
|
return;
|
|
4206
|
+
if (
|
|
4207
|
+
action.classList.contains('ok-native-list-market-subtitle-prefix') &&
|
|
4208
|
+
action.scrollWidth <= action.clientWidth + 1
|
|
4209
|
+
)
|
|
4210
|
+
return;
|
|
3721
4211
|
const rowElement = action.closest<HTMLElement>(
|
|
3722
4212
|
'[data-native-list-row-key]'
|
|
3723
4213
|
);
|
|
@@ -3741,7 +4231,7 @@ export class NativeListWebEngine {
|
|
|
3741
4231
|
this.emitRowAction(sourceRow, actionKey, action, rowElement ?? undefined);
|
|
3742
4232
|
};
|
|
3743
4233
|
|
|
3744
|
-
private handleTitlePointerOut = (event: PointerEvent) => {
|
|
4234
|
+
private handleTitlePointerOut = (event: PointerEvent | FocusEvent) => {
|
|
3745
4235
|
const target = event.target;
|
|
3746
4236
|
if (!(target instanceof Element)) return;
|
|
3747
4237
|
const action = target.closest<HTMLElement>(
|
|
@@ -3934,7 +4424,20 @@ export class NativeListWebEngine {
|
|
|
3934
4424
|
?.focus({ preventScroll: true });
|
|
3935
4425
|
}
|
|
3936
4426
|
|
|
4427
|
+
private handleExternalScroll = (event: Event) => {
|
|
4428
|
+
const target = event.target;
|
|
4429
|
+
if (
|
|
4430
|
+
target === this.externalScrollHost ||
|
|
4431
|
+
(target instanceof Element &&
|
|
4432
|
+
target !== this.root &&
|
|
4433
|
+
this.externalScrollHost?.contains(target) &&
|
|
4434
|
+
target.contains(this.root))
|
|
4435
|
+
)
|
|
4436
|
+
this.handleScroll();
|
|
4437
|
+
};
|
|
4438
|
+
|
|
3937
4439
|
private handleScroll = () => {
|
|
4440
|
+
this.externalGeometryCache = undefined;
|
|
3938
4441
|
this.cancelMarketPointer();
|
|
3939
4442
|
this.invalidateActionAnchor('scroll');
|
|
3940
4443
|
this.scheduleFrame();
|
|
@@ -3950,6 +4453,9 @@ export class NativeListWebEngine {
|
|
|
3950
4453
|
if (this.frameHandle !== undefined || this.destroyed) return;
|
|
3951
4454
|
this.frameHandle = this.requestFrame(() => {
|
|
3952
4455
|
this.frameHandle = undefined;
|
|
4456
|
+
this.externalGeometryCache = undefined;
|
|
4457
|
+
if (this.externalScrollHost)
|
|
4458
|
+
this.externalOrigin = this.externalGeometry().origin;
|
|
3953
4459
|
if (this.virtualizationEnabled) this.renderWindow();
|
|
3954
4460
|
else {
|
|
3955
4461
|
this.updateAvatarWindow();
|
|
@@ -4050,7 +4556,8 @@ export class NativeListWebEngine {
|
|
|
4050
4556
|
if (
|
|
4051
4557
|
this.pointerReorder?.pointerId === event.pointerId ||
|
|
4052
4558
|
!this.snapshot.capabilities?.pullToRefresh ||
|
|
4053
|
-
this.
|
|
4559
|
+
(!!this.externalScrollHost && !this.ownsRefresh) ||
|
|
4560
|
+
this.pullTarget.scrollTop > 0 ||
|
|
4054
4561
|
(event.pointerType !== 'touch' && event.pointerType !== 'pen')
|
|
4055
4562
|
)
|
|
4056
4563
|
return;
|
|
@@ -4149,6 +4656,7 @@ export class NativeListWebEngine {
|
|
|
4149
4656
|
if (this.pointerReorder !== state) return;
|
|
4150
4657
|
this.clearReorderLongPress(state);
|
|
4151
4658
|
state.active = true;
|
|
4659
|
+
this.cancelMarketPointer();
|
|
4152
4660
|
state.activatedAt = Date.now();
|
|
4153
4661
|
state.viewportRect = this.reorderViewportRect();
|
|
4154
4662
|
this.captureReorderPointer(state);
|
|
@@ -4247,6 +4755,10 @@ export class NativeListWebEngine {
|
|
|
4247
4755
|
};
|
|
4248
4756
|
|
|
4249
4757
|
private setCurrentOffset(offset: number) {
|
|
4758
|
+
if (this.externalScrollHost) {
|
|
4759
|
+
this.scrollToAbsoluteOffset(offset, false);
|
|
4760
|
+
return;
|
|
4761
|
+
}
|
|
4250
4762
|
const maximum = Math.max(0, this.contentLength() - this.viewportLength());
|
|
4251
4763
|
const next = Math.max(0, Math.min(maximum, offset));
|
|
4252
4764
|
if (this.layout.horizontal) this.viewport.scrollLeft = next;
|
|
@@ -4339,12 +4851,13 @@ export class NativeListWebEngine {
|
|
|
4339
4851
|
const insets = this.collapsiblePagerInsets();
|
|
4340
4852
|
const left =
|
|
4341
4853
|
viewportRect.left + destinationLayout.x - this.viewport.scrollLeft;
|
|
4342
|
-
const top =
|
|
4343
|
-
viewportRect.top +
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4854
|
+
const top = this.externalScrollHost
|
|
4855
|
+
? viewportRect.top + destinationLayout.y
|
|
4856
|
+
: viewportRect.top +
|
|
4857
|
+
destinationLayout.y +
|
|
4858
|
+
insets.header +
|
|
4859
|
+
insets.sticky -
|
|
4860
|
+
this.viewport.scrollTop;
|
|
4348
4861
|
this.reorderPreview.getBoundingClientRect();
|
|
4349
4862
|
this.reorderPreview.style.transition =
|
|
4350
4863
|
'transform ' +
|
|
@@ -4416,6 +4929,18 @@ export class NativeListWebEngine {
|
|
|
4416
4929
|
}
|
|
4417
4930
|
|
|
4418
4931
|
private reorderViewportRect() {
|
|
4932
|
+
if (this.externalScrollHost) {
|
|
4933
|
+
const geometry = this.externalGeometry();
|
|
4934
|
+
const body = this.viewport.getBoundingClientRect();
|
|
4935
|
+
return {
|
|
4936
|
+
left: body.left,
|
|
4937
|
+
right: body.right,
|
|
4938
|
+
width: body.width,
|
|
4939
|
+
top: geometry.top,
|
|
4940
|
+
bottom: geometry.bottom,
|
|
4941
|
+
height: geometry.viewportLength,
|
|
4942
|
+
};
|
|
4943
|
+
}
|
|
4419
4944
|
const { left, top, right, bottom, width, height } =
|
|
4420
4945
|
this.viewport.getBoundingClientRect();
|
|
4421
4946
|
return { left, top, right, bottom, width, height };
|