@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.
- package/android/build.gradle +3 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +18 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +70 -33
- 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/NativeListRendererRowView.kt +21 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListRowUpdates.kt +34 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
- package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentitySubtitleBindingTest.kt +177 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
- package/docs/SPEC.md +127 -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
|
@@ -7,6 +7,19 @@ enum NativeListTopScrollEdgeEffect {
|
|
|
7
7
|
case none, hard, soft
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
private final class NativeListReorderLongPress: UILongPressGestureRecognizer {
|
|
11
|
+
var sourceItem: NativeListItem?
|
|
12
|
+
var bindingEpoch: Int?
|
|
13
|
+
weak var handle: NativeListAccessoryButton?
|
|
14
|
+
|
|
15
|
+
override func reset() {
|
|
16
|
+
super.reset()
|
|
17
|
+
sourceItem = nil
|
|
18
|
+
bindingEpoch = nil
|
|
19
|
+
handle = nil
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
final class NativeListView: UIView {
|
|
11
24
|
private var fonts = NativeListFontFamilies()
|
|
12
25
|
|
|
@@ -722,7 +735,7 @@ final class NativeListView: UIView {
|
|
|
722
735
|
private var pagerCommandCancelObserver: NSObjectProtocol?
|
|
723
736
|
private var pendingScrollRequest: ScrollRequest?
|
|
724
737
|
private let sectionIndexFeedback = UISelectionFeedbackGenerator()
|
|
725
|
-
private lazy var reorderLongPress =
|
|
738
|
+
private lazy var reorderLongPress = NativeListReorderLongPress(
|
|
726
739
|
target: self,
|
|
727
740
|
action: #selector(reorderLongPressChanged(_:))
|
|
728
741
|
)
|
|
@@ -756,6 +769,8 @@ final class NativeListView: UIView {
|
|
|
756
769
|
private let reorderStartFeedback = UIImpactFeedbackGenerator(style: .medium)
|
|
757
770
|
private let reorderMoveFeedback = UISelectionFeedbackGenerator()
|
|
758
771
|
private var interactiveReorderFeedbackIndex: Int?
|
|
772
|
+
/// Ancestor pans (for example a sheet's dismiss pan) paused while a reorder is active.
|
|
773
|
+
private var reorderSuspendedAncestorPans: [UIGestureRecognizer] = []
|
|
759
774
|
private var interactiveMovementKeys: [String]?
|
|
760
775
|
private var actionAnchor: ActionAnchorRecord?
|
|
761
776
|
private let actionAnchorInstanceID = UUID().uuidString
|
|
@@ -1102,6 +1117,13 @@ final class NativeListView: UIView {
|
|
|
1102
1117
|
|
|
1103
1118
|
func applySnapshotJson(_ json: String) {
|
|
1104
1119
|
guard let next = try? NativeListConfig.parse(json: json) else { return }
|
|
1120
|
+
if let current = config,
|
|
1121
|
+
current.reorderable != next.reorderable ||
|
|
1122
|
+
current.reorderFromHandleOnly != next.reorderFromHandleOnly {
|
|
1123
|
+
cancelInteractiveReorderForStructuralUpdate()
|
|
1124
|
+
reorderLongPress.isEnabled = false
|
|
1125
|
+
reorderLongPress.isEnabled = true
|
|
1126
|
+
}
|
|
1105
1127
|
let transition = next.structuralTransition
|
|
1106
1128
|
let isNewTransition = transition != nil && transition?.id != consumedStructuralTransitionID
|
|
1107
1129
|
let disclosureGeometryInvalid = deferredDisclosureGeometryInvalid
|
|
@@ -2022,11 +2044,12 @@ final class NativeListView: UIView {
|
|
|
2022
2044
|
let point = gesture.location(in: collectionView)
|
|
2023
2045
|
guard let current = config,
|
|
2024
2046
|
current.reorderable,
|
|
2025
|
-
let indexPath =
|
|
2047
|
+
let indexPath = reorderSourceIndexPath(at: point),
|
|
2026
2048
|
let item = item(at: indexPath),
|
|
2027
2049
|
item.isReorderable,
|
|
2028
2050
|
let cell = collectionView.cellForItem(at: indexPath) as? NativeListRowHost,
|
|
2029
|
-
|
|
2051
|
+
(current.reorderFromHandleOnly ||
|
|
2052
|
+
cell.canStartWalletGroupReorder(at: gesture.location(in: cell))) else {
|
|
2030
2053
|
interactiveReorderSource = nil
|
|
2031
2054
|
interactiveReorderCell = nil
|
|
2032
2055
|
interactiveReorderTargetIndex = nil
|
|
@@ -2077,6 +2100,7 @@ final class NativeListView: UIView {
|
|
|
2077
2100
|
interactiveMovementKeys = dataSource.snapshot().itemIdentifiers
|
|
2078
2101
|
}
|
|
2079
2102
|
interactiveReorderFeedbackIndex = indexPath.item
|
|
2103
|
+
suspendAncestorPansForReorder()
|
|
2080
2104
|
reorderStartFeedback.impactOccurred(intensity: 0.7)
|
|
2081
2105
|
reorderStartFeedback.prepare()
|
|
2082
2106
|
reorderMoveFeedback.prepare()
|
|
@@ -2118,6 +2142,42 @@ final class NativeListView: UIView {
|
|
|
2118
2142
|
}
|
|
2119
2143
|
}
|
|
2120
2144
|
|
|
2145
|
+
// NativeOverlay implements this optional UIKit coordination hook to retain
|
|
2146
|
+
// ownership of its current dismiss policy. The packages can load independently.
|
|
2147
|
+
private static let setPanReorderSuppressed =
|
|
2148
|
+
NSSelectorFromString("setOneKeyNativeListReorderSuppressed:")
|
|
2149
|
+
|
|
2150
|
+
/// A reorder that has started owns the drag: an enclosing sheet or pager must
|
|
2151
|
+
/// not also pan (and dismiss or page) with the same finger.
|
|
2152
|
+
private func suspendAncestorPansForReorder() {
|
|
2153
|
+
resumeAncestorPansAfterReorder()
|
|
2154
|
+
var view = collectionView.superview
|
|
2155
|
+
while let current = view {
|
|
2156
|
+
for recognizer in current.gestureRecognizers ?? []
|
|
2157
|
+
where recognizer is UIPanGestureRecognizer && recognizer.delegate !== self {
|
|
2158
|
+
if recognizer.responds(to: Self.setPanReorderSuppressed) {
|
|
2159
|
+
_ = recognizer.perform(Self.setPanReorderSuppressed, with: NSNumber(value: true))
|
|
2160
|
+
} else {
|
|
2161
|
+
guard recognizer.isEnabled else { continue }
|
|
2162
|
+
recognizer.isEnabled = false
|
|
2163
|
+
}
|
|
2164
|
+
reorderSuspendedAncestorPans.append(recognizer)
|
|
2165
|
+
}
|
|
2166
|
+
view = current.superview
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
private func resumeAncestorPansAfterReorder() {
|
|
2171
|
+
for recognizer in reorderSuspendedAncestorPans {
|
|
2172
|
+
if recognizer.responds(to: Self.setPanReorderSuppressed) {
|
|
2173
|
+
_ = recognizer.perform(Self.setPanReorderSuppressed, with: NSNumber(value: false))
|
|
2174
|
+
} else {
|
|
2175
|
+
recognizer.isEnabled = true
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
reorderSuspendedAncestorPans.removeAll()
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2121
2181
|
private func nearestReorderIndexPath(to point: CGPoint) -> IndexPath? {
|
|
2122
2182
|
let isHorizontal = config?.orientation == "horizontal"
|
|
2123
2183
|
return collectionView.indexPathsForVisibleItems.min { lhs, rhs in
|
|
@@ -2175,6 +2235,7 @@ final class NativeListView: UIView {
|
|
|
2175
2235
|
}
|
|
2176
2236
|
|
|
2177
2237
|
private func finishInteractiveReorder(cancelled: Bool) {
|
|
2238
|
+
resumeAncestorPansAfterReorder()
|
|
2178
2239
|
interactiveReorderLockedCrossAxisPosition = nil
|
|
2179
2240
|
if interactiveReorderUsesAtomicTargeting {
|
|
2180
2241
|
finishAtomicInteractiveReorder(cancelled: cancelled)
|
|
@@ -2219,6 +2280,7 @@ final class NativeListView: UIView {
|
|
|
2219
2280
|
|
|
2220
2281
|
private func cancelInteractiveReorderForStructuralUpdate() {
|
|
2221
2282
|
guard interactiveReorderSource != nil else { return }
|
|
2283
|
+
resumeAncestorPansAfterReorder()
|
|
2222
2284
|
interactiveReorderAnimator?.stopAnimation(true)
|
|
2223
2285
|
interactiveReorderAnimator = nil
|
|
2224
2286
|
interactiveMovementKeys = nil
|
|
@@ -2862,6 +2924,7 @@ final class NativeListView: UIView {
|
|
|
2862
2924
|
current.selectionMode == next.selectionMode,
|
|
2863
2925
|
current.rowPressToggles == next.rowPressToggles,
|
|
2864
2926
|
current.reorderable == next.reorderable,
|
|
2927
|
+
current.reorderFromHandleOnly == next.reorderFromHandleOnly,
|
|
2865
2928
|
current.pullToRefresh == next.pullToRefresh,
|
|
2866
2929
|
current.refreshTriggerDistance == next.refreshTriggerDistance,
|
|
2867
2930
|
current.refreshing == next.refreshing,
|
|
@@ -2874,26 +2937,23 @@ final class NativeListView: UIView {
|
|
|
2874
2937
|
current.fixedFooter?.content == next.fixedFooter?.content,
|
|
2875
2938
|
current.items.count == next.items.count else { return false }
|
|
2876
2939
|
|
|
2940
|
+
let controlled = next.selectionMode == "single" || next.selectionMode == "multiple"
|
|
2877
2941
|
return zip(current.items, next.items).allSatisfy { old, new in
|
|
2878
|
-
|
|
2879
|
-
if old.content == new.content { return true }
|
|
2880
|
-
// OneKey patch: controlled echoes can also update row and checkbox selection fields.
|
|
2881
|
-
// guard old.type == "sectionHeader",
|
|
2882
|
-
// old.data.string("variant") == "summary",
|
|
2883
|
-
// new.data.string("variant") == "summary" else { return false }
|
|
2884
|
-
// var oldData = old.data
|
|
2885
|
-
// var newData = new.data
|
|
2886
|
-
// oldData.removeValue(forKey: "title")
|
|
2887
|
-
// oldData.removeValue(forKey: "value")
|
|
2888
|
-
// newData.removeValue(forKey: "title")
|
|
2889
|
-
// newData.removeValue(forKey: "value")
|
|
2890
|
-
let controlled = next.selectionMode == "single" || next.selectionMode == "multiple"
|
|
2891
|
-
guard let oldData = selectionComparisonData(old.data, controlled: controlled),
|
|
2892
|
-
let newData = selectionComparisonData(new.data, controlled: controlled) else { return false }
|
|
2893
|
-
return jsonData(oldData) == jsonData(newData)
|
|
2942
|
+
isStableSelectionUpdate(from: old, to: new, controlled: controlled)
|
|
2894
2943
|
}
|
|
2895
2944
|
}
|
|
2896
2945
|
|
|
2946
|
+
// The lightweight selection rebind leaves the original row and controls mounted.
|
|
2947
|
+
private func isStableSelectionUpdate(
|
|
2948
|
+
from old: NativeListItem, to new: NativeListItem, controlled: Bool
|
|
2949
|
+
) -> Bool {
|
|
2950
|
+
guard old.key == new.key, old.type == new.type else { return false }
|
|
2951
|
+
if old.content == new.content { return true }
|
|
2952
|
+
guard let oldData = selectionComparisonData(old.data, controlled: controlled),
|
|
2953
|
+
let newData = selectionComparisonData(new.data, controlled: controlled) else { return false }
|
|
2954
|
+
return jsonData(oldData) == jsonData(newData)
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2897
2957
|
private func canDeferSnapshotDuringInteractiveReorder(
|
|
2898
2958
|
from current: NativeListConfig,
|
|
2899
2959
|
to next: NativeListConfig
|
|
@@ -2909,6 +2969,7 @@ final class NativeListView: UIView {
|
|
|
2909
2969
|
current.contentPaddingBottom == next.contentPaddingBottom,
|
|
2910
2970
|
current.itemSpacing == next.itemSpacing,
|
|
2911
2971
|
current.reorderable == next.reorderable,
|
|
2972
|
+
current.reorderFromHandleOnly == next.reorderFromHandleOnly,
|
|
2912
2973
|
current.sectionIndexEnabled == next.sectionIndexEnabled,
|
|
2913
2974
|
current.items.count == next.items.count,
|
|
2914
2975
|
hasSameFooterGeometry(current.fixedFooter, next.fixedFooter) else { return false }
|
|
@@ -3161,6 +3222,7 @@ final class NativeListView: UIView {
|
|
|
3161
3222
|
keyboardDragRecognizer.delegate = nil
|
|
3162
3223
|
listBodyGestureGuard.delegate = nil
|
|
3163
3224
|
reorderLongPress.delegate = nil
|
|
3225
|
+
resumeAncestorPansAfterReorder()
|
|
3164
3226
|
marketLongPress.delegate = nil
|
|
3165
3227
|
|
|
3166
3228
|
for case let cell as NativeListRowHost in collectionView.visibleCells {
|
|
@@ -3348,13 +3410,33 @@ final class NativeListView: UIView {
|
|
|
3348
3410
|
}.sorted()
|
|
3349
3411
|
}
|
|
3350
3412
|
|
|
3413
|
+
private func reorderSourceIndexPath(at point: CGPoint) -> IndexPath? {
|
|
3414
|
+
guard config?.reorderFromHandleOnly == true else {
|
|
3415
|
+
return collectionView.indexPathForItem(at: point)
|
|
3416
|
+
}
|
|
3417
|
+
let controlled = config?.selectionMode == "single" || config?.selectionMode == "multiple"
|
|
3418
|
+
guard let original = reorderLongPress.sourceItem,
|
|
3419
|
+
let handle = reorderLongPress.handle, handle.isReorderHandle,
|
|
3420
|
+
let indexPath = dataSource.indexPath(for: original.key),
|
|
3421
|
+
let cell = collectionView.cellForItem(at: indexPath) as? NativeListRowHost,
|
|
3422
|
+
cell.bindingEpoch == reorderLongPress.bindingEpoch,
|
|
3423
|
+
handle.isDescendant(of: cell),
|
|
3424
|
+
let current = item(at: indexPath),
|
|
3425
|
+
isStableSelectionUpdate(from: original, to: current, controlled: controlled)
|
|
3426
|
+
else { return nil }
|
|
3427
|
+
return indexPath
|
|
3428
|
+
}
|
|
3429
|
+
|
|
3351
3430
|
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
|
|
3352
3431
|
if gestureRecognizer === keyboardDragRecognizer {
|
|
3353
3432
|
return keyboardDismissMode == .onDrag && focusedTextInput(in: window) != nil
|
|
3354
3433
|
}
|
|
3355
3434
|
if gestureRecognizer === reorderLongPress || gestureRecognizer === marketLongPress {
|
|
3356
3435
|
let point = gestureRecognizer.location(in: collectionView)
|
|
3357
|
-
|
|
3436
|
+
let sourceIndexPath = gestureRecognizer === reorderLongPress
|
|
3437
|
+
? reorderSourceIndexPath(at: point)
|
|
3438
|
+
: collectionView.indexPathForItem(at: point)
|
|
3439
|
+
guard let indexPath = sourceIndexPath,
|
|
3358
3440
|
let item = item(at: indexPath), !isInertPresentationKey(item.key),
|
|
3359
3441
|
!item.data.bool("disabled") else { return false }
|
|
3360
3442
|
if gestureRecognizer === reorderLongPress {
|
|
@@ -3387,6 +3469,28 @@ extension NativeListView: UIGestureRecognizerDelegate {
|
|
|
3387
3469
|
}
|
|
3388
3470
|
}
|
|
3389
3471
|
if gestureRecognizer === listBodyGestureGuard { return true }
|
|
3472
|
+
if gestureRecognizer === reorderLongPress, config?.reorderFromHandleOnly == true {
|
|
3473
|
+
guard reorderLongPress.sourceItem == nil else { return false }
|
|
3474
|
+
var view = touch.view
|
|
3475
|
+
var handle: NativeListAccessoryButton?
|
|
3476
|
+
while let current = view, current !== footerCell, current !== collectionView {
|
|
3477
|
+
if let button = current as? NativeListAccessoryButton, button.isReorderHandle {
|
|
3478
|
+
handle = button
|
|
3479
|
+
}
|
|
3480
|
+
if let cell = current as? NativeListRowHost, let handle,
|
|
3481
|
+
let indexPath = collectionView.indexPath(for: cell),
|
|
3482
|
+
let item = item(at: indexPath), item.isReorderable,
|
|
3483
|
+
!isInertPresentationKey(item.key),
|
|
3484
|
+
cell.canStartWalletGroupReorder(at: touch.location(in: cell)) {
|
|
3485
|
+
reorderLongPress.sourceItem = item
|
|
3486
|
+
reorderLongPress.bindingEpoch = cell.bindingEpoch
|
|
3487
|
+
reorderLongPress.handle = handle
|
|
3488
|
+
return true
|
|
3489
|
+
}
|
|
3490
|
+
view = current.superview
|
|
3491
|
+
}
|
|
3492
|
+
return false
|
|
3493
|
+
}
|
|
3390
3494
|
var view = touch.view
|
|
3391
3495
|
while let current = view, current !== footerCell {
|
|
3392
3496
|
if current is UIControl { return false }
|
|
@@ -1203,6 +1203,111 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1203
1203
|
XCTAssertEqual(actions, ["continue", "footer-accessory"])
|
|
1204
1204
|
}
|
|
1205
1205
|
|
|
1206
|
+
func testPendingHandleReorderSurvivesSelectionEchoButRejectsHandleRemoval() throws {
|
|
1207
|
+
final class HandleTouch: UITouch {
|
|
1208
|
+
let handle: UIView
|
|
1209
|
+
init(handle: UIView) {
|
|
1210
|
+
self.handle = handle
|
|
1211
|
+
super.init()
|
|
1212
|
+
}
|
|
1213
|
+
override var view: UIView? { handle }
|
|
1214
|
+
override func location(in view: UIView?) -> CGPoint {
|
|
1215
|
+
handle.convert(CGPoint(x: handle.bounds.midX, y: handle.bounds.midY), to: view)
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
func findHandle(in view: UIView) -> NativeListAccessoryButton? {
|
|
1219
|
+
if let button = view as? NativeListAccessoryButton, button.isReorderHandle { return button }
|
|
1220
|
+
return view.subviews.lazy.compactMap { findHandle(in: $0) }.first
|
|
1221
|
+
}
|
|
1222
|
+
func snapshot(selected: Bool) throws -> String {
|
|
1223
|
+
let row: [String: Any] = [
|
|
1224
|
+
"type": "identity", "key": "source", "title": "Source", "height": 60,
|
|
1225
|
+
"selected": selected, "draggable": true, "trailing": [["kind": "drag"]],
|
|
1226
|
+
]
|
|
1227
|
+
let body: [String: Any] = [
|
|
1228
|
+
"schemaVersion": 1, "generation": 1, "layout": ["kind": "linear"],
|
|
1229
|
+
"capabilities": ["reorderable": true, "reorderActivation": "handle"],
|
|
1230
|
+
"selection": ["mode": "multiple", "selectedKeys": selected ? ["source"] : []],
|
|
1231
|
+
"rows": [row],
|
|
1232
|
+
]
|
|
1233
|
+
return String(decoding: try JSONSerialization.data(withJSONObject: body), as: UTF8.self)
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 390, height: 697))
|
|
1237
|
+
let controller = UIViewController()
|
|
1238
|
+
window.rootViewController = controller
|
|
1239
|
+
window.makeKeyAndVisible()
|
|
1240
|
+
let list = NativeListView(frame: window.bounds)
|
|
1241
|
+
controller.view.addSubview(list)
|
|
1242
|
+
defer {
|
|
1243
|
+
list.dispose()
|
|
1244
|
+
window.isHidden = true
|
|
1245
|
+
}
|
|
1246
|
+
list.applySnapshotJson(try snapshot(selected: false))
|
|
1247
|
+
window.layoutIfNeeded()
|
|
1248
|
+
list.layoutIfNeeded()
|
|
1249
|
+
let collection = try XCTUnwrap(list.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
1250
|
+
collection.layoutIfNeeded()
|
|
1251
|
+
let recognizer = try XCTUnwrap(collection.gestureRecognizers?.compactMap {
|
|
1252
|
+
$0 as? UILongPressGestureRecognizer
|
|
1253
|
+
}.first { String(describing: type(of: $0)) == "NativeListReorderLongPress" })
|
|
1254
|
+
let cell = try XCTUnwrap(collection.cellForItem(at: IndexPath(item: 0, section: 0)) as? NativeListRowHost)
|
|
1255
|
+
let handle = try XCTUnwrap(findHandle(in: cell))
|
|
1256
|
+
let epoch = cell.bindingEpoch
|
|
1257
|
+
XCTAssertTrue(list.gestureRecognizer(recognizer, shouldReceive: HandleTouch(handle: handle)))
|
|
1258
|
+
|
|
1259
|
+
list.applySnapshotJson(try snapshot(selected: true))
|
|
1260
|
+
XCTAssertEqual(cell.bindingEpoch, epoch)
|
|
1261
|
+
XCTAssertTrue(list.gestureRecognizerShouldBegin(recognizer))
|
|
1262
|
+
|
|
1263
|
+
list.applyPatchesJson(#"[{"type":"identity","key":"source","changes":{"trailing":[]}}]"#)
|
|
1264
|
+
XCTAssertFalse(list.gestureRecognizerShouldBegin(recognizer))
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
func testResolvedTrackingAffectsWidthAndIsClearedOnRebind() {
|
|
1268
|
+
let fonts = NativeListFontFamilies()
|
|
1269
|
+
func text(_ style: [String: Any]?) -> NativeListResolvedText {
|
|
1270
|
+
NativeListResolvedText("Wallet 123456", style: style, size: 16, color: .label,
|
|
1271
|
+
lineHeight: 24, lines: 1, tabular: true, fonts: fonts)
|
|
1272
|
+
}
|
|
1273
|
+
let label = NativeListTextLabel()
|
|
1274
|
+
let tracked = text(["letterSpacing": 4, "tabularNumbers": false])
|
|
1275
|
+
let standard = text(nil)
|
|
1276
|
+
tracked.bind(label)
|
|
1277
|
+
XCTAssertEqual(label.attributedText?.attribute(.kern, at: 0, effectiveRange: nil) as? CGFloat, 4)
|
|
1278
|
+
XCTAssertEqual(tracked.digitSpacing, false)
|
|
1279
|
+
XCTAssertGreaterThan(tracked.measureWidth(), standard.measureWidth())
|
|
1280
|
+
standard.bind(label)
|
|
1281
|
+
XCTAssertNil(label.attributedText?.attribute(.kern, at: 0, effectiveRange: nil))
|
|
1282
|
+
XCTAssertEqual(standard.digitSpacing, true)
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
func testAutoHeightIdentityAccountsForCollapsedTrailingAndTracking() throws {
|
|
1286
|
+
func item(collapse: Bool, tracking: Double) throws -> NativeListItem {
|
|
1287
|
+
try NativeListItem(data: [
|
|
1288
|
+
"key": "recipient", "type": "identity", "title": "Recipient",
|
|
1289
|
+
"subtitle": String(repeating: "Wallet 1234567890 ", count: 8),
|
|
1290
|
+
"subtitleLines": 0, "contentHeight": "auto",
|
|
1291
|
+
"collapseEmptyTrailing": collapse,
|
|
1292
|
+
"style": ["subtitle": ["letterSpacing": tracking]],
|
|
1293
|
+
])
|
|
1294
|
+
}
|
|
1295
|
+
func height(_ item: NativeListItem, width: CGFloat) throws -> CGFloat {
|
|
1296
|
+
try XCTUnwrap(NativeListIdentityCell.measure(
|
|
1297
|
+
item, width: width, theme: nil, layout: "linear", fonts: NativeListFontFamilies()))
|
|
1298
|
+
}
|
|
1299
|
+
let collapsed = try item(collapse: true, tracking: 0)
|
|
1300
|
+
let reserved = try item(collapse: false, tracking: 0)
|
|
1301
|
+
let tracked = try item(collapse: true, tracking: 4)
|
|
1302
|
+
let widths = stride(from: CGFloat(180), through: 260, by: 4)
|
|
1303
|
+
let differences = try widths.map { width in
|
|
1304
|
+
(try height(collapsed, width: width), try height(reserved, width: width),
|
|
1305
|
+
try height(tracked, width: width))
|
|
1306
|
+
}
|
|
1307
|
+
XCTAssertTrue(differences.contains { collapsed, reserved, _ in collapsed < reserved })
|
|
1308
|
+
XCTAssertTrue(differences.contains { collapsed, _, tracked in collapsed < tracked })
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1206
1311
|
func testFontResolversMeasureBindResetAndKeepIndependentInstances() throws {
|
|
1207
1312
|
let first = NativeListFontFamilies(names: ["regular": "Courier", "bold": "Courier-Bold"])
|
|
1208
1313
|
let second = NativeListFontFamilies(names: ["regular": "Georgia", "bold": "Georgia-Bold"])
|
package/lib/module/validation.js
CHANGED
|
@@ -184,7 +184,7 @@ function assertTextStyle(style, path, additionalKeys = []) {
|
|
|
184
184
|
if (typeof style !== 'object' || style === null || Array.isArray(style)) {
|
|
185
185
|
fail(path, 'must be an object');
|
|
186
186
|
}
|
|
187
|
-
assertUnknownKeys(style, ['token', 'fontSize', 'fontWeight', 'color', 'lineHeight', 'lines', 'truncate', 'alignment', 'verticalAlignment', 'offsetY', ...additionalKeys], path, 'text style key');
|
|
187
|
+
assertUnknownKeys(style, ['token', 'fontSize', 'fontWeight', 'color', 'lineHeight', 'lines', 'truncate', 'alignment', 'verticalAlignment', 'offsetY', 'letterSpacing', 'tabularNumbers', ...additionalKeys], path, 'text style key');
|
|
188
188
|
if (style.color !== undefined && (typeof style.color !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(style.color))) {
|
|
189
189
|
fail(`${path}.color`, 'must be #RRGGBB or #RRGGBBAA');
|
|
190
190
|
}
|
|
@@ -209,6 +209,8 @@ function assertTextStyle(style, path, additionalKeys = []) {
|
|
|
209
209
|
fail(`${path}.verticalAlignment`, 'must be top, center, or bottom');
|
|
210
210
|
}
|
|
211
211
|
assertBoundedStyleNumber(style.offsetY, `${path}.offsetY`, -8, 8);
|
|
212
|
+
assertBoundedStyleNumber(style.letterSpacing, `${path}.letterSpacing`, -4, 10);
|
|
213
|
+
if (style.tabularNumbers !== undefined && typeof style.tabularNumbers !== 'boolean') fail(`${path}.tabularNumbers`, 'must be a boolean');
|
|
212
214
|
}
|
|
213
215
|
function assertBoxStyle(style, path) {
|
|
214
216
|
const container = style.container;
|
|
@@ -791,6 +793,7 @@ function assertLeadingVisual(visual, path) {
|
|
|
791
793
|
// OneKey patch: validate optional selector overlays at the JSON boundary.
|
|
792
794
|
assertText(visual.fallbackIcon?.name, `${path}.fallbackIcon.name`);
|
|
793
795
|
if (visual.fallbackTextColor !== undefined && (typeof visual.fallbackTextColor !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(visual.fallbackTextColor))) fail(`${path}.fallbackTextColor`, 'must be a hex color');
|
|
796
|
+
if ('borderWidth' in visual && visual.borderWidth !== undefined && (typeof visual.borderWidth !== 'number' || !Number.isFinite(visual.borderWidth) || visual.borderWidth <= 0 || visual.borderWidth > 4)) fail(`${path}.borderWidth`, 'must be within (0, 4]');
|
|
794
797
|
if (visual.fallbackIcon?.size !== undefined && (!Number.isFinite(visual.fallbackIcon.size) || visual.fallbackIcon.size <= 0 || visual.fallbackIcon.size > 40)) fail(`${path}.fallbackIcon.size`, 'must be within (0, 40]');
|
|
795
798
|
if (visual.fallbackIcon?.backgroundColor !== undefined && !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(visual.fallbackIcon.backgroundColor)) fail(`${path}.fallbackIcon.backgroundColor`, 'must be a hex color');
|
|
796
799
|
if ((visual.overlays?.length ?? 0) > 2) fail(`${path}.overlays`, 'supports at most two overlays');
|
|
@@ -1248,7 +1251,7 @@ function assertSnapshotContract(snapshot) {
|
|
|
1248
1251
|
}
|
|
1249
1252
|
const COMMON_ROW_FIELDS = ['height', 'heightRounding', 'testID', 'opacity', 'backgroundColor', 'backgroundFullWidth', 'pressDisabled', 'key', 'revision', 'sectionKey', 'groupId', 'groupPosition', 'size', 'density', 'disabled', 'selected', 'accessibilityLabel', 'separator', 'type', 'style'];
|
|
1250
1253
|
const ROW_FIELDS = {
|
|
1251
|
-
identity: [...COMMON_ROW_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'presentation', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'titleLines', 'subtitleLines', 'badges', 'trailing', 'draggable'],
|
|
1254
|
+
identity: [...COMMON_ROW_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'presentation', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'titleLines', 'subtitleLines', 'collapseEmptyTrailing', 'badges', 'trailing', 'draggable'],
|
|
1252
1255
|
walletGroup: [...COMMON_ROW_FIELDS, 'parent', 'children', 'draggable'],
|
|
1253
1256
|
rail: [...COMMON_ROW_FIELDS, 'visual', 'title', 'status', 'badge', 'draggable'],
|
|
1254
1257
|
activity: [...COMMON_ROW_FIELDS, 'leading', 'hideLeading', 'secondaryLeading', 'title', 'description', 'status', 'primaryAmount', 'secondaryAmount', 'amounts', 'badges', 'presentation', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
|
|
@@ -1264,7 +1267,7 @@ const ROW_FIELDS = {
|
|
|
1264
1267
|
};
|
|
1265
1268
|
const COMMON_PATCH_FIELDS = ['height', 'heightRounding', 'opacity', 'pressDisabled', 'revision', 'disabled', 'selected', 'accessibilityLabel', 'separator', 'style'];
|
|
1266
1269
|
const PATCH_FIELDS = {
|
|
1267
|
-
identity: [...COMMON_PATCH_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'subtitleLines', 'badges', 'trailing'],
|
|
1270
|
+
identity: [...COMMON_PATCH_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'subtitleLines', 'collapseEmptyTrailing', 'badges', 'trailing'],
|
|
1268
1271
|
rail: [...COMMON_PATCH_FIELDS, 'title', 'visual', 'status', 'badge'],
|
|
1269
1272
|
activity: [...COMMON_PATCH_FIELDS, 'presentation', 'leading', 'title', 'badges', 'status', 'hideLeading', 'secondaryLeading', 'description', 'primaryAmount', 'secondaryAmount', 'amounts', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
|
|
1270
1273
|
message: [...COMMON_PATCH_FIELDS, 'presentation', 'title', 'unread', 'body', 'bodyLines', 'time', 'thumbnail'],
|
|
@@ -1285,7 +1288,7 @@ function protocolKey(value, path) {
|
|
|
1285
1288
|
if (typeof value !== 'string' || value.trim().length === 0) fail(path, 'must be a non-blank string');
|
|
1286
1289
|
}
|
|
1287
1290
|
const PROTOCOL_ARRAY_FIELDS = new Set(['columns', 'titleSuffixes', 'cells', 'points', 'images', 'overlays', 'badges', 'trailing', 'footerActions', 'buttons', 'amounts', 'metrics', 'children', 'subtitleSegments', 'titleMatch', 'selectedKeys', 'segments', 'hoverSecondary', 'hoverImages', 'secondaryBadges', 'fallbackUris', 'probeOrder', 'priceSegments', 'textSegments', 'secondaryTextSegments', 'primaryTextSegments']);
|
|
1288
|
-
const PROTOCOL_NUMBER_FIELDS = new Set(['leadingContentMaxWidthRatio', 'height', 'width', 'fontSize', 'lineHeight', 'opacity', 'offsetY', 'offsetX', 'cornerRadius', 'borderWidth', 'horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'titleBadgeGap', 'trailingGap', 'start', 'end', 'padding', 'offset', 'overscan', 'minWidth', 'flex', 'paddingStart', 'paddingEnd', 'changeWidth', 'changeHeight', 'changeCornerRadius', 'contentTrailingGap', 'subtitleTrailingPadding', 'partGap', 'contentPadding', 'contentPaddingHorizontal', 'contentPaddingTop', 'contentPaddingBottom', 'itemSpacing', 'gridColumns']);
|
|
1291
|
+
const PROTOCOL_NUMBER_FIELDS = new Set(['leadingContentMaxWidthRatio', 'height', 'width', 'fontSize', 'lineHeight', 'opacity', 'offsetY', 'offsetX', 'letterSpacing', 'cornerRadius', 'borderWidth', 'horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'titleBadgeGap', 'trailingGap', 'start', 'end', 'padding', 'offset', 'overscan', 'minWidth', 'flex', 'paddingStart', 'paddingEnd', 'changeWidth', 'changeHeight', 'changeCornerRadius', 'contentTrailingGap', 'subtitleTrailingPadding', 'partGap', 'contentPadding', 'contentPaddingHorizontal', 'contentPaddingTop', 'contentPaddingBottom', 'itemSpacing', 'gridColumns']);
|
|
1289
1292
|
|
|
1290
1293
|
/** Validate only shapes that renderers dereference, not display budgets. */
|
|
1291
1294
|
function assertProtocolFields(value, path, parentField = '') {
|
|
@@ -1325,10 +1328,10 @@ function assertProtocolFields(value, path, parentField = '') {
|
|
|
1325
1328
|
const fieldPath = `${path}.${field}`;
|
|
1326
1329
|
if (!path.endsWith('.style') && PROTOCOL_ARRAY_FIELDS.has(field) && !Array.isArray(item)) fail(fieldPath, 'must be an array');
|
|
1327
1330
|
if (PROTOCOL_NUMBER_FIELDS.has(field) && typeof item !== 'number') fail(fieldPath, 'must be a finite number');
|
|
1328
|
-
if (PROTOCOL_NUMBER_FIELDS.has(field) && typeof item === 'number' && item < 0 && !['offsetX', 'offsetY'].includes(field)) fail(fieldPath, 'must be non-negative');
|
|
1331
|
+
if (PROTOCOL_NUMBER_FIELDS.has(field) && typeof item === 'number' && item < 0 && !['offsetX', 'offsetY', 'letterSpacing'].includes(field)) fail(fieldPath, 'must be non-negative');
|
|
1329
1332
|
if (parentField === 'overlays' && field === 'fontWeight' && !['regular', 'medium', 'semibold', 'bold'].includes(item)) fail(fieldPath, 'must be regular, medium, semibold, or bold');
|
|
1330
1333
|
if (field === 'buttonStyle' && item !== 'tertiary') fail(fieldPath, 'must be tertiary');
|
|
1331
|
-
if (field === 'hideLeading' && typeof item !== 'boolean') fail(fieldPath, 'must be boolean');
|
|
1334
|
+
if ((field === 'hideLeading' || field === 'collapseEmptyTrailing') && typeof item !== 'boolean') fail(fieldPath, 'must be boolean');
|
|
1332
1335
|
if (field === 'key' || field === 'sectionKey' || field === 'groupId' || field === 'actionKey' || field.endsWith('ActionKey')) protocolKey(item, fieldPath);
|
|
1333
1336
|
if ((field === 'uri' || field === 'fallbackUri') && typeof item !== 'string') fail(fieldPath, 'must be a string');
|
|
1334
1337
|
if (field === 'style' && !(item === 'subscript' && /[Ss]egments\[/.test(path)) || field === 'container') protocolObject(item, fieldPath);
|
|
@@ -1425,6 +1428,10 @@ function assertRowProtocol(row, path) {
|
|
|
1425
1428
|
}
|
|
1426
1429
|
function assertSnapshotProtocol(snapshot) {
|
|
1427
1430
|
protocolObject(snapshot, 'snapshot');
|
|
1431
|
+
const reorderActivation = snapshot.capabilities?.reorderActivation;
|
|
1432
|
+
if (reorderActivation !== undefined && reorderActivation !== 'row' && reorderActivation !== 'handle') {
|
|
1433
|
+
fail('snapshot.capabilities.reorderActivation', "must be 'row' or 'handle'");
|
|
1434
|
+
}
|
|
1428
1435
|
if (snapshot.disclosure !== undefined) {
|
|
1429
1436
|
protocolObject(snapshot.disclosure, 'snapshot.disclosure');
|
|
1430
1437
|
if (typeof snapshot.disclosure.expanded !== 'boolean') fail('snapshot.disclosure.expanded', 'must be a boolean');
|
|
@@ -1473,8 +1480,8 @@ function isAllowedImageUri(value) {
|
|
|
1473
1480
|
}
|
|
1474
1481
|
const IMAGE_FIELDS = ['uri', 'width', 'height', 'headers', 'contentFit', 'cachePolicy', 'autoplay', 'optimizeTos', 'overscan', 'loadingStrategy', 'fallbackUri', 'fallbackUris', 'retryTimes'];
|
|
1475
1482
|
const ICON_FIELDS = ['name', 'tintColor', 'backgroundColor', 'size', 'accessibilityLabel', 'hoverActionKey'];
|
|
1476
|
-
const VISUAL_FIELDS = ['kind', 'name', 'image', 'images', 'networkImage', 'shape', 'tintColor', 'backgroundColor', 'fallbackIcon', 'fallbackText', 'fallbackTextColor', 'overlays', 'borderStyle', 'borderColor', 'cornerIcon'];
|
|
1477
|
-
const TEXT_STYLE_FIELDS = ['token', 'fontSize', 'fontWeight', 'color', 'lineHeight', 'lines', 'truncate', 'alignment', 'verticalAlignment', 'offsetY'];
|
|
1483
|
+
const VISUAL_FIELDS = ['kind', 'name', 'image', 'images', 'networkImage', 'shape', 'tintColor', 'backgroundColor', 'fallbackIcon', 'fallbackText', 'fallbackTextColor', 'overlays', 'borderStyle', 'borderColor', 'borderWidth', 'cornerIcon'];
|
|
1484
|
+
const TEXT_STYLE_FIELDS = ['token', 'fontSize', 'fontWeight', 'color', 'lineHeight', 'lines', 'truncate', 'alignment', 'verticalAlignment', 'offsetY', 'letterSpacing', 'tabularNumbers'];
|
|
1478
1485
|
const ACCESSORY_FIELDS = {
|
|
1479
1486
|
value: ['kind', 'text', 'secondary', 'textSegments'],
|
|
1480
1487
|
valuePair: ['kind', 'primary', 'secondary', 'primaryFontWeight', 'primaryHelp', 'primaryTextSegments', 'secondaryTextSegments', 'primaryTone', 'secondaryTone'],
|
|
@@ -1635,6 +1642,7 @@ function sanitizeDecoration(value, field) {
|
|
|
1635
1642
|
return field === 'hoverImages' ? items.map(item => item ?? null) : items.filter(item => item !== undefined);
|
|
1636
1643
|
}
|
|
1637
1644
|
if (!isRecord(value)) return value;
|
|
1645
|
+
const isLeadingVisual = ['leading', 'visual', 'secondaryLeading'].includes(field);
|
|
1638
1646
|
let object = value;
|
|
1639
1647
|
if (field === 'titleImage') {
|
|
1640
1648
|
const image = sanitizeImage(value.image);
|
|
@@ -1651,7 +1659,7 @@ function sanitizeDecoration(value, field) {
|
|
|
1651
1659
|
} else if (['titleIcon', 'secondaryTitleIcon', 'fallbackIcon', 'cornerIcon'].includes(field) && value.kind === undefined) {
|
|
1652
1660
|
if (typeof value.name !== 'string' || !value.name.trim()) return undefined;
|
|
1653
1661
|
object = pickFields(value, ICON_FIELDS);
|
|
1654
|
-
} else if (
|
|
1662
|
+
} else if (isLeadingVisual) {
|
|
1655
1663
|
object = pickFields(value, VISUAL_FIELDS);
|
|
1656
1664
|
} else if (field === 'media') {
|
|
1657
1665
|
object = pickFields(value, ['source', 'probeOrder']);
|
|
@@ -1669,6 +1677,9 @@ function sanitizeDecoration(value, field) {
|
|
|
1669
1677
|
const next = {};
|
|
1670
1678
|
for (const [key, item] of Object.entries(object)) {
|
|
1671
1679
|
if (item === undefined || item === null) continue;
|
|
1680
|
+
if (isLeadingVisual && key === 'borderWidth' && (typeof item !== 'number' || !Number.isFinite(item) || item <= 0 || item > 4)) continue;
|
|
1681
|
+
if (key === 'letterSpacing' && (typeof item !== 'number' || !Number.isFinite(item) || item < -4 || item > 10)) continue;
|
|
1682
|
+
if (key === 'tabularNumbers' && typeof item !== 'boolean') continue;
|
|
1672
1683
|
if ((/color$/i.test(key) || /background$/i.test(key)) && (typeof item !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(item))) continue;
|
|
1673
1684
|
if (/TextSegments$/.test(key) || ['textSegments', 'priceSegments', 'subtitleSegments', 'segments'].includes(key)) {
|
|
1674
1685
|
if (!Array.isArray(item) || item.some(segment => !isRecord(segment) || typeof segment.text !== 'string')) continue;
|
|
@@ -1681,7 +1692,7 @@ function sanitizeDecoration(value, field) {
|
|
|
1681
1692
|
if (key === 'buttonStyle' && item !== 'tertiary') continue;
|
|
1682
1693
|
if (key === 'hoverActionKey' && (typeof item !== 'string' || !item.trim())) continue;
|
|
1683
1694
|
if (key === 'accessibilityLabel' && typeof item !== 'string') continue;
|
|
1684
|
-
if ((field === 'style' || PROTOCOL_NUMBER_FIELDS.has(key)) && typeof item !== 'object' && typeof item === 'number' && (!Number.isFinite(item) || item < 0 && !['offsetX', 'offsetY'].includes(key))) continue;
|
|
1695
|
+
if ((field === 'style' || PROTOCOL_NUMBER_FIELDS.has(key)) && typeof item !== 'object' && typeof item === 'number' && (!Number.isFinite(item) || item < 0 && !['offsetX', 'offsetY', 'letterSpacing'].includes(key))) continue;
|
|
1685
1696
|
if (field === 'style' && PROTOCOL_NUMBER_FIELDS.has(key) && typeof item !== 'number') continue;
|
|
1686
1697
|
if (key === 'leadingContentMaxWidthRatio' && (typeof item !== 'number' || item <= 0 || item > 1)) continue;
|
|
1687
1698
|
const normalized = sanitizeDecoration(item, field === 'style' && key === 'image' ? 'imageStyle' : key);
|