@expo/ui 58.0.6 → 58.0.7
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/CHANGELOG.md +12 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +9 -0
- package/android/src/main/java/expo/modules/ui/LazyColumnView.kt +6 -1
- package/android/src/main/java/expo/modules/ui/LazyItemsView.kt +313 -0
- package/android/src/main/java/expo/modules/ui/LazyRowView.kt +6 -1
- package/android/src/main/java/expo/modules/ui/RNHostView.kt +18 -4
- package/build/jetpack-compose/LazyColumn/index.d.ts +6 -0
- package/build/jetpack-compose/LazyColumn/index.js +2 -0
- package/build/jetpack-compose/LazyColumn/index.js.map +1 -1
- package/build/jetpack-compose/LazyItems/index.d.ts +54 -0
- package/build/jetpack-compose/LazyItems/index.js +63 -0
- package/build/jetpack-compose/LazyItems/index.js.map +1 -0
- package/build/jetpack-compose/LazyRow/index.d.ts +6 -0
- package/build/jetpack-compose/LazyRow/index.js +2 -0
- package/build/jetpack-compose/LazyRow/index.js.map +1 -1
- package/build/jetpack-compose/index.d.ts +1 -0
- package/build/jetpack-compose/index.js.map +1 -1
- package/build/recycling/useRecycledRows.d.ts +52 -0
- package/build/recycling/useRecycledRows.js +121 -0
- package/build/recycling/useRecycledRows.js.map +1 -0
- package/build/recycling/window.js.map +1 -0
- package/build/swift-ui/List/DataListForEach.d.ts +2 -9
- package/build/swift-ui/List/DataListForEach.js +15 -106
- package/build/swift-ui/List/DataListForEach.js.map +1 -1
- package/build/swift-ui/List/ListForEach.js +3 -2
- package/build/swift-ui/List/ListForEach.js.map +1 -1
- package/build/swift-ui/modifiers/presentationModifiers.d.ts +8 -0
- package/build/swift-ui/modifiers/presentationModifiers.js +9 -0
- package/build/swift-ui/modifiers/presentationModifiers.js.map +1 -1
- package/build/universal/transformStyle.ios.js +4 -3
- package/build/universal/transformStyle.ios.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/ios/Modifiers/PresentationModifiers.swift +10 -0
- package/ios/Modifiers/ViewModifierRegistry.swift +4 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.6/expo.modules.ui-58.0.6-sources.jar → 58.0.7/expo.modules.ui-58.0.7-sources.jar} +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7-sources.jar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7-sources.jar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7-sources.jar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7-sources.jar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.aar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.aar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.aar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.aar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.6/expo.modules.ui-58.0.6.module → 58.0.7/expo.modules.ui-58.0.7.module} +23 -23
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.module.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.module.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.module.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.module.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.6/expo.modules.ui-58.0.6.pom → 58.0.7/expo.modules.ui-58.0.7.pom} +2 -2
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.pom.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.pom.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.pom.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.pom.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml +4 -4
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha512 +1 -1
- package/package.json +4 -4
- package/prebuilds/output/debug/xcframeworks/ExpoUI.tar.gz +0 -0
- package/prebuilds/output/release/xcframeworks/ExpoUI.tar.gz +0 -0
- package/src/jetpack-compose/LazyColumn/index.tsx +3 -0
- package/src/jetpack-compose/LazyItems/index.tsx +121 -0
- package/src/jetpack-compose/LazyRow/index.tsx +3 -0
- package/src/jetpack-compose/index.ts +1 -0
- package/src/recycling/useRecycledRows.tsx +200 -0
- package/src/swift-ui/List/DataListForEach.tsx +21 -142
- package/src/swift-ui/List/ListForEach.tsx +3 -2
- package/src/swift-ui/modifiers/presentationModifiers.ts +10 -0
- package/src/universal/transformStyle.ios.ts +5 -2
- package/build/swift-ui/List/window.js.map +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6-sources.jar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6-sources.jar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6-sources.jar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6-sources.jar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.aar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.aar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.aar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.aar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.module.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.6/expo.modules.ui-58.0.6.pom.sha512 +0 -1
- /package/build/{swift-ui/List → recycling}/window.d.ts +0 -0
- /package/build/{swift-ui/List → recycling}/window.js +0 -0
- /package/src/{swift-ui/List → recycling}/window.ts +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "expo.modules.ui",
|
|
5
5
|
"module": "expo.modules.ui",
|
|
6
|
-
"version": "58.0.
|
|
6
|
+
"version": "58.0.7",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
{
|
|
27
|
-
"name": "expo.modules.ui-58.0.
|
|
28
|
-
"url": "expo.modules.ui-58.0.
|
|
29
|
-
"size":
|
|
30
|
-
"sha512": "
|
|
31
|
-
"sha256": "
|
|
32
|
-
"sha1": "
|
|
33
|
-
"md5": "
|
|
27
|
+
"name": "expo.modules.ui-58.0.7.aar",
|
|
28
|
+
"url": "expo.modules.ui-58.0.7.aar",
|
|
29
|
+
"size": 1835156,
|
|
30
|
+
"sha512": "58f2fa2376432db80f54bf406250ceb0c07fd16f2dd693dcb9aa784c078a18e5044bd224896e2112237b52f6169eeda86f3cfa4edae36be61fec24ffaa6ea1ac",
|
|
31
|
+
"sha256": "db4b84c7879a230cb83fb791d8f9a8f86a282f5c93751bc267dd8a648ed141af",
|
|
32
|
+
"sha1": "955cc1dcde621dc0ad9d70588bff46adfedc1129",
|
|
33
|
+
"md5": "b4a6d6acd9603febf32c95c833b1405f"
|
|
34
34
|
}
|
|
35
35
|
]
|
|
36
36
|
},
|
|
@@ -135,19 +135,19 @@
|
|
|
135
135
|
"group": "io.github.expo.pika",
|
|
136
136
|
"module": "pika-api",
|
|
137
137
|
"version": {
|
|
138
|
-
"requires": "1.
|
|
138
|
+
"requires": "1.1.0"
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
],
|
|
142
142
|
"files": [
|
|
143
143
|
{
|
|
144
|
-
"name": "expo.modules.ui-58.0.
|
|
145
|
-
"url": "expo.modules.ui-58.0.
|
|
146
|
-
"size":
|
|
147
|
-
"sha512": "
|
|
148
|
-
"sha256": "
|
|
149
|
-
"sha1": "
|
|
150
|
-
"md5": "
|
|
144
|
+
"name": "expo.modules.ui-58.0.7.aar",
|
|
145
|
+
"url": "expo.modules.ui-58.0.7.aar",
|
|
146
|
+
"size": 1835156,
|
|
147
|
+
"sha512": "58f2fa2376432db80f54bf406250ceb0c07fd16f2dd693dcb9aa784c078a18e5044bd224896e2112237b52f6169eeda86f3cfa4edae36be61fec24ffaa6ea1ac",
|
|
148
|
+
"sha256": "db4b84c7879a230cb83fb791d8f9a8f86a282f5c93751bc267dd8a648ed141af",
|
|
149
|
+
"sha1": "955cc1dcde621dc0ad9d70588bff46adfedc1129",
|
|
150
|
+
"md5": "b4a6d6acd9603febf32c95c833b1405f"
|
|
151
151
|
}
|
|
152
152
|
]
|
|
153
153
|
},
|
|
@@ -161,13 +161,13 @@
|
|
|
161
161
|
},
|
|
162
162
|
"files": [
|
|
163
163
|
{
|
|
164
|
-
"name": "expo.modules.ui-58.0.
|
|
165
|
-
"url": "expo.modules.ui-58.0.
|
|
166
|
-
"size":
|
|
167
|
-
"sha512": "
|
|
168
|
-
"sha256": "
|
|
169
|
-
"sha1": "
|
|
170
|
-
"md5": "
|
|
164
|
+
"name": "expo.modules.ui-58.0.7-sources.jar",
|
|
165
|
+
"url": "expo.modules.ui-58.0.7-sources.jar",
|
|
166
|
+
"size": 109722,
|
|
167
|
+
"sha512": "c1f94d22a03f47ec553960cf5a44936e26992755aebc5f3583484c41ee224f9637620571022ae95f0687e5701632d93a1752f817dca5923b07aa10a2697c4776",
|
|
168
|
+
"sha256": "5645728c21cb9bd3183045c4208434114a1372ed0a367dadc545a2555294748b",
|
|
169
|
+
"sha1": "21cb93383a49b039772df3cbd1a14c3cd821886c",
|
|
170
|
+
"md5": "bbdad22fa84c26c5a5b649ed116f1fcb"
|
|
171
171
|
}
|
|
172
172
|
]
|
|
173
173
|
}
|
package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.module.md5
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ef9649b49362d0da4b0e79afd086b9a8
|
package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.module.sha1
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
9dd32ee8f56b957697d2292dce6935a9a6c113f7
|
package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.module.sha256
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4461d437dc9b9973416bb69437c013180a65b2a0d3cb5cb9a87566d1d388bad9
|
package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.module.sha512
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
62141bdabeb89bd61f79ba40fe8a39c31d7ff0f04eb060a7872dd83eb1e72899ee8d1befaeebdfb4251174b0dc53e4d9ac9e6cac357364d905ddd1df91754ed6
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<modelVersion>4.0.0</modelVersion>
|
|
10
10
|
<groupId>expo.modules.ui</groupId>
|
|
11
11
|
<artifactId>expo.modules.ui</artifactId>
|
|
12
|
-
<version>58.0.
|
|
12
|
+
<version>58.0.7</version>
|
|
13
13
|
<packaging>aar</packaging>
|
|
14
14
|
<name>expo.modules.ui</name>
|
|
15
15
|
<url>https://github.com/expo/expo</url>
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
<dependency>
|
|
118
118
|
<groupId>io.github.expo.pika</groupId>
|
|
119
119
|
<artifactId>pika-api</artifactId>
|
|
120
|
-
<version>1.
|
|
120
|
+
<version>1.1.0</version>
|
|
121
121
|
<scope>runtime</scope>
|
|
122
122
|
</dependency>
|
|
123
123
|
</dependencies>
|
package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.pom.md5
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ea27c56a290e1fc992da3e12320a93e8
|
package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.pom.sha1
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
582b5b30bd24edc8b923d34cce63fcd644fa12d6
|
package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.pom.sha256
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5365fa5ce4427865eebebb3fa8fb502842f890b4bd2d79c2b6be0225fb07a2fc
|
package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.7/expo.modules.ui-58.0.7.pom.sha512
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5fcaae8cc43b51d719769cbebd906e1333dd120c6d14212a2006aa0ee966143bb32a04edc35ed68a7f8cdb1cee1ae442c3cf98f6f0a39b0cbc2a05ae0287c4fd
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>expo.modules.ui</groupId>
|
|
4
4
|
<artifactId>expo.modules.ui</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>58.0.
|
|
7
|
-
<release>58.0.
|
|
6
|
+
<latest>58.0.7</latest>
|
|
7
|
+
<release>58.0.7</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>58.0.
|
|
9
|
+
<version>58.0.7</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20260925081306</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3b013569e130377748855287121192d4
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
c66fce1b7df0c1281b2cabcf550be469af735aee
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4531b51612843804ca4cd240ad0c2e8ca8c576a8459e0a5311a68a9859ab7251
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
a2250c863289705ac41b43de2372d4232e10cda70f7fb7e2cc2f1fc32ea8005ad51acbcf9f24f7be1295e4cfe50fed4ee6ed6950bc87557253faa1a1d22f54f3
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/ui",
|
|
3
|
-
"version": "58.0.
|
|
3
|
+
"version": "58.0.7",
|
|
4
4
|
"description": "A collection of UI components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Jetpack Compose",
|
|
@@ -149,8 +149,8 @@
|
|
|
149
149
|
"@types/node": "^22.14.0",
|
|
150
150
|
"@types/react": "~19.3.0",
|
|
151
151
|
"expo-module-scripts": "56.0.3",
|
|
152
|
-
"react-native-reanimated": "4.
|
|
153
|
-
"react-native-worklets": "0.
|
|
152
|
+
"react-native-reanimated": "4.7.0",
|
|
153
|
+
"react-native-worklets": "0.13.0"
|
|
154
154
|
},
|
|
155
155
|
"peerDependencies": {
|
|
156
156
|
"@babel/core": "*",
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
"optional": true
|
|
172
172
|
}
|
|
173
173
|
},
|
|
174
|
-
"gitHead": "
|
|
174
|
+
"gitHead": "ad41d067bd3df6dd12f1788acc6b54a68e7a650d",
|
|
175
175
|
"scripts": {
|
|
176
176
|
"precompile-ios": "et prebuild-package-for-publish",
|
|
177
177
|
"build": "pnpm run build:lib && pnpm run build:plugin",
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { requireNativeView } from 'expo';
|
|
2
2
|
|
|
3
3
|
import type { ExpoModifier } from '../../types';
|
|
4
|
+
import { LazyItems } from '../LazyItems';
|
|
4
5
|
import { createViewModifierEventListener } from '../modifiers/utils';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -77,3 +78,5 @@ function transformProps(props: LazyColumnProps): NativeLazyColumnProps {
|
|
|
77
78
|
export function LazyColumn(props: LazyColumnProps) {
|
|
78
79
|
return <LazyColumnNativeView {...transformProps(props)} />;
|
|
79
80
|
}
|
|
81
|
+
|
|
82
|
+
LazyColumn.Items = LazyItems;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import { Fragment, type ReactElement } from 'react';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
useItemKeys,
|
|
6
|
+
useRecycledRows,
|
|
7
|
+
type RecycledSlotProps,
|
|
8
|
+
type RenderItem,
|
|
9
|
+
type WindowChangeEvent,
|
|
10
|
+
} from '../../recycling/useRecycledRows';
|
|
11
|
+
import { type ViewEvent } from '../../types';
|
|
12
|
+
|
|
13
|
+
export interface LazyItemsProps<ItemT> {
|
|
14
|
+
/** Items to display. Replace the array when updating data. */
|
|
15
|
+
data: readonly ItemT[];
|
|
16
|
+
/** Returns a stable, unique string key, also used as the lazy list item key. */
|
|
17
|
+
keyExtractor: (item: ItemT, index: number) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Renders a row. Wrap it in `useCallback`, or every row re-renders on each parent render.
|
|
20
|
+
* Recycled rows are reused for other items, so their local state (`useState`) carries over.
|
|
21
|
+
* Reset it when the item changes, or keep the state outside the row.
|
|
22
|
+
*/
|
|
23
|
+
children: RenderItem<ItemT>;
|
|
24
|
+
/**
|
|
25
|
+
* Renders only the rows near the visible range and reuses them while scrolling. Set to `false` to
|
|
26
|
+
* render every row at once. Set it once; changing it remounts the rows.
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
recycling?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Extra rows to prepare on each side of the visible rows. Must be a non-negative integer.
|
|
32
|
+
* Ignored when `recycling` is `false`.
|
|
33
|
+
* @default 10
|
|
34
|
+
*/
|
|
35
|
+
overscanCount?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Placeholder size in dp along the scroll axis, until a row is measured. Must be positive.
|
|
38
|
+
* Measurements reset when the data changes. In `LazyColumn.Items` they also reset when the list
|
|
39
|
+
* width changes. Ignored when `recycling` is `false`.
|
|
40
|
+
* @default 64
|
|
41
|
+
*/
|
|
42
|
+
estimatedItemSize?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type NativeLazyItemsProps = ViewEvent<'onWindowChange', WindowChangeEvent> & {
|
|
46
|
+
itemKeys: string[];
|
|
47
|
+
revision: number;
|
|
48
|
+
estimatedItemSize: number;
|
|
49
|
+
children: ReactElement;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const LazyItemsNativeView: React.ComponentType<NativeLazyItemsProps> =
|
|
53
|
+
requireNativeView<NativeLazyItemsProps>('ExpoUI', 'LazyItemsView');
|
|
54
|
+
const LazyItemsSlotNativeView: React.ComponentType<RecycledSlotProps> =
|
|
55
|
+
requireNativeView<RecycledSlotProps>('ExpoUI', 'LazyItemsSlotView');
|
|
56
|
+
const LazyItemsPoolNativeView: React.ComponentType<{ children: ReactElement[] }> =
|
|
57
|
+
requireNativeView('ExpoUI', 'LazyItemsPoolView');
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A block of recycled rows inside `LazyColumn` or `LazyRow`, mirroring the Compose
|
|
61
|
+
* `items(count, key)` builder. Only a small pool of rows around the visible range is mounted,
|
|
62
|
+
* so large data sets stay cheap. Rows that are not ready yet show a placeholder of
|
|
63
|
+
* `estimatedItemSize`, or of the size last measured for that item.
|
|
64
|
+
*
|
|
65
|
+
* Mount it as a direct child of `LazyColumn` or `LazyRow`. Plain children of the same list stay
|
|
66
|
+
* single items, so static and recycled content can be mixed in order.
|
|
67
|
+
* @platform android
|
|
68
|
+
*/
|
|
69
|
+
export const LazyItems = createLazyItems('LazyColumn.Items');
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @hidden
|
|
73
|
+
* Creates the `Items` component of one lazy list, so its errors name that list.
|
|
74
|
+
*/
|
|
75
|
+
export function createLazyItems(componentName: string) {
|
|
76
|
+
function Items<ItemT>({ recycling = true, ...props }: LazyItemsProps<ItemT>) {
|
|
77
|
+
return recycling ? <RecycledItems {...props} /> : <StaticItems {...props} />;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Each row is a plain child of the lazy list, so it becomes one lazy item.
|
|
81
|
+
function StaticItems<ItemT>({
|
|
82
|
+
data,
|
|
83
|
+
keyExtractor,
|
|
84
|
+
children: renderItem,
|
|
85
|
+
}: Omit<LazyItemsProps<ItemT>, 'recycling'>) {
|
|
86
|
+
const itemKeys = useItemKeys(componentName, data, keyExtractor);
|
|
87
|
+
return data.map((item, index) => (
|
|
88
|
+
<Fragment key={itemKeys[index]}>{renderItem({ item, index })}</Fragment>
|
|
89
|
+
));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function RecycledItems<ItemT>({
|
|
93
|
+
data,
|
|
94
|
+
keyExtractor,
|
|
95
|
+
children: renderItem,
|
|
96
|
+
overscanCount,
|
|
97
|
+
estimatedItemSize = 64,
|
|
98
|
+
}: Omit<LazyItemsProps<ItemT>, 'recycling'>) {
|
|
99
|
+
const { itemKeys, revision, rows, onWindowChange } = useRecycledRows({
|
|
100
|
+
componentName,
|
|
101
|
+
Slot: LazyItemsSlotNativeView,
|
|
102
|
+
data,
|
|
103
|
+
keyExtractor,
|
|
104
|
+
renderItem,
|
|
105
|
+
overscanCount,
|
|
106
|
+
estimatedItemSize,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<LazyItemsNativeView
|
|
111
|
+
itemKeys={itemKeys}
|
|
112
|
+
revision={revision}
|
|
113
|
+
estimatedItemSize={estimatedItemSize}
|
|
114
|
+
onWindowChange={({ nativeEvent }) => onWindowChange(nativeEvent)}>
|
|
115
|
+
<LazyItemsPoolNativeView>{rows}</LazyItemsPoolNativeView>
|
|
116
|
+
</LazyItemsNativeView>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
Items.displayName = componentName;
|
|
120
|
+
return Items;
|
|
121
|
+
}
|
|
@@ -2,6 +2,7 @@ import { requireNativeView } from 'expo';
|
|
|
2
2
|
|
|
3
3
|
import type { ExpoModifier } from '../../types';
|
|
4
4
|
import { type ContentPadding } from '../LazyColumn';
|
|
5
|
+
import { createLazyItems } from '../LazyItems';
|
|
5
6
|
import { createViewModifierEventListener } from '../modifiers/utils';
|
|
6
7
|
|
|
7
8
|
export interface LazyRowProps {
|
|
@@ -56,3 +57,5 @@ function transformProps(props: LazyRowProps): NativeLazyRowProps {
|
|
|
56
57
|
export function LazyRow(props: LazyRowProps) {
|
|
57
58
|
return <LazyRowNativeView {...transformProps(props)} />;
|
|
58
59
|
}
|
|
60
|
+
|
|
61
|
+
LazyRow.Items = createLazyItems('LazyRow.Items');
|
|
@@ -17,6 +17,7 @@ export * from './ExposedDropdownMenuBox';
|
|
|
17
17
|
export * from './Divider';
|
|
18
18
|
export * from './Host';
|
|
19
19
|
export * from './LazyColumn';
|
|
20
|
+
export { type LazyItemsProps } from './LazyItems';
|
|
20
21
|
export * from './LazyRow';
|
|
21
22
|
export * from './ListItem';
|
|
22
23
|
export * from './RNHostView';
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import {
|
|
2
|
+
memo,
|
|
3
|
+
useLayoutEffect,
|
|
4
|
+
useMemo,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
type ComponentType,
|
|
8
|
+
type ReactElement,
|
|
9
|
+
} from 'react';
|
|
10
|
+
|
|
11
|
+
import { getSlotIndices, getWindow } from './window';
|
|
12
|
+
|
|
13
|
+
/** Payload of the native event asking for the rows around the visible range. */
|
|
14
|
+
export type WindowChangeEvent = { first: number; last: number; revision: number };
|
|
15
|
+
|
|
16
|
+
/** Props of the native view that holds one recycled row. */
|
|
17
|
+
export type RecycledSlotProps = {
|
|
18
|
+
itemKey: string;
|
|
19
|
+
index: number;
|
|
20
|
+
revision: number;
|
|
21
|
+
children: ReactElement;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** Renders one row of the data set. */
|
|
25
|
+
export type RenderItem<ItemT> = (info: { item: ItemT; index: number }) => ReactElement;
|
|
26
|
+
|
|
27
|
+
type RecycledRowProps<ItemT> = Omit<RecycledSlotProps, 'children'> & {
|
|
28
|
+
Slot: ComponentType<RecycledSlotProps>;
|
|
29
|
+
item: ItemT;
|
|
30
|
+
renderItem: RenderItem<ItemT>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Skip unchanged rows when the window moves.
|
|
34
|
+
const RecycledRow = memo(function RecycledRow<ItemT>({
|
|
35
|
+
Slot,
|
|
36
|
+
item,
|
|
37
|
+
index,
|
|
38
|
+
itemKey,
|
|
39
|
+
revision,
|
|
40
|
+
renderItem,
|
|
41
|
+
}: RecycledRowProps<ItemT>) {
|
|
42
|
+
return (
|
|
43
|
+
<Slot itemKey={itemKey} index={index} revision={revision}>
|
|
44
|
+
{renderItem({ item, index })}
|
|
45
|
+
</Slot>
|
|
46
|
+
);
|
|
47
|
+
}) as <ItemT>(props: RecycledRowProps<ItemT>) => ReactElement;
|
|
48
|
+
|
|
49
|
+
export type RecycledRows = {
|
|
50
|
+
/** Keys of every item, so the native list can size and identify the full data set. */
|
|
51
|
+
itemKeys: string[];
|
|
52
|
+
/** Increases whenever the data changes, so late native events can be dropped. */
|
|
53
|
+
revision: number;
|
|
54
|
+
/** The pooled rows to mount, one per slot. */
|
|
55
|
+
rows: ReactElement[];
|
|
56
|
+
/** Applies a native window request. */
|
|
57
|
+
onWindowChange: (event: WindowChangeEvent) => void;
|
|
58
|
+
/** Whether a native event was sent for the data currently committed to native. */
|
|
59
|
+
isCurrentRevision: (revision: number) => boolean;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Returns one key per item. Keys follow `data` only: an inline `keyExtractor` changes identity on
|
|
64
|
+
* every parent render, and recomputing keys for it would bump the revision and re-render every row.
|
|
65
|
+
*/
|
|
66
|
+
export function useItemKeys<ItemT>(
|
|
67
|
+
componentName: string,
|
|
68
|
+
data: readonly ItemT[],
|
|
69
|
+
keyExtractor: (item: ItemT, index: number) => string
|
|
70
|
+
): string[] {
|
|
71
|
+
const keyExtractorRef = useRef(keyExtractor);
|
|
72
|
+
keyExtractorRef.current = keyExtractor;
|
|
73
|
+
return useMemo(() => {
|
|
74
|
+
const keys = data.map((item, index) => keyExtractorRef.current(item, index));
|
|
75
|
+
if (keys.some((key) => typeof key !== 'string') || new Set(keys).size !== keys.length) {
|
|
76
|
+
throw new Error(`${componentName} keyExtractor must return a unique string for every item.`);
|
|
77
|
+
}
|
|
78
|
+
return keys;
|
|
79
|
+
}, [data]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Keeps a fixed pool of rows centered on the range the native list asks for.
|
|
84
|
+
* Item `index` always renders in slot `index % capacity`, so moving the window
|
|
85
|
+
* only re-renders the slots whose item changed.
|
|
86
|
+
*/
|
|
87
|
+
export function useRecycledRows<ItemT>({
|
|
88
|
+
componentName,
|
|
89
|
+
Slot,
|
|
90
|
+
data,
|
|
91
|
+
keyExtractor,
|
|
92
|
+
renderItem,
|
|
93
|
+
overscanCount = 10,
|
|
94
|
+
estimatedItemSize = 64,
|
|
95
|
+
}: {
|
|
96
|
+
/** Name used in error messages, for example `List.ForEach`. */
|
|
97
|
+
componentName: string;
|
|
98
|
+
/** Native view that holds one recycled row. */
|
|
99
|
+
Slot: ComponentType<RecycledSlotProps>;
|
|
100
|
+
data: readonly ItemT[];
|
|
101
|
+
keyExtractor: (item: ItemT, index: number) => string;
|
|
102
|
+
renderItem: RenderItem<ItemT>;
|
|
103
|
+
overscanCount?: number;
|
|
104
|
+
estimatedItemSize?: number;
|
|
105
|
+
}): RecycledRows {
|
|
106
|
+
if (!Number.isSafeInteger(overscanCount) || overscanCount < 0) {
|
|
107
|
+
throw new Error(`${componentName} overscanCount must be a non-negative integer.`);
|
|
108
|
+
}
|
|
109
|
+
if (!Number.isFinite(estimatedItemSize) || estimatedItemSize <= 0) {
|
|
110
|
+
throw new Error(`${componentName} estimatedItemSize must be a positive finite number.`);
|
|
111
|
+
}
|
|
112
|
+
const itemKeys = useItemKeys(componentName, data, keyExtractor);
|
|
113
|
+
const [state, setState] = useState({
|
|
114
|
+
keys: itemKeys,
|
|
115
|
+
first: 0,
|
|
116
|
+
last: 0,
|
|
117
|
+
revision: 0,
|
|
118
|
+
capacity: 0,
|
|
119
|
+
overscanCount,
|
|
120
|
+
});
|
|
121
|
+
let current = state;
|
|
122
|
+
if (state.keys !== itemKeys) {
|
|
123
|
+
const previousKey = state.keys[state.first];
|
|
124
|
+
const anchor = previousKey === undefined ? 0 : Math.max(0, itemKeys.indexOf(previousKey));
|
|
125
|
+
current = {
|
|
126
|
+
...state,
|
|
127
|
+
keys: itemKeys,
|
|
128
|
+
first: Math.min(anchor, Math.max(0, data.length - 1)),
|
|
129
|
+
last: Math.min(anchor + state.last - state.first, Math.max(0, data.length - 1)),
|
|
130
|
+
revision: state.revision + 1,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (current.overscanCount !== overscanCount) {
|
|
134
|
+
current = { ...current, overscanCount, capacity: 0 };
|
|
135
|
+
}
|
|
136
|
+
if (current !== state) setState(current);
|
|
137
|
+
const { start, capacity } = getWindow(
|
|
138
|
+
data.length,
|
|
139
|
+
current.first,
|
|
140
|
+
current.last,
|
|
141
|
+
overscanCount,
|
|
142
|
+
current.capacity
|
|
143
|
+
);
|
|
144
|
+
const committedRevision = useRef(current.revision);
|
|
145
|
+
useLayoutEffect(() => {
|
|
146
|
+
committedRevision.current = current.revision;
|
|
147
|
+
}, [current.revision]);
|
|
148
|
+
|
|
149
|
+
const rows = getSlotIndices(start, capacity).map((index, slot) => {
|
|
150
|
+
const item = data[index];
|
|
151
|
+
const itemKey = itemKeys[index];
|
|
152
|
+
if (item === undefined || itemKey === undefined) {
|
|
153
|
+
throw new Error(`${componentName} could not resolve the item at index ${index}.`);
|
|
154
|
+
}
|
|
155
|
+
return (
|
|
156
|
+
<RecycledRow
|
|
157
|
+
key={slot}
|
|
158
|
+
Slot={Slot}
|
|
159
|
+
item={item}
|
|
160
|
+
index={index}
|
|
161
|
+
itemKey={itemKey}
|
|
162
|
+
revision={current.revision}
|
|
163
|
+
renderItem={renderItem}
|
|
164
|
+
/>
|
|
165
|
+
);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
itemKeys,
|
|
170
|
+
revision: current.revision,
|
|
171
|
+
rows,
|
|
172
|
+
isCurrentRevision: (revision) => revision === committedRevision.current,
|
|
173
|
+
onWindowChange: (event) => {
|
|
174
|
+
if (
|
|
175
|
+
!Number.isSafeInteger(event.first) ||
|
|
176
|
+
!Number.isSafeInteger(event.last) ||
|
|
177
|
+
event.last < event.first
|
|
178
|
+
) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
setState((previous) => {
|
|
182
|
+
// Ignore requests from before a data change.
|
|
183
|
+
if (event.revision !== previous.revision) return previous;
|
|
184
|
+
const maximum = Math.max(0, previous.keys.length - 1);
|
|
185
|
+
const first = Math.max(0, Math.min(event.first, maximum));
|
|
186
|
+
const last = Math.max(first, Math.min(event.last, maximum));
|
|
187
|
+
const { capacity } = getWindow(
|
|
188
|
+
previous.keys.length,
|
|
189
|
+
first,
|
|
190
|
+
last,
|
|
191
|
+
previous.overscanCount,
|
|
192
|
+
previous.capacity
|
|
193
|
+
);
|
|
194
|
+
return first === previous.first && last === previous.last && capacity === previous.capacity
|
|
195
|
+
? previous
|
|
196
|
+
: { ...previous, first, last, capacity };
|
|
197
|
+
});
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|