@onekeyfe/react-native-native-list 6.7.0-17 → 6.7.0-19
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/NativeListView.kt +29 -73
- package/docs/SPEC.md +52 -8
- package/ios/HybridNativeList.swift +8 -4
- package/ios/RNCNativeListView.swift +35 -8
- package/ios/tests/NativeListLifecycleTests.swift +243 -18
- package/lib/module/NativeList.js +5 -1
- package/lib/module/NativeList.web.js +79 -30
- package/lib/module/index.js +1 -1
- package/lib/module/validation.js +90 -0
- package/lib/module/web/NativeListWebEngine.js +4 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/validation.d.ts +2 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +1 -0
- package/package.json +3 -3
- package/src/NativeList.tsx +7 -1
- package/src/NativeList.web.tsx +136 -47
- package/src/index.ts +1 -0
- package/src/validation.ts +110 -0
- package/src/web/NativeListWebEngine.ts +5 -1
|
@@ -4,6 +4,81 @@ import XCTest
|
|
|
4
4
|
|
|
5
5
|
@MainActor
|
|
6
6
|
final class NativeListLifecycleTests: XCTestCase {
|
|
7
|
+
func testAcceptedRowIndexReusesStableShapeAndRejectsLateInvalidPatch() throws {
|
|
8
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
|
|
9
|
+
func snapshot(_ keys: [String], generation: Int, title: String = "Old") throws -> String {
|
|
10
|
+
let rows: [[String: Any]] = keys.map { key in
|
|
11
|
+
["key": key, "type": "action", "title": title, "actionKey": "open"]
|
|
12
|
+
}
|
|
13
|
+
let value: [String: Any] = ["schemaVersion": 1, "generation": generation,
|
|
14
|
+
"layout": ["kind": "linear"], "rows": rows]
|
|
15
|
+
return String(decoding: try JSONSerialization.data(withJSONObject: value), as: UTF8.self)
|
|
16
|
+
}
|
|
17
|
+
func index() throws -> (ObjectIdentifier, [String: Int]) {
|
|
18
|
+
let optional = try XCTUnwrap(Mirror(reflecting: view).descendant("acceptedRowIndex"))
|
|
19
|
+
let value = try XCTUnwrap(Mirror(reflecting: optional).children.first?.value)
|
|
20
|
+
let byKey = try XCTUnwrap(Mirror(reflecting: value).descendant("byKey") as? [String: Int])
|
|
21
|
+
return (ObjectIdentifier(value as AnyObject), byKey)
|
|
22
|
+
}
|
|
23
|
+
func title(_ key: String) throws -> String {
|
|
24
|
+
let items = try XCTUnwrap(Mirror(reflecting: view).descendant("itemsByKey")
|
|
25
|
+
as? [String: NativeListItem])
|
|
26
|
+
return try XCTUnwrap(items[key]?.data["title"] as? String)
|
|
27
|
+
}
|
|
28
|
+
func patch(_ rows: [[String: Any]]) throws {
|
|
29
|
+
view.applyPatchesJson(String(decoding: try JSONSerialization.data(withJSONObject: rows),
|
|
30
|
+
as: UTF8.self))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
view.applySnapshotJson(try snapshot(["alpha", "beta"], generation: 1))
|
|
34
|
+
let initial = try index()
|
|
35
|
+
XCTAssertEqual(initial.1, ["alpha": 0, "beta": 1])
|
|
36
|
+
view.applySnapshotJson(try snapshot(["alpha", "beta"], generation: 1, title: "New"))
|
|
37
|
+
XCTAssertEqual(try index().0, initial.0)
|
|
38
|
+
try patch([["key": "alpha", "type": "action", "changes": ["title": "Patched"]],
|
|
39
|
+
["key": "missing", "type": "action", "changes": ["title": "Invalid"]]])
|
|
40
|
+
XCTAssertEqual(try title("alpha"), "New")
|
|
41
|
+
XCTAssertEqual(try title("beta"), "New")
|
|
42
|
+
XCTAssertEqual(try index().0, initial.0)
|
|
43
|
+
try patch([["key": "alpha", "type": "action", "changes": ["title": "Patched"]]])
|
|
44
|
+
XCTAssertEqual(try title("alpha"), "Patched")
|
|
45
|
+
XCTAssertEqual(try index().0, initial.0)
|
|
46
|
+
|
|
47
|
+
view.applySnapshotJson(try snapshot(["beta", "alpha"], generation: 1))
|
|
48
|
+
let reordered = try index()
|
|
49
|
+
XCTAssertNotEqual(reordered.0, initial.0)
|
|
50
|
+
XCTAssertEqual(reordered.1, ["beta": 0, "alpha": 1])
|
|
51
|
+
try patch([["key": "alpha", "type": "action", "changes": ["title": "After reorder"]]])
|
|
52
|
+
XCTAssertEqual(try title("alpha"), "After reorder")
|
|
53
|
+
view.applySnapshotJson(try snapshot(["beta", "gamma", "alpha"], generation: 1))
|
|
54
|
+
let inserted = try index()
|
|
55
|
+
XCTAssertNotEqual(inserted.0, reordered.0)
|
|
56
|
+
XCTAssertEqual(inserted.1, ["beta": 0, "gamma": 1, "alpha": 2])
|
|
57
|
+
try patch([["key": "alpha", "type": "action", "changes": ["title": "After insert"]]])
|
|
58
|
+
XCTAssertEqual(try title("alpha"), "After insert")
|
|
59
|
+
view.applySnapshotJson(try snapshot(["beta", "alpha"], generation: 1))
|
|
60
|
+
let deleted = try index()
|
|
61
|
+
XCTAssertNotEqual(deleted.0, inserted.0)
|
|
62
|
+
XCTAssertEqual(deleted.1, ["beta": 0, "alpha": 1])
|
|
63
|
+
try patch([["key": "alpha", "type": "action", "changes": ["title": "After delete"]]])
|
|
64
|
+
XCTAssertEqual(try title("alpha"), "After delete")
|
|
65
|
+
view.applySnapshotJson(try snapshot(["beta", "alpha"], generation: 2))
|
|
66
|
+
XCTAssertNotEqual(try index().0, deleted.0)
|
|
67
|
+
let beforeTypeChange = try index().0
|
|
68
|
+
let typeChanged: [String: Any] = ["schemaVersion": 1, "generation": 2,
|
|
69
|
+
"layout": ["kind": "linear"], "rows": [
|
|
70
|
+
["key": "beta", "type": "identity", "title": "Beta",
|
|
71
|
+
"leading": ["kind": "icon", "name": "coin"]],
|
|
72
|
+
["key": "alpha", "type": "action", "title": "Alpha", "actionKey": "open"],
|
|
73
|
+
]]
|
|
74
|
+
view.applySnapshotJson(String(decoding: try JSONSerialization.data(withJSONObject: typeChanged),
|
|
75
|
+
as: UTF8.self))
|
|
76
|
+
XCTAssertNotEqual(try index().0, beforeTypeChange)
|
|
77
|
+
view.dispose()
|
|
78
|
+
XCTAssertEqual(Mirror(reflecting: try XCTUnwrap(Mirror(reflecting: view)
|
|
79
|
+
.descendant("acceptedRowIndex"))).children.count, 0)
|
|
80
|
+
}
|
|
81
|
+
|
|
7
82
|
func testScrollEdgeStylesPreserveOverlayGeometryAndRestoreOriginalStyle() throws {
|
|
8
83
|
guard #available(iOS 26.0, *) else {
|
|
9
84
|
throw XCTSkip("Scroll-edge styles require iOS 26 or newer")
|
|
@@ -1557,6 +1632,73 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1557
1632
|
}
|
|
1558
1633
|
}
|
|
1559
1634
|
|
|
1635
|
+
func testHybridSettlementListenerFollowsRegistration() throws {
|
|
1636
|
+
let hybrid = HybridNativeList()
|
|
1637
|
+
let host = try XCTUnwrap(hybrid.view as? NativeListView)
|
|
1638
|
+
var first: [String] = []
|
|
1639
|
+
var second: [String] = []
|
|
1640
|
+
XCTAssertNil(host.onStructuralTransitionSettled)
|
|
1641
|
+
|
|
1642
|
+
hybrid.onStructuralTransitionSettled = { first.append($0) }
|
|
1643
|
+
host.onStructuralTransitionSettled?("first")
|
|
1644
|
+
XCTAssertEqual(first, ["first"])
|
|
1645
|
+
|
|
1646
|
+
hybrid.onStructuralTransitionSettled = { second.append($0) }
|
|
1647
|
+
host.onStructuralTransitionSettled?("second")
|
|
1648
|
+
XCTAssertEqual(first, ["first"])
|
|
1649
|
+
XCTAssertEqual(second, ["second"])
|
|
1650
|
+
|
|
1651
|
+
hybrid.onStructuralTransitionSettled = nil
|
|
1652
|
+
XCTAssertNil(host.onStructuralTransitionSettled)
|
|
1653
|
+
hybrid.dispose()
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
func testDisclosureWithoutListenerStillSettlesWithoutReplay() throws {
|
|
1657
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 600))
|
|
1658
|
+
let controller = UIViewController()
|
|
1659
|
+
window.rootViewController = controller
|
|
1660
|
+
let view = NativeListView(frame: window.bounds)
|
|
1661
|
+
controller.view.addSubview(view)
|
|
1662
|
+
window.isHidden = false
|
|
1663
|
+
defer {
|
|
1664
|
+
view.dispose()
|
|
1665
|
+
view.removeFromSuperview()
|
|
1666
|
+
window.isHidden = true
|
|
1667
|
+
window.rootViewController = nil
|
|
1668
|
+
}
|
|
1669
|
+
for index in 0..<6 { view.mountContainerSlot(UIView(), atIndex: index) }
|
|
1670
|
+
view.setContainerSlotHeightsJson("[0,0,60,0,100,40]")
|
|
1671
|
+
view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 1,
|
|
1672
|
+
disclosureExpanded: false))
|
|
1673
|
+
view.layoutIfNeeded()
|
|
1674
|
+
|
|
1675
|
+
let first = try structuralRowsSnapshot(count: 6, generation: 2,
|
|
1676
|
+
transitionID: "without-listener", durationMs: 0, disclosureExpanded: true)
|
|
1677
|
+
view.applySnapshotJson(first)
|
|
1678
|
+
drainMainQueue()
|
|
1679
|
+
XCTAssertEqual(Mirror(reflecting: view).descendant("pendingDisclosureSettlement")
|
|
1680
|
+
.map { Mirror(reflecting: $0).children.count }, 0)
|
|
1681
|
+
|
|
1682
|
+
var settlements: [[String: Any]] = []
|
|
1683
|
+
view.onStructuralTransitionSettled = { payload in
|
|
1684
|
+
guard let data = payload.data(using: .utf8),
|
|
1685
|
+
let value = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else {
|
|
1686
|
+
return
|
|
1687
|
+
}
|
|
1688
|
+
settlements.append(value)
|
|
1689
|
+
}
|
|
1690
|
+
view.applySnapshotJson(first)
|
|
1691
|
+
drainMainQueue()
|
|
1692
|
+
XCTAssertTrue(settlements.isEmpty)
|
|
1693
|
+
|
|
1694
|
+
view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 3,
|
|
1695
|
+
transitionID: "with-listener", durationMs: 0, disclosureExpanded: false))
|
|
1696
|
+
drainMainQueue()
|
|
1697
|
+
XCTAssertEqual(settlements.count, 1)
|
|
1698
|
+
XCTAssertEqual(settlements.first?["transitionId"] as? String, "with-listener")
|
|
1699
|
+
XCTAssertEqual(settlements.first?["status"] as? String, "completed")
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1560
1702
|
func testDisclosureInitialEndpoints() throws {
|
|
1561
1703
|
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 600))
|
|
1562
1704
|
let controller = UIViewController()
|
|
@@ -1907,44 +2049,112 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1907
2049
|
view.setContainerSlotHeightsJson("[0,0,140,0,100,40]")
|
|
1908
2050
|
let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
1909
2051
|
list.contentInsetAdjustmentBehavior = .never
|
|
2052
|
+
let contentHost = try XCTUnwrap(slots[4].superview)
|
|
1910
2053
|
var settlements: [(String, String)] = []
|
|
2054
|
+
let growSettled = expectation(description: "Disclosure growth settles")
|
|
1911
2055
|
view.onStructuralTransitionSettled = { payload in
|
|
1912
2056
|
guard let data = payload.data(using: .utf8),
|
|
1913
2057
|
let object = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
|
|
1914
2058
|
let id = object["transitionId"] as? String,
|
|
1915
2059
|
let status = object["status"] as? String else { return }
|
|
1916
2060
|
settlements.append((id, status))
|
|
2061
|
+
if id == "grow" && status == "completed" { growSettled.fulfill() }
|
|
1917
2062
|
}
|
|
1918
2063
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 1,
|
|
1919
2064
|
disclosureExpanded: false))
|
|
1920
2065
|
view.layoutIfNeeded()
|
|
2066
|
+
list.layoutIfNeeded()
|
|
2067
|
+
drainMainQueue()
|
|
2068
|
+
XCTAssertTrue(contentHost.isHidden, "Initial collapsed content must be hidden")
|
|
2069
|
+
XCTAssertNil(Mirror(reflecting: view).descendant("structuralDisplayLink") as? CADisplayLink)
|
|
2070
|
+
|
|
2071
|
+
let growthPhase = expectation(description: "Disclosure growth presents a partial content mask")
|
|
2072
|
+
var growthObserved = false
|
|
2073
|
+
var growthLast = "no frame sampled"
|
|
2074
|
+
let growthStartedAt = CACurrentMediaTime()
|
|
2075
|
+
let growthProbe = Timer(timeInterval: 1.0 / 60, repeats: true) { _ in
|
|
2076
|
+
let clock = Mirror(reflecting: view).descendant("structuralDisplayLink") as? CADisplayLink
|
|
2077
|
+
let tail = Mirror(reflecting: view).descendant("structuralTail")
|
|
2078
|
+
let tailActive = tail.map { !Mirror(reflecting: $0).children.isEmpty } ?? false
|
|
2079
|
+
let maskHeight = contentHost.layer.mask?.frame.height
|
|
2080
|
+
growthLast = "clock=\(clock != nil) tail=\(tailActive) "
|
|
2081
|
+
+ "mask=\(String(describing: maskHeight)) bounds=\(contentHost.bounds.height) "
|
|
2082
|
+
+ "elapsed=\(CACurrentMediaTime() - growthStartedAt) settlements=\(settlements)"
|
|
2083
|
+
guard !growthObserved, let clock, tailActive, let maskHeight,
|
|
2084
|
+
maskHeight > 0, maskHeight < 100 else { return }
|
|
2085
|
+
growthObserved = true
|
|
2086
|
+
let animationStart = Mirror(reflecting: view).descendant("structuralAnimationStart")
|
|
2087
|
+
as? CFTimeInterval
|
|
2088
|
+
let animationDuration = Mirror(reflecting: view).descendant("structuralAnimationDuration")
|
|
2089
|
+
as? CFTimeInterval
|
|
2090
|
+
XCTAssertNotNil(animationStart, "The active disclosure clock must have a start time")
|
|
2091
|
+
XCTAssertNotNil(animationDuration, "The active disclosure clock must have a duration")
|
|
2092
|
+
view.setContainerSlotHeightsJson("[0,0,140,0,140,40]")
|
|
2093
|
+
XCTAssertTrue(Mirror(reflecting: view).descendant("structuralDisplayLink") as? CADisplayLink
|
|
2094
|
+
=== clock, "Content growth must retain the active display link")
|
|
2095
|
+
XCTAssertEqual(Mirror(reflecting: view).descendant("structuralAnimationStart")
|
|
2096
|
+
as? CFTimeInterval, animationStart, "Content growth must keep the original deadline")
|
|
2097
|
+
XCTAssertEqual(Mirror(reflecting: view).descendant("structuralAnimationDuration")
|
|
2098
|
+
as? CFTimeInterval, animationDuration, "Content growth must keep the original duration")
|
|
2099
|
+
XCTAssertEqual(contentHost.layer.mask?.frame.height ?? -1, maskHeight, accuracy: 1,
|
|
2100
|
+
"Content growth must not jump the visible mask")
|
|
2101
|
+
growthPhase.fulfill()
|
|
2102
|
+
}
|
|
2103
|
+
RunLoop.main.add(growthProbe, forMode: .common)
|
|
2104
|
+
defer { growthProbe.invalidate() }
|
|
1921
2105
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 50, generation: 2,
|
|
1922
2106
|
transitionID: "grow", durationMs: 800, disclosureExpanded: true))
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
=== clock)
|
|
1931
|
-
XCTAssertEqual(try XCTUnwrap(contentHost.layer.mask).frame.height,
|
|
1932
|
-
beforeHeight, accuracy: 1)
|
|
1933
|
-
waitForStructuralFrames(0.75)
|
|
2107
|
+
wait(for: [growthPhase], timeout: 1.5)
|
|
2108
|
+
guard growthObserved else {
|
|
2109
|
+
XCTFail("No partial disclosure growth frame observed: \(growthLast)")
|
|
2110
|
+
return
|
|
2111
|
+
}
|
|
2112
|
+
growthProbe.invalidate()
|
|
2113
|
+
wait(for: [growSettled], timeout: 1.5)
|
|
1934
2114
|
XCTAssertEqual(contentHost.bounds.height, 140, accuracy: 1)
|
|
1935
2115
|
XCTAssertNil(contentHost.layer.mask)
|
|
1936
2116
|
XCTAssertTrue(contentHost.isUserInteractionEnabled)
|
|
1937
|
-
XCTAssertEqual(settlements.map(\.0), ["grow"])
|
|
2117
|
+
XCTAssertEqual(settlements.map(\.0), ["grow"], "Growth must settle exactly once")
|
|
1938
2118
|
XCTAssertEqual(settlements.last?.1, "completed")
|
|
1939
2119
|
|
|
2120
|
+
let collapsePhase = expectation(description: "Disclosure collapse presents a partial content mask")
|
|
2121
|
+
var collapseObserved = false
|
|
2122
|
+
var collapseLast = "no frame sampled"
|
|
2123
|
+
let collapseStartedAt = CACurrentMediaTime()
|
|
2124
|
+
let collapseProbe = Timer(timeInterval: 1.0 / 60, repeats: true) { _ in
|
|
2125
|
+
let clock = Mirror(reflecting: view).descendant("structuralDisplayLink") as? CADisplayLink
|
|
2126
|
+
let tail = Mirror(reflecting: view).descendant("structuralTail")
|
|
2127
|
+
let tailActive = tail.map { !Mirror(reflecting: $0).children.isEmpty } ?? false
|
|
2128
|
+
let maskHeight = contentHost.layer.mask?.frame.height
|
|
2129
|
+
collapseLast = "clock=\(clock != nil) tail=\(tailActive) "
|
|
2130
|
+
+ "mask=\(String(describing: maskHeight)) bounds=\(contentHost.bounds.height) "
|
|
2131
|
+
+ "elapsed=\(CACurrentMediaTime() - collapseStartedAt) settlements=\(settlements)"
|
|
2132
|
+
guard !collapseObserved, clock != nil, tailActive, let maskHeight,
|
|
2133
|
+
maskHeight > 0, maskHeight < 140 else { return }
|
|
2134
|
+
collapseObserved = true
|
|
2135
|
+
view.scrollViewWillBeginDragging(list)
|
|
2136
|
+
XCTAssertNil(Mirror(reflecting: view).descendant("structuralDisplayLink") as? CADisplayLink,
|
|
2137
|
+
"Dragging must stop the active disclosure display link")
|
|
2138
|
+
let remainingTail = Mirror(reflecting: view).descendant("structuralTail")
|
|
2139
|
+
XCTAssertNotNil(remainingTail, "The structural tail field must remain observable")
|
|
2140
|
+
XCTAssertFalse(remainingTail.map { !Mirror(reflecting: $0).children.isEmpty } ?? true,
|
|
2141
|
+
"Dragging must clear the temporary structural tail")
|
|
2142
|
+
XCTAssertTrue(contentHost.isHidden, "Dragging a collapse must hide content")
|
|
2143
|
+
XCTAssertEqual(settlements.map(\.0), ["grow", "drag"],
|
|
2144
|
+
"Dragging must settle the collapse exactly once")
|
|
2145
|
+
XCTAssertEqual(settlements.last?.1, "interrupted")
|
|
2146
|
+
collapsePhase.fulfill()
|
|
2147
|
+
}
|
|
2148
|
+
RunLoop.main.add(collapseProbe, forMode: .common)
|
|
2149
|
+
defer { collapseProbe.invalidate() }
|
|
1940
2150
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 3,
|
|
1941
2151
|
transitionID: "drag", durationMs: 800, disclosureExpanded: false))
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
2152
|
+
wait(for: [collapsePhase], timeout: 1.5)
|
|
2153
|
+
guard collapseObserved else {
|
|
2154
|
+
XCTFail("No partial disclosure collapse frame observed: \(collapseLast)")
|
|
2155
|
+
return
|
|
2156
|
+
}
|
|
2157
|
+
collapseProbe.invalidate()
|
|
1948
2158
|
}
|
|
1949
2159
|
|
|
1950
2160
|
func testDisclosureDirectCollapseKeepsToggleVisible() throws {
|
|
@@ -2552,6 +2762,13 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2552
2762
|
XCTAssertGreaterThan(heightBeforePatch, 1500)
|
|
2553
2763
|
let retiring = try XCTUnwrap(list.cellForItem(at: IndexPath(item: 25, section: 0)) as? NativeListRowHost)
|
|
2554
2764
|
XCTAssertEqual(retiring.bounds.height, 60, accuracy: 1)
|
|
2765
|
+
func storedContent(_ key: String) throws -> String {
|
|
2766
|
+
let items = try XCTUnwrap(Mirror(reflecting: view).descendant("itemsByKey")
|
|
2767
|
+
as? [String: NativeListItem])
|
|
2768
|
+
return try XCTUnwrap(items[key]).content
|
|
2769
|
+
}
|
|
2770
|
+
let oldAcceptedContent = try storedContent("row-20")
|
|
2771
|
+
let retiredContent = try storedContent("row-25")
|
|
2555
2772
|
let patch: [[String: Any]] = [[
|
|
2556
2773
|
"key": "row-20", "type": "dataRow", "changes": [
|
|
2557
2774
|
"revision": 2,
|
|
@@ -2559,8 +2776,16 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2559
2776
|
["key": "price", "text": "$123.45"]],
|
|
2560
2777
|
],
|
|
2561
2778
|
]]
|
|
2779
|
+
let invalidRetiredPatch: [String: Any] = ["key": "row-25", "type": "dataRow",
|
|
2780
|
+
"changes": ["revision": 2]]
|
|
2781
|
+
view.applyPatchesJson(String(decoding: try JSONSerialization.data(
|
|
2782
|
+
withJSONObject: patch + [invalidRetiredPatch]), as: UTF8.self))
|
|
2783
|
+
XCTAssertEqual(try storedContent("row-20"), oldAcceptedContent)
|
|
2784
|
+
XCTAssertEqual(try storedContent("row-25"), retiredContent)
|
|
2562
2785
|
view.applyPatchesJson(String(decoding: try JSONSerialization.data(withJSONObject: patch),
|
|
2563
2786
|
as: UTF8.self))
|
|
2787
|
+
XCTAssertNotEqual(try storedContent("row-20"), oldAcceptedContent)
|
|
2788
|
+
XCTAssertEqual(try storedContent("row-25"), retiredContent)
|
|
2564
2789
|
list.layoutIfNeeded()
|
|
2565
2790
|
let patched = try XCTUnwrap(list.cellForItem(at: IndexPath(item: 20, section: 0)))
|
|
2566
2791
|
XCTAssertTrue(labels(in: patched).contains { $0.text == "$123.45" })
|
package/lib/module/NativeList.js
CHANGED
|
@@ -12,6 +12,9 @@ import { applyOwnedNativePatches, captureNativeListInput, containNativeListInput
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
const NativeListConfig = require('../nitrogen/generated/shared/json/NativeListConfig.json');
|
|
14
14
|
const NativeListHost = getHostComponent('NativeList', () => NativeListConfig);
|
|
15
|
+
const clearedStructuralTransitionSettled = {
|
|
16
|
+
f: undefined
|
|
17
|
+
};
|
|
15
18
|
const disclosureSlotMeasurementStyle = {
|
|
16
19
|
alignSelf: 'stretch'
|
|
17
20
|
};
|
|
@@ -154,7 +157,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
154
157
|
const containerSlotHeightsJson = JSON.stringify(slotHeights);
|
|
155
158
|
const defaultSlotInset = snapshot.layout.contentPaddingHorizontal ?? snapshot.layout.contentPadding ?? 0;
|
|
156
159
|
const bandWidth = sidecarLayout ? Math.min(viewportWidth, sidecarLayout.maxContentWidth) : 0;
|
|
157
|
-
const slotInset = sidecarLayout ? Math.max(0, (viewportWidth - bandWidth) / 2) : defaultSlotInset;
|
|
160
|
+
const slotInset = sidecarLayout ? Math.max(0, (viewportWidth - bandWidth) / 2) + defaultSlotInset : defaultSlotInset;
|
|
158
161
|
const sidecarSpace = sidecarLayout ? sidecarLayout.width + sidecarLayout.gap : 0;
|
|
159
162
|
const slotContents = [listHeader, listEmpty, listFooter, listSidecar, listExpandedContent, listStructureToggle];
|
|
160
163
|
const recordSlotLayout = (index, height, epoch) => {
|
|
@@ -478,6 +481,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
478
481
|
viewProps.onLayout?.(event);
|
|
479
482
|
},
|
|
480
483
|
...nativeCallbacks,
|
|
484
|
+
onStructuralTransitionSettled: onStructuralTransitionSettled ? nativeCallbacks.onStructuralTransitionSettled : clearedStructuralTransitionSettled,
|
|
481
485
|
fontFamiliesJson: fontFamiliesJson,
|
|
482
486
|
snapshotJson: snapshotJson,
|
|
483
487
|
containerSlotHeightsJson: containerSlotHeightsJson,
|
|
@@ -8,6 +8,9 @@ import { applyRowPatches, containNativeListInput, emptyNativeListSnapshot, valid
|
|
|
8
8
|
import { NativeListWebEngine } from "./web/NativeListWebEngine.js";
|
|
9
9
|
import { acquireNativeListAvatar, canonicalNativeListAvatarUri } from "./web/NativeListWebAvatarCache.js";
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const collapsedExpandedContentStyle = {
|
|
12
|
+
display: 'none'
|
|
13
|
+
};
|
|
11
14
|
export function preloadNativeListAvatarImages(sources) {
|
|
12
15
|
if (typeof document === 'undefined') return Promise.resolve(false);
|
|
13
16
|
const uris = [...new Set(sources.map(source => canonicalNativeListAvatarUri(source.uri)).filter(uri => uri !== undefined))];
|
|
@@ -26,8 +29,8 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
26
29
|
listHeader,
|
|
27
30
|
listEmpty,
|
|
28
31
|
listFooter,
|
|
29
|
-
listExpandedContent
|
|
30
|
-
listStructureToggle
|
|
32
|
+
listExpandedContent,
|
|
33
|
+
listStructureToggle,
|
|
31
34
|
listSidecar,
|
|
32
35
|
sidecarLayout,
|
|
33
36
|
topOverlay: _topOverlay,
|
|
@@ -61,7 +64,14 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
61
64
|
if (!Number.isFinite(inputStickyInset) || inputStickyInset < 0) throw new Error('webStickyInset must be finite and non-negative');
|
|
62
65
|
return inputStickyInset;
|
|
63
66
|
}) ?? 0, [inputStickyInset]);
|
|
64
|
-
|
|
67
|
+
// Freshness is limited to this component invocation; later renders revalidate.
|
|
68
|
+
let freshlyValidatedSnapshot;
|
|
69
|
+
const preparedSnapshot = useMemo(() => {
|
|
70
|
+
const prepared = containNativeListInput(() => validateSnapshot(inputSnapshot));
|
|
71
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- The value is intentionally render-local.
|
|
72
|
+
freshlyValidatedSnapshot = prepared;
|
|
73
|
+
return prepared;
|
|
74
|
+
}, [inputSnapshot]);
|
|
65
75
|
const snapshot = preparedSnapshot ?? acceptedSnapshotRef.current;
|
|
66
76
|
const fontFamiliesJson = useNativeListFontFamiliesJson();
|
|
67
77
|
const fontFamiliesJsonRef = useRef(fontFamiliesJson);
|
|
@@ -69,31 +79,18 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
69
79
|
const hasEmptySlot = listEmpty !== undefined;
|
|
70
80
|
const hasEmptySlotRef = useRef(hasEmptySlot);
|
|
71
81
|
hasEmptySlotRef.current = hasEmptySlot;
|
|
72
|
-
const [slotState, setSlotState] = useState(() => ({
|
|
73
|
-
hasRows: snapshot.rows.length > 0,
|
|
74
|
-
emptyBottomPadding: !snapshot.rows.length && hasEmptySlot ? snapshot.layout.contentPaddingBottom ?? snapshot.layout.contentPadding ?? 0 : 0,
|
|
75
|
-
padding: snapshot.layout.contentPaddingHorizontal ?? snapshot.layout.contentPadding ?? 0
|
|
76
|
-
}));
|
|
77
82
|
const [viewportWidth, setViewportWidth] = useState(0);
|
|
78
83
|
const [sidecarHeight, setSidecarHeight] = useState(0);
|
|
79
|
-
const
|
|
80
|
-
const hasRows = next.rows.length > 0;
|
|
81
|
-
const padding = next.layout.contentPaddingHorizontal ?? next.layout.contentPadding ?? 0;
|
|
82
|
-
const emptyBottomPadding = !hasRows && hasEmptySlotRef.current ? next.layout.contentPaddingBottom ?? next.layout.contentPadding ?? 0 : 0;
|
|
83
|
-
setSlotState(previous => previous.hasRows === hasRows && previous.padding === padding && previous.emptyBottomPadding === emptyBottomPadding ? previous : {
|
|
84
|
-
hasRows,
|
|
85
|
-
padding,
|
|
86
|
-
emptyBottomPadding
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
const normalizeWebSnapshot = (next, hasReactEmpty = hasEmptySlotRef.current, hasSlotLayout = useSlotLayoutRef.current) => {
|
|
84
|
+
const normalizeWebSnapshot = (next, hasReactEmpty = hasEmptySlotRef.current, hasSlotLayout = useSlotLayoutRef.current, validatedInThisRender = false) => {
|
|
90
85
|
if (hasSlotLayout && next.layout.orientation === 'horizontal') throw new Error('Web parent scrolling and container slots support vertical lists only');
|
|
91
86
|
const emptySlot = hasReactEmpty && next.rows.length === 0;
|
|
92
|
-
const
|
|
87
|
+
const normalized = emptySlot && next.emptyState !== undefined ? {
|
|
93
88
|
...next,
|
|
94
89
|
emptyState: undefined
|
|
95
|
-
} : next
|
|
96
|
-
|
|
90
|
+
} : next;
|
|
91
|
+
const validated = validatedInThisRender ? normalized : validateSnapshot(normalized);
|
|
92
|
+
// Preserve an already normalized fallback's identity across rerenders.
|
|
93
|
+
return emptySlot && validated.layout.contentPaddingBottom !== 0 ? {
|
|
97
94
|
...validated,
|
|
98
95
|
layout: {
|
|
99
96
|
...validated.layout,
|
|
@@ -107,6 +104,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
107
104
|
const useSlotLayoutRef = useRef(false);
|
|
108
105
|
useSlotLayoutRef.current ||= webScrollHost !== undefined || listHeader !== undefined || listEmpty !== undefined || listFooter !== undefined;
|
|
109
106
|
useSlotLayoutRef.current ||= listSidecar !== undefined;
|
|
107
|
+
useSlotLayoutRef.current ||= listExpandedContent !== undefined || listStructureToggle !== undefined;
|
|
110
108
|
const useSlotLayout = useSlotLayoutRef.current;
|
|
111
109
|
const resolvedScrollHost = webScrollHost === undefined ? useSlotLayout ? ownedScrollHost : undefined : webScrollHost;
|
|
112
110
|
const engineRef = useRef(undefined);
|
|
@@ -122,8 +120,39 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
122
120
|
} = sidecarLayout;
|
|
123
121
|
if (snapshot.layout.kind !== 'linear' || !Number.isFinite(width) || width <= 0 || !Number.isFinite(gap) || gap < 0 || !Number.isFinite(maxContentWidth) || maxContentWidth <= width + gap) throw new Error('Invalid NativeList sidecar layout');
|
|
124
122
|
}
|
|
125
|
-
return normalizeWebSnapshot(snapshot, hasEmptySlot, useSlotLayout);
|
|
126
|
-
}) ?? acceptedSnapshotRef.current,
|
|
123
|
+
return normalizeWebSnapshot(snapshot, hasEmptySlot, useSlotLayout, preparedSnapshot !== undefined && preparedSnapshot === freshlyValidatedSnapshot);
|
|
124
|
+
}) ?? acceptedSnapshotRef.current,
|
|
125
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- Preserve the existing memo dependencies; freshness is render-local.
|
|
126
|
+
[snapshot, hasEmptySlot, useSlotLayout, listSidecar, sidecarLayout]);
|
|
127
|
+
const [slotState, setSlotState] = useState(() => ({
|
|
128
|
+
hasRows: validatedSnapshot.rows.length > 0,
|
|
129
|
+
emptyBottomPadding: !validatedSnapshot.rows.length && hasEmptySlot ? validatedSnapshot.layout.contentPaddingBottom ?? validatedSnapshot.layout.contentPadding ?? 0 : 0,
|
|
130
|
+
padding: validatedSnapshot.layout.contentPaddingHorizontal ?? validatedSnapshot.layout.contentPadding ?? 0,
|
|
131
|
+
disclosurePresent: validatedSnapshot.disclosure !== undefined,
|
|
132
|
+
disclosureExpanded: validatedSnapshot.disclosure?.expanded === true,
|
|
133
|
+
hasExpandedContent: validatedSnapshot.disclosure?.expanded === true,
|
|
134
|
+
expandedTrailingInset: validatedSnapshot.disclosure?.expandedTrailingInset ?? 0
|
|
135
|
+
}));
|
|
136
|
+
const synchronizeSlots = next => {
|
|
137
|
+
const hasRows = next.rows.length > 0;
|
|
138
|
+
const padding = next.layout.contentPaddingHorizontal ?? next.layout.contentPadding ?? 0;
|
|
139
|
+
const emptyBottomPadding = !hasRows && hasEmptySlotRef.current ? next.layout.contentPaddingBottom ?? next.layout.contentPadding ?? 0 : 0;
|
|
140
|
+
const disclosurePresent = next.disclosure !== undefined;
|
|
141
|
+
const disclosureExpanded = next.disclosure?.expanded === true;
|
|
142
|
+
const expandedTrailingInset = next.disclosure?.expandedTrailingInset ?? 0;
|
|
143
|
+
setSlotState(previous => {
|
|
144
|
+
const hasExpandedContent = previous.hasExpandedContent || disclosureExpanded;
|
|
145
|
+
return previous.hasRows === hasRows && previous.padding === padding && previous.emptyBottomPadding === emptyBottomPadding && previous.disclosurePresent === disclosurePresent && previous.disclosureExpanded === disclosureExpanded && previous.hasExpandedContent === hasExpandedContent && previous.expandedTrailingInset === expandedTrailingInset ? previous : {
|
|
146
|
+
hasRows,
|
|
147
|
+
padding,
|
|
148
|
+
emptyBottomPadding,
|
|
149
|
+
disclosurePresent,
|
|
150
|
+
disclosureExpanded,
|
|
151
|
+
hasExpandedContent,
|
|
152
|
+
expandedTrailingInset
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
};
|
|
127
156
|
const snapshotRef = useRef(validatedSnapshot);
|
|
128
157
|
const snapshotPropRef = useRef(validatedSnapshot);
|
|
129
158
|
// An imperative snapshot survives host mounting until the snapshot prop changes.
|
|
@@ -131,7 +160,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
131
160
|
snapshotPropRef.current = validatedSnapshot;
|
|
132
161
|
snapshotRef.current = validatedSnapshot;
|
|
133
162
|
acceptedSnapshotRef.current = validatedSnapshot;
|
|
134
|
-
synchronizeSlots(
|
|
163
|
+
synchronizeSlots(validatedSnapshot);
|
|
135
164
|
}
|
|
136
165
|
if (!initializedSnapshot.current) {
|
|
137
166
|
acceptedSnapshotRef.current = validatedSnapshot;
|
|
@@ -315,6 +344,13 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
315
344
|
ref: setHostRef
|
|
316
345
|
});
|
|
317
346
|
const padding = slotState.padding;
|
|
347
|
+
const footerBandStyle = {
|
|
348
|
+
paddingHorizontal: padding
|
|
349
|
+
};
|
|
350
|
+
const trailingInsetStyle = {
|
|
351
|
+
height: slotState.disclosureExpanded ? slotState.expandedTrailingInset : 0
|
|
352
|
+
};
|
|
353
|
+
const hasFooterBand = listFooter !== undefined || listExpandedContent !== undefined || listStructureToggle !== undefined;
|
|
318
354
|
const content = /*#__PURE__*/_jsxs(View, {
|
|
319
355
|
ref: sidecarLayout ? undefined : setBoundsRef,
|
|
320
356
|
style: {
|
|
@@ -339,12 +375,25 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
339
375
|
paddingBottom: slotState.emptyBottomPadding
|
|
340
376
|
},
|
|
341
377
|
children: listEmpty
|
|
342
|
-
}) : null,
|
|
378
|
+
}) : null, hasFooterBand ? /*#__PURE__*/_jsxs(View, {
|
|
343
379
|
testID: "native-list-footer-slot",
|
|
344
|
-
style:
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
380
|
+
style: footerBandStyle,
|
|
381
|
+
children: [listExpandedContent !== undefined && slotState.hasExpandedContent ? /*#__PURE__*/_jsx(View, {
|
|
382
|
+
testID: "native-list-expanded-content-slot",
|
|
383
|
+
"aria-hidden": !slotState.disclosureExpanded,
|
|
384
|
+
pointerEvents: slotState.disclosureExpanded ? 'auto' : 'none',
|
|
385
|
+
style: slotState.disclosureExpanded ? undefined : collapsedExpandedContentStyle,
|
|
386
|
+
children: listExpandedContent
|
|
387
|
+
}) : null, listStructureToggle !== undefined ? /*#__PURE__*/_jsx(View, {
|
|
388
|
+
testID: "native-list-structure-toggle-slot",
|
|
389
|
+
"aria-hidden": !slotState.disclosurePresent,
|
|
390
|
+
pointerEvents: slotState.disclosurePresent ? 'auto' : 'none',
|
|
391
|
+
style: slotState.disclosurePresent ? undefined : collapsedExpandedContentStyle,
|
|
392
|
+
children: listStructureToggle
|
|
393
|
+
}) : null, slotState.expandedTrailingInset > 0 && (listExpandedContent !== undefined || listStructureToggle !== undefined) ? /*#__PURE__*/_jsx(View, {
|
|
394
|
+
testID: "native-list-trailing-inset-slot",
|
|
395
|
+
style: trailingInsetStyle
|
|
396
|
+
}) : null, listFooter]
|
|
348
397
|
}) : null]
|
|
349
398
|
});
|
|
350
399
|
const bandWidth = sidecarLayout ? Math.min(viewportWidth, sidecarLayout.maxContentWidth) : 0;
|
package/lib/module/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export { NativeList, preloadNativeListAvatarImages } from './NativeList';
|
|
4
|
-
export { applyRowPatches, serializePatches, serializeSnapshot, validatePatches, validateSnapshot } from "./validation.js";
|
|
4
|
+
export { applyRowPatches, planNativeListPatches, serializePatches, serializeSnapshot, validatePatches, validateSnapshot } from "./validation.js";
|
|
5
5
|
export { checkboxStateForKeys, checkboxStateForSection, isSelectableRow, reduceSelection, selectionStateFromSnapshot } from "./selection.js";
|
|
6
6
|
export { configureNativeListFonts } from "./fonts.js";
|
|
7
7
|
export { ScrollEdgeEffect } from "./ScrollEdgeEffect.js";
|
package/lib/module/validation.js
CHANGED
|
@@ -1669,6 +1669,96 @@ function normalizePatchStyles(patches) {
|
|
|
1669
1669
|
});
|
|
1670
1670
|
return changed ? next : patches;
|
|
1671
1671
|
}
|
|
1672
|
+
const EMPTY_ROW_PATCHES = Object.freeze([]);
|
|
1673
|
+
function sameJsonValue(left, right) {
|
|
1674
|
+
if (left === right) return true;
|
|
1675
|
+
if (left === null || right === null) return false;
|
|
1676
|
+
if (typeof left !== 'object' || typeof right !== 'object') return false;
|
|
1677
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
1678
|
+
return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index) => sameJsonValue(value, right[index]));
|
|
1679
|
+
}
|
|
1680
|
+
const leftObject = left;
|
|
1681
|
+
const rightObject = right;
|
|
1682
|
+
const leftKeys = Object.keys(leftObject).filter(key => leftObject[key] !== undefined);
|
|
1683
|
+
const rightKeys = Object.keys(rightObject).filter(key => rightObject[key] !== undefined);
|
|
1684
|
+
return leftKeys.length === rightKeys.length && leftKeys.every(key => sameJsonValue(leftObject[key], rightObject[key]));
|
|
1685
|
+
}
|
|
1686
|
+
function sameOptionalPresence(left, right) {
|
|
1687
|
+
return left === undefined === (right === undefined);
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
/** Plan value-only patches; callers own valid immutable snapshots and commit state. */
|
|
1691
|
+
export function planNativeListPatches(previous, next) {
|
|
1692
|
+
if (previous === next) return EMPTY_ROW_PATCHES;
|
|
1693
|
+
const {
|
|
1694
|
+
rows: previousRows,
|
|
1695
|
+
...previousMetadata
|
|
1696
|
+
} = previous;
|
|
1697
|
+
const {
|
|
1698
|
+
rows: nextRows,
|
|
1699
|
+
...nextMetadata
|
|
1700
|
+
} = next;
|
|
1701
|
+
if (previousRows.length !== nextRows.length || !sameJsonValue(previousMetadata, nextMetadata)) return undefined;
|
|
1702
|
+
if (previousRows === nextRows) return EMPTY_ROW_PATCHES;
|
|
1703
|
+
const patches = [];
|
|
1704
|
+
for (let index = 0; index < nextRows.length; index += 1) {
|
|
1705
|
+
const oldRow = previousRows[index];
|
|
1706
|
+
const row = nextRows[index];
|
|
1707
|
+
if (oldRow.key !== row.key || oldRow.type !== row.type) return undefined;
|
|
1708
|
+
if (oldRow === row) continue;
|
|
1709
|
+
if (oldRow.type === 'identity' && row.type === 'identity') {
|
|
1710
|
+
const {
|
|
1711
|
+
subtitle: oldSubtitle,
|
|
1712
|
+
subtitleSegments: oldSubtitleSegments,
|
|
1713
|
+
trailing: oldTrailing,
|
|
1714
|
+
...oldMetadata
|
|
1715
|
+
} = oldRow;
|
|
1716
|
+
const {
|
|
1717
|
+
subtitle,
|
|
1718
|
+
subtitleSegments,
|
|
1719
|
+
trailing,
|
|
1720
|
+
...metadata
|
|
1721
|
+
} = row;
|
|
1722
|
+
if (!sameOptionalPresence(oldSubtitle, subtitle) || !sameOptionalPresence(oldSubtitleSegments, subtitleSegments) || !sameOptionalPresence(oldTrailing, trailing) || !sameJsonValue(oldMetadata, metadata)) return undefined;
|
|
1723
|
+
if (!sameJsonValue(oldSubtitle, subtitle) || !sameJsonValue(oldSubtitleSegments, subtitleSegments) || !sameJsonValue(oldTrailing, trailing)) {
|
|
1724
|
+
patches.push({
|
|
1725
|
+
type: 'identity',
|
|
1726
|
+
key: row.key,
|
|
1727
|
+
changes: {
|
|
1728
|
+
subtitle,
|
|
1729
|
+
subtitleSegments,
|
|
1730
|
+
trailing
|
|
1731
|
+
}
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
} else if (oldRow.type === 'dataRow' && row.type === 'dataRow') {
|
|
1735
|
+
const {
|
|
1736
|
+
columns: oldColumns,
|
|
1737
|
+
trailing: oldTrailing,
|
|
1738
|
+
...oldMetadata
|
|
1739
|
+
} = oldRow;
|
|
1740
|
+
const {
|
|
1741
|
+
columns,
|
|
1742
|
+
trailing,
|
|
1743
|
+
...metadata
|
|
1744
|
+
} = row;
|
|
1745
|
+
if (!sameOptionalPresence(oldTrailing, trailing) || !sameJsonValue(oldMetadata, metadata) || !sameJsonValue(oldColumns[0], columns[0])) return undefined;
|
|
1746
|
+
if (!sameJsonValue(oldColumns.slice(1), columns.slice(1)) || !sameJsonValue(oldTrailing, trailing)) {
|
|
1747
|
+
patches.push({
|
|
1748
|
+
type: 'dataRow',
|
|
1749
|
+
key: row.key,
|
|
1750
|
+
changes: {
|
|
1751
|
+
columns,
|
|
1752
|
+
trailing
|
|
1753
|
+
}
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
} else if (!sameJsonValue(oldRow, row)) {
|
|
1757
|
+
return undefined;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
return patches.length === 0 ? EMPTY_ROW_PATCHES : patches;
|
|
1761
|
+
}
|
|
1672
1762
|
export function applyRowPatches(snapshot, patches) {
|
|
1673
1763
|
const normalizedPatches = validatePatches(patches);
|
|
1674
1764
|
const patchByKey = new Map(normalizedPatches.map(patch => [patch.key, patch]));
|
|
@@ -1604,7 +1604,7 @@ export class NativeListWebEngine {
|
|
|
1604
1604
|
this.document.fonts?.addEventListener('loadingdone', this.handleWindowResize);
|
|
1605
1605
|
this.observeSectionIndexTransforms();
|
|
1606
1606
|
this.applyFontFamilies(fontFamiliesJson);
|
|
1607
|
-
this.
|
|
1607
|
+
this.applyValidatedSnapshot(this.snapshot);
|
|
1608
1608
|
}
|
|
1609
1609
|
validateStickyInset(value = 0) {
|
|
1610
1610
|
if (!Number.isFinite(value) || value < 0) throw new Error('webStickyInset must be finite and non-negative');
|
|
@@ -1674,6 +1674,9 @@ export class NativeListWebEngine {
|
|
|
1674
1674
|
return next;
|
|
1675
1675
|
});
|
|
1676
1676
|
if (!validated) return;
|
|
1677
|
+
this.applyValidatedSnapshot(validated);
|
|
1678
|
+
}
|
|
1679
|
+
applyValidatedSnapshot(validated) {
|
|
1677
1680
|
this.pressedHelpElement = undefined;
|
|
1678
1681
|
this.invalidateActionAnchor('snapshot');
|
|
1679
1682
|
const transition = validated.structuralTransition;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { NativeList, preloadNativeListAvatarImages } from './NativeList';
|
|
2
2
|
export type { ActionAnchorState, NativeListKeyboardDismissMode, NativeListKeyboardShouldPersistTaps, NativeListProps, NativeListRef, ScrollAlignment, ScrollPositionOptions, ScrollToEndParams, ScrollToIndexFailedInfo, ScrollToIndexParams, ScrollToItemParams, ScrollToKeyParams, ScrollToLocationParams, ScrollToOffsetParams, StructuralTransitionSettledEvent, } from './NativeList';
|
|
3
3
|
export type * from './models';
|
|
4
|
-
export { applyRowPatches, serializePatches, serializeSnapshot, validatePatches, validateSnapshot, } from './validation';
|
|
4
|
+
export { applyRowPatches, planNativeListPatches, serializePatches, serializeSnapshot, validatePatches, validateSnapshot, } from './validation';
|
|
5
5
|
export { checkboxStateForKeys, checkboxStateForSection, isSelectableRow, reduceSelection, selectionStateFromSnapshot, } from './selection';
|
|
6
6
|
export type { SelectionAction, SelectionResult, SelectionState, } from './selection';
|
|
7
7
|
export { configureNativeListFonts } from './fonts';
|