@onekeyfe/react-native-native-list 6.8.0-3 → 6.8.0-31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +3 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +18 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +12 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +166 -36
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +8 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +6 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +21 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListRowUpdates.kt +34 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentLayout.kt +71 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentsView.kt +126 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
- package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentitySubtitleBindingTest.kt +177 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListTitleSegmentLayoutTest.kt +130 -0
- package/docs/ROW_TEMPLATES.md +8 -1
- package/docs/SPEC.md +312 -5
- package/docs/STYLE_SPEC.md +7 -1
- package/ios/NativeListAccessoryStack.swift +22 -0
- package/ios/NativeListActivityDetailsView.swift +45 -1
- package/ios/NativeListDataRowRenderer.swift +12 -5
- package/ios/NativeListIdentityRenderer.swift +145 -66
- package/ios/NativeListLeadingVisual.swift +8 -0
- package/ios/NativeListMarketRenderer.swift +6 -2
- package/ios/NativeListModels.swift +7 -0
- package/ios/NativeListResolvedText.swift +9 -7
- package/ios/NativeListSectionHeaderRenderer.swift +9 -43
- package/ios/NativeListTextStyles.swift +72 -12
- package/ios/NativeListTitleSegmentLayout.swift +72 -0
- package/ios/NativeListTitleSegmentsLabel.swift +92 -0
- package/ios/RNCNativeListView.swift +203 -45
- package/ios/tests/NativeListActivityPresentationTests.swift +137 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +155 -0
- package/ios/tests/NativeListLifecycleTests.swift +298 -24
- package/ios/tests/NativeListMediaVisibilityTests.swift +2 -1
- package/lib/module/models.js +2 -0
- package/lib/module/validation.js +96 -13
- package/lib/module/web/NativeListWebEngine.js +427 -100
- package/lib/module/web/templates/ActivityRowRenderer.js +1 -1
- package/lib/module/web/templates/IdentityRowRenderer.js +134 -3
- package/lib/module/web/templates/MarketRowRenderer.js +2 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +1 -0
- package/lib/module/web/templates/RowElements.js +2 -2
- package/lib/module/web/templates/RowText.js +2 -0
- package/lib/typescript/src/models.d.ts +35 -1
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +17 -2
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +6 -2
- package/lib/typescript/src/web/templates/RowVisual.d.ts +1 -1
- package/package.json +1 -1
- package/src/models.ts +38 -0
- package/src/validation.ts +196 -6
- package/src/web/NativeListWebEngine.ts +671 -112
- package/src/web/templates/ActivityRowRenderer.ts +1 -1
- package/src/web/templates/IdentityRowRenderer.ts +208 -3
- package/src/web/templates/MarketRowRenderer.ts +2 -0
- package/src/web/templates/MediaTileRowRenderer.ts +1 -0
- package/src/web/templates/RowElements.ts +3 -2
- package/src/web/templates/RowText.ts +6 -0
- package/src/web/templates/RowVisual.ts +2 -1
|
@@ -97,6 +97,7 @@ export const WEB_REORDER_ANIMATION = {
|
|
|
97
97
|
} as const;
|
|
98
98
|
|
|
99
99
|
const REORDER_TOUCH_LONG_PRESS_MS = 120;
|
|
100
|
+
const REORDER_CLICK_GRACE_MS = 500;
|
|
100
101
|
const MARKET_LONG_PRESS_MS = 800;
|
|
101
102
|
const MARKET_MOVE_CANCEL_PX = 10;
|
|
102
103
|
const REORDER_MOUSE_MOVE_THRESHOLD_PX = 5;
|
|
@@ -277,6 +278,7 @@ type PendingScroll =
|
|
|
277
278
|
kind: 'index';
|
|
278
279
|
index: number;
|
|
279
280
|
scroll: NormalizedPositionScroll;
|
|
281
|
+
behavior: ScrollBehavior;
|
|
280
282
|
}>
|
|
281
283
|
| Readonly<{ kind: 'offset'; offset: number; animated: boolean }>
|
|
282
284
|
| Readonly<{ kind: 'end'; animated: boolean }>;
|
|
@@ -285,6 +287,8 @@ type PointerReorderState = {
|
|
|
285
287
|
pointerId: number;
|
|
286
288
|
pointerType: string;
|
|
287
289
|
sourceKey: string;
|
|
290
|
+
memberKey?: string;
|
|
291
|
+
handle?: HTMLElement;
|
|
288
292
|
currentIndex: number;
|
|
289
293
|
startX: number;
|
|
290
294
|
startY: number;
|
|
@@ -302,11 +306,25 @@ type PointerReorderState = {
|
|
|
302
306
|
}>;
|
|
303
307
|
previewOffsetX?: number;
|
|
304
308
|
previewOffsetY?: number;
|
|
309
|
+
handoff?: { index: number; scrollOffset: number; itemCenter: number };
|
|
310
|
+
restoringKeyboardOrder?: boolean;
|
|
305
311
|
longPressTimer?: number;
|
|
306
312
|
activatedAt?: number;
|
|
307
313
|
active: boolean;
|
|
308
314
|
};
|
|
309
315
|
|
|
316
|
+
type ReorderClickPointer = Readonly<{
|
|
317
|
+
suppress: boolean;
|
|
318
|
+
pressTarget?: Element;
|
|
319
|
+
release?: Readonly<{
|
|
320
|
+
target: Element | undefined;
|
|
321
|
+
clientX: number;
|
|
322
|
+
clientY: number;
|
|
323
|
+
pointerType: string;
|
|
324
|
+
timer: number;
|
|
325
|
+
}>;
|
|
326
|
+
}>;
|
|
327
|
+
|
|
310
328
|
type KeyboardReorderState = {
|
|
311
329
|
sourceKey: string;
|
|
312
330
|
originalRows: readonly RowModel[];
|
|
@@ -327,6 +345,15 @@ export function isWebRowReorderable(
|
|
|
327
345
|
);
|
|
328
346
|
}
|
|
329
347
|
|
|
348
|
+
function hasWebReorderHandle(row: RowModel): boolean {
|
|
349
|
+
if (row.type === 'walletGroup')
|
|
350
|
+
return [row.parent, ...row.children].some(hasWebReorderHandle);
|
|
351
|
+
return (
|
|
352
|
+
'trailing' in row &&
|
|
353
|
+
row.trailing?.some((accessory) => accessory.kind === 'drag') === true
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
|
|
330
357
|
export function moveWebReorderRow(
|
|
331
358
|
rows: readonly RowModel[],
|
|
332
359
|
fromIndex: number,
|
|
@@ -829,8 +856,11 @@ export const WEB_LIST_CSS = `
|
|
|
829
856
|
.ok-native-list-wallet-member[data-native-list-selected="true"]>.ok-native-list-wallet-row{background:var(--nl-selected)}
|
|
830
857
|
.ok-native-list-wallet-member:not([data-native-list-selected="true"]):hover>.ok-native-list-wallet-row{background:var(--nl-strong)}
|
|
831
858
|
.ok-native-list-wallet-member:not([data-native-list-selected="true"]):active>.ok-native-list-wallet-row{background:var(--nl-pressed)}
|
|
859
|
+
.ok-native-list-item[data-native-list-reorderable="true"]:focus-visible>:is(.ok-native-list-row,.ok-native-list-wallet-group),
|
|
832
860
|
.ok-native-list-item[data-native-list-row-press-enabled="true"]:focus-visible>.ok-native-list-row{outline:2px solid var(--nl-accent);outline-offset:-2px}
|
|
833
861
|
.ok-native-list-item[data-native-list-reorderable="true"]>.ok-native-list-row{cursor:grab}
|
|
862
|
+
:where(.ok-native-list-root[data-native-list-reorder-activation="handle"]) .ok-native-list-item[data-native-list-reorderable="true"]>.ok-native-list-row{cursor:default}
|
|
863
|
+
.ok-native-list-item[data-native-list-reorderable="true"] [data-native-list-reorder-handle]{cursor:grab}
|
|
834
864
|
.ok-native-list-root[data-native-list-dragging="true"] .ok-native-list-row{cursor:grabbing}
|
|
835
865
|
.ok-native-list-item[data-native-list-animate-reorder="true"]{transition:transform ${WEB_REORDER_ANIMATION.outOfWayDurationMs}ms ${WEB_REORDER_ANIMATION.outOfWayTimingFunction},height ${WEB_REORDER_ANIMATION.outOfWayDurationMs}ms ${WEB_REORDER_ANIMATION.outOfWayTimingFunction}}
|
|
836
866
|
.ok-native-list-item[data-native-list-dragging="true"]>.ok-native-list-row{overflow:hidden;border-radius:12px;background:var(--nl-pressed)}
|
|
@@ -851,8 +881,9 @@ export const WEB_LIST_CSS = `
|
|
|
851
881
|
.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}
|
|
852
882
|
.ok-native-list-trailing-button{appearance:none;box-sizing:border-box;flex:0 0 auto;padding:4px 10px;border:1px solid transparent;border-radius:9999px;background:var(--nl-button-bg,var(--nl-strong));color:var(--nl-button-text,var(--nl-primary));font:500 14px/20px var(--nl-font-medium);white-space:nowrap;cursor:default}.ok-native-list-trailing-button:hover:not(:disabled){background:var(--nl-button-hover,var(--nl-strong))}.ok-native-list-trailing-button:active:not(:disabled){background:var(--nl-button-pressed,var(--nl-pressed))}.ok-native-list-trailing-button:focus-visible{outline:2px solid var(--nl-button-focus,var(--nl-accent))}.ok-native-list-trailing-button:disabled{opacity:.4;cursor:default}
|
|
853
883
|
.ok-native-list-icon-button.ok-native-list-tertiary-icon{box-sizing:border-box;flex:0 0 38px;width:38px;height:38px;margin:-7px;padding:6px;border:1px solid transparent;border-radius:9999px;color:var(--nl-icon-subdued);background:transparent}.ok-native-list-icon-button.ok-native-list-tertiary-icon:hover:not(:disabled){background:var(--nl-hover)}.ok-native-list-icon-button.ok-native-list-tertiary-icon:active:not(:disabled){background:var(--nl-pressed)}.ok-native-list-icon-button.ok-native-list-tertiary-icon:disabled{opacity:.4;cursor:default}
|
|
884
|
+
.ok-native-list-action-glyph{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center}
|
|
854
885
|
.ok-native-list-icon-button.ok-native-list-tertiary-icon:focus-visible:not(:disabled){outline:2px solid var(--nl-accent)}
|
|
855
|
-
.ok-native-list-identity-title-icon{flex:0 0 20px;width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;color:var(--nl-icon);font-size:20px}.ok-native-list-identity-title-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
886
|
+
.ok-native-list-identity-title-icon{flex:0 0 20px;width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;color:var(--nl-icon);font-size:20px}.ok-native-list-identity-title-leading-icon{flex:0 0 16px;width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--nl-icon-subdued);font-size:16px}.ok-native-list-identity-title-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
856
887
|
.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)}
|
|
857
888
|
.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)}
|
|
858
889
|
.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}
|
|
@@ -861,7 +892,7 @@ export const WEB_LIST_CSS = `
|
|
|
861
892
|
.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-image-skeleton{position:absolute;inset:0;border-radius:inherit;pointer-events:none;animation:ok-native-list-skeleton-light 1.5s linear infinite alternate}.ok-native-list-image-skeleton[data-dark="true"]{animation-name:ok-native-list-skeleton-dark}@keyframes ok-native-list-skeleton-light{0%{background-color:#fafafa}100%{background-color:#cdcdcd}}@keyframes ok-native-list-skeleton-dark{0%{background-color:#111111}100%{background-color:#333333}}@media(prefers-reduced-motion:reduce){.ok-native-list-image-skeleton{animation:none;background-color:var(--nl-strong)}}.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}
|
|
862
893
|
.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)}}
|
|
863
894
|
.ok-native-list-icon-button.ok-native-list-decorative-refresh{min-width:16px;width:16px;height:16px}
|
|
864
|
-
.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-badge[data-tone="success"]{background:var(--nl-success-background,color-mix(in srgb,var(--nl-positive) 12%,transparent));color:var(--nl-positive)}.ok-native-list-section>.ok-native-list-badge[data-tone="success"]{box-sizing:border-box;height:20px;padding:2px 8px;border-radius:4px;font:500 12px/16px var(--nl-font-medium)}.ok-native-list-badges{display:inline-flex;gap:4px;margin-left:6px;vertical-align:middle}
|
|
895
|
+
.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-badge[data-tone="success"]{background:var(--nl-success-background,color-mix(in srgb,var(--nl-positive) 12%,transparent));color:var(--nl-positive)}.ok-native-list-section>.ok-native-list-badge[data-tone="success"]{box-sizing:border-box;height:20px;padding:2px 8px;border-radius:4px;font:500 12px/16px var(--nl-font-medium);font-variant-numeric:inherit}.ok-native-list-badges{display:inline-flex;gap:4px;margin-left:6px;vertical-align:middle}
|
|
865
896
|
.ok-native-list-identity-row .ok-native-list-badge[data-tone="neutral"]{height:20px;box-sizing:border-box;padding:2px 8px;border-radius:4px;background:var(--nl-strong);color:var(--nl-secondary);font-size:12px;line-height:16px;font-weight:500;font-family:var(--nl-font-medium)}
|
|
866
897
|
.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}
|
|
867
898
|
.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)}
|
|
@@ -1187,7 +1218,11 @@ function paintSelectorImageBackground(
|
|
|
1187
1218
|
}
|
|
1188
1219
|
|
|
1189
1220
|
function applySelectorIcon(element: HTMLElement, name: string) {
|
|
1190
|
-
|
|
1221
|
+
// Registered names keep their legacy aliases; any other name resolves
|
|
1222
|
+
// through the host icon catalog, matching the iOS/Android fallback.
|
|
1223
|
+
const canonical = Object.prototype.hasOwnProperty.call(selectorIcons, name)
|
|
1224
|
+
? selectorIcons[name]
|
|
1225
|
+
: name;
|
|
1191
1226
|
if (!canonical) return;
|
|
1192
1227
|
if (canonical === 'Circle') {
|
|
1193
1228
|
const svg = element.ownerDocument.createElementNS(
|
|
@@ -1210,7 +1245,10 @@ function applySelectorIcon(element: HTMLElement, name: string) {
|
|
|
1210
1245
|
element.replaceChildren(svg);
|
|
1211
1246
|
return;
|
|
1212
1247
|
}
|
|
1213
|
-
|
|
1248
|
+
const svg = createNamedIcon(element.ownerDocument, canonical);
|
|
1249
|
+
// Without host artwork the element keeps its text glyph.
|
|
1250
|
+
if (!svg.firstChild) return;
|
|
1251
|
+
element.replaceChildren(svg);
|
|
1214
1252
|
}
|
|
1215
1253
|
|
|
1216
1254
|
function iconGlyph(name: string): string {
|
|
@@ -1395,6 +1433,8 @@ function createVisual(
|
|
|
1395
1433
|
if (svg) {
|
|
1396
1434
|
svg.style.width = `${fallbackIcon.size}px`;
|
|
1397
1435
|
svg.style.height = `${fallbackIcon.size}px`;
|
|
1436
|
+
// Keep the requested size inside a bordered frame, as Icon w/h does.
|
|
1437
|
+
svg.style.flexShrink = '0';
|
|
1398
1438
|
}
|
|
1399
1439
|
}
|
|
1400
1440
|
}
|
|
@@ -1413,8 +1453,21 @@ function createVisual(
|
|
|
1413
1453
|
'2px dashed ' + (visual.borderColor ?? 'var(--nl-disabled)');
|
|
1414
1454
|
frame.style.boxSizing = 'border-box';
|
|
1415
1455
|
} else if ('borderColor' in visual && visual.borderColor) {
|
|
1416
|
-
frame.style.border =
|
|
1456
|
+
frame.style.border =
|
|
1457
|
+
String(
|
|
1458
|
+
'borderWidth' in visual && visual.borderWidth ? visual.borderWidth : 1
|
|
1459
|
+
) +
|
|
1460
|
+
'px solid ' +
|
|
1461
|
+
visual.borderColor;
|
|
1417
1462
|
frame.style.boxSizing = 'border-box';
|
|
1463
|
+
// iOS and Android inset the image by the border, as React Native's Image does.
|
|
1464
|
+
const main = frame.querySelector<HTMLElement>(
|
|
1465
|
+
':scope > .ok-native-list-visual-main'
|
|
1466
|
+
);
|
|
1467
|
+
if (main) {
|
|
1468
|
+
main.style.width = '100%';
|
|
1469
|
+
main.style.height = '100%';
|
|
1470
|
+
}
|
|
1418
1471
|
}
|
|
1419
1472
|
if ('overlays' in visual)
|
|
1420
1473
|
visual.overlays?.forEach((overlay) => {
|
|
@@ -1630,7 +1683,8 @@ function createIconAction(
|
|
|
1630
1683
|
name: string,
|
|
1631
1684
|
actionKey: string | undefined,
|
|
1632
1685
|
disabled?: boolean,
|
|
1633
|
-
tintColor?: string
|
|
1686
|
+
tintColor?: string,
|
|
1687
|
+
accessibilityLabel?: string
|
|
1634
1688
|
): HTMLElement {
|
|
1635
1689
|
const element = createElement(
|
|
1636
1690
|
context.document,
|
|
@@ -1641,7 +1695,13 @@ function createIconAction(
|
|
|
1641
1695
|
if (element.tagName === 'BUTTON') {
|
|
1642
1696
|
element.setAttribute('type', 'button');
|
|
1643
1697
|
element.toggleAttribute('disabled', Boolean(disabled));
|
|
1644
|
-
|
|
1698
|
+
element.setAttribute(
|
|
1699
|
+
'aria-label',
|
|
1700
|
+
accessibilityLabel || (name === 'DotVerSolid' ? '⋮' : iconGlyph(name))
|
|
1701
|
+
);
|
|
1702
|
+
} else if (accessibilityLabel) {
|
|
1703
|
+
element.setAttribute('aria-label', accessibilityLabel);
|
|
1704
|
+
element.setAttribute('role', 'img');
|
|
1645
1705
|
}
|
|
1646
1706
|
applySelectorIcon(element, name);
|
|
1647
1707
|
if (actionKey) setData(element, 'nativeListAction', actionKey);
|
|
@@ -1712,8 +1772,9 @@ function createAccessory(
|
|
|
1712
1772
|
context,
|
|
1713
1773
|
accessory.name,
|
|
1714
1774
|
accessory.actionKey,
|
|
1715
|
-
accessory.disabled,
|
|
1716
|
-
accessory.tintColor
|
|
1775
|
+
rowDisabled || accessory.disabled,
|
|
1776
|
+
accessory.tintColor,
|
|
1777
|
+
accessory.accessibilityLabel
|
|
1717
1778
|
);
|
|
1718
1779
|
markActionAnchorSource(element, 'trailingAccessory', slot);
|
|
1719
1780
|
if (accessory.name === 'RefreshCcwOutline' && !accessory.actionKey) {
|
|
@@ -1731,8 +1792,6 @@ function createAccessory(
|
|
|
1731
1792
|
setData(element, 'nativeListHoverAction', accessory.hoverActionKey);
|
|
1732
1793
|
if (accessory.hoverActionKey && accessory.buttonStyle === 'tertiary')
|
|
1733
1794
|
setData(element, 'nativeListIconHelp', true);
|
|
1734
|
-
if (accessory.accessibilityLabel)
|
|
1735
|
-
element.setAttribute('aria-label', accessory.accessibilityLabel);
|
|
1736
1795
|
const row = context.snapshot.rows[context.itemIndex];
|
|
1737
1796
|
if (
|
|
1738
1797
|
row &&
|
|
@@ -1830,6 +1889,23 @@ function createAccessory(
|
|
|
1830
1889
|
break;
|
|
1831
1890
|
case 'drag':
|
|
1832
1891
|
element.textContent = '≡';
|
|
1892
|
+
applySelectorIcon(element, 'DragOutline');
|
|
1893
|
+
// iOS and Android tint the handle iconSubdued, like ListItem.IconButton.
|
|
1894
|
+
element.style.color = 'var(--nl-icon-subdued)';
|
|
1895
|
+
// A 24-point centered box, so the glyph does not follow the text line box.
|
|
1896
|
+
Object.assign(element.style, {
|
|
1897
|
+
display: 'inline-flex',
|
|
1898
|
+
alignItems: 'center',
|
|
1899
|
+
justifyContent: 'center',
|
|
1900
|
+
width: '24px',
|
|
1901
|
+
height: '24px',
|
|
1902
|
+
});
|
|
1903
|
+
if (actionKey) {
|
|
1904
|
+
element.toggleAttribute('disabled', rowDisabled);
|
|
1905
|
+
element.setAttribute('aria-label', '≡');
|
|
1906
|
+
}
|
|
1907
|
+
setData(element, 'nativeListReorderHandle', true);
|
|
1908
|
+
setData(element, 'nativeListAnchorSlot', slot);
|
|
1833
1909
|
break;
|
|
1834
1910
|
case 'progress':
|
|
1835
1911
|
element.textContent = String(Math.round(accessory.value * 100)) + '%';
|
|
@@ -1854,8 +1930,17 @@ function rendererPrimitives(context: RenderContext, rowDisabled: boolean) {
|
|
|
1854
1930
|
name: string,
|
|
1855
1931
|
actionKey: string | undefined,
|
|
1856
1932
|
disabled?: boolean,
|
|
1857
|
-
tintColor?: string
|
|
1858
|
-
|
|
1933
|
+
tintColor?: string,
|
|
1934
|
+
accessibilityLabel?: string
|
|
1935
|
+
) =>
|
|
1936
|
+
createIconAction(
|
|
1937
|
+
context,
|
|
1938
|
+
name,
|
|
1939
|
+
actionKey,
|
|
1940
|
+
rowDisabled || disabled,
|
|
1941
|
+
tintColor,
|
|
1942
|
+
accessibilityLabel
|
|
1943
|
+
),
|
|
1859
1944
|
dispose: disposeWebImageRetries,
|
|
1860
1945
|
};
|
|
1861
1946
|
}
|
|
@@ -1955,7 +2040,10 @@ export class NativeListWebEngine {
|
|
|
1955
2040
|
private reorderSettlingKey: string | undefined;
|
|
1956
2041
|
private reorderCompactKey: string | undefined;
|
|
1957
2042
|
private reorderExpandingKey: string | undefined;
|
|
1958
|
-
private
|
|
2043
|
+
private readonly reorderClickPointers = new Map<
|
|
2044
|
+
number,
|
|
2045
|
+
ReorderClickPointer
|
|
2046
|
+
>();
|
|
1959
2047
|
private pullStartY: number | undefined;
|
|
1960
2048
|
private pullDistance = 0;
|
|
1961
2049
|
private virtualizationEnabled: boolean;
|
|
@@ -2199,6 +2287,13 @@ export class NativeListWebEngine {
|
|
|
2199
2287
|
this.handleCollapsiblePagerInsetsChanged
|
|
2200
2288
|
);
|
|
2201
2289
|
this.root.addEventListener('click', this.handleClick);
|
|
2290
|
+
this.document.addEventListener('pointerdown', this.trackReorderPress, true);
|
|
2291
|
+
this.document.addEventListener('pointerup', this.trackReorderRelease, true);
|
|
2292
|
+
this.document.addEventListener(
|
|
2293
|
+
'pointercancel',
|
|
2294
|
+
this.trackReorderRelease,
|
|
2295
|
+
true
|
|
2296
|
+
);
|
|
2202
2297
|
this.root.addEventListener('contextmenu', this.handleMarketContextMenu);
|
|
2203
2298
|
this.root.addEventListener('pointerdown', this.handleMarketPointerDown);
|
|
2204
2299
|
this.root.addEventListener('pointermove', this.handleMarketPointerMove);
|
|
@@ -2384,6 +2479,27 @@ export class NativeListWebEngine {
|
|
|
2384
2479
|
private applyValidatedSnapshot(validated: NativeListSnapshot) {
|
|
2385
2480
|
this.pressedHelpElement = undefined;
|
|
2386
2481
|
this.invalidateActionAnchor('snapshot');
|
|
2482
|
+
const capabilities = this.snapshot.capabilities;
|
|
2483
|
+
const nextCapabilities = validated.capabilities;
|
|
2484
|
+
if (
|
|
2485
|
+
this.pointerReorder?.active ||
|
|
2486
|
+
this.pointerReorder?.restoringKeyboardOrder ||
|
|
2487
|
+
this.keyboardReorder ||
|
|
2488
|
+
capabilities?.reorderable !== nextCapabilities?.reorderable ||
|
|
2489
|
+
(capabilities?.reorderActivation ?? 'row') !==
|
|
2490
|
+
(nextCapabilities?.reorderActivation ?? 'row')
|
|
2491
|
+
) {
|
|
2492
|
+
this.cancelPointerReorder(false);
|
|
2493
|
+
}
|
|
2494
|
+
const keyboardSource = this.keyboardReorder?.sourceKey;
|
|
2495
|
+
const preserveKeyboardFocus =
|
|
2496
|
+
keyboardSource &&
|
|
2497
|
+
this.document.activeElement?.getAttribute('data-native-list-row-key') ===
|
|
2498
|
+
keyboardSource;
|
|
2499
|
+
if (this.keyboardReorder) {
|
|
2500
|
+
this.keyboardReorder = undefined;
|
|
2501
|
+
this.updateReorderVisualState();
|
|
2502
|
+
}
|
|
2387
2503
|
const transition = validated.structuralTransition;
|
|
2388
2504
|
const isNewTransition =
|
|
2389
2505
|
transition !== undefined &&
|
|
@@ -2424,6 +2540,7 @@ export class NativeListWebEngine {
|
|
|
2424
2540
|
this.cancelStructuralAnimation();
|
|
2425
2541
|
this.setSnapshot(validated);
|
|
2426
2542
|
}
|
|
2543
|
+
if (preserveKeyboardFocus) this.focusMountedRow(keyboardSource);
|
|
2427
2544
|
this.hasAppliedSnapshot = true;
|
|
2428
2545
|
}
|
|
2429
2546
|
|
|
@@ -2478,6 +2595,13 @@ export class NativeListWebEngine {
|
|
|
2478
2595
|
(event as PointerEvent).pointerType !== 'touch'
|
|
2479
2596
|
)
|
|
2480
2597
|
return;
|
|
2598
|
+
if (
|
|
2599
|
+
event.type === 'wheel' &&
|
|
2600
|
+
this.keyboardReorder &&
|
|
2601
|
+
this.wheelReachesScrollOwner(event as WheelEvent)
|
|
2602
|
+
) {
|
|
2603
|
+
this.cancelKeyboardReorder(false);
|
|
2604
|
+
}
|
|
2481
2605
|
this.structuralScrollInterrupted = true;
|
|
2482
2606
|
if (this.structuralPrefixTransition) {
|
|
2483
2607
|
this.cancelStructuralAnimation();
|
|
@@ -2485,6 +2609,62 @@ export class NativeListWebEngine {
|
|
|
2485
2609
|
}
|
|
2486
2610
|
};
|
|
2487
2611
|
|
|
2612
|
+
private wheelReachesScrollOwner(event: WheelEvent) {
|
|
2613
|
+
if (event.defaultPrevented || event.ctrlKey) return false;
|
|
2614
|
+
const view = this.document.defaultView;
|
|
2615
|
+
if (!view) return true;
|
|
2616
|
+
const horizontal =
|
|
2617
|
+
event.shiftKey || Math.abs(event.deltaX) > Math.abs(event.deltaY);
|
|
2618
|
+
const delta = horizontal ? event.deltaX || event.deltaY : event.deltaY;
|
|
2619
|
+
for (const target of event.composedPath()) {
|
|
2620
|
+
if (target === event.currentTarget) break;
|
|
2621
|
+
if (!(target instanceof view.HTMLElement)) continue;
|
|
2622
|
+
const offset = horizontal ? target.scrollLeft : target.scrollTop;
|
|
2623
|
+
const scrollRange = horizontal
|
|
2624
|
+
? target.scrollWidth - target.clientWidth
|
|
2625
|
+
: target.scrollHeight - target.clientHeight;
|
|
2626
|
+
if (scrollRange <= 0) continue;
|
|
2627
|
+
const style = view.getComputedStyle(target);
|
|
2628
|
+
const negativeOffset = this.hasNegativeScrollOffsets(style, horizontal);
|
|
2629
|
+
const minOffset = negativeOffset ? -scrollRange : 0;
|
|
2630
|
+
const maxOffset = negativeOffset ? 0 : scrollRange;
|
|
2631
|
+
const overflow =
|
|
2632
|
+
(horizontal ? style.overflowX : style.overflowY) || style.overflow;
|
|
2633
|
+
if (overflow !== 'auto' && overflow !== 'scroll') continue;
|
|
2634
|
+
const overscroll = horizontal
|
|
2635
|
+
? style.overscrollBehaviorX
|
|
2636
|
+
: style.overscrollBehaviorY;
|
|
2637
|
+
if (
|
|
2638
|
+
overscroll === 'contain' ||
|
|
2639
|
+
overscroll === 'none' ||
|
|
2640
|
+
(delta < 0 ? offset > minOffset : offset < maxOffset)
|
|
2641
|
+
) {
|
|
2642
|
+
return false;
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
return true;
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2648
|
+
private hasNegativeScrollOffsets(
|
|
2649
|
+
style: CSSStyleDeclaration,
|
|
2650
|
+
horizontal: boolean
|
|
2651
|
+
): boolean {
|
|
2652
|
+
const { writingMode, direction, display, flexDirection, flexWrap } = style;
|
|
2653
|
+
const horizontalWritingMode =
|
|
2654
|
+
!writingMode || writingMode === 'horizontal-tb';
|
|
2655
|
+
const inlineAxis = horizontal === horizontalWritingMode;
|
|
2656
|
+
const negative = inlineAxis
|
|
2657
|
+
? (direction === 'rtl') !== (writingMode === 'sideways-lr')
|
|
2658
|
+
: horizontal && writingMode.endsWith('-rl');
|
|
2659
|
+
const isFlexMainAxis = inlineAxis !== flexDirection.startsWith('column');
|
|
2660
|
+
const reversedFlex =
|
|
2661
|
+
(display === 'flex' || display === 'inline-flex') &&
|
|
2662
|
+
(isFlexMainAxis
|
|
2663
|
+
? flexDirection.endsWith('-reverse')
|
|
2664
|
+
: flexWrap === 'wrap-reverse');
|
|
2665
|
+
return negative !== reversedFlex;
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2488
2668
|
private updateStructuralTailWindow() {
|
|
2489
2669
|
const tail = this.structuralTail;
|
|
2490
2670
|
if (!tail) return;
|
|
@@ -2814,7 +2994,12 @@ export class NativeListWebEngine {
|
|
|
2814
2994
|
}
|
|
2815
2995
|
|
|
2816
2996
|
currentSnapshot(): NativeListSnapshot {
|
|
2817
|
-
|
|
2997
|
+
const originalRows = this.pointerReorder?.active
|
|
2998
|
+
? this.pointerReorder.originalRows
|
|
2999
|
+
: this.keyboardReorder?.originalRows;
|
|
3000
|
+
return originalRows
|
|
3001
|
+
? { ...this.snapshot, rows: originalRows }
|
|
3002
|
+
: this.snapshot;
|
|
2818
3003
|
}
|
|
2819
3004
|
|
|
2820
3005
|
applyPatches(patches: readonly RowPatch[]) {
|
|
@@ -2823,7 +3008,38 @@ export class NativeListWebEngine {
|
|
|
2823
3008
|
);
|
|
2824
3009
|
if (!accepted || accepted.patches.length === 0) return;
|
|
2825
3010
|
patches = accepted.patches;
|
|
2826
|
-
|
|
3011
|
+
let next = accepted.snapshot;
|
|
3012
|
+
let restoredReorder = false;
|
|
3013
|
+
const pointer = this.pointerReorder?.active
|
|
3014
|
+
? this.pointerReorder
|
|
3015
|
+
: undefined;
|
|
3016
|
+
const keyboard = this.keyboardReorder;
|
|
3017
|
+
const reorder = pointer ?? keyboard;
|
|
3018
|
+
if (reorder) {
|
|
3019
|
+
const byKey = new Map(next.rows.map((row) => [row.key, row]));
|
|
3020
|
+
reorder.originalRows = reorder.originalRows.map(
|
|
3021
|
+
(row) => byKey.get(row.key) ?? row
|
|
3022
|
+
);
|
|
3023
|
+
const source = byKey.get(reorder.sourceKey);
|
|
3024
|
+
const canContinue = pointer
|
|
3025
|
+
? this.canStartPointerReorder(pointer, next)
|
|
3026
|
+
: source &&
|
|
3027
|
+
isWebRowReorderable(next, source) &&
|
|
3028
|
+
(next.capabilities?.reorderActivation !== 'handle' ||
|
|
3029
|
+
hasWebReorderHandle(source));
|
|
3030
|
+
if (!canContinue) {
|
|
3031
|
+
this.cancelPointerReorder(false);
|
|
3032
|
+
if (keyboard) {
|
|
3033
|
+
this.keyboardReorder = undefined;
|
|
3034
|
+
this.updateReorderVisualState();
|
|
3035
|
+
}
|
|
3036
|
+
this.remapMountedRows(reorder.originalRows);
|
|
3037
|
+
next = { ...next, rows: reorder.originalRows };
|
|
3038
|
+
restoredReorder = true;
|
|
3039
|
+
} else if (pointer) {
|
|
3040
|
+
pointer.workingRows = [...next.rows];
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
2827
3043
|
const selection = new Set(this.selectedKeys);
|
|
2828
3044
|
patches.forEach((patch) => {
|
|
2829
3045
|
const selected =
|
|
@@ -2846,7 +3062,10 @@ export class NativeListWebEngine {
|
|
|
2846
3062
|
canPatchMarketTableValues(before, after)
|
|
2847
3063
|
);
|
|
2848
3064
|
});
|
|
2849
|
-
if (
|
|
3065
|
+
if (
|
|
3066
|
+
!restoredReorder &&
|
|
3067
|
+
(webMarketImageBindDeltaForPatches(patches) === 0 || tableValuesOnly)
|
|
3068
|
+
) {
|
|
2850
3069
|
this.snapshot = next;
|
|
2851
3070
|
this.rows = effectiveRows(next);
|
|
2852
3071
|
this.selectedKeys = selection;
|
|
@@ -2885,19 +3104,23 @@ export class NativeListWebEngine {
|
|
|
2885
3104
|
this.renderFooter();
|
|
2886
3105
|
}
|
|
2887
3106
|
|
|
2888
|
-
scrollToIndex(
|
|
3107
|
+
scrollToIndex(
|
|
3108
|
+
index: number,
|
|
3109
|
+
scroll: NormalizedPositionScroll,
|
|
3110
|
+
behavior: ScrollBehavior = scroll.animated ? 'smooth' : 'auto'
|
|
3111
|
+
) {
|
|
2889
3112
|
if (index < 0 || index >= this.rows.length) {
|
|
2890
3113
|
this.emitScrollFailure(index, 'index-out-of-range');
|
|
2891
3114
|
return;
|
|
2892
3115
|
}
|
|
2893
3116
|
this.notifyScrollCommandAccepted();
|
|
2894
3117
|
if (!this.canScroll()) {
|
|
2895
|
-
this.pendingScroll = { kind: 'index', index, scroll };
|
|
3118
|
+
this.pendingScroll = { kind: 'index', index, scroll, behavior };
|
|
2896
3119
|
return;
|
|
2897
3120
|
}
|
|
2898
3121
|
const item = this.layout.items[index];
|
|
2899
3122
|
if (!item) {
|
|
2900
|
-
this.pendingScroll = { kind: 'index', index, scroll };
|
|
3123
|
+
this.pendingScroll = { kind: 'index', index, scroll, behavior };
|
|
2901
3124
|
return;
|
|
2902
3125
|
}
|
|
2903
3126
|
const viewportLength = this.viewportLength();
|
|
@@ -2913,7 +3136,7 @@ export class NativeListWebEngine {
|
|
|
2913
3136
|
viewPosition: scroll.viewPosition,
|
|
2914
3137
|
viewOffset: scroll.viewOffset,
|
|
2915
3138
|
});
|
|
2916
|
-
this.scrollToAbsoluteOffset(offset,
|
|
3139
|
+
this.scrollToAbsoluteOffset(offset, behavior);
|
|
2917
3140
|
}
|
|
2918
3141
|
|
|
2919
3142
|
scrollToKey(key: string, scroll: NormalizedPositionScroll) {
|
|
@@ -2930,8 +3153,11 @@ export class NativeListWebEngine {
|
|
|
2930
3153
|
}
|
|
2931
3154
|
if (this.externalScrollHost) {
|
|
2932
3155
|
const geometry = this.externalGeometry();
|
|
2933
|
-
this.writeExternalOffset(
|
|
2934
|
-
|
|
3156
|
+
this.writeExternalOffset(
|
|
3157
|
+
geometry.containerOrigin + offset,
|
|
3158
|
+
animated ? 'smooth' : 'auto'
|
|
3159
|
+
);
|
|
3160
|
+
} else this.scrollToAbsoluteOffset(offset, animated ? 'smooth' : 'auto');
|
|
2935
3161
|
}
|
|
2936
3162
|
|
|
2937
3163
|
scrollToEnd(animated: boolean) {
|
|
@@ -2944,12 +3170,12 @@ export class NativeListWebEngine {
|
|
|
2944
3170
|
const geometry = this.externalGeometry();
|
|
2945
3171
|
this.writeExternalOffset(
|
|
2946
3172
|
geometry.end - this.externalScrollHost.clientHeight,
|
|
2947
|
-
animated
|
|
3173
|
+
animated ? 'smooth' : 'auto'
|
|
2948
3174
|
);
|
|
2949
3175
|
} else
|
|
2950
3176
|
this.scrollToAbsoluteOffset(
|
|
2951
3177
|
Math.max(0, this.contentLength() - this.viewportLength()),
|
|
2952
|
-
animated
|
|
3178
|
+
animated ? 'smooth' : 'auto'
|
|
2953
3179
|
);
|
|
2954
3180
|
}
|
|
2955
3181
|
|
|
@@ -3048,6 +3274,23 @@ export class NativeListWebEngine {
|
|
|
3048
3274
|
this.handleCollapsiblePagerInsetsChanged
|
|
3049
3275
|
);
|
|
3050
3276
|
this.root.removeEventListener('click', this.handleClick);
|
|
3277
|
+
this.document.removeEventListener(
|
|
3278
|
+
'pointerdown',
|
|
3279
|
+
this.trackReorderPress,
|
|
3280
|
+
true
|
|
3281
|
+
);
|
|
3282
|
+
this.document.removeEventListener(
|
|
3283
|
+
'pointerup',
|
|
3284
|
+
this.trackReorderRelease,
|
|
3285
|
+
true
|
|
3286
|
+
);
|
|
3287
|
+
this.document.removeEventListener(
|
|
3288
|
+
'pointercancel',
|
|
3289
|
+
this.trackReorderRelease,
|
|
3290
|
+
true
|
|
3291
|
+
);
|
|
3292
|
+
for (const id of this.reorderClickPointers.keys())
|
|
3293
|
+
this.clearReorderClick(id);
|
|
3051
3294
|
this.root.removeEventListener('contextmenu', this.handleMarketContextMenu);
|
|
3052
3295
|
this.cancelMarketPointer();
|
|
3053
3296
|
this.root.removeEventListener('pointerdown', this.handleMarketPointerDown);
|
|
@@ -3125,6 +3368,11 @@ export class NativeListWebEngine {
|
|
|
3125
3368
|
this.pressedHelpElement = undefined;
|
|
3126
3369
|
this.measuredRendererHeights.clear();
|
|
3127
3370
|
this.snapshot = snapshot;
|
|
3371
|
+
setData(
|
|
3372
|
+
this.root,
|
|
3373
|
+
'nativeListReorderActivation',
|
|
3374
|
+
snapshot.capabilities?.reorderActivation
|
|
3375
|
+
);
|
|
3128
3376
|
this.rows = effectiveRows(snapshot);
|
|
3129
3377
|
this.selectedKeys =
|
|
3130
3378
|
selectedKeys ?? selectionStateFromSnapshot(snapshot).selectedKeys;
|
|
@@ -3250,7 +3498,7 @@ export class NativeListWebEngine {
|
|
|
3250
3498
|
this.root.style.height = value;
|
|
3251
3499
|
}
|
|
3252
3500
|
|
|
3253
|
-
private recomputeLayout = () => {
|
|
3501
|
+
private recomputeLayout = (revealIndex?: number) => {
|
|
3254
3502
|
if (this.destroyed) return;
|
|
3255
3503
|
if (
|
|
3256
3504
|
this.structuralPrefixTransition &&
|
|
@@ -3354,7 +3602,21 @@ export class NativeListWebEngine {
|
|
|
3354
3602
|
this.viewport.scrollLeft = 0;
|
|
3355
3603
|
this.viewport.scrollTop = 0;
|
|
3356
3604
|
}
|
|
3357
|
-
|
|
3605
|
+
if (revealIndex !== undefined) {
|
|
3606
|
+
// Mount against the destination offset, even on hosts with smooth scrolling.
|
|
3607
|
+
this.pendingScroll = undefined;
|
|
3608
|
+
this.scrollToIndex(
|
|
3609
|
+
revealIndex,
|
|
3610
|
+
{
|
|
3611
|
+
animated: false,
|
|
3612
|
+
alignment: 'nearest',
|
|
3613
|
+
viewPosition: 0,
|
|
3614
|
+
viewOffset: 0,
|
|
3615
|
+
},
|
|
3616
|
+
'instant'
|
|
3617
|
+
);
|
|
3618
|
+
}
|
|
3619
|
+
this.renderWindow(revealIndex);
|
|
3358
3620
|
this.performPendingScroll();
|
|
3359
3621
|
};
|
|
3360
3622
|
|
|
@@ -3417,7 +3679,7 @@ export class NativeListWebEngine {
|
|
|
3417
3679
|
});
|
|
3418
3680
|
}
|
|
3419
3681
|
|
|
3420
|
-
private renderWindow() {
|
|
3682
|
+
private renderWindow(revealIndex?: number) {
|
|
3421
3683
|
this.updateAvatarWindow();
|
|
3422
3684
|
const viewportLength = this.viewportLength();
|
|
3423
3685
|
const visible =
|
|
@@ -3430,6 +3692,11 @@ export class NativeListWebEngine {
|
|
|
3430
3692
|
this.virtualizationEnabled,
|
|
3431
3693
|
viewportLength * OVERSCAN_VIEWPORTS
|
|
3432
3694
|
);
|
|
3695
|
+
const keyboardSource = this.keyboardReorder?.sourceKey;
|
|
3696
|
+
if (keyboardSource && !visible.some(({ key }) => key === keyboardSource)) {
|
|
3697
|
+
this.cancelKeyboardReorder(false);
|
|
3698
|
+
return;
|
|
3699
|
+
}
|
|
3433
3700
|
const desired = new Set(visible.map((item) => item.index));
|
|
3434
3701
|
this.mounted.forEach((element, index) => {
|
|
3435
3702
|
const nextRow = this.rows[index];
|
|
@@ -3473,6 +3740,8 @@ export class NativeListWebEngine {
|
|
|
3473
3740
|
) {
|
|
3474
3741
|
this.renderElement(element, layoutItem.index, row);
|
|
3475
3742
|
element.dataset.renderSignature = signature;
|
|
3743
|
+
} else {
|
|
3744
|
+
this.updateRowReorderability(element, layoutItem.index, row);
|
|
3476
3745
|
}
|
|
3477
3746
|
});
|
|
3478
3747
|
let measuredHeightChanged = false;
|
|
@@ -3499,7 +3768,7 @@ export class NativeListWebEngine {
|
|
|
3499
3768
|
}
|
|
3500
3769
|
});
|
|
3501
3770
|
if (measuredHeightChanged) {
|
|
3502
|
-
this.recomputeLayout();
|
|
3771
|
+
this.recomputeLayout(revealIndex);
|
|
3503
3772
|
return;
|
|
3504
3773
|
}
|
|
3505
3774
|
this.updateVisibleSelection();
|
|
@@ -3514,6 +3783,29 @@ export class NativeListWebEngine {
|
|
|
3514
3783
|
element.style.height = String(item.height) + 'px';
|
|
3515
3784
|
}
|
|
3516
3785
|
|
|
3786
|
+
private updateRowReorderability(
|
|
3787
|
+
element: HTMLElement,
|
|
3788
|
+
index: number,
|
|
3789
|
+
row: RowModel
|
|
3790
|
+
) {
|
|
3791
|
+
const reorderable =
|
|
3792
|
+
this.snapshot.rows[index] === row && this.isReorderable(row);
|
|
3793
|
+
setData(element, 'nativeListReorderable', reorderable);
|
|
3794
|
+
if (isRowPressEnabled(row) || this.canStartKeyboardReorder(element)) {
|
|
3795
|
+
if (element.tabIndex !== 0) element.tabIndex = 0;
|
|
3796
|
+
} else {
|
|
3797
|
+
element.removeAttribute('tabindex');
|
|
3798
|
+
}
|
|
3799
|
+
}
|
|
3800
|
+
|
|
3801
|
+
private canStartKeyboardReorder(element: HTMLElement) {
|
|
3802
|
+
return (
|
|
3803
|
+
element.dataset.nativeListReorderable === 'true' &&
|
|
3804
|
+
(this.snapshot.capabilities?.reorderActivation !== 'handle' ||
|
|
3805
|
+
element.querySelector('[data-native-list-reorder-handle]') !== null)
|
|
3806
|
+
);
|
|
3807
|
+
}
|
|
3808
|
+
|
|
3517
3809
|
private renderElement(
|
|
3518
3810
|
element: HTMLElement,
|
|
3519
3811
|
index: number,
|
|
@@ -3548,7 +3840,6 @@ export class NativeListWebEngine {
|
|
|
3548
3840
|
(row.style?.container?.opacity ?? row.opacity ?? 1) *
|
|
3549
3841
|
(row.disabled ? 0.5 : 1)
|
|
3550
3842
|
);
|
|
3551
|
-
setData(element, 'nativeListReorderable', this.isReorderable(row));
|
|
3552
3843
|
setData(
|
|
3553
3844
|
element,
|
|
3554
3845
|
'nativeListDragging',
|
|
@@ -3568,11 +3859,6 @@ export class NativeListWebEngine {
|
|
|
3568
3859
|
'aria-label',
|
|
3569
3860
|
row.accessibilityLabel ?? this.rowLabel(row)
|
|
3570
3861
|
);
|
|
3571
|
-
if (isRowPressEnabled(row)) {
|
|
3572
|
-
element.tabIndex = 0;
|
|
3573
|
-
} else {
|
|
3574
|
-
element.removeAttribute('tabindex');
|
|
3575
|
-
}
|
|
3576
3862
|
element.draggable = false;
|
|
3577
3863
|
const context = {
|
|
3578
3864
|
document: this.document,
|
|
@@ -3606,6 +3892,7 @@ export class NativeListWebEngine {
|
|
|
3606
3892
|
// Template and presentation defaults must precede caller overrides.
|
|
3607
3893
|
applyRowStyle(body, row);
|
|
3608
3894
|
if (body.parentElement !== element) element.replaceChildren(body);
|
|
3895
|
+
this.updateRowReorderability(element, overlay ? -1 : index, row);
|
|
3609
3896
|
if (
|
|
3610
3897
|
row.type === 'market' &&
|
|
3611
3898
|
row.diagnostics?.imageBindActionKey &&
|
|
@@ -4190,7 +4477,7 @@ export class NativeListWebEngine {
|
|
|
4190
4477
|
this.recomputeLayout();
|
|
4191
4478
|
};
|
|
4192
4479
|
|
|
4193
|
-
private writeExternalOffset(rawOffset: number,
|
|
4480
|
+
private writeExternalOffset(rawOffset: number, behavior: ScrollBehavior) {
|
|
4194
4481
|
this.externalGeometryCache = undefined;
|
|
4195
4482
|
const host = this.externalScrollHost!;
|
|
4196
4483
|
const scrollTo: (options: ScrollToOptions) => void =
|
|
@@ -4201,17 +4488,17 @@ export class NativeListWebEngine {
|
|
|
4201
4488
|
0,
|
|
4202
4489
|
Math.min(host.scrollHeight - host.clientHeight, rawOffset)
|
|
4203
4490
|
),
|
|
4204
|
-
behavior
|
|
4491
|
+
behavior,
|
|
4205
4492
|
});
|
|
4206
4493
|
this.scheduleFrame();
|
|
4207
4494
|
}
|
|
4208
4495
|
|
|
4209
|
-
private scrollToAbsoluteOffset(offset: number,
|
|
4496
|
+
private scrollToAbsoluteOffset(offset: number, behavior: ScrollBehavior) {
|
|
4210
4497
|
if (this.externalScrollHost) {
|
|
4211
4498
|
const geometry = this.externalGeometry();
|
|
4212
4499
|
this.writeExternalOffset(
|
|
4213
4500
|
geometry.origin + offset - this.externalStickyInset,
|
|
4214
|
-
|
|
4501
|
+
behavior
|
|
4215
4502
|
);
|
|
4216
4503
|
return;
|
|
4217
4504
|
}
|
|
@@ -4227,8 +4514,8 @@ export class NativeListWebEngine {
|
|
|
4227
4514
|
);
|
|
4228
4515
|
this.viewport.scrollTo(
|
|
4229
4516
|
this.layout.horizontal
|
|
4230
|
-
? { left: rawOffset, top: 0, behavior
|
|
4231
|
-
: { left: 0, top: rawOffset, behavior
|
|
4517
|
+
? { left: rawOffset, top: 0, behavior }
|
|
4518
|
+
: { left: 0, top: rawOffset, behavior }
|
|
4232
4519
|
);
|
|
4233
4520
|
this.scheduleFrame();
|
|
4234
4521
|
}
|
|
@@ -4238,7 +4525,7 @@ export class NativeListWebEngine {
|
|
|
4238
4525
|
if (!pending || !this.canScroll()) return;
|
|
4239
4526
|
this.pendingScroll = undefined;
|
|
4240
4527
|
if (pending.kind === 'index')
|
|
4241
|
-
this.scrollToIndex(pending.index, pending.scroll);
|
|
4528
|
+
this.scrollToIndex(pending.index, pending.scroll, pending.behavior);
|
|
4242
4529
|
else if (pending.kind === 'offset')
|
|
4243
4530
|
this.scrollToOffset(pending.offset, pending.animated);
|
|
4244
4531
|
else this.scrollToEnd(pending.animated);
|
|
@@ -4328,7 +4615,10 @@ export class NativeListWebEngine {
|
|
|
4328
4615
|
if (!source || !bindingEpoch || !rowElement.contains(actionElement))
|
|
4329
4616
|
return undefined;
|
|
4330
4617
|
this.invalidateActionAnchor('rebind');
|
|
4331
|
-
const
|
|
4618
|
+
const glyph = actionElement.querySelector(
|
|
4619
|
+
':scope > [data-native-list-anchor-glyph]'
|
|
4620
|
+
);
|
|
4621
|
+
const actualRect = (glyph ?? actionElement).getBoundingClientRect();
|
|
4332
4622
|
const inset = Number(actionElement.dataset.nativeListAnchorInset ?? 0);
|
|
4333
4623
|
const rect = {
|
|
4334
4624
|
left: actualRect.left + inset,
|
|
@@ -4682,8 +4972,122 @@ export class NativeListWebEngine {
|
|
|
4682
4972
|
this.invalidateActionAnchor('pointerLeave');
|
|
4683
4973
|
};
|
|
4684
4974
|
|
|
4685
|
-
private
|
|
4686
|
-
|
|
4975
|
+
private clearReorderClick(
|
|
4976
|
+
pointerId: number
|
|
4977
|
+
): ReorderClickPointer | undefined {
|
|
4978
|
+
const pointer = this.reorderClickPointers.get(pointerId);
|
|
4979
|
+
if (pointer?.release)
|
|
4980
|
+
this.document.defaultView?.clearTimeout(pointer.release.timer);
|
|
4981
|
+
this.reorderClickPointers.delete(pointerId);
|
|
4982
|
+
return pointer;
|
|
4983
|
+
}
|
|
4984
|
+
|
|
4985
|
+
private reorderClickTarget(
|
|
4986
|
+
target: EventTarget | null,
|
|
4987
|
+
pressTarget?: Element
|
|
4988
|
+
): Element | undefined {
|
|
4989
|
+
if (!(target instanceof Element) || !this.root.contains(target))
|
|
4990
|
+
return undefined;
|
|
4991
|
+
let clickTarget: Element | null = target;
|
|
4992
|
+
if (pressTarget && this.root.contains(pressTarget)) {
|
|
4993
|
+
// An uncaptured click can target the common ancestor of two controls.
|
|
4994
|
+
while (clickTarget && !clickTarget.contains(pressTarget))
|
|
4995
|
+
clickTarget = clickTarget.parentElement;
|
|
4996
|
+
}
|
|
4997
|
+
return (
|
|
4998
|
+
clickTarget?.closest(
|
|
4999
|
+
'[data-native-list-action],[data-native-list-group-member-key],[data-native-list-row-key]'
|
|
5000
|
+
) ??
|
|
5001
|
+
clickTarget ??
|
|
5002
|
+
undefined
|
|
5003
|
+
);
|
|
5004
|
+
}
|
|
5005
|
+
|
|
5006
|
+
private trackReorderPress = (event: PointerEvent) => {
|
|
5007
|
+
this.clearReorderClick(event.pointerId);
|
|
5008
|
+
if (
|
|
5009
|
+
event.isPrimary === false ||
|
|
5010
|
+
event.button !== 0 ||
|
|
5011
|
+
!(event.target instanceof Element) ||
|
|
5012
|
+
!this.root.contains(event.target)
|
|
5013
|
+
)
|
|
5014
|
+
return;
|
|
5015
|
+
|
|
5016
|
+
this.reorderClickPointers.set(event.pointerId, {
|
|
5017
|
+
suppress: false,
|
|
5018
|
+
pressTarget: event.target,
|
|
5019
|
+
});
|
|
5020
|
+
};
|
|
5021
|
+
|
|
5022
|
+
private trackReorderRelease = (event: PointerEvent) => {
|
|
5023
|
+
if (this.reorderClickPointers.size === 0) return;
|
|
5024
|
+
const {
|
|
5025
|
+
type,
|
|
5026
|
+
pointerId,
|
|
5027
|
+
clientX,
|
|
5028
|
+
clientY,
|
|
5029
|
+
pointerType,
|
|
5030
|
+
isPrimary,
|
|
5031
|
+
button,
|
|
5032
|
+
} = event;
|
|
5033
|
+
const pending = this.clearReorderClick(pointerId);
|
|
5034
|
+
if (!pending || type !== 'pointerup' || isPrimary === false || button !== 0)
|
|
5035
|
+
return;
|
|
5036
|
+
const releaseTarget =
|
|
5037
|
+
event.target === this.viewport &&
|
|
5038
|
+
this.viewport.hasPointerCapture?.(pointerId)
|
|
5039
|
+
? this.document.elementFromPoint?.(clientX, clientY) ?? event.target
|
|
5040
|
+
: event.target;
|
|
5041
|
+
const target = this.reorderClickTarget(releaseTarget, pending.pressTarget);
|
|
5042
|
+
if (!pending.suppress && !target) return;
|
|
5043
|
+
|
|
5044
|
+
// Start expiry at release so a cancelled reorder stays suppressed while held.
|
|
5045
|
+
const view = this.document.defaultView;
|
|
5046
|
+
if (!view) return;
|
|
5047
|
+
const timer = view.setTimeout(
|
|
5048
|
+
() => this.reorderClickPointers.delete(pointerId),
|
|
5049
|
+
REORDER_CLICK_GRACE_MS
|
|
5050
|
+
);
|
|
5051
|
+
this.reorderClickPointers.set(pointerId, {
|
|
5052
|
+
suppress: pending.suppress,
|
|
5053
|
+
release: { target, clientX, clientY, pointerType, timer },
|
|
5054
|
+
});
|
|
5055
|
+
};
|
|
5056
|
+
|
|
5057
|
+
private legacyClickPointerId(event: MouseEvent): number | undefined {
|
|
5058
|
+
// Keyboard and programmatic activations have detail 0.
|
|
5059
|
+
if (!(event.detail > 0)) return undefined;
|
|
5060
|
+
const target = this.reorderClickTarget(event.target);
|
|
5061
|
+
if (!target) return undefined;
|
|
5062
|
+
const fromTouch = (
|
|
5063
|
+
event as MouseEvent & {
|
|
5064
|
+
sourceCapabilities?: { firesTouchEvents: boolean } | null;
|
|
5065
|
+
}
|
|
5066
|
+
).sourceCapabilities?.firesTouchEvents;
|
|
5067
|
+
let match: number | undefined;
|
|
5068
|
+
// A release inserts at the end of the map. Keep the latest matching release.
|
|
5069
|
+
for (const [pointerId, { release }] of this.reorderClickPointers) {
|
|
5070
|
+
if (
|
|
5071
|
+
release?.target === target &&
|
|
5072
|
+
(fromTouch === undefined ||
|
|
5073
|
+
fromTouch === (release.pointerType === 'touch')) &&
|
|
5074
|
+
Math.abs(release.clientX - event.clientX) <= 1 &&
|
|
5075
|
+
Math.abs(release.clientY - event.clientY) <= 1
|
|
5076
|
+
)
|
|
5077
|
+
match = pointerId;
|
|
5078
|
+
}
|
|
5079
|
+
return match;
|
|
5080
|
+
}
|
|
5081
|
+
|
|
5082
|
+
private handleClick = (event: MouseEvent) => {
|
|
5083
|
+
const pointerId =
|
|
5084
|
+
(event as PointerEvent).pointerId ??
|
|
5085
|
+
(this.reorderClickPointers.size > 0
|
|
5086
|
+
? this.legacyClickPointerId(event)
|
|
5087
|
+
: undefined);
|
|
5088
|
+
const clickFromReorder =
|
|
5089
|
+
pointerId !== undefined && this.clearReorderClick(pointerId)?.suppress;
|
|
5090
|
+
if (this.marketLongPressFired || clickFromReorder) {
|
|
4687
5091
|
this.marketLongPressFired = false;
|
|
4688
5092
|
event.preventDefault();
|
|
4689
5093
|
event.stopPropagation();
|
|
@@ -4745,41 +5149,60 @@ export class NativeListWebEngine {
|
|
|
4745
5149
|
};
|
|
4746
5150
|
|
|
4747
5151
|
private handleKeyDown = (event: KeyboardEvent) => {
|
|
5152
|
+
const target = event.target;
|
|
5153
|
+
if (!(target instanceof HTMLElement)) return;
|
|
5154
|
+
if (event.key === 'Escape') {
|
|
5155
|
+
if (this.pointerReorder?.active) {
|
|
5156
|
+
event.preventDefault();
|
|
5157
|
+
this.cancelPointerReorder(true);
|
|
5158
|
+
return;
|
|
5159
|
+
}
|
|
5160
|
+
if (this.keyboardReorder) {
|
|
5161
|
+
event.preventDefault();
|
|
5162
|
+
this.cancelKeyboardReorder();
|
|
5163
|
+
return;
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5166
|
+
const rowElement = target.closest<HTMLElement>(
|
|
5167
|
+
'[data-native-list-row-key]'
|
|
5168
|
+
);
|
|
5169
|
+
if (
|
|
5170
|
+
this.keyboardReorder &&
|
|
5171
|
+
(event.key === 'Tab' ||
|
|
5172
|
+
target.dataset.nativeListRowKey !== this.keyboardReorder.sourceKey)
|
|
5173
|
+
) {
|
|
5174
|
+
const bindingEpoch = rowElement?.dataset.nativeListBindingEpoch;
|
|
5175
|
+
this.cancelKeyboardReorder(false);
|
|
5176
|
+
if (event.key === 'Tab') return;
|
|
5177
|
+
if (
|
|
5178
|
+
!this.root.contains(target) ||
|
|
5179
|
+
rowElement?.dataset.nativeListBindingEpoch !== bindingEpoch
|
|
5180
|
+
) {
|
|
5181
|
+
event.preventDefault();
|
|
5182
|
+
return;
|
|
5183
|
+
}
|
|
5184
|
+
}
|
|
4748
5185
|
if (
|
|
4749
5186
|
(event.key === 'Enter' || event.key === ' ') &&
|
|
4750
|
-
|
|
4751
|
-
event.target.matches('[role="button"][data-native-list-hover-action]')
|
|
5187
|
+
target.matches('[role="button"][data-native-list-hover-action]')
|
|
4752
5188
|
) {
|
|
4753
5189
|
event.preventDefault();
|
|
4754
5190
|
if (
|
|
4755
|
-
this.actionAnchor?.actionElement !==
|
|
5191
|
+
this.actionAnchor?.actionElement !== target ||
|
|
4756
5192
|
!this.actionAnchor.open
|
|
4757
5193
|
)
|
|
4758
|
-
this.emitHoverAction(
|
|
5194
|
+
this.emitHoverAction(target);
|
|
4759
5195
|
return;
|
|
4760
5196
|
}
|
|
4761
5197
|
// OneKey patch: non-button title help supports keyboard activation.
|
|
4762
5198
|
if (
|
|
4763
5199
|
(event.key === 'Enter' || event.key === ' ') &&
|
|
4764
|
-
|
|
4765
|
-
event.target.matches('[role="button"][data-native-list-action]')
|
|
5200
|
+
target.matches('[role="button"][data-native-list-action]')
|
|
4766
5201
|
) {
|
|
4767
5202
|
event.preventDefault();
|
|
4768
|
-
|
|
5203
|
+
target.click();
|
|
4769
5204
|
return;
|
|
4770
5205
|
}
|
|
4771
|
-
if (event.key === 'Escape') {
|
|
4772
|
-
if (this.pointerReorder?.active) {
|
|
4773
|
-
event.preventDefault();
|
|
4774
|
-
this.cancelPointerReorder(true);
|
|
4775
|
-
return;
|
|
4776
|
-
}
|
|
4777
|
-
if (this.keyboardReorder) {
|
|
4778
|
-
event.preventDefault();
|
|
4779
|
-
this.cancelKeyboardReorder();
|
|
4780
|
-
return;
|
|
4781
|
-
}
|
|
4782
|
-
}
|
|
4783
5206
|
if (
|
|
4784
5207
|
this.keyboardReorder &&
|
|
4785
5208
|
(event.key === 'ArrowUp' || event.key === 'ArrowLeft')
|
|
@@ -4797,21 +5220,21 @@ export class NativeListWebEngine {
|
|
|
4797
5220
|
return;
|
|
4798
5221
|
}
|
|
4799
5222
|
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
4800
|
-
const target = event.target;
|
|
4801
|
-
if (!(target instanceof HTMLElement)) return;
|
|
4802
5223
|
if (target.matches('button')) return;
|
|
4803
|
-
const row = this.rowAtElement(
|
|
5224
|
+
const row = this.rowAtElement(rowElement);
|
|
4804
5225
|
if (!row) return;
|
|
4805
5226
|
event.preventDefault();
|
|
4806
|
-
if (
|
|
5227
|
+
if (
|
|
5228
|
+
event.key === ' ' &&
|
|
5229
|
+
target === rowElement &&
|
|
5230
|
+
!this.pointerReorder?.active &&
|
|
5231
|
+
this.canStartKeyboardReorder(target)
|
|
5232
|
+
) {
|
|
4807
5233
|
if (this.keyboardReorder) this.finishKeyboardReorder();
|
|
4808
5234
|
else this.startKeyboardReorder(row);
|
|
4809
5235
|
return;
|
|
4810
5236
|
}
|
|
4811
|
-
this.handleRowPress(
|
|
4812
|
-
row,
|
|
4813
|
-
target.closest<HTMLElement>('[data-native-list-row-key]') ?? undefined
|
|
4814
|
-
);
|
|
5237
|
+
this.handleRowPress(row, rowElement ?? undefined);
|
|
4815
5238
|
};
|
|
4816
5239
|
|
|
4817
5240
|
private startKeyboardReorder(row: RowModel) {
|
|
@@ -4838,19 +5261,13 @@ export class NativeListWebEngine {
|
|
|
4838
5261
|
from.sectionKey !== to.sectionKey
|
|
4839
5262
|
)
|
|
4840
5263
|
return;
|
|
5264
|
+
this.cancelPendingPointerReorder();
|
|
4841
5265
|
const rows = moveWebReorderRow(this.snapshot.rows, fromIndex, toIndex);
|
|
4842
|
-
this.
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
alignment: 'nearest',
|
|
4848
|
-
viewPosition: 0,
|
|
4849
|
-
viewOffset: 0,
|
|
4850
|
-
});
|
|
4851
|
-
[...this.mounted.values()]
|
|
4852
|
-
.find((element) => element.dataset.nativeListRowKey === state.sourceKey)
|
|
4853
|
-
?.focus({ preventScroll: true });
|
|
5266
|
+
this.setReorderRows(rows, toIndex);
|
|
5267
|
+
if (this.keyboardReorder === state) {
|
|
5268
|
+
this.updateReorderVisualState();
|
|
5269
|
+
this.focusMountedRow(state.sourceKey);
|
|
5270
|
+
}
|
|
4854
5271
|
}
|
|
4855
5272
|
|
|
4856
5273
|
private finishKeyboardReorder() {
|
|
@@ -4866,18 +5283,30 @@ export class NativeListWebEngine {
|
|
|
4866
5283
|
if (reorderEvent) this.callbacks.onReorder?.(reorderEvent);
|
|
4867
5284
|
}
|
|
4868
5285
|
|
|
4869
|
-
private cancelKeyboardReorder() {
|
|
5286
|
+
private cancelKeyboardReorder(restoreFocus = true, revealIndex?: number) {
|
|
4870
5287
|
const state = this.keyboardReorder;
|
|
4871
5288
|
if (!state) return;
|
|
4872
5289
|
this.keyboardReorder = undefined;
|
|
4873
|
-
this.
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
this.selectedKeys
|
|
4877
|
-
);
|
|
5290
|
+
this.cancelPendingPointerReorder();
|
|
5291
|
+
const rows = cancelWebReorderRows(state.originalRows);
|
|
5292
|
+
this.setReorderRows(rows, revealIndex);
|
|
4878
5293
|
this.updateReorderVisualState();
|
|
5294
|
+
if (restoreFocus && this.snapshot.rows === rows)
|
|
5295
|
+
this.focusMountedRow(state.sourceKey);
|
|
5296
|
+
}
|
|
5297
|
+
|
|
5298
|
+
private setReorderRows(rows: readonly RowModel[], revealIndex?: number) {
|
|
5299
|
+
this.cancelMarketPointer();
|
|
5300
|
+
this.pressedHelpElement = undefined;
|
|
5301
|
+
this.remapMountedRows(rows);
|
|
5302
|
+
this.snapshot = { ...this.snapshot, rows };
|
|
5303
|
+
this.rows = rows;
|
|
5304
|
+
this.recomputeLayout(revealIndex);
|
|
5305
|
+
}
|
|
5306
|
+
|
|
5307
|
+
private focusMountedRow(key: string) {
|
|
4879
5308
|
[...this.mounted.values()]
|
|
4880
|
-
.find((element) => element.dataset.nativeListRowKey ===
|
|
5309
|
+
.find((element) => element.dataset.nativeListRowKey === key)
|
|
4881
5310
|
?.focus({ preventScroll: true });
|
|
4882
5311
|
}
|
|
4883
5312
|
|
|
@@ -5059,7 +5488,6 @@ export class NativeListWebEngine {
|
|
|
5059
5488
|
private handleReorderPointerDown = (event: PointerEvent) => {
|
|
5060
5489
|
if (
|
|
5061
5490
|
this.pointerReorder ||
|
|
5062
|
-
this.keyboardReorder ||
|
|
5063
5491
|
event.isPrimary === false ||
|
|
5064
5492
|
(event.pointerType === 'mouse' && event.button !== 0)
|
|
5065
5493
|
) {
|
|
@@ -5067,7 +5495,14 @@ export class NativeListWebEngine {
|
|
|
5067
5495
|
}
|
|
5068
5496
|
const target = event.target;
|
|
5069
5497
|
if (!(target instanceof Element)) return;
|
|
5070
|
-
|
|
5498
|
+
const handleMode =
|
|
5499
|
+
this.snapshot.capabilities?.reorderActivation === 'handle';
|
|
5500
|
+
const handle = handleMode
|
|
5501
|
+
? target.closest<HTMLElement>('[data-native-list-reorder-handle]')
|
|
5502
|
+
: undefined;
|
|
5503
|
+
const control = target.closest('button,input,textarea,select,a');
|
|
5504
|
+
if (handleMode && !handle) return;
|
|
5505
|
+
if (control && (control !== handle || control.matches(':disabled'))) return;
|
|
5071
5506
|
const rowElement = target.closest<HTMLElement>(
|
|
5072
5507
|
'[data-native-list-row-index]'
|
|
5073
5508
|
);
|
|
@@ -5091,6 +5526,8 @@ export class NativeListWebEngine {
|
|
|
5091
5526
|
pointerId: event.pointerId,
|
|
5092
5527
|
pointerType: event.pointerType || 'mouse',
|
|
5093
5528
|
sourceKey: row.key,
|
|
5529
|
+
memberKey,
|
|
5530
|
+
handle: handle ?? undefined,
|
|
5094
5531
|
currentIndex: index,
|
|
5095
5532
|
startX: event.clientX,
|
|
5096
5533
|
startY: event.clientY,
|
|
@@ -5110,15 +5547,93 @@ export class NativeListWebEngine {
|
|
|
5110
5547
|
}
|
|
5111
5548
|
};
|
|
5112
5549
|
|
|
5550
|
+
private canStartPointerReorder(
|
|
5551
|
+
state: PointerReorderState,
|
|
5552
|
+
snapshot: NativeListSnapshot
|
|
5553
|
+
): boolean {
|
|
5554
|
+
const row = snapshot.rows.find(
|
|
5555
|
+
(candidate) => candidate.key === state.sourceKey
|
|
5556
|
+
);
|
|
5557
|
+
if (
|
|
5558
|
+
!row ||
|
|
5559
|
+
!isWebRowReorderable(snapshot, row) ||
|
|
5560
|
+
!canStartWebWalletGroupReorder(row, state.memberKey)
|
|
5561
|
+
)
|
|
5562
|
+
return false;
|
|
5563
|
+
if (!state.handle) return true;
|
|
5564
|
+
const handleRow =
|
|
5565
|
+
row.type === 'walletGroup'
|
|
5566
|
+
? [row.parent, ...row.children].find(
|
|
5567
|
+
(member) => member.key === state.memberKey
|
|
5568
|
+
)
|
|
5569
|
+
: row;
|
|
5570
|
+
const slot = Number(state.handle.dataset.nativeListAnchorSlot);
|
|
5571
|
+
return Boolean(
|
|
5572
|
+
handleRow &&
|
|
5573
|
+
'trailing' in handleRow &&
|
|
5574
|
+
handleRow.trailing?.[slot]?.kind === 'drag'
|
|
5575
|
+
);
|
|
5576
|
+
}
|
|
5577
|
+
|
|
5578
|
+
private pointerReorderSourceIndex(state: PointerReorderState): number {
|
|
5579
|
+
const index = this.snapshot.rows.findIndex(
|
|
5580
|
+
(row) => row.key === state.sourceKey
|
|
5581
|
+
);
|
|
5582
|
+
const element = this.mounted.get(index);
|
|
5583
|
+
if (
|
|
5584
|
+
!element ||
|
|
5585
|
+
!this.canStartPointerReorder(state, this.snapshot) ||
|
|
5586
|
+
(state.handle && !element.contains(state.handle))
|
|
5587
|
+
) {
|
|
5588
|
+
return -1;
|
|
5589
|
+
}
|
|
5590
|
+
return index;
|
|
5591
|
+
}
|
|
5592
|
+
|
|
5113
5593
|
private activatePointerReorder(state: PointerReorderState) {
|
|
5114
5594
|
if (this.pointerReorder !== state) return;
|
|
5595
|
+
let sourceIndex = this.pointerReorderSourceIndex(state);
|
|
5596
|
+
const keyboard = this.keyboardReorder;
|
|
5597
|
+
const restoredIndex = keyboard
|
|
5598
|
+
? keyboard.originalRows.findIndex((row) => row.key === state.sourceKey)
|
|
5599
|
+
: sourceIndex;
|
|
5600
|
+
if (sourceIndex < 0 || restoredIndex < 0) {
|
|
5601
|
+
this.cancelPointerReorder(false);
|
|
5602
|
+
return;
|
|
5603
|
+
}
|
|
5115
5604
|
this.clearReorderLongPress(state);
|
|
5116
|
-
state.
|
|
5605
|
+
this.reorderClickPointers.set(state.pointerId, {
|
|
5606
|
+
suppress: true,
|
|
5607
|
+
pressTarget: this.reorderClickPointers.get(state.pointerId)?.pressTarget,
|
|
5608
|
+
});
|
|
5117
5609
|
this.cancelMarketPointer();
|
|
5610
|
+
if (keyboard) {
|
|
5611
|
+
// Capture the pressed row at its visible position before restoring order.
|
|
5612
|
+
state.currentIndex = sourceIndex;
|
|
5613
|
+
state.workingRows = [...this.snapshot.rows];
|
|
5614
|
+
state.restoringKeyboardOrder = true;
|
|
5615
|
+
this.showReorderPreview(state);
|
|
5616
|
+
if (this.pointerReorder !== state) return;
|
|
5617
|
+
this.cancelKeyboardReorder(false, restoredIndex);
|
|
5618
|
+
if (this.pointerReorder !== state) return;
|
|
5619
|
+
sourceIndex = this.pointerReorderSourceIndex(state);
|
|
5620
|
+
if (sourceIndex < 0) {
|
|
5621
|
+
this.cancelPointerReorder(false);
|
|
5622
|
+
return;
|
|
5623
|
+
}
|
|
5624
|
+
state.restoringKeyboardOrder = false;
|
|
5625
|
+
}
|
|
5626
|
+
state.currentIndex = sourceIndex;
|
|
5627
|
+
state.originalRows = this.snapshot.rows;
|
|
5628
|
+
state.workingRows = [...this.snapshot.rows];
|
|
5629
|
+
state.active = true;
|
|
5118
5630
|
state.activatedAt = Date.now();
|
|
5119
5631
|
state.viewportRect = this.reorderViewportRect();
|
|
5120
5632
|
this.captureReorderPointer(state);
|
|
5121
|
-
|
|
5633
|
+
if (!keyboard) {
|
|
5634
|
+
this.showReorderPreview(state);
|
|
5635
|
+
if (this.pointerReorder !== state) return;
|
|
5636
|
+
}
|
|
5122
5637
|
if (
|
|
5123
5638
|
state.workingRows[state.currentIndex]?.type === 'walletGroup' &&
|
|
5124
5639
|
this.reorderCompactKey !== state.sourceKey
|
|
@@ -5127,7 +5642,21 @@ export class NativeListWebEngine {
|
|
|
5127
5642
|
this.mounted.forEach((element) =>
|
|
5128
5643
|
setData(element, 'nativeListAnimateReorder', true)
|
|
5129
5644
|
);
|
|
5130
|
-
this.recomputeLayout();
|
|
5645
|
+
this.recomputeLayout(keyboard ? sourceIndex : undefined);
|
|
5646
|
+
if (this.pointerReorder !== state) return;
|
|
5647
|
+
}
|
|
5648
|
+
if (keyboard) {
|
|
5649
|
+
const item = this.layout.items[sourceIndex];
|
|
5650
|
+
if (item) {
|
|
5651
|
+
state.handoff = {
|
|
5652
|
+
index: sourceIndex,
|
|
5653
|
+
scrollOffset: this.currentOffset(),
|
|
5654
|
+
itemCenter:
|
|
5655
|
+
(itemStart(item, this.layout.horizontal) +
|
|
5656
|
+
itemEnd(item, this.layout.horizontal)) /
|
|
5657
|
+
2,
|
|
5658
|
+
};
|
|
5659
|
+
}
|
|
5131
5660
|
}
|
|
5132
5661
|
this.updateReorderVisualState();
|
|
5133
5662
|
this.scheduleReorderAutoScroll();
|
|
@@ -5214,7 +5743,7 @@ export class NativeListWebEngine {
|
|
|
5214
5743
|
|
|
5215
5744
|
private setCurrentOffset(offset: number) {
|
|
5216
5745
|
if (this.externalScrollHost) {
|
|
5217
|
-
this.scrollToAbsoluteOffset(offset,
|
|
5746
|
+
this.scrollToAbsoluteOffset(offset, 'auto');
|
|
5218
5747
|
return;
|
|
5219
5748
|
}
|
|
5220
5749
|
const maximum = Math.max(0, this.contentLength() - this.viewportLength());
|
|
@@ -5231,6 +5760,7 @@ export class NativeListWebEngine {
|
|
|
5231
5760
|
|
|
5232
5761
|
private showReorderPreview(state: PointerReorderState) {
|
|
5233
5762
|
this.hideReorderPreview();
|
|
5763
|
+
if (this.pointerReorder !== state) return;
|
|
5234
5764
|
const source = [...this.mounted.values()].find(
|
|
5235
5765
|
(element) => element.dataset.nativeListRowKey === state.sourceKey
|
|
5236
5766
|
);
|
|
@@ -5434,7 +5964,7 @@ export class NativeListWebEngine {
|
|
|
5434
5964
|
this.reorderMoveFrame = undefined;
|
|
5435
5965
|
}
|
|
5436
5966
|
|
|
5437
|
-
private
|
|
5967
|
+
private reorderPointerCoordinate(
|
|
5438
5968
|
state: PointerReorderState,
|
|
5439
5969
|
clientX: number,
|
|
5440
5970
|
clientY: number
|
|
@@ -5443,7 +5973,27 @@ export class NativeListWebEngine {
|
|
|
5443
5973
|
const local = this.layout.horizontal
|
|
5444
5974
|
? Math.max(0, Math.min(Math.max(0, rect.width - 1), clientX - rect.left))
|
|
5445
5975
|
: Math.max(0, Math.min(Math.max(0, rect.height - 1), clientY - rect.top));
|
|
5446
|
-
|
|
5976
|
+
return this.currentOffset() + local;
|
|
5977
|
+
}
|
|
5978
|
+
|
|
5979
|
+
private reorderIndexAtPointer(
|
|
5980
|
+
state: PointerReorderState,
|
|
5981
|
+
clientX: number,
|
|
5982
|
+
clientY: number
|
|
5983
|
+
): number {
|
|
5984
|
+
const handoff = state.handoff;
|
|
5985
|
+
let coordinate: number;
|
|
5986
|
+
if (handoff) {
|
|
5987
|
+
const pointerDelta = this.layout.horizontal
|
|
5988
|
+
? clientX - state.startX
|
|
5989
|
+
: clientY - state.startY;
|
|
5990
|
+
const displacement =
|
|
5991
|
+
pointerDelta + (this.currentOffset() - handoff.scrollOffset);
|
|
5992
|
+
if (displacement === 0) return handoff.index;
|
|
5993
|
+
coordinate = handoff.itemCenter + displacement;
|
|
5994
|
+
} else {
|
|
5995
|
+
coordinate = this.reorderPointerCoordinate(state, clientX, clientY);
|
|
5996
|
+
}
|
|
5447
5997
|
const centerAt = (index: number) => {
|
|
5448
5998
|
const item = this.layout.items[index];
|
|
5449
5999
|
return item
|
|
@@ -5478,6 +6028,7 @@ export class NativeListWebEngine {
|
|
|
5478
6028
|
const to = state.workingRows[toIndex];
|
|
5479
6029
|
if (
|
|
5480
6030
|
!from ||
|
|
6031
|
+
from.key !== state.sourceKey ||
|
|
5481
6032
|
!to ||
|
|
5482
6033
|
fromIndex === toIndex ||
|
|
5483
6034
|
!this.isReorderable(from) ||
|
|
@@ -5533,6 +6084,8 @@ export class NativeListWebEngine {
|
|
|
5533
6084
|
if (!state?.active) return 0;
|
|
5534
6085
|
const rect = state.viewportRect ?? this.reorderViewportRect();
|
|
5535
6086
|
const point = this.layout.horizontal ? state.clientX : state.clientY;
|
|
6087
|
+
const pressPoint = this.layout.horizontal ? state.startX : state.startY;
|
|
6088
|
+
if (state.handoff && point === pressPoint) return 0;
|
|
5536
6089
|
const start = this.layout.horizontal ? rect.left : rect.top;
|
|
5537
6090
|
const end = this.layout.horizontal ? rect.right : rect.bottom;
|
|
5538
6091
|
return webReorderAutoScrollVelocity(
|
|
@@ -5584,6 +6137,7 @@ export class NativeListWebEngine {
|
|
|
5584
6137
|
|
|
5585
6138
|
private completePointerReorder(state: PointerReorderState) {
|
|
5586
6139
|
this.flushReorderMove(state);
|
|
6140
|
+
if (this.pointerReorder !== state) return;
|
|
5587
6141
|
const finalRows = this.snapshot.rows;
|
|
5588
6142
|
const reorderEvent = webReorderEventForRows(
|
|
5589
6143
|
state.originalRows,
|
|
@@ -5594,7 +6148,6 @@ export class NativeListWebEngine {
|
|
|
5594
6148
|
this.pointerReorder = undefined;
|
|
5595
6149
|
this.stopReorderMove();
|
|
5596
6150
|
this.stopReorderAutoScroll();
|
|
5597
|
-
this.suppressClickUntil = Date.now() + 300;
|
|
5598
6151
|
this.updateReorderVisualState();
|
|
5599
6152
|
if (reorderEvent) this.callbacks.onReorder?.(reorderEvent);
|
|
5600
6153
|
}
|
|
@@ -5615,22 +6168,23 @@ export class NativeListWebEngine {
|
|
|
5615
6168
|
this.reorderAutoScrollFrame = undefined;
|
|
5616
6169
|
}
|
|
5617
6170
|
|
|
6171
|
+
private cancelPendingPointerReorder() {
|
|
6172
|
+
const pointer = this.pointerReorder;
|
|
6173
|
+
if (pointer && !pointer.active && !pointer.restoringKeyboardOrder)
|
|
6174
|
+
this.cancelPointerReorder(false);
|
|
6175
|
+
}
|
|
6176
|
+
|
|
5618
6177
|
private cancelPointerReorder(restore: boolean) {
|
|
5619
6178
|
const state = this.pointerReorder;
|
|
5620
6179
|
if (!state) return;
|
|
5621
6180
|
this.clearReorderLongPress(state);
|
|
5622
|
-
this.releaseReorderPointer(state);
|
|
5623
6181
|
this.pointerReorder = undefined;
|
|
6182
|
+
if (!state.active && !state.restoringKeyboardOrder) return;
|
|
6183
|
+
this.releaseReorderPointer(state);
|
|
5624
6184
|
this.stopReorderMove();
|
|
5625
6185
|
this.stopReorderAutoScroll();
|
|
5626
|
-
if (state.active && restore)
|
|
5627
|
-
this.
|
|
5628
|
-
this.setSnapshot(
|
|
5629
|
-
{ ...this.snapshot, rows: cancelWebReorderRows(state.originalRows) },
|
|
5630
|
-
this.selectedKeys
|
|
5631
|
-
);
|
|
5632
|
-
this.suppressClickUntil = Date.now() + 300;
|
|
5633
|
-
}
|
|
6186
|
+
if (state.active && restore)
|
|
6187
|
+
this.setReorderRows(cancelWebReorderRows(state.originalRows));
|
|
5634
6188
|
if (state.active && restore) this.animateReorderPreviewToCurrent(state);
|
|
5635
6189
|
else this.hideReorderPreview();
|
|
5636
6190
|
this.updateReorderVisualState();
|
|
@@ -5654,9 +6208,10 @@ export class NativeListWebEngine {
|
|
|
5654
6208
|
}
|
|
5655
6209
|
|
|
5656
6210
|
private updateReorderVisualState() {
|
|
5657
|
-
const
|
|
6211
|
+
const pointerSourceKey = this.pointerReorder?.active
|
|
5658
6212
|
? this.pointerReorder.sourceKey
|
|
5659
|
-
: this.
|
|
6213
|
+
: this.reorderSettlingKey;
|
|
6214
|
+
const sourceKey = this.keyboardReorder?.sourceKey ?? pointerSourceKey;
|
|
5660
6215
|
setData(this.root, 'nativeListDragging', Boolean(sourceKey));
|
|
5661
6216
|
if (this.reorderMovementTimer !== undefined) {
|
|
5662
6217
|
this.document.defaultView?.clearTimeout(this.reorderMovementTimer);
|
|
@@ -5679,7 +6234,11 @@ export class NativeListWebEngine {
|
|
|
5679
6234
|
'nativeListReorderExpanding',
|
|
5680
6235
|
element.dataset.nativeListRowKey === this.reorderExpandingKey
|
|
5681
6236
|
);
|
|
5682
|
-
setData(
|
|
6237
|
+
setData(
|
|
6238
|
+
element,
|
|
6239
|
+
'nativeListDragging',
|
|
6240
|
+
element.dataset.nativeListRowKey === pointerSourceKey
|
|
6241
|
+
);
|
|
5683
6242
|
if (dragging) element.setAttribute('aria-grabbed', 'true');
|
|
5684
6243
|
else element.removeAttribute('aria-grabbed');
|
|
5685
6244
|
});
|