@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.
Files changed (62) hide show
  1. package/android/build.gradle +3 -0
  2. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +18 -4
  3. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +12 -1
  4. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +166 -36
  5. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +3 -2
  6. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +8 -1
  7. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +6 -3
  8. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +21 -4
  9. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
  10. package/android/src/main/java/com/onekey/nativelist/NativeListRowUpdates.kt +34 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
  12. package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentLayout.kt +71 -0
  13. package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentsView.kt +126 -0
  14. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
  15. package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
  16. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentitySubtitleBindingTest.kt +177 -0
  17. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
  18. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListTitleSegmentLayoutTest.kt +130 -0
  19. package/docs/ROW_TEMPLATES.md +8 -1
  20. package/docs/SPEC.md +312 -5
  21. package/docs/STYLE_SPEC.md +7 -1
  22. package/ios/NativeListAccessoryStack.swift +22 -0
  23. package/ios/NativeListActivityDetailsView.swift +45 -1
  24. package/ios/NativeListDataRowRenderer.swift +12 -5
  25. package/ios/NativeListIdentityRenderer.swift +145 -66
  26. package/ios/NativeListLeadingVisual.swift +8 -0
  27. package/ios/NativeListMarketRenderer.swift +6 -2
  28. package/ios/NativeListModels.swift +7 -0
  29. package/ios/NativeListResolvedText.swift +9 -7
  30. package/ios/NativeListSectionHeaderRenderer.swift +9 -43
  31. package/ios/NativeListTextStyles.swift +72 -12
  32. package/ios/NativeListTitleSegmentLayout.swift +72 -0
  33. package/ios/NativeListTitleSegmentsLabel.swift +92 -0
  34. package/ios/RNCNativeListView.swift +203 -45
  35. package/ios/tests/NativeListActivityPresentationTests.swift +137 -0
  36. package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +155 -0
  37. package/ios/tests/NativeListLifecycleTests.swift +298 -24
  38. package/ios/tests/NativeListMediaVisibilityTests.swift +2 -1
  39. package/lib/module/models.js +2 -0
  40. package/lib/module/validation.js +96 -13
  41. package/lib/module/web/NativeListWebEngine.js +427 -100
  42. package/lib/module/web/templates/ActivityRowRenderer.js +1 -1
  43. package/lib/module/web/templates/IdentityRowRenderer.js +134 -3
  44. package/lib/module/web/templates/MarketRowRenderer.js +2 -0
  45. package/lib/module/web/templates/MediaTileRowRenderer.js +1 -0
  46. package/lib/module/web/templates/RowElements.js +2 -2
  47. package/lib/module/web/templates/RowText.js +2 -0
  48. package/lib/typescript/src/models.d.ts +35 -1
  49. package/lib/typescript/src/web/NativeListWebEngine.d.ts +17 -2
  50. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +6 -2
  51. package/lib/typescript/src/web/templates/RowVisual.d.ts +1 -1
  52. package/package.json +1 -1
  53. package/src/models.ts +38 -0
  54. package/src/validation.ts +196 -6
  55. package/src/web/NativeListWebEngine.ts +671 -112
  56. package/src/web/templates/ActivityRowRenderer.ts +1 -1
  57. package/src/web/templates/IdentityRowRenderer.ts +208 -3
  58. package/src/web/templates/MarketRowRenderer.ts +2 -0
  59. package/src/web/templates/MediaTileRowRenderer.ts +1 -0
  60. package/src/web/templates/RowElements.ts +3 -2
  61. package/src/web/templates/RowText.ts +6 -0
  62. package/src/web/templates/RowVisual.ts +2 -1
@@ -37,6 +37,7 @@ export const WEB_REORDER_ANIMATION = {
37
37
  dropTimingFunction: 'ease'
38
38
  };
39
39
  const REORDER_TOUCH_LONG_PRESS_MS = 120;
40
+ const REORDER_CLICK_GRACE_MS = 500;
40
41
  const MARKET_LONG_PRESS_MS = 800;
41
42
  const MARKET_MOVE_CANCEL_PX = 10;
42
43
  const REORDER_MOUSE_MOVE_THRESHOLD_PX = 5;
@@ -135,6 +136,10 @@ export function isWebRowReorderable(snapshot, row) {
135
136
  if (row.type === 'market' && row.webTable?.draggable) return true;
136
137
  return (row.type === 'identity' || row.type === 'action') && Boolean(row.trailing?.some(accessory => accessory.kind === 'drag'));
137
138
  }
139
+ function hasWebReorderHandle(row) {
140
+ if (row.type === 'walletGroup') return [row.parent, ...row.children].some(hasWebReorderHandle);
141
+ return 'trailing' in row && row.trailing?.some(accessory => accessory.kind === 'drag') === true;
142
+ }
138
143
  export function moveWebReorderRow(rows, fromIndex, toIndex) {
139
144
  if (fromIndex === toIndex || fromIndex < 0 || fromIndex >= rows.length || toIndex < 0 || toIndex >= rows.length) {
140
145
  return rows;
@@ -450,8 +455,11 @@ export const WEB_LIST_CSS = `
450
455
  .ok-native-list-wallet-member[data-native-list-selected="true"]>.ok-native-list-wallet-row{background:var(--nl-selected)}
451
456
  .ok-native-list-wallet-member:not([data-native-list-selected="true"]):hover>.ok-native-list-wallet-row{background:var(--nl-strong)}
452
457
  .ok-native-list-wallet-member:not([data-native-list-selected="true"]):active>.ok-native-list-wallet-row{background:var(--nl-pressed)}
458
+ .ok-native-list-item[data-native-list-reorderable="true"]:focus-visible>:is(.ok-native-list-row,.ok-native-list-wallet-group),
453
459
  .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}
454
460
  .ok-native-list-item[data-native-list-reorderable="true"]>.ok-native-list-row{cursor:grab}
461
+ :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}
462
+ .ok-native-list-item[data-native-list-reorderable="true"] [data-native-list-reorder-handle]{cursor:grab}
455
463
  .ok-native-list-root[data-native-list-dragging="true"] .ok-native-list-row{cursor:grabbing}
456
464
  .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}}
457
465
  .ok-native-list-item[data-native-list-dragging="true"]>.ok-native-list-row{overflow:hidden;border-radius:12px;background:var(--nl-pressed)}
@@ -472,8 +480,9 @@ export const WEB_LIST_CSS = `
472
480
  .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}
473
481
  .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}
474
482
  .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}
483
+ .ok-native-list-action-glyph{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center}
475
484
  .ok-native-list-icon-button.ok-native-list-tertiary-icon:focus-visible:not(:disabled){outline:2px solid var(--nl-accent)}
476
- .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}
485
+ .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}
477
486
  .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)}
478
487
  .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)}
479
488
  .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}
@@ -482,7 +491,7 @@ export const WEB_LIST_CSS = `
482
491
  .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}
483
492
  .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)}}
484
493
  .ok-native-list-icon-button.ok-native-list-decorative-refresh{min-width:16px;width:16px;height:16px}
485
- .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}
494
+ .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}
486
495
  .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)}
487
496
  .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}
488
497
  .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)}
@@ -731,7 +740,9 @@ function paintSelectorImageBackground(image, frame, inset = 0) {
731
740
  if (image.complete && image.naturalWidth > 0) update();
732
741
  }
733
742
  function applySelectorIcon(element, name) {
734
- const canonical = selectorIcons[name];
743
+ // Registered names keep their legacy aliases; any other name resolves
744
+ // through the host icon catalog, matching the iOS/Android fallback.
745
+ const canonical = Object.prototype.hasOwnProperty.call(selectorIcons, name) ? selectorIcons[name] : name;
735
746
  if (!canonical) return;
736
747
  if (canonical === 'Circle') {
737
748
  const svg = element.ownerDocument.createElementNS('http://www.w3.org/2000/svg', 'svg');
@@ -748,7 +759,10 @@ function applySelectorIcon(element, name) {
748
759
  element.replaceChildren(svg);
749
760
  return;
750
761
  }
751
- element.replaceChildren(createNamedIcon(element.ownerDocument, canonical));
762
+ const svg = createNamedIcon(element.ownerDocument, canonical);
763
+ // Without host artwork the element keeps its text glyph.
764
+ if (!svg.firstChild) return;
765
+ element.replaceChildren(svg);
752
766
  }
753
767
  function iconGlyph(name) {
754
768
  const normalized = name.toLocaleLowerCase();
@@ -857,6 +871,8 @@ function createVisual(context, visual, selectorPresentation) {
857
871
  if (svg) {
858
872
  svg.style.width = `${fallbackIcon.size}px`;
859
873
  svg.style.height = `${fallbackIcon.size}px`;
874
+ // Keep the requested size inside a bordered frame, as Icon w/h does.
875
+ svg.style.flexShrink = '0';
860
876
  }
861
877
  }
862
878
  }
@@ -871,8 +887,14 @@ function createVisual(context, visual, selectorPresentation) {
871
887
  frame.style.border = '2px dashed ' + (visual.borderColor ?? 'var(--nl-disabled)');
872
888
  frame.style.boxSizing = 'border-box';
873
889
  } else if ('borderColor' in visual && visual.borderColor) {
874
- frame.style.border = '1px solid ' + visual.borderColor;
890
+ frame.style.border = String('borderWidth' in visual && visual.borderWidth ? visual.borderWidth : 1) + 'px solid ' + visual.borderColor;
875
891
  frame.style.boxSizing = 'border-box';
892
+ // iOS and Android inset the image by the border, as React Native's Image does.
893
+ const main = frame.querySelector(':scope > .ok-native-list-visual-main');
894
+ if (main) {
895
+ main.style.width = '100%';
896
+ main.style.height = '100%';
897
+ }
876
898
  }
877
899
  if ('overlays' in visual) visual.overlays?.forEach(overlay => {
878
900
  const corner = createElement(context.document, 'span', 'ok-native-list-visual-overlay', overlay.text);
@@ -982,12 +1004,15 @@ function createCheckbox(context, rowKey, accessory) {
982
1004
  if (accessory.target?.scope === 'section') setData(element, 'selectionKey', accessory.target.sectionKey);else if (accessory.target?.scope === 'row') setData(element, 'selectionKey', rowKey);
983
1005
  return element;
984
1006
  }
985
- function createIconAction(context, name, actionKey, disabled, tintColor) {
1007
+ function createIconAction(context, name, actionKey, disabled, tintColor, accessibilityLabel) {
986
1008
  const element = createElement(context.document, actionKey ? 'button' : 'span', 'ok-native-list-icon-button', iconGlyph(name));
987
1009
  if (element.tagName === 'BUTTON') {
988
1010
  element.setAttribute('type', 'button');
989
1011
  element.toggleAttribute('disabled', Boolean(disabled));
990
- if (name === 'DotVerSolid') element.setAttribute('aria-label', '⋮');
1012
+ element.setAttribute('aria-label', accessibilityLabel || (name === 'DotVerSolid' ? '⋮' : iconGlyph(name)));
1013
+ } else if (accessibilityLabel) {
1014
+ element.setAttribute('aria-label', accessibilityLabel);
1015
+ element.setAttribute('role', 'img');
991
1016
  }
992
1017
  applySelectorIcon(element, name);
993
1018
  if (actionKey) setData(element, 'nativeListAction', actionKey);
@@ -1024,7 +1049,7 @@ function createAccessory(context, rowKey, accessory, slot, rowDisabled) {
1024
1049
  return element;
1025
1050
  }
1026
1051
  if (accessory.kind === 'icon') {
1027
- const element = createIconAction(context, accessory.name, accessory.actionKey, accessory.disabled, accessory.tintColor);
1052
+ const element = createIconAction(context, accessory.name, accessory.actionKey, rowDisabled || accessory.disabled, accessory.tintColor, accessory.accessibilityLabel);
1028
1053
  markActionAnchorSource(element, 'trailingAccessory', slot);
1029
1054
  if (accessory.name === 'RefreshCcwOutline' && !accessory.actionKey) {
1030
1055
  element.classList.add('ok-native-list-decorative-refresh');
@@ -1039,7 +1064,6 @@ function createAccessory(context, rowKey, accessory, slot, rowDisabled) {
1039
1064
  setData(element, 'testid', accessory.testID);
1040
1065
  if (accessory.hoverActionKey) setData(element, 'nativeListHoverAction', accessory.hoverActionKey);
1041
1066
  if (accessory.hoverActionKey && accessory.buttonStyle === 'tertiary') setData(element, 'nativeListIconHelp', true);
1042
- if (accessory.accessibilityLabel) element.setAttribute('aria-label', accessory.accessibilityLabel);
1043
1067
  const row = context.snapshot.rows[context.itemIndex];
1044
1068
  if (row && 'presentation' in row && row.presentation === 'accountSelector') {
1045
1069
  setData(element, 'nativeListAnchorInset', 7);
@@ -1111,6 +1135,23 @@ function createAccessory(context, rowKey, accessory, slot, rowDisabled) {
1111
1135
  break;
1112
1136
  case 'drag':
1113
1137
  element.textContent = '≡';
1138
+ applySelectorIcon(element, 'DragOutline');
1139
+ // iOS and Android tint the handle iconSubdued, like ListItem.IconButton.
1140
+ element.style.color = 'var(--nl-icon-subdued)';
1141
+ // A 24-point centered box, so the glyph does not follow the text line box.
1142
+ Object.assign(element.style, {
1143
+ display: 'inline-flex',
1144
+ alignItems: 'center',
1145
+ justifyContent: 'center',
1146
+ width: '24px',
1147
+ height: '24px'
1148
+ });
1149
+ if (actionKey) {
1150
+ element.toggleAttribute('disabled', rowDisabled);
1151
+ element.setAttribute('aria-label', '≡');
1152
+ }
1153
+ setData(element, 'nativeListReorderHandle', true);
1154
+ setData(element, 'nativeListAnchorSlot', slot);
1114
1155
  break;
1115
1156
  case 'progress':
1116
1157
  element.textContent = String(Math.round(accessory.value * 100)) + '%';
@@ -1127,7 +1168,7 @@ function rendererPrimitives(context, rowDisabled) {
1127
1168
  thumbnail: source => createImage(context, source, 'ok-native-list-thumbnail'),
1128
1169
  textStyle: applyTextStyleToSlot,
1129
1170
  icon: applySelectorIcon,
1130
- iconAction: (name, actionKey, disabled, tintColor) => createIconAction(context, name, actionKey, disabled, tintColor),
1171
+ iconAction: (name, actionKey, disabled, tintColor, accessibilityLabel) => createIconAction(context, name, actionKey, rowDisabled || disabled, tintColor, accessibilityLabel),
1131
1172
  dispose: disposeWebImageRetries
1132
1173
  };
1133
1174
  }
@@ -1168,7 +1209,7 @@ export class NativeListWebEngine {
1168
1209
  avatarOffset = 0;
1169
1210
  avatarDirection = 1;
1170
1211
  sectionIndexEntries = [];
1171
- suppressClickUntil = 0;
1212
+ reorderClickPointers = new Map();
1172
1213
  pullDistance = 0;
1173
1214
  actionAnchorInstanceId = String(++webNativeListInstanceCounter);
1174
1215
  actionAnchorCounter = 0;
@@ -1283,6 +1324,9 @@ export class NativeListWebEngine {
1283
1324
  });
1284
1325
  (this.externalScrollHost ?? this.viewport).addEventListener('ok-collapsible-pager-insets-changed', this.handleCollapsiblePagerInsetsChanged);
1285
1326
  this.root.addEventListener('click', this.handleClick);
1327
+ this.document.addEventListener('pointerdown', this.trackReorderPress, true);
1328
+ this.document.addEventListener('pointerup', this.trackReorderRelease, true);
1329
+ this.document.addEventListener('pointercancel', this.trackReorderRelease, true);
1286
1330
  this.root.addEventListener('contextmenu', this.handleMarketContextMenu);
1287
1331
  this.root.addEventListener('pointerdown', this.handleMarketPointerDown);
1288
1332
  this.root.addEventListener('pointermove', this.handleMarketPointerMove);
@@ -1422,6 +1466,17 @@ export class NativeListWebEngine {
1422
1466
  applyValidatedSnapshot(validated) {
1423
1467
  this.pressedHelpElement = undefined;
1424
1468
  this.invalidateActionAnchor('snapshot');
1469
+ const capabilities = this.snapshot.capabilities;
1470
+ const nextCapabilities = validated.capabilities;
1471
+ if (this.pointerReorder?.active || this.pointerReorder?.restoringKeyboardOrder || this.keyboardReorder || capabilities?.reorderable !== nextCapabilities?.reorderable || (capabilities?.reorderActivation ?? 'row') !== (nextCapabilities?.reorderActivation ?? 'row')) {
1472
+ this.cancelPointerReorder(false);
1473
+ }
1474
+ const keyboardSource = this.keyboardReorder?.sourceKey;
1475
+ const preserveKeyboardFocus = keyboardSource && this.document.activeElement?.getAttribute('data-native-list-row-key') === keyboardSource;
1476
+ if (this.keyboardReorder) {
1477
+ this.keyboardReorder = undefined;
1478
+ this.updateReorderVisualState();
1479
+ }
1425
1480
  const transition = validated.structuralTransition;
1426
1481
  const isNewTransition = transition !== undefined && transition.id !== this.lastStructuralTransitionId;
1427
1482
  if (transition) this.lastStructuralTransitionId = transition.id;
@@ -1433,6 +1488,7 @@ export class NativeListWebEngine {
1433
1488
  if (isNewTransition || changedKeys || incompatibleActivePrefix) this.cancelStructuralAnimation();
1434
1489
  this.setSnapshot(validated);
1435
1490
  }
1491
+ if (preserveKeyboardFocus) this.focusMountedRow(keyboardSource);
1436
1492
  this.hasAppliedSnapshot = true;
1437
1493
  }
1438
1494
  cancelStructuralAnimation() {
@@ -1475,12 +1531,55 @@ export class NativeListWebEngine {
1475
1531
  }
1476
1532
  handleStructuralUserScroll = event => {
1477
1533
  if (event.type === 'pointerdown' && event.target !== (this.externalScrollHost ?? this.viewport) && event.pointerType !== 'touch') return;
1534
+ if (event.type === 'wheel' && this.keyboardReorder && this.wheelReachesScrollOwner(event)) {
1535
+ this.cancelKeyboardReorder(false);
1536
+ }
1478
1537
  this.structuralScrollInterrupted = true;
1479
1538
  if (this.structuralPrefixTransition) {
1480
1539
  this.cancelStructuralAnimation();
1481
1540
  this.recomputeLayout();
1482
1541
  }
1483
1542
  };
1543
+ wheelReachesScrollOwner(event) {
1544
+ if (event.defaultPrevented || event.ctrlKey) return false;
1545
+ const view = this.document.defaultView;
1546
+ if (!view) return true;
1547
+ const horizontal = event.shiftKey || Math.abs(event.deltaX) > Math.abs(event.deltaY);
1548
+ const delta = horizontal ? event.deltaX || event.deltaY : event.deltaY;
1549
+ for (const target of event.composedPath()) {
1550
+ if (target === event.currentTarget) break;
1551
+ if (!(target instanceof view.HTMLElement)) continue;
1552
+ const offset = horizontal ? target.scrollLeft : target.scrollTop;
1553
+ const scrollRange = horizontal ? target.scrollWidth - target.clientWidth : target.scrollHeight - target.clientHeight;
1554
+ if (scrollRange <= 0) continue;
1555
+ const style = view.getComputedStyle(target);
1556
+ const negativeOffset = this.hasNegativeScrollOffsets(style, horizontal);
1557
+ const minOffset = negativeOffset ? -scrollRange : 0;
1558
+ const maxOffset = negativeOffset ? 0 : scrollRange;
1559
+ const overflow = (horizontal ? style.overflowX : style.overflowY) || style.overflow;
1560
+ if (overflow !== 'auto' && overflow !== 'scroll') continue;
1561
+ const overscroll = horizontal ? style.overscrollBehaviorX : style.overscrollBehaviorY;
1562
+ if (overscroll === 'contain' || overscroll === 'none' || (delta < 0 ? offset > minOffset : offset < maxOffset)) {
1563
+ return false;
1564
+ }
1565
+ }
1566
+ return true;
1567
+ }
1568
+ hasNegativeScrollOffsets(style, horizontal) {
1569
+ const {
1570
+ writingMode,
1571
+ direction,
1572
+ display,
1573
+ flexDirection,
1574
+ flexWrap
1575
+ } = style;
1576
+ const horizontalWritingMode = !writingMode || writingMode === 'horizontal-tb';
1577
+ const inlineAxis = horizontal === horizontalWritingMode;
1578
+ const negative = inlineAxis ? direction === 'rtl' !== (writingMode === 'sideways-lr') : horizontal && writingMode.endsWith('-rl');
1579
+ const isFlexMainAxis = inlineAxis !== flexDirection.startsWith('column');
1580
+ const reversedFlex = (display === 'flex' || display === 'inline-flex') && (isFlexMainAxis ? flexDirection.endsWith('-reverse') : flexWrap === 'wrap-reverse');
1581
+ return negative !== reversedFlex;
1582
+ }
1484
1583
  updateStructuralTailWindow() {
1485
1584
  const tail = this.structuralTail;
1486
1585
  if (!tail) return;
@@ -1701,13 +1800,42 @@ export class NativeListWebEngine {
1701
1800
  return this.layout.contentHeight;
1702
1801
  }
1703
1802
  currentSnapshot() {
1704
- return this.snapshot;
1803
+ const originalRows = this.pointerReorder?.active ? this.pointerReorder.originalRows : this.keyboardReorder?.originalRows;
1804
+ return originalRows ? {
1805
+ ...this.snapshot,
1806
+ rows: originalRows
1807
+ } : this.snapshot;
1705
1808
  }
1706
1809
  applyPatches(patches) {
1707
1810
  const accepted = containNativeListInput(() => applyValidatedRowPatches(this.snapshot, patches));
1708
1811
  if (!accepted || accepted.patches.length === 0) return;
1709
1812
  patches = accepted.patches;
1710
- const next = accepted.snapshot;
1813
+ let next = accepted.snapshot;
1814
+ let restoredReorder = false;
1815
+ const pointer = this.pointerReorder?.active ? this.pointerReorder : undefined;
1816
+ const keyboard = this.keyboardReorder;
1817
+ const reorder = pointer ?? keyboard;
1818
+ if (reorder) {
1819
+ const byKey = new Map(next.rows.map(row => [row.key, row]));
1820
+ reorder.originalRows = reorder.originalRows.map(row => byKey.get(row.key) ?? row);
1821
+ const source = byKey.get(reorder.sourceKey);
1822
+ const canContinue = pointer ? this.canStartPointerReorder(pointer, next) : source && isWebRowReorderable(next, source) && (next.capabilities?.reorderActivation !== 'handle' || hasWebReorderHandle(source));
1823
+ if (!canContinue) {
1824
+ this.cancelPointerReorder(false);
1825
+ if (keyboard) {
1826
+ this.keyboardReorder = undefined;
1827
+ this.updateReorderVisualState();
1828
+ }
1829
+ this.remapMountedRows(reorder.originalRows);
1830
+ next = {
1831
+ ...next,
1832
+ rows: reorder.originalRows
1833
+ };
1834
+ restoredReorder = true;
1835
+ } else if (pointer) {
1836
+ pointer.workingRows = [...next.rows];
1837
+ }
1838
+ }
1711
1839
  const selection = new Set(this.selectedKeys);
1712
1840
  patches.forEach(patch => {
1713
1841
  const selected = 'selected' in patch.changes ? patch.changes.selected : undefined;
@@ -1719,7 +1847,7 @@ export class NativeListWebEngine {
1719
1847
  after = next.rows[index];
1720
1848
  return patch.type === 'market' && before?.type === 'market' && after?.type === 'market' && Object.keys(patch.changes).every(key => MARKET_QUOTE_PATCH_FIELDS.has(key) || key === 'webTable') && canPatchMarketTableValues(before, after);
1721
1849
  });
1722
- if (webMarketImageBindDeltaForPatches(patches) === 0 || tableValuesOnly) {
1850
+ if (!restoredReorder && (webMarketImageBindDeltaForPatches(patches) === 0 || tableValuesOnly)) {
1723
1851
  this.snapshot = next;
1724
1852
  this.rows = effectiveRows(next);
1725
1853
  this.selectedKeys = selection;
@@ -1749,7 +1877,7 @@ export class NativeListWebEngine {
1749
1877
  this.updateVisibleSelection();
1750
1878
  this.renderFooter();
1751
1879
  }
1752
- scrollToIndex(index, scroll) {
1880
+ scrollToIndex(index, scroll, behavior = scroll.animated ? 'smooth' : 'auto') {
1753
1881
  if (index < 0 || index >= this.rows.length) {
1754
1882
  this.emitScrollFailure(index, 'index-out-of-range');
1755
1883
  return;
@@ -1759,7 +1887,8 @@ export class NativeListWebEngine {
1759
1887
  this.pendingScroll = {
1760
1888
  kind: 'index',
1761
1889
  index,
1762
- scroll
1890
+ scroll,
1891
+ behavior
1763
1892
  };
1764
1893
  return;
1765
1894
  }
@@ -1768,7 +1897,8 @@ export class NativeListWebEngine {
1768
1897
  this.pendingScroll = {
1769
1898
  kind: 'index',
1770
1899
  index,
1771
- scroll
1900
+ scroll,
1901
+ behavior
1772
1902
  };
1773
1903
  return;
1774
1904
  }
@@ -1785,7 +1915,7 @@ export class NativeListWebEngine {
1785
1915
  viewPosition: scroll.viewPosition,
1786
1916
  viewOffset: scroll.viewOffset
1787
1917
  });
1788
- this.scrollToAbsoluteOffset(offset, scroll.animated);
1918
+ this.scrollToAbsoluteOffset(offset, behavior);
1789
1919
  }
1790
1920
  scrollToKey(key, scroll) {
1791
1921
  const index = this.rows.findIndex(row => row.key === key);
@@ -1804,8 +1934,8 @@ export class NativeListWebEngine {
1804
1934
  }
1805
1935
  if (this.externalScrollHost) {
1806
1936
  const geometry = this.externalGeometry();
1807
- this.writeExternalOffset(geometry.containerOrigin + offset, animated);
1808
- } else this.scrollToAbsoluteOffset(offset, animated);
1937
+ this.writeExternalOffset(geometry.containerOrigin + offset, animated ? 'smooth' : 'auto');
1938
+ } else this.scrollToAbsoluteOffset(offset, animated ? 'smooth' : 'auto');
1809
1939
  }
1810
1940
  scrollToEnd(animated) {
1811
1941
  this.notifyScrollCommandAccepted();
@@ -1818,8 +1948,8 @@ export class NativeListWebEngine {
1818
1948
  }
1819
1949
  if (this.externalScrollHost) {
1820
1950
  const geometry = this.externalGeometry();
1821
- this.writeExternalOffset(geometry.end - this.externalScrollHost.clientHeight, animated);
1822
- } else this.scrollToAbsoluteOffset(Math.max(0, this.contentLength() - this.viewportLength()), animated);
1951
+ this.writeExternalOffset(geometry.end - this.externalScrollHost.clientHeight, animated ? 'smooth' : 'auto');
1952
+ } else this.scrollToAbsoluteOffset(Math.max(0, this.contentLength() - this.viewportLength()), animated ? 'smooth' : 'auto');
1823
1953
  }
1824
1954
  scrollToLocation(params, scroll) {
1825
1955
  const index = resolveLocationIndex(this.snapshot.rows, params);
@@ -1880,6 +2010,10 @@ export class NativeListWebEngine {
1880
2010
  this.viewport.removeEventListener('scroll', this.handleScroll);
1881
2011
  (this.externalScrollHost ?? this.viewport).removeEventListener('ok-collapsible-pager-insets-changed', this.handleCollapsiblePagerInsetsChanged);
1882
2012
  this.root.removeEventListener('click', this.handleClick);
2013
+ this.document.removeEventListener('pointerdown', this.trackReorderPress, true);
2014
+ this.document.removeEventListener('pointerup', this.trackReorderRelease, true);
2015
+ this.document.removeEventListener('pointercancel', this.trackReorderRelease, true);
2016
+ for (const id of this.reorderClickPointers.keys()) this.clearReorderClick(id);
1883
2017
  this.root.removeEventListener('contextmenu', this.handleMarketContextMenu);
1884
2018
  this.cancelMarketPointer();
1885
2019
  this.root.removeEventListener('pointerdown', this.handleMarketPointerDown);
@@ -1930,6 +2064,7 @@ export class NativeListWebEngine {
1930
2064
  this.pressedHelpElement = undefined;
1931
2065
  this.measuredRendererHeights.clear();
1932
2066
  this.snapshot = snapshot;
2067
+ setData(this.root, 'nativeListReorderActivation', snapshot.capabilities?.reorderActivation);
1933
2068
  this.rows = effectiveRows(snapshot);
1934
2069
  this.selectedKeys = selectedKeys ?? selectionStateFromSnapshot(snapshot).selectedKeys;
1935
2070
  if (this.reachedGeneration !== snapshot.generation) this.reachedGeneration = undefined;
@@ -2022,7 +2157,7 @@ export class NativeListWebEngine {
2022
2157
  this.viewportFrame.style.height = value;
2023
2158
  this.root.style.height = value;
2024
2159
  }
2025
- recomputeLayout = () => {
2160
+ recomputeLayout = revealIndex => {
2026
2161
  if (this.destroyed) return;
2027
2162
  if (this.structuralPrefixTransition && this.lastViewportWidth > 0 && this.viewport.clientWidth > 0 && this.viewport.clientWidth !== this.lastViewportWidth) this.cancelStructuralAnimation();
2028
2163
  if (this.structuralRenderedHeight === undefined) this.reactFooterHeight = this.readReactFooterHeight();else {
@@ -2083,7 +2218,17 @@ export class NativeListWebEngine {
2083
2218
  this.viewport.scrollLeft = 0;
2084
2219
  this.viewport.scrollTop = 0;
2085
2220
  }
2086
- this.renderWindow();
2221
+ if (revealIndex !== undefined) {
2222
+ // Mount against the destination offset, even on hosts with smooth scrolling.
2223
+ this.pendingScroll = undefined;
2224
+ this.scrollToIndex(revealIndex, {
2225
+ animated: false,
2226
+ alignment: 'nearest',
2227
+ viewPosition: 0,
2228
+ viewOffset: 0
2229
+ }, 'instant');
2230
+ }
2231
+ this.renderWindow(revealIndex);
2087
2232
  this.performPendingScroll();
2088
2233
  };
2089
2234
  updateAvatarWindow() {
@@ -2127,10 +2272,17 @@ export class NativeListWebEngine {
2127
2272
  }
2128
2273
  });
2129
2274
  }
2130
- renderWindow() {
2275
+ renderWindow(revealIndex) {
2131
2276
  this.updateAvatarWindow();
2132
2277
  const viewportLength = this.viewportLength();
2133
2278
  const visible = this.externalScrollHost && !this.externalGeometry().visible ? [] : webLayoutItemsForMount(this.layout, this.currentOffset(), viewportLength, this.virtualizationEnabled, viewportLength * OVERSCAN_VIEWPORTS);
2279
+ const keyboardSource = this.keyboardReorder?.sourceKey;
2280
+ if (keyboardSource && !visible.some(({
2281
+ key
2282
+ }) => key === keyboardSource)) {
2283
+ this.cancelKeyboardReorder(false);
2284
+ return;
2285
+ }
2134
2286
  const desired = new Set(visible.map(item => item.index));
2135
2287
  this.mounted.forEach((element, index) => {
2136
2288
  const nextRow = this.rows[index];
@@ -2161,6 +2313,8 @@ export class NativeListWebEngine {
2161
2313
  if (element.dataset.nativeListRowKey !== row.key || element.dataset.renderSignature !== signature) {
2162
2314
  this.renderElement(element, layoutItem.index, row);
2163
2315
  element.dataset.renderSignature = signature;
2316
+ } else {
2317
+ this.updateRowReorderability(element, layoutItem.index, row);
2164
2318
  }
2165
2319
  });
2166
2320
  let measuredHeightChanged = false;
@@ -2180,7 +2334,7 @@ export class NativeListWebEngine {
2180
2334
  }
2181
2335
  });
2182
2336
  if (measuredHeightChanged) {
2183
- this.recomputeLayout();
2337
+ this.recomputeLayout(revealIndex);
2184
2338
  return;
2185
2339
  }
2186
2340
  this.updateVisibleSelection();
@@ -2192,6 +2346,18 @@ export class NativeListWebEngine {
2192
2346
  element.style.width = String(item.width) + 'px';
2193
2347
  element.style.height = String(item.height) + 'px';
2194
2348
  }
2349
+ updateRowReorderability(element, index, row) {
2350
+ const reorderable = this.snapshot.rows[index] === row && this.isReorderable(row);
2351
+ setData(element, 'nativeListReorderable', reorderable);
2352
+ if (isRowPressEnabled(row) || this.canStartKeyboardReorder(element)) {
2353
+ if (element.tabIndex !== 0) element.tabIndex = 0;
2354
+ } else {
2355
+ element.removeAttribute('tabindex');
2356
+ }
2357
+ }
2358
+ canStartKeyboardReorder(element) {
2359
+ return element.dataset.nativeListReorderable === 'true' && (this.snapshot.capabilities?.reorderActivation !== 'handle' || element.querySelector('[data-native-list-reorder-handle]') !== null);
2360
+ }
2195
2361
  renderElement(element, index, row, overlay = false) {
2196
2362
  this.invalidateActionAnchorForElement(element);
2197
2363
  const registered = rowRenderer(row);
@@ -2209,18 +2375,12 @@ export class NativeListWebEngine {
2209
2375
  setData(element, 'testid', row.testID);
2210
2376
  // OneKey patch: deprecation dims a row without disabling its actions.
2211
2377
  element.style.opacity = String((row.style?.container?.opacity ?? row.opacity ?? 1) * (row.disabled ? 0.5 : 1));
2212
- setData(element, 'nativeListReorderable', this.isReorderable(row));
2213
2378
  setData(element, 'nativeListDragging', this.pointerReorder?.active && this.pointerReorder.sourceKey === row.key);
2214
2379
  setData(element, 'separator', row.separator);
2215
2380
  setData(element, 'groupPosition', row.groupPosition);
2216
2381
  setData(element, 'tableAlternate', this.snapshot.layout.kind === 'table' && row.type === 'dataRow' && (row.index ?? index) % 2 === 0);
2217
2382
  element.setAttribute('role', 'listitem');
2218
2383
  element.setAttribute('aria-label', row.accessibilityLabel ?? this.rowLabel(row));
2219
- if (isRowPressEnabled(row)) {
2220
- element.tabIndex = 0;
2221
- } else {
2222
- element.removeAttribute('tabindex');
2223
- }
2224
2384
  element.draggable = false;
2225
2385
  const context = {
2226
2386
  document: this.document,
@@ -2246,6 +2406,7 @@ export class NativeListWebEngine {
2246
2406
  // Template and presentation defaults must precede caller overrides.
2247
2407
  applyRowStyle(body, row);
2248
2408
  if (body.parentElement !== element) element.replaceChildren(body);
2409
+ this.updateRowReorderability(element, overlay ? -1 : index, row);
2249
2410
  if (row.type === 'market' && row.diagnostics?.imageBindActionKey && body.querySelector('img')) {
2250
2411
  this.callbacks.onRowAction?.({
2251
2412
  rowKey: row.key,
@@ -2608,20 +2769,20 @@ export class NativeListWebEngine {
2608
2769
  handleCollapsiblePagerInsetsChanged = () => {
2609
2770
  this.recomputeLayout();
2610
2771
  };
2611
- writeExternalOffset(rawOffset, animated) {
2772
+ writeExternalOffset(rawOffset, behavior) {
2612
2773
  this.externalGeometryCache = undefined;
2613
2774
  const host = this.externalScrollHost;
2614
2775
  const scrollTo = host.ownerDocument.defaultView?.Element.prototype.scrollTo ?? host.scrollTo;
2615
2776
  scrollTo.call(host, {
2616
2777
  top: Math.max(0, Math.min(host.scrollHeight - host.clientHeight, rawOffset)),
2617
- behavior: animated ? 'smooth' : 'auto'
2778
+ behavior
2618
2779
  });
2619
2780
  this.scheduleFrame();
2620
2781
  }
2621
- scrollToAbsoluteOffset(offset, animated) {
2782
+ scrollToAbsoluteOffset(offset, behavior) {
2622
2783
  if (this.externalScrollHost) {
2623
2784
  const geometry = this.externalGeometry();
2624
- this.writeExternalOffset(geometry.origin + offset - this.externalStickyInset, animated);
2785
+ this.writeExternalOffset(geometry.origin + offset - this.externalStickyInset, behavior);
2625
2786
  return;
2626
2787
  }
2627
2788
  const resolved = Math.min(Math.max(0, offset), Math.max(0, this.contentLength() - this.viewportLength()));
@@ -2629,11 +2790,11 @@ export class NativeListWebEngine {
2629
2790
  this.viewport.scrollTo(this.layout.horizontal ? {
2630
2791
  left: rawOffset,
2631
2792
  top: 0,
2632
- behavior: animated ? 'smooth' : 'auto'
2793
+ behavior
2633
2794
  } : {
2634
2795
  left: 0,
2635
2796
  top: rawOffset,
2636
- behavior: animated ? 'smooth' : 'auto'
2797
+ behavior
2637
2798
  });
2638
2799
  this.scheduleFrame();
2639
2800
  }
@@ -2641,7 +2802,7 @@ export class NativeListWebEngine {
2641
2802
  const pending = this.pendingScroll;
2642
2803
  if (!pending || !this.canScroll()) return;
2643
2804
  this.pendingScroll = undefined;
2644
- if (pending.kind === 'index') this.scrollToIndex(pending.index, pending.scroll);else if (pending.kind === 'offset') this.scrollToOffset(pending.offset, pending.animated);else this.scrollToEnd(pending.animated);
2805
+ if (pending.kind === 'index') this.scrollToIndex(pending.index, pending.scroll, pending.behavior);else if (pending.kind === 'offset') this.scrollToOffset(pending.offset, pending.animated);else this.scrollToEnd(pending.animated);
2645
2806
  }
2646
2807
  rowAtElement(element) {
2647
2808
  if (!element) return undefined;
@@ -2689,7 +2850,8 @@ export class NativeListWebEngine {
2689
2850
  const bindingEpoch = rowElement.dataset.nativeListBindingEpoch;
2690
2851
  if (!source || !bindingEpoch || !rowElement.contains(actionElement)) return undefined;
2691
2852
  this.invalidateActionAnchor('rebind');
2692
- const actualRect = actionElement.getBoundingClientRect();
2853
+ const glyph = actionElement.querySelector(':scope > [data-native-list-anchor-glyph]');
2854
+ const actualRect = (glyph ?? actionElement).getBoundingClientRect();
2693
2855
  const inset = Number(actionElement.dataset.nativeListAnchorInset ?? 0);
2694
2856
  const rect = {
2695
2857
  left: actualRect.left + inset,
@@ -2882,8 +3044,80 @@ export class NativeListWebEngine {
2882
3044
  if (event.type === 'pointerout' && this.pressedHelpElement === action) this.pressedHelpElement = undefined;
2883
3045
  if (this.actionAnchor?.actionElement === action) this.invalidateActionAnchor('pointerLeave');
2884
3046
  };
3047
+ clearReorderClick(pointerId) {
3048
+ const pointer = this.reorderClickPointers.get(pointerId);
3049
+ if (pointer?.release) this.document.defaultView?.clearTimeout(pointer.release.timer);
3050
+ this.reorderClickPointers.delete(pointerId);
3051
+ return pointer;
3052
+ }
3053
+ reorderClickTarget(target, pressTarget) {
3054
+ if (!(target instanceof Element) || !this.root.contains(target)) return undefined;
3055
+ let clickTarget = target;
3056
+ if (pressTarget && this.root.contains(pressTarget)) {
3057
+ // An uncaptured click can target the common ancestor of two controls.
3058
+ while (clickTarget && !clickTarget.contains(pressTarget)) clickTarget = clickTarget.parentElement;
3059
+ }
3060
+ return clickTarget?.closest('[data-native-list-action],[data-native-list-group-member-key],[data-native-list-row-key]') ?? clickTarget ?? undefined;
3061
+ }
3062
+ trackReorderPress = event => {
3063
+ this.clearReorderClick(event.pointerId);
3064
+ if (event.isPrimary === false || event.button !== 0 || !(event.target instanceof Element) || !this.root.contains(event.target)) return;
3065
+ this.reorderClickPointers.set(event.pointerId, {
3066
+ suppress: false,
3067
+ pressTarget: event.target
3068
+ });
3069
+ };
3070
+ trackReorderRelease = event => {
3071
+ if (this.reorderClickPointers.size === 0) return;
3072
+ const {
3073
+ type,
3074
+ pointerId,
3075
+ clientX,
3076
+ clientY,
3077
+ pointerType,
3078
+ isPrimary,
3079
+ button
3080
+ } = event;
3081
+ const pending = this.clearReorderClick(pointerId);
3082
+ if (!pending || type !== 'pointerup' || isPrimary === false || button !== 0) return;
3083
+ const releaseTarget = event.target === this.viewport && this.viewport.hasPointerCapture?.(pointerId) ? this.document.elementFromPoint?.(clientX, clientY) ?? event.target : event.target;
3084
+ const target = this.reorderClickTarget(releaseTarget, pending.pressTarget);
3085
+ if (!pending.suppress && !target) return;
3086
+
3087
+ // Start expiry at release so a cancelled reorder stays suppressed while held.
3088
+ const view = this.document.defaultView;
3089
+ if (!view) return;
3090
+ const timer = view.setTimeout(() => this.reorderClickPointers.delete(pointerId), REORDER_CLICK_GRACE_MS);
3091
+ this.reorderClickPointers.set(pointerId, {
3092
+ suppress: pending.suppress,
3093
+ release: {
3094
+ target,
3095
+ clientX,
3096
+ clientY,
3097
+ pointerType,
3098
+ timer
3099
+ }
3100
+ });
3101
+ };
3102
+ legacyClickPointerId(event) {
3103
+ // Keyboard and programmatic activations have detail 0.
3104
+ if (!(event.detail > 0)) return undefined;
3105
+ const target = this.reorderClickTarget(event.target);
3106
+ if (!target) return undefined;
3107
+ const fromTouch = event.sourceCapabilities?.firesTouchEvents;
3108
+ let match;
3109
+ // A release inserts at the end of the map. Keep the latest matching release.
3110
+ for (const [pointerId, {
3111
+ release
3112
+ }] of this.reorderClickPointers) {
3113
+ if (release?.target === target && (fromTouch === undefined || fromTouch === (release.pointerType === 'touch')) && Math.abs(release.clientX - event.clientX) <= 1 && Math.abs(release.clientY - event.clientY) <= 1) match = pointerId;
3114
+ }
3115
+ return match;
3116
+ }
2885
3117
  handleClick = event => {
2886
- if (this.marketLongPressFired || Date.now() < this.suppressClickUntil) {
3118
+ const pointerId = event.pointerId ?? (this.reorderClickPointers.size > 0 ? this.legacyClickPointerId(event) : undefined);
3119
+ const clickFromReorder = pointerId !== undefined && this.clearReorderClick(pointerId)?.suppress;
3120
+ if (this.marketLongPressFired || clickFromReorder) {
2887
3121
  this.marketLongPressFired = false;
2888
3122
  event.preventDefault();
2889
3123
  event.stopPropagation();
@@ -2923,17 +3157,8 @@ export class NativeListWebEngine {
2923
3157
  this.handleRowPress(sourceRow, rowElement ?? undefined, memberElement ?? rowElement ?? undefined);
2924
3158
  };
2925
3159
  handleKeyDown = event => {
2926
- if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && event.target.matches('[role="button"][data-native-list-hover-action]')) {
2927
- event.preventDefault();
2928
- if (this.actionAnchor?.actionElement !== event.target || !this.actionAnchor.open) this.emitHoverAction(event.target);
2929
- return;
2930
- }
2931
- // OneKey patch: non-button title help supports keyboard activation.
2932
- if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && event.target.matches('[role="button"][data-native-list-action]')) {
2933
- event.preventDefault();
2934
- event.target.click();
2935
- return;
2936
- }
3160
+ const target = event.target;
3161
+ if (!(target instanceof HTMLElement)) return;
2937
3162
  if (event.key === 'Escape') {
2938
3163
  if (this.pointerReorder?.active) {
2939
3164
  event.preventDefault();
@@ -2946,6 +3171,27 @@ export class NativeListWebEngine {
2946
3171
  return;
2947
3172
  }
2948
3173
  }
3174
+ const rowElement = target.closest('[data-native-list-row-key]');
3175
+ if (this.keyboardReorder && (event.key === 'Tab' || target.dataset.nativeListRowKey !== this.keyboardReorder.sourceKey)) {
3176
+ const bindingEpoch = rowElement?.dataset.nativeListBindingEpoch;
3177
+ this.cancelKeyboardReorder(false);
3178
+ if (event.key === 'Tab') return;
3179
+ if (!this.root.contains(target) || rowElement?.dataset.nativeListBindingEpoch !== bindingEpoch) {
3180
+ event.preventDefault();
3181
+ return;
3182
+ }
3183
+ }
3184
+ if ((event.key === 'Enter' || event.key === ' ') && target.matches('[role="button"][data-native-list-hover-action]')) {
3185
+ event.preventDefault();
3186
+ if (this.actionAnchor?.actionElement !== target || !this.actionAnchor.open) this.emitHoverAction(target);
3187
+ return;
3188
+ }
3189
+ // OneKey patch: non-button title help supports keyboard activation.
3190
+ if ((event.key === 'Enter' || event.key === ' ') && target.matches('[role="button"][data-native-list-action]')) {
3191
+ event.preventDefault();
3192
+ target.click();
3193
+ return;
3194
+ }
2949
3195
  if (this.keyboardReorder && (event.key === 'ArrowUp' || event.key === 'ArrowLeft')) {
2950
3196
  event.preventDefault();
2951
3197
  this.moveKeyboardReorder(-1);
@@ -2957,17 +3203,15 @@ export class NativeListWebEngine {
2957
3203
  return;
2958
3204
  }
2959
3205
  if (event.key !== 'Enter' && event.key !== ' ') return;
2960
- const target = event.target;
2961
- if (!(target instanceof HTMLElement)) return;
2962
3206
  if (target.matches('button')) return;
2963
- const row = this.rowAtElement(target.closest('[data-native-list-row-key]'));
3207
+ const row = this.rowAtElement(rowElement);
2964
3208
  if (!row) return;
2965
3209
  event.preventDefault();
2966
- if (event.key === ' ' && this.isReorderable(row)) {
3210
+ if (event.key === ' ' && target === rowElement && !this.pointerReorder?.active && this.canStartKeyboardReorder(target)) {
2967
3211
  if (this.keyboardReorder) this.finishKeyboardReorder();else this.startKeyboardReorder(row);
2968
3212
  return;
2969
3213
  }
2970
- this.handleRowPress(row, target.closest('[data-native-list-row-key]') ?? undefined);
3214
+ this.handleRowPress(row, rowElement ?? undefined);
2971
3215
  };
2972
3216
  startKeyboardReorder(row) {
2973
3217
  this.keyboardReorder = {
@@ -2984,22 +3228,13 @@ export class NativeListWebEngine {
2984
3228
  const from = this.snapshot.rows[fromIndex];
2985
3229
  const to = this.snapshot.rows[toIndex];
2986
3230
  if (!from || !to || !this.isReorderable(to) || from.sectionKey !== to.sectionKey) return;
3231
+ this.cancelPendingPointerReorder();
2987
3232
  const rows = moveWebReorderRow(this.snapshot.rows, fromIndex, toIndex);
2988
- this.remapMountedRows(rows);
2989
- this.setSnapshot({
2990
- ...this.snapshot,
2991
- rows
2992
- }, this.selectedKeys);
2993
- this.updateReorderVisualState();
2994
- this.scrollToIndex(toIndex, {
2995
- animated: false,
2996
- alignment: 'nearest',
2997
- viewPosition: 0,
2998
- viewOffset: 0
2999
- });
3000
- [...this.mounted.values()].find(element => element.dataset.nativeListRowKey === state.sourceKey)?.focus({
3001
- preventScroll: true
3002
- });
3233
+ this.setReorderRows(rows, toIndex);
3234
+ if (this.keyboardReorder === state) {
3235
+ this.updateReorderVisualState();
3236
+ this.focusMountedRow(state.sourceKey);
3237
+ }
3003
3238
  }
3004
3239
  finishKeyboardReorder() {
3005
3240
  const state = this.keyboardReorder;
@@ -3009,17 +3244,29 @@ export class NativeListWebEngine {
3009
3244
  this.updateReorderVisualState();
3010
3245
  if (reorderEvent) this.callbacks.onReorder?.(reorderEvent);
3011
3246
  }
3012
- cancelKeyboardReorder() {
3247
+ cancelKeyboardReorder(restoreFocus = true, revealIndex) {
3013
3248
  const state = this.keyboardReorder;
3014
3249
  if (!state) return;
3015
3250
  this.keyboardReorder = undefined;
3016
- this.remapMountedRows(state.originalRows);
3017
- this.setSnapshot({
3018
- ...this.snapshot,
3019
- rows: cancelWebReorderRows(state.originalRows)
3020
- }, this.selectedKeys);
3251
+ this.cancelPendingPointerReorder();
3252
+ const rows = cancelWebReorderRows(state.originalRows);
3253
+ this.setReorderRows(rows, revealIndex);
3021
3254
  this.updateReorderVisualState();
3022
- [...this.mounted.values()].find(element => element.dataset.nativeListRowKey === state.sourceKey)?.focus({
3255
+ if (restoreFocus && this.snapshot.rows === rows) this.focusMountedRow(state.sourceKey);
3256
+ }
3257
+ setReorderRows(rows, revealIndex) {
3258
+ this.cancelMarketPointer();
3259
+ this.pressedHelpElement = undefined;
3260
+ this.remapMountedRows(rows);
3261
+ this.snapshot = {
3262
+ ...this.snapshot,
3263
+ rows
3264
+ };
3265
+ this.rows = rows;
3266
+ this.recomputeLayout(revealIndex);
3267
+ }
3268
+ focusMountedRow(key) {
3269
+ [...this.mounted.values()].find(element => element.dataset.nativeListRowKey === key)?.focus({
3023
3270
  preventScroll: true
3024
3271
  });
3025
3272
  }
@@ -3139,12 +3386,16 @@ export class NativeListWebEngine {
3139
3386
  setData(this.refreshIndicator, 'visible', refreshing);
3140
3387
  }
3141
3388
  handleReorderPointerDown = event => {
3142
- if (this.pointerReorder || this.keyboardReorder || event.isPrimary === false || event.pointerType === 'mouse' && event.button !== 0) {
3389
+ if (this.pointerReorder || event.isPrimary === false || event.pointerType === 'mouse' && event.button !== 0) {
3143
3390
  return;
3144
3391
  }
3145
3392
  const target = event.target;
3146
3393
  if (!(target instanceof Element)) return;
3147
- if (target.closest('button,input,textarea,select,a')) return;
3394
+ const handleMode = this.snapshot.capabilities?.reorderActivation === 'handle';
3395
+ const handle = handleMode ? target.closest('[data-native-list-reorder-handle]') : undefined;
3396
+ const control = target.closest('button,input,textarea,select,a');
3397
+ if (handleMode && !handle) return;
3398
+ if (control && (control !== handle || control.matches(':disabled'))) return;
3148
3399
  const rowElement = target.closest('[data-native-list-row-index]');
3149
3400
  const index = Number(rowElement?.dataset.nativeListRowIndex);
3150
3401
  const row = this.rows[index];
@@ -3164,6 +3415,8 @@ export class NativeListWebEngine {
3164
3415
  pointerId: event.pointerId,
3165
3416
  pointerType: event.pointerType || 'mouse',
3166
3417
  sourceKey: row.key,
3418
+ memberKey,
3419
+ handle: handle ?? undefined,
3167
3420
  currentIndex: index,
3168
3421
  startX: event.clientX,
3169
3422
  startY: event.clientY,
@@ -3179,19 +3432,79 @@ export class NativeListWebEngine {
3179
3432
  state.longPressTimer = view?.setTimeout(() => this.activatePointerReorder(state), REORDER_TOUCH_LONG_PRESS_MS);
3180
3433
  }
3181
3434
  };
3435
+ canStartPointerReorder(state, snapshot) {
3436
+ const row = snapshot.rows.find(candidate => candidate.key === state.sourceKey);
3437
+ if (!row || !isWebRowReorderable(snapshot, row) || !canStartWebWalletGroupReorder(row, state.memberKey)) return false;
3438
+ if (!state.handle) return true;
3439
+ const handleRow = row.type === 'walletGroup' ? [row.parent, ...row.children].find(member => member.key === state.memberKey) : row;
3440
+ const slot = Number(state.handle.dataset.nativeListAnchorSlot);
3441
+ return Boolean(handleRow && 'trailing' in handleRow && handleRow.trailing?.[slot]?.kind === 'drag');
3442
+ }
3443
+ pointerReorderSourceIndex(state) {
3444
+ const index = this.snapshot.rows.findIndex(row => row.key === state.sourceKey);
3445
+ const element = this.mounted.get(index);
3446
+ if (!element || !this.canStartPointerReorder(state, this.snapshot) || state.handle && !element.contains(state.handle)) {
3447
+ return -1;
3448
+ }
3449
+ return index;
3450
+ }
3182
3451
  activatePointerReorder(state) {
3183
3452
  if (this.pointerReorder !== state) return;
3453
+ let sourceIndex = this.pointerReorderSourceIndex(state);
3454
+ const keyboard = this.keyboardReorder;
3455
+ const restoredIndex = keyboard ? keyboard.originalRows.findIndex(row => row.key === state.sourceKey) : sourceIndex;
3456
+ if (sourceIndex < 0 || restoredIndex < 0) {
3457
+ this.cancelPointerReorder(false);
3458
+ return;
3459
+ }
3184
3460
  this.clearReorderLongPress(state);
3185
- state.active = true;
3461
+ this.reorderClickPointers.set(state.pointerId, {
3462
+ suppress: true,
3463
+ pressTarget: this.reorderClickPointers.get(state.pointerId)?.pressTarget
3464
+ });
3186
3465
  this.cancelMarketPointer();
3466
+ if (keyboard) {
3467
+ // Capture the pressed row at its visible position before restoring order.
3468
+ state.currentIndex = sourceIndex;
3469
+ state.workingRows = [...this.snapshot.rows];
3470
+ state.restoringKeyboardOrder = true;
3471
+ this.showReorderPreview(state);
3472
+ if (this.pointerReorder !== state) return;
3473
+ this.cancelKeyboardReorder(false, restoredIndex);
3474
+ if (this.pointerReorder !== state) return;
3475
+ sourceIndex = this.pointerReorderSourceIndex(state);
3476
+ if (sourceIndex < 0) {
3477
+ this.cancelPointerReorder(false);
3478
+ return;
3479
+ }
3480
+ state.restoringKeyboardOrder = false;
3481
+ }
3482
+ state.currentIndex = sourceIndex;
3483
+ state.originalRows = this.snapshot.rows;
3484
+ state.workingRows = [...this.snapshot.rows];
3485
+ state.active = true;
3187
3486
  state.activatedAt = Date.now();
3188
3487
  state.viewportRect = this.reorderViewportRect();
3189
3488
  this.captureReorderPointer(state);
3190
- this.showReorderPreview(state);
3489
+ if (!keyboard) {
3490
+ this.showReorderPreview(state);
3491
+ if (this.pointerReorder !== state) return;
3492
+ }
3191
3493
  if (state.workingRows[state.currentIndex]?.type === 'walletGroup' && this.reorderCompactKey !== state.sourceKey) {
3192
3494
  this.reorderCompactKey = state.sourceKey;
3193
3495
  this.mounted.forEach(element => setData(element, 'nativeListAnimateReorder', true));
3194
- this.recomputeLayout();
3496
+ this.recomputeLayout(keyboard ? sourceIndex : undefined);
3497
+ if (this.pointerReorder !== state) return;
3498
+ }
3499
+ if (keyboard) {
3500
+ const item = this.layout.items[sourceIndex];
3501
+ if (item) {
3502
+ state.handoff = {
3503
+ index: sourceIndex,
3504
+ scrollOffset: this.currentOffset(),
3505
+ itemCenter: (itemStart(item, this.layout.horizontal) + itemEnd(item, this.layout.horizontal)) / 2
3506
+ };
3507
+ }
3195
3508
  }
3196
3509
  this.updateReorderVisualState();
3197
3510
  this.scheduleReorderAutoScroll();
@@ -3261,7 +3574,7 @@ export class NativeListWebEngine {
3261
3574
  };
3262
3575
  setCurrentOffset(offset) {
3263
3576
  if (this.externalScrollHost) {
3264
- this.scrollToAbsoluteOffset(offset, false);
3577
+ this.scrollToAbsoluteOffset(offset, 'auto');
3265
3578
  return;
3266
3579
  }
3267
3580
  const maximum = Math.max(0, this.contentLength() - this.viewportLength());
@@ -3273,6 +3586,7 @@ export class NativeListWebEngine {
3273
3586
  }
3274
3587
  showReorderPreview(state) {
3275
3588
  this.hideReorderPreview();
3589
+ if (this.pointerReorder !== state) return;
3276
3590
  const source = [...this.mounted.values()].find(element => element.dataset.nativeListRowKey === state.sourceKey);
3277
3591
  const row = source?.firstElementChild;
3278
3592
  if (!source || !row) return;
@@ -3425,10 +3739,22 @@ export class NativeListWebEngine {
3425
3739
  this.cancelFrame(this.reorderMoveFrame);
3426
3740
  this.reorderMoveFrame = undefined;
3427
3741
  }
3428
- reorderIndexAtPointer(state, clientX, clientY) {
3742
+ reorderPointerCoordinate(state, clientX, clientY) {
3429
3743
  const rect = state.viewportRect ?? this.reorderViewportRect();
3430
3744
  const local = this.layout.horizontal ? Math.max(0, Math.min(Math.max(0, rect.width - 1), clientX - rect.left)) : Math.max(0, Math.min(Math.max(0, rect.height - 1), clientY - rect.top));
3431
- const coordinate = this.currentOffset() + local;
3745
+ return this.currentOffset() + local;
3746
+ }
3747
+ reorderIndexAtPointer(state, clientX, clientY) {
3748
+ const handoff = state.handoff;
3749
+ let coordinate;
3750
+ if (handoff) {
3751
+ const pointerDelta = this.layout.horizontal ? clientX - state.startX : clientY - state.startY;
3752
+ const displacement = pointerDelta + (this.currentOffset() - handoff.scrollOffset);
3753
+ if (displacement === 0) return handoff.index;
3754
+ coordinate = handoff.itemCenter + displacement;
3755
+ } else {
3756
+ coordinate = this.reorderPointerCoordinate(state, clientX, clientY);
3757
+ }
3432
3758
  const centerAt = index => {
3433
3759
  const item = this.layout.items[index];
3434
3760
  return item ? (itemStart(item, this.layout.horizontal) + itemEnd(item, this.layout.horizontal)) / 2 : Number.POSITIVE_INFINITY;
@@ -3451,7 +3777,7 @@ export class NativeListWebEngine {
3451
3777
  const toIndex = this.reorderIndexAtPointer(state, clientX, clientY);
3452
3778
  const from = state.workingRows[fromIndex];
3453
3779
  const to = state.workingRows[toIndex];
3454
- if (!from || !to || fromIndex === toIndex || !this.isReorderable(from) || !this.isReorderable(to) || from.sectionKey !== to.sectionKey) return;
3780
+ if (!from || from.key !== state.sourceKey || !to || fromIndex === toIndex || !this.isReorderable(from) || !this.isReorderable(to) || from.sectionKey !== to.sectionKey) return;
3455
3781
  const [moved] = state.workingRows.splice(fromIndex, 1);
3456
3782
  if (!moved) return;
3457
3783
  state.workingRows.splice(toIndex, 0, moved);
@@ -3494,6 +3820,8 @@ export class NativeListWebEngine {
3494
3820
  if (!state?.active) return 0;
3495
3821
  const rect = state.viewportRect ?? this.reorderViewportRect();
3496
3822
  const point = this.layout.horizontal ? state.clientX : state.clientY;
3823
+ const pressPoint = this.layout.horizontal ? state.startX : state.startY;
3824
+ if (state.handoff && point === pressPoint) return 0;
3497
3825
  const start = this.layout.horizontal ? rect.left : rect.top;
3498
3826
  const end = this.layout.horizontal ? rect.right : rect.bottom;
3499
3827
  return webReorderAutoScrollVelocity(point, start, end, Date.now() - (state.activatedAt ?? 0));
@@ -3531,13 +3859,13 @@ export class NativeListWebEngine {
3531
3859
  };
3532
3860
  completePointerReorder(state) {
3533
3861
  this.flushReorderMove(state);
3862
+ if (this.pointerReorder !== state) return;
3534
3863
  const finalRows = this.snapshot.rows;
3535
3864
  const reorderEvent = webReorderEventForRows(state.originalRows, finalRows, state.sourceKey);
3536
3865
  this.animateReorderPreviewToCurrent(state);
3537
3866
  this.pointerReorder = undefined;
3538
3867
  this.stopReorderMove();
3539
3868
  this.stopReorderAutoScroll();
3540
- this.suppressClickUntil = Date.now() + 300;
3541
3869
  this.updateReorderVisualState();
3542
3870
  if (reorderEvent) this.callbacks.onReorder?.(reorderEvent);
3543
3871
  }
@@ -3551,22 +3879,20 @@ export class NativeListWebEngine {
3551
3879
  this.cancelFrame(this.reorderAutoScrollFrame);
3552
3880
  this.reorderAutoScrollFrame = undefined;
3553
3881
  }
3882
+ cancelPendingPointerReorder() {
3883
+ const pointer = this.pointerReorder;
3884
+ if (pointer && !pointer.active && !pointer.restoringKeyboardOrder) this.cancelPointerReorder(false);
3885
+ }
3554
3886
  cancelPointerReorder(restore) {
3555
3887
  const state = this.pointerReorder;
3556
3888
  if (!state) return;
3557
3889
  this.clearReorderLongPress(state);
3558
- this.releaseReorderPointer(state);
3559
3890
  this.pointerReorder = undefined;
3891
+ if (!state.active && !state.restoringKeyboardOrder) return;
3892
+ this.releaseReorderPointer(state);
3560
3893
  this.stopReorderMove();
3561
3894
  this.stopReorderAutoScroll();
3562
- if (state.active && restore) {
3563
- this.remapMountedRows(state.originalRows);
3564
- this.setSnapshot({
3565
- ...this.snapshot,
3566
- rows: cancelWebReorderRows(state.originalRows)
3567
- }, this.selectedKeys);
3568
- this.suppressClickUntil = Date.now() + 300;
3569
- }
3895
+ if (state.active && restore) this.setReorderRows(cancelWebReorderRows(state.originalRows));
3570
3896
  if (state.active && restore) this.animateReorderPreviewToCurrent(state);else this.hideReorderPreview();
3571
3897
  this.updateReorderVisualState();
3572
3898
  }
@@ -3587,7 +3913,8 @@ export class NativeListWebEngine {
3587
3913
  });
3588
3914
  }
3589
3915
  updateReorderVisualState() {
3590
- const sourceKey = this.pointerReorder?.active ? this.pointerReorder.sourceKey : this.keyboardReorder?.sourceKey ?? this.reorderSettlingKey;
3916
+ const pointerSourceKey = this.pointerReorder?.active ? this.pointerReorder.sourceKey : this.reorderSettlingKey;
3917
+ const sourceKey = this.keyboardReorder?.sourceKey ?? pointerSourceKey;
3591
3918
  setData(this.root, 'nativeListDragging', Boolean(sourceKey));
3592
3919
  if (this.reorderMovementTimer !== undefined) {
3593
3920
  this.document.defaultView?.clearTimeout(this.reorderMovementTimer);
@@ -3606,7 +3933,7 @@ export class NativeListWebEngine {
3606
3933
  this.mounted.forEach(element => {
3607
3934
  const dragging = element.dataset.nativeListRowKey === sourceKey;
3608
3935
  setData(element, 'nativeListReorderExpanding', element.dataset.nativeListRowKey === this.reorderExpandingKey);
3609
- setData(element, 'nativeListDragging', dragging);
3936
+ setData(element, 'nativeListDragging', element.dataset.nativeListRowKey === pointerSourceKey);
3610
3937
  if (dragging) element.setAttribute('aria-grabbed', 'true');else element.removeAttribute('aria-grabbed');
3611
3938
  });
3612
3939
  }