@onekeyfe/react-native-native-list 6.7.0-2 → 6.7.0-4
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 +371 -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 +356 -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 +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/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 +603 -95
- package/src/web/templates/ActivityRowRenderer.ts +656 -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,
|
|
@@ -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,25 @@ 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
|
+
let nextUri: string | undefined;
|
|
991
|
+
while (!nextUri && fallbackIndex < orderedFallbacks.length) {
|
|
992
|
+
nextUri = safeImageUri(orderedFallbacks[fallbackIndex++]);
|
|
993
|
+
}
|
|
994
|
+
if (!nextUri) return;
|
|
995
|
+
event.stopImmediatePropagation();
|
|
996
|
+
retryCount = 0;
|
|
997
|
+
currentUri = nextUri;
|
|
998
|
+
image.src = currentUri;
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
if (
|
|
1002
|
+
orderedFallbacks === undefined &&
|
|
1003
|
+
fallbackUri &&
|
|
1004
|
+
!usedFallback &&
|
|
1005
|
+
fallbackUri !== currentUri
|
|
1006
|
+
) {
|
|
976
1007
|
event.stopImmediatePropagation();
|
|
977
1008
|
usedFallback = true;
|
|
978
1009
|
currentUri = fallbackUri;
|
|
@@ -1012,6 +1043,12 @@ function configureWebAvatar(
|
|
|
1012
1043
|
image.src = resolvedUri;
|
|
1013
1044
|
},
|
|
1014
1045
|
() => {
|
|
1046
|
+
if (source.fallbackUris !== undefined) {
|
|
1047
|
+
configureWebImageRetry(image, source, uri);
|
|
1048
|
+
const ImageEvent = image.ownerDocument.defaultView?.Event;
|
|
1049
|
+
if (ImageEvent) image.dispatchEvent(new ImageEvent('error'));
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1015
1052
|
const fallbackUri = source.fallbackUri
|
|
1016
1053
|
? safeImageUri(source.fallbackUri)
|
|
1017
1054
|
: undefined;
|
|
@@ -1144,6 +1181,23 @@ const selectorIcons: Readonly<
|
|
|
1144
1181
|
}>
|
|
1145
1182
|
>
|
|
1146
1183
|
> = {
|
|
1184
|
+
CryptoCoinOutline: {
|
|
1185
|
+
viewBox: '0 0 24 24',
|
|
1186
|
+
paths: [
|
|
1187
|
+
{
|
|
1188
|
+
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',
|
|
1189
|
+
fill: 'currentColor',
|
|
1190
|
+
fillRule: 'nonzero',
|
|
1191
|
+
opacity: 1,
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
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',
|
|
1195
|
+
fill: 'currentColor',
|
|
1196
|
+
fillRule: 'evenodd',
|
|
1197
|
+
opacity: 1,
|
|
1198
|
+
},
|
|
1199
|
+
],
|
|
1200
|
+
},
|
|
1147
1201
|
GlobusOutline: {
|
|
1148
1202
|
viewBox: '0 0 24 24',
|
|
1149
1203
|
paths: [
|
|
@@ -1577,6 +1631,8 @@ function createVisual(
|
|
|
1577
1631
|
if (fallbackIcon.tintColor)
|
|
1578
1632
|
fallback.style.color = fallbackIcon.tintColor;
|
|
1579
1633
|
}
|
|
1634
|
+
fallback.style.backgroundColor =
|
|
1635
|
+
'var(--nl-image-fallback-background, transparent)';
|
|
1580
1636
|
frame.prepend(fallback);
|
|
1581
1637
|
};
|
|
1582
1638
|
if (image) image.addEventListener('error', showFallback, { once: true });
|
|
@@ -1929,7 +1985,23 @@ export function createRowBody(
|
|
|
1929
1985
|
return rowRenderer(row).create(context.document, rendererPrimitives(context));
|
|
1930
1986
|
}
|
|
1931
1987
|
|
|
1988
|
+
export type NativeListWebScrollOptions = Readonly<{
|
|
1989
|
+
scrollHost?: HTMLElement;
|
|
1990
|
+
contentBounds?: HTMLElement;
|
|
1991
|
+
stickyInset?: number;
|
|
1992
|
+
ownsRefresh?: boolean;
|
|
1993
|
+
}>;
|
|
1994
|
+
|
|
1932
1995
|
export class NativeListWebEngine {
|
|
1996
|
+
private readonly externalScrollHost: HTMLElement | undefined;
|
|
1997
|
+
private readonly ownsRefresh: boolean;
|
|
1998
|
+
private readonly pullTarget: HTMLElement;
|
|
1999
|
+
private readonly contentBounds: HTMLElement | undefined;
|
|
2000
|
+
private externalStickyInset: number;
|
|
2001
|
+
private externalOrigin: number | undefined;
|
|
2002
|
+
private externalGeometryCache:
|
|
2003
|
+
| ReturnType<NativeListWebEngine['readExternalGeometry']>
|
|
2004
|
+
| undefined;
|
|
1933
2005
|
private readonly document: Document;
|
|
1934
2006
|
private readonly root: HTMLElement;
|
|
1935
2007
|
private readonly viewportFrame: HTMLElement;
|
|
@@ -1964,6 +2036,7 @@ export class NativeListWebEngine {
|
|
|
1964
2036
|
dataRow: [],
|
|
1965
2037
|
metricCard: [],
|
|
1966
2038
|
market: [],
|
|
2039
|
+
marketTable: [],
|
|
1967
2040
|
identity: [],
|
|
1968
2041
|
sectionHeader: [],
|
|
1969
2042
|
};
|
|
@@ -2009,6 +2082,8 @@ export class NativeListWebEngine {
|
|
|
2009
2082
|
private marketPointer:
|
|
2010
2083
|
| Readonly<{
|
|
2011
2084
|
pointerId: number;
|
|
2085
|
+
pointerType: string;
|
|
2086
|
+
compact: boolean;
|
|
2012
2087
|
rowKey: string;
|
|
2013
2088
|
startX: number;
|
|
2014
2089
|
startY: number;
|
|
@@ -2028,21 +2103,29 @@ export class NativeListWebEngine {
|
|
|
2028
2103
|
|
|
2029
2104
|
private notifyScrollCommandAccepted() {
|
|
2030
2105
|
if (this.destroyed) return;
|
|
2031
|
-
const
|
|
2106
|
+
const owner = this.externalScrollHost ?? this.viewport;
|
|
2107
|
+
const EventConstructor = owner.ownerDocument.defaultView?.Event;
|
|
2032
2108
|
if (EventConstructor)
|
|
2033
|
-
|
|
2109
|
+
owner.dispatchEvent(
|
|
2034
2110
|
new EventConstructor('ok-native-list-scroll-command-accepted')
|
|
2035
2111
|
);
|
|
2036
2112
|
}
|
|
2037
2113
|
|
|
2038
2114
|
private readonly handlePagerScrollCommandCancel = (event: Event) => {
|
|
2039
|
-
|
|
2115
|
+
const owner = this.externalScrollHost ?? this.viewport;
|
|
2116
|
+
if (this.destroyed || event.target !== owner) return;
|
|
2040
2117
|
this.pendingScroll = undefined;
|
|
2041
|
-
|
|
2042
|
-
left:
|
|
2043
|
-
top:
|
|
2118
|
+
const options: ScrollToOptions = {
|
|
2119
|
+
left: owner.scrollLeft,
|
|
2120
|
+
top: owner.scrollTop,
|
|
2044
2121
|
behavior: 'instant',
|
|
2045
|
-
}
|
|
2122
|
+
};
|
|
2123
|
+
if (this.externalScrollHost) {
|
|
2124
|
+
const scrollTo: (options: ScrollToOptions) => void =
|
|
2125
|
+
owner.ownerDocument.defaultView?.Element.prototype.scrollTo ??
|
|
2126
|
+
owner.scrollTo;
|
|
2127
|
+
scrollTo.call(owner, options);
|
|
2128
|
+
} else this.viewport.scrollTo(options);
|
|
2046
2129
|
};
|
|
2047
2130
|
|
|
2048
2131
|
constructor(
|
|
@@ -2051,8 +2134,31 @@ export class NativeListWebEngine {
|
|
|
2051
2134
|
callbacks: NativeListWebCallbacks,
|
|
2052
2135
|
virtualizationEnabled = true,
|
|
2053
2136
|
sectionIndexContainer?: HTMLElement | null,
|
|
2054
|
-
fontFamiliesJson = '{}'
|
|
2137
|
+
fontFamiliesJson = '{}',
|
|
2138
|
+
scrollOptions: NativeListWebScrollOptions = {}
|
|
2055
2139
|
) {
|
|
2140
|
+
if (
|
|
2141
|
+
scrollOptions.scrollHost &&
|
|
2142
|
+
(!(
|
|
2143
|
+
scrollOptions.scrollHost instanceof
|
|
2144
|
+
host.ownerDocument.defaultView!.HTMLElement
|
|
2145
|
+
) ||
|
|
2146
|
+
!scrollOptions.scrollHost.contains(host))
|
|
2147
|
+
)
|
|
2148
|
+
throw new Error(
|
|
2149
|
+
'webScrollHost must be an ancestor HTMLElement in the same document'
|
|
2150
|
+
);
|
|
2151
|
+
this.ownsRefresh = scrollOptions.ownsRefresh === true;
|
|
2152
|
+
if (
|
|
2153
|
+
scrollOptions.scrollHost &&
|
|
2154
|
+
snapshot.layout.orientation === 'horizontal'
|
|
2155
|
+
)
|
|
2156
|
+
throw new Error('External scrolling supports vertical lists only');
|
|
2157
|
+
this.externalScrollHost = scrollOptions.scrollHost;
|
|
2158
|
+
this.contentBounds = scrollOptions.contentBounds;
|
|
2159
|
+
this.externalStickyInset = this.validateStickyInset(
|
|
2160
|
+
scrollOptions.stickyInset
|
|
2161
|
+
);
|
|
2056
2162
|
this.document = host.ownerDocument;
|
|
2057
2163
|
this.snapshot = validateSnapshot(snapshot);
|
|
2058
2164
|
this.callbacks = callbacks;
|
|
@@ -2062,6 +2168,7 @@ export class NativeListWebEngine {
|
|
|
2062
2168
|
if (!host.style.position) host.style.position = 'relative';
|
|
2063
2169
|
|
|
2064
2170
|
this.root = createElement(this.document, 'div', 'ok-native-list-root');
|
|
2171
|
+
setData(this.root, 'nativeListParentScroll', !!this.externalScrollHost);
|
|
2065
2172
|
const style = this.document.createElement('style');
|
|
2066
2173
|
style.textContent = WEB_LIST_CSS;
|
|
2067
2174
|
this.viewportFrame = createElement(
|
|
@@ -2074,6 +2181,10 @@ export class NativeListWebEngine {
|
|
|
2074
2181
|
'div',
|
|
2075
2182
|
'ok-native-list-viewport'
|
|
2076
2183
|
);
|
|
2184
|
+
this.pullTarget =
|
|
2185
|
+
this.externalScrollHost && this.ownsRefresh
|
|
2186
|
+
? this.externalScrollHost
|
|
2187
|
+
: this.viewport;
|
|
2077
2188
|
this.viewport.setAttribute('role', 'list');
|
|
2078
2189
|
this.content = createElement(
|
|
2079
2190
|
this.document,
|
|
@@ -2120,25 +2231,58 @@ export class NativeListWebEngine {
|
|
|
2120
2231
|
);
|
|
2121
2232
|
this.root.append(style, this.viewportFrame, this.footer);
|
|
2122
2233
|
host.appendChild(this.root);
|
|
2234
|
+
if (this.externalScrollHost) {
|
|
2235
|
+
Object.assign(this.root.style, {
|
|
2236
|
+
position: 'relative',
|
|
2237
|
+
inset: 'auto',
|
|
2238
|
+
overflow: 'visible',
|
|
2239
|
+
flex: 'none',
|
|
2240
|
+
});
|
|
2241
|
+
Object.assign(this.viewportFrame.style, {
|
|
2242
|
+
overflow: 'visible',
|
|
2243
|
+
flex: 'none',
|
|
2244
|
+
});
|
|
2245
|
+
Object.assign(this.viewport.style, {
|
|
2246
|
+
position: 'relative',
|
|
2247
|
+
inset: 'auto',
|
|
2248
|
+
overflow: 'visible',
|
|
2249
|
+
scrollbarGutter: 'auto',
|
|
2250
|
+
});
|
|
2251
|
+
this.content.style.minHeight = '0';
|
|
2252
|
+
this.externalScrollHost.addEventListener(
|
|
2253
|
+
'scroll',
|
|
2254
|
+
this.handleExternalScroll,
|
|
2255
|
+
{
|
|
2256
|
+
passive: true,
|
|
2257
|
+
capture: true,
|
|
2258
|
+
}
|
|
2259
|
+
);
|
|
2260
|
+
}
|
|
2123
2261
|
|
|
2124
|
-
this.viewport.addEventListener(
|
|
2262
|
+
(this.externalScrollHost ?? this.viewport).addEventListener(
|
|
2125
2263
|
'ok-collapsible-pager-cancel-scroll-command',
|
|
2126
2264
|
this.handlePagerScrollCommandCancel
|
|
2127
2265
|
);
|
|
2128
2266
|
this.viewport.addEventListener('scroll', this.handleScroll, {
|
|
2129
2267
|
passive: true,
|
|
2130
2268
|
});
|
|
2131
|
-
this.viewport.addEventListener(
|
|
2269
|
+
(this.externalScrollHost ?? this.viewport).addEventListener(
|
|
2132
2270
|
'ok-collapsible-pager-insets-changed',
|
|
2133
2271
|
this.handleCollapsiblePagerInsetsChanged
|
|
2134
2272
|
);
|
|
2135
2273
|
this.root.addEventListener('click', this.handleClick);
|
|
2274
|
+
this.root.addEventListener('contextmenu', this.handleMarketContextMenu);
|
|
2136
2275
|
this.root.addEventListener('pointerdown', this.handleMarketPointerDown);
|
|
2137
2276
|
this.root.addEventListener('pointermove', this.handleMarketPointerMove);
|
|
2277
|
+
this.root.addEventListener('touchmove', this.handleMarketTouchMove, {
|
|
2278
|
+
passive: true,
|
|
2279
|
+
});
|
|
2138
2280
|
this.root.addEventListener('pointerup', this.handleMarketPointerEnd);
|
|
2139
2281
|
this.root.addEventListener('pointercancel', this.handleMarketPointerEnd);
|
|
2140
2282
|
// OneKey patch: preserve web tooltip hover for section titles.
|
|
2141
2283
|
this.root.addEventListener('pointerover', this.handleTitlePointerOver);
|
|
2284
|
+
this.root.addEventListener('focusin', this.handleTitlePointerOver);
|
|
2285
|
+
this.root.addEventListener('focusout', this.handleTitlePointerOut);
|
|
2142
2286
|
this.root.addEventListener('pointerout', this.handleTitlePointerOut);
|
|
2143
2287
|
this.root.addEventListener('keydown', this.handleKeyDown);
|
|
2144
2288
|
this.viewport.addEventListener(
|
|
@@ -2174,14 +2318,14 @@ export class NativeListWebEngine {
|
|
|
2174
2318
|
this.handleIndexPointerEnd
|
|
2175
2319
|
);
|
|
2176
2320
|
this.indexRail.addEventListener('click', this.handleIndexClick);
|
|
2177
|
-
this.
|
|
2321
|
+
this.pullTarget.addEventListener('pointerdown', this.handlePullStart, {
|
|
2178
2322
|
passive: true,
|
|
2179
2323
|
});
|
|
2180
|
-
this.
|
|
2324
|
+
this.pullTarget.addEventListener('pointermove', this.handlePullMove, {
|
|
2181
2325
|
passive: false,
|
|
2182
2326
|
});
|
|
2183
|
-
this.
|
|
2184
|
-
this.
|
|
2327
|
+
this.pullTarget.addEventListener('pointerup', this.handlePullEnd);
|
|
2328
|
+
this.pullTarget.addEventListener('pointercancel', this.handlePullEnd);
|
|
2185
2329
|
|
|
2186
2330
|
const ResizeObserverConstructor = this.document.defaultView?.ResizeObserver;
|
|
2187
2331
|
if (ResizeObserverConstructor) {
|
|
@@ -2189,17 +2333,78 @@ export class NativeListWebEngine {
|
|
|
2189
2333
|
this.recomputeLayout()
|
|
2190
2334
|
);
|
|
2191
2335
|
this.resizeObserver.observe(this.viewport);
|
|
2336
|
+
if (this.externalScrollHost) {
|
|
2337
|
+
this.resizeObserver.observe(this.externalScrollHost);
|
|
2338
|
+
let ancestor: HTMLElement | null = host;
|
|
2339
|
+
while (ancestor && ancestor !== this.externalScrollHost) {
|
|
2340
|
+
this.resizeObserver.observe(ancestor);
|
|
2341
|
+
for (const sibling of ancestor.parentElement?.children ?? []) {
|
|
2342
|
+
if (sibling instanceof this.document.defaultView!.HTMLElement)
|
|
2343
|
+
this.resizeObserver.observe(sibling);
|
|
2344
|
+
}
|
|
2345
|
+
ancestor = ancestor.parentElement;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2192
2348
|
} else {
|
|
2193
2349
|
this.document.defaultView?.addEventListener(
|
|
2194
2350
|
'resize',
|
|
2195
2351
|
this.handleWindowResize
|
|
2196
2352
|
);
|
|
2197
2353
|
}
|
|
2354
|
+
this.document.fonts?.addEventListener(
|
|
2355
|
+
'loadingdone',
|
|
2356
|
+
this.handleWindowResize
|
|
2357
|
+
);
|
|
2198
2358
|
this.observeSectionIndexTransforms();
|
|
2199
2359
|
this.applyFontFamilies(fontFamiliesJson);
|
|
2200
2360
|
this.applySnapshot(this.snapshot);
|
|
2201
2361
|
}
|
|
2202
2362
|
|
|
2363
|
+
private validateStickyInset(value = 0): number {
|
|
2364
|
+
if (!Number.isFinite(value) || value < 0)
|
|
2365
|
+
throw new Error('webStickyInset must be finite and non-negative');
|
|
2366
|
+
return value;
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
setStickyInset(value = 0) {
|
|
2370
|
+
const next = this.validateStickyInset(value);
|
|
2371
|
+
if (next === this.externalStickyInset) return;
|
|
2372
|
+
this.externalStickyInset = next;
|
|
2373
|
+
this.recomputeLayout();
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
private externalGeometry() {
|
|
2377
|
+
return (this.externalGeometryCache ??= this.readExternalGeometry());
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
private readExternalGeometry() {
|
|
2381
|
+
const host = this.externalScrollHost!;
|
|
2382
|
+
const hostRect = host.getBoundingClientRect();
|
|
2383
|
+
const bodyRect = this.viewport.getBoundingClientRect();
|
|
2384
|
+
const boundsRect = (
|
|
2385
|
+
this.contentBounds ?? this.root
|
|
2386
|
+
).getBoundingClientRect();
|
|
2387
|
+
const top = hostRect.top + host.clientTop + this.externalStickyInset;
|
|
2388
|
+
const bottom = hostRect.top + host.clientTop + host.clientHeight;
|
|
2389
|
+
return {
|
|
2390
|
+
origin: bodyRect.top - hostRect.top - host.clientTop + host.scrollTop,
|
|
2391
|
+
containerOrigin:
|
|
2392
|
+
boundsRect.top - hostRect.top - host.clientTop + host.scrollTop,
|
|
2393
|
+
end: boundsRect.bottom - hostRect.top - host.clientTop + host.scrollTop,
|
|
2394
|
+
top,
|
|
2395
|
+
bottom,
|
|
2396
|
+
offset: top - bodyRect.top,
|
|
2397
|
+
viewportLength: Math.max(0, bottom - top),
|
|
2398
|
+
visible:
|
|
2399
|
+
bodyRect.width > 0 &&
|
|
2400
|
+
bodyRect.right > hostRect.left &&
|
|
2401
|
+
bodyRect.left < hostRect.right &&
|
|
2402
|
+
host.clientHeight > 0 &&
|
|
2403
|
+
boundsRect.bottom > top &&
|
|
2404
|
+
boundsRect.top < bottom,
|
|
2405
|
+
};
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2203
2408
|
private fontFamiliesJson = '{}';
|
|
2204
2409
|
|
|
2205
2410
|
private applyFontFamilies(json: string) {
|
|
@@ -2238,10 +2443,23 @@ export class NativeListWebEngine {
|
|
|
2238
2443
|
|
|
2239
2444
|
applySnapshot(snapshot: NativeListSnapshot) {
|
|
2240
2445
|
const validated = validateSnapshot(snapshot);
|
|
2446
|
+
if (
|
|
2447
|
+
this.externalScrollHost &&
|
|
2448
|
+
validated.layout.orientation === 'horizontal'
|
|
2449
|
+
)
|
|
2450
|
+
throw new Error('External scrolling supports vertical lists only');
|
|
2241
2451
|
this.invalidateActionAnchor('snapshot');
|
|
2242
2452
|
this.setSnapshot(validated);
|
|
2243
2453
|
}
|
|
2244
2454
|
|
|
2455
|
+
currentContentHeight(): number {
|
|
2456
|
+
return this.layout.contentHeight;
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2459
|
+
currentSnapshot(): NativeListSnapshot {
|
|
2460
|
+
return this.snapshot;
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2245
2463
|
applyPatches(patches: readonly RowPatch[]) {
|
|
2246
2464
|
if (patches.length === 0) return;
|
|
2247
2465
|
const next = applyRowPatches(this.snapshot, patches);
|
|
@@ -2252,7 +2470,21 @@ export class NativeListWebEngine {
|
|
|
2252
2470
|
if (selected === true) selection.add(patch.key);
|
|
2253
2471
|
else if (selected === false) selection.delete(patch.key);
|
|
2254
2472
|
});
|
|
2255
|
-
|
|
2473
|
+
const tableValuesOnly = patches.every((patch) => {
|
|
2474
|
+
const index = this.rows.findIndex((row) => row.key === patch.key);
|
|
2475
|
+
const before = this.rows[index],
|
|
2476
|
+
after = next.rows[index];
|
|
2477
|
+
return (
|
|
2478
|
+
patch.type === 'market' &&
|
|
2479
|
+
before?.type === 'market' &&
|
|
2480
|
+
after?.type === 'market' &&
|
|
2481
|
+
Object.keys(patch.changes).every(
|
|
2482
|
+
(key) => MARKET_QUOTE_PATCH_FIELDS.has(key) || key === 'webTable'
|
|
2483
|
+
) &&
|
|
2484
|
+
canPatchMarketTableValues(before, after)
|
|
2485
|
+
);
|
|
2486
|
+
});
|
|
2487
|
+
if (webMarketImageBindDeltaForPatches(patches) === 0 || tableValuesOnly) {
|
|
2256
2488
|
this.snapshot = next;
|
|
2257
2489
|
this.rows = effectiveRows(next);
|
|
2258
2490
|
this.selectedKeys = selection;
|
|
@@ -2261,14 +2493,16 @@ export class NativeListWebEngine {
|
|
|
2261
2493
|
const row = this.rows[index];
|
|
2262
2494
|
const element = this.mounted.get(index);
|
|
2263
2495
|
if (row?.type === 'market' && element) {
|
|
2264
|
-
|
|
2496
|
+
if (row.webTable) updateMarketTableValues(element, row);
|
|
2497
|
+
else setMarketQuoteContent(element, row);
|
|
2265
2498
|
element.dataset.renderSignature = webRowRenderSignature(row);
|
|
2266
2499
|
}
|
|
2267
2500
|
if (
|
|
2268
2501
|
row?.type === 'market' &&
|
|
2269
2502
|
this.sticky.dataset.nativeListRowKey === row.key
|
|
2270
2503
|
) {
|
|
2271
|
-
|
|
2504
|
+
if (row.webTable) updateMarketTableValues(this.sticky, row);
|
|
2505
|
+
else setMarketQuoteContent(this.sticky, row);
|
|
2272
2506
|
this.sticky.dataset.renderSignature = webRowRenderSignature(row);
|
|
2273
2507
|
}
|
|
2274
2508
|
});
|
|
@@ -2332,7 +2566,10 @@ export class NativeListWebEngine {
|
|
|
2332
2566
|
this.pendingScroll = { kind: 'offset', offset, animated };
|
|
2333
2567
|
return;
|
|
2334
2568
|
}
|
|
2335
|
-
this.
|
|
2569
|
+
if (this.externalScrollHost) {
|
|
2570
|
+
const geometry = this.externalGeometry();
|
|
2571
|
+
this.writeExternalOffset(geometry.containerOrigin + offset, animated);
|
|
2572
|
+
} else this.scrollToAbsoluteOffset(offset, animated);
|
|
2336
2573
|
}
|
|
2337
2574
|
|
|
2338
2575
|
scrollToEnd(animated: boolean) {
|
|
@@ -2341,10 +2578,17 @@ export class NativeListWebEngine {
|
|
|
2341
2578
|
this.pendingScroll = { kind: 'end', animated };
|
|
2342
2579
|
return;
|
|
2343
2580
|
}
|
|
2344
|
-
this.
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2581
|
+
if (this.externalScrollHost) {
|
|
2582
|
+
const geometry = this.externalGeometry();
|
|
2583
|
+
this.writeExternalOffset(
|
|
2584
|
+
geometry.end - this.externalScrollHost.clientHeight,
|
|
2585
|
+
animated
|
|
2586
|
+
);
|
|
2587
|
+
} else
|
|
2588
|
+
this.scrollToAbsoluteOffset(
|
|
2589
|
+
Math.max(0, this.contentLength() - this.viewportLength()),
|
|
2590
|
+
animated
|
|
2591
|
+
);
|
|
2348
2592
|
}
|
|
2349
2593
|
|
|
2350
2594
|
scrollToLocation(
|
|
@@ -2410,28 +2654,41 @@ export class NativeListWebEngine {
|
|
|
2410
2654
|
if (this.reorderMovementTimer !== undefined)
|
|
2411
2655
|
this.document.defaultView?.clearTimeout(this.reorderMovementTimer);
|
|
2412
2656
|
this.resizeObserver?.disconnect();
|
|
2657
|
+
this.externalScrollHost?.removeEventListener(
|
|
2658
|
+
'scroll',
|
|
2659
|
+
this.handleExternalScroll,
|
|
2660
|
+
true
|
|
2661
|
+
);
|
|
2662
|
+
this.document.fonts?.removeEventListener(
|
|
2663
|
+
'loadingdone',
|
|
2664
|
+
this.handleWindowResize
|
|
2665
|
+
);
|
|
2413
2666
|
this.sectionIndexTransformObserver?.disconnect();
|
|
2414
2667
|
this.document.defaultView?.removeEventListener(
|
|
2415
2668
|
'resize',
|
|
2416
2669
|
this.handleWindowResize
|
|
2417
2670
|
);
|
|
2418
2671
|
this.pendingScroll = undefined;
|
|
2419
|
-
this.viewport.removeEventListener(
|
|
2672
|
+
(this.externalScrollHost ?? this.viewport).removeEventListener(
|
|
2420
2673
|
'ok-collapsible-pager-cancel-scroll-command',
|
|
2421
2674
|
this.handlePagerScrollCommandCancel
|
|
2422
2675
|
);
|
|
2423
2676
|
this.viewport.removeEventListener('scroll', this.handleScroll);
|
|
2424
|
-
this.viewport.removeEventListener(
|
|
2677
|
+
(this.externalScrollHost ?? this.viewport).removeEventListener(
|
|
2425
2678
|
'ok-collapsible-pager-insets-changed',
|
|
2426
2679
|
this.handleCollapsiblePagerInsetsChanged
|
|
2427
2680
|
);
|
|
2428
2681
|
this.root.removeEventListener('click', this.handleClick);
|
|
2682
|
+
this.root.removeEventListener('contextmenu', this.handleMarketContextMenu);
|
|
2429
2683
|
this.cancelMarketPointer();
|
|
2430
2684
|
this.root.removeEventListener('pointerdown', this.handleMarketPointerDown);
|
|
2431
2685
|
this.root.removeEventListener('pointermove', this.handleMarketPointerMove);
|
|
2686
|
+
this.root.removeEventListener('touchmove', this.handleMarketTouchMove);
|
|
2432
2687
|
this.root.removeEventListener('pointerup', this.handleMarketPointerEnd);
|
|
2433
2688
|
this.root.removeEventListener('pointercancel', this.handleMarketPointerEnd);
|
|
2434
2689
|
this.root.removeEventListener('pointerover', this.handleTitlePointerOver);
|
|
2690
|
+
this.root.removeEventListener('focusin', this.handleTitlePointerOver);
|
|
2691
|
+
this.root.removeEventListener('focusout', this.handleTitlePointerOut);
|
|
2435
2692
|
this.root.removeEventListener('pointerout', this.handleTitlePointerOut);
|
|
2436
2693
|
this.root.removeEventListener('keydown', this.handleKeyDown);
|
|
2437
2694
|
this.cancelPointerReorder(true);
|
|
@@ -2465,10 +2722,10 @@ export class NativeListWebEngine {
|
|
|
2465
2722
|
this.handleIndexPointerEnd
|
|
2466
2723
|
);
|
|
2467
2724
|
this.indexRail.removeEventListener('click', this.handleIndexClick);
|
|
2468
|
-
this.
|
|
2469
|
-
this.
|
|
2470
|
-
this.
|
|
2471
|
-
this.
|
|
2725
|
+
this.pullTarget.removeEventListener('pointerdown', this.handlePullStart);
|
|
2726
|
+
this.pullTarget.removeEventListener('pointermove', this.handlePullMove);
|
|
2727
|
+
this.pullTarget.removeEventListener('pointerup', this.handlePullEnd);
|
|
2728
|
+
this.pullTarget.removeEventListener('pointercancel', this.handlePullEnd);
|
|
2472
2729
|
const host = this.root.parentElement;
|
|
2473
2730
|
disposeWebImageRetries(this.root);
|
|
2474
2731
|
Object.values(this.pool).forEach((elements) =>
|
|
@@ -2514,6 +2771,8 @@ export class NativeListWebEngine {
|
|
|
2514
2771
|
'--nl-pressed': theme.rowPressedBackground,
|
|
2515
2772
|
'--nl-subdued': theme.subduedBackground,
|
|
2516
2773
|
'--nl-strong': theme.strongBackground,
|
|
2774
|
+
'--nl-image-fallback-background':
|
|
2775
|
+
theme.imageFallbackBackground ?? 'transparent',
|
|
2517
2776
|
'--nl-primary': theme.primaryText,
|
|
2518
2777
|
'--nl-secondary': theme.secondaryText,
|
|
2519
2778
|
'--nl-disabled': theme.disabledText,
|
|
@@ -2566,8 +2825,79 @@ export class NativeListWebEngine {
|
|
|
2566
2825
|
});
|
|
2567
2826
|
}
|
|
2568
2827
|
|
|
2828
|
+
private computeLayout(
|
|
2829
|
+
viewportWidth: number,
|
|
2830
|
+
viewportHeight: number
|
|
2831
|
+
): WebListLayout {
|
|
2832
|
+
const measuredSnapshot: NativeListSnapshot = {
|
|
2833
|
+
...this.snapshot,
|
|
2834
|
+
rows: this.snapshot.rows.map((row) =>
|
|
2835
|
+
row.style?.container?.height === undefined &&
|
|
2836
|
+
row.height === undefined &&
|
|
2837
|
+
this.measuredRendererHeights.get(row.key)?.signature ===
|
|
2838
|
+
webRowRenderSignature(row)
|
|
2839
|
+
? {
|
|
2840
|
+
...row,
|
|
2841
|
+
height: this.measuredRendererHeights.get(row.key)!.height,
|
|
2842
|
+
}
|
|
2843
|
+
: row
|
|
2844
|
+
),
|
|
2845
|
+
};
|
|
2846
|
+
let layout = computeWebListLayout(
|
|
2847
|
+
measuredSnapshot,
|
|
2848
|
+
viewportWidth,
|
|
2849
|
+
viewportHeight,
|
|
2850
|
+
this.reorderCompactKey
|
|
2851
|
+
);
|
|
2852
|
+
if (this.externalScrollHost) {
|
|
2853
|
+
const padding = paddingValues(this.snapshot);
|
|
2854
|
+
layout = {
|
|
2855
|
+
...layout,
|
|
2856
|
+
contentHeight:
|
|
2857
|
+
Math.max(
|
|
2858
|
+
padding.top,
|
|
2859
|
+
...layout.items.map((item) => item.y + item.height)
|
|
2860
|
+
) + padding.bottom,
|
|
2861
|
+
};
|
|
2862
|
+
}
|
|
2863
|
+
return layout;
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
private writeExternalHeight(height: number) {
|
|
2867
|
+
const value = String(height) + 'px';
|
|
2868
|
+
this.content.style.height = value;
|
|
2869
|
+
this.viewport.style.height = value;
|
|
2870
|
+
this.viewportFrame.style.height = value;
|
|
2871
|
+
this.root.style.height = value;
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2569
2874
|
private recomputeLayout = () => {
|
|
2570
2875
|
if (this.destroyed) return;
|
|
2876
|
+
const cachedWidth = this.lastViewportWidth;
|
|
2877
|
+
const cachedHeight = this.lastViewportHeight;
|
|
2878
|
+
const precomputedLayout =
|
|
2879
|
+
this.externalScrollHost && cachedWidth > 0 && cachedHeight > 0
|
|
2880
|
+
? this.computeLayout(cachedWidth, cachedHeight)
|
|
2881
|
+
: undefined;
|
|
2882
|
+
if (precomputedLayout) {
|
|
2883
|
+
// Commit appended row extent before measuring React-owned slot changes.
|
|
2884
|
+
this.writeExternalHeight(
|
|
2885
|
+
Math.max(this.layout.contentHeight, precomputedLayout.contentHeight)
|
|
2886
|
+
);
|
|
2887
|
+
}
|
|
2888
|
+
this.externalGeometryCache = undefined;
|
|
2889
|
+
if (this.externalScrollHost) {
|
|
2890
|
+
const geometry = this.externalGeometry();
|
|
2891
|
+
const previousOrigin = this.externalOrigin;
|
|
2892
|
+
this.externalOrigin = geometry.origin;
|
|
2893
|
+
if (
|
|
2894
|
+
previousOrigin !== undefined &&
|
|
2895
|
+
geometry.origin !== previousOrigin &&
|
|
2896
|
+
this.externalScrollHost.scrollTop > previousOrigin &&
|
|
2897
|
+
geometry.visible
|
|
2898
|
+
)
|
|
2899
|
+
this.externalScrollHost.scrollTop += geometry.origin - previousOrigin;
|
|
2900
|
+
}
|
|
2571
2901
|
const viewportWidth = this.viewport.clientWidth;
|
|
2572
2902
|
const viewportHeight =
|
|
2573
2903
|
this.snapshot.layout.orientation === 'horizontal'
|
|
@@ -2595,28 +2925,18 @@ export class NativeListWebEngine {
|
|
|
2595
2925
|
this.lastViewportWidth = viewportWidth;
|
|
2596
2926
|
this.lastViewportHeight = viewportHeight;
|
|
2597
2927
|
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
|
-
);
|
|
2928
|
+
this.layout =
|
|
2929
|
+
precomputedLayout &&
|
|
2930
|
+
viewportWidth === cachedWidth &&
|
|
2931
|
+
viewportHeight === cachedHeight
|
|
2932
|
+
? precomputedLayout
|
|
2933
|
+
: this.computeLayout(viewportWidth, viewportHeight);
|
|
2618
2934
|
this.content.style.width = String(this.layout.contentWidth) + 'px';
|
|
2619
2935
|
this.content.style.height = String(this.layout.contentHeight) + 'px';
|
|
2936
|
+
if (this.externalScrollHost) {
|
|
2937
|
+
this.writeExternalHeight(this.layout.contentHeight);
|
|
2938
|
+
this.externalGeometryCache = undefined;
|
|
2939
|
+
}
|
|
2620
2940
|
this.renderSectionIndex(
|
|
2621
2941
|
this.viewport.clientHeight <= 0
|
|
2622
2942
|
? DEFAULT_VIEWPORT_HEIGHT
|
|
@@ -2632,6 +2952,11 @@ export class NativeListWebEngine {
|
|
|
2632
2952
|
};
|
|
2633
2953
|
|
|
2634
2954
|
private updateAvatarWindow() {
|
|
2955
|
+
if (this.externalScrollHost && !this.externalGeometry().visible) {
|
|
2956
|
+
this.avatarLeases.forEach((lease) => lease());
|
|
2957
|
+
this.avatarLeases.clear();
|
|
2958
|
+
return;
|
|
2959
|
+
}
|
|
2635
2960
|
const offset = this.currentOffset();
|
|
2636
2961
|
if (offset !== this.avatarOffset)
|
|
2637
2962
|
this.avatarDirection = Math.sign(offset - this.avatarOffset);
|
|
@@ -2688,13 +3013,16 @@ export class NativeListWebEngine {
|
|
|
2688
3013
|
private renderWindow() {
|
|
2689
3014
|
this.updateAvatarWindow();
|
|
2690
3015
|
const viewportLength = this.viewportLength();
|
|
2691
|
-
const visible =
|
|
2692
|
-
this.
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
3016
|
+
const visible =
|
|
3017
|
+
this.externalScrollHost && !this.externalGeometry().visible
|
|
3018
|
+
? []
|
|
3019
|
+
: webLayoutItemsForMount(
|
|
3020
|
+
this.layout,
|
|
3021
|
+
this.currentOffset(),
|
|
3022
|
+
viewportLength,
|
|
3023
|
+
this.virtualizationEnabled,
|
|
3024
|
+
viewportLength * OVERSCAN_VIEWPORTS
|
|
3025
|
+
);
|
|
2698
3026
|
const desired = new Set(visible.map((item) => item.index));
|
|
2699
3027
|
this.mounted.forEach((element, index) => {
|
|
2700
3028
|
const nextRow = this.rows[index];
|
|
@@ -2797,6 +3125,11 @@ export class NativeListWebEngine {
|
|
|
2797
3125
|
? 'ok-native-list-item ok-native-list-sticky'
|
|
2798
3126
|
: 'ok-native-list-item';
|
|
2799
3127
|
setData(element, 'nativeListRowKey', row.key);
|
|
3128
|
+
setData(
|
|
3129
|
+
element,
|
|
3130
|
+
'nativeListMediaGallery',
|
|
3131
|
+
row.type === 'mediaTile' && row.variant === 'gallery' ? 'true' : undefined
|
|
3132
|
+
);
|
|
2800
3133
|
setData(element, 'nativeListBindingEpoch', bindingEpoch);
|
|
2801
3134
|
setData(element, 'nativeListRowIndex', index);
|
|
2802
3135
|
setData(element, 'nativeListDisabled', Boolean(row.disabled));
|
|
@@ -3221,11 +3554,14 @@ export class NativeListWebEngine {
|
|
|
3221
3554
|
}
|
|
3222
3555
|
|
|
3223
3556
|
private updateVisibleState() {
|
|
3224
|
-
const visible =
|
|
3225
|
-
this.
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3557
|
+
const visible =
|
|
3558
|
+
this.externalScrollHost && !this.externalGeometry().visible
|
|
3559
|
+
? []
|
|
3560
|
+
: visibleWebLayoutItems(
|
|
3561
|
+
this.layout,
|
|
3562
|
+
this.currentOffset(),
|
|
3563
|
+
this.viewportLength()
|
|
3564
|
+
);
|
|
3229
3565
|
const first = visible[0];
|
|
3230
3566
|
const last = visible.at(-1);
|
|
3231
3567
|
const signature =
|
|
@@ -3295,6 +3631,8 @@ export class NativeListWebEngine {
|
|
|
3295
3631
|
this.sticky.style.right = 'auto';
|
|
3296
3632
|
this.sticky.style.width = String(item.width) + 'px';
|
|
3297
3633
|
this.sticky.style.height = String(item.height) + 'px';
|
|
3634
|
+
if (this.externalScrollHost)
|
|
3635
|
+
this.sticky.style.top = String(Math.max(0, this.currentOffset())) + 'px';
|
|
3298
3636
|
let nextIndex = -1;
|
|
3299
3637
|
for (let cursor = index + 1; cursor < this.rows.length; cursor += 1) {
|
|
3300
3638
|
const candidate = this.rows[cursor];
|
|
@@ -3333,6 +3671,7 @@ export class NativeListWebEngine {
|
|
|
3333
3671
|
|
|
3334
3672
|
private checkEndReached(lastVisibleIndex: number) {
|
|
3335
3673
|
if (
|
|
3674
|
+
(this.externalScrollHost && !this.externalGeometry().visible) ||
|
|
3336
3675
|
!this.snapshot.capabilities?.loadMore ||
|
|
3337
3676
|
this.reachedGeneration === this.snapshot.generation ||
|
|
3338
3677
|
this.rows.length === 0
|
|
@@ -3371,6 +3710,11 @@ export class NativeListWebEngine {
|
|
|
3371
3710
|
}
|
|
3372
3711
|
|
|
3373
3712
|
private canScroll(): boolean {
|
|
3713
|
+
if (this.externalScrollHost)
|
|
3714
|
+
return (
|
|
3715
|
+
this.viewport.clientWidth > 0 &&
|
|
3716
|
+
this.externalScrollHost.clientHeight > 0
|
|
3717
|
+
);
|
|
3374
3718
|
const viewportLength = this.layout.horizontal
|
|
3375
3719
|
? this.viewport.clientWidth
|
|
3376
3720
|
: this.viewport.clientHeight;
|
|
@@ -3381,11 +3725,19 @@ export class NativeListWebEngine {
|
|
|
3381
3725
|
if (this.layout.horizontal) {
|
|
3382
3726
|
return this.viewport.clientWidth || DEFAULT_VIEWPORT_WIDTH;
|
|
3383
3727
|
}
|
|
3728
|
+
if (this.externalScrollHost) return this.externalGeometry().viewportLength;
|
|
3384
3729
|
if (this.viewport.clientHeight <= 0) return DEFAULT_VIEWPORT_HEIGHT;
|
|
3385
3730
|
return Math.max(1, this.verticalScrollMetrics().viewportLength);
|
|
3386
3731
|
}
|
|
3387
3732
|
|
|
3388
3733
|
private contentLength(): number {
|
|
3734
|
+
if (this.externalScrollHost) {
|
|
3735
|
+
const geometry = this.externalGeometry();
|
|
3736
|
+
return Math.max(
|
|
3737
|
+
this.layout.contentHeight,
|
|
3738
|
+
geometry.end - geometry.origin
|
|
3739
|
+
);
|
|
3740
|
+
}
|
|
3389
3741
|
return this.layout.horizontal
|
|
3390
3742
|
? this.layout.contentWidth
|
|
3391
3743
|
: this.layout.contentHeight;
|
|
@@ -3401,6 +3753,8 @@ export class NativeListWebEngine {
|
|
|
3401
3753
|
header: number;
|
|
3402
3754
|
sticky: number;
|
|
3403
3755
|
}> {
|
|
3756
|
+
if (this.externalScrollHost)
|
|
3757
|
+
return { header: 0, sticky: this.externalStickyInset };
|
|
3404
3758
|
const readInset = (name: string) => {
|
|
3405
3759
|
const parsed = Number.parseFloat(
|
|
3406
3760
|
this.viewport.style.getPropertyValue(name)
|
|
@@ -3414,6 +3768,7 @@ export class NativeListWebEngine {
|
|
|
3414
3768
|
}
|
|
3415
3769
|
|
|
3416
3770
|
private verticalScrollMetrics(): WebCollapsiblePagerScrollMetrics {
|
|
3771
|
+
if (this.externalScrollHost) return this.externalGeometry();
|
|
3417
3772
|
const insets = this.collapsiblePagerInsets();
|
|
3418
3773
|
return resolveWebCollapsiblePagerScrollMetrics(
|
|
3419
3774
|
this.viewport.scrollTop,
|
|
@@ -3427,7 +3782,31 @@ export class NativeListWebEngine {
|
|
|
3427
3782
|
this.recomputeLayout();
|
|
3428
3783
|
};
|
|
3429
3784
|
|
|
3785
|
+
private writeExternalOffset(rawOffset: number, animated: boolean) {
|
|
3786
|
+
this.externalGeometryCache = undefined;
|
|
3787
|
+
const host = this.externalScrollHost!;
|
|
3788
|
+
const scrollTo: (options: ScrollToOptions) => void =
|
|
3789
|
+
host.ownerDocument.defaultView?.Element.prototype.scrollTo ??
|
|
3790
|
+
host.scrollTo;
|
|
3791
|
+
scrollTo.call(host, {
|
|
3792
|
+
top: Math.max(
|
|
3793
|
+
0,
|
|
3794
|
+
Math.min(host.scrollHeight - host.clientHeight, rawOffset)
|
|
3795
|
+
),
|
|
3796
|
+
behavior: animated ? 'smooth' : 'auto',
|
|
3797
|
+
});
|
|
3798
|
+
this.scheduleFrame();
|
|
3799
|
+
}
|
|
3800
|
+
|
|
3430
3801
|
private scrollToAbsoluteOffset(offset: number, animated: boolean) {
|
|
3802
|
+
if (this.externalScrollHost) {
|
|
3803
|
+
const geometry = this.externalGeometry();
|
|
3804
|
+
this.writeExternalOffset(
|
|
3805
|
+
geometry.origin + offset - this.externalStickyInset,
|
|
3806
|
+
animated
|
|
3807
|
+
);
|
|
3808
|
+
return;
|
|
3809
|
+
}
|
|
3431
3810
|
const resolved = Math.min(
|
|
3432
3811
|
Math.max(0, offset),
|
|
3433
3812
|
Math.max(0, this.contentLength() - this.viewportLength())
|
|
@@ -3507,7 +3886,8 @@ export class NativeListWebEngine {
|
|
|
3507
3886
|
row: RowModel,
|
|
3508
3887
|
actionKey: string,
|
|
3509
3888
|
actionElement?: HTMLElement,
|
|
3510
|
-
rowElement?: HTMLElement
|
|
3889
|
+
rowElement?: HTMLElement,
|
|
3890
|
+
windowPoint?: RowActionEvent['windowPoint']
|
|
3511
3891
|
) {
|
|
3512
3892
|
const anchor =
|
|
3513
3893
|
actionElement && rowElement
|
|
@@ -3518,6 +3898,11 @@ export class NativeListWebEngine {
|
|
|
3518
3898
|
actionKey,
|
|
3519
3899
|
sectionKey: row.sectionKey,
|
|
3520
3900
|
anchor,
|
|
3901
|
+
...(windowPoint &&
|
|
3902
|
+
Number.isFinite(windowPoint.x) &&
|
|
3903
|
+
Number.isFinite(windowPoint.y)
|
|
3904
|
+
? { windowPoint }
|
|
3905
|
+
: {}),
|
|
3521
3906
|
});
|
|
3522
3907
|
}
|
|
3523
3908
|
|
|
@@ -3654,6 +4039,38 @@ export class NativeListWebEngine {
|
|
|
3654
4039
|
this.marketPointer = undefined;
|
|
3655
4040
|
}
|
|
3656
4041
|
|
|
4042
|
+
private handleMarketContextMenu = (event: MouseEvent) => {
|
|
4043
|
+
if (
|
|
4044
|
+
!(event.target instanceof Element) ||
|
|
4045
|
+
event.target.closest('[data-native-list-action]')
|
|
4046
|
+
)
|
|
4047
|
+
return;
|
|
4048
|
+
const element = event.target.closest<HTMLElement>(
|
|
4049
|
+
'[data-native-list-row-key]'
|
|
4050
|
+
);
|
|
4051
|
+
const row = this.rowAtElement(element);
|
|
4052
|
+
if (
|
|
4053
|
+
row?.type !== 'market' ||
|
|
4054
|
+
!row.webTable?.contextMenuActionKey ||
|
|
4055
|
+
!element ||
|
|
4056
|
+
!isRowPressEnabled(row)
|
|
4057
|
+
)
|
|
4058
|
+
return;
|
|
4059
|
+
event.preventDefault();
|
|
4060
|
+
this.cancelMarketPointer();
|
|
4061
|
+
markActionAnchorSource(element, 'row');
|
|
4062
|
+
const rect = element.getBoundingClientRect();
|
|
4063
|
+
this.emitRowAction(
|
|
4064
|
+
row,
|
|
4065
|
+
row.webTable.contextMenuActionKey,
|
|
4066
|
+
element,
|
|
4067
|
+
element,
|
|
4068
|
+
event.clientX || event.clientY
|
|
4069
|
+
? { x: event.clientX, y: event.clientY }
|
|
4070
|
+
: { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 }
|
|
4071
|
+
);
|
|
4072
|
+
};
|
|
4073
|
+
|
|
3657
4074
|
private handleMarketPointerDown = (event: PointerEvent) => {
|
|
3658
4075
|
if (event.button !== 0 || !(event.target instanceof Element)) return;
|
|
3659
4076
|
this.marketLongPressFired = false;
|
|
@@ -3673,16 +4090,35 @@ export class NativeListWebEngine {
|
|
|
3673
4090
|
);
|
|
3674
4091
|
if (!row.longPressActionKey || !rowElement) return;
|
|
3675
4092
|
markActionAnchorSource(rowElement, 'row');
|
|
4093
|
+
const bindingEpoch = rowElement.dataset.nativeListBindingEpoch;
|
|
3676
4094
|
const timer = this.document.defaultView?.setTimeout(() => {
|
|
3677
4095
|
const current = this.marketPointer;
|
|
3678
4096
|
if (!current || current.pointerId !== event.pointerId) return;
|
|
4097
|
+
const currentRow = this.rowAtElement(rowElement);
|
|
3679
4098
|
this.marketPointer = undefined;
|
|
4099
|
+
if (
|
|
4100
|
+
!rowElement.isConnected ||
|
|
4101
|
+
rowElement.dataset.nativeListBindingEpoch !== bindingEpoch ||
|
|
4102
|
+
currentRow?.key !== row.key ||
|
|
4103
|
+
currentRow.type !== 'market' ||
|
|
4104
|
+
!isRowPressEnabled(currentRow) ||
|
|
4105
|
+
!currentRow.longPressActionKey
|
|
4106
|
+
)
|
|
4107
|
+
return;
|
|
3680
4108
|
this.marketLongPressFired = true;
|
|
3681
|
-
this.emitRowAction(
|
|
4109
|
+
this.emitRowAction(
|
|
4110
|
+
currentRow,
|
|
4111
|
+
currentRow.longPressActionKey,
|
|
4112
|
+
rowElement,
|
|
4113
|
+
rowElement,
|
|
4114
|
+
{ x: event.clientX, y: event.clientY }
|
|
4115
|
+
);
|
|
3682
4116
|
}, MARKET_LONG_PRESS_MS);
|
|
3683
4117
|
if (timer === undefined) return;
|
|
3684
4118
|
this.marketPointer = {
|
|
3685
4119
|
pointerId: event.pointerId,
|
|
4120
|
+
pointerType: event.pointerType,
|
|
4121
|
+
compact: !row.webTable,
|
|
3686
4122
|
rowKey: row.key,
|
|
3687
4123
|
startX: event.clientX,
|
|
3688
4124
|
startY: event.clientY,
|
|
@@ -3693,9 +4129,41 @@ export class NativeListWebEngine {
|
|
|
3693
4129
|
private handleMarketPointerMove = (event: PointerEvent) => {
|
|
3694
4130
|
const state = this.marketPointer;
|
|
3695
4131
|
if (!state || state.pointerId !== event.pointerId) return;
|
|
4132
|
+
if (state.compact && state.pointerType === 'touch') return;
|
|
4133
|
+
const row = this.rows.find((item) => item.key === state.rowKey);
|
|
4134
|
+
const threshold =
|
|
4135
|
+
row?.type === 'market' && !row.webTable ? 3 : MARKET_MOVE_CANCEL_PX;
|
|
4136
|
+
if (
|
|
4137
|
+
Math.abs(event.clientX - state.startX) > threshold ||
|
|
4138
|
+
Math.abs(event.clientY - state.startY) > threshold
|
|
4139
|
+
)
|
|
4140
|
+
this.cancelMarketPointer();
|
|
4141
|
+
};
|
|
4142
|
+
|
|
4143
|
+
private handleMarketTouchMove = (event: TouchEvent) => {
|
|
4144
|
+
const state = this.marketPointer;
|
|
4145
|
+
if (
|
|
4146
|
+
!state?.compact ||
|
|
4147
|
+
state.pointerType !== 'touch' ||
|
|
4148
|
+
!(event.target instanceof Element) ||
|
|
4149
|
+
event.target.closest<HTMLElement>('[data-native-list-row-key]')?.dataset
|
|
4150
|
+
.nativeListRowKey !== state.rowKey
|
|
4151
|
+
)
|
|
4152
|
+
return;
|
|
4153
|
+
if (event.touches.length > 1) {
|
|
4154
|
+
this.cancelMarketPointer();
|
|
4155
|
+
return;
|
|
4156
|
+
}
|
|
4157
|
+
const touch = event.touches[0] ?? event.changedTouches[0];
|
|
4158
|
+
if (
|
|
4159
|
+
!touch ||
|
|
4160
|
+
!Number.isFinite(touch.clientX) ||
|
|
4161
|
+
!Number.isFinite(touch.clientY)
|
|
4162
|
+
)
|
|
4163
|
+
return;
|
|
3696
4164
|
if (
|
|
3697
|
-
Math.abs(
|
|
3698
|
-
Math.abs(
|
|
4165
|
+
Math.abs(touch.clientX - state.startX) > 3 ||
|
|
4166
|
+
Math.abs(touch.clientY - state.startY) > 3
|
|
3699
4167
|
)
|
|
3700
4168
|
this.cancelMarketPointer();
|
|
3701
4169
|
};
|
|
@@ -3706,7 +4174,7 @@ export class NativeListWebEngine {
|
|
|
3706
4174
|
};
|
|
3707
4175
|
|
|
3708
4176
|
// OneKey patch: hover opens the same anchored help action as native taps.
|
|
3709
|
-
private handleTitlePointerOver = (event: PointerEvent) => {
|
|
4177
|
+
private handleTitlePointerOver = (event: PointerEvent | FocusEvent) => {
|
|
3710
4178
|
const target = event.target;
|
|
3711
4179
|
if (!(target instanceof Element)) return;
|
|
3712
4180
|
const action = target.closest<HTMLElement>(
|
|
@@ -3718,6 +4186,11 @@ export class NativeListWebEngine {
|
|
|
3718
4186
|
action.contains(event.relatedTarget))
|
|
3719
4187
|
)
|
|
3720
4188
|
return;
|
|
4189
|
+
if (
|
|
4190
|
+
action.classList.contains('ok-native-list-market-subtitle-prefix') &&
|
|
4191
|
+
action.scrollWidth <= action.clientWidth + 1
|
|
4192
|
+
)
|
|
4193
|
+
return;
|
|
3721
4194
|
const rowElement = action.closest<HTMLElement>(
|
|
3722
4195
|
'[data-native-list-row-key]'
|
|
3723
4196
|
);
|
|
@@ -3741,7 +4214,7 @@ export class NativeListWebEngine {
|
|
|
3741
4214
|
this.emitRowAction(sourceRow, actionKey, action, rowElement ?? undefined);
|
|
3742
4215
|
};
|
|
3743
4216
|
|
|
3744
|
-
private handleTitlePointerOut = (event: PointerEvent) => {
|
|
4217
|
+
private handleTitlePointerOut = (event: PointerEvent | FocusEvent) => {
|
|
3745
4218
|
const target = event.target;
|
|
3746
4219
|
if (!(target instanceof Element)) return;
|
|
3747
4220
|
const action = target.closest<HTMLElement>(
|
|
@@ -3934,7 +4407,20 @@ export class NativeListWebEngine {
|
|
|
3934
4407
|
?.focus({ preventScroll: true });
|
|
3935
4408
|
}
|
|
3936
4409
|
|
|
4410
|
+
private handleExternalScroll = (event: Event) => {
|
|
4411
|
+
const target = event.target;
|
|
4412
|
+
if (
|
|
4413
|
+
target === this.externalScrollHost ||
|
|
4414
|
+
(target instanceof Element &&
|
|
4415
|
+
target !== this.root &&
|
|
4416
|
+
this.externalScrollHost?.contains(target) &&
|
|
4417
|
+
target.contains(this.root))
|
|
4418
|
+
)
|
|
4419
|
+
this.handleScroll();
|
|
4420
|
+
};
|
|
4421
|
+
|
|
3937
4422
|
private handleScroll = () => {
|
|
4423
|
+
this.externalGeometryCache = undefined;
|
|
3938
4424
|
this.cancelMarketPointer();
|
|
3939
4425
|
this.invalidateActionAnchor('scroll');
|
|
3940
4426
|
this.scheduleFrame();
|
|
@@ -3950,6 +4436,9 @@ export class NativeListWebEngine {
|
|
|
3950
4436
|
if (this.frameHandle !== undefined || this.destroyed) return;
|
|
3951
4437
|
this.frameHandle = this.requestFrame(() => {
|
|
3952
4438
|
this.frameHandle = undefined;
|
|
4439
|
+
this.externalGeometryCache = undefined;
|
|
4440
|
+
if (this.externalScrollHost)
|
|
4441
|
+
this.externalOrigin = this.externalGeometry().origin;
|
|
3953
4442
|
if (this.virtualizationEnabled) this.renderWindow();
|
|
3954
4443
|
else {
|
|
3955
4444
|
this.updateAvatarWindow();
|
|
@@ -4050,7 +4539,8 @@ export class NativeListWebEngine {
|
|
|
4050
4539
|
if (
|
|
4051
4540
|
this.pointerReorder?.pointerId === event.pointerId ||
|
|
4052
4541
|
!this.snapshot.capabilities?.pullToRefresh ||
|
|
4053
|
-
this.
|
|
4542
|
+
(!!this.externalScrollHost && !this.ownsRefresh) ||
|
|
4543
|
+
this.pullTarget.scrollTop > 0 ||
|
|
4054
4544
|
(event.pointerType !== 'touch' && event.pointerType !== 'pen')
|
|
4055
4545
|
)
|
|
4056
4546
|
return;
|
|
@@ -4149,6 +4639,7 @@ export class NativeListWebEngine {
|
|
|
4149
4639
|
if (this.pointerReorder !== state) return;
|
|
4150
4640
|
this.clearReorderLongPress(state);
|
|
4151
4641
|
state.active = true;
|
|
4642
|
+
this.cancelMarketPointer();
|
|
4152
4643
|
state.activatedAt = Date.now();
|
|
4153
4644
|
state.viewportRect = this.reorderViewportRect();
|
|
4154
4645
|
this.captureReorderPointer(state);
|
|
@@ -4247,6 +4738,10 @@ export class NativeListWebEngine {
|
|
|
4247
4738
|
};
|
|
4248
4739
|
|
|
4249
4740
|
private setCurrentOffset(offset: number) {
|
|
4741
|
+
if (this.externalScrollHost) {
|
|
4742
|
+
this.scrollToAbsoluteOffset(offset, false);
|
|
4743
|
+
return;
|
|
4744
|
+
}
|
|
4250
4745
|
const maximum = Math.max(0, this.contentLength() - this.viewportLength());
|
|
4251
4746
|
const next = Math.max(0, Math.min(maximum, offset));
|
|
4252
4747
|
if (this.layout.horizontal) this.viewport.scrollLeft = next;
|
|
@@ -4339,12 +4834,13 @@ export class NativeListWebEngine {
|
|
|
4339
4834
|
const insets = this.collapsiblePagerInsets();
|
|
4340
4835
|
const left =
|
|
4341
4836
|
viewportRect.left + destinationLayout.x - this.viewport.scrollLeft;
|
|
4342
|
-
const top =
|
|
4343
|
-
viewportRect.top +
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4837
|
+
const top = this.externalScrollHost
|
|
4838
|
+
? viewportRect.top + destinationLayout.y
|
|
4839
|
+
: viewportRect.top +
|
|
4840
|
+
destinationLayout.y +
|
|
4841
|
+
insets.header +
|
|
4842
|
+
insets.sticky -
|
|
4843
|
+
this.viewport.scrollTop;
|
|
4348
4844
|
this.reorderPreview.getBoundingClientRect();
|
|
4349
4845
|
this.reorderPreview.style.transition =
|
|
4350
4846
|
'transform ' +
|
|
@@ -4416,6 +4912,18 @@ export class NativeListWebEngine {
|
|
|
4416
4912
|
}
|
|
4417
4913
|
|
|
4418
4914
|
private reorderViewportRect() {
|
|
4915
|
+
if (this.externalScrollHost) {
|
|
4916
|
+
const geometry = this.externalGeometry();
|
|
4917
|
+
const body = this.viewport.getBoundingClientRect();
|
|
4918
|
+
return {
|
|
4919
|
+
left: body.left,
|
|
4920
|
+
right: body.right,
|
|
4921
|
+
width: body.width,
|
|
4922
|
+
top: geometry.top,
|
|
4923
|
+
bottom: geometry.bottom,
|
|
4924
|
+
height: geometry.viewportLength,
|
|
4925
|
+
};
|
|
4926
|
+
}
|
|
4419
4927
|
const { left, top, right, bottom, width, height } =
|
|
4420
4928
|
this.viewport.getBoundingClientRect();
|
|
4421
4929
|
return { left, top, right, bottom, width, height };
|