@onekeyfe/react-native-native-list 6.8.0-13 → 6.8.0-15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +18 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +21 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +8 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
- package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
- package/docs/SPEC.md +113 -2
- package/docs/STYLE_SPEC.md +7 -1
- package/ios/NativeListAccessoryStack.swift +22 -0
- package/ios/NativeListDataRowRenderer.swift +12 -5
- package/ios/NativeListIdentityRenderer.swift +36 -58
- package/ios/NativeListLeadingVisual.swift +8 -0
- package/ios/NativeListMarketRenderer.swift +6 -2
- package/ios/NativeListModels.swift +7 -0
- package/ios/NativeListResolvedText.swift +9 -7
- package/ios/NativeListSectionHeaderRenderer.swift +9 -43
- package/ios/NativeListTextStyles.swift +72 -12
- package/ios/RNCNativeListView.swift +124 -20
- package/ios/tests/NativeListLifecycleTests.swift +105 -0
- package/lib/module/validation.js +21 -10
- package/lib/module/web/NativeListWebEngine.js +213 -23
- package/lib/module/web/templates/ActivityRowRenderer.js +1 -1
- package/lib/module/web/templates/IdentityRowRenderer.js +12 -1
- package/lib/module/web/templates/MarketRowRenderer.js +2 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +1 -0
- package/lib/module/web/templates/RowElements.js +2 -2
- package/lib/module/web/templates/RowText.js +2 -0
- package/lib/typescript/src/models.d.ts +15 -1
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +8 -1
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +6 -2
- package/lib/typescript/src/web/templates/RowVisual.d.ts +1 -1
- package/package.json +1 -1
- package/src/models.ts +15 -0
- package/src/validation.ts +67 -4
- package/src/web/NativeListWebEngine.ts +382 -27
- package/src/web/templates/ActivityRowRenderer.ts +1 -1
- package/src/web/templates/IdentityRowRenderer.ts +23 -1
- package/src/web/templates/MarketRowRenderer.ts +2 -0
- package/src/web/templates/MediaTileRowRenderer.ts +1 -0
- package/src/web/templates/RowElements.ts +3 -2
- package/src/web/templates/RowText.ts +6 -0
- package/src/web/templates/RowVisual.ts +2 -1
|
@@ -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;
|
|
@@ -452,6 +457,8 @@ export const WEB_LIST_CSS = `
|
|
|
452
457
|
.ok-native-list-wallet-member:not([data-native-list-selected="true"]):active>.ok-native-list-wallet-row{background:var(--nl-pressed)}
|
|
453
458
|
.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
459
|
.ok-native-list-item[data-native-list-reorderable="true"]>.ok-native-list-row{cursor:grab}
|
|
460
|
+
: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}
|
|
461
|
+
.ok-native-list-item[data-native-list-reorderable="true"] [data-native-list-reorder-handle]{cursor:grab}
|
|
455
462
|
.ok-native-list-root[data-native-list-dragging="true"] .ok-native-list-row{cursor:grabbing}
|
|
456
463
|
.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
464
|
.ok-native-list-item[data-native-list-dragging="true"]>.ok-native-list-row{overflow:hidden;border-radius:12px;background:var(--nl-pressed)}
|
|
@@ -472,6 +479,7 @@ export const WEB_LIST_CSS = `
|
|
|
472
479
|
.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
480
|
.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
481
|
.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}
|
|
482
|
+
.ok-native-list-action-glyph{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center}
|
|
475
483
|
.ok-native-list-icon-button.ok-native-list-tertiary-icon:focus-visible:not(:disabled){outline:2px solid var(--nl-accent)}
|
|
476
484
|
.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}
|
|
477
485
|
.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)}
|
|
@@ -482,7 +490,7 @@ export const WEB_LIST_CSS = `
|
|
|
482
490
|
.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
491
|
.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
492
|
.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}
|
|
493
|
+
.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
494
|
.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
495
|
.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
496
|
.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 +739,9 @@ function paintSelectorImageBackground(image, frame, inset = 0) {
|
|
|
731
739
|
if (image.complete && image.naturalWidth > 0) update();
|
|
732
740
|
}
|
|
733
741
|
function applySelectorIcon(element, name) {
|
|
734
|
-
|
|
742
|
+
// Registered names keep their legacy aliases; any other name resolves
|
|
743
|
+
// through the host icon catalog, matching the iOS/Android fallback.
|
|
744
|
+
const canonical = Object.prototype.hasOwnProperty.call(selectorIcons, name) ? selectorIcons[name] : name;
|
|
735
745
|
if (!canonical) return;
|
|
736
746
|
if (canonical === 'Circle') {
|
|
737
747
|
const svg = element.ownerDocument.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
@@ -748,7 +758,10 @@ function applySelectorIcon(element, name) {
|
|
|
748
758
|
element.replaceChildren(svg);
|
|
749
759
|
return;
|
|
750
760
|
}
|
|
751
|
-
|
|
761
|
+
const svg = createNamedIcon(element.ownerDocument, canonical);
|
|
762
|
+
// Without host artwork the element keeps its text glyph.
|
|
763
|
+
if (!svg.firstChild) return;
|
|
764
|
+
element.replaceChildren(svg);
|
|
752
765
|
}
|
|
753
766
|
function iconGlyph(name) {
|
|
754
767
|
const normalized = name.toLocaleLowerCase();
|
|
@@ -857,6 +870,8 @@ function createVisual(context, visual, selectorPresentation) {
|
|
|
857
870
|
if (svg) {
|
|
858
871
|
svg.style.width = `${fallbackIcon.size}px`;
|
|
859
872
|
svg.style.height = `${fallbackIcon.size}px`;
|
|
873
|
+
// Keep the requested size inside a bordered frame, as Icon w/h does.
|
|
874
|
+
svg.style.flexShrink = '0';
|
|
860
875
|
}
|
|
861
876
|
}
|
|
862
877
|
}
|
|
@@ -871,8 +886,14 @@ function createVisual(context, visual, selectorPresentation) {
|
|
|
871
886
|
frame.style.border = '2px dashed ' + (visual.borderColor ?? 'var(--nl-disabled)');
|
|
872
887
|
frame.style.boxSizing = 'border-box';
|
|
873
888
|
} else if ('borderColor' in visual && visual.borderColor) {
|
|
874
|
-
frame.style.border = '
|
|
889
|
+
frame.style.border = String('borderWidth' in visual && visual.borderWidth ? visual.borderWidth : 1) + 'px solid ' + visual.borderColor;
|
|
875
890
|
frame.style.boxSizing = 'border-box';
|
|
891
|
+
// iOS and Android inset the image by the border, as React Native's Image does.
|
|
892
|
+
const main = frame.querySelector(':scope > .ok-native-list-visual-main');
|
|
893
|
+
if (main) {
|
|
894
|
+
main.style.width = '100%';
|
|
895
|
+
main.style.height = '100%';
|
|
896
|
+
}
|
|
876
897
|
}
|
|
877
898
|
if ('overlays' in visual) visual.overlays?.forEach(overlay => {
|
|
878
899
|
const corner = createElement(context.document, 'span', 'ok-native-list-visual-overlay', overlay.text);
|
|
@@ -982,12 +1003,15 @@ function createCheckbox(context, rowKey, accessory) {
|
|
|
982
1003
|
if (accessory.target?.scope === 'section') setData(element, 'selectionKey', accessory.target.sectionKey);else if (accessory.target?.scope === 'row') setData(element, 'selectionKey', rowKey);
|
|
983
1004
|
return element;
|
|
984
1005
|
}
|
|
985
|
-
function createIconAction(context, name, actionKey, disabled, tintColor) {
|
|
1006
|
+
function createIconAction(context, name, actionKey, disabled, tintColor, accessibilityLabel) {
|
|
986
1007
|
const element = createElement(context.document, actionKey ? 'button' : 'span', 'ok-native-list-icon-button', iconGlyph(name));
|
|
987
1008
|
if (element.tagName === 'BUTTON') {
|
|
988
1009
|
element.setAttribute('type', 'button');
|
|
989
1010
|
element.toggleAttribute('disabled', Boolean(disabled));
|
|
990
|
-
|
|
1011
|
+
element.setAttribute('aria-label', accessibilityLabel || (name === 'DotVerSolid' ? '⋮' : iconGlyph(name)));
|
|
1012
|
+
} else if (accessibilityLabel) {
|
|
1013
|
+
element.setAttribute('aria-label', accessibilityLabel);
|
|
1014
|
+
element.setAttribute('role', 'img');
|
|
991
1015
|
}
|
|
992
1016
|
applySelectorIcon(element, name);
|
|
993
1017
|
if (actionKey) setData(element, 'nativeListAction', actionKey);
|
|
@@ -1024,7 +1048,7 @@ function createAccessory(context, rowKey, accessory, slot, rowDisabled) {
|
|
|
1024
1048
|
return element;
|
|
1025
1049
|
}
|
|
1026
1050
|
if (accessory.kind === 'icon') {
|
|
1027
|
-
const element = createIconAction(context, accessory.name, accessory.actionKey, accessory.disabled, accessory.tintColor);
|
|
1051
|
+
const element = createIconAction(context, accessory.name, accessory.actionKey, rowDisabled || accessory.disabled, accessory.tintColor, accessory.accessibilityLabel);
|
|
1028
1052
|
markActionAnchorSource(element, 'trailingAccessory', slot);
|
|
1029
1053
|
if (accessory.name === 'RefreshCcwOutline' && !accessory.actionKey) {
|
|
1030
1054
|
element.classList.add('ok-native-list-decorative-refresh');
|
|
@@ -1039,7 +1063,6 @@ function createAccessory(context, rowKey, accessory, slot, rowDisabled) {
|
|
|
1039
1063
|
setData(element, 'testid', accessory.testID);
|
|
1040
1064
|
if (accessory.hoverActionKey) setData(element, 'nativeListHoverAction', accessory.hoverActionKey);
|
|
1041
1065
|
if (accessory.hoverActionKey && accessory.buttonStyle === 'tertiary') setData(element, 'nativeListIconHelp', true);
|
|
1042
|
-
if (accessory.accessibilityLabel) element.setAttribute('aria-label', accessory.accessibilityLabel);
|
|
1043
1066
|
const row = context.snapshot.rows[context.itemIndex];
|
|
1044
1067
|
if (row && 'presentation' in row && row.presentation === 'accountSelector') {
|
|
1045
1068
|
setData(element, 'nativeListAnchorInset', 7);
|
|
@@ -1111,6 +1134,23 @@ function createAccessory(context, rowKey, accessory, slot, rowDisabled) {
|
|
|
1111
1134
|
break;
|
|
1112
1135
|
case 'drag':
|
|
1113
1136
|
element.textContent = '≡';
|
|
1137
|
+
applySelectorIcon(element, 'DragOutline');
|
|
1138
|
+
// iOS and Android tint the handle iconSubdued, like ListItem.IconButton.
|
|
1139
|
+
element.style.color = 'var(--nl-icon-subdued)';
|
|
1140
|
+
// A 24-point centered box, so the glyph does not follow the text line box.
|
|
1141
|
+
Object.assign(element.style, {
|
|
1142
|
+
display: 'inline-flex',
|
|
1143
|
+
alignItems: 'center',
|
|
1144
|
+
justifyContent: 'center',
|
|
1145
|
+
width: '24px',
|
|
1146
|
+
height: '24px'
|
|
1147
|
+
});
|
|
1148
|
+
if (actionKey) {
|
|
1149
|
+
element.toggleAttribute('disabled', rowDisabled);
|
|
1150
|
+
element.setAttribute('aria-label', '≡');
|
|
1151
|
+
}
|
|
1152
|
+
setData(element, 'nativeListReorderHandle', true);
|
|
1153
|
+
setData(element, 'nativeListAnchorSlot', slot);
|
|
1114
1154
|
break;
|
|
1115
1155
|
case 'progress':
|
|
1116
1156
|
element.textContent = String(Math.round(accessory.value * 100)) + '%';
|
|
@@ -1127,7 +1167,7 @@ function rendererPrimitives(context, rowDisabled) {
|
|
|
1127
1167
|
thumbnail: source => createImage(context, source, 'ok-native-list-thumbnail'),
|
|
1128
1168
|
textStyle: applyTextStyleToSlot,
|
|
1129
1169
|
icon: applySelectorIcon,
|
|
1130
|
-
iconAction: (name, actionKey, disabled, tintColor) => createIconAction(context, name, actionKey, disabled, tintColor),
|
|
1170
|
+
iconAction: (name, actionKey, disabled, tintColor, accessibilityLabel) => createIconAction(context, name, actionKey, rowDisabled || disabled, tintColor, accessibilityLabel),
|
|
1131
1171
|
dispose: disposeWebImageRetries
|
|
1132
1172
|
};
|
|
1133
1173
|
}
|
|
@@ -1168,7 +1208,7 @@ export class NativeListWebEngine {
|
|
|
1168
1208
|
avatarOffset = 0;
|
|
1169
1209
|
avatarDirection = 1;
|
|
1170
1210
|
sectionIndexEntries = [];
|
|
1171
|
-
|
|
1211
|
+
reorderClickPointers = new Map();
|
|
1172
1212
|
pullDistance = 0;
|
|
1173
1213
|
actionAnchorInstanceId = String(++webNativeListInstanceCounter);
|
|
1174
1214
|
actionAnchorCounter = 0;
|
|
@@ -1283,6 +1323,9 @@ export class NativeListWebEngine {
|
|
|
1283
1323
|
});
|
|
1284
1324
|
(this.externalScrollHost ?? this.viewport).addEventListener('ok-collapsible-pager-insets-changed', this.handleCollapsiblePagerInsetsChanged);
|
|
1285
1325
|
this.root.addEventListener('click', this.handleClick);
|
|
1326
|
+
this.document.addEventListener('pointerdown', this.trackReorderPress, true);
|
|
1327
|
+
this.document.addEventListener('pointerup', this.trackReorderRelease, true);
|
|
1328
|
+
this.document.addEventListener('pointercancel', this.trackReorderRelease, true);
|
|
1286
1329
|
this.root.addEventListener('contextmenu', this.handleMarketContextMenu);
|
|
1287
1330
|
this.root.addEventListener('pointerdown', this.handleMarketPointerDown);
|
|
1288
1331
|
this.root.addEventListener('pointermove', this.handleMarketPointerMove);
|
|
@@ -1422,6 +1465,17 @@ export class NativeListWebEngine {
|
|
|
1422
1465
|
applyValidatedSnapshot(validated) {
|
|
1423
1466
|
this.pressedHelpElement = undefined;
|
|
1424
1467
|
this.invalidateActionAnchor('snapshot');
|
|
1468
|
+
const capabilities = this.snapshot.capabilities;
|
|
1469
|
+
const nextCapabilities = validated.capabilities;
|
|
1470
|
+
if (this.pointerReorder?.active || capabilities?.reorderable !== nextCapabilities?.reorderable || (capabilities?.reorderActivation ?? 'row') !== (nextCapabilities?.reorderActivation ?? 'row')) {
|
|
1471
|
+
this.cancelPointerReorder(false);
|
|
1472
|
+
}
|
|
1473
|
+
const keyboardSource = this.keyboardReorder?.sourceKey;
|
|
1474
|
+
const preserveKeyboardFocus = keyboardSource && this.document.activeElement?.getAttribute('data-native-list-row-key') === keyboardSource;
|
|
1475
|
+
if (this.keyboardReorder) {
|
|
1476
|
+
this.keyboardReorder = undefined;
|
|
1477
|
+
this.updateReorderVisualState();
|
|
1478
|
+
}
|
|
1425
1479
|
const transition = validated.structuralTransition;
|
|
1426
1480
|
const isNewTransition = transition !== undefined && transition.id !== this.lastStructuralTransitionId;
|
|
1427
1481
|
if (transition) this.lastStructuralTransitionId = transition.id;
|
|
@@ -1433,6 +1487,7 @@ export class NativeListWebEngine {
|
|
|
1433
1487
|
if (isNewTransition || changedKeys || incompatibleActivePrefix) this.cancelStructuralAnimation();
|
|
1434
1488
|
this.setSnapshot(validated);
|
|
1435
1489
|
}
|
|
1490
|
+
if (preserveKeyboardFocus) this.focusMountedRow(keyboardSource);
|
|
1436
1491
|
this.hasAppliedSnapshot = true;
|
|
1437
1492
|
}
|
|
1438
1493
|
cancelStructuralAnimation() {
|
|
@@ -1701,13 +1756,42 @@ export class NativeListWebEngine {
|
|
|
1701
1756
|
return this.layout.contentHeight;
|
|
1702
1757
|
}
|
|
1703
1758
|
currentSnapshot() {
|
|
1704
|
-
|
|
1759
|
+
const originalRows = this.pointerReorder?.active ? this.pointerReorder.originalRows : this.keyboardReorder?.originalRows;
|
|
1760
|
+
return originalRows ? {
|
|
1761
|
+
...this.snapshot,
|
|
1762
|
+
rows: originalRows
|
|
1763
|
+
} : this.snapshot;
|
|
1705
1764
|
}
|
|
1706
1765
|
applyPatches(patches) {
|
|
1707
1766
|
const accepted = containNativeListInput(() => applyValidatedRowPatches(this.snapshot, patches));
|
|
1708
1767
|
if (!accepted || accepted.patches.length === 0) return;
|
|
1709
1768
|
patches = accepted.patches;
|
|
1710
|
-
|
|
1769
|
+
let next = accepted.snapshot;
|
|
1770
|
+
let restoredReorder = false;
|
|
1771
|
+
const pointer = this.pointerReorder?.active ? this.pointerReorder : undefined;
|
|
1772
|
+
const keyboard = this.keyboardReorder;
|
|
1773
|
+
const reorder = pointer ?? keyboard;
|
|
1774
|
+
if (reorder) {
|
|
1775
|
+
const byKey = new Map(next.rows.map(row => [row.key, row]));
|
|
1776
|
+
reorder.originalRows = reorder.originalRows.map(row => byKey.get(row.key) ?? row);
|
|
1777
|
+
const source = byKey.get(reorder.sourceKey);
|
|
1778
|
+
const canContinue = pointer ? this.canStartPointerReorder(pointer, next) : source && isWebRowReorderable(next, source) && (next.capabilities?.reorderActivation !== 'handle' || hasWebReorderHandle(source));
|
|
1779
|
+
if (!canContinue) {
|
|
1780
|
+
if (pointer) this.cancelPointerReorder(false);
|
|
1781
|
+
if (keyboard) {
|
|
1782
|
+
this.keyboardReorder = undefined;
|
|
1783
|
+
this.updateReorderVisualState();
|
|
1784
|
+
}
|
|
1785
|
+
this.remapMountedRows(reorder.originalRows);
|
|
1786
|
+
next = {
|
|
1787
|
+
...next,
|
|
1788
|
+
rows: reorder.originalRows
|
|
1789
|
+
};
|
|
1790
|
+
restoredReorder = true;
|
|
1791
|
+
} else if (pointer) {
|
|
1792
|
+
pointer.workingRows = [...next.rows];
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1711
1795
|
const selection = new Set(this.selectedKeys);
|
|
1712
1796
|
patches.forEach(patch => {
|
|
1713
1797
|
const selected = 'selected' in patch.changes ? patch.changes.selected : undefined;
|
|
@@ -1719,7 +1803,7 @@ export class NativeListWebEngine {
|
|
|
1719
1803
|
after = next.rows[index];
|
|
1720
1804
|
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
1805
|
});
|
|
1722
|
-
if (webMarketImageBindDeltaForPatches(patches) === 0 || tableValuesOnly) {
|
|
1806
|
+
if (!restoredReorder && (webMarketImageBindDeltaForPatches(patches) === 0 || tableValuesOnly)) {
|
|
1723
1807
|
this.snapshot = next;
|
|
1724
1808
|
this.rows = effectiveRows(next);
|
|
1725
1809
|
this.selectedKeys = selection;
|
|
@@ -1880,6 +1964,10 @@ export class NativeListWebEngine {
|
|
|
1880
1964
|
this.viewport.removeEventListener('scroll', this.handleScroll);
|
|
1881
1965
|
(this.externalScrollHost ?? this.viewport).removeEventListener('ok-collapsible-pager-insets-changed', this.handleCollapsiblePagerInsetsChanged);
|
|
1882
1966
|
this.root.removeEventListener('click', this.handleClick);
|
|
1967
|
+
this.document.removeEventListener('pointerdown', this.trackReorderPress, true);
|
|
1968
|
+
this.document.removeEventListener('pointerup', this.trackReorderRelease, true);
|
|
1969
|
+
this.document.removeEventListener('pointercancel', this.trackReorderRelease, true);
|
|
1970
|
+
for (const id of this.reorderClickPointers.keys()) this.clearReorderClick(id);
|
|
1883
1971
|
this.root.removeEventListener('contextmenu', this.handleMarketContextMenu);
|
|
1884
1972
|
this.cancelMarketPointer();
|
|
1885
1973
|
this.root.removeEventListener('pointerdown', this.handleMarketPointerDown);
|
|
@@ -1930,6 +2018,7 @@ export class NativeListWebEngine {
|
|
|
1930
2018
|
this.pressedHelpElement = undefined;
|
|
1931
2019
|
this.measuredRendererHeights.clear();
|
|
1932
2020
|
this.snapshot = snapshot;
|
|
2021
|
+
setData(this.root, 'nativeListReorderActivation', snapshot.capabilities?.reorderActivation);
|
|
1933
2022
|
this.rows = effectiveRows(snapshot);
|
|
1934
2023
|
this.selectedKeys = selectedKeys ?? selectionStateFromSnapshot(snapshot).selectedKeys;
|
|
1935
2024
|
if (this.reachedGeneration !== snapshot.generation) this.reachedGeneration = undefined;
|
|
@@ -2157,6 +2246,7 @@ export class NativeListWebEngine {
|
|
|
2157
2246
|
this.content.appendChild(element);
|
|
2158
2247
|
}
|
|
2159
2248
|
this.positionElement(element, layoutItem);
|
|
2249
|
+
setData(element, 'nativeListReorderable', this.isReorderable(row));
|
|
2160
2250
|
const signature = webRowRenderSignature(row);
|
|
2161
2251
|
if (element.dataset.nativeListRowKey !== row.key || element.dataset.renderSignature !== signature) {
|
|
2162
2252
|
this.renderElement(element, layoutItem.index, row);
|
|
@@ -2689,7 +2779,8 @@ export class NativeListWebEngine {
|
|
|
2689
2779
|
const bindingEpoch = rowElement.dataset.nativeListBindingEpoch;
|
|
2690
2780
|
if (!source || !bindingEpoch || !rowElement.contains(actionElement)) return undefined;
|
|
2691
2781
|
this.invalidateActionAnchor('rebind');
|
|
2692
|
-
const
|
|
2782
|
+
const glyph = actionElement.querySelector(':scope > [data-native-list-anchor-glyph]');
|
|
2783
|
+
const actualRect = (glyph ?? actionElement).getBoundingClientRect();
|
|
2693
2784
|
const inset = Number(actionElement.dataset.nativeListAnchorInset ?? 0);
|
|
2694
2785
|
const rect = {
|
|
2695
2786
|
left: actualRect.left + inset,
|
|
@@ -2882,8 +2973,80 @@ export class NativeListWebEngine {
|
|
|
2882
2973
|
if (event.type === 'pointerout' && this.pressedHelpElement === action) this.pressedHelpElement = undefined;
|
|
2883
2974
|
if (this.actionAnchor?.actionElement === action) this.invalidateActionAnchor('pointerLeave');
|
|
2884
2975
|
};
|
|
2976
|
+
clearReorderClick(pointerId) {
|
|
2977
|
+
const pointer = this.reorderClickPointers.get(pointerId);
|
|
2978
|
+
if (pointer?.release) this.document.defaultView?.clearTimeout(pointer.release.timer);
|
|
2979
|
+
this.reorderClickPointers.delete(pointerId);
|
|
2980
|
+
return pointer;
|
|
2981
|
+
}
|
|
2982
|
+
reorderClickTarget(target, pressTarget) {
|
|
2983
|
+
if (!(target instanceof Element) || !this.root.contains(target)) return undefined;
|
|
2984
|
+
let clickTarget = target;
|
|
2985
|
+
if (pressTarget && this.root.contains(pressTarget)) {
|
|
2986
|
+
// An uncaptured click can target the common ancestor of two controls.
|
|
2987
|
+
while (clickTarget && !clickTarget.contains(pressTarget)) clickTarget = clickTarget.parentElement;
|
|
2988
|
+
}
|
|
2989
|
+
return clickTarget?.closest('[data-native-list-action],[data-native-list-group-member-key],[data-native-list-row-key]') ?? clickTarget ?? undefined;
|
|
2990
|
+
}
|
|
2991
|
+
trackReorderPress = event => {
|
|
2992
|
+
this.clearReorderClick(event.pointerId);
|
|
2993
|
+
if (event.isPrimary === false || event.button !== 0 || !(event.target instanceof Element) || !this.root.contains(event.target)) return;
|
|
2994
|
+
this.reorderClickPointers.set(event.pointerId, {
|
|
2995
|
+
suppress: false,
|
|
2996
|
+
pressTarget: event.target
|
|
2997
|
+
});
|
|
2998
|
+
};
|
|
2999
|
+
trackReorderRelease = event => {
|
|
3000
|
+
if (this.reorderClickPointers.size === 0) return;
|
|
3001
|
+
const {
|
|
3002
|
+
type,
|
|
3003
|
+
pointerId,
|
|
3004
|
+
clientX,
|
|
3005
|
+
clientY,
|
|
3006
|
+
pointerType,
|
|
3007
|
+
isPrimary,
|
|
3008
|
+
button
|
|
3009
|
+
} = event;
|
|
3010
|
+
const pending = this.clearReorderClick(pointerId);
|
|
3011
|
+
if (!pending || type !== 'pointerup' || isPrimary === false || button !== 0) return;
|
|
3012
|
+
const releaseTarget = event.target === this.viewport && this.viewport.hasPointerCapture?.(pointerId) ? this.document.elementFromPoint?.(clientX, clientY) ?? event.target : event.target;
|
|
3013
|
+
const target = this.reorderClickTarget(releaseTarget, pending.pressTarget);
|
|
3014
|
+
if (!pending.suppress && !target) return;
|
|
3015
|
+
|
|
3016
|
+
// Start expiry at release so a cancelled reorder stays suppressed while held.
|
|
3017
|
+
const view = this.document.defaultView;
|
|
3018
|
+
if (!view) return;
|
|
3019
|
+
const timer = view.setTimeout(() => this.reorderClickPointers.delete(pointerId), REORDER_CLICK_GRACE_MS);
|
|
3020
|
+
this.reorderClickPointers.set(pointerId, {
|
|
3021
|
+
suppress: pending.suppress,
|
|
3022
|
+
release: {
|
|
3023
|
+
target,
|
|
3024
|
+
clientX,
|
|
3025
|
+
clientY,
|
|
3026
|
+
pointerType,
|
|
3027
|
+
timer
|
|
3028
|
+
}
|
|
3029
|
+
});
|
|
3030
|
+
};
|
|
3031
|
+
legacyClickPointerId(event) {
|
|
3032
|
+
// Keyboard and programmatic activations have detail 0.
|
|
3033
|
+
if (!(event.detail > 0)) return undefined;
|
|
3034
|
+
const target = this.reorderClickTarget(event.target);
|
|
3035
|
+
if (!target) return undefined;
|
|
3036
|
+
const fromTouch = event.sourceCapabilities?.firesTouchEvents;
|
|
3037
|
+
let match;
|
|
3038
|
+
// A release inserts at the end of the map. Keep the latest matching release.
|
|
3039
|
+
for (const [pointerId, {
|
|
3040
|
+
release
|
|
3041
|
+
}] of this.reorderClickPointers) {
|
|
3042
|
+
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;
|
|
3043
|
+
}
|
|
3044
|
+
return match;
|
|
3045
|
+
}
|
|
2885
3046
|
handleClick = event => {
|
|
2886
|
-
|
|
3047
|
+
const pointerId = event.pointerId ?? (this.reorderClickPointers.size > 0 ? this.legacyClickPointerId(event) : undefined);
|
|
3048
|
+
const clickFromReorder = pointerId !== undefined && this.clearReorderClick(pointerId)?.suppress;
|
|
3049
|
+
if (this.marketLongPressFired || clickFromReorder) {
|
|
2887
3050
|
this.marketLongPressFired = false;
|
|
2888
3051
|
event.preventDefault();
|
|
2889
3052
|
event.stopPropagation();
|
|
@@ -2963,7 +3126,8 @@ export class NativeListWebEngine {
|
|
|
2963
3126
|
const row = this.rowAtElement(target.closest('[data-native-list-row-key]'));
|
|
2964
3127
|
if (!row) return;
|
|
2965
3128
|
event.preventDefault();
|
|
2966
|
-
|
|
3129
|
+
const hasHandle = target.closest('[data-native-list-row-key]')?.querySelector('[data-native-list-reorder-handle]');
|
|
3130
|
+
if (event.key === ' ' && this.isReorderable(row) && (this.keyboardReorder || this.snapshot.capabilities?.reorderActivation !== 'handle' || hasHandle)) {
|
|
2967
3131
|
if (this.keyboardReorder) this.finishKeyboardReorder();else this.startKeyboardReorder(row);
|
|
2968
3132
|
return;
|
|
2969
3133
|
}
|
|
@@ -2997,9 +3161,7 @@ export class NativeListWebEngine {
|
|
|
2997
3161
|
viewPosition: 0,
|
|
2998
3162
|
viewOffset: 0
|
|
2999
3163
|
});
|
|
3000
|
-
|
|
3001
|
-
preventScroll: true
|
|
3002
|
-
});
|
|
3164
|
+
this.focusMountedRow(state.sourceKey);
|
|
3003
3165
|
}
|
|
3004
3166
|
finishKeyboardReorder() {
|
|
3005
3167
|
const state = this.keyboardReorder;
|
|
@@ -3019,7 +3181,10 @@ export class NativeListWebEngine {
|
|
|
3019
3181
|
rows: cancelWebReorderRows(state.originalRows)
|
|
3020
3182
|
}, this.selectedKeys);
|
|
3021
3183
|
this.updateReorderVisualState();
|
|
3022
|
-
|
|
3184
|
+
this.focusMountedRow(state.sourceKey);
|
|
3185
|
+
}
|
|
3186
|
+
focusMountedRow(key) {
|
|
3187
|
+
[...this.mounted.values()].find(element => element.dataset.nativeListRowKey === key)?.focus({
|
|
3023
3188
|
preventScroll: true
|
|
3024
3189
|
});
|
|
3025
3190
|
}
|
|
@@ -3144,7 +3309,11 @@ export class NativeListWebEngine {
|
|
|
3144
3309
|
}
|
|
3145
3310
|
const target = event.target;
|
|
3146
3311
|
if (!(target instanceof Element)) return;
|
|
3147
|
-
|
|
3312
|
+
const handleMode = this.snapshot.capabilities?.reorderActivation === 'handle';
|
|
3313
|
+
const handle = handleMode ? target.closest('[data-native-list-reorder-handle]') : undefined;
|
|
3314
|
+
const control = target.closest('button,input,textarea,select,a');
|
|
3315
|
+
if (handleMode && !handle) return;
|
|
3316
|
+
if (control && (control !== handle || control.matches(':disabled'))) return;
|
|
3148
3317
|
const rowElement = target.closest('[data-native-list-row-index]');
|
|
3149
3318
|
const index = Number(rowElement?.dataset.nativeListRowIndex);
|
|
3150
3319
|
const row = this.rows[index];
|
|
@@ -3164,6 +3333,8 @@ export class NativeListWebEngine {
|
|
|
3164
3333
|
pointerId: event.pointerId,
|
|
3165
3334
|
pointerType: event.pointerType || 'mouse',
|
|
3166
3335
|
sourceKey: row.key,
|
|
3336
|
+
memberKey,
|
|
3337
|
+
handle: handle ?? undefined,
|
|
3167
3338
|
currentIndex: index,
|
|
3168
3339
|
startX: event.clientX,
|
|
3169
3340
|
startY: event.clientY,
|
|
@@ -3179,10 +3350,31 @@ export class NativeListWebEngine {
|
|
|
3179
3350
|
state.longPressTimer = view?.setTimeout(() => this.activatePointerReorder(state), REORDER_TOUCH_LONG_PRESS_MS);
|
|
3180
3351
|
}
|
|
3181
3352
|
};
|
|
3353
|
+
canStartPointerReorder(state, snapshot) {
|
|
3354
|
+
const row = snapshot.rows.find(candidate => candidate.key === state.sourceKey);
|
|
3355
|
+
if (!row || !isWebRowReorderable(snapshot, row) || !canStartWebWalletGroupReorder(row, state.memberKey)) return false;
|
|
3356
|
+
if (!state.handle) return true;
|
|
3357
|
+
const handleRow = row.type === 'walletGroup' ? [row.parent, ...row.children].find(member => member.key === state.memberKey) : row;
|
|
3358
|
+
const slot = Number(state.handle.dataset.nativeListAnchorSlot);
|
|
3359
|
+
return Boolean(handleRow && 'trailing' in handleRow && handleRow.trailing?.[slot]?.kind === 'drag');
|
|
3360
|
+
}
|
|
3182
3361
|
activatePointerReorder(state) {
|
|
3183
3362
|
if (this.pointerReorder !== state) return;
|
|
3363
|
+
const rowIndex = this.snapshot.rows.findIndex(row => row.key === state.sourceKey);
|
|
3364
|
+
const source = this.mounted.get(rowIndex);
|
|
3365
|
+
if (!source || !this.canStartPointerReorder(state, this.snapshot) || state.handle && !source.contains(state.handle)) {
|
|
3366
|
+
this.cancelPointerReorder(false);
|
|
3367
|
+
return;
|
|
3368
|
+
}
|
|
3184
3369
|
this.clearReorderLongPress(state);
|
|
3370
|
+
state.currentIndex = rowIndex;
|
|
3371
|
+
state.originalRows = this.snapshot.rows;
|
|
3372
|
+
state.workingRows = [...this.snapshot.rows];
|
|
3185
3373
|
state.active = true;
|
|
3374
|
+
this.reorderClickPointers.set(state.pointerId, {
|
|
3375
|
+
suppress: true,
|
|
3376
|
+
pressTarget: this.reorderClickPointers.get(state.pointerId)?.pressTarget
|
|
3377
|
+
});
|
|
3186
3378
|
this.cancelMarketPointer();
|
|
3187
3379
|
state.activatedAt = Date.now();
|
|
3188
3380
|
state.viewportRect = this.reorderViewportRect();
|
|
@@ -3537,7 +3729,6 @@ export class NativeListWebEngine {
|
|
|
3537
3729
|
this.pointerReorder = undefined;
|
|
3538
3730
|
this.stopReorderMove();
|
|
3539
3731
|
this.stopReorderAutoScroll();
|
|
3540
|
-
this.suppressClickUntil = Date.now() + 300;
|
|
3541
3732
|
this.updateReorderVisualState();
|
|
3542
3733
|
if (reorderEvent) this.callbacks.onReorder?.(reorderEvent);
|
|
3543
3734
|
}
|
|
@@ -3565,7 +3756,6 @@ export class NativeListWebEngine {
|
|
|
3565
3756
|
...this.snapshot,
|
|
3566
3757
|
rows: cancelWebReorderRows(state.originalRows)
|
|
3567
3758
|
}, this.selectedKeys);
|
|
3568
|
-
this.suppressClickUntil = Date.now() + 300;
|
|
3569
3759
|
}
|
|
3570
3760
|
if (state.active && restore) this.animateReorderPreviewToCurrent(state);else this.hideReorderPreview();
|
|
3571
3761
|
this.updateReorderVisualState();
|
|
@@ -384,7 +384,7 @@ function bindHistory(body, row, primitives) {
|
|
|
384
384
|
// the one native label does. A prefix wider than the row is capped instead,
|
|
385
385
|
// or it would squeeze the action to nothing and leave no pointer target.
|
|
386
386
|
v.descriptionPrefix.style.cssText = `${ellipsis}flex-shrink:0;max-width:${actionText ? `calc(100% - ${descriptionActionReserve})` : '100%'};white-space:pre;display:${actionStart > 0 ? 'block' : 'none'}`;
|
|
387
|
-
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:${actionText ? 'block' : 'none'};`;
|
|
387
|
+
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:${actionText ? 'block' : 'none'};`;
|
|
388
388
|
v.descriptionAction.textContent = actionText;
|
|
389
389
|
v.description.style.display = row.description ? 'flex' : 'none';
|
|
390
390
|
v.descriptionAction.tabIndex = boundAction ? 0 : -1;
|
|
@@ -14,6 +14,10 @@ function toneColor(tone, fallback) {
|
|
|
14
14
|
function appendAccessories(parent, document, primitives, row, accessories) {
|
|
15
15
|
if (!accessories?.length) return;
|
|
16
16
|
const container = createElement(document, 'span', 'ok-native-list-accessories');
|
|
17
|
+
|
|
18
|
+
// ListItem's rename + drag pair sits in <XStack gap="$6">; iOS and Android
|
|
19
|
+
// lay the same pair out natively.
|
|
20
|
+
if (accessories.length === 2 && accessories[0].kind === 'icon' && accessories[0].name === 'PencilOutline' && accessories[1].kind === 'drag') container.style.gap = '24px';
|
|
17
21
|
if (row && hasExplicitRowHeight(row) && 'presentation' in row && row.presentation === 'networkSelector') {
|
|
18
22
|
container.style.gap = accessories.some(accessory => accessory.kind === 'checkbox') ? '12px' : '20px';
|
|
19
23
|
}
|
|
@@ -39,8 +43,15 @@ function createIdentityRow(document, primitives, row) {
|
|
|
39
43
|
markActionAnchorSource(body, 'leadingAction');
|
|
40
44
|
}
|
|
41
45
|
if (row.leadingAction) {
|
|
42
|
-
const action = primitives.iconAction(row.leadingAction.name, row.leadingAction.actionKey, row.leadingAction.disabled, row.leadingAction.tintColor);
|
|
46
|
+
const action = primitives.iconAction(row.leadingAction.name, row.leadingAction.actionKey, row.leadingAction.disabled, row.leadingAction.tintColor, row.leadingAction.accessibilityLabel);
|
|
43
47
|
markActionAnchorSource(action, 'leadingAction');
|
|
48
|
+
// ListItem.IconButton geometry, as on iOS and Android: the medium tertiary
|
|
49
|
+
// frame overhangs its 24-point slot by 7 on each side.
|
|
50
|
+
action.classList.add('ok-native-list-tertiary-icon');
|
|
51
|
+
const glyph = createElement(document, 'span', 'ok-native-list-action-glyph');
|
|
52
|
+
glyph.dataset.nativeListAnchorGlyph = '';
|
|
53
|
+
glyph.append(...action.childNodes);
|
|
54
|
+
action.append(glyph);
|
|
44
55
|
body.appendChild(action);
|
|
45
56
|
}
|
|
46
57
|
const visual = primitives.visual(row.leading, hasExplicitRowHeight(row) ? presentation : undefined);
|
|
@@ -27,6 +27,8 @@ function applyMarketTextStyle(element, style, defaults) {
|
|
|
27
27
|
element.style.lineHeight = String(style?.lineHeight ?? defaults.lineHeight) + 'px';
|
|
28
28
|
applyTextWeight(element, String(fontWeight(style?.fontWeight, defaults.weight)));
|
|
29
29
|
element.style.color = style?.color ?? '';
|
|
30
|
+
element.style.letterSpacing = '';
|
|
31
|
+
element.style.fontVariantNumeric = '';
|
|
30
32
|
element.style.textAlign = style?.alignment ?? defaults.alignment;
|
|
31
33
|
element.style.whiteSpace = (style?.lines ?? 1) > 1 ? 'normal' : 'nowrap';
|
|
32
34
|
element.style.display = '';
|
|
@@ -48,8 +48,8 @@ export function createBadge(document, badge) {
|
|
|
48
48
|
// Selector digits retain their font family, including explicit button fonts.
|
|
49
49
|
export function applyTabularNumbers(body) {
|
|
50
50
|
body.style.fontVariantNumeric = 'tabular-nums';
|
|
51
|
-
body.querySelectorAll('
|
|
52
|
-
|
|
51
|
+
body.querySelectorAll('button').forEach(button => {
|
|
52
|
+
if (!button.style.fontVariantNumeric) button.style.fontVariantNumeric = 'inherit';
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -96,6 +96,8 @@ export function applyTextStyleToSlot(element, style, defaultLines) {
|
|
|
96
96
|
if (style.lineHeight !== undefined) element.style.lineHeight = String(style.lineHeight) + 'px';
|
|
97
97
|
if (style.fontWeight !== undefined) applyTextWeight(element, String(fontWeight(style.fontWeight, 400)));
|
|
98
98
|
if (style.color !== undefined) element.style.color = style.color;
|
|
99
|
+
if (style.tabularNumbers !== undefined) element.style.fontVariantNumeric = style.tabularNumbers ? 'tabular-nums' : 'proportional-nums';
|
|
100
|
+
if (style.letterSpacing !== undefined) element.style.letterSpacing = String(style.letterSpacing) + 'px';
|
|
99
101
|
// Explicit overrides also apply to rich text runs, but never to sibling badges.
|
|
100
102
|
// Subscript segments keep their legacy size relative to the field size.
|
|
101
103
|
element.querySelectorAll('span').forEach(run => {
|
|
@@ -51,6 +51,10 @@ export type NativeListTextStyle = Readonly<{
|
|
|
51
51
|
verticalAlignment?: 'top' | 'center' | 'bottom';
|
|
52
52
|
/** Optical translation in logical units; does not affect layout. */
|
|
53
53
|
offsetY?: number;
|
|
54
|
+
/** Extra spacing between glyphs in logical units. An explicit 0 turns off the platform's pair kerning on iOS, matching React Native `letterSpacing: 0`. */
|
|
55
|
+
letterSpacing?: number;
|
|
56
|
+
/** Equal-width (tabular) digits, matching the App's `SizableText` default. Omission keeps each template's current digits. */
|
|
57
|
+
tabularNumbers?: boolean;
|
|
54
58
|
}>;
|
|
55
59
|
/** Retained alias: Market shipped this name before the style surface was shared. */
|
|
56
60
|
export type MarketTextStyle = NativeListTextStyle;
|
|
@@ -254,6 +258,8 @@ type VisualWithImage = Readonly<{
|
|
|
254
258
|
overlays?: readonly VisualOverlay[];
|
|
255
259
|
borderStyle?: 'dashed';
|
|
256
260
|
borderColor?: string;
|
|
261
|
+
/** Solid border width in logical units (0 < width <= 4); defaults to 1. Use the host's hairline width for a hairline. */
|
|
262
|
+
borderWidth?: number;
|
|
257
263
|
image?: ImageSource;
|
|
258
264
|
fallbackText?: string;
|
|
259
265
|
fallbackTextColor?: string;
|
|
@@ -441,6 +447,8 @@ export type IdentityRow = RowBase & Readonly<{
|
|
|
441
447
|
titleLines?: 1 | 2;
|
|
442
448
|
/** Zero displays the complete subtitle. */
|
|
443
449
|
subtitleLines?: 0 | 1 | 2;
|
|
450
|
+
/** Drop the trailing column (and its gap) when the row has no trailing accessories. Omitted keeps the legacy 12-point reservation. */
|
|
451
|
+
collapseEmptyTrailing?: boolean;
|
|
444
452
|
badges?: readonly BadgeModel[];
|
|
445
453
|
trailing?: readonly TrailingAccessory[];
|
|
446
454
|
draggable?: boolean;
|
|
@@ -877,6 +885,12 @@ export type NativeListSnapshot = Readonly<{
|
|
|
877
885
|
}>;
|
|
878
886
|
capabilities?: Readonly<{
|
|
879
887
|
reorderable?: boolean;
|
|
888
|
+
/**
|
|
889
|
+
* `row` (default) starts a reorder from a long press anywhere on a
|
|
890
|
+
* reorderable row. `handle` starts it only from a long press on the
|
|
891
|
+
* row's trailing `drag` accessory.
|
|
892
|
+
*/
|
|
893
|
+
reorderActivation?: 'row' | 'handle';
|
|
880
894
|
pullToRefresh?: boolean;
|
|
881
895
|
refreshing?: boolean;
|
|
882
896
|
refreshTriggerDistance?: number;
|
|
@@ -897,7 +911,7 @@ export type PatchClearableChanges<Row, Keys extends keyof Row> = Readonly<{
|
|
|
897
911
|
export type RowPatch = Readonly<{
|
|
898
912
|
type: 'identity';
|
|
899
913
|
key: string;
|
|
900
|
-
changes: PatchClearableChanges<IdentityRow, CommonPatchFields | 'title' | 'titleSuffixes' | 'titleIcon' | 'secondaryTitleIcon' | 'titleImage' | 'subtitle' | 'subtitleLines' | 'contentHeight' | 'longPressActionKey' | 'tertiary' | 'tertiaryTone' | 'badges' | 'trailing' | 'leading' | 'leadingAction' | 'titleMatch' | 'titleActionKey' | 'titleActionOnHover' | 'subtitleSegments'>;
|
|
914
|
+
changes: PatchClearableChanges<IdentityRow, CommonPatchFields | 'title' | 'titleSuffixes' | 'titleIcon' | 'secondaryTitleIcon' | 'titleImage' | 'subtitle' | 'subtitleLines' | 'collapseEmptyTrailing' | 'contentHeight' | 'longPressActionKey' | 'tertiary' | 'tertiaryTone' | 'badges' | 'trailing' | 'leading' | 'leadingAction' | 'titleMatch' | 'titleActionKey' | 'titleActionOnHover' | 'subtitleSegments'>;
|
|
901
915
|
}> | Readonly<{
|
|
902
916
|
type: 'rail';
|
|
903
917
|
key: string;
|