@onekeyfe/react-native-native-list 6.8.0-alpha.514 → 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 +159 -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 +203 -45
  26. package/ios/tests/NativeListLifecycleTests.swift +298 -24
  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
@@ -1,9 +1,97 @@
1
+ import ObjectiveC
1
2
  import UIKit
2
3
  import XCTest
3
4
  @testable import NativeListModule
4
5
 
5
6
  @MainActor
6
7
  final class NativeListLifecycleTests: XCTestCase {
8
+ func testFilteredSnapshotSuppliesCellsDuringOutgoingUIKitLayout() throws {
9
+ let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 390, height: 697))
10
+ let window = UIWindow(frame: view.frame)
11
+ let controller = UIViewController()
12
+ window.rootViewController = controller
13
+ window.makeKeyAndVisible()
14
+ controller.view.addSubview(view)
15
+ defer {
16
+ view.dispose()
17
+ window.isHidden = true
18
+ }
19
+
20
+ let collection = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
21
+ let dataSource = try XCTUnwrap(collection.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
22
+ collection.isPrefetchingEnabled = false
23
+ collection.contentInsetAdjustmentBehavior = .never
24
+ collection.contentInset = UIEdgeInsets(top: 190, left: 0, bottom: 449, right: 0)
25
+ func snapshot(_ indices: Range<Int>) throws -> String {
26
+ let rows: [[String: Any]] = indices.map { index in
27
+ ["key": "account-\(index)", "type": "identity", "title": "Account \(index)",
28
+ "testID": "recipient-\(index)", "height": 64,
29
+ "leading": ["kind": "icon", "name": "Circle"]]
30
+ }
31
+ let value: [String: Any] = ["schemaVersion": 1, "generation": 1,
32
+ "layout": ["kind": "linear"], "rows": rows]
33
+ return String(decoding: try JSONSerialization.data(withJSONObject: value), as: UTF8.self)
34
+ }
35
+ view.applySnapshotJson(try snapshot(0..<18))
36
+ view.layoutIfNeeded()
37
+ let initialOffset = CGPoint(x: 0, y: -190)
38
+ collection.contentOffset = initialOffset
39
+ collection.layoutIfNeeded()
40
+ XCTAssertEqual(dataSource.snapshot().numberOfItems, 18)
41
+ let outgoingIndexPath = IndexPath(item: 8, section: 0)
42
+ let outgoingFrame = try XCTUnwrap(collection.layoutAttributesForItem(at: outgoingIndexPath)).frame
43
+ XCTAssertFalse(collection.bounds.intersects(outgoingFrame))
44
+ XCTAssertNil(collection.cellForItem(at: outgoingIndexPath))
45
+
46
+ // Force a real UIKit layout at the invalidation inside applySnapshotJson,
47
+ // while UIKit still owns the old snapshot. Scope the hook to this layout.
48
+ let layout = collection.collectionViewLayout
49
+ let layoutClass: AnyClass = type(of: layout)
50
+ let selector = NSSelectorFromString("invalidateLayout")
51
+ let method = try XCTUnwrap(class_getInstanceMethod(layoutClass, selector))
52
+ let encoding = try XCTUnwrap(method_getTypeEncoding(method))
53
+ let original = method_getImplementation(method)
54
+ let callOriginal = unsafeBitCast(original, to: (@convention(c) (AnyObject, Selector) -> Void).self)
55
+ var didLayoutOutgoingSnapshot = false
56
+ let invalidate: @convention(block) (UICollectionViewLayout) -> Void = { current in
57
+ callOriginal(current, selector)
58
+ guard current === layout, !didLayoutOutgoingSnapshot,
59
+ dataSource.snapshot().numberOfItems == 18 else { return }
60
+ didLayoutOutgoingSnapshot = true
61
+ let size = view.collectionView(collection, layout: current, sizeForItemAt: outgoingIndexPath)
62
+ XCTAssertEqual(size.height, 64, "UIKit still needs the outgoing row’s geometry")
63
+ XCTAssertNil(collection.cellForItem(at: outgoingIndexPath))
64
+ collection.contentOffset.y = outgoingFrame.midY - collection.bounds.height / 2
65
+ collection.setNeedsLayout()
66
+ collection.layoutIfNeeded()
67
+ XCTAssertTrue(collection.bounds.intersects(outgoingFrame))
68
+ guard let outgoingCell = collection.cellForItem(at: outgoingIndexPath) else {
69
+ XCTFail("UIKit must request the previously offscreen outgoing cell")
70
+ return
71
+ }
72
+ XCTAssertEqual(outgoingCell.reuseIdentifier,
73
+ NativeListRendererRegistry.reuseIdentifier(for: .identity))
74
+ XCTAssertFalse(outgoingCell.isUserInteractionEnabled)
75
+ XCTAssertTrue(outgoingCell.accessibilityElementsHidden)
76
+ XCTAssertFalse(view.collectionView(collection, shouldSelectItemAt: outgoingIndexPath))
77
+ }
78
+ let replacement = imp_implementationWithBlock(invalidate)
79
+ class_replaceMethod(layoutClass, selector, replacement, encoding)
80
+ defer {
81
+ class_replaceMethod(layoutClass, selector, original, encoding)
82
+ imp_removeBlock(replacement)
83
+ }
84
+
85
+ view.applySnapshotJson(try snapshot(12..<15))
86
+ collection.contentOffset = initialOffset
87
+ collection.layoutIfNeeded()
88
+ XCTAssertTrue(didLayoutOutgoingSnapshot)
89
+ XCTAssertEqual(dataSource.snapshot().itemIdentifiers, ["account-12", "account-13", "account-14"])
90
+ let first = try XCTUnwrap(collection.cellForItem(at: IndexPath(item: 0, section: 0)))
91
+ XCTAssertFalse(first.isHidden)
92
+ XCTAssertEqual(first.accessibilityIdentifier, "recipient-12")
93
+ }
94
+
7
95
  func testCanonicalNullPatchRemovesStoredOptionalFields() throws {
8
96
  let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
9
97
  let row: [String: Any] = ["key": "token", "type": "identity", "title": "Token",
@@ -135,11 +223,17 @@ final class NativeListLifecycleTests: XCTestCase {
135
223
  window.rootViewController = controller
136
224
  controller.view.addSubview(view)
137
225
  window.isHidden = false
138
- defer { window.isHidden = true }
139
226
  window.layoutIfNeeded()
140
227
  view.layoutIfNeeded()
141
228
  drainMainQueue()
142
229
  let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
230
+ defer {
231
+ list.setContentOffset(list.contentOffset, animated: false)
232
+ view.dispose()
233
+ view.removeFromSuperview()
234
+ window.isHidden = true
235
+ window.rootViewController = nil
236
+ }
143
237
  XCTAssertNotNil(view.window)
144
238
  XCTAssertGreaterThan(list.contentSize.height - list.bounds.height +
145
239
  list.adjustedContentInset.top + list.adjustedContentInset.bottom, 800)
@@ -1047,6 +1141,173 @@ final class NativeListLifecycleTests: XCTestCase {
1047
1141
  XCTAssertTrue(second.isHidden)
1048
1142
  }
1049
1143
 
1144
+ func testFixedFooterSharesRetiringRowKeyDuringStructuralTransition() throws {
1145
+ try requireStructuralAnimation()
1146
+ let footerData: [String: Any] = [
1147
+ "key": "a", "type": "action", "title": "Continue", "actionKey": "continue",
1148
+ ]
1149
+ func snapshot(_ keys: [String], animate: Bool) throws -> String {
1150
+ let rows: [[String: Any]] = keys.map {
1151
+ ["key": $0, "type": "action", "title": $0, "actionKey": "row-\($0)"]
1152
+ }
1153
+ var value: [String: Any] = ["schemaVersion": 1, "generation": animate ? 2 : 1,
1154
+ "layout": ["kind": "linear"], "rows": rows, "fixedFooter": footerData]
1155
+ if animate { value["structuralTransition"] = ["id": "remove-a", "durationMs": 800] }
1156
+ return String(decoding: try JSONSerialization.data(withJSONObject: value), as: UTF8.self)
1157
+ }
1158
+
1159
+ let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
1160
+ let controller = UIViewController()
1161
+ window.rootViewController = controller
1162
+ let view = NativeListView(frame: window.bounds)
1163
+ controller.view.addSubview(view)
1164
+ window.isHidden = false
1165
+ defer {
1166
+ view.dispose()
1167
+ window.isHidden = true
1168
+ }
1169
+
1170
+ let collection = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
1171
+ let dataSource = try XCTUnwrap(collection.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
1172
+ var actions: [String] = []
1173
+ view.onRowAction = { payload in
1174
+ if let action = (try? JSONSerialization.jsonObject(with: Data(payload.utf8))) as? [String: Any],
1175
+ let key = action["actionKey"] as? String { actions.append(key) }
1176
+ }
1177
+ view.applySnapshotJson(try snapshot(["a", "b", "c"], animate: false))
1178
+ view.layoutIfNeeded()
1179
+ collection.layoutIfNeeded()
1180
+ let outgoingIndex = IndexPath(item: 0, section: 0)
1181
+ let outgoing = try XCTUnwrap(collection.cellForItem(at: outgoingIndex) as? NativeListRowHost)
1182
+ let outgoingAction = try XCTUnwrap(outgoing.onAction)
1183
+
1184
+ view.applySnapshotJson(try snapshot(["b", "c"], animate: true))
1185
+ XCTAssertEqual(dataSource.itemIdentifier(for: outgoingIndex), "a")
1186
+ XCTAssertFalse(view.collectionView(collection, shouldSelectItemAt: outgoingIndex))
1187
+ view.collectionView(collection, didSelectItemAt: outgoingIndex)
1188
+ // Child renderers can emit a different key than the enclosing collection row.
1189
+ let child = try NativeListItem(data: ["key": "child", "type": "action", "title": "Child"])
1190
+ outgoingAction(child, "child-press", nil, outgoing.rowActionOrigin())
1191
+ XCTAssertTrue(actions.isEmpty)
1192
+
1193
+ let footer = try XCTUnwrap(footerCell(in: view))
1194
+ XCTAssertEqual(footer.accessibilityLabel, "Continue")
1195
+ XCTAssertEqual(footer.alpha, 1)
1196
+ XCTAssertTrue(footer.isUserInteractionEnabled)
1197
+ XCTAssertFalse(footer.accessibilityElementsHidden)
1198
+ // Dispatch the gesture's target directly in this hostless XCTest.
1199
+ let footerPress = NSSelectorFromString("footerPressed")
1200
+ XCTAssertTrue(view.responds(to: footerPress))
1201
+ _ = view.perform(footerPress)
1202
+ footer.onAction?(try NativeListItem(data: footerData), "footer-accessory", nil, footer.rowActionOrigin())
1203
+ XCTAssertEqual(actions, ["continue", "footer-accessory"])
1204
+ }
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
+
1050
1311
  func testFontResolversMeasureBindResetAndKeepIndependentInstances() throws {
1051
1312
  let first = NativeListFontFamilies(names: ["regular": "Courier", "bold": "Courier-Bold"])
1052
1313
  let second = NativeListFontFamilies(names: ["regular": "Georgia", "bold": "Georgia-Bold"])
@@ -1620,7 +1881,7 @@ final class NativeListLifecycleTests: XCTestCase {
1620
1881
  view.layoutIfNeeded()
1621
1882
  list.layoutIfNeeded()
1622
1883
  } completion: { _ in finished.fulfill() }
1623
- wait(for: [finished], timeout: 1)
1884
+ wait(for: [finished], timeout: 5)
1624
1885
  try check(phase, count: count, width: 700)
1625
1886
  waitForStructuralFrames(0.1)
1626
1887
  try check("\(phase) stable", count: count, width: 700)
@@ -1677,9 +1938,12 @@ final class NativeListLifecycleTests: XCTestCase {
1677
1938
  XCTAssertEqual(list.contentOffset.y, testCase.offset, accuracy: 1, testCase.name)
1678
1939
 
1679
1940
  view.applySnapshotJson(try structuralRowsSnapshot(count: 25, transitionID: testCase.name))
1680
- let completed = expectation(description: "Native structural display link: \(testCase.name)")
1681
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { completed.fulfill() }
1682
- wait(for: [completed], timeout: 1)
1941
+ let settleDeadline = Date().addingTimeInterval(5)
1942
+ while Mirror(reflecting: view).descendant("structuralDisplayLink") as? CADisplayLink != nil,
1943
+ Date() < settleDeadline {
1944
+ RunLoop.main.run(until: Date().addingTimeInterval(0.01))
1945
+ }
1946
+ waitForStructuralFrames(0.05)
1683
1947
  list.layoutIfNeeded()
1684
1948
  XCTAssertEqual(list.adjustedContentInset, explicitInset, testCase.name)
1685
1949
  XCTAssertEqual(list.contentSize.height, testCase.height, accuracy: 1, testCase.name)
@@ -1801,17 +2065,20 @@ final class NativeListLifecycleTests: XCTestCase {
1801
2065
  list.contentOffset.y = 900
1802
2066
  list.layoutIfNeeded()
1803
2067
 
2068
+ let flow = try XCTUnwrap(list.collectionViewLayout as? NativeListFlowLayout)
1804
2069
  view.applySnapshotJson(try structuralRowsSnapshot(count: 30, generation: 2,
1805
- transitionID: "expand-first", durationMs: 400))
1806
- waitForStructuralFrames(0.08)
2070
+ transitionID: "expand-first", durationMs: 1200))
2071
+ let expandDeadline = Date().addingTimeInterval(3)
2072
+ while (flow.tailClip?.endY ?? 0) <= 1505 && Date() < expandDeadline {
2073
+ RunLoop.main.run(until: Date().addingTimeInterval(0.01))
2074
+ }
1807
2075
  list.contentOffset.y = 1100
1808
2076
  list.layoutIfNeeded()
1809
2077
  view.applySnapshotJson(try structuralRowsSnapshot(count: 25, generation: 3,
1810
- transitionID: "collapse-middle", durationMs: 400))
2078
+ transitionID: "collapse-middle", durationMs: 2400))
1811
2079
  waitForStructuralFrames(0.08)
1812
2080
  list.layoutIfNeeded()
1813
2081
  let source = try XCTUnwrap(list.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
1814
- let flow = try XCTUnwrap(list.collectionViewLayout as? NativeListFlowLayout)
1815
2082
  let clip = try XCTUnwrap(flow.tailClip)
1816
2083
  let retiring = try XCTUnwrap(list.cellForItem(at: IndexPath(item: 25, section: 0)) as? NativeListRowHost)
1817
2084
  XCTAssertGreaterThan(clip.endY, 1500)
@@ -2129,7 +2396,7 @@ final class NativeListLifecycleTests: XCTestCase {
2129
2396
  view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 5,
2130
2397
  transitionID: "collapse-latest", durationMs: 400,
2131
2398
  disclosureExpanded: false))
2132
- wait(for: [latestSettled], timeout: 2)
2399
+ wait(for: [latestSettled], timeout: 5)
2133
2400
  XCTAssertEqual(settlements.map(\.0), ["same-rows", "collapse-latest"])
2134
2401
  XCTAssertEqual(settlements.last?.1, "completed")
2135
2402
  XCTAssertEqual(settlements.last?.2, false)
@@ -2321,13 +2588,13 @@ final class NativeListLifecycleTests: XCTestCase {
2321
2588
  defer { growthProbe.invalidate() }
2322
2589
  view.applySnapshotJson(try structuralRowsSnapshot(count: 50, generation: 2,
2323
2590
  transitionID: "grow", durationMs: 800, disclosureExpanded: true))
2324
- wait(for: [growthPhase], timeout: 1.5)
2591
+ wait(for: [growthPhase], timeout: 5)
2325
2592
  guard growthObserved else {
2326
2593
  XCTFail("No partial disclosure growth frame observed: \(growthLast)")
2327
2594
  return
2328
2595
  }
2329
2596
  growthProbe.invalidate()
2330
- wait(for: [growSettled], timeout: 1.5)
2597
+ wait(for: [growSettled], timeout: 5)
2331
2598
  XCTAssertEqual(contentHost.bounds.height, 140, accuracy: 1)
2332
2599
  XCTAssertNil(contentHost.layer.mask)
2333
2600
  XCTAssertTrue(contentHost.isUserInteractionEnabled)
@@ -2366,7 +2633,7 @@ final class NativeListLifecycleTests: XCTestCase {
2366
2633
  defer { collapseProbe.invalidate() }
2367
2634
  view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 3,
2368
2635
  transitionID: "drag", durationMs: 800, disclosureExpanded: false))
2369
- wait(for: [collapsePhase], timeout: 1.5)
2636
+ wait(for: [collapsePhase], timeout: 5)
2370
2637
  guard collapseObserved else {
2371
2638
  XCTFail("No partial disclosure collapse frame observed: \(collapseLast)")
2372
2639
  return
@@ -2875,8 +3142,8 @@ final class NativeListLifecycleTests: XCTestCase {
2875
3142
  drainMainQueue()
2876
3143
  list.contentOffset.y = 300
2877
3144
  list.layoutIfNeeded()
2878
- view.applySnapshotJson(try structuralRowsSnapshot(count: 50, generation: 2,
2879
- transitionID: "interrupt-boundary", durationMs: 1200))
3145
+ view.applySnapshotJson(try structuralRowsSnapshot(count: 15, generation: 2,
3146
+ transitionID: "interrupt-boundary", durationMs: 2400))
2880
3147
  let footerBottomBeforeResize = footer.convert(.zero, to: list).y + 60
2881
3148
  view.setContainerSlotHeightsJson("[0,0,80,2200]")
2882
3149
  XCTAssertEqual(footer.convert(.zero, to: list).y + 80,
@@ -2890,7 +3157,7 @@ final class NativeListLifecycleTests: XCTestCase {
2890
3157
  XCTAssertFalse(footerHost.point(inside: CGPoint(x: 10, y: hiddenTop / 2), with: nil))
2891
3158
  XCTAssertTrue(footerHost.point(inside: CGPoint(x: 10, y: hiddenTop + 1), with: nil))
2892
3159
  var boundaryCell: NativeListRowHost?
2893
- let deadline = Date().addingTimeInterval(1)
3160
+ let deadline = Date().addingTimeInterval(3)
2894
3161
  while boundaryCell == nil && Date() < deadline {
2895
3162
  if let clip = flow.tailClip {
2896
3163
  for case let cell as NativeListRowHost in list.visibleCells {
@@ -3172,9 +3439,13 @@ final class NativeListLifecycleTests: XCTestCase {
3172
3439
  }
3173
3440
 
3174
3441
  private func waitForStructuralFrames(_ seconds: TimeInterval) {
3175
- let completed = expectation(description: "Native structural display link ran for \(seconds)s")
3176
- DispatchQueue.main.asyncAfter(deadline: .now() + seconds) { completed.fulfill() }
3177
- wait(for: [completed], timeout: seconds + 1)
3442
+ let deadline = Date().addingTimeInterval(seconds)
3443
+ while Date() < deadline {
3444
+ RunLoop.main.run(until: Date().addingTimeInterval(0.01))
3445
+ }
3446
+ for _ in 0..<4 {
3447
+ RunLoop.main.run(until: Date().addingTimeInterval(0.02))
3448
+ }
3178
3449
  }
3179
3450
 
3180
3451
  private func labels(in view: UIView) -> [UILabel] {
@@ -3343,14 +3614,17 @@ final class NativeListLifecycleTests: XCTestCase {
3343
3614
  }
3344
3615
 
3345
3616
  private func drainMainQueue() {
3346
- let settled = expectation(description: "Deferred content shrink correction")
3347
- DispatchQueue.main.async { settled.fulfill() }
3348
- wait(for: [settled], timeout: 1)
3617
+ var drained = false
3618
+ DispatchQueue.main.async { drained = true }
3619
+ let deadline = Date().addingTimeInterval(5)
3620
+ while !drained && Date() < deadline {
3621
+ RunLoop.main.run(until: Date().addingTimeInterval(0.01))
3622
+ }
3349
3623
  }
3350
3624
 
3351
3625
  private func footerCell(in view: NativeListView) -> NativeListRowHost? {
3352
- view.subviews.lazy.compactMap { container in
3353
- container.subviews.compactMap { $0 as? NativeListRowHost }.first
3626
+ view.subviews.lazy.filter { !($0 is UICollectionView) }.compactMap { container in
3627
+ container.subviews.first { $0 is NativeListRowHost } as? NativeListRowHost
3354
3628
  }.first
3355
3629
  }
3356
3630
  }
@@ -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 (['leading', 'visual', 'secondaryLeading'].includes(field)) {
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);