@onekeyfe/react-native-native-list 6.7.0-2 → 6.7.0-3
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/docs/SPEC.md +365 -9
- package/lib/module/NativeList.js +2 -0
- package/lib/module/NativeList.web.js +135 -29
- package/lib/module/validation.js +143 -34
- package/lib/module/web/NativeListWebEngine.js +353 -62
- package/lib/module/web/templates/ActivityRowRenderer.js +432 -5
- package/lib/module/web/templates/MarketRowRenderer.js +8 -3
- package/lib/module/web/templates/MarketTableRowRenderer.js +576 -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/typescript/src/NativeList.types.d.ts +11 -1
- package/lib/typescript/src/NativeList.web.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +71 -1
- 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/package.json +3 -3
- package/src/NativeList.tsx +2 -0
- package/src/NativeList.types.ts +12 -1
- package/src/NativeList.web.tsx +183 -38
- package/src/models.ts +93 -0
- package/src/validation.ts +348 -58
- package/src/web/NativeListWebEngine.ts +600 -95
- package/src/web/templates/ActivityRowRenderer.ts +656 -7
- package/src/web/templates/MarketRowRenderer.ts +19 -3
- package/src/web/templates/MarketTableRowRenderer.ts +752 -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,
|
|
@@ -311,6 +315,7 @@ export function isWebRowReorderable(
|
|
|
311
315
|
if (row.type === 'rail' && row.draggable) return true;
|
|
312
316
|
if (row.type === 'identity' && row.draggable) return true;
|
|
313
317
|
if (row.type === 'walletGroup' && row.draggable) return true;
|
|
318
|
+
if (row.type === 'market' && row.webTable?.draggable) return true;
|
|
314
319
|
return (
|
|
315
320
|
(row.type === 'identity' || row.type === 'action') &&
|
|
316
321
|
Boolean(row.trailing?.some((accessory) => accessory.kind === 'drag'))
|
|
@@ -563,9 +568,7 @@ export function computeWebListLayout(
|
|
|
563
568
|
}
|
|
564
569
|
|
|
565
570
|
const columns = snapshot.layout.gridColumns ?? 2;
|
|
566
|
-
const itemWidth =
|
|
567
|
-
(availableWidth - spacing * (columns - 1)) / columns
|
|
568
|
-
);
|
|
571
|
+
const itemWidth = (availableWidth - spacing * (columns - 1)) / columns;
|
|
569
572
|
let y = padding.top;
|
|
570
573
|
let column = 0;
|
|
571
574
|
let bandStart = y;
|
|
@@ -789,12 +792,15 @@ export function webMarketImageBindDeltaForPatches(
|
|
|
789
792
|
|
|
790
793
|
// OneKey patch: selector names must shrink before the sidebar clips their contents.
|
|
791
794
|
export const WEB_LIST_CSS = `
|
|
795
|
+
.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}
|
|
796
|
+
|
|
792
797
|
[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)
|
|
798
|
+
.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
799
|
.ok-native-list-viewport-frame{position:relative;flex:1;min-width:0;min-height:0;overflow:hidden}
|
|
795
800
|
.ok-native-list-viewport{position:absolute;inset:0;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;scrollbar-gutter:stable}
|
|
796
801
|
.ok-native-list-content{position:relative;min-width:100%;min-height:100%}
|
|
797
802
|
.ok-native-list-item{position:absolute;left:0;top:0;box-sizing:border-box;contain:layout paint style;outline:none}
|
|
803
|
+
.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
804
|
.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
805
|
.ok-native-list-item[data-table-alternate="true"]>.ok-native-list-row{background:var(--nl-bg)}
|
|
800
806
|
.ok-native-list-item[data-native-list-selected="true"]>.ok-native-list-row{background:var(--nl-selected)}
|
|
@@ -819,7 +825,7 @@ export const WEB_LIST_CSS = `
|
|
|
819
825
|
.ok-native-list-item[data-native-list-dragging="true"]>.ok-native-list-row>*{visibility:hidden}
|
|
820
826
|
.ok-native-list-item[data-native-list-dragging="true"]>.ok-native-list-wallet-group{border-color:transparent;background:var(--nl-pressed)}
|
|
821
827
|
.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-
|
|
828
|
+
.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
829
|
.ok-native-list-reorder-preview>.ok-native-list-row{background:var(--nl-pressed);cursor:grabbing}
|
|
824
830
|
.ok-native-list-reorder-preview[data-native-list-selected="true"]>.ok-native-list-row{background:var(--nl-selected)}
|
|
825
831
|
.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 +838,33 @@ export const WEB_LIST_CSS = `
|
|
|
832
838
|
.ok-native-list-item[data-group-position="single"]>.ok-native-list-row{border-radius:var(--nl-group-radius,12px)}
|
|
833
839
|
.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
840
|
.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;
|
|
841
|
+
.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
842
|
.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)
|
|
843
|
+
.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}
|
|
844
|
+
.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}
|
|
845
|
+
.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}
|
|
846
|
+
.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
847
|
.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;
|
|
848
|
+
.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}
|
|
849
|
+
.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
850
|
.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
851
|
.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;
|
|
852
|
+
.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)}
|
|
853
|
+
.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
854
|
.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-
|
|
855
|
+
.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}
|
|
856
|
+
.ok-native-list-item[data-native-list-row-press-enabled="true"]:active>.ok-native-list-history{background:var(--nl-selected)}
|
|
857
|
+
.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}
|
|
858
|
+
.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)}
|
|
859
|
+
.ok-native-list-market-table .ok-native-list-visual-fallback>svg{width:28px;height:28px}
|
|
860
|
+
.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
861
|
.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;
|
|
862
|
+
.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
863
|
.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
864
|
@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-
|
|
865
|
+
.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
866
|
.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;
|
|
867
|
+
.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
868
|
.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
869
|
.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
870
|
.ok-native-list-checkbox[data-selector="networkSelector"]::after{display:none}
|
|
@@ -866,7 +876,7 @@ export const WEB_LIST_CSS = `
|
|
|
866
876
|
/* OneKey patch: selected group members use the same primary title color as standalone wallets. */
|
|
867
877
|
.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
878
|
.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;
|
|
879
|
+
.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
880
|
.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
881
|
.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
882
|
.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 +966,13 @@ function configureWebImageRetry(
|
|
|
956
966
|
const retryLimit = Number.isFinite(source.retryTimes)
|
|
957
967
|
? Math.max(0, Math.floor(source.retryTimes ?? 0))
|
|
958
968
|
: 0;
|
|
959
|
-
|
|
969
|
+
const orderedFallbacks = source.fallbackUris;
|
|
970
|
+
if (!fallbackUri && retryLimit === 0 && orderedFallbacks === undefined)
|
|
971
|
+
return;
|
|
960
972
|
const view = image.ownerDocument.defaultView;
|
|
961
973
|
let currentUri = initialUri;
|
|
962
974
|
let usedFallback = false;
|
|
975
|
+
let fallbackIndex = 0;
|
|
963
976
|
let retryCount = 0;
|
|
964
977
|
let retryTimer: number | undefined;
|
|
965
978
|
let disposed = false;
|
|
@@ -972,7 +985,22 @@ function configureWebImageRetry(
|
|
|
972
985
|
event.stopImmediatePropagation();
|
|
973
986
|
return;
|
|
974
987
|
}
|
|
975
|
-
if (
|
|
988
|
+
if (orderedFallbacks !== undefined && retryCount >= retryLimit) {
|
|
989
|
+
if (fallbackIndex >= orderedFallbacks.length) return;
|
|
990
|
+
const nextUri = safeImageUri(orderedFallbacks[fallbackIndex++]);
|
|
991
|
+
if (!nextUri) return;
|
|
992
|
+
event.stopImmediatePropagation();
|
|
993
|
+
retryCount = 0;
|
|
994
|
+
currentUri = nextUri;
|
|
995
|
+
image.src = currentUri;
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
if (
|
|
999
|
+
orderedFallbacks === undefined &&
|
|
1000
|
+
fallbackUri &&
|
|
1001
|
+
!usedFallback &&
|
|
1002
|
+
fallbackUri !== currentUri
|
|
1003
|
+
) {
|
|
976
1004
|
event.stopImmediatePropagation();
|
|
977
1005
|
usedFallback = true;
|
|
978
1006
|
currentUri = fallbackUri;
|
|
@@ -1012,6 +1040,12 @@ function configureWebAvatar(
|
|
|
1012
1040
|
image.src = resolvedUri;
|
|
1013
1041
|
},
|
|
1014
1042
|
() => {
|
|
1043
|
+
if (source.fallbackUris !== undefined) {
|
|
1044
|
+
configureWebImageRetry(image, source, uri);
|
|
1045
|
+
const ImageEvent = image.ownerDocument.defaultView?.Event;
|
|
1046
|
+
if (ImageEvent) image.dispatchEvent(new ImageEvent('error'));
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1015
1049
|
const fallbackUri = source.fallbackUri
|
|
1016
1050
|
? safeImageUri(source.fallbackUri)
|
|
1017
1051
|
: undefined;
|
|
@@ -1144,6 +1178,23 @@ const selectorIcons: Readonly<
|
|
|
1144
1178
|
}>
|
|
1145
1179
|
>
|
|
1146
1180
|
> = {
|
|
1181
|
+
CryptoCoinOutline: {
|
|
1182
|
+
viewBox: '0 0 24 24',
|
|
1183
|
+
paths: [
|
|
1184
|
+
{
|
|
1185
|
+
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',
|
|
1186
|
+
fill: 'currentColor',
|
|
1187
|
+
fillRule: 'nonzero',
|
|
1188
|
+
opacity: 1,
|
|
1189
|
+
},
|
|
1190
|
+
{
|
|
1191
|
+
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',
|
|
1192
|
+
fill: 'currentColor',
|
|
1193
|
+
fillRule: 'evenodd',
|
|
1194
|
+
opacity: 1,
|
|
1195
|
+
},
|
|
1196
|
+
],
|
|
1197
|
+
},
|
|
1147
1198
|
GlobusOutline: {
|
|
1148
1199
|
viewBox: '0 0 24 24',
|
|
1149
1200
|
paths: [
|
|
@@ -1577,6 +1628,8 @@ function createVisual(
|
|
|
1577
1628
|
if (fallbackIcon.tintColor)
|
|
1578
1629
|
fallback.style.color = fallbackIcon.tintColor;
|
|
1579
1630
|
}
|
|
1631
|
+
fallback.style.backgroundColor =
|
|
1632
|
+
'var(--nl-image-fallback-background, transparent)';
|
|
1580
1633
|
frame.prepend(fallback);
|
|
1581
1634
|
};
|
|
1582
1635
|
if (image) image.addEventListener('error', showFallback, { once: true });
|
|
@@ -1929,7 +1982,23 @@ export function createRowBody(
|
|
|
1929
1982
|
return rowRenderer(row).create(context.document, rendererPrimitives(context));
|
|
1930
1983
|
}
|
|
1931
1984
|
|
|
1985
|
+
export type NativeListWebScrollOptions = Readonly<{
|
|
1986
|
+
scrollHost?: HTMLElement;
|
|
1987
|
+
contentBounds?: HTMLElement;
|
|
1988
|
+
stickyInset?: number;
|
|
1989
|
+
ownsRefresh?: boolean;
|
|
1990
|
+
}>;
|
|
1991
|
+
|
|
1932
1992
|
export class NativeListWebEngine {
|
|
1993
|
+
private readonly externalScrollHost: HTMLElement | undefined;
|
|
1994
|
+
private readonly ownsRefresh: boolean;
|
|
1995
|
+
private readonly pullTarget: HTMLElement;
|
|
1996
|
+
private readonly contentBounds: HTMLElement | undefined;
|
|
1997
|
+
private externalStickyInset: number;
|
|
1998
|
+
private externalOrigin: number | undefined;
|
|
1999
|
+
private externalGeometryCache:
|
|
2000
|
+
| ReturnType<NativeListWebEngine['readExternalGeometry']>
|
|
2001
|
+
| undefined;
|
|
1933
2002
|
private readonly document: Document;
|
|
1934
2003
|
private readonly root: HTMLElement;
|
|
1935
2004
|
private readonly viewportFrame: HTMLElement;
|
|
@@ -1964,6 +2033,7 @@ export class NativeListWebEngine {
|
|
|
1964
2033
|
dataRow: [],
|
|
1965
2034
|
metricCard: [],
|
|
1966
2035
|
market: [],
|
|
2036
|
+
marketTable: [],
|
|
1967
2037
|
identity: [],
|
|
1968
2038
|
sectionHeader: [],
|
|
1969
2039
|
};
|
|
@@ -2009,6 +2079,8 @@ export class NativeListWebEngine {
|
|
|
2009
2079
|
private marketPointer:
|
|
2010
2080
|
| Readonly<{
|
|
2011
2081
|
pointerId: number;
|
|
2082
|
+
pointerType: string;
|
|
2083
|
+
compact: boolean;
|
|
2012
2084
|
rowKey: string;
|
|
2013
2085
|
startX: number;
|
|
2014
2086
|
startY: number;
|
|
@@ -2028,21 +2100,29 @@ export class NativeListWebEngine {
|
|
|
2028
2100
|
|
|
2029
2101
|
private notifyScrollCommandAccepted() {
|
|
2030
2102
|
if (this.destroyed) return;
|
|
2031
|
-
const
|
|
2103
|
+
const owner = this.externalScrollHost ?? this.viewport;
|
|
2104
|
+
const EventConstructor = owner.ownerDocument.defaultView?.Event;
|
|
2032
2105
|
if (EventConstructor)
|
|
2033
|
-
|
|
2106
|
+
owner.dispatchEvent(
|
|
2034
2107
|
new EventConstructor('ok-native-list-scroll-command-accepted')
|
|
2035
2108
|
);
|
|
2036
2109
|
}
|
|
2037
2110
|
|
|
2038
2111
|
private readonly handlePagerScrollCommandCancel = (event: Event) => {
|
|
2039
|
-
|
|
2112
|
+
const owner = this.externalScrollHost ?? this.viewport;
|
|
2113
|
+
if (this.destroyed || event.target !== owner) return;
|
|
2040
2114
|
this.pendingScroll = undefined;
|
|
2041
|
-
|
|
2042
|
-
left:
|
|
2043
|
-
top:
|
|
2115
|
+
const options: ScrollToOptions = {
|
|
2116
|
+
left: owner.scrollLeft,
|
|
2117
|
+
top: owner.scrollTop,
|
|
2044
2118
|
behavior: 'instant',
|
|
2045
|
-
}
|
|
2119
|
+
};
|
|
2120
|
+
if (this.externalScrollHost) {
|
|
2121
|
+
const scrollTo: (options: ScrollToOptions) => void =
|
|
2122
|
+
owner.ownerDocument.defaultView?.Element.prototype.scrollTo ??
|
|
2123
|
+
owner.scrollTo;
|
|
2124
|
+
scrollTo.call(owner, options);
|
|
2125
|
+
} else this.viewport.scrollTo(options);
|
|
2046
2126
|
};
|
|
2047
2127
|
|
|
2048
2128
|
constructor(
|
|
@@ -2051,8 +2131,31 @@ export class NativeListWebEngine {
|
|
|
2051
2131
|
callbacks: NativeListWebCallbacks,
|
|
2052
2132
|
virtualizationEnabled = true,
|
|
2053
2133
|
sectionIndexContainer?: HTMLElement | null,
|
|
2054
|
-
fontFamiliesJson = '{}'
|
|
2134
|
+
fontFamiliesJson = '{}',
|
|
2135
|
+
scrollOptions: NativeListWebScrollOptions = {}
|
|
2055
2136
|
) {
|
|
2137
|
+
if (
|
|
2138
|
+
scrollOptions.scrollHost &&
|
|
2139
|
+
(!(
|
|
2140
|
+
scrollOptions.scrollHost instanceof
|
|
2141
|
+
host.ownerDocument.defaultView!.HTMLElement
|
|
2142
|
+
) ||
|
|
2143
|
+
!scrollOptions.scrollHost.contains(host))
|
|
2144
|
+
)
|
|
2145
|
+
throw new Error(
|
|
2146
|
+
'webScrollHost must be an ancestor HTMLElement in the same document'
|
|
2147
|
+
);
|
|
2148
|
+
this.ownsRefresh = scrollOptions.ownsRefresh === true;
|
|
2149
|
+
if (
|
|
2150
|
+
scrollOptions.scrollHost &&
|
|
2151
|
+
snapshot.layout.orientation === 'horizontal'
|
|
2152
|
+
)
|
|
2153
|
+
throw new Error('External scrolling supports vertical lists only');
|
|
2154
|
+
this.externalScrollHost = scrollOptions.scrollHost;
|
|
2155
|
+
this.contentBounds = scrollOptions.contentBounds;
|
|
2156
|
+
this.externalStickyInset = this.validateStickyInset(
|
|
2157
|
+
scrollOptions.stickyInset
|
|
2158
|
+
);
|
|
2056
2159
|
this.document = host.ownerDocument;
|
|
2057
2160
|
this.snapshot = validateSnapshot(snapshot);
|
|
2058
2161
|
this.callbacks = callbacks;
|
|
@@ -2062,6 +2165,7 @@ export class NativeListWebEngine {
|
|
|
2062
2165
|
if (!host.style.position) host.style.position = 'relative';
|
|
2063
2166
|
|
|
2064
2167
|
this.root = createElement(this.document, 'div', 'ok-native-list-root');
|
|
2168
|
+
setData(this.root, 'nativeListParentScroll', !!this.externalScrollHost);
|
|
2065
2169
|
const style = this.document.createElement('style');
|
|
2066
2170
|
style.textContent = WEB_LIST_CSS;
|
|
2067
2171
|
this.viewportFrame = createElement(
|
|
@@ -2074,6 +2178,10 @@ export class NativeListWebEngine {
|
|
|
2074
2178
|
'div',
|
|
2075
2179
|
'ok-native-list-viewport'
|
|
2076
2180
|
);
|
|
2181
|
+
this.pullTarget =
|
|
2182
|
+
this.externalScrollHost && this.ownsRefresh
|
|
2183
|
+
? this.externalScrollHost
|
|
2184
|
+
: this.viewport;
|
|
2077
2185
|
this.viewport.setAttribute('role', 'list');
|
|
2078
2186
|
this.content = createElement(
|
|
2079
2187
|
this.document,
|
|
@@ -2120,25 +2228,58 @@ export class NativeListWebEngine {
|
|
|
2120
2228
|
);
|
|
2121
2229
|
this.root.append(style, this.viewportFrame, this.footer);
|
|
2122
2230
|
host.appendChild(this.root);
|
|
2231
|
+
if (this.externalScrollHost) {
|
|
2232
|
+
Object.assign(this.root.style, {
|
|
2233
|
+
position: 'relative',
|
|
2234
|
+
inset: 'auto',
|
|
2235
|
+
overflow: 'visible',
|
|
2236
|
+
flex: 'none',
|
|
2237
|
+
});
|
|
2238
|
+
Object.assign(this.viewportFrame.style, {
|
|
2239
|
+
overflow: 'visible',
|
|
2240
|
+
flex: 'none',
|
|
2241
|
+
});
|
|
2242
|
+
Object.assign(this.viewport.style, {
|
|
2243
|
+
position: 'relative',
|
|
2244
|
+
inset: 'auto',
|
|
2245
|
+
overflow: 'visible',
|
|
2246
|
+
scrollbarGutter: 'auto',
|
|
2247
|
+
});
|
|
2248
|
+
this.content.style.minHeight = '0';
|
|
2249
|
+
this.externalScrollHost.addEventListener(
|
|
2250
|
+
'scroll',
|
|
2251
|
+
this.handleExternalScroll,
|
|
2252
|
+
{
|
|
2253
|
+
passive: true,
|
|
2254
|
+
capture: true,
|
|
2255
|
+
}
|
|
2256
|
+
);
|
|
2257
|
+
}
|
|
2123
2258
|
|
|
2124
|
-
this.viewport.addEventListener(
|
|
2259
|
+
(this.externalScrollHost ?? this.viewport).addEventListener(
|
|
2125
2260
|
'ok-collapsible-pager-cancel-scroll-command',
|
|
2126
2261
|
this.handlePagerScrollCommandCancel
|
|
2127
2262
|
);
|
|
2128
2263
|
this.viewport.addEventListener('scroll', this.handleScroll, {
|
|
2129
2264
|
passive: true,
|
|
2130
2265
|
});
|
|
2131
|
-
this.viewport.addEventListener(
|
|
2266
|
+
(this.externalScrollHost ?? this.viewport).addEventListener(
|
|
2132
2267
|
'ok-collapsible-pager-insets-changed',
|
|
2133
2268
|
this.handleCollapsiblePagerInsetsChanged
|
|
2134
2269
|
);
|
|
2135
2270
|
this.root.addEventListener('click', this.handleClick);
|
|
2271
|
+
this.root.addEventListener('contextmenu', this.handleMarketContextMenu);
|
|
2136
2272
|
this.root.addEventListener('pointerdown', this.handleMarketPointerDown);
|
|
2137
2273
|
this.root.addEventListener('pointermove', this.handleMarketPointerMove);
|
|
2274
|
+
this.root.addEventListener('touchmove', this.handleMarketTouchMove, {
|
|
2275
|
+
passive: true,
|
|
2276
|
+
});
|
|
2138
2277
|
this.root.addEventListener('pointerup', this.handleMarketPointerEnd);
|
|
2139
2278
|
this.root.addEventListener('pointercancel', this.handleMarketPointerEnd);
|
|
2140
2279
|
// OneKey patch: preserve web tooltip hover for section titles.
|
|
2141
2280
|
this.root.addEventListener('pointerover', this.handleTitlePointerOver);
|
|
2281
|
+
this.root.addEventListener('focusin', this.handleTitlePointerOver);
|
|
2282
|
+
this.root.addEventListener('focusout', this.handleTitlePointerOut);
|
|
2142
2283
|
this.root.addEventListener('pointerout', this.handleTitlePointerOut);
|
|
2143
2284
|
this.root.addEventListener('keydown', this.handleKeyDown);
|
|
2144
2285
|
this.viewport.addEventListener(
|
|
@@ -2174,14 +2315,14 @@ export class NativeListWebEngine {
|
|
|
2174
2315
|
this.handleIndexPointerEnd
|
|
2175
2316
|
);
|
|
2176
2317
|
this.indexRail.addEventListener('click', this.handleIndexClick);
|
|
2177
|
-
this.
|
|
2318
|
+
this.pullTarget.addEventListener('pointerdown', this.handlePullStart, {
|
|
2178
2319
|
passive: true,
|
|
2179
2320
|
});
|
|
2180
|
-
this.
|
|
2321
|
+
this.pullTarget.addEventListener('pointermove', this.handlePullMove, {
|
|
2181
2322
|
passive: false,
|
|
2182
2323
|
});
|
|
2183
|
-
this.
|
|
2184
|
-
this.
|
|
2324
|
+
this.pullTarget.addEventListener('pointerup', this.handlePullEnd);
|
|
2325
|
+
this.pullTarget.addEventListener('pointercancel', this.handlePullEnd);
|
|
2185
2326
|
|
|
2186
2327
|
const ResizeObserverConstructor = this.document.defaultView?.ResizeObserver;
|
|
2187
2328
|
if (ResizeObserverConstructor) {
|
|
@@ -2189,17 +2330,78 @@ export class NativeListWebEngine {
|
|
|
2189
2330
|
this.recomputeLayout()
|
|
2190
2331
|
);
|
|
2191
2332
|
this.resizeObserver.observe(this.viewport);
|
|
2333
|
+
if (this.externalScrollHost) {
|
|
2334
|
+
this.resizeObserver.observe(this.externalScrollHost);
|
|
2335
|
+
let ancestor: HTMLElement | null = host;
|
|
2336
|
+
while (ancestor && ancestor !== this.externalScrollHost) {
|
|
2337
|
+
this.resizeObserver.observe(ancestor);
|
|
2338
|
+
for (const sibling of ancestor.parentElement?.children ?? []) {
|
|
2339
|
+
if (sibling instanceof this.document.defaultView!.HTMLElement)
|
|
2340
|
+
this.resizeObserver.observe(sibling);
|
|
2341
|
+
}
|
|
2342
|
+
ancestor = ancestor.parentElement;
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2192
2345
|
} else {
|
|
2193
2346
|
this.document.defaultView?.addEventListener(
|
|
2194
2347
|
'resize',
|
|
2195
2348
|
this.handleWindowResize
|
|
2196
2349
|
);
|
|
2197
2350
|
}
|
|
2351
|
+
this.document.fonts?.addEventListener(
|
|
2352
|
+
'loadingdone',
|
|
2353
|
+
this.handleWindowResize
|
|
2354
|
+
);
|
|
2198
2355
|
this.observeSectionIndexTransforms();
|
|
2199
2356
|
this.applyFontFamilies(fontFamiliesJson);
|
|
2200
2357
|
this.applySnapshot(this.snapshot);
|
|
2201
2358
|
}
|
|
2202
2359
|
|
|
2360
|
+
private validateStickyInset(value = 0): number {
|
|
2361
|
+
if (!Number.isFinite(value) || value < 0)
|
|
2362
|
+
throw new Error('webStickyInset must be finite and non-negative');
|
|
2363
|
+
return value;
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
setStickyInset(value = 0) {
|
|
2367
|
+
const next = this.validateStickyInset(value);
|
|
2368
|
+
if (next === this.externalStickyInset) return;
|
|
2369
|
+
this.externalStickyInset = next;
|
|
2370
|
+
this.recomputeLayout();
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
private externalGeometry() {
|
|
2374
|
+
return (this.externalGeometryCache ??= this.readExternalGeometry());
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
private readExternalGeometry() {
|
|
2378
|
+
const host = this.externalScrollHost!;
|
|
2379
|
+
const hostRect = host.getBoundingClientRect();
|
|
2380
|
+
const bodyRect = this.viewport.getBoundingClientRect();
|
|
2381
|
+
const boundsRect = (
|
|
2382
|
+
this.contentBounds ?? this.root
|
|
2383
|
+
).getBoundingClientRect();
|
|
2384
|
+
const top = hostRect.top + host.clientTop + this.externalStickyInset;
|
|
2385
|
+
const bottom = hostRect.top + host.clientTop + host.clientHeight;
|
|
2386
|
+
return {
|
|
2387
|
+
origin: bodyRect.top - hostRect.top - host.clientTop + host.scrollTop,
|
|
2388
|
+
containerOrigin:
|
|
2389
|
+
boundsRect.top - hostRect.top - host.clientTop + host.scrollTop,
|
|
2390
|
+
end: boundsRect.bottom - hostRect.top - host.clientTop + host.scrollTop,
|
|
2391
|
+
top,
|
|
2392
|
+
bottom,
|
|
2393
|
+
offset: top - bodyRect.top,
|
|
2394
|
+
viewportLength: Math.max(0, bottom - top),
|
|
2395
|
+
visible:
|
|
2396
|
+
bodyRect.width > 0 &&
|
|
2397
|
+
bodyRect.right > hostRect.left &&
|
|
2398
|
+
bodyRect.left < hostRect.right &&
|
|
2399
|
+
host.clientHeight > 0 &&
|
|
2400
|
+
boundsRect.bottom > top &&
|
|
2401
|
+
boundsRect.top < bottom,
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2203
2405
|
private fontFamiliesJson = '{}';
|
|
2204
2406
|
|
|
2205
2407
|
private applyFontFamilies(json: string) {
|
|
@@ -2238,10 +2440,23 @@ export class NativeListWebEngine {
|
|
|
2238
2440
|
|
|
2239
2441
|
applySnapshot(snapshot: NativeListSnapshot) {
|
|
2240
2442
|
const validated = validateSnapshot(snapshot);
|
|
2443
|
+
if (
|
|
2444
|
+
this.externalScrollHost &&
|
|
2445
|
+
validated.layout.orientation === 'horizontal'
|
|
2446
|
+
)
|
|
2447
|
+
throw new Error('External scrolling supports vertical lists only');
|
|
2241
2448
|
this.invalidateActionAnchor('snapshot');
|
|
2242
2449
|
this.setSnapshot(validated);
|
|
2243
2450
|
}
|
|
2244
2451
|
|
|
2452
|
+
currentContentHeight(): number {
|
|
2453
|
+
return this.layout.contentHeight;
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
currentSnapshot(): NativeListSnapshot {
|
|
2457
|
+
return this.snapshot;
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2245
2460
|
applyPatches(patches: readonly RowPatch[]) {
|
|
2246
2461
|
if (patches.length === 0) return;
|
|
2247
2462
|
const next = applyRowPatches(this.snapshot, patches);
|
|
@@ -2252,7 +2467,21 @@ export class NativeListWebEngine {
|
|
|
2252
2467
|
if (selected === true) selection.add(patch.key);
|
|
2253
2468
|
else if (selected === false) selection.delete(patch.key);
|
|
2254
2469
|
});
|
|
2255
|
-
|
|
2470
|
+
const tableValuesOnly = patches.every((patch) => {
|
|
2471
|
+
const index = this.rows.findIndex((row) => row.key === patch.key);
|
|
2472
|
+
const before = this.rows[index],
|
|
2473
|
+
after = next.rows[index];
|
|
2474
|
+
return (
|
|
2475
|
+
patch.type === 'market' &&
|
|
2476
|
+
before?.type === 'market' &&
|
|
2477
|
+
after?.type === 'market' &&
|
|
2478
|
+
Object.keys(patch.changes).every(
|
|
2479
|
+
(key) => MARKET_QUOTE_PATCH_FIELDS.has(key) || key === 'webTable'
|
|
2480
|
+
) &&
|
|
2481
|
+
canPatchMarketTableValues(before, after)
|
|
2482
|
+
);
|
|
2483
|
+
});
|
|
2484
|
+
if (webMarketImageBindDeltaForPatches(patches) === 0 || tableValuesOnly) {
|
|
2256
2485
|
this.snapshot = next;
|
|
2257
2486
|
this.rows = effectiveRows(next);
|
|
2258
2487
|
this.selectedKeys = selection;
|
|
@@ -2261,14 +2490,16 @@ export class NativeListWebEngine {
|
|
|
2261
2490
|
const row = this.rows[index];
|
|
2262
2491
|
const element = this.mounted.get(index);
|
|
2263
2492
|
if (row?.type === 'market' && element) {
|
|
2264
|
-
|
|
2493
|
+
if (row.webTable) updateMarketTableValues(element, row);
|
|
2494
|
+
else setMarketQuoteContent(element, row);
|
|
2265
2495
|
element.dataset.renderSignature = webRowRenderSignature(row);
|
|
2266
2496
|
}
|
|
2267
2497
|
if (
|
|
2268
2498
|
row?.type === 'market' &&
|
|
2269
2499
|
this.sticky.dataset.nativeListRowKey === row.key
|
|
2270
2500
|
) {
|
|
2271
|
-
|
|
2501
|
+
if (row.webTable) updateMarketTableValues(this.sticky, row);
|
|
2502
|
+
else setMarketQuoteContent(this.sticky, row);
|
|
2272
2503
|
this.sticky.dataset.renderSignature = webRowRenderSignature(row);
|
|
2273
2504
|
}
|
|
2274
2505
|
});
|
|
@@ -2332,7 +2563,10 @@ export class NativeListWebEngine {
|
|
|
2332
2563
|
this.pendingScroll = { kind: 'offset', offset, animated };
|
|
2333
2564
|
return;
|
|
2334
2565
|
}
|
|
2335
|
-
this.
|
|
2566
|
+
if (this.externalScrollHost) {
|
|
2567
|
+
const geometry = this.externalGeometry();
|
|
2568
|
+
this.writeExternalOffset(geometry.containerOrigin + offset, animated);
|
|
2569
|
+
} else this.scrollToAbsoluteOffset(offset, animated);
|
|
2336
2570
|
}
|
|
2337
2571
|
|
|
2338
2572
|
scrollToEnd(animated: boolean) {
|
|
@@ -2341,10 +2575,17 @@ export class NativeListWebEngine {
|
|
|
2341
2575
|
this.pendingScroll = { kind: 'end', animated };
|
|
2342
2576
|
return;
|
|
2343
2577
|
}
|
|
2344
|
-
this.
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2578
|
+
if (this.externalScrollHost) {
|
|
2579
|
+
const geometry = this.externalGeometry();
|
|
2580
|
+
this.writeExternalOffset(
|
|
2581
|
+
geometry.end - this.externalScrollHost.clientHeight,
|
|
2582
|
+
animated
|
|
2583
|
+
);
|
|
2584
|
+
} else
|
|
2585
|
+
this.scrollToAbsoluteOffset(
|
|
2586
|
+
Math.max(0, this.contentLength() - this.viewportLength()),
|
|
2587
|
+
animated
|
|
2588
|
+
);
|
|
2348
2589
|
}
|
|
2349
2590
|
|
|
2350
2591
|
scrollToLocation(
|
|
@@ -2410,28 +2651,41 @@ export class NativeListWebEngine {
|
|
|
2410
2651
|
if (this.reorderMovementTimer !== undefined)
|
|
2411
2652
|
this.document.defaultView?.clearTimeout(this.reorderMovementTimer);
|
|
2412
2653
|
this.resizeObserver?.disconnect();
|
|
2654
|
+
this.externalScrollHost?.removeEventListener(
|
|
2655
|
+
'scroll',
|
|
2656
|
+
this.handleExternalScroll,
|
|
2657
|
+
true
|
|
2658
|
+
);
|
|
2659
|
+
this.document.fonts?.removeEventListener(
|
|
2660
|
+
'loadingdone',
|
|
2661
|
+
this.handleWindowResize
|
|
2662
|
+
);
|
|
2413
2663
|
this.sectionIndexTransformObserver?.disconnect();
|
|
2414
2664
|
this.document.defaultView?.removeEventListener(
|
|
2415
2665
|
'resize',
|
|
2416
2666
|
this.handleWindowResize
|
|
2417
2667
|
);
|
|
2418
2668
|
this.pendingScroll = undefined;
|
|
2419
|
-
this.viewport.removeEventListener(
|
|
2669
|
+
(this.externalScrollHost ?? this.viewport).removeEventListener(
|
|
2420
2670
|
'ok-collapsible-pager-cancel-scroll-command',
|
|
2421
2671
|
this.handlePagerScrollCommandCancel
|
|
2422
2672
|
);
|
|
2423
2673
|
this.viewport.removeEventListener('scroll', this.handleScroll);
|
|
2424
|
-
this.viewport.removeEventListener(
|
|
2674
|
+
(this.externalScrollHost ?? this.viewport).removeEventListener(
|
|
2425
2675
|
'ok-collapsible-pager-insets-changed',
|
|
2426
2676
|
this.handleCollapsiblePagerInsetsChanged
|
|
2427
2677
|
);
|
|
2428
2678
|
this.root.removeEventListener('click', this.handleClick);
|
|
2679
|
+
this.root.removeEventListener('contextmenu', this.handleMarketContextMenu);
|
|
2429
2680
|
this.cancelMarketPointer();
|
|
2430
2681
|
this.root.removeEventListener('pointerdown', this.handleMarketPointerDown);
|
|
2431
2682
|
this.root.removeEventListener('pointermove', this.handleMarketPointerMove);
|
|
2683
|
+
this.root.removeEventListener('touchmove', this.handleMarketTouchMove);
|
|
2432
2684
|
this.root.removeEventListener('pointerup', this.handleMarketPointerEnd);
|
|
2433
2685
|
this.root.removeEventListener('pointercancel', this.handleMarketPointerEnd);
|
|
2434
2686
|
this.root.removeEventListener('pointerover', this.handleTitlePointerOver);
|
|
2687
|
+
this.root.removeEventListener('focusin', this.handleTitlePointerOver);
|
|
2688
|
+
this.root.removeEventListener('focusout', this.handleTitlePointerOut);
|
|
2435
2689
|
this.root.removeEventListener('pointerout', this.handleTitlePointerOut);
|
|
2436
2690
|
this.root.removeEventListener('keydown', this.handleKeyDown);
|
|
2437
2691
|
this.cancelPointerReorder(true);
|
|
@@ -2465,10 +2719,10 @@ export class NativeListWebEngine {
|
|
|
2465
2719
|
this.handleIndexPointerEnd
|
|
2466
2720
|
);
|
|
2467
2721
|
this.indexRail.removeEventListener('click', this.handleIndexClick);
|
|
2468
|
-
this.
|
|
2469
|
-
this.
|
|
2470
|
-
this.
|
|
2471
|
-
this.
|
|
2722
|
+
this.pullTarget.removeEventListener('pointerdown', this.handlePullStart);
|
|
2723
|
+
this.pullTarget.removeEventListener('pointermove', this.handlePullMove);
|
|
2724
|
+
this.pullTarget.removeEventListener('pointerup', this.handlePullEnd);
|
|
2725
|
+
this.pullTarget.removeEventListener('pointercancel', this.handlePullEnd);
|
|
2472
2726
|
const host = this.root.parentElement;
|
|
2473
2727
|
disposeWebImageRetries(this.root);
|
|
2474
2728
|
Object.values(this.pool).forEach((elements) =>
|
|
@@ -2514,6 +2768,8 @@ export class NativeListWebEngine {
|
|
|
2514
2768
|
'--nl-pressed': theme.rowPressedBackground,
|
|
2515
2769
|
'--nl-subdued': theme.subduedBackground,
|
|
2516
2770
|
'--nl-strong': theme.strongBackground,
|
|
2771
|
+
'--nl-image-fallback-background':
|
|
2772
|
+
theme.imageFallbackBackground ?? 'transparent',
|
|
2517
2773
|
'--nl-primary': theme.primaryText,
|
|
2518
2774
|
'--nl-secondary': theme.secondaryText,
|
|
2519
2775
|
'--nl-disabled': theme.disabledText,
|
|
@@ -2566,8 +2822,79 @@ export class NativeListWebEngine {
|
|
|
2566
2822
|
});
|
|
2567
2823
|
}
|
|
2568
2824
|
|
|
2825
|
+
private computeLayout(
|
|
2826
|
+
viewportWidth: number,
|
|
2827
|
+
viewportHeight: number
|
|
2828
|
+
): WebListLayout {
|
|
2829
|
+
const measuredSnapshot: NativeListSnapshot = {
|
|
2830
|
+
...this.snapshot,
|
|
2831
|
+
rows: this.snapshot.rows.map((row) =>
|
|
2832
|
+
row.style?.container?.height === undefined &&
|
|
2833
|
+
row.height === undefined &&
|
|
2834
|
+
this.measuredRendererHeights.get(row.key)?.signature ===
|
|
2835
|
+
webRowRenderSignature(row)
|
|
2836
|
+
? {
|
|
2837
|
+
...row,
|
|
2838
|
+
height: this.measuredRendererHeights.get(row.key)!.height,
|
|
2839
|
+
}
|
|
2840
|
+
: row
|
|
2841
|
+
),
|
|
2842
|
+
};
|
|
2843
|
+
let layout = computeWebListLayout(
|
|
2844
|
+
measuredSnapshot,
|
|
2845
|
+
viewportWidth,
|
|
2846
|
+
viewportHeight,
|
|
2847
|
+
this.reorderCompactKey
|
|
2848
|
+
);
|
|
2849
|
+
if (this.externalScrollHost) {
|
|
2850
|
+
const padding = paddingValues(this.snapshot);
|
|
2851
|
+
layout = {
|
|
2852
|
+
...layout,
|
|
2853
|
+
contentHeight:
|
|
2854
|
+
Math.max(
|
|
2855
|
+
padding.top,
|
|
2856
|
+
...layout.items.map((item) => item.y + item.height)
|
|
2857
|
+
) + padding.bottom,
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2860
|
+
return layout;
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
private writeExternalHeight(height: number) {
|
|
2864
|
+
const value = String(height) + 'px';
|
|
2865
|
+
this.content.style.height = value;
|
|
2866
|
+
this.viewport.style.height = value;
|
|
2867
|
+
this.viewportFrame.style.height = value;
|
|
2868
|
+
this.root.style.height = value;
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2569
2871
|
private recomputeLayout = () => {
|
|
2570
2872
|
if (this.destroyed) return;
|
|
2873
|
+
const cachedWidth = this.lastViewportWidth;
|
|
2874
|
+
const cachedHeight = this.lastViewportHeight;
|
|
2875
|
+
const precomputedLayout =
|
|
2876
|
+
this.externalScrollHost && cachedWidth > 0 && cachedHeight > 0
|
|
2877
|
+
? this.computeLayout(cachedWidth, cachedHeight)
|
|
2878
|
+
: undefined;
|
|
2879
|
+
if (precomputedLayout) {
|
|
2880
|
+
// Commit appended row extent before measuring React-owned slot changes.
|
|
2881
|
+
this.writeExternalHeight(
|
|
2882
|
+
Math.max(this.layout.contentHeight, precomputedLayout.contentHeight)
|
|
2883
|
+
);
|
|
2884
|
+
}
|
|
2885
|
+
this.externalGeometryCache = undefined;
|
|
2886
|
+
if (this.externalScrollHost) {
|
|
2887
|
+
const geometry = this.externalGeometry();
|
|
2888
|
+
const previousOrigin = this.externalOrigin;
|
|
2889
|
+
this.externalOrigin = geometry.origin;
|
|
2890
|
+
if (
|
|
2891
|
+
previousOrigin !== undefined &&
|
|
2892
|
+
geometry.origin !== previousOrigin &&
|
|
2893
|
+
this.externalScrollHost.scrollTop > previousOrigin &&
|
|
2894
|
+
geometry.visible
|
|
2895
|
+
)
|
|
2896
|
+
this.externalScrollHost.scrollTop += geometry.origin - previousOrigin;
|
|
2897
|
+
}
|
|
2571
2898
|
const viewportWidth = this.viewport.clientWidth;
|
|
2572
2899
|
const viewportHeight =
|
|
2573
2900
|
this.snapshot.layout.orientation === 'horizontal'
|
|
@@ -2595,28 +2922,18 @@ export class NativeListWebEngine {
|
|
|
2595
2922
|
this.lastViewportWidth = viewportWidth;
|
|
2596
2923
|
this.lastViewportHeight = viewportHeight;
|
|
2597
2924
|
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
|
-
);
|
|
2925
|
+
this.layout =
|
|
2926
|
+
precomputedLayout &&
|
|
2927
|
+
viewportWidth === cachedWidth &&
|
|
2928
|
+
viewportHeight === cachedHeight
|
|
2929
|
+
? precomputedLayout
|
|
2930
|
+
: this.computeLayout(viewportWidth, viewportHeight);
|
|
2618
2931
|
this.content.style.width = String(this.layout.contentWidth) + 'px';
|
|
2619
2932
|
this.content.style.height = String(this.layout.contentHeight) + 'px';
|
|
2933
|
+
if (this.externalScrollHost) {
|
|
2934
|
+
this.writeExternalHeight(this.layout.contentHeight);
|
|
2935
|
+
this.externalGeometryCache = undefined;
|
|
2936
|
+
}
|
|
2620
2937
|
this.renderSectionIndex(
|
|
2621
2938
|
this.viewport.clientHeight <= 0
|
|
2622
2939
|
? DEFAULT_VIEWPORT_HEIGHT
|
|
@@ -2632,6 +2949,11 @@ export class NativeListWebEngine {
|
|
|
2632
2949
|
};
|
|
2633
2950
|
|
|
2634
2951
|
private updateAvatarWindow() {
|
|
2952
|
+
if (this.externalScrollHost && !this.externalGeometry().visible) {
|
|
2953
|
+
this.avatarLeases.forEach((lease) => lease());
|
|
2954
|
+
this.avatarLeases.clear();
|
|
2955
|
+
return;
|
|
2956
|
+
}
|
|
2635
2957
|
const offset = this.currentOffset();
|
|
2636
2958
|
if (offset !== this.avatarOffset)
|
|
2637
2959
|
this.avatarDirection = Math.sign(offset - this.avatarOffset);
|
|
@@ -2688,13 +3010,16 @@ export class NativeListWebEngine {
|
|
|
2688
3010
|
private renderWindow() {
|
|
2689
3011
|
this.updateAvatarWindow();
|
|
2690
3012
|
const viewportLength = this.viewportLength();
|
|
2691
|
-
const visible =
|
|
2692
|
-
this.
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
3013
|
+
const visible =
|
|
3014
|
+
this.externalScrollHost && !this.externalGeometry().visible
|
|
3015
|
+
? []
|
|
3016
|
+
: webLayoutItemsForMount(
|
|
3017
|
+
this.layout,
|
|
3018
|
+
this.currentOffset(),
|
|
3019
|
+
viewportLength,
|
|
3020
|
+
this.virtualizationEnabled,
|
|
3021
|
+
viewportLength * OVERSCAN_VIEWPORTS
|
|
3022
|
+
);
|
|
2698
3023
|
const desired = new Set(visible.map((item) => item.index));
|
|
2699
3024
|
this.mounted.forEach((element, index) => {
|
|
2700
3025
|
const nextRow = this.rows[index];
|
|
@@ -2797,6 +3122,11 @@ export class NativeListWebEngine {
|
|
|
2797
3122
|
? 'ok-native-list-item ok-native-list-sticky'
|
|
2798
3123
|
: 'ok-native-list-item';
|
|
2799
3124
|
setData(element, 'nativeListRowKey', row.key);
|
|
3125
|
+
setData(
|
|
3126
|
+
element,
|
|
3127
|
+
'nativeListMediaGallery',
|
|
3128
|
+
row.type === 'mediaTile' && row.variant === 'gallery' ? 'true' : undefined
|
|
3129
|
+
);
|
|
2800
3130
|
setData(element, 'nativeListBindingEpoch', bindingEpoch);
|
|
2801
3131
|
setData(element, 'nativeListRowIndex', index);
|
|
2802
3132
|
setData(element, 'nativeListDisabled', Boolean(row.disabled));
|
|
@@ -3221,11 +3551,14 @@ export class NativeListWebEngine {
|
|
|
3221
3551
|
}
|
|
3222
3552
|
|
|
3223
3553
|
private updateVisibleState() {
|
|
3224
|
-
const visible =
|
|
3225
|
-
this.
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3554
|
+
const visible =
|
|
3555
|
+
this.externalScrollHost && !this.externalGeometry().visible
|
|
3556
|
+
? []
|
|
3557
|
+
: visibleWebLayoutItems(
|
|
3558
|
+
this.layout,
|
|
3559
|
+
this.currentOffset(),
|
|
3560
|
+
this.viewportLength()
|
|
3561
|
+
);
|
|
3229
3562
|
const first = visible[0];
|
|
3230
3563
|
const last = visible.at(-1);
|
|
3231
3564
|
const signature =
|
|
@@ -3295,6 +3628,8 @@ export class NativeListWebEngine {
|
|
|
3295
3628
|
this.sticky.style.right = 'auto';
|
|
3296
3629
|
this.sticky.style.width = String(item.width) + 'px';
|
|
3297
3630
|
this.sticky.style.height = String(item.height) + 'px';
|
|
3631
|
+
if (this.externalScrollHost)
|
|
3632
|
+
this.sticky.style.top = String(Math.max(0, this.currentOffset())) + 'px';
|
|
3298
3633
|
let nextIndex = -1;
|
|
3299
3634
|
for (let cursor = index + 1; cursor < this.rows.length; cursor += 1) {
|
|
3300
3635
|
const candidate = this.rows[cursor];
|
|
@@ -3333,6 +3668,7 @@ export class NativeListWebEngine {
|
|
|
3333
3668
|
|
|
3334
3669
|
private checkEndReached(lastVisibleIndex: number) {
|
|
3335
3670
|
if (
|
|
3671
|
+
(this.externalScrollHost && !this.externalGeometry().visible) ||
|
|
3336
3672
|
!this.snapshot.capabilities?.loadMore ||
|
|
3337
3673
|
this.reachedGeneration === this.snapshot.generation ||
|
|
3338
3674
|
this.rows.length === 0
|
|
@@ -3371,6 +3707,11 @@ export class NativeListWebEngine {
|
|
|
3371
3707
|
}
|
|
3372
3708
|
|
|
3373
3709
|
private canScroll(): boolean {
|
|
3710
|
+
if (this.externalScrollHost)
|
|
3711
|
+
return (
|
|
3712
|
+
this.viewport.clientWidth > 0 &&
|
|
3713
|
+
this.externalScrollHost.clientHeight > 0
|
|
3714
|
+
);
|
|
3374
3715
|
const viewportLength = this.layout.horizontal
|
|
3375
3716
|
? this.viewport.clientWidth
|
|
3376
3717
|
: this.viewport.clientHeight;
|
|
@@ -3381,11 +3722,19 @@ export class NativeListWebEngine {
|
|
|
3381
3722
|
if (this.layout.horizontal) {
|
|
3382
3723
|
return this.viewport.clientWidth || DEFAULT_VIEWPORT_WIDTH;
|
|
3383
3724
|
}
|
|
3725
|
+
if (this.externalScrollHost) return this.externalGeometry().viewportLength;
|
|
3384
3726
|
if (this.viewport.clientHeight <= 0) return DEFAULT_VIEWPORT_HEIGHT;
|
|
3385
3727
|
return Math.max(1, this.verticalScrollMetrics().viewportLength);
|
|
3386
3728
|
}
|
|
3387
3729
|
|
|
3388
3730
|
private contentLength(): number {
|
|
3731
|
+
if (this.externalScrollHost) {
|
|
3732
|
+
const geometry = this.externalGeometry();
|
|
3733
|
+
return Math.max(
|
|
3734
|
+
this.layout.contentHeight,
|
|
3735
|
+
geometry.end - geometry.origin
|
|
3736
|
+
);
|
|
3737
|
+
}
|
|
3389
3738
|
return this.layout.horizontal
|
|
3390
3739
|
? this.layout.contentWidth
|
|
3391
3740
|
: this.layout.contentHeight;
|
|
@@ -3401,6 +3750,8 @@ export class NativeListWebEngine {
|
|
|
3401
3750
|
header: number;
|
|
3402
3751
|
sticky: number;
|
|
3403
3752
|
}> {
|
|
3753
|
+
if (this.externalScrollHost)
|
|
3754
|
+
return { header: 0, sticky: this.externalStickyInset };
|
|
3404
3755
|
const readInset = (name: string) => {
|
|
3405
3756
|
const parsed = Number.parseFloat(
|
|
3406
3757
|
this.viewport.style.getPropertyValue(name)
|
|
@@ -3414,6 +3765,7 @@ export class NativeListWebEngine {
|
|
|
3414
3765
|
}
|
|
3415
3766
|
|
|
3416
3767
|
private verticalScrollMetrics(): WebCollapsiblePagerScrollMetrics {
|
|
3768
|
+
if (this.externalScrollHost) return this.externalGeometry();
|
|
3417
3769
|
const insets = this.collapsiblePagerInsets();
|
|
3418
3770
|
return resolveWebCollapsiblePagerScrollMetrics(
|
|
3419
3771
|
this.viewport.scrollTop,
|
|
@@ -3427,7 +3779,31 @@ export class NativeListWebEngine {
|
|
|
3427
3779
|
this.recomputeLayout();
|
|
3428
3780
|
};
|
|
3429
3781
|
|
|
3782
|
+
private writeExternalOffset(rawOffset: number, animated: boolean) {
|
|
3783
|
+
this.externalGeometryCache = undefined;
|
|
3784
|
+
const host = this.externalScrollHost!;
|
|
3785
|
+
const scrollTo: (options: ScrollToOptions) => void =
|
|
3786
|
+
host.ownerDocument.defaultView?.Element.prototype.scrollTo ??
|
|
3787
|
+
host.scrollTo;
|
|
3788
|
+
scrollTo.call(host, {
|
|
3789
|
+
top: Math.max(
|
|
3790
|
+
0,
|
|
3791
|
+
Math.min(host.scrollHeight - host.clientHeight, rawOffset)
|
|
3792
|
+
),
|
|
3793
|
+
behavior: animated ? 'smooth' : 'auto',
|
|
3794
|
+
});
|
|
3795
|
+
this.scheduleFrame();
|
|
3796
|
+
}
|
|
3797
|
+
|
|
3430
3798
|
private scrollToAbsoluteOffset(offset: number, animated: boolean) {
|
|
3799
|
+
if (this.externalScrollHost) {
|
|
3800
|
+
const geometry = this.externalGeometry();
|
|
3801
|
+
this.writeExternalOffset(
|
|
3802
|
+
geometry.origin + offset - this.externalStickyInset,
|
|
3803
|
+
animated
|
|
3804
|
+
);
|
|
3805
|
+
return;
|
|
3806
|
+
}
|
|
3431
3807
|
const resolved = Math.min(
|
|
3432
3808
|
Math.max(0, offset),
|
|
3433
3809
|
Math.max(0, this.contentLength() - this.viewportLength())
|
|
@@ -3507,7 +3883,8 @@ export class NativeListWebEngine {
|
|
|
3507
3883
|
row: RowModel,
|
|
3508
3884
|
actionKey: string,
|
|
3509
3885
|
actionElement?: HTMLElement,
|
|
3510
|
-
rowElement?: HTMLElement
|
|
3886
|
+
rowElement?: HTMLElement,
|
|
3887
|
+
windowPoint?: RowActionEvent['windowPoint']
|
|
3511
3888
|
) {
|
|
3512
3889
|
const anchor =
|
|
3513
3890
|
actionElement && rowElement
|
|
@@ -3518,6 +3895,11 @@ export class NativeListWebEngine {
|
|
|
3518
3895
|
actionKey,
|
|
3519
3896
|
sectionKey: row.sectionKey,
|
|
3520
3897
|
anchor,
|
|
3898
|
+
...(windowPoint &&
|
|
3899
|
+
Number.isFinite(windowPoint.x) &&
|
|
3900
|
+
Number.isFinite(windowPoint.y)
|
|
3901
|
+
? { windowPoint }
|
|
3902
|
+
: {}),
|
|
3521
3903
|
});
|
|
3522
3904
|
}
|
|
3523
3905
|
|
|
@@ -3654,6 +4036,38 @@ export class NativeListWebEngine {
|
|
|
3654
4036
|
this.marketPointer = undefined;
|
|
3655
4037
|
}
|
|
3656
4038
|
|
|
4039
|
+
private handleMarketContextMenu = (event: MouseEvent) => {
|
|
4040
|
+
if (
|
|
4041
|
+
!(event.target instanceof Element) ||
|
|
4042
|
+
event.target.closest('[data-native-list-action]')
|
|
4043
|
+
)
|
|
4044
|
+
return;
|
|
4045
|
+
const element = event.target.closest<HTMLElement>(
|
|
4046
|
+
'[data-native-list-row-key]'
|
|
4047
|
+
);
|
|
4048
|
+
const row = this.rowAtElement(element);
|
|
4049
|
+
if (
|
|
4050
|
+
row?.type !== 'market' ||
|
|
4051
|
+
!row.webTable?.contextMenuActionKey ||
|
|
4052
|
+
!element ||
|
|
4053
|
+
!isRowPressEnabled(row)
|
|
4054
|
+
)
|
|
4055
|
+
return;
|
|
4056
|
+
event.preventDefault();
|
|
4057
|
+
this.cancelMarketPointer();
|
|
4058
|
+
markActionAnchorSource(element, 'row');
|
|
4059
|
+
const rect = element.getBoundingClientRect();
|
|
4060
|
+
this.emitRowAction(
|
|
4061
|
+
row,
|
|
4062
|
+
row.webTable.contextMenuActionKey,
|
|
4063
|
+
element,
|
|
4064
|
+
element,
|
|
4065
|
+
event.clientX || event.clientY
|
|
4066
|
+
? { x: event.clientX, y: event.clientY }
|
|
4067
|
+
: { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 }
|
|
4068
|
+
);
|
|
4069
|
+
};
|
|
4070
|
+
|
|
3657
4071
|
private handleMarketPointerDown = (event: PointerEvent) => {
|
|
3658
4072
|
if (event.button !== 0 || !(event.target instanceof Element)) return;
|
|
3659
4073
|
this.marketLongPressFired = false;
|
|
@@ -3673,16 +4087,35 @@ export class NativeListWebEngine {
|
|
|
3673
4087
|
);
|
|
3674
4088
|
if (!row.longPressActionKey || !rowElement) return;
|
|
3675
4089
|
markActionAnchorSource(rowElement, 'row');
|
|
4090
|
+
const bindingEpoch = rowElement.dataset.nativeListBindingEpoch;
|
|
3676
4091
|
const timer = this.document.defaultView?.setTimeout(() => {
|
|
3677
4092
|
const current = this.marketPointer;
|
|
3678
4093
|
if (!current || current.pointerId !== event.pointerId) return;
|
|
4094
|
+
const currentRow = this.rowAtElement(rowElement);
|
|
3679
4095
|
this.marketPointer = undefined;
|
|
4096
|
+
if (
|
|
4097
|
+
!rowElement.isConnected ||
|
|
4098
|
+
rowElement.dataset.nativeListBindingEpoch !== bindingEpoch ||
|
|
4099
|
+
currentRow?.key !== row.key ||
|
|
4100
|
+
currentRow.type !== 'market' ||
|
|
4101
|
+
!isRowPressEnabled(currentRow) ||
|
|
4102
|
+
!currentRow.longPressActionKey
|
|
4103
|
+
)
|
|
4104
|
+
return;
|
|
3680
4105
|
this.marketLongPressFired = true;
|
|
3681
|
-
this.emitRowAction(
|
|
4106
|
+
this.emitRowAction(
|
|
4107
|
+
currentRow,
|
|
4108
|
+
currentRow.longPressActionKey,
|
|
4109
|
+
rowElement,
|
|
4110
|
+
rowElement,
|
|
4111
|
+
{ x: event.clientX, y: event.clientY }
|
|
4112
|
+
);
|
|
3682
4113
|
}, MARKET_LONG_PRESS_MS);
|
|
3683
4114
|
if (timer === undefined) return;
|
|
3684
4115
|
this.marketPointer = {
|
|
3685
4116
|
pointerId: event.pointerId,
|
|
4117
|
+
pointerType: event.pointerType,
|
|
4118
|
+
compact: !row.webTable,
|
|
3686
4119
|
rowKey: row.key,
|
|
3687
4120
|
startX: event.clientX,
|
|
3688
4121
|
startY: event.clientY,
|
|
@@ -3693,9 +4126,41 @@ export class NativeListWebEngine {
|
|
|
3693
4126
|
private handleMarketPointerMove = (event: PointerEvent) => {
|
|
3694
4127
|
const state = this.marketPointer;
|
|
3695
4128
|
if (!state || state.pointerId !== event.pointerId) return;
|
|
4129
|
+
if (state.compact && state.pointerType === 'touch') return;
|
|
4130
|
+
const row = this.rows.find((item) => item.key === state.rowKey);
|
|
4131
|
+
const threshold =
|
|
4132
|
+
row?.type === 'market' && !row.webTable ? 3 : MARKET_MOVE_CANCEL_PX;
|
|
4133
|
+
if (
|
|
4134
|
+
Math.abs(event.clientX - state.startX) > threshold ||
|
|
4135
|
+
Math.abs(event.clientY - state.startY) > threshold
|
|
4136
|
+
)
|
|
4137
|
+
this.cancelMarketPointer();
|
|
4138
|
+
};
|
|
4139
|
+
|
|
4140
|
+
private handleMarketTouchMove = (event: TouchEvent) => {
|
|
4141
|
+
const state = this.marketPointer;
|
|
4142
|
+
if (
|
|
4143
|
+
!state?.compact ||
|
|
4144
|
+
state.pointerType !== 'touch' ||
|
|
4145
|
+
!(event.target instanceof Element) ||
|
|
4146
|
+
event.target.closest<HTMLElement>('[data-native-list-row-key]')?.dataset
|
|
4147
|
+
.nativeListRowKey !== state.rowKey
|
|
4148
|
+
)
|
|
4149
|
+
return;
|
|
4150
|
+
if (event.touches.length > 1) {
|
|
4151
|
+
this.cancelMarketPointer();
|
|
4152
|
+
return;
|
|
4153
|
+
}
|
|
4154
|
+
const touch = event.touches[0] ?? event.changedTouches[0];
|
|
4155
|
+
if (
|
|
4156
|
+
!touch ||
|
|
4157
|
+
!Number.isFinite(touch.clientX) ||
|
|
4158
|
+
!Number.isFinite(touch.clientY)
|
|
4159
|
+
)
|
|
4160
|
+
return;
|
|
3696
4161
|
if (
|
|
3697
|
-
Math.abs(
|
|
3698
|
-
Math.abs(
|
|
4162
|
+
Math.abs(touch.clientX - state.startX) > 3 ||
|
|
4163
|
+
Math.abs(touch.clientY - state.startY) > 3
|
|
3699
4164
|
)
|
|
3700
4165
|
this.cancelMarketPointer();
|
|
3701
4166
|
};
|
|
@@ -3706,7 +4171,7 @@ export class NativeListWebEngine {
|
|
|
3706
4171
|
};
|
|
3707
4172
|
|
|
3708
4173
|
// OneKey patch: hover opens the same anchored help action as native taps.
|
|
3709
|
-
private handleTitlePointerOver = (event: PointerEvent) => {
|
|
4174
|
+
private handleTitlePointerOver = (event: PointerEvent | FocusEvent) => {
|
|
3710
4175
|
const target = event.target;
|
|
3711
4176
|
if (!(target instanceof Element)) return;
|
|
3712
4177
|
const action = target.closest<HTMLElement>(
|
|
@@ -3718,6 +4183,11 @@ export class NativeListWebEngine {
|
|
|
3718
4183
|
action.contains(event.relatedTarget))
|
|
3719
4184
|
)
|
|
3720
4185
|
return;
|
|
4186
|
+
if (
|
|
4187
|
+
action.classList.contains('ok-native-list-market-subtitle-prefix') &&
|
|
4188
|
+
action.scrollWidth <= action.clientWidth + 1
|
|
4189
|
+
)
|
|
4190
|
+
return;
|
|
3721
4191
|
const rowElement = action.closest<HTMLElement>(
|
|
3722
4192
|
'[data-native-list-row-key]'
|
|
3723
4193
|
);
|
|
@@ -3741,7 +4211,7 @@ export class NativeListWebEngine {
|
|
|
3741
4211
|
this.emitRowAction(sourceRow, actionKey, action, rowElement ?? undefined);
|
|
3742
4212
|
};
|
|
3743
4213
|
|
|
3744
|
-
private handleTitlePointerOut = (event: PointerEvent) => {
|
|
4214
|
+
private handleTitlePointerOut = (event: PointerEvent | FocusEvent) => {
|
|
3745
4215
|
const target = event.target;
|
|
3746
4216
|
if (!(target instanceof Element)) return;
|
|
3747
4217
|
const action = target.closest<HTMLElement>(
|
|
@@ -3934,7 +4404,20 @@ export class NativeListWebEngine {
|
|
|
3934
4404
|
?.focus({ preventScroll: true });
|
|
3935
4405
|
}
|
|
3936
4406
|
|
|
4407
|
+
private handleExternalScroll = (event: Event) => {
|
|
4408
|
+
const target = event.target;
|
|
4409
|
+
if (
|
|
4410
|
+
target === this.externalScrollHost ||
|
|
4411
|
+
(target instanceof Element &&
|
|
4412
|
+
target !== this.root &&
|
|
4413
|
+
this.externalScrollHost?.contains(target) &&
|
|
4414
|
+
target.contains(this.root))
|
|
4415
|
+
)
|
|
4416
|
+
this.handleScroll();
|
|
4417
|
+
};
|
|
4418
|
+
|
|
3937
4419
|
private handleScroll = () => {
|
|
4420
|
+
this.externalGeometryCache = undefined;
|
|
3938
4421
|
this.cancelMarketPointer();
|
|
3939
4422
|
this.invalidateActionAnchor('scroll');
|
|
3940
4423
|
this.scheduleFrame();
|
|
@@ -3950,6 +4433,9 @@ export class NativeListWebEngine {
|
|
|
3950
4433
|
if (this.frameHandle !== undefined || this.destroyed) return;
|
|
3951
4434
|
this.frameHandle = this.requestFrame(() => {
|
|
3952
4435
|
this.frameHandle = undefined;
|
|
4436
|
+
this.externalGeometryCache = undefined;
|
|
4437
|
+
if (this.externalScrollHost)
|
|
4438
|
+
this.externalOrigin = this.externalGeometry().origin;
|
|
3953
4439
|
if (this.virtualizationEnabled) this.renderWindow();
|
|
3954
4440
|
else {
|
|
3955
4441
|
this.updateAvatarWindow();
|
|
@@ -4050,7 +4536,8 @@ export class NativeListWebEngine {
|
|
|
4050
4536
|
if (
|
|
4051
4537
|
this.pointerReorder?.pointerId === event.pointerId ||
|
|
4052
4538
|
!this.snapshot.capabilities?.pullToRefresh ||
|
|
4053
|
-
this.
|
|
4539
|
+
(!!this.externalScrollHost && !this.ownsRefresh) ||
|
|
4540
|
+
this.pullTarget.scrollTop > 0 ||
|
|
4054
4541
|
(event.pointerType !== 'touch' && event.pointerType !== 'pen')
|
|
4055
4542
|
)
|
|
4056
4543
|
return;
|
|
@@ -4149,6 +4636,7 @@ export class NativeListWebEngine {
|
|
|
4149
4636
|
if (this.pointerReorder !== state) return;
|
|
4150
4637
|
this.clearReorderLongPress(state);
|
|
4151
4638
|
state.active = true;
|
|
4639
|
+
this.cancelMarketPointer();
|
|
4152
4640
|
state.activatedAt = Date.now();
|
|
4153
4641
|
state.viewportRect = this.reorderViewportRect();
|
|
4154
4642
|
this.captureReorderPointer(state);
|
|
@@ -4247,6 +4735,10 @@ export class NativeListWebEngine {
|
|
|
4247
4735
|
};
|
|
4248
4736
|
|
|
4249
4737
|
private setCurrentOffset(offset: number) {
|
|
4738
|
+
if (this.externalScrollHost) {
|
|
4739
|
+
this.scrollToAbsoluteOffset(offset, false);
|
|
4740
|
+
return;
|
|
4741
|
+
}
|
|
4250
4742
|
const maximum = Math.max(0, this.contentLength() - this.viewportLength());
|
|
4251
4743
|
const next = Math.max(0, Math.min(maximum, offset));
|
|
4252
4744
|
if (this.layout.horizontal) this.viewport.scrollLeft = next;
|
|
@@ -4339,12 +4831,13 @@ export class NativeListWebEngine {
|
|
|
4339
4831
|
const insets = this.collapsiblePagerInsets();
|
|
4340
4832
|
const left =
|
|
4341
4833
|
viewportRect.left + destinationLayout.x - this.viewport.scrollLeft;
|
|
4342
|
-
const top =
|
|
4343
|
-
viewportRect.top +
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4834
|
+
const top = this.externalScrollHost
|
|
4835
|
+
? viewportRect.top + destinationLayout.y
|
|
4836
|
+
: viewportRect.top +
|
|
4837
|
+
destinationLayout.y +
|
|
4838
|
+
insets.header +
|
|
4839
|
+
insets.sticky -
|
|
4840
|
+
this.viewport.scrollTop;
|
|
4348
4841
|
this.reorderPreview.getBoundingClientRect();
|
|
4349
4842
|
this.reorderPreview.style.transition =
|
|
4350
4843
|
'transform ' +
|
|
@@ -4416,6 +4909,18 @@ export class NativeListWebEngine {
|
|
|
4416
4909
|
}
|
|
4417
4910
|
|
|
4418
4911
|
private reorderViewportRect() {
|
|
4912
|
+
if (this.externalScrollHost) {
|
|
4913
|
+
const geometry = this.externalGeometry();
|
|
4914
|
+
const body = this.viewport.getBoundingClientRect();
|
|
4915
|
+
return {
|
|
4916
|
+
left: body.left,
|
|
4917
|
+
right: body.right,
|
|
4918
|
+
width: body.width,
|
|
4919
|
+
top: geometry.top,
|
|
4920
|
+
bottom: geometry.bottom,
|
|
4921
|
+
height: geometry.viewportLength,
|
|
4922
|
+
};
|
|
4923
|
+
}
|
|
4419
4924
|
const { left, top, right, bottom, width, height } =
|
|
4420
4925
|
this.viewport.getBoundingClientRect();
|
|
4421
4926
|
return { left, top, right, bottom, width, height };
|