@onekeyfe/react-native-native-list 6.8.0-9 → 6.8.0-alpha.540

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 (49) 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/NativeListIdentityRenderer.kt +70 -33
  4. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +3 -2
  5. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +8 -1
  6. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +21 -4
  7. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
  8. package/android/src/main/java/com/onekey/nativelist/NativeListRowUpdates.kt +34 -0
  9. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
  10. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
  11. package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
  12. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentitySubtitleBindingTest.kt +177 -0
  13. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
  14. package/docs/SPEC.md +127 -2
  15. package/docs/STYLE_SPEC.md +7 -1
  16. package/ios/NativeListAccessoryStack.swift +22 -0
  17. package/ios/NativeListDataRowRenderer.swift +12 -5
  18. package/ios/NativeListIdentityRenderer.swift +36 -58
  19. package/ios/NativeListLeadingVisual.swift +8 -0
  20. package/ios/NativeListMarketRenderer.swift +6 -2
  21. package/ios/NativeListModels.swift +7 -0
  22. package/ios/NativeListResolvedText.swift +9 -7
  23. package/ios/NativeListSectionHeaderRenderer.swift +9 -43
  24. package/ios/NativeListTextStyles.swift +72 -12
  25. package/ios/RNCNativeListView.swift +124 -20
  26. package/ios/tests/NativeListLifecycleTests.swift +105 -0
  27. package/lib/module/validation.js +21 -10
  28. package/lib/module/web/NativeListWebEngine.js +213 -23
  29. package/lib/module/web/templates/ActivityRowRenderer.js +1 -1
  30. package/lib/module/web/templates/IdentityRowRenderer.js +12 -1
  31. package/lib/module/web/templates/MarketRowRenderer.js +2 -0
  32. package/lib/module/web/templates/MediaTileRowRenderer.js +1 -0
  33. package/lib/module/web/templates/RowElements.js +2 -2
  34. package/lib/module/web/templates/RowText.js +2 -0
  35. package/lib/typescript/src/models.d.ts +15 -1
  36. package/lib/typescript/src/web/NativeListWebEngine.d.ts +8 -1
  37. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +6 -2
  38. package/lib/typescript/src/web/templates/RowVisual.d.ts +1 -1
  39. package/package.json +1 -1
  40. package/src/models.ts +15 -0
  41. package/src/validation.ts +67 -4
  42. package/src/web/NativeListWebEngine.ts +382 -27
  43. package/src/web/templates/ActivityRowRenderer.ts +1 -1
  44. package/src/web/templates/IdentityRowRenderer.ts +23 -1
  45. package/src/web/templates/MarketRowRenderer.ts +2 -0
  46. package/src/web/templates/MediaTileRowRenderer.ts +1 -0
  47. package/src/web/templates/RowElements.ts +3 -2
  48. package/src/web/templates/RowText.ts +6 -0
  49. 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;
@@ -285,6 +286,8 @@ type PointerReorderState = {
285
286
  pointerId: number;
286
287
  pointerType: string;
287
288
  sourceKey: string;
289
+ memberKey?: string;
290
+ handle?: HTMLElement;
288
291
  currentIndex: number;
289
292
  startX: number;
290
293
  startY: number;
@@ -307,6 +310,18 @@ type PointerReorderState = {
307
310
  active: boolean;
308
311
  };
309
312
 
313
+ type ReorderClickPointer = Readonly<{
314
+ suppress: boolean;
315
+ pressTarget?: Element;
316
+ release?: Readonly<{
317
+ target: Element | undefined;
318
+ clientX: number;
319
+ clientY: number;
320
+ pointerType: string;
321
+ timer: number;
322
+ }>;
323
+ }>;
324
+
310
325
  type KeyboardReorderState = {
311
326
  sourceKey: string;
312
327
  originalRows: readonly RowModel[];
@@ -327,6 +342,15 @@ export function isWebRowReorderable(
327
342
  );
328
343
  }
329
344
 
345
+ function hasWebReorderHandle(row: RowModel): boolean {
346
+ if (row.type === 'walletGroup')
347
+ return [row.parent, ...row.children].some(hasWebReorderHandle);
348
+ return (
349
+ 'trailing' in row &&
350
+ row.trailing?.some((accessory) => accessory.kind === 'drag') === true
351
+ );
352
+ }
353
+
330
354
  export function moveWebReorderRow(
331
355
  rows: readonly RowModel[],
332
356
  fromIndex: number,
@@ -831,6 +855,8 @@ export const WEB_LIST_CSS = `
831
855
  .ok-native-list-wallet-member:not([data-native-list-selected="true"]):active>.ok-native-list-wallet-row{background:var(--nl-pressed)}
832
856
  .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
857
  .ok-native-list-item[data-native-list-reorderable="true"]>.ok-native-list-row{cursor:grab}
858
+ :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}
859
+ .ok-native-list-item[data-native-list-reorderable="true"] [data-native-list-reorder-handle]{cursor:grab}
834
860
  .ok-native-list-root[data-native-list-dragging="true"] .ok-native-list-row{cursor:grabbing}
835
861
  .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
862
  .ok-native-list-item[data-native-list-dragging="true"]>.ok-native-list-row{overflow:hidden;border-radius:12px;background:var(--nl-pressed)}
@@ -851,6 +877,7 @@ export const WEB_LIST_CSS = `
851
877
  .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
878
  .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
879
  .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}
880
+ .ok-native-list-action-glyph{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center}
854
881
  .ok-native-list-icon-button.ok-native-list-tertiary-icon:focus-visible:not(:disabled){outline:2px solid var(--nl-accent)}
855
882
  .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}
856
883
  .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)}
@@ -861,7 +888,7 @@ export const WEB_LIST_CSS = `
861
888
  .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
889
  .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
890
  .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}
891
+ .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
892
  .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
893
  .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
894
  .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 +1214,11 @@ function paintSelectorImageBackground(
1187
1214
  }
1188
1215
 
1189
1216
  function applySelectorIcon(element: HTMLElement, name: string) {
1190
- const canonical = selectorIcons[name];
1217
+ // Registered names keep their legacy aliases; any other name resolves
1218
+ // through the host icon catalog, matching the iOS/Android fallback.
1219
+ const canonical = Object.prototype.hasOwnProperty.call(selectorIcons, name)
1220
+ ? selectorIcons[name]
1221
+ : name;
1191
1222
  if (!canonical) return;
1192
1223
  if (canonical === 'Circle') {
1193
1224
  const svg = element.ownerDocument.createElementNS(
@@ -1210,7 +1241,10 @@ function applySelectorIcon(element: HTMLElement, name: string) {
1210
1241
  element.replaceChildren(svg);
1211
1242
  return;
1212
1243
  }
1213
- element.replaceChildren(createNamedIcon(element.ownerDocument, canonical));
1244
+ const svg = createNamedIcon(element.ownerDocument, canonical);
1245
+ // Without host artwork the element keeps its text glyph.
1246
+ if (!svg.firstChild) return;
1247
+ element.replaceChildren(svg);
1214
1248
  }
1215
1249
 
1216
1250
  function iconGlyph(name: string): string {
@@ -1395,6 +1429,8 @@ function createVisual(
1395
1429
  if (svg) {
1396
1430
  svg.style.width = `${fallbackIcon.size}px`;
1397
1431
  svg.style.height = `${fallbackIcon.size}px`;
1432
+ // Keep the requested size inside a bordered frame, as Icon w/h does.
1433
+ svg.style.flexShrink = '0';
1398
1434
  }
1399
1435
  }
1400
1436
  }
@@ -1413,8 +1449,21 @@ function createVisual(
1413
1449
  '2px dashed ' + (visual.borderColor ?? 'var(--nl-disabled)');
1414
1450
  frame.style.boxSizing = 'border-box';
1415
1451
  } else if ('borderColor' in visual && visual.borderColor) {
1416
- frame.style.border = '1px solid ' + visual.borderColor;
1452
+ frame.style.border =
1453
+ String(
1454
+ 'borderWidth' in visual && visual.borderWidth ? visual.borderWidth : 1
1455
+ ) +
1456
+ 'px solid ' +
1457
+ visual.borderColor;
1417
1458
  frame.style.boxSizing = 'border-box';
1459
+ // iOS and Android inset the image by the border, as React Native's Image does.
1460
+ const main = frame.querySelector<HTMLElement>(
1461
+ ':scope > .ok-native-list-visual-main'
1462
+ );
1463
+ if (main) {
1464
+ main.style.width = '100%';
1465
+ main.style.height = '100%';
1466
+ }
1418
1467
  }
1419
1468
  if ('overlays' in visual)
1420
1469
  visual.overlays?.forEach((overlay) => {
@@ -1630,7 +1679,8 @@ function createIconAction(
1630
1679
  name: string,
1631
1680
  actionKey: string | undefined,
1632
1681
  disabled?: boolean,
1633
- tintColor?: string
1682
+ tintColor?: string,
1683
+ accessibilityLabel?: string
1634
1684
  ): HTMLElement {
1635
1685
  const element = createElement(
1636
1686
  context.document,
@@ -1641,7 +1691,13 @@ function createIconAction(
1641
1691
  if (element.tagName === 'BUTTON') {
1642
1692
  element.setAttribute('type', 'button');
1643
1693
  element.toggleAttribute('disabled', Boolean(disabled));
1644
- if (name === 'DotVerSolid') element.setAttribute('aria-label', '⋮');
1694
+ element.setAttribute(
1695
+ 'aria-label',
1696
+ accessibilityLabel || (name === 'DotVerSolid' ? '⋮' : iconGlyph(name))
1697
+ );
1698
+ } else if (accessibilityLabel) {
1699
+ element.setAttribute('aria-label', accessibilityLabel);
1700
+ element.setAttribute('role', 'img');
1645
1701
  }
1646
1702
  applySelectorIcon(element, name);
1647
1703
  if (actionKey) setData(element, 'nativeListAction', actionKey);
@@ -1712,8 +1768,9 @@ function createAccessory(
1712
1768
  context,
1713
1769
  accessory.name,
1714
1770
  accessory.actionKey,
1715
- accessory.disabled,
1716
- accessory.tintColor
1771
+ rowDisabled || accessory.disabled,
1772
+ accessory.tintColor,
1773
+ accessory.accessibilityLabel
1717
1774
  );
1718
1775
  markActionAnchorSource(element, 'trailingAccessory', slot);
1719
1776
  if (accessory.name === 'RefreshCcwOutline' && !accessory.actionKey) {
@@ -1731,8 +1788,6 @@ function createAccessory(
1731
1788
  setData(element, 'nativeListHoverAction', accessory.hoverActionKey);
1732
1789
  if (accessory.hoverActionKey && accessory.buttonStyle === 'tertiary')
1733
1790
  setData(element, 'nativeListIconHelp', true);
1734
- if (accessory.accessibilityLabel)
1735
- element.setAttribute('aria-label', accessory.accessibilityLabel);
1736
1791
  const row = context.snapshot.rows[context.itemIndex];
1737
1792
  if (
1738
1793
  row &&
@@ -1830,6 +1885,23 @@ function createAccessory(
1830
1885
  break;
1831
1886
  case 'drag':
1832
1887
  element.textContent = '≡';
1888
+ applySelectorIcon(element, 'DragOutline');
1889
+ // iOS and Android tint the handle iconSubdued, like ListItem.IconButton.
1890
+ element.style.color = 'var(--nl-icon-subdued)';
1891
+ // A 24-point centered box, so the glyph does not follow the text line box.
1892
+ Object.assign(element.style, {
1893
+ display: 'inline-flex',
1894
+ alignItems: 'center',
1895
+ justifyContent: 'center',
1896
+ width: '24px',
1897
+ height: '24px',
1898
+ });
1899
+ if (actionKey) {
1900
+ element.toggleAttribute('disabled', rowDisabled);
1901
+ element.setAttribute('aria-label', '≡');
1902
+ }
1903
+ setData(element, 'nativeListReorderHandle', true);
1904
+ setData(element, 'nativeListAnchorSlot', slot);
1833
1905
  break;
1834
1906
  case 'progress':
1835
1907
  element.textContent = String(Math.round(accessory.value * 100)) + '%';
@@ -1854,8 +1926,17 @@ function rendererPrimitives(context: RenderContext, rowDisabled: boolean) {
1854
1926
  name: string,
1855
1927
  actionKey: string | undefined,
1856
1928
  disabled?: boolean,
1857
- tintColor?: string
1858
- ) => createIconAction(context, name, actionKey, disabled, tintColor),
1929
+ tintColor?: string,
1930
+ accessibilityLabel?: string
1931
+ ) =>
1932
+ createIconAction(
1933
+ context,
1934
+ name,
1935
+ actionKey,
1936
+ rowDisabled || disabled,
1937
+ tintColor,
1938
+ accessibilityLabel
1939
+ ),
1859
1940
  dispose: disposeWebImageRetries,
1860
1941
  };
1861
1942
  }
@@ -1955,7 +2036,10 @@ export class NativeListWebEngine {
1955
2036
  private reorderSettlingKey: string | undefined;
1956
2037
  private reorderCompactKey: string | undefined;
1957
2038
  private reorderExpandingKey: string | undefined;
1958
- private suppressClickUntil = 0;
2039
+ private readonly reorderClickPointers = new Map<
2040
+ number,
2041
+ ReorderClickPointer
2042
+ >();
1959
2043
  private pullStartY: number | undefined;
1960
2044
  private pullDistance = 0;
1961
2045
  private virtualizationEnabled: boolean;
@@ -2199,6 +2283,13 @@ export class NativeListWebEngine {
2199
2283
  this.handleCollapsiblePagerInsetsChanged
2200
2284
  );
2201
2285
  this.root.addEventListener('click', this.handleClick);
2286
+ this.document.addEventListener('pointerdown', this.trackReorderPress, true);
2287
+ this.document.addEventListener('pointerup', this.trackReorderRelease, true);
2288
+ this.document.addEventListener(
2289
+ 'pointercancel',
2290
+ this.trackReorderRelease,
2291
+ true
2292
+ );
2202
2293
  this.root.addEventListener('contextmenu', this.handleMarketContextMenu);
2203
2294
  this.root.addEventListener('pointerdown', this.handleMarketPointerDown);
2204
2295
  this.root.addEventListener('pointermove', this.handleMarketPointerMove);
@@ -2384,6 +2475,25 @@ export class NativeListWebEngine {
2384
2475
  private applyValidatedSnapshot(validated: NativeListSnapshot) {
2385
2476
  this.pressedHelpElement = undefined;
2386
2477
  this.invalidateActionAnchor('snapshot');
2478
+ const capabilities = this.snapshot.capabilities;
2479
+ const nextCapabilities = validated.capabilities;
2480
+ if (
2481
+ this.pointerReorder?.active ||
2482
+ capabilities?.reorderable !== nextCapabilities?.reorderable ||
2483
+ (capabilities?.reorderActivation ?? 'row') !==
2484
+ (nextCapabilities?.reorderActivation ?? 'row')
2485
+ ) {
2486
+ this.cancelPointerReorder(false);
2487
+ }
2488
+ const keyboardSource = this.keyboardReorder?.sourceKey;
2489
+ const preserveKeyboardFocus =
2490
+ keyboardSource &&
2491
+ this.document.activeElement?.getAttribute('data-native-list-row-key') ===
2492
+ keyboardSource;
2493
+ if (this.keyboardReorder) {
2494
+ this.keyboardReorder = undefined;
2495
+ this.updateReorderVisualState();
2496
+ }
2387
2497
  const transition = validated.structuralTransition;
2388
2498
  const isNewTransition =
2389
2499
  transition !== undefined &&
@@ -2424,6 +2534,7 @@ export class NativeListWebEngine {
2424
2534
  this.cancelStructuralAnimation();
2425
2535
  this.setSnapshot(validated);
2426
2536
  }
2537
+ if (preserveKeyboardFocus) this.focusMountedRow(keyboardSource);
2427
2538
  this.hasAppliedSnapshot = true;
2428
2539
  }
2429
2540
 
@@ -2814,7 +2925,12 @@ export class NativeListWebEngine {
2814
2925
  }
2815
2926
 
2816
2927
  currentSnapshot(): NativeListSnapshot {
2817
- return this.snapshot;
2928
+ const originalRows = this.pointerReorder?.active
2929
+ ? this.pointerReorder.originalRows
2930
+ : this.keyboardReorder?.originalRows;
2931
+ return originalRows
2932
+ ? { ...this.snapshot, rows: originalRows }
2933
+ : this.snapshot;
2818
2934
  }
2819
2935
 
2820
2936
  applyPatches(patches: readonly RowPatch[]) {
@@ -2823,7 +2939,38 @@ export class NativeListWebEngine {
2823
2939
  );
2824
2940
  if (!accepted || accepted.patches.length === 0) return;
2825
2941
  patches = accepted.patches;
2826
- const next = accepted.snapshot;
2942
+ let next = accepted.snapshot;
2943
+ let restoredReorder = false;
2944
+ const pointer = this.pointerReorder?.active
2945
+ ? this.pointerReorder
2946
+ : undefined;
2947
+ const keyboard = this.keyboardReorder;
2948
+ const reorder = pointer ?? keyboard;
2949
+ if (reorder) {
2950
+ const byKey = new Map(next.rows.map((row) => [row.key, row]));
2951
+ reorder.originalRows = reorder.originalRows.map(
2952
+ (row) => byKey.get(row.key) ?? row
2953
+ );
2954
+ const source = byKey.get(reorder.sourceKey);
2955
+ const canContinue = pointer
2956
+ ? this.canStartPointerReorder(pointer, next)
2957
+ : source &&
2958
+ isWebRowReorderable(next, source) &&
2959
+ (next.capabilities?.reorderActivation !== 'handle' ||
2960
+ hasWebReorderHandle(source));
2961
+ if (!canContinue) {
2962
+ if (pointer) this.cancelPointerReorder(false);
2963
+ if (keyboard) {
2964
+ this.keyboardReorder = undefined;
2965
+ this.updateReorderVisualState();
2966
+ }
2967
+ this.remapMountedRows(reorder.originalRows);
2968
+ next = { ...next, rows: reorder.originalRows };
2969
+ restoredReorder = true;
2970
+ } else if (pointer) {
2971
+ pointer.workingRows = [...next.rows];
2972
+ }
2973
+ }
2827
2974
  const selection = new Set(this.selectedKeys);
2828
2975
  patches.forEach((patch) => {
2829
2976
  const selected =
@@ -2846,7 +2993,10 @@ export class NativeListWebEngine {
2846
2993
  canPatchMarketTableValues(before, after)
2847
2994
  );
2848
2995
  });
2849
- if (webMarketImageBindDeltaForPatches(patches) === 0 || tableValuesOnly) {
2996
+ if (
2997
+ !restoredReorder &&
2998
+ (webMarketImageBindDeltaForPatches(patches) === 0 || tableValuesOnly)
2999
+ ) {
2850
3000
  this.snapshot = next;
2851
3001
  this.rows = effectiveRows(next);
2852
3002
  this.selectedKeys = selection;
@@ -3048,6 +3198,23 @@ export class NativeListWebEngine {
3048
3198
  this.handleCollapsiblePagerInsetsChanged
3049
3199
  );
3050
3200
  this.root.removeEventListener('click', this.handleClick);
3201
+ this.document.removeEventListener(
3202
+ 'pointerdown',
3203
+ this.trackReorderPress,
3204
+ true
3205
+ );
3206
+ this.document.removeEventListener(
3207
+ 'pointerup',
3208
+ this.trackReorderRelease,
3209
+ true
3210
+ );
3211
+ this.document.removeEventListener(
3212
+ 'pointercancel',
3213
+ this.trackReorderRelease,
3214
+ true
3215
+ );
3216
+ for (const id of this.reorderClickPointers.keys())
3217
+ this.clearReorderClick(id);
3051
3218
  this.root.removeEventListener('contextmenu', this.handleMarketContextMenu);
3052
3219
  this.cancelMarketPointer();
3053
3220
  this.root.removeEventListener('pointerdown', this.handleMarketPointerDown);
@@ -3125,6 +3292,11 @@ export class NativeListWebEngine {
3125
3292
  this.pressedHelpElement = undefined;
3126
3293
  this.measuredRendererHeights.clear();
3127
3294
  this.snapshot = snapshot;
3295
+ setData(
3296
+ this.root,
3297
+ 'nativeListReorderActivation',
3298
+ snapshot.capabilities?.reorderActivation
3299
+ );
3128
3300
  this.rows = effectiveRows(snapshot);
3129
3301
  this.selectedKeys =
3130
3302
  selectedKeys ?? selectionStateFromSnapshot(snapshot).selectedKeys;
@@ -3466,6 +3638,7 @@ export class NativeListWebEngine {
3466
3638
  this.content.appendChild(element);
3467
3639
  }
3468
3640
  this.positionElement(element, layoutItem);
3641
+ setData(element, 'nativeListReorderable', this.isReorderable(row));
3469
3642
  const signature = webRowRenderSignature(row);
3470
3643
  if (
3471
3644
  element.dataset.nativeListRowKey !== row.key ||
@@ -4328,7 +4501,10 @@ export class NativeListWebEngine {
4328
4501
  if (!source || !bindingEpoch || !rowElement.contains(actionElement))
4329
4502
  return undefined;
4330
4503
  this.invalidateActionAnchor('rebind');
4331
- const actualRect = actionElement.getBoundingClientRect();
4504
+ const glyph = actionElement.querySelector(
4505
+ ':scope > [data-native-list-anchor-glyph]'
4506
+ );
4507
+ const actualRect = (glyph ?? actionElement).getBoundingClientRect();
4332
4508
  const inset = Number(actionElement.dataset.nativeListAnchorInset ?? 0);
4333
4509
  const rect = {
4334
4510
  left: actualRect.left + inset,
@@ -4682,8 +4858,122 @@ export class NativeListWebEngine {
4682
4858
  this.invalidateActionAnchor('pointerLeave');
4683
4859
  };
4684
4860
 
4685
- private handleClick = (event: Event) => {
4686
- if (this.marketLongPressFired || Date.now() < this.suppressClickUntil) {
4861
+ private clearReorderClick(
4862
+ pointerId: number
4863
+ ): ReorderClickPointer | undefined {
4864
+ const pointer = this.reorderClickPointers.get(pointerId);
4865
+ if (pointer?.release)
4866
+ this.document.defaultView?.clearTimeout(pointer.release.timer);
4867
+ this.reorderClickPointers.delete(pointerId);
4868
+ return pointer;
4869
+ }
4870
+
4871
+ private reorderClickTarget(
4872
+ target: EventTarget | null,
4873
+ pressTarget?: Element
4874
+ ): Element | undefined {
4875
+ if (!(target instanceof Element) || !this.root.contains(target))
4876
+ return undefined;
4877
+ let clickTarget: Element | null = target;
4878
+ if (pressTarget && this.root.contains(pressTarget)) {
4879
+ // An uncaptured click can target the common ancestor of two controls.
4880
+ while (clickTarget && !clickTarget.contains(pressTarget))
4881
+ clickTarget = clickTarget.parentElement;
4882
+ }
4883
+ return (
4884
+ clickTarget?.closest(
4885
+ '[data-native-list-action],[data-native-list-group-member-key],[data-native-list-row-key]'
4886
+ ) ??
4887
+ clickTarget ??
4888
+ undefined
4889
+ );
4890
+ }
4891
+
4892
+ private trackReorderPress = (event: PointerEvent) => {
4893
+ this.clearReorderClick(event.pointerId);
4894
+ if (
4895
+ event.isPrimary === false ||
4896
+ event.button !== 0 ||
4897
+ !(event.target instanceof Element) ||
4898
+ !this.root.contains(event.target)
4899
+ )
4900
+ return;
4901
+
4902
+ this.reorderClickPointers.set(event.pointerId, {
4903
+ suppress: false,
4904
+ pressTarget: event.target,
4905
+ });
4906
+ };
4907
+
4908
+ private trackReorderRelease = (event: PointerEvent) => {
4909
+ if (this.reorderClickPointers.size === 0) return;
4910
+ const {
4911
+ type,
4912
+ pointerId,
4913
+ clientX,
4914
+ clientY,
4915
+ pointerType,
4916
+ isPrimary,
4917
+ button,
4918
+ } = event;
4919
+ const pending = this.clearReorderClick(pointerId);
4920
+ if (!pending || type !== 'pointerup' || isPrimary === false || button !== 0)
4921
+ return;
4922
+ const releaseTarget =
4923
+ event.target === this.viewport &&
4924
+ this.viewport.hasPointerCapture?.(pointerId)
4925
+ ? this.document.elementFromPoint?.(clientX, clientY) ?? event.target
4926
+ : event.target;
4927
+ const target = this.reorderClickTarget(releaseTarget, pending.pressTarget);
4928
+ if (!pending.suppress && !target) return;
4929
+
4930
+ // Start expiry at release so a cancelled reorder stays suppressed while held.
4931
+ const view = this.document.defaultView;
4932
+ if (!view) return;
4933
+ const timer = view.setTimeout(
4934
+ () => this.reorderClickPointers.delete(pointerId),
4935
+ REORDER_CLICK_GRACE_MS
4936
+ );
4937
+ this.reorderClickPointers.set(pointerId, {
4938
+ suppress: pending.suppress,
4939
+ release: { target, clientX, clientY, pointerType, timer },
4940
+ });
4941
+ };
4942
+
4943
+ private legacyClickPointerId(event: MouseEvent): number | undefined {
4944
+ // Keyboard and programmatic activations have detail 0.
4945
+ if (!(event.detail > 0)) return undefined;
4946
+ const target = this.reorderClickTarget(event.target);
4947
+ if (!target) return undefined;
4948
+ const fromTouch = (
4949
+ event as MouseEvent & {
4950
+ sourceCapabilities?: { firesTouchEvents: boolean } | null;
4951
+ }
4952
+ ).sourceCapabilities?.firesTouchEvents;
4953
+ let match: number | undefined;
4954
+ // A release inserts at the end of the map. Keep the latest matching release.
4955
+ for (const [pointerId, { release }] of this.reorderClickPointers) {
4956
+ if (
4957
+ release?.target === target &&
4958
+ (fromTouch === undefined ||
4959
+ fromTouch === (release.pointerType === 'touch')) &&
4960
+ Math.abs(release.clientX - event.clientX) <= 1 &&
4961
+ Math.abs(release.clientY - event.clientY) <= 1
4962
+ )
4963
+ match = pointerId;
4964
+ }
4965
+ return match;
4966
+ }
4967
+
4968
+ private handleClick = (event: MouseEvent) => {
4969
+ const pointerId =
4970
+ (event as PointerEvent).pointerId ??
4971
+ (this.reorderClickPointers.size > 0
4972
+ ? this.legacyClickPointerId(event)
4973
+ : undefined);
4974
+ const clickFromReorder =
4975
+ pointerId !== undefined && this.clearReorderClick(pointerId)?.suppress;
4976
+ if (this.marketLongPressFired || clickFromReorder) {
4687
4977
  this.marketLongPressFired = false;
4688
4978
  event.preventDefault();
4689
4979
  event.stopPropagation();
@@ -4803,7 +5093,16 @@ export class NativeListWebEngine {
4803
5093
  const row = this.rowAtElement(target.closest('[data-native-list-row-key]'));
4804
5094
  if (!row) return;
4805
5095
  event.preventDefault();
4806
- if (event.key === ' ' && this.isReorderable(row)) {
5096
+ const hasHandle = target
5097
+ .closest('[data-native-list-row-key]')
5098
+ ?.querySelector('[data-native-list-reorder-handle]');
5099
+ if (
5100
+ event.key === ' ' &&
5101
+ this.isReorderable(row) &&
5102
+ (this.keyboardReorder ||
5103
+ this.snapshot.capabilities?.reorderActivation !== 'handle' ||
5104
+ hasHandle)
5105
+ ) {
4807
5106
  if (this.keyboardReorder) this.finishKeyboardReorder();
4808
5107
  else this.startKeyboardReorder(row);
4809
5108
  return;
@@ -4848,9 +5147,7 @@ export class NativeListWebEngine {
4848
5147
  viewPosition: 0,
4849
5148
  viewOffset: 0,
4850
5149
  });
4851
- [...this.mounted.values()]
4852
- .find((element) => element.dataset.nativeListRowKey === state.sourceKey)
4853
- ?.focus({ preventScroll: true });
5150
+ this.focusMountedRow(state.sourceKey);
4854
5151
  }
4855
5152
 
4856
5153
  private finishKeyboardReorder() {
@@ -4876,8 +5173,12 @@ export class NativeListWebEngine {
4876
5173
  this.selectedKeys
4877
5174
  );
4878
5175
  this.updateReorderVisualState();
5176
+ this.focusMountedRow(state.sourceKey);
5177
+ }
5178
+
5179
+ private focusMountedRow(key: string) {
4879
5180
  [...this.mounted.values()]
4880
- .find((element) => element.dataset.nativeListRowKey === state.sourceKey)
5181
+ .find((element) => element.dataset.nativeListRowKey === key)
4881
5182
  ?.focus({ preventScroll: true });
4882
5183
  }
4883
5184
 
@@ -5067,7 +5368,14 @@ export class NativeListWebEngine {
5067
5368
  }
5068
5369
  const target = event.target;
5069
5370
  if (!(target instanceof Element)) return;
5070
- if (target.closest('button,input,textarea,select,a')) return;
5371
+ const handleMode =
5372
+ this.snapshot.capabilities?.reorderActivation === 'handle';
5373
+ const handle = handleMode
5374
+ ? target.closest<HTMLElement>('[data-native-list-reorder-handle]')
5375
+ : undefined;
5376
+ const control = target.closest('button,input,textarea,select,a');
5377
+ if (handleMode && !handle) return;
5378
+ if (control && (control !== handle || control.matches(':disabled'))) return;
5071
5379
  const rowElement = target.closest<HTMLElement>(
5072
5380
  '[data-native-list-row-index]'
5073
5381
  );
@@ -5091,6 +5399,8 @@ export class NativeListWebEngine {
5091
5399
  pointerId: event.pointerId,
5092
5400
  pointerType: event.pointerType || 'mouse',
5093
5401
  sourceKey: row.key,
5402
+ memberKey,
5403
+ handle: handle ?? undefined,
5094
5404
  currentIndex: index,
5095
5405
  startX: event.clientX,
5096
5406
  startY: event.clientY,
@@ -5110,10 +5420,57 @@ export class NativeListWebEngine {
5110
5420
  }
5111
5421
  };
5112
5422
 
5423
+ private canStartPointerReorder(
5424
+ state: PointerReorderState,
5425
+ snapshot: NativeListSnapshot
5426
+ ): boolean {
5427
+ const row = snapshot.rows.find(
5428
+ (candidate) => candidate.key === state.sourceKey
5429
+ );
5430
+ if (
5431
+ !row ||
5432
+ !isWebRowReorderable(snapshot, row) ||
5433
+ !canStartWebWalletGroupReorder(row, state.memberKey)
5434
+ )
5435
+ return false;
5436
+ if (!state.handle) return true;
5437
+ const handleRow =
5438
+ row.type === 'walletGroup'
5439
+ ? [row.parent, ...row.children].find(
5440
+ (member) => member.key === state.memberKey
5441
+ )
5442
+ : row;
5443
+ const slot = Number(state.handle.dataset.nativeListAnchorSlot);
5444
+ return Boolean(
5445
+ handleRow &&
5446
+ 'trailing' in handleRow &&
5447
+ handleRow.trailing?.[slot]?.kind === 'drag'
5448
+ );
5449
+ }
5450
+
5113
5451
  private activatePointerReorder(state: PointerReorderState) {
5114
5452
  if (this.pointerReorder !== state) return;
5453
+ const rowIndex = this.snapshot.rows.findIndex(
5454
+ (row) => row.key === state.sourceKey
5455
+ );
5456
+ const source = this.mounted.get(rowIndex);
5457
+ if (
5458
+ !source ||
5459
+ !this.canStartPointerReorder(state, this.snapshot) ||
5460
+ (state.handle && !source.contains(state.handle))
5461
+ ) {
5462
+ this.cancelPointerReorder(false);
5463
+ return;
5464
+ }
5115
5465
  this.clearReorderLongPress(state);
5466
+ state.currentIndex = rowIndex;
5467
+ state.originalRows = this.snapshot.rows;
5468
+ state.workingRows = [...this.snapshot.rows];
5116
5469
  state.active = true;
5470
+ this.reorderClickPointers.set(state.pointerId, {
5471
+ suppress: true,
5472
+ pressTarget: this.reorderClickPointers.get(state.pointerId)?.pressTarget,
5473
+ });
5117
5474
  this.cancelMarketPointer();
5118
5475
  state.activatedAt = Date.now();
5119
5476
  state.viewportRect = this.reorderViewportRect();
@@ -5594,7 +5951,6 @@ export class NativeListWebEngine {
5594
5951
  this.pointerReorder = undefined;
5595
5952
  this.stopReorderMove();
5596
5953
  this.stopReorderAutoScroll();
5597
- this.suppressClickUntil = Date.now() + 300;
5598
5954
  this.updateReorderVisualState();
5599
5955
  if (reorderEvent) this.callbacks.onReorder?.(reorderEvent);
5600
5956
  }
@@ -5629,7 +5985,6 @@ export class NativeListWebEngine {
5629
5985
  { ...this.snapshot, rows: cancelWebReorderRows(state.originalRows) },
5630
5986
  this.selectedKeys
5631
5987
  );
5632
- this.suppressClickUntil = Date.now() + 300;
5633
5988
  }
5634
5989
  if (state.active && restore) this.animateReorderPreviewToCurrent(state);
5635
5990
  else this.hideReorderPreview();
@@ -598,7 +598,7 @@ function bindHistory(
598
598
  v.descriptionPrefix.style.cssText = `${ellipsis}flex-shrink:0;max-width:${
599
599
  actionText ? `calc(100% - ${descriptionActionReserve})` : '100%'
600
600
  };white-space:pre;display:${actionStart > 0 ? 'block' : 'none'}`;
601
- v.descriptionAction.style.cssText = `${ellipsis}appearance:none;max-width:100%;border:0;padding:0;background:transparent;text-align:left;color:inherit;font:inherit;font-variant-numeric:inherit;display:${
601
+ v.descriptionAction.style.cssText = `${ellipsis}appearance:none;max-width:100%;border:0;padding:0;background:transparent;text-align:left;color:inherit;font:inherit;font-variant-numeric:inherit;letter-spacing:inherit;display:${
602
602
  actionText ? 'block' : 'none'
603
603
  };`;
604
604
  v.descriptionAction.textContent = actionText;