@depup/react-native-web 0.21.2-depup.0

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 (864) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +34 -0
  3. package/changes.json +22 -0
  4. package/dist/cjs/exports/AccessibilityInfo/index.js +99 -0
  5. package/dist/cjs/exports/ActivityIndicator/index.js +106 -0
  6. package/dist/cjs/exports/Alert/index.js +18 -0
  7. package/dist/cjs/exports/Animated/index.js +18 -0
  8. package/dist/cjs/exports/AppRegistry/AppContainer.js +47 -0
  9. package/dist/cjs/exports/AppRegistry/index.js +92 -0
  10. package/dist/cjs/exports/AppRegistry/renderApplication.js +55 -0
  11. package/dist/cjs/exports/AppState/index.js +63 -0
  12. package/dist/cjs/exports/Appearance/index.js +54 -0
  13. package/dist/cjs/exports/BackHandler/index.js +27 -0
  14. package/dist/cjs/exports/Button/index.js +68 -0
  15. package/dist/cjs/exports/CheckBox/index.js +112 -0
  16. package/dist/cjs/exports/Clipboard/index.js +61 -0
  17. package/dist/cjs/exports/DeviceEventEmitter/index.js +8 -0
  18. package/dist/cjs/exports/Dimensions/index.js +128 -0
  19. package/dist/cjs/exports/Easing/index.js +16 -0
  20. package/dist/cjs/exports/FlatList/index.js +19 -0
  21. package/dist/cjs/exports/I18nManager/index.js +29 -0
  22. package/dist/cjs/exports/Image/index.js +364 -0
  23. package/dist/cjs/exports/Image/types.js +1 -0
  24. package/dist/cjs/exports/ImageBackground/index.js +59 -0
  25. package/dist/cjs/exports/InputAccessoryView/index.js +8 -0
  26. package/dist/cjs/exports/InteractionManager/TaskQueue.js +93 -0
  27. package/dist/cjs/exports/InteractionManager/index.js +130 -0
  28. package/dist/cjs/exports/Keyboard/index.js +34 -0
  29. package/dist/cjs/exports/KeyboardAvoidingView/index.js +52 -0
  30. package/dist/cjs/exports/LayoutAnimation/index.js +17 -0
  31. package/dist/cjs/exports/Linking/index.js +109 -0
  32. package/dist/cjs/exports/LogBox/index.js +21 -0
  33. package/dist/cjs/exports/Modal/ModalAnimation.js +149 -0
  34. package/dist/cjs/exports/Modal/ModalContent.js +75 -0
  35. package/dist/cjs/exports/Modal/ModalFocusTrap.js +138 -0
  36. package/dist/cjs/exports/Modal/ModalPortal.js +43 -0
  37. package/dist/cjs/exports/Modal/index.js +106 -0
  38. package/dist/cjs/exports/NativeEventEmitter/index.js +16 -0
  39. package/dist/cjs/exports/NativeModules/index.js +21 -0
  40. package/dist/cjs/exports/PanResponder/Alternative.js +273 -0
  41. package/dist/cjs/exports/PanResponder/index.js +8 -0
  42. package/dist/cjs/exports/Picker/PickerItem.js +32 -0
  43. package/dist/cjs/exports/Picker/index.js +73 -0
  44. package/dist/cjs/exports/PixelRatio/index.js +55 -0
  45. package/dist/cjs/exports/Platform/index.js +29 -0
  46. package/dist/cjs/exports/Pressable/index.js +158 -0
  47. package/dist/cjs/exports/ProgressBar/index.js +81 -0
  48. package/dist/cjs/exports/RefreshControl/index.js +34 -0
  49. package/dist/cjs/exports/SafeAreaView/index.js +47 -0
  50. package/dist/cjs/exports/ScrollView/ScrollViewBase.js +150 -0
  51. package/dist/cjs/exports/ScrollView/index.js +662 -0
  52. package/dist/cjs/exports/SectionList/index.js +18 -0
  53. package/dist/cjs/exports/Share/index.js +53 -0
  54. package/dist/cjs/exports/StatusBar/index.js +24 -0
  55. package/dist/cjs/exports/StyleSheet/compiler/createReactDOMStyle.js +184 -0
  56. package/dist/cjs/exports/StyleSheet/compiler/hash.js +52 -0
  57. package/dist/cjs/exports/StyleSheet/compiler/hyphenateStyleName.js +28 -0
  58. package/dist/cjs/exports/StyleSheet/compiler/index.js +484 -0
  59. package/dist/cjs/exports/StyleSheet/compiler/normalizeColor.js +36 -0
  60. package/dist/cjs/exports/StyleSheet/compiler/normalizeValueWithProperty.js +38 -0
  61. package/dist/cjs/exports/StyleSheet/compiler/resolveShadowValue.js +38 -0
  62. package/dist/cjs/exports/StyleSheet/compiler/unitlessNumbers.js +80 -0
  63. package/dist/cjs/exports/StyleSheet/dom/createCSSStyleSheet.js +42 -0
  64. package/dist/cjs/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js +168 -0
  65. package/dist/cjs/exports/StyleSheet/dom/index.js +78 -0
  66. package/dist/cjs/exports/StyleSheet/index.js +190 -0
  67. package/dist/cjs/exports/StyleSheet/preprocess.js +222 -0
  68. package/dist/cjs/exports/StyleSheet/validate.js +89 -0
  69. package/dist/cjs/exports/Switch/index.js +194 -0
  70. package/dist/cjs/exports/Text/TextAncestorContext.js +18 -0
  71. package/dist/cjs/exports/Text/index.js +199 -0
  72. package/dist/cjs/exports/Text/types.js +1 -0
  73. package/dist/cjs/exports/TextInput/index.js +424 -0
  74. package/dist/cjs/exports/TextInput/types.js +1 -0
  75. package/dist/cjs/exports/Touchable/BoundingDimensions.js +35 -0
  76. package/dist/cjs/exports/Touchable/Position.js +27 -0
  77. package/dist/cjs/exports/Touchable/ensurePositiveDelayProps.js +20 -0
  78. package/dist/cjs/exports/Touchable/index.js +839 -0
  79. package/dist/cjs/exports/TouchableHighlight/index.js +152 -0
  80. package/dist/cjs/exports/TouchableNativeFeedback/index.js +16 -0
  81. package/dist/cjs/exports/TouchableOpacity/index.js +121 -0
  82. package/dist/cjs/exports/TouchableWithoutFeedback/index.js +78 -0
  83. package/dist/cjs/exports/UIManager/index.js +133 -0
  84. package/dist/cjs/exports/Vibration/index.js +32 -0
  85. package/dist/cjs/exports/View/index.js +146 -0
  86. package/dist/cjs/exports/View/types.js +1 -0
  87. package/dist/cjs/exports/VirtualizedList/index.js +18 -0
  88. package/dist/cjs/exports/YellowBox/index.js +23 -0
  89. package/dist/cjs/exports/createElement/index.js +39 -0
  90. package/dist/cjs/exports/findNodeHandle/index.js +19 -0
  91. package/dist/cjs/exports/processColor/index.js +31 -0
  92. package/dist/cjs/exports/render/index.js +27 -0
  93. package/dist/cjs/exports/unmountComponentAtNode/index.js +18 -0
  94. package/dist/cjs/exports/useColorScheme/index.js +34 -0
  95. package/dist/cjs/exports/useLocaleContext/index.js +17 -0
  96. package/dist/cjs/exports/useWindowDimensions/index.js +41 -0
  97. package/dist/cjs/index.js +127 -0
  98. package/dist/cjs/modules/AccessibilityUtil/index.js +24 -0
  99. package/dist/cjs/modules/AccessibilityUtil/isDisabled.js +16 -0
  100. package/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityComponent.js +60 -0
  101. package/dist/cjs/modules/AccessibilityUtil/propsToAriaRole.js +41 -0
  102. package/dist/cjs/modules/AssetRegistry/index.js +23 -0
  103. package/dist/cjs/modules/ImageLoader/index.js +149 -0
  104. package/dist/cjs/modules/TextInputState/index.js +65 -0
  105. package/dist/cjs/modules/UnimplementedView/index.js +35 -0
  106. package/dist/cjs/modules/addEventListener/index.js +75 -0
  107. package/dist/cjs/modules/canUseDom/index.js +16 -0
  108. package/dist/cjs/modules/createDOMProps/index.js +844 -0
  109. package/dist/cjs/modules/dismissKeyboard/index.js +20 -0
  110. package/dist/cjs/modules/forwardedProps/index.js +169 -0
  111. package/dist/cjs/modules/getBoundingClientRect/index.js +23 -0
  112. package/dist/cjs/modules/isSelectionValid/index.js +22 -0
  113. package/dist/cjs/modules/isWebColor/index.js +16 -0
  114. package/dist/cjs/modules/mergeRefs/index.js +37 -0
  115. package/dist/cjs/modules/modality/index.js +196 -0
  116. package/dist/cjs/modules/multiplyStyleLengthValue/index.js +29 -0
  117. package/dist/cjs/modules/normalizeColor/index.js +36 -0
  118. package/dist/cjs/modules/pick/index.js +25 -0
  119. package/dist/cjs/modules/prefixStyles/index.js +19 -0
  120. package/dist/cjs/modules/prefixStyles/static.js +74 -0
  121. package/dist/cjs/modules/requestIdleCallback/index.js +33 -0
  122. package/dist/cjs/modules/setValueForStyles/dangerousStyleValue.js +49 -0
  123. package/dist/cjs/modules/setValueForStyles/index.js +45 -0
  124. package/dist/cjs/modules/unitlessNumbers/index.js +80 -0
  125. package/dist/cjs/modules/useElementLayout/index.js +91 -0
  126. package/dist/cjs/modules/useEvent/index.js +54 -0
  127. package/dist/cjs/modules/useHover/index.js +158 -0
  128. package/dist/cjs/modules/useLayoutEffect/index.js +22 -0
  129. package/dist/cjs/modules/useLocale/index.js +42 -0
  130. package/dist/cjs/modules/useLocale/isLocaleRTL.js +87 -0
  131. package/dist/cjs/modules/useMergeRefs/index.js +26 -0
  132. package/dist/cjs/modules/usePlatformMethods/index.js +34 -0
  133. package/dist/cjs/modules/usePressEvents/PressResponder.js +496 -0
  134. package/dist/cjs/modules/usePressEvents/index.js +40 -0
  135. package/dist/cjs/modules/useResponderEvents/ResponderEventTypes.js +51 -0
  136. package/dist/cjs/modules/useResponderEvents/ResponderSystem.js +598 -0
  137. package/dist/cjs/modules/useResponderEvents/ResponderTouchHistoryStore.js +175 -0
  138. package/dist/cjs/modules/useResponderEvents/createResponderEvent.js +152 -0
  139. package/dist/cjs/modules/useResponderEvents/index.js +79 -0
  140. package/dist/cjs/modules/useResponderEvents/utils.js +175 -0
  141. package/dist/cjs/modules/useStable/index.js +25 -0
  142. package/dist/cjs/modules/warnOnce/index.js +31 -0
  143. package/dist/cjs/types/index.js +1 -0
  144. package/dist/cjs/types/styles.js +1 -0
  145. package/dist/cjs/vendor/hash/index.js +52 -0
  146. package/dist/cjs/vendor/react-native/Animated/Animated.js +35 -0
  147. package/dist/cjs/vendor/react-native/Animated/AnimatedEvent.js +167 -0
  148. package/dist/cjs/vendor/react-native/Animated/AnimatedImplementation.js +582 -0
  149. package/dist/cjs/vendor/react-native/Animated/AnimatedMock.js +140 -0
  150. package/dist/cjs/vendor/react-native/Animated/AnimatedPlatformConfig.js +11 -0
  151. package/dist/cjs/vendor/react-native/Animated/Easing.js +253 -0
  152. package/dist/cjs/vendor/react-native/Animated/NativeAnimatedHelper.js +480 -0
  153. package/dist/cjs/vendor/react-native/Animated/NativeAnimatedModule.js +19 -0
  154. package/dist/cjs/vendor/react-native/Animated/NativeAnimatedTurboModule.js +19 -0
  155. package/dist/cjs/vendor/react-native/Animated/SpringConfig.js +72 -0
  156. package/dist/cjs/vendor/react-native/Animated/animations/Animation.js +59 -0
  157. package/dist/cjs/vendor/react-native/Animated/animations/DecayAnimation.js +74 -0
  158. package/dist/cjs/vendor/react-native/Animated/animations/SpringAnimation.js +226 -0
  159. package/dist/cjs/vendor/react-native/Animated/animations/TimingAnimation.js +120 -0
  160. package/dist/cjs/vendor/react-native/Animated/bezier.js +125 -0
  161. package/dist/cjs/vendor/react-native/Animated/components/AnimatedFlatList.js +30 -0
  162. package/dist/cjs/vendor/react-native/Animated/components/AnimatedImage.js +20 -0
  163. package/dist/cjs/vendor/react-native/Animated/components/AnimatedScrollView.js +30 -0
  164. package/dist/cjs/vendor/react-native/Animated/components/AnimatedSectionList.js +30 -0
  165. package/dist/cjs/vendor/react-native/Animated/components/AnimatedText.js +20 -0
  166. package/dist/cjs/vendor/react-native/Animated/components/AnimatedView.js +20 -0
  167. package/dist/cjs/vendor/react-native/Animated/createAnimatedComponent.js +52 -0
  168. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedAddition.js +53 -0
  169. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedColor.js +288 -0
  170. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedDiffClamp.js +57 -0
  171. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedDivision.js +70 -0
  172. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedInterpolation.js +270 -0
  173. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedModulo.js +50 -0
  174. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedMultiplication.js +53 -0
  175. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedNode.js +163 -0
  176. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedProps.js +145 -0
  177. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedStyle.js +128 -0
  178. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedSubtraction.js +53 -0
  179. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedTracking.js +76 -0
  180. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedTransform.js +113 -0
  181. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedValue.js +271 -0
  182. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedValueXY.js +191 -0
  183. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedWithChildren.js +77 -0
  184. package/dist/cjs/vendor/react-native/Animated/useAnimatedProps.js +158 -0
  185. package/dist/cjs/vendor/react-native/Batchinator/index.js +82 -0
  186. package/dist/cjs/vendor/react-native/EventEmitter/NativeEventEmitter.js +82 -0
  187. package/dist/cjs/vendor/react-native/EventEmitter/RCTDeviceEventEmitter.js +24 -0
  188. package/dist/cjs/vendor/react-native/FillRateHelper/index.js +196 -0
  189. package/dist/cjs/vendor/react-native/FlatList/index.js +451 -0
  190. package/dist/cjs/vendor/react-native/JSEventLoopWatchdog/index.js +90 -0
  191. package/dist/cjs/vendor/react-native/LayoutAnimation/index.js +112 -0
  192. package/dist/cjs/vendor/react-native/PanResponder/index.js +420 -0
  193. package/dist/cjs/vendor/react-native/PooledClass/index.js +64 -0
  194. package/dist/cjs/vendor/react-native/ReactNative/ReactNativeFeatureFlags.js +23 -0
  195. package/dist/cjs/vendor/react-native/SectionList/index.js +150 -0
  196. package/dist/cjs/vendor/react-native/StaticContainer/index.js +43 -0
  197. package/dist/cjs/vendor/react-native/StaticRenderer/index.js +26 -0
  198. package/dist/cjs/vendor/react-native/TouchHistoryMath/index.js +105 -0
  199. package/dist/cjs/vendor/react-native/TurboModule/RCTExport.js +29 -0
  200. package/dist/cjs/vendor/react-native/TurboModule/TurboModuleRegistry.js +25 -0
  201. package/dist/cjs/vendor/react-native/Types/CoreEventTypes.js +11 -0
  202. package/dist/cjs/vendor/react-native/Utilities/Platform.js +8 -0
  203. package/dist/cjs/vendor/react-native/Utilities/clamp.js +25 -0
  204. package/dist/cjs/vendor/react-native/Utilities/setAndForwardRef.js +64 -0
  205. package/dist/cjs/vendor/react-native/Utilities/useMergeRefs.js +43 -0
  206. package/dist/cjs/vendor/react-native/Utilities/useRefEffect.js +42 -0
  207. package/dist/cjs/vendor/react-native/ViewabilityHelper/index.js +210 -0
  208. package/dist/cjs/vendor/react-native/VirtualizeUtils/index.js +180 -0
  209. package/dist/cjs/vendor/react-native/VirtualizedList/CellRenderMask.js +112 -0
  210. package/dist/cjs/vendor/react-native/VirtualizedList/ChildListCollection.js +75 -0
  211. package/dist/cjs/vendor/react-native/VirtualizedList/StateSafePureComponent.js +77 -0
  212. package/dist/cjs/vendor/react-native/VirtualizedList/VirtualizedListCellRenderer.js +161 -0
  213. package/dist/cjs/vendor/react-native/VirtualizedList/VirtualizedListContext.js +73 -0
  214. package/dist/cjs/vendor/react-native/VirtualizedList/VirtualizedListProps.js +6 -0
  215. package/dist/cjs/vendor/react-native/VirtualizedList/index.js +1486 -0
  216. package/dist/cjs/vendor/react-native/VirtualizedSectionList/index.js +390 -0
  217. package/dist/cjs/vendor/react-native/deepDiffer/index.js +73 -0
  218. package/dist/cjs/vendor/react-native/infoLog/index.js +22 -0
  219. package/dist/cjs/vendor/react-native/vendor/emitter/EventEmitter.js +104 -0
  220. package/dist/exports/AccessibilityInfo/index.js +94 -0
  221. package/dist/exports/AccessibilityInfo/index.js.flow +76 -0
  222. package/dist/exports/ActivityIndicator/index.js +100 -0
  223. package/dist/exports/ActivityIndicator/index.js.flow +88 -0
  224. package/dist/exports/Alert/index.js +13 -0
  225. package/dist/exports/Alert/index.js.flow +12 -0
  226. package/dist/exports/Animated/index.js +13 -0
  227. package/dist/exports/Animated/index.js.flow +13 -0
  228. package/dist/exports/AppRegistry/AppContainer.js +40 -0
  229. package/dist/exports/AppRegistry/AppContainer.js.flow +43 -0
  230. package/dist/exports/AppRegistry/index.js +85 -0
  231. package/dist/exports/AppRegistry/index.js.flow +58 -0
  232. package/dist/exports/AppRegistry/renderApplication.js +48 -0
  233. package/dist/exports/AppRegistry/renderApplication.js.flow +28 -0
  234. package/dist/exports/AppState/index.js +58 -0
  235. package/dist/exports/AppState/index.js.flow +31 -0
  236. package/dist/exports/Appearance/index.js +49 -0
  237. package/dist/exports/Appearance/index.js.flow +50 -0
  238. package/dist/exports/BackHandler/index.js +22 -0
  239. package/dist/exports/BackHandler/index.js.flow +23 -0
  240. package/dist/exports/Button/index.js +61 -0
  241. package/dist/exports/Button/index.js.flow +65 -0
  242. package/dist/exports/CheckBox/index.js +106 -0
  243. package/dist/exports/CheckBox/index.js.flow +108 -0
  244. package/dist/exports/Clipboard/index.js +56 -0
  245. package/dist/exports/Clipboard/index.js.flow +18 -0
  246. package/dist/exports/DeviceEventEmitter/index.js +2 -0
  247. package/dist/exports/Dimensions/index.js +122 -0
  248. package/dist/exports/Dimensions/index.js.flow +58 -0
  249. package/dist/exports/Easing/index.js +11 -0
  250. package/dist/exports/Easing/index.js.flow +11 -0
  251. package/dist/exports/FlatList/index.js +14 -0
  252. package/dist/exports/FlatList/index.js.flow +14 -0
  253. package/dist/exports/I18nManager/index.js +24 -0
  254. package/dist/exports/I18nManager/index.js.flow +32 -0
  255. package/dist/exports/Image/index.js +358 -0
  256. package/dist/exports/Image/index.js.flow +225 -0
  257. package/dist/exports/Image/types.js +0 -0
  258. package/dist/exports/Image/types.js.flow +94 -0
  259. package/dist/exports/ImageBackground/index.js +53 -0
  260. package/dist/exports/ImageBackground/index.js.flow +57 -0
  261. package/dist/exports/InputAccessoryView/index.js +2 -0
  262. package/dist/exports/InteractionManager/TaskQueue.js +87 -0
  263. package/dist/exports/InteractionManager/TaskQueue.js.flow +40 -0
  264. package/dist/exports/InteractionManager/index.js +124 -0
  265. package/dist/exports/InteractionManager/index.js.flow +99 -0
  266. package/dist/exports/Keyboard/index.js +29 -0
  267. package/dist/exports/Keyboard/index.js.flow +31 -0
  268. package/dist/exports/KeyboardAvoidingView/index.js +46 -0
  269. package/dist/exports/KeyboardAvoidingView/index.js.flow +30 -0
  270. package/dist/exports/LayoutAnimation/index.js +12 -0
  271. package/dist/exports/LayoutAnimation/index.js.flow +12 -0
  272. package/dist/exports/Linking/index.js +103 -0
  273. package/dist/exports/Linking/index.js.flow +30 -0
  274. package/dist/exports/LogBox/index.js +16 -0
  275. package/dist/exports/LogBox/index.js.flow +16 -0
  276. package/dist/exports/Modal/ModalAnimation.js +142 -0
  277. package/dist/exports/Modal/ModalAnimation.js.flow +94 -0
  278. package/dist/exports/Modal/ModalContent.js +69 -0
  279. package/dist/exports/Modal/ModalContent.js.flow +64 -0
  280. package/dist/exports/Modal/ModalFocusTrap.js +132 -0
  281. package/dist/exports/Modal/ModalFocusTrap.js.flow +39 -0
  282. package/dist/exports/Modal/ModalPortal.js +36 -0
  283. package/dist/exports/Modal/ModalPortal.js.flow +18 -0
  284. package/dist/exports/Modal/index.js +100 -0
  285. package/dist/exports/Modal/index.js.flow +83 -0
  286. package/dist/exports/NativeEventEmitter/index.js +11 -0
  287. package/dist/exports/NativeEventEmitter/index.js.flow +11 -0
  288. package/dist/exports/NativeModules/index.js +16 -0
  289. package/dist/exports/NativeModules/index.js.flow +16 -0
  290. package/dist/exports/PanResponder/Alternative.js +269 -0
  291. package/dist/exports/PanResponder/Alternative.js.flow +335 -0
  292. package/dist/exports/PanResponder/index.js +2 -0
  293. package/dist/exports/PanResponder/index.js.flow +4 -0
  294. package/dist/exports/Picker/PickerItem.js +26 -0
  295. package/dist/exports/Picker/PickerItem.js.flow +19 -0
  296. package/dist/exports/Picker/index.js +67 -0
  297. package/dist/exports/Picker/index.js.flow +74 -0
  298. package/dist/exports/PixelRatio/index.js +49 -0
  299. package/dist/exports/PixelRatio/index.js.flow +21 -0
  300. package/dist/exports/Platform/index.js +24 -0
  301. package/dist/exports/Platform/index.js.flow +24 -0
  302. package/dist/exports/Pressable/index.js +152 -0
  303. package/dist/exports/Pressable/index.js.flow +80 -0
  304. package/dist/exports/ProgressBar/index.js +75 -0
  305. package/dist/exports/ProgressBar/index.js.flow +72 -0
  306. package/dist/exports/RefreshControl/index.js +29 -0
  307. package/dist/exports/RefreshControl/index.js.flow +30 -0
  308. package/dist/exports/SafeAreaView/index.js +41 -0
  309. package/dist/exports/SafeAreaView/index.js.flow +38 -0
  310. package/dist/exports/ScrollView/ScrollViewBase.js +144 -0
  311. package/dist/exports/ScrollView/ScrollViewBase.js.flow +74 -0
  312. package/dist/exports/ScrollView/index.js +657 -0
  313. package/dist/exports/ScrollView/index.js.flow +140 -0
  314. package/dist/exports/SectionList/index.js +13 -0
  315. package/dist/exports/SectionList/index.js.flow +13 -0
  316. package/dist/exports/Share/index.js +47 -0
  317. package/dist/exports/Share/index.js.flow +26 -0
  318. package/dist/exports/StatusBar/index.js +19 -0
  319. package/dist/exports/StatusBar/index.js.flow +16 -0
  320. package/dist/exports/StyleSheet/compiler/createReactDOMStyle.js +178 -0
  321. package/dist/exports/StyleSheet/compiler/createReactDOMStyle.js.flow +84 -0
  322. package/dist/exports/StyleSheet/compiler/hash.js +47 -0
  323. package/dist/exports/StyleSheet/compiler/hash.js.flow +18 -0
  324. package/dist/exports/StyleSheet/compiler/hyphenateStyleName.js +23 -0
  325. package/dist/exports/StyleSheet/compiler/hyphenateStyleName.js.flow +15 -0
  326. package/dist/exports/StyleSheet/compiler/index.js +477 -0
  327. package/dist/exports/StyleSheet/compiler/index.js.flow +180 -0
  328. package/dist/exports/StyleSheet/compiler/normalizeColor.js +30 -0
  329. package/dist/exports/StyleSheet/compiler/normalizeColor.js.flow +13 -0
  330. package/dist/exports/StyleSheet/compiler/normalizeValueWithProperty.js +32 -0
  331. package/dist/exports/StyleSheet/compiler/normalizeValueWithProperty.js.flow +24 -0
  332. package/dist/exports/StyleSheet/compiler/resolveShadowValue.js +32 -0
  333. package/dist/exports/StyleSheet/compiler/resolveShadowValue.js.flow +17 -0
  334. package/dist/exports/StyleSheet/compiler/unitlessNumbers.js +75 -0
  335. package/dist/exports/StyleSheet/compiler/unitlessNumbers.js.flow +73 -0
  336. package/dist/exports/StyleSheet/dom/createCSSStyleSheet.js +36 -0
  337. package/dist/exports/StyleSheet/dom/createCSSStyleSheet.js.flow +12 -0
  338. package/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js +163 -0
  339. package/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js.flow +52 -0
  340. package/dist/exports/StyleSheet/dom/index.js +73 -0
  341. package/dist/exports/StyleSheet/dom/index.js.flow +26 -0
  342. package/dist/exports/StyleSheet/index.js +185 -0
  343. package/dist/exports/StyleSheet/index.js.flow +97 -0
  344. package/dist/exports/StyleSheet/preprocess.js +212 -0
  345. package/dist/exports/StyleSheet/preprocess.js.flow +73 -0
  346. package/dist/exports/StyleSheet/validate.js +84 -0
  347. package/dist/exports/StyleSheet/validate.js.flow +46 -0
  348. package/dist/exports/Switch/index.js +188 -0
  349. package/dist/exports/Switch/index.js.flow +187 -0
  350. package/dist/exports/Text/TextAncestorContext.js +14 -0
  351. package/dist/exports/Text/TextAncestorContext.js.flow +15 -0
  352. package/dist/exports/Text/index.js +193 -0
  353. package/dist/exports/Text/index.js.flow +198 -0
  354. package/dist/exports/Text/types.js +0 -0
  355. package/dist/exports/Text/types.js.flow +65 -0
  356. package/dist/exports/TextInput/index.js +418 -0
  357. package/dist/exports/TextInput/index.js.flow +315 -0
  358. package/dist/exports/TextInput/types.js +0 -0
  359. package/dist/exports/TextInput/types.js.flow +65 -0
  360. package/dist/exports/Touchable/BoundingDimensions.js +29 -0
  361. package/dist/exports/Touchable/BoundingDimensions.js.flow +26 -0
  362. package/dist/exports/Touchable/Position.js +21 -0
  363. package/dist/exports/Touchable/Position.js.flow +18 -0
  364. package/dist/exports/Touchable/ensurePositiveDelayProps.js +14 -0
  365. package/dist/exports/Touchable/ensurePositiveDelayProps.js.flow +12 -0
  366. package/dist/exports/Touchable/index.js +835 -0
  367. package/dist/exports/Touchable/index.js.flow +849 -0
  368. package/dist/exports/TouchableHighlight/index.js +146 -0
  369. package/dist/exports/TouchableHighlight/index.js.flow +65 -0
  370. package/dist/exports/TouchableNativeFeedback/index.js +11 -0
  371. package/dist/exports/TouchableNativeFeedback/index.js.flow +11 -0
  372. package/dist/exports/TouchableOpacity/index.js +115 -0
  373. package/dist/exports/TouchableOpacity/index.js.flow +48 -0
  374. package/dist/exports/TouchableWithoutFeedback/index.js +72 -0
  375. package/dist/exports/TouchableWithoutFeedback/index.js.flow +62 -0
  376. package/dist/exports/UIManager/index.js +127 -0
  377. package/dist/exports/UIManager/index.js.flow +92 -0
  378. package/dist/exports/Vibration/index.js +27 -0
  379. package/dist/exports/Vibration/index.js.flow +21 -0
  380. package/dist/exports/View/index.js +140 -0
  381. package/dist/exports/View/index.js.flow +146 -0
  382. package/dist/exports/View/types.js +0 -0
  383. package/dist/exports/View/types.js.flow +223 -0
  384. package/dist/exports/VirtualizedList/index.js +13 -0
  385. package/dist/exports/VirtualizedList/index.js.flow +13 -0
  386. package/dist/exports/YellowBox/index.js +17 -0
  387. package/dist/exports/YellowBox/index.js.flow +16 -0
  388. package/dist/exports/createElement/index.js +34 -0
  389. package/dist/exports/createElement/index.js.flow +17 -0
  390. package/dist/exports/findNodeHandle/index.js +14 -0
  391. package/dist/exports/findNodeHandle/index.js.flow +11 -0
  392. package/dist/exports/processColor/index.js +25 -0
  393. package/dist/exports/processColor/index.js.flow +13 -0
  394. package/dist/exports/render/index.js +23 -0
  395. package/dist/exports/render/index.js.flow +15 -0
  396. package/dist/exports/unmountComponentAtNode/index.js +13 -0
  397. package/dist/exports/unmountComponentAtNode/index.js.flow +9 -0
  398. package/dist/exports/useColorScheme/index.js +28 -0
  399. package/dist/exports/useColorScheme/index.js.flow +16 -0
  400. package/dist/exports/useLocaleContext/index.js +13 -0
  401. package/dist/exports/useLocaleContext/index.js.flow +13 -0
  402. package/dist/exports/useWindowDimensions/index.js +36 -0
  403. package/dist/exports/useWindowDimensions/index.js.flow +16 -0
  404. package/dist/index.js +69 -0
  405. package/dist/index.js.flow +70 -0
  406. package/dist/modules/AccessibilityUtil/index.js +18 -0
  407. package/dist/modules/AccessibilityUtil/index.js.flow +18 -0
  408. package/dist/modules/AccessibilityUtil/isDisabled.js +11 -0
  409. package/dist/modules/AccessibilityUtil/isDisabled.js.flow +10 -0
  410. package/dist/modules/AccessibilityUtil/propsToAccessibilityComponent.js +54 -0
  411. package/dist/modules/AccessibilityUtil/propsToAccessibilityComponent.js.flow +34 -0
  412. package/dist/modules/AccessibilityUtil/propsToAriaRole.js +36 -0
  413. package/dist/modules/AccessibilityUtil/propsToAriaRole.js.flow +28 -0
  414. package/dist/modules/AssetRegistry/index.js +18 -0
  415. package/dist/modules/AssetRegistry/index.js.flow +23 -0
  416. package/dist/modules/ImageLoader/index.js +144 -0
  417. package/dist/modules/ImageLoader/index.js.flow +84 -0
  418. package/dist/modules/TextInputState/index.js +60 -0
  419. package/dist/modules/TextInputState/index.js.flow +60 -0
  420. package/dist/modules/UnimplementedView/index.js +31 -0
  421. package/dist/modules/UnimplementedView/index.js.flow +23 -0
  422. package/dist/modules/addEventListener/index.js +72 -0
  423. package/dist/modules/addEventListener/index.js.flow +34 -0
  424. package/dist/modules/canUseDom/index.js +11 -0
  425. package/dist/modules/canUseDom/index.js.flow +11 -0
  426. package/dist/modules/createDOMProps/index.js +839 -0
  427. package/dist/modules/createDOMProps/index.js.flow +35 -0
  428. package/dist/modules/dismissKeyboard/index.js +14 -0
  429. package/dist/modules/dismissKeyboard/index.js.flow +12 -0
  430. package/dist/modules/forwardedProps/index.js +165 -0
  431. package/dist/modules/forwardedProps/index.js.flow +165 -0
  432. package/dist/modules/getBoundingClientRect/index.js +18 -0
  433. package/dist/modules/getBoundingClientRect/index.js.flow +10 -0
  434. package/dist/modules/isSelectionValid/index.js +17 -0
  435. package/dist/modules/isSelectionValid/index.js.flow +9 -0
  436. package/dist/modules/isWebColor/index.js +11 -0
  437. package/dist/modules/isWebColor/index.js.flow +10 -0
  438. package/dist/modules/mergeRefs/index.js +31 -0
  439. package/dist/modules/mergeRefs/index.js.flow +11 -0
  440. package/dist/modules/modality/index.js +188 -0
  441. package/dist/modules/modality/index.js.flow +79 -0
  442. package/dist/modules/multiplyStyleLengthValue/index.js +24 -0
  443. package/dist/modules/multiplyStyleLengthValue/index.js.flow +14 -0
  444. package/dist/modules/normalizeColor/index.js +30 -0
  445. package/dist/modules/normalizeColor/index.js.flow +13 -0
  446. package/dist/modules/pick/index.js +20 -0
  447. package/dist/modules/pick/index.js.flow +11 -0
  448. package/dist/modules/prefixStyles/index.js +13 -0
  449. package/dist/modules/prefixStyles/index.js.flow +14 -0
  450. package/dist/modules/prefixStyles/static.js +68 -0
  451. package/dist/modules/requestIdleCallback/index.js +28 -0
  452. package/dist/modules/requestIdleCallback/index.js.flow +28 -0
  453. package/dist/modules/setValueForStyles/dangerousStyleValue.js +44 -0
  454. package/dist/modules/setValueForStyles/dangerousStyleValue.js.flow +25 -0
  455. package/dist/modules/setValueForStyles/index.js +40 -0
  456. package/dist/modules/setValueForStyles/index.js.flow +23 -0
  457. package/dist/modules/unitlessNumbers/index.js +75 -0
  458. package/dist/modules/unitlessNumbers/index.js.flow +73 -0
  459. package/dist/modules/useElementLayout/index.js +85 -0
  460. package/dist/modules/useElementLayout/index.js.flow +19 -0
  461. package/dist/modules/useEvent/index.js +48 -0
  462. package/dist/modules/useEvent/index.js.flow +29 -0
  463. package/dist/modules/useHover/index.js +153 -0
  464. package/dist/modules/useHover/index.js.flow +46 -0
  465. package/dist/modules/useLayoutEffect/index.js +16 -0
  466. package/dist/modules/useLayoutEffect/index.js.flow +16 -0
  467. package/dist/modules/useLocale/index.js +35 -0
  468. package/dist/modules/useLocale/index.js.flow +32 -0
  469. package/dist/modules/useLocale/isLocaleRTL.js +83 -0
  470. package/dist/modules/useLocale/isLocaleRTL.js.flow +58 -0
  471. package/dist/modules/useMergeRefs/index.js +19 -0
  472. package/dist/modules/useMergeRefs/index.js.flow +12 -0
  473. package/dist/modules/usePlatformMethods/index.js +29 -0
  474. package/dist/modules/usePlatformMethods/index.js.flow +22 -0
  475. package/dist/modules/usePressEvents/PressResponder.js +492 -0
  476. package/dist/modules/usePressEvents/PressResponder.js.flow +216 -0
  477. package/dist/modules/usePressEvents/index.js +36 -0
  478. package/dist/modules/usePressEvents/index.js.flow +16 -0
  479. package/dist/modules/useResponderEvents/ResponderEventTypes.js +41 -0
  480. package/dist/modules/useResponderEvents/ResponderEventTypes.js.flow +61 -0
  481. package/dist/modules/useResponderEvents/ResponderSystem.js +590 -0
  482. package/dist/modules/useResponderEvents/ResponderSystem.js.flow +269 -0
  483. package/dist/modules/useResponderEvents/ResponderTouchHistoryStore.js +170 -0
  484. package/dist/modules/useResponderEvents/ResponderTouchHistoryStore.js.flow +56 -0
  485. package/dist/modules/useResponderEvents/createResponderEvent.js +146 -0
  486. package/dist/modules/useResponderEvents/createResponderEvent.js.flow +51 -0
  487. package/dist/modules/useResponderEvents/index.js +73 -0
  488. package/dist/modules/useResponderEvents/index.js.flow +26 -0
  489. package/dist/modules/useResponderEvents/utils.js +165 -0
  490. package/dist/modules/useResponderEvents/utils.js.flow +46 -0
  491. package/dist/modules/useStable/index.js +19 -0
  492. package/dist/modules/useStable/index.js.flow +12 -0
  493. package/dist/modules/warnOnce/index.js +27 -0
  494. package/dist/modules/warnOnce/index.js.flow +22 -0
  495. package/dist/types/index.js +0 -0
  496. package/dist/types/index.js.flow +46 -0
  497. package/dist/types/styles.js +0 -0
  498. package/dist/types/styles.js.flow +279 -0
  499. package/dist/vendor/hash/index.js +47 -0
  500. package/dist/vendor/hash/index.js.flow +18 -0
  501. package/dist/vendor/react-native/Animated/Animated.js +29 -0
  502. package/dist/vendor/react-native/Animated/Animated.js.flow +35 -0
  503. package/dist/vendor/react-native/Animated/AnimatedEvent.js +162 -0
  504. package/dist/vendor/react-native/Animated/AnimatedEvent.js.flow +46 -0
  505. package/dist/vendor/react-native/Animated/AnimatedImplementation.js +579 -0
  506. package/dist/vendor/react-native/Animated/AnimatedImplementation.js.flow +605 -0
  507. package/dist/vendor/react-native/Animated/AnimatedMock.js +137 -0
  508. package/dist/vendor/react-native/Animated/AnimatedMock.js.flow +139 -0
  509. package/dist/vendor/react-native/Animated/AnimatedPlatformConfig.js +11 -0
  510. package/dist/vendor/react-native/Animated/AnimatedPlatformConfig.js.flow +13 -0
  511. package/dist/vendor/react-native/Animated/Easing.js +249 -0
  512. package/dist/vendor/react-native/Animated/Easing.js.flow +80 -0
  513. package/dist/vendor/react-native/Animated/NativeAnimatedHelper.js +460 -0
  514. package/dist/vendor/react-native/Animated/NativeAnimatedHelper.js.flow +396 -0
  515. package/dist/vendor/react-native/Animated/NativeAnimatedModule.js +16 -0
  516. package/dist/vendor/react-native/Animated/NativeAnimatedModule.js.flow +56 -0
  517. package/dist/vendor/react-native/Animated/NativeAnimatedTurboModule.js +16 -0
  518. package/dist/vendor/react-native/Animated/NativeAnimatedTurboModule.js.flow +53 -0
  519. package/dist/vendor/react-native/Animated/SpringConfig.js +69 -0
  520. package/dist/vendor/react-native/Animated/SpringConfig.js.flow +25 -0
  521. package/dist/vendor/react-native/Animated/animations/Animation.js +55 -0
  522. package/dist/vendor/react-native/Animated/animations/Animation.js.flow +45 -0
  523. package/dist/vendor/react-native/Animated/animations/DecayAnimation.js +70 -0
  524. package/dist/vendor/react-native/Animated/animations/DecayAnimation.js.flow +51 -0
  525. package/dist/vendor/react-native/Animated/animations/SpringAnimation.js +222 -0
  526. package/dist/vendor/react-native/Animated/animations/SpringAnimation.js.flow +110 -0
  527. package/dist/vendor/react-native/Animated/animations/TimingAnimation.js +116 -0
  528. package/dist/vendor/react-native/Animated/animations/TimingAnimation.js.flow +61 -0
  529. package/dist/vendor/react-native/Animated/bezier.js +122 -0
  530. package/dist/vendor/react-native/Animated/bezier.js.flow +35 -0
  531. package/dist/vendor/react-native/Animated/components/AnimatedFlatList.js +23 -0
  532. package/dist/vendor/react-native/Animated/components/AnimatedFlatList.js.flow +20 -0
  533. package/dist/vendor/react-native/Animated/components/AnimatedImage.js +14 -0
  534. package/dist/vendor/react-native/Animated/components/AnimatedImage.js.flow +15 -0
  535. package/dist/vendor/react-native/Animated/components/AnimatedScrollView.js +23 -0
  536. package/dist/vendor/react-native/Animated/components/AnimatedScrollView.js.flow +20 -0
  537. package/dist/vendor/react-native/Animated/components/AnimatedSectionList.js +23 -0
  538. package/dist/vendor/react-native/Animated/components/AnimatedSectionList.js.flow +20 -0
  539. package/dist/vendor/react-native/Animated/components/AnimatedText.js +14 -0
  540. package/dist/vendor/react-native/Animated/components/AnimatedText.js.flow +15 -0
  541. package/dist/vendor/react-native/Animated/components/AnimatedView.js +14 -0
  542. package/dist/vendor/react-native/Animated/components/AnimatedView.js.flow +15 -0
  543. package/dist/vendor/react-native/Animated/createAnimatedComponent.js +46 -0
  544. package/dist/vendor/react-native/Animated/createAnimatedComponent.js.flow +27 -0
  545. package/dist/vendor/react-native/Animated/nodes/AnimatedAddition.js +49 -0
  546. package/dist/vendor/react-native/Animated/nodes/AnimatedAddition.js.flow +30 -0
  547. package/dist/vendor/react-native/Animated/nodes/AnimatedColor.js +283 -0
  548. package/dist/vendor/react-native/Animated/nodes/AnimatedColor.js.flow +83 -0
  549. package/dist/vendor/react-native/Animated/nodes/AnimatedDiffClamp.js +53 -0
  550. package/dist/vendor/react-native/Animated/nodes/AnimatedDiffClamp.js.flow +32 -0
  551. package/dist/vendor/react-native/Animated/nodes/AnimatedDivision.js +66 -0
  552. package/dist/vendor/react-native/Animated/nodes/AnimatedDivision.js.flow +31 -0
  553. package/dist/vendor/react-native/Animated/nodes/AnimatedInterpolation.js +266 -0
  554. package/dist/vendor/react-native/Animated/nodes/AnimatedInterpolation.js.flow +69 -0
  555. package/dist/vendor/react-native/Animated/nodes/AnimatedModulo.js +46 -0
  556. package/dist/vendor/react-native/Animated/nodes/AnimatedModulo.js.flow +29 -0
  557. package/dist/vendor/react-native/Animated/nodes/AnimatedMultiplication.js +49 -0
  558. package/dist/vendor/react-native/Animated/nodes/AnimatedMultiplication.js.flow +30 -0
  559. package/dist/vendor/react-native/Animated/nodes/AnimatedNode.js +159 -0
  560. package/dist/vendor/react-native/Animated/nodes/AnimatedNode.js.flow +58 -0
  561. package/dist/vendor/react-native/Animated/nodes/AnimatedProps.js +141 -0
  562. package/dist/vendor/react-native/Animated/nodes/AnimatedProps.js.flow +35 -0
  563. package/dist/vendor/react-native/Animated/nodes/AnimatedStyle.js +124 -0
  564. package/dist/vendor/react-native/Animated/nodes/AnimatedStyle.js.flow +33 -0
  565. package/dist/vendor/react-native/Animated/nodes/AnimatedSubtraction.js +49 -0
  566. package/dist/vendor/react-native/Animated/nodes/AnimatedSubtraction.js.flow +30 -0
  567. package/dist/vendor/react-native/Animated/nodes/AnimatedTracking.js +72 -0
  568. package/dist/vendor/react-native/Animated/nodes/AnimatedTracking.js.flow +32 -0
  569. package/dist/vendor/react-native/Animated/nodes/AnimatedTransform.js +109 -0
  570. package/dist/vendor/react-native/Animated/nodes/AnimatedTransform.js.flow +26 -0
  571. package/dist/vendor/react-native/Animated/nodes/AnimatedValue.js +267 -0
  572. package/dist/vendor/react-native/Animated/nodes/AnimatedValue.js.flow +86 -0
  573. package/dist/vendor/react-native/Animated/nodes/AnimatedValueXY.js +187 -0
  574. package/dist/vendor/react-native/Animated/nodes/AnimatedValueXY.js.flow +84 -0
  575. package/dist/vendor/react-native/Animated/nodes/AnimatedWithChildren.js +73 -0
  576. package/dist/vendor/react-native/Animated/nodes/AnimatedWithChildren.js.flow +25 -0
  577. package/dist/vendor/react-native/Animated/useAnimatedProps.js +154 -0
  578. package/dist/vendor/react-native/Animated/useAnimatedProps.js.flow +37 -0
  579. package/dist/vendor/react-native/Batchinator/index.js +79 -0
  580. package/dist/vendor/react-native/Batchinator/index.js.flow +51 -0
  581. package/dist/vendor/react-native/EventEmitter/NativeEventEmitter.js +77 -0
  582. package/dist/vendor/react-native/EventEmitter/NativeEventEmitter.js.flow +42 -0
  583. package/dist/vendor/react-native/EventEmitter/RCTDeviceEventEmitter.js +21 -0
  584. package/dist/vendor/react-native/EventEmitter/RCTDeviceEventEmitter.js.flow +22 -0
  585. package/dist/vendor/react-native/FillRateHelper/index.js +192 -0
  586. package/dist/vendor/react-native/FillRateHelper/index.js.flow +80 -0
  587. package/dist/vendor/react-native/FlatList/index.js +445 -0
  588. package/dist/vendor/react-native/FlatList/index.js.flow +331 -0
  589. package/dist/vendor/react-native/JSEventLoopWatchdog/index.js +86 -0
  590. package/dist/vendor/react-native/JSEventLoopWatchdog/index.js.flow +75 -0
  591. package/dist/vendor/react-native/LayoutAnimation/index.js +108 -0
  592. package/dist/vendor/react-native/LayoutAnimation/index.js.flow +105 -0
  593. package/dist/vendor/react-native/PanResponder/index.js +416 -0
  594. package/dist/vendor/react-native/PanResponder/index.js.flow +496 -0
  595. package/dist/vendor/react-native/PooledClass/index.js +58 -0
  596. package/dist/vendor/react-native/ReactNative/ReactNativeFeatureFlags.js +20 -0
  597. package/dist/vendor/react-native/ReactNative/ReactNativeFeatureFlags.js.flow +49 -0
  598. package/dist/vendor/react-native/SectionList/index.js +144 -0
  599. package/dist/vendor/react-native/SectionList/index.js.flow +165 -0
  600. package/dist/vendor/react-native/StaticContainer/index.js +40 -0
  601. package/dist/vendor/react-native/StaticContainer/index.js.flow +45 -0
  602. package/dist/vendor/react-native/StaticRenderer/index.js +22 -0
  603. package/dist/vendor/react-native/StaticRenderer/index.js.flow +29 -0
  604. package/dist/vendor/react-native/TouchHistoryMath/index.js +100 -0
  605. package/dist/vendor/react-native/TurboModule/RCTExport.js +29 -0
  606. package/dist/vendor/react-native/TurboModule/RCTExport.js.flow +35 -0
  607. package/dist/vendor/react-native/TurboModule/TurboModuleRegistry.js +21 -0
  608. package/dist/vendor/react-native/TurboModule/TurboModuleRegistry.js.flow +16 -0
  609. package/dist/vendor/react-native/Types/CoreEventTypes.js +11 -0
  610. package/dist/vendor/react-native/Types/CoreEventTypes.js.flow +264 -0
  611. package/dist/vendor/react-native/Utilities/Platform.js +2 -0
  612. package/dist/vendor/react-native/Utilities/clamp.js +22 -0
  613. package/dist/vendor/react-native/Utilities/clamp.js.flow +14 -0
  614. package/dist/vendor/react-native/Utilities/setAndForwardRef.js +61 -0
  615. package/dist/vendor/react-native/Utilities/setAndForwardRef.js.flow +50 -0
  616. package/dist/vendor/react-native/Utilities/useMergeRefs.js +38 -0
  617. package/dist/vendor/react-native/Utilities/useMergeRefs.js.flow +28 -0
  618. package/dist/vendor/react-native/Utilities/useRefEffect.js +37 -0
  619. package/dist/vendor/react-native/Utilities/useRefEffect.js.flow +28 -0
  620. package/dist/vendor/react-native/ViewabilityHelper/index.js +206 -0
  621. package/dist/vendor/react-native/ViewabilityHelper/index.js.flow +111 -0
  622. package/dist/vendor/react-native/VirtualizeUtils/index.js +175 -0
  623. package/dist/vendor/react-native/VirtualizeUtils/index.js.flow +64 -0
  624. package/dist/vendor/react-native/VirtualizedList/CellRenderMask.js +106 -0
  625. package/dist/vendor/react-native/VirtualizedList/CellRenderMask.js.flow +29 -0
  626. package/dist/vendor/react-native/VirtualizedList/ChildListCollection.js +68 -0
  627. package/dist/vendor/react-native/VirtualizedList/ChildListCollection.js.flow +21 -0
  628. package/dist/vendor/react-native/VirtualizedList/StateSafePureComponent.js +70 -0
  629. package/dist/vendor/react-native/VirtualizedList/StateSafePureComponent.js.flow +28 -0
  630. package/dist/vendor/react-native/VirtualizedList/VirtualizedListCellRenderer.js +153 -0
  631. package/dist/vendor/react-native/VirtualizedList/VirtualizedListCellRenderer.js.flow +68 -0
  632. package/dist/vendor/react-native/VirtualizedList/VirtualizedListContext.js +64 -0
  633. package/dist/vendor/react-native/VirtualizedList/VirtualizedListContext.js.flow +61 -0
  634. package/dist/vendor/react-native/VirtualizedList/VirtualizedListProps.js +16 -0
  635. package/dist/vendor/react-native/VirtualizedList/VirtualizedListProps.js.flow +294 -0
  636. package/dist/vendor/react-native/VirtualizedList/index.js +1479 -0
  637. package/dist/vendor/react-native/VirtualizedList/index.js.flow +303 -0
  638. package/dist/vendor/react-native/VirtualizedSectionList/index.js +384 -0
  639. package/dist/vendor/react-native/VirtualizedSectionList/index.js.flow +191 -0
  640. package/dist/vendor/react-native/deepDiffer/index.js +70 -0
  641. package/dist/vendor/react-native/deepDiffer/index.js.flow +67 -0
  642. package/dist/vendor/react-native/infoLog/index.js +19 -0
  643. package/dist/vendor/react-native/infoLog/index.js.flow +17 -0
  644. package/dist/vendor/react-native/vendor/emitter/EventEmitter.js +98 -0
  645. package/dist/vendor/react-native/vendor/emitter/EventEmitter.js.flow +54 -0
  646. package/package.json +81 -0
  647. package/src/exports/AccessibilityInfo/index.js +118 -0
  648. package/src/exports/ActivityIndicator/index.js +119 -0
  649. package/src/exports/Alert/index.js +14 -0
  650. package/src/exports/Animated/index.js +13 -0
  651. package/src/exports/AppRegistry/AppContainer.js +55 -0
  652. package/src/exports/AppRegistry/index.js +151 -0
  653. package/src/exports/AppRegistry/renderApplication.js +72 -0
  654. package/src/exports/AppState/index.js +81 -0
  655. package/src/exports/Appearance/index.js +65 -0
  656. package/src/exports/BackHandler/index.js +26 -0
  657. package/src/exports/Button/index.js +80 -0
  658. package/src/exports/CheckBox/index.js +143 -0
  659. package/src/exports/Clipboard/index.js +63 -0
  660. package/src/exports/DeviceEventEmitter/index.js +2 -0
  661. package/src/exports/Dimensions/index.js +160 -0
  662. package/src/exports/Easing/index.js +11 -0
  663. package/src/exports/FlatList/index.js +14 -0
  664. package/src/exports/I18nManager/index.js +33 -0
  665. package/src/exports/Image/index.js +443 -0
  666. package/src/exports/Image/types.js +103 -0
  667. package/src/exports/ImageBackground/index.js +73 -0
  668. package/src/exports/InputAccessoryView/index.js +2 -0
  669. package/src/exports/InteractionManager/TaskQueue.js +115 -0
  670. package/src/exports/InteractionManager/index.js +142 -0
  671. package/src/exports/Keyboard/index.js +28 -0
  672. package/src/exports/KeyboardAvoidingView/index.js +59 -0
  673. package/src/exports/LayoutAnimation/index.js +12 -0
  674. package/src/exports/Linking/index.js +124 -0
  675. package/src/exports/LogBox/index.js +17 -0
  676. package/src/exports/Modal/ModalAnimation.js +164 -0
  677. package/src/exports/Modal/ModalContent.js +87 -0
  678. package/src/exports/Modal/ModalFocusTrap.js +173 -0
  679. package/src/exports/Modal/ModalPortal.js +48 -0
  680. package/src/exports/Modal/index.js +151 -0
  681. package/src/exports/NativeEventEmitter/index.js +11 -0
  682. package/src/exports/NativeModules/index.js +17 -0
  683. package/src/exports/PanResponder/Alternative.js +408 -0
  684. package/src/exports/PanResponder/index.js +4 -0
  685. package/src/exports/Picker/PickerItem.js +26 -0
  686. package/src/exports/Picker/index.js +95 -0
  687. package/src/exports/PixelRatio/index.js +49 -0
  688. package/src/exports/Platform/index.js +25 -0
  689. package/src/exports/Pressable/index.js +242 -0
  690. package/src/exports/ProgressBar/index.js +92 -0
  691. package/src/exports/RefreshControl/index.js +52 -0
  692. package/src/exports/SafeAreaView/index.js +49 -0
  693. package/src/exports/ScrollView/ScrollViewBase.js +183 -0
  694. package/src/exports/ScrollView/index.js +784 -0
  695. package/src/exports/SectionList/index.js +13 -0
  696. package/src/exports/Share/index.js +65 -0
  697. package/src/exports/StatusBar/index.js +22 -0
  698. package/src/exports/StyleSheet/compiler/createReactDOMStyle.js +214 -0
  699. package/src/exports/StyleSheet/compiler/hash.js +67 -0
  700. package/src/exports/StyleSheet/compiler/hyphenateStyleName.js +27 -0
  701. package/src/exports/StyleSheet/compiler/index.js +518 -0
  702. package/src/exports/StyleSheet/compiler/normalizeColor.js +34 -0
  703. package/src/exports/StyleSheet/compiler/normalizeValueWithProperty.js +40 -0
  704. package/src/exports/StyleSheet/compiler/resolveShadowValue.js +32 -0
  705. package/src/exports/StyleSheet/compiler/unitlessNumbers.js +76 -0
  706. package/src/exports/StyleSheet/dom/createCSSStyleSheet.js +40 -0
  707. package/src/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js +184 -0
  708. package/src/exports/StyleSheet/dom/index.js +90 -0
  709. package/src/exports/StyleSheet/index.js +197 -0
  710. package/src/exports/StyleSheet/preprocess.js +255 -0
  711. package/src/exports/StyleSheet/validate.js +93 -0
  712. package/src/exports/Switch/index.js +236 -0
  713. package/src/exports/Text/TextAncestorContext.js +17 -0
  714. package/src/exports/Text/index.js +241 -0
  715. package/src/exports/Text/types.js +121 -0
  716. package/src/exports/TextInput/index.js +484 -0
  717. package/src/exports/TextInput/types.js +97 -0
  718. package/src/exports/Touchable/BoundingDimensions.js +37 -0
  719. package/src/exports/Touchable/Position.js +26 -0
  720. package/src/exports/Touchable/ensurePositiveDelayProps.js +23 -0
  721. package/src/exports/Touchable/index.js +1026 -0
  722. package/src/exports/TouchableHighlight/index.js +214 -0
  723. package/src/exports/TouchableNativeFeedback/index.js +11 -0
  724. package/src/exports/TouchableOpacity/index.js +168 -0
  725. package/src/exports/TouchableWithoutFeedback/index.js +132 -0
  726. package/src/exports/UIManager/index.js +132 -0
  727. package/src/exports/Vibration/index.js +28 -0
  728. package/src/exports/View/index.js +175 -0
  729. package/src/exports/View/types.js +247 -0
  730. package/src/exports/VirtualizedList/index.js +13 -0
  731. package/src/exports/YellowBox/index.js +22 -0
  732. package/src/exports/createElement/index.js +43 -0
  733. package/src/exports/findNodeHandle/index.js +18 -0
  734. package/src/exports/processColor/index.js +29 -0
  735. package/src/exports/render/index.js +29 -0
  736. package/src/exports/unmountComponentAtNode/index.js +13 -0
  737. package/src/exports/useColorScheme/index.js +31 -0
  738. package/src/exports/useLocaleContext/index.js +13 -0
  739. package/src/exports/useWindowDimensions/index.js +36 -0
  740. package/src/index.js +70 -0
  741. package/src/modules/AccessibilityUtil/index.js +20 -0
  742. package/src/modules/AccessibilityUtil/isDisabled.js +15 -0
  743. package/src/modules/AccessibilityUtil/propsToAccessibilityComponent.js +58 -0
  744. package/src/modules/AccessibilityUtil/propsToAriaRole.js +42 -0
  745. package/src/modules/AssetRegistry/index.js +32 -0
  746. package/src/modules/ImageLoader/index.js +167 -0
  747. package/src/modules/TextInputState/index.js +64 -0
  748. package/src/modules/UnimplementedView/index.js +31 -0
  749. package/src/modules/addEventListener/index.js +89 -0
  750. package/src/modules/canUseDom/index.js +16 -0
  751. package/src/modules/createDOMProps/index.js +919 -0
  752. package/src/modules/dismissKeyboard/index.js +16 -0
  753. package/src/modules/forwardedProps/index.js +172 -0
  754. package/src/modules/getBoundingClientRect/index.js +19 -0
  755. package/src/modules/isSelectionValid/index.js +19 -0
  756. package/src/modules/isWebColor/index.js +16 -0
  757. package/src/modules/mergeRefs/index.js +35 -0
  758. package/src/modules/modality/index.js +215 -0
  759. package/src/modules/multiplyStyleLengthValue/index.js +28 -0
  760. package/src/modules/normalizeColor/index.js +34 -0
  761. package/src/modules/pick/index.js +20 -0
  762. package/src/modules/prefixStyles/index.js +17 -0
  763. package/src/modules/prefixStyles/static.js +69 -0
  764. package/src/modules/requestIdleCallback/index.js +38 -0
  765. package/src/modules/setValueForStyles/dangerousStyleValue.js +52 -0
  766. package/src/modules/setValueForStyles/index.js +45 -0
  767. package/src/modules/unitlessNumbers/index.js +76 -0
  768. package/src/modules/useElementLayout/index.js +95 -0
  769. package/src/modules/useEvent/index.js +70 -0
  770. package/src/modules/useHover/index.js +197 -0
  771. package/src/modules/useLayoutEffect/index.js +20 -0
  772. package/src/modules/useLocale/index.js +60 -0
  773. package/src/modules/useLocale/isLocaleRTL.js +81 -0
  774. package/src/modules/useMergeRefs/index.js +21 -0
  775. package/src/modules/usePlatformMethods/index.js +39 -0
  776. package/src/modules/usePressEvents/PressResponder.js +625 -0
  777. package/src/modules/usePressEvents/index.js +44 -0
  778. package/src/modules/useResponderEvents/README.md +209 -0
  779. package/src/modules/useResponderEvents/ResponderEventTypes.js +83 -0
  780. package/src/modules/useResponderEvents/ResponderSystem.js +688 -0
  781. package/src/modules/useResponderEvents/ResponderTouchHistoryStore.js +219 -0
  782. package/src/modules/useResponderEvents/createResponderEvent.js +206 -0
  783. package/src/modules/useResponderEvents/index.js +91 -0
  784. package/src/modules/useResponderEvents/utils.js +179 -0
  785. package/src/modules/useStable/index.js +24 -0
  786. package/src/modules/warnOnce/index.js +29 -0
  787. package/src/types/index.js +76 -0
  788. package/src/types/styles.js +346 -0
  789. package/src/vendor/hash/index.js +60 -0
  790. package/src/vendor/react-native/Animated/Animated.js +41 -0
  791. package/src/vendor/react-native/Animated/AnimatedEvent.js +232 -0
  792. package/src/vendor/react-native/Animated/AnimatedImplementation.js +757 -0
  793. package/src/vendor/react-native/Animated/AnimatedMock.js +197 -0
  794. package/src/vendor/react-native/Animated/AnimatedPlatformConfig.js +13 -0
  795. package/src/vendor/react-native/Animated/Easing.js +253 -0
  796. package/src/vendor/react-native/Animated/NativeAnimatedHelper.js +603 -0
  797. package/src/vendor/react-native/Animated/NativeAnimatedModule.js +72 -0
  798. package/src/vendor/react-native/Animated/NativeAnimatedTurboModule.js +70 -0
  799. package/src/vendor/react-native/Animated/SpringConfig.js +103 -0
  800. package/src/vendor/react-native/Animated/animations/Animation.js +89 -0
  801. package/src/vendor/react-native/Animated/animations/DecayAnimation.js +120 -0
  802. package/src/vendor/react-native/Animated/animations/SpringAnimation.js +376 -0
  803. package/src/vendor/react-native/Animated/animations/TimingAnimation.js +177 -0
  804. package/src/vendor/react-native/Animated/bezier.js +153 -0
  805. package/src/vendor/react-native/Animated/components/AnimatedFlatList.js +30 -0
  806. package/src/vendor/react-native/Animated/components/AnimatedImage.js +23 -0
  807. package/src/vendor/react-native/Animated/components/AnimatedScrollView.js +30 -0
  808. package/src/vendor/react-native/Animated/components/AnimatedSectionList.js +30 -0
  809. package/src/vendor/react-native/Animated/components/AnimatedText.js +23 -0
  810. package/src/vendor/react-native/Animated/components/AnimatedView.js +21 -0
  811. package/src/vendor/react-native/Animated/createAnimatedComponent.js +65 -0
  812. package/src/vendor/react-native/Animated/nodes/AnimatedAddition.js +67 -0
  813. package/src/vendor/react-native/Animated/nodes/AnimatedColor.js +359 -0
  814. package/src/vendor/react-native/Animated/nodes/AnimatedDiffClamp.js +75 -0
  815. package/src/vendor/react-native/Animated/nodes/AnimatedDivision.js +82 -0
  816. package/src/vendor/react-native/Animated/nodes/AnimatedInterpolation.js +375 -0
  817. package/src/vendor/react-native/Animated/nodes/AnimatedModulo.js +66 -0
  818. package/src/vendor/react-native/Animated/nodes/AnimatedMultiplication.js +66 -0
  819. package/src/vendor/react-native/Animated/nodes/AnimatedNode.js +197 -0
  820. package/src/vendor/react-native/Animated/nodes/AnimatedProps.js +171 -0
  821. package/src/vendor/react-native/Animated/nodes/AnimatedStyle.js +143 -0
  822. package/src/vendor/react-native/Animated/nodes/AnimatedSubtraction.js +66 -0
  823. package/src/vendor/react-native/Animated/nodes/AnimatedTracking.js +102 -0
  824. package/src/vendor/react-native/Animated/nodes/AnimatedTransform.js +121 -0
  825. package/src/vendor/react-native/Animated/nodes/AnimatedValue.js +306 -0
  826. package/src/vendor/react-native/Animated/nodes/AnimatedValueXY.js +226 -0
  827. package/src/vendor/react-native/Animated/nodes/AnimatedWithChildren.js +90 -0
  828. package/src/vendor/react-native/Animated/useAnimatedProps.js +188 -0
  829. package/src/vendor/react-native/Batchinator/index.js +76 -0
  830. package/src/vendor/react-native/EventEmitter/NativeEventEmitter.js +113 -0
  831. package/src/vendor/react-native/EventEmitter/RCTDeviceEventEmitter.js +22 -0
  832. package/src/vendor/react-native/FillRateHelper/index.js +253 -0
  833. package/src/vendor/react-native/FlatList/index.js +696 -0
  834. package/src/vendor/react-native/JSEventLoopWatchdog/index.js +87 -0
  835. package/src/vendor/react-native/LayoutAnimation/index.js +142 -0
  836. package/src/vendor/react-native/PanResponder/index.js +613 -0
  837. package/src/vendor/react-native/PooledClass/index.js +63 -0
  838. package/src/vendor/react-native/ReactNative/ReactNativeFeatureFlags.js +51 -0
  839. package/src/vendor/react-native/SHA +2 -0
  840. package/src/vendor/react-native/SectionList/index.js +254 -0
  841. package/src/vendor/react-native/StaticContainer/index.js +54 -0
  842. package/src/vendor/react-native/StaticRenderer/index.js +37 -0
  843. package/src/vendor/react-native/TouchHistoryMath/index.js +153 -0
  844. package/src/vendor/react-native/TurboModule/RCTExport.js +35 -0
  845. package/src/vendor/react-native/TurboModule/TurboModuleRegistry.js +28 -0
  846. package/src/vendor/react-native/Types/CoreEventTypes.js +291 -0
  847. package/src/vendor/react-native/Utilities/Platform.js +2 -0
  848. package/src/vendor/react-native/Utilities/clamp.js +23 -0
  849. package/src/vendor/react-native/Utilities/setAndForwardRef.js +71 -0
  850. package/src/vendor/react-native/Utilities/useMergeRefs.js +44 -0
  851. package/src/vendor/react-native/Utilities/useRefEffect.js +45 -0
  852. package/src/vendor/react-native/ViewabilityHelper/index.js +360 -0
  853. package/src/vendor/react-native/VirtualizeUtils/index.js +258 -0
  854. package/src/vendor/react-native/VirtualizedList/CellRenderMask.js +155 -0
  855. package/src/vendor/react-native/VirtualizedList/ChildListCollection.js +72 -0
  856. package/src/vendor/react-native/VirtualizedList/StateSafePureComponent.js +85 -0
  857. package/src/vendor/react-native/VirtualizedList/VirtualizedListCellRenderer.js +247 -0
  858. package/src/vendor/react-native/VirtualizedList/VirtualizedListContext.js +118 -0
  859. package/src/vendor/react-native/VirtualizedList/VirtualizedListProps.js +307 -0
  860. package/src/vendor/react-native/VirtualizedList/index.js +2048 -0
  861. package/src/vendor/react-native/VirtualizedSectionList/index.js +616 -0
  862. package/src/vendor/react-native/deepDiffer/index.js +72 -0
  863. package/src/vendor/react-native/infoLog/index.js +20 -0
  864. package/src/vendor/react-native/vendor/emitter/EventEmitter.js +146 -0
@@ -0,0 +1,2048 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ * @format
9
+ */
10
+
11
+ import type { LayoutEvent } from '../../../types';
12
+ import type {
13
+ ScrollEvent,
14
+ } from '../Types/CoreEventTypes';
15
+ import type {ViewToken} from '../ViewabilityHelper';
16
+ import type {
17
+ FrameMetricProps,
18
+ Item,
19
+ Props,
20
+ RenderItemProps,
21
+ RenderItemType,
22
+ Separators,
23
+ } from './VirtualizedListProps';
24
+
25
+ import RefreshControl from '../../../exports/RefreshControl';
26
+ import ScrollView from '../../../exports/ScrollView';
27
+ import View, { type ViewProps } from '../../../exports/View';
28
+ import StyleSheet from '../../../exports/StyleSheet';
29
+
30
+ import Batchinator from '../Batchinator';
31
+ import clamp from '../Utilities/clamp';
32
+ import infoLog from '../infoLog';
33
+ import {CellRenderMask} from './CellRenderMask';
34
+ import ChildListCollection from './ChildListCollection';
35
+ import FillRateHelper from '../FillRateHelper';
36
+ import StateSafePureComponent from './StateSafePureComponent';
37
+ import ViewabilityHelper from '../ViewabilityHelper';
38
+ import CellRenderer from './VirtualizedListCellRenderer';
39
+ import {
40
+ VirtualizedListCellContextProvider,
41
+ VirtualizedListContext,
42
+ VirtualizedListContextProvider,
43
+ } from './VirtualizedListContext.js';
44
+ import {
45
+ computeWindowedRenderLimits,
46
+ keyExtractor as defaultKeyExtractor,
47
+ } from '../VirtualizeUtils';
48
+ import invariant from 'fbjs/lib/invariant';
49
+ import nullthrows from 'nullthrows';
50
+ import * as React from 'react';
51
+
52
+ export type {RenderItemProps, RenderItemType, Separators};
53
+
54
+ const __DEV__ = process.env.NODE_ENV !== 'production';
55
+
56
+ const ON_EDGE_REACHED_EPSILON = 0.001;
57
+
58
+ let _usedIndexForKey = false;
59
+ let _keylessItemComponentName: string = '';
60
+
61
+ type ScrollResponderType = any;
62
+ type ViewStyleProp = $PropertyType<ViewProps, 'style'>;
63
+
64
+ type ViewabilityHelperCallbackTuple = {
65
+ viewabilityHelper: ViewabilityHelper,
66
+ onViewableItemsChanged: (info: {
67
+ viewableItems: Array<ViewToken>,
68
+ changed: Array<ViewToken>,
69
+ ...
70
+ }) => void,
71
+ ...
72
+ };
73
+
74
+ type State = {
75
+ renderMask: CellRenderMask,
76
+ cellsAroundViewport: {first: number, last: number},
77
+ };
78
+
79
+ /**
80
+ * Default Props Helper Functions
81
+ * Use the following helper functions for default values
82
+ */
83
+
84
+ // horizontalOrDefault(this.props.horizontal)
85
+ function horizontalOrDefault(horizontal: ?boolean) {
86
+ return horizontal ?? false;
87
+ }
88
+
89
+ // initialNumToRenderOrDefault(this.props.initialNumToRender)
90
+ function initialNumToRenderOrDefault(initialNumToRender: ?number) {
91
+ return initialNumToRender ?? 10;
92
+ }
93
+
94
+ // maxToRenderPerBatchOrDefault(this.props.maxToRenderPerBatch)
95
+ function maxToRenderPerBatchOrDefault(maxToRenderPerBatch: ?number) {
96
+ return maxToRenderPerBatch ?? 10;
97
+ }
98
+
99
+ // onStartReachedThresholdOrDefault(this.props.onStartReachedThreshold)
100
+ function onStartReachedThresholdOrDefault(onStartReachedThreshold: ?number) {
101
+ return onStartReachedThreshold ?? 2;
102
+ }
103
+
104
+ // onEndReachedThresholdOrDefault(this.props.onEndReachedThreshold)
105
+ function onEndReachedThresholdOrDefault(onEndReachedThreshold: ?number) {
106
+ return onEndReachedThreshold ?? 2;
107
+ }
108
+
109
+ // getScrollingThreshold(visibleLength, onEndReachedThreshold)
110
+ function getScrollingThreshold(threshold: number, visibleLength: number) {
111
+ return (threshold * visibleLength) / 2;
112
+ }
113
+
114
+ // scrollEventThrottleOrDefault(this.props.scrollEventThrottle)
115
+ function scrollEventThrottleOrDefault(scrollEventThrottle: ?number) {
116
+ return scrollEventThrottle ?? 50;
117
+ }
118
+
119
+ // windowSizeOrDefault(this.props.windowSize)
120
+ function windowSizeOrDefault(windowSize: ?number) {
121
+ return windowSize ?? 21;
122
+ }
123
+
124
+ function findLastWhere<T>(
125
+ arr: $ReadOnlyArray<T>,
126
+ predicate: (element: T) => boolean,
127
+ ): T | null {
128
+ for (let i = arr.length - 1; i >= 0; i--) {
129
+ if (predicate(arr[i])) {
130
+ return arr[i];
131
+ }
132
+ }
133
+
134
+ return null;
135
+ }
136
+
137
+ /**
138
+ * Base implementation for the more convenient [`<FlatList>`](https://reactnative.dev/docs/flatlist)
139
+ * and [`<SectionList>`](https://reactnative.dev/docs/sectionlist) components, which are also better
140
+ * documented. In general, this should only really be used if you need more flexibility than
141
+ * `FlatList` provides, e.g. for use with immutable data instead of plain arrays.
142
+ *
143
+ * Virtualization massively improves memory consumption and performance of large lists by
144
+ * maintaining a finite render window of active items and replacing all items outside of the render
145
+ * window with appropriately sized blank space. The window adapts to scrolling behavior, and items
146
+ * are rendered incrementally with low-pri (after any running interactions) if they are far from the
147
+ * visible area, or with hi-pri otherwise to minimize the potential of seeing blank space.
148
+ *
149
+ * Some caveats:
150
+ *
151
+ * - Internal state is not preserved when content scrolls out of the render window. Make sure all
152
+ * your data is captured in the item data or external stores like Flux, Redux, or Relay.
153
+ * - This is a `PureComponent` which means that it will not re-render if `props` remain shallow-
154
+ * equal. Make sure that everything your `renderItem` function depends on is passed as a prop
155
+ * (e.g. `extraData`) that is not `===` after updates, otherwise your UI may not update on
156
+ * changes. This includes the `data` prop and parent component state.
157
+ * - In order to constrain memory and enable smooth scrolling, content is rendered asynchronously
158
+ * offscreen. This means it's possible to scroll faster than the fill rate ands momentarily see
159
+ * blank content. This is a tradeoff that can be adjusted to suit the needs of each application,
160
+ * and we are working on improving it behind the scenes.
161
+ * - By default, the list looks for a `key` or `id` prop on each item and uses that for the React key.
162
+ * Alternatively, you can provide a custom `keyExtractor` prop.
163
+ * - As an effort to remove defaultProps, use helper functions when referencing certain props
164
+ *
165
+ */
166
+ class VirtualizedList extends StateSafePureComponent<Props, State> {
167
+ static contextType: typeof VirtualizedListContext = VirtualizedListContext;
168
+
169
+ // scrollToEnd may be janky without getItemLayout prop
170
+ scrollToEnd(params?: ?{animated?: ?boolean, ...}) {
171
+ const animated = params ? params.animated : true;
172
+ const veryLast = this.props.getItemCount(this.props.data) - 1;
173
+ if (veryLast < 0) {
174
+ return;
175
+ }
176
+ const frame = this.__getFrameMetricsApprox(veryLast, this.props);
177
+ const offset = Math.max(
178
+ 0,
179
+ frame.offset +
180
+ frame.length +
181
+ this._footerLength -
182
+ this._scrollMetrics.visibleLength,
183
+ );
184
+
185
+ if (this._scrollRef == null) {
186
+ return;
187
+ }
188
+
189
+ if (this._scrollRef.scrollTo == null) {
190
+ console.warn(
191
+ 'No scrollTo method provided. This may be because you have two nested ' +
192
+ 'VirtualizedLists with the same orientation, or because you are ' +
193
+ 'using a custom component that does not implement scrollTo.',
194
+ );
195
+ return;
196
+ }
197
+
198
+ this._scrollRef.scrollTo(
199
+ horizontalOrDefault(this.props.horizontal)
200
+ ? {x: offset, animated}
201
+ : {y: offset, animated},
202
+ );
203
+ }
204
+
205
+ // scrollToIndex may be janky without getItemLayout prop
206
+ scrollToIndex(params: {
207
+ animated?: ?boolean,
208
+ index: number,
209
+ viewOffset?: number,
210
+ viewPosition?: number,
211
+ ...
212
+ }): $FlowFixMe {
213
+ const {
214
+ data,
215
+ horizontal,
216
+ getItemCount,
217
+ getItemLayout,
218
+ onScrollToIndexFailed,
219
+ } = this.props;
220
+ const {animated, index, viewOffset, viewPosition} = params;
221
+ invariant(
222
+ index >= 0,
223
+ `scrollToIndex out of range: requested index ${index} but minimum is 0`,
224
+ );
225
+ invariant(
226
+ getItemCount(data) >= 1,
227
+ `scrollToIndex out of range: item length ${getItemCount(
228
+ data,
229
+ )} but minimum is 1`,
230
+ );
231
+ invariant(
232
+ index < getItemCount(data),
233
+ `scrollToIndex out of range: requested index ${index} is out of 0 to ${
234
+ getItemCount(data) - 1
235
+ }`,
236
+ );
237
+ if (!getItemLayout && index > this._highestMeasuredFrameIndex) {
238
+ invariant(
239
+ !!onScrollToIndexFailed,
240
+ 'scrollToIndex should be used in conjunction with getItemLayout or onScrollToIndexFailed, ' +
241
+ 'otherwise there is no way to know the location of offscreen indices or handle failures.',
242
+ );
243
+ onScrollToIndexFailed({
244
+ averageItemLength: this._averageCellLength,
245
+ highestMeasuredFrameIndex: this._highestMeasuredFrameIndex,
246
+ index,
247
+ });
248
+ return;
249
+ }
250
+ const frame = this.__getFrameMetricsApprox(Math.floor(index), this.props);
251
+ const offset =
252
+ Math.max(
253
+ 0,
254
+ this._getOffsetApprox(index, this.props) -
255
+ (viewPosition || 0) *
256
+ (this._scrollMetrics.visibleLength - frame.length),
257
+ ) - (viewOffset || 0);
258
+
259
+ if (this._scrollRef == null) {
260
+ return;
261
+ }
262
+
263
+ if (this._scrollRef.scrollTo == null) {
264
+ console.warn(
265
+ 'No scrollTo method provided. This may be because you have two nested ' +
266
+ 'VirtualizedLists with the same orientation, or because you are ' +
267
+ 'using a custom component that does not implement scrollTo.',
268
+ );
269
+ return;
270
+ }
271
+
272
+ this._scrollRef.scrollTo(
273
+ horizontal ? {x: offset, animated} : {y: offset, animated},
274
+ );
275
+ }
276
+
277
+ // scrollToItem may be janky without getItemLayout prop. Required linear scan through items -
278
+ // use scrollToIndex instead if possible.
279
+ scrollToItem(params: {
280
+ animated?: ?boolean,
281
+ item: Item,
282
+ viewOffset?: number,
283
+ viewPosition?: number,
284
+ ...
285
+ }) {
286
+ const {item} = params;
287
+ const {data, getItem, getItemCount} = this.props;
288
+ const itemCount = getItemCount(data);
289
+ for (let index = 0; index < itemCount; index++) {
290
+ if (getItem(data, index) === item) {
291
+ this.scrollToIndex({...params, index});
292
+ break;
293
+ }
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Scroll to a specific content pixel offset in the list.
299
+ *
300
+ * Param `offset` expects the offset to scroll to.
301
+ * In case of `horizontal` is true, the offset is the x-value,
302
+ * in any other case the offset is the y-value.
303
+ *
304
+ * Param `animated` (`true` by default) defines whether the list
305
+ * should do an animation while scrolling.
306
+ */
307
+ scrollToOffset(params: {animated?: ?boolean, offset: number, ...}) {
308
+ const {animated, offset} = params;
309
+
310
+ if (this._scrollRef == null) {
311
+ return;
312
+ }
313
+
314
+ if (this._scrollRef.scrollTo == null) {
315
+ console.warn(
316
+ 'No scrollTo method provided. This may be because you have two nested ' +
317
+ 'VirtualizedLists with the same orientation, or because you are ' +
318
+ 'using a custom component that does not implement scrollTo.',
319
+ );
320
+ return;
321
+ }
322
+
323
+ this._scrollRef.scrollTo(
324
+ horizontalOrDefault(this.props.horizontal)
325
+ ? {x: offset, animated}
326
+ : {y: offset, animated},
327
+ );
328
+ }
329
+
330
+ recordInteraction() {
331
+ this._nestedChildLists.forEach(childList => {
332
+ childList.recordInteraction();
333
+ });
334
+ this._viewabilityTuples.forEach(t => {
335
+ t.viewabilityHelper.recordInteraction();
336
+ });
337
+ this._updateViewableItems(this.props, this.state.cellsAroundViewport);
338
+ }
339
+
340
+ flashScrollIndicators() {
341
+ if (this._scrollRef == null) {
342
+ return;
343
+ }
344
+
345
+ this._scrollRef.flashScrollIndicators();
346
+ }
347
+
348
+ /**
349
+ * Provides a handle to the underlying scroll responder.
350
+ * Note that `this._scrollRef` might not be a `ScrollView`, so we
351
+ * need to check that it responds to `getScrollResponder` before calling it.
352
+ */
353
+ getScrollResponder(): ?ScrollResponderType {
354
+ if (this._scrollRef && this._scrollRef.getScrollResponder) {
355
+ return this._scrollRef.getScrollResponder();
356
+ }
357
+ }
358
+
359
+ getScrollableNode(): ?number {
360
+ if (this._scrollRef && this._scrollRef.getScrollableNode) {
361
+ return this._scrollRef.getScrollableNode();
362
+ } else {
363
+ return this._scrollRef;
364
+ }
365
+ }
366
+
367
+ getScrollRef():
368
+ | ?React.ElementRef<typeof ScrollView>
369
+ | ?React.ElementRef<typeof View> {
370
+ if (this._scrollRef && this._scrollRef.getScrollRef) {
371
+ return this._scrollRef.getScrollRef();
372
+ } else {
373
+ return this._scrollRef;
374
+ }
375
+ }
376
+
377
+ _getCellKey(): string {
378
+ return this.context?.cellKey || 'rootList';
379
+ }
380
+
381
+ // $FlowFixMe[missing-local-annot]
382
+ _getScrollMetrics = () => {
383
+ return this._scrollMetrics;
384
+ };
385
+
386
+ hasMore(): boolean {
387
+ return this._hasMore;
388
+ }
389
+
390
+ // $FlowFixMe[missing-local-annot]
391
+ _getOutermostParentListRef = () => {
392
+ if (this._isNestedWithSameOrientation()) {
393
+ return this.context.getOutermostParentListRef();
394
+ } else {
395
+ return this;
396
+ }
397
+ };
398
+
399
+ _registerAsNestedChild = (childList: {
400
+ cellKey: string,
401
+ ref: React.ElementRef<typeof VirtualizedList>,
402
+ }): void => {
403
+ this._nestedChildLists.add(childList.ref, childList.cellKey);
404
+ if (this._hasInteracted) {
405
+ childList.ref.recordInteraction();
406
+ }
407
+ };
408
+
409
+ _unregisterAsNestedChild = (childList: {
410
+ ref: React.ElementRef<typeof VirtualizedList>,
411
+ }): void => {
412
+ this._nestedChildLists.remove(childList.ref);
413
+ };
414
+
415
+ state: State;
416
+
417
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
418
+ invertedWheelEventHandler: ?(ev: any) => void;
419
+
420
+ constructor(props: Props) {
421
+ super(props);
422
+ this._checkProps(props);
423
+
424
+ this._fillRateHelper = new FillRateHelper(this._getFrameMetrics);
425
+ this._updateCellsToRenderBatcher = new Batchinator(
426
+ this._updateCellsToRender,
427
+ this.props.updateCellsBatchingPeriod ?? 50,
428
+ );
429
+
430
+ if (this.props.viewabilityConfigCallbackPairs) {
431
+ this._viewabilityTuples = this.props.viewabilityConfigCallbackPairs.map(
432
+ pair => ({
433
+ viewabilityHelper: new ViewabilityHelper(pair.viewabilityConfig),
434
+ onViewableItemsChanged: pair.onViewableItemsChanged,
435
+ }),
436
+ );
437
+ } else {
438
+ const {onViewableItemsChanged, viewabilityConfig} = this.props;
439
+ if (onViewableItemsChanged) {
440
+ this._viewabilityTuples.push({
441
+ viewabilityHelper: new ViewabilityHelper(viewabilityConfig),
442
+ onViewableItemsChanged: onViewableItemsChanged,
443
+ });
444
+ }
445
+ }
446
+
447
+ const initialRenderRegion = VirtualizedList._initialRenderRegion(props);
448
+
449
+ this.state = {
450
+ cellsAroundViewport: initialRenderRegion,
451
+ renderMask: VirtualizedList._createRenderMask(props, initialRenderRegion),
452
+ };
453
+
454
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
455
+ // For issue https://github.com/necolas/react-native-web/issues/995
456
+ this.invertedWheelEventHandler = (ev: any) => {
457
+ const scrollOffset = this.props.horizontal ? ev.target.scrollLeft : ev.target.scrollTop;
458
+ const scrollLength = this.props.horizontal ? ev.target.scrollWidth : ev.target.scrollHeight;
459
+ const clientLength = this.props.horizontal ? ev.target.clientWidth : ev.target.clientHeight;
460
+ const isEventTargetScrollable = scrollLength > clientLength;
461
+ const delta = this.props.horizontal
462
+ ? ev.deltaX || ev.wheelDeltaX
463
+ : ev.deltaY || ev.wheelDeltaY;
464
+ let leftoverDelta = delta;
465
+ if (isEventTargetScrollable) {
466
+ leftoverDelta = delta < 0
467
+ ? Math.min(delta + scrollOffset, 0)
468
+ : Math.max(delta - (scrollLength - clientLength - scrollOffset), 0);
469
+ }
470
+ const targetDelta = delta - leftoverDelta;
471
+
472
+ if (this.props.inverted && this._scrollRef && this._scrollRef.getScrollableNode) {
473
+ const node = (this._scrollRef: any).getScrollableNode();
474
+ if (this.props.horizontal) {
475
+ ev.target.scrollLeft += targetDelta;
476
+ const nextScrollLeft = node.scrollLeft - leftoverDelta;
477
+ node.scrollLeft = !this.props.getItemLayout ? Math.min(nextScrollLeft, this._totalCellLength) : nextScrollLeft;
478
+ } else {
479
+ ev.target.scrollTop += targetDelta;
480
+ const nextScrollTop = node.scrollTop - leftoverDelta;
481
+ node.scrollTop = !this.props.getItemLayout ? Math.min(nextScrollTop, this._totalCellLength) : nextScrollTop;
482
+ }
483
+ ev.preventDefault();
484
+ }
485
+ };
486
+ }
487
+
488
+ _checkProps(props: Props) {
489
+ const {onScroll, windowSize, getItemCount, data, initialScrollIndex} =
490
+ props;
491
+
492
+ invariant(
493
+ // $FlowFixMe[prop-missing]
494
+ !onScroll || !onScroll.__isNative,
495
+ 'Components based on VirtualizedList must be wrapped with Animated.createAnimatedComponent ' +
496
+ 'to support native onScroll events with useNativeDriver',
497
+ );
498
+ invariant(
499
+ windowSizeOrDefault(windowSize) > 0,
500
+ 'VirtualizedList: The windowSize prop must be present and set to a value greater than 0.',
501
+ );
502
+
503
+ invariant(
504
+ getItemCount,
505
+ 'VirtualizedList: The "getItemCount" prop must be provided',
506
+ );
507
+
508
+ const itemCount = getItemCount(data);
509
+
510
+ if (
511
+ initialScrollIndex != null &&
512
+ !this._hasTriggeredInitialScrollToIndex &&
513
+ (initialScrollIndex < 0 ||
514
+ (itemCount > 0 && initialScrollIndex >= itemCount)) &&
515
+ !this._hasWarned.initialScrollIndex
516
+ ) {
517
+ console.warn(
518
+ `initialScrollIndex "${initialScrollIndex}" is not valid (list has ${itemCount} items)`,
519
+ );
520
+ this._hasWarned.initialScrollIndex = true;
521
+ }
522
+
523
+ if (__DEV__ && !this._hasWarned.flexWrap) {
524
+ // $FlowFixMe[underconstrained-implicit-instantiation]
525
+ const flatStyles = StyleSheet.flatten(this.props.contentContainerStyle);
526
+ if (flatStyles != null && flatStyles.flexWrap === 'wrap') {
527
+ console.warn(
528
+ '`flexWrap: `wrap`` is not supported with the `VirtualizedList` components.' +
529
+ 'Consider using `numColumns` with `FlatList` instead.',
530
+ );
531
+ this._hasWarned.flexWrap = true;
532
+ }
533
+ }
534
+ }
535
+
536
+ static _createRenderMask(
537
+ props: Props,
538
+ cellsAroundViewport: {first: number, last: number},
539
+ additionalRegions?: ?$ReadOnlyArray<{first: number, last: number}>,
540
+ ): CellRenderMask {
541
+ const itemCount = props.getItemCount(props.data);
542
+
543
+ invariant(
544
+ cellsAroundViewport.first >= 0 &&
545
+ cellsAroundViewport.last >= cellsAroundViewport.first - 1 &&
546
+ cellsAroundViewport.last < itemCount,
547
+ `Invalid cells around viewport "[${cellsAroundViewport.first}, ${cellsAroundViewport.last}]" was passed to VirtualizedList._createRenderMask`,
548
+ );
549
+
550
+ const renderMask = new CellRenderMask(itemCount);
551
+
552
+ if (itemCount > 0) {
553
+ const allRegions = [cellsAroundViewport, ...(additionalRegions ?? [])];
554
+ for (const region of allRegions) {
555
+ renderMask.addCells(region);
556
+ }
557
+
558
+ // The initially rendered cells are retained as part of the
559
+ // "scroll-to-top" optimization
560
+ if (props.initialScrollIndex == null || props.initialScrollIndex <= 0) {
561
+ const initialRegion = VirtualizedList._initialRenderRegion(props);
562
+ renderMask.addCells(initialRegion);
563
+ }
564
+
565
+ // The layout coordinates of sticker headers may be off-screen while the
566
+ // actual header is on-screen. Keep the most recent before the viewport
567
+ // rendered, even if its layout coordinates are not in viewport.
568
+ const stickyIndicesSet = new Set(props.stickyHeaderIndices);
569
+ VirtualizedList._ensureClosestStickyHeader(
570
+ props,
571
+ stickyIndicesSet,
572
+ renderMask,
573
+ cellsAroundViewport.first,
574
+ );
575
+ }
576
+
577
+ return renderMask;
578
+ }
579
+
580
+ static _initialRenderRegion(props: Props): {first: number, last: number} {
581
+ const itemCount = props.getItemCount(props.data);
582
+
583
+ const firstCellIndex = Math.max(
584
+ 0,
585
+ Math.min(itemCount - 1, Math.floor(props.initialScrollIndex ?? 0)),
586
+ );
587
+
588
+ const lastCellIndex =
589
+ Math.min(
590
+ itemCount,
591
+ firstCellIndex + initialNumToRenderOrDefault(props.initialNumToRender),
592
+ ) - 1;
593
+
594
+ return {
595
+ first: firstCellIndex,
596
+ last: lastCellIndex,
597
+ };
598
+ }
599
+
600
+ static _ensureClosestStickyHeader(
601
+ props: Props,
602
+ stickyIndicesSet: Set<number>,
603
+ renderMask: CellRenderMask,
604
+ cellIdx: number,
605
+ ) {
606
+ const stickyOffset = props.ListHeaderComponent ? 1 : 0;
607
+
608
+ for (let itemIdx = cellIdx - 1; itemIdx >= 0; itemIdx--) {
609
+ if (stickyIndicesSet.has(itemIdx + stickyOffset)) {
610
+ renderMask.addCells({first: itemIdx, last: itemIdx});
611
+ break;
612
+ }
613
+ }
614
+ }
615
+
616
+ _adjustCellsAroundViewport(
617
+ props: Props,
618
+ cellsAroundViewport: {first: number, last: number},
619
+ ): {first: number, last: number} {
620
+ const {data, getItemCount} = props;
621
+ const onEndReachedThreshold = onEndReachedThresholdOrDefault(
622
+ props.onEndReachedThreshold,
623
+ );
624
+ const {contentLength, offset, visibleLength} = this._scrollMetrics;
625
+ const distanceFromEnd = contentLength - visibleLength - offset;
626
+
627
+ // Wait until the scroll view metrics have been set up. And until then,
628
+ // we will trust the initialNumToRender suggestion
629
+ if (visibleLength <= 0 || contentLength <= 0) {
630
+ return cellsAroundViewport.last >= getItemCount(data)
631
+ ? VirtualizedList._constrainToItemCount(cellsAroundViewport, props)
632
+ : cellsAroundViewport;
633
+ }
634
+
635
+ let newCellsAroundViewport: {first: number, last: number};
636
+ if (props.disableVirtualization) {
637
+ const renderAhead =
638
+ distanceFromEnd < onEndReachedThreshold * visibleLength
639
+ ? maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch)
640
+ : 0;
641
+
642
+ newCellsAroundViewport = {
643
+ first: 0,
644
+ last: Math.min(
645
+ cellsAroundViewport.last + renderAhead,
646
+ getItemCount(data) - 1,
647
+ ),
648
+ };
649
+ } else {
650
+ // If we have a non-zero initialScrollIndex and run this before we've scrolled,
651
+ // we'll wipe out the initialNumToRender rendered elements starting at initialScrollIndex.
652
+ // So let's wait until we've scrolled the view to the right place. And until then,
653
+ // we will trust the initialScrollIndex suggestion.
654
+
655
+ // Thus, we want to recalculate the windowed render limits if any of the following hold:
656
+ // - initialScrollIndex is undefined or is 0
657
+ // - initialScrollIndex > 0 AND scrolling is complete
658
+ // - initialScrollIndex > 0 AND the end of the list is visible (this handles the case
659
+ // where the list is shorter than the visible area)
660
+ if (
661
+ props.initialScrollIndex &&
662
+ !this._scrollMetrics.offset &&
663
+ Math.abs(distanceFromEnd) >= Number.EPSILON
664
+ ) {
665
+ return cellsAroundViewport.last >= getItemCount(data)
666
+ ? VirtualizedList._constrainToItemCount(cellsAroundViewport, props)
667
+ : cellsAroundViewport;
668
+ }
669
+
670
+ newCellsAroundViewport = computeWindowedRenderLimits(
671
+ props,
672
+ maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch),
673
+ windowSizeOrDefault(props.windowSize),
674
+ cellsAroundViewport,
675
+ this.__getFrameMetricsApprox,
676
+ this._scrollMetrics,
677
+ );
678
+ invariant(
679
+ newCellsAroundViewport.last < getItemCount(data),
680
+ 'computeWindowedRenderLimits() should return range in-bounds',
681
+ );
682
+ }
683
+
684
+ if (this._nestedChildLists.size() > 0) {
685
+ // If some cell in the new state has a child list in it, we should only render
686
+ // up through that item, so that we give that list a chance to render.
687
+ // Otherwise there's churn from multiple child lists mounting and un-mounting
688
+ // their items.
689
+
690
+ // Will this prevent rendering if the nested list doesn't realize the end?
691
+ const childIdx = this._findFirstChildWithMore(
692
+ newCellsAroundViewport.first,
693
+ newCellsAroundViewport.last,
694
+ );
695
+
696
+ newCellsAroundViewport.last = childIdx ?? newCellsAroundViewport.last;
697
+ }
698
+
699
+ return newCellsAroundViewport;
700
+ }
701
+
702
+ _findFirstChildWithMore(first: number, last: number): number | null {
703
+ for (let ii = first; ii <= last; ii++) {
704
+ const cellKeyForIndex = this._indicesToKeys.get(ii);
705
+ if (
706
+ cellKeyForIndex != null &&
707
+ this._nestedChildLists.anyInCell(cellKeyForIndex, childList =>
708
+ childList.hasMore(),
709
+ )
710
+ ) {
711
+ return ii;
712
+ }
713
+ }
714
+
715
+ return null;
716
+ }
717
+
718
+ componentDidMount() {
719
+ if (this._isNestedWithSameOrientation()) {
720
+ this.context.registerAsNestedChild({
721
+ ref: this,
722
+ cellKey: this.context.cellKey,
723
+ });
724
+ }
725
+
726
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
727
+ this.setupWebWheelHandler();
728
+ }
729
+
730
+ componentWillUnmount() {
731
+ if (this._isNestedWithSameOrientation()) {
732
+ this.context.unregisterAsNestedChild({ref: this});
733
+ }
734
+ this._updateCellsToRenderBatcher.dispose({abort: true});
735
+ this._viewabilityTuples.forEach(tuple => {
736
+ tuple.viewabilityHelper.dispose();
737
+ });
738
+ this._fillRateHelper.deactivateAndFlush();
739
+
740
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
741
+ this.teardownWebWheelHandler();
742
+ }
743
+
744
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
745
+ setupWebWheelHandler() {
746
+ if (this._scrollRef && this._scrollRef.getScrollableNode) {
747
+ this._scrollRef.getScrollableNode().addEventListener('wheel',
748
+ this.invertedWheelEventHandler
749
+ );
750
+ } else {
751
+ setTimeout(() => this.setupWebWheelHandler(), 50);
752
+ return
753
+ }
754
+ }
755
+
756
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
757
+ teardownWebWheelHandler() {
758
+ if (this._scrollRef && this._scrollRef.getScrollableNode) {
759
+ this._scrollRef.getScrollableNode().removeEventListener('wheel',
760
+ this.invertedWheelEventHandler
761
+ );
762
+ }
763
+ }
764
+
765
+ static getDerivedStateFromProps(newProps: Props, prevState: State): State {
766
+ // first and last could be stale (e.g. if a new, shorter items props is passed in), so we make
767
+ // sure we're rendering a reasonable range here.
768
+ const itemCount = newProps.getItemCount(newProps.data);
769
+ if (itemCount === prevState.renderMask.numCells()) {
770
+ return prevState;
771
+ }
772
+
773
+ const constrainedCells = VirtualizedList._constrainToItemCount(
774
+ prevState.cellsAroundViewport,
775
+ newProps,
776
+ );
777
+
778
+ return {
779
+ cellsAroundViewport: constrainedCells,
780
+ renderMask: VirtualizedList._createRenderMask(newProps, constrainedCells),
781
+ };
782
+ }
783
+
784
+ _pushCells(
785
+ cells: Array<Object>,
786
+ stickyHeaderIndices: Array<number>,
787
+ stickyIndicesFromProps: Set<number>,
788
+ first: number,
789
+ last: number,
790
+ inversionStyle: ViewStyleProp,
791
+ ) {
792
+ const {
793
+ CellRendererComponent,
794
+ ItemSeparatorComponent,
795
+ ListHeaderComponent,
796
+ ListItemComponent,
797
+ data,
798
+ debug,
799
+ getItem,
800
+ getItemCount,
801
+ getItemLayout,
802
+ horizontal,
803
+ renderItem,
804
+ } = this.props;
805
+ const stickyOffset = ListHeaderComponent ? 1 : 0;
806
+ const end = getItemCount(data) - 1;
807
+ let prevCellKey;
808
+ last = Math.min(end, last);
809
+
810
+ for (let ii = first; ii <= last; ii++) {
811
+ const item = getItem(data, ii);
812
+ const key = this._keyExtractor(item, ii, this.props);
813
+
814
+ this._indicesToKeys.set(ii, key);
815
+ if (stickyIndicesFromProps.has(ii + stickyOffset)) {
816
+ stickyHeaderIndices.push(cells.length);
817
+ }
818
+
819
+ const shouldListenForLayout =
820
+ getItemLayout == null || debug || this._fillRateHelper.enabled();
821
+
822
+ cells.push(
823
+ <CellRenderer
824
+ CellRendererComponent={CellRendererComponent}
825
+ ItemSeparatorComponent={ii < end ? ItemSeparatorComponent : undefined}
826
+ ListItemComponent={ListItemComponent}
827
+ cellKey={key}
828
+ horizontal={horizontal}
829
+ index={ii}
830
+ inversionStyle={inversionStyle}
831
+ item={item}
832
+ key={key}
833
+ prevCellKey={prevCellKey}
834
+ onUpdateSeparators={this._onUpdateSeparators}
835
+ onCellFocusCapture={e => this._onCellFocusCapture(key)}
836
+ onUnmount={this._onCellUnmount}
837
+ ref={ref => {
838
+ this._cellRefs[key] = ref;
839
+ }}
840
+ renderItem={renderItem}
841
+ {...(shouldListenForLayout && {
842
+ onCellLayout: this._onCellLayout,
843
+ })}
844
+ />,
845
+ );
846
+ prevCellKey = key;
847
+ }
848
+ }
849
+
850
+ static _constrainToItemCount(
851
+ cells: {first: number, last: number},
852
+ props: Props,
853
+ ): {first: number, last: number} {
854
+ const itemCount = props.getItemCount(props.data);
855
+ const last = Math.min(itemCount - 1, cells.last);
856
+
857
+ const maxToRenderPerBatch = maxToRenderPerBatchOrDefault(
858
+ props.maxToRenderPerBatch,
859
+ );
860
+
861
+ return {
862
+ first: clamp(0, itemCount - 1 - maxToRenderPerBatch, cells.first),
863
+ last,
864
+ };
865
+ }
866
+
867
+ _onUpdateSeparators = (keys: Array<?string>, newProps: Object) => {
868
+ keys.forEach(key => {
869
+ const ref = key != null && this._cellRefs[key];
870
+ ref && ref.updateSeparatorProps(newProps);
871
+ });
872
+ };
873
+
874
+ _isNestedWithSameOrientation(): boolean {
875
+ const nestedContext = this.context;
876
+ return !!(
877
+ nestedContext &&
878
+ !!nestedContext.horizontal === horizontalOrDefault(this.props.horizontal)
879
+ );
880
+ }
881
+
882
+ _getSpacerKey = (isVertical: boolean): string =>
883
+ isVertical ? 'height' : 'width';
884
+
885
+ _keyExtractor(
886
+ item: Item,
887
+ index: number,
888
+ props: {
889
+ keyExtractor?: ?(item: Item, index: number) => string,
890
+ ...
891
+ },
892
+ // $FlowFixMe[missing-local-annot]
893
+ ) {
894
+ if (props.keyExtractor != null) {
895
+ return props.keyExtractor(item, index);
896
+ }
897
+
898
+ const key = defaultKeyExtractor(item, index);
899
+ if (key === String(index)) {
900
+ _usedIndexForKey = true;
901
+ if (item.type && item.type.displayName) {
902
+ _keylessItemComponentName = item.type.displayName;
903
+ }
904
+ }
905
+ return key;
906
+ }
907
+
908
+ render(): React.Node {
909
+ this._checkProps(this.props);
910
+ const {ListEmptyComponent, ListFooterComponent, ListHeaderComponent} =
911
+ this.props;
912
+ const {data, horizontal} = this.props;
913
+ const inversionStyle = this.props.inverted
914
+ ? horizontalOrDefault(this.props.horizontal)
915
+ ? styles.horizontallyInverted
916
+ : styles.verticallyInverted
917
+ : null;
918
+ const cells: Array<any | React.Node> = [];
919
+ const stickyIndicesFromProps = new Set(this.props.stickyHeaderIndices);
920
+ const stickyHeaderIndices = [];
921
+
922
+ // 1. Add cell for ListHeaderComponent
923
+ if (ListHeaderComponent) {
924
+ if (stickyIndicesFromProps.has(0)) {
925
+ stickyHeaderIndices.push(0);
926
+ }
927
+ const element = React.isValidElement(ListHeaderComponent) ? (
928
+ ListHeaderComponent
929
+ ) : (
930
+ // $FlowFixMe[not-a-component]
931
+ // $FlowFixMe[incompatible-type-arg]
932
+ <ListHeaderComponent />
933
+ );
934
+ cells.push(
935
+ <VirtualizedListCellContextProvider
936
+ cellKey={this._getCellKey() + '-header'}
937
+ key="$header">
938
+ <View
939
+ onLayout={this._onLayoutHeader}
940
+ style={[
941
+ inversionStyle,
942
+ this.props.ListHeaderComponentStyle,
943
+ ]}>
944
+ {
945
+ // $FlowFixMe[incompatible-type] - Typing ReactNativeComponent revealed errors
946
+ element
947
+ }
948
+ </View>
949
+ </VirtualizedListCellContextProvider>,
950
+ );
951
+ }
952
+
953
+ // 2a. Add a cell for ListEmptyComponent if applicable
954
+ const itemCount = this.props.getItemCount(data);
955
+ if (itemCount === 0 && ListEmptyComponent) {
956
+ const element: React.Element<any> = ((React.isValidElement(
957
+ ListEmptyComponent,
958
+ ) ? (
959
+ ListEmptyComponent
960
+ ) : (
961
+ // $FlowFixMe[not-a-component]
962
+ // $FlowFixMe[incompatible-type-arg]
963
+ <ListEmptyComponent />
964
+ )): any);
965
+ cells.push(
966
+ <VirtualizedListCellContextProvider
967
+ cellKey={this._getCellKey() + '-empty'}
968
+ key="$empty">
969
+ {React.cloneElement(element, {
970
+ onLayout: (event: LayoutEvent) => {
971
+ this._onLayoutEmpty(event);
972
+ if (element.props.onLayout) {
973
+ element.props.onLayout(event);
974
+ }
975
+ },
976
+ style: [inversionStyle, element.props.style],
977
+ })}
978
+ </VirtualizedListCellContextProvider>,
979
+ );
980
+ }
981
+
982
+ // 2b. Add cells and spacers for each item
983
+ if (itemCount > 0) {
984
+ _usedIndexForKey = false;
985
+ _keylessItemComponentName = '';
986
+ const spacerKey = this._getSpacerKey(!horizontal);
987
+
988
+ const renderRegions = this.state.renderMask.enumerateRegions();
989
+ const lastSpacer = findLastWhere(renderRegions, r => r.isSpacer);
990
+
991
+ for (const section of renderRegions) {
992
+ if (section.isSpacer) {
993
+ // Legacy behavior is to avoid spacers when virtualization is
994
+ // disabled (including head spacers on initial render).
995
+ if (this.props.disableVirtualization) {
996
+ continue;
997
+ }
998
+
999
+ // Without getItemLayout, we limit our tail spacer to the _highestMeasuredFrameIndex to
1000
+ // prevent the user for hyperscrolling into un-measured area because otherwise content will
1001
+ // likely jump around as it renders in above the viewport.
1002
+ const isLastSpacer = section === lastSpacer;
1003
+ const constrainToMeasured = isLastSpacer && !this.props.getItemLayout;
1004
+ const last = constrainToMeasured
1005
+ ? clamp(
1006
+ section.first - 1,
1007
+ section.last,
1008
+ this._highestMeasuredFrameIndex,
1009
+ )
1010
+ : section.last;
1011
+
1012
+ const firstMetrics = this.__getFrameMetricsApprox(
1013
+ section.first,
1014
+ this.props,
1015
+ );
1016
+ const lastMetrics = this.__getFrameMetricsApprox(last, this.props);
1017
+ const spacerSize =
1018
+ lastMetrics.offset + lastMetrics.length - firstMetrics.offset;
1019
+ cells.push(
1020
+ <View
1021
+ key={`$spacer-${section.first}`}
1022
+ style={{[spacerKey]: spacerSize}}
1023
+ />,
1024
+ );
1025
+ } else {
1026
+ this._pushCells(
1027
+ cells,
1028
+ stickyHeaderIndices,
1029
+ stickyIndicesFromProps,
1030
+ section.first,
1031
+ section.last,
1032
+ inversionStyle,
1033
+ );
1034
+ }
1035
+ }
1036
+
1037
+ if (!this._hasWarned.keys && _usedIndexForKey) {
1038
+ console.warn(
1039
+ 'VirtualizedList: missing keys for items, make sure to specify a key or id property on each ' +
1040
+ 'item or provide a custom keyExtractor.',
1041
+ _keylessItemComponentName,
1042
+ );
1043
+ this._hasWarned.keys = true;
1044
+ }
1045
+ }
1046
+
1047
+ // 3. Add cell for ListFooterComponent
1048
+ if (ListFooterComponent) {
1049
+ const element = React.isValidElement(ListFooterComponent) ? (
1050
+ ListFooterComponent
1051
+ ) : (
1052
+ // $FlowFixMe[not-a-component]
1053
+ // $FlowFixMe[incompatible-type-arg]
1054
+ <ListFooterComponent />
1055
+ );
1056
+ cells.push(
1057
+ <VirtualizedListCellContextProvider
1058
+ cellKey={this._getFooterCellKey()}
1059
+ key="$footer">
1060
+ <View
1061
+ onLayout={this._onLayoutFooter}
1062
+ style={[
1063
+ inversionStyle,
1064
+ this.props.ListFooterComponentStyle,
1065
+ ]}>
1066
+ {
1067
+ // $FlowFixMe[incompatible-type] - Typing ReactNativeComponent revealed errors
1068
+ element
1069
+ }
1070
+ </View>
1071
+ </VirtualizedListCellContextProvider>,
1072
+ );
1073
+ }
1074
+
1075
+ // 4. Render the ScrollView
1076
+ const scrollProps = {
1077
+ ...this.props,
1078
+ onContentSizeChange: this._onContentSizeChange,
1079
+ onLayout: this._onLayout,
1080
+ onScroll: this._onScroll,
1081
+ onScrollBeginDrag: this._onScrollBeginDrag,
1082
+ onScrollEndDrag: this._onScrollEndDrag,
1083
+ onMomentumScrollBegin: this._onMomentumScrollBegin,
1084
+ onMomentumScrollEnd: this._onMomentumScrollEnd,
1085
+ scrollEventThrottle: scrollEventThrottleOrDefault(
1086
+ this.props.scrollEventThrottle,
1087
+ ), // TODO: Android support
1088
+ invertStickyHeaders:
1089
+ this.props.invertStickyHeaders !== undefined
1090
+ ? this.props.invertStickyHeaders
1091
+ : this.props.inverted,
1092
+ stickyHeaderIndices,
1093
+ style: inversionStyle
1094
+ ? [inversionStyle, this.props.style]
1095
+ : this.props.style,
1096
+ };
1097
+
1098
+ this._hasMore = this.state.cellsAroundViewport.last < itemCount - 1;
1099
+
1100
+ const innerRet = (
1101
+ <VirtualizedListContextProvider
1102
+ value={{
1103
+ cellKey: null,
1104
+ getScrollMetrics: this._getScrollMetrics,
1105
+ horizontal: horizontalOrDefault(this.props.horizontal),
1106
+ getOutermostParentListRef: this._getOutermostParentListRef,
1107
+ registerAsNestedChild: this._registerAsNestedChild,
1108
+ unregisterAsNestedChild: this._unregisterAsNestedChild,
1109
+ }}>
1110
+ {React.cloneElement(
1111
+ (
1112
+ this.props.renderScrollComponent ||
1113
+ this._defaultRenderScrollComponent
1114
+ )(scrollProps),
1115
+ {
1116
+ ref: this._captureScrollRef,
1117
+ },
1118
+ cells,
1119
+ )}
1120
+ </VirtualizedListContextProvider>
1121
+ );
1122
+ let ret: React.Node = innerRet;
1123
+ /* https://github.com/necolas/react-native-web/issues/2239: Re-enable when ScrollView.Context.Consumer is available.
1124
+ if (__DEV__) {
1125
+ ret = (
1126
+ <ScrollView.Context.Consumer>
1127
+ {scrollContext => {
1128
+ if (
1129
+ scrollContext != null &&
1130
+ !scrollContext.horizontal ===
1131
+ !horizontalOrDefault(this.props.horizontal) &&
1132
+ !this._hasWarned.nesting &&
1133
+ this.context == null &&
1134
+ this.props.scrollEnabled !== false
1135
+ ) {
1136
+ // TODO (T46547044): use React.warn once 16.9 is sync'd: https://github.com/facebook/react/pull/15170
1137
+ console.error(
1138
+ 'VirtualizedLists should never be nested inside plain ScrollViews with the same ' +
1139
+ 'orientation because it can break windowing and other functionality - use another ' +
1140
+ 'VirtualizedList-backed container instead.',
1141
+ );
1142
+ this._hasWarned.nesting = true;
1143
+ }
1144
+ return innerRet;
1145
+ }}
1146
+ </ScrollView.Context.Consumer>
1147
+ );
1148
+ }*/
1149
+ if (this.props.debug) {
1150
+ return (
1151
+ <View style={styles.debug}>
1152
+ {ret}
1153
+ {this._renderDebugOverlay()}
1154
+ </View>
1155
+ );
1156
+ } else {
1157
+ return ret;
1158
+ }
1159
+ }
1160
+
1161
+ componentDidUpdate(prevProps: Props) {
1162
+ const {data, extraData} = this.props;
1163
+ if (data !== prevProps.data || extraData !== prevProps.extraData) {
1164
+ // clear the viewableIndices cache to also trigger
1165
+ // the onViewableItemsChanged callback with the new data
1166
+ this._viewabilityTuples.forEach(tuple => {
1167
+ tuple.viewabilityHelper.resetViewableIndices();
1168
+ });
1169
+ }
1170
+ // The `this._hiPriInProgress` is guaranteeing a hiPri cell update will only happen
1171
+ // once per fiber update. The `_scheduleCellsToRenderUpdate` will set it to true
1172
+ // if a hiPri update needs to perform. If `componentDidUpdate` is triggered with
1173
+ // `this._hiPriInProgress=true`, means it's triggered by the hiPri update. The
1174
+ // `_scheduleCellsToRenderUpdate` will check this condition and not perform
1175
+ // another hiPri update.
1176
+ const hiPriInProgress = this._hiPriInProgress;
1177
+ this._scheduleCellsToRenderUpdate();
1178
+ // Make sure setting `this._hiPriInProgress` back to false after `componentDidUpdate`
1179
+ // is triggered with `this._hiPriInProgress = true`
1180
+ if (hiPriInProgress) {
1181
+ this._hiPriInProgress = false;
1182
+ }
1183
+ }
1184
+
1185
+ _averageCellLength = 0;
1186
+ _cellRefs: {[string]: null | CellRenderer<any>} = {};
1187
+ _fillRateHelper: FillRateHelper;
1188
+ _frames: {
1189
+ [string]: {
1190
+ inLayout?: boolean,
1191
+ index: number,
1192
+ length: number,
1193
+ offset: number,
1194
+ },
1195
+ } = {};
1196
+ _footerLength = 0;
1197
+ // Used for preventing scrollToIndex from being called multiple times for initialScrollIndex
1198
+ _hasTriggeredInitialScrollToIndex = false;
1199
+ _hasInteracted = false;
1200
+ _hasMore = false;
1201
+ _hasWarned: {[string]: boolean} = {};
1202
+ _headerLength = 0;
1203
+ _hiPriInProgress: boolean = false; // flag to prevent infinite hiPri cell limit update
1204
+ _highestMeasuredFrameIndex = 0;
1205
+ _indicesToKeys: Map<number, string> = new Map();
1206
+ _lastFocusedCellKey: ?string = null;
1207
+ _nestedChildLists: ChildListCollection<VirtualizedList> =
1208
+ new ChildListCollection();
1209
+ _offsetFromParentVirtualizedList: number = 0;
1210
+ _prevParentOffset: number = 0;
1211
+ // $FlowFixMe[missing-local-annot]
1212
+ _scrollMetrics = {
1213
+ contentLength: 0,
1214
+ dOffset: 0,
1215
+ dt: 10,
1216
+ offset: 0,
1217
+ timestamp: 0,
1218
+ velocity: 0,
1219
+ visibleLength: 0,
1220
+ zoomScale: 1,
1221
+ };
1222
+ _scrollRef: ?React.ElementRef<any> = null;
1223
+ _sentStartForContentLength = 0;
1224
+ _sentEndForContentLength = 0;
1225
+ _totalCellLength = 0;
1226
+ _totalCellsMeasured = 0;
1227
+ _updateCellsToRenderBatcher: Batchinator;
1228
+ _viewabilityTuples: Array<ViewabilityHelperCallbackTuple> = [];
1229
+
1230
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
1231
+ * LTI update could not be added via codemod */
1232
+ _captureScrollRef = ref => {
1233
+ this._scrollRef = ref;
1234
+ };
1235
+
1236
+ _computeBlankness() {
1237
+ this._fillRateHelper.computeBlankness(
1238
+ this.props,
1239
+ this.state.cellsAroundViewport,
1240
+ this._scrollMetrics,
1241
+ );
1242
+ }
1243
+
1244
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
1245
+ * LTI update could not be added via codemod */
1246
+ _defaultRenderScrollComponent = props => {
1247
+ const onRefresh = props.onRefresh;
1248
+ if (this._isNestedWithSameOrientation()) {
1249
+ // $FlowFixMe[prop-missing] - Typing ReactNativeComponent revealed errors
1250
+ return <View {...props} />;
1251
+ } else if (onRefresh) {
1252
+ invariant(
1253
+ typeof props.refreshing === 'boolean',
1254
+ '`refreshing` prop must be set as a boolean in order to use `onRefresh`, but got `' +
1255
+ JSON.stringify(props.refreshing ?? 'undefined') +
1256
+ '`',
1257
+ );
1258
+ return (
1259
+ // $FlowFixMe[prop-missing] Invalid prop usage
1260
+ // $FlowFixMe[incompatible-use]
1261
+ <ScrollView
1262
+ {...props}
1263
+ refreshControl={
1264
+ props.refreshControl == null ? (
1265
+ <RefreshControl
1266
+ // $FlowFixMe[incompatible-type]
1267
+ refreshing={props.refreshing}
1268
+ onRefresh={onRefresh}
1269
+ progressViewOffset={props.progressViewOffset}
1270
+ />
1271
+ ) : (
1272
+ props.refreshControl
1273
+ )
1274
+ }
1275
+ />
1276
+ );
1277
+ } else {
1278
+ // $FlowFixMe[prop-missing] Invalid prop usage
1279
+ // $FlowFixMe[incompatible-use]
1280
+ return <ScrollView {...props} />;
1281
+ }
1282
+ };
1283
+
1284
+ _onCellLayout = (e: LayoutEvent, cellKey: string, index: number): void => {
1285
+ const layout = e.nativeEvent.layout;
1286
+ const next = {
1287
+ offset: this._selectOffset(layout),
1288
+ length: this._selectLength(layout),
1289
+ index,
1290
+ inLayout: true,
1291
+ };
1292
+ const curr = this._frames[cellKey];
1293
+ if (
1294
+ !curr ||
1295
+ next.offset !== curr.offset ||
1296
+ next.length !== curr.length ||
1297
+ index !== curr.index
1298
+ ) {
1299
+ this._totalCellLength += next.length - (curr ? curr.length : 0);
1300
+ this._totalCellsMeasured += curr ? 0 : 1;
1301
+ this._averageCellLength =
1302
+ this._totalCellLength / this._totalCellsMeasured;
1303
+ this._frames[cellKey] = next;
1304
+ this._highestMeasuredFrameIndex = Math.max(
1305
+ this._highestMeasuredFrameIndex,
1306
+ index,
1307
+ );
1308
+ this._scheduleCellsToRenderUpdate();
1309
+ } else {
1310
+ this._frames[cellKey].inLayout = true;
1311
+ }
1312
+
1313
+ this._triggerRemeasureForChildListsInCell(cellKey);
1314
+
1315
+ this._computeBlankness();
1316
+ this._updateViewableItems(this.props, this.state.cellsAroundViewport);
1317
+ };
1318
+
1319
+ _onCellFocusCapture(cellKey: string) {
1320
+ this._lastFocusedCellKey = cellKey;
1321
+ this._updateCellsToRender();
1322
+ }
1323
+
1324
+ _onCellUnmount = (cellKey: string) => {
1325
+ delete this._cellRefs[cellKey];
1326
+ const curr = this._frames[cellKey];
1327
+ if (curr) {
1328
+ this._frames[cellKey] = {...curr, inLayout: false};
1329
+ }
1330
+ };
1331
+
1332
+ _triggerRemeasureForChildListsInCell(cellKey: string): void {
1333
+ this._nestedChildLists.forEachInCell(cellKey, childList => {
1334
+ childList.measureLayoutRelativeToContainingList();
1335
+ });
1336
+ }
1337
+
1338
+ measureLayoutRelativeToContainingList(): void {
1339
+ // TODO (T35574538): findNodeHandle sometimes crashes with "Unable to find
1340
+ // node on an unmounted component" during scrolling
1341
+ try {
1342
+ if (!this._scrollRef) {
1343
+ return;
1344
+ }
1345
+ // We are assuming that getOutermostParentListRef().getScrollRef()
1346
+ // is a non-null reference to a ScrollView
1347
+ this._scrollRef.measureLayout(
1348
+ this.context.getOutermostParentListRef().getScrollRef(),
1349
+ (x, y, width, height) => {
1350
+ this._offsetFromParentVirtualizedList = this._selectOffset({x, y});
1351
+ this._scrollMetrics.contentLength = this._selectLength({
1352
+ width,
1353
+ height,
1354
+ });
1355
+ const scrollMetrics = this._convertParentScrollMetrics(
1356
+ this.context.getScrollMetrics(),
1357
+ );
1358
+
1359
+ const metricsChanged =
1360
+ this._scrollMetrics.visibleLength !== scrollMetrics.visibleLength ||
1361
+ this._scrollMetrics.offset !== scrollMetrics.offset;
1362
+
1363
+ if (metricsChanged) {
1364
+ this._scrollMetrics.visibleLength = scrollMetrics.visibleLength;
1365
+ this._scrollMetrics.offset = scrollMetrics.offset;
1366
+
1367
+ // If metrics of the scrollView changed, then we triggered remeasure for child list
1368
+ // to ensure VirtualizedList has the right information.
1369
+ this._nestedChildLists.forEach(childList => {
1370
+ childList.measureLayoutRelativeToContainingList();
1371
+ });
1372
+ }
1373
+ },
1374
+ error => {
1375
+ console.warn(
1376
+ "VirtualizedList: Encountered an error while measuring a list's" +
1377
+ ' offset from its containing VirtualizedList.',
1378
+ );
1379
+ },
1380
+ );
1381
+ } catch (error) {
1382
+ console.warn(
1383
+ 'measureLayoutRelativeToContainingList threw an error',
1384
+ error.stack,
1385
+ );
1386
+ }
1387
+ }
1388
+
1389
+ _onLayout = (e: LayoutEvent) => {
1390
+ if (this._isNestedWithSameOrientation()) {
1391
+ // Need to adjust our scroll metrics to be relative to our containing
1392
+ // VirtualizedList before we can make claims about list item viewability
1393
+ this.measureLayoutRelativeToContainingList();
1394
+ } else {
1395
+ this._scrollMetrics.visibleLength = this._selectLength(
1396
+ e.nativeEvent.layout,
1397
+ );
1398
+ }
1399
+ this.props.onLayout && this.props.onLayout(e);
1400
+ this._scheduleCellsToRenderUpdate();
1401
+ this._maybeCallOnEdgeReached();
1402
+ };
1403
+
1404
+ _onLayoutEmpty = (e: LayoutEvent) => {
1405
+ this.props.onLayout && this.props.onLayout(e);
1406
+ };
1407
+
1408
+ _getFooterCellKey(): string {
1409
+ return this._getCellKey() + '-footer';
1410
+ }
1411
+
1412
+ _onLayoutFooter = (e: LayoutEvent) => {
1413
+ this._triggerRemeasureForChildListsInCell(this._getFooterCellKey());
1414
+ this._footerLength = this._selectLength(e.nativeEvent.layout);
1415
+ };
1416
+
1417
+ _onLayoutHeader = (e: LayoutEvent) => {
1418
+ this._headerLength = this._selectLength(e.nativeEvent.layout);
1419
+ };
1420
+
1421
+ // $FlowFixMe[missing-local-annot]
1422
+ _renderDebugOverlay() {
1423
+ const normalize =
1424
+ this._scrollMetrics.visibleLength /
1425
+ (this._scrollMetrics.contentLength || 1);
1426
+ const framesInLayout = [];
1427
+ const itemCount = this.props.getItemCount(this.props.data);
1428
+ for (let ii = 0; ii < itemCount; ii++) {
1429
+ const frame = this.__getFrameMetricsApprox(ii, this.props);
1430
+ /* $FlowFixMe[prop-missing] (>=0.68.0 site=react_native_fb) This comment
1431
+ * suppresses an error found when Flow v0.68 was deployed. To see the
1432
+ * error delete this comment and run Flow. */
1433
+ if (frame.inLayout) {
1434
+ framesInLayout.push(frame);
1435
+ }
1436
+ }
1437
+ const windowTop = this.__getFrameMetricsApprox(
1438
+ this.state.cellsAroundViewport.first,
1439
+ this.props,
1440
+ ).offset;
1441
+ const frameLast = this.__getFrameMetricsApprox(
1442
+ this.state.cellsAroundViewport.last,
1443
+ this.props,
1444
+ );
1445
+ const windowLen = frameLast.offset + frameLast.length - windowTop;
1446
+ const visTop = this._scrollMetrics.offset;
1447
+ const visLen = this._scrollMetrics.visibleLength;
1448
+
1449
+ return (
1450
+ <View style={[styles.debugOverlayBase, styles.debugOverlay]}>
1451
+ {framesInLayout.map((f, ii) => (
1452
+ <View
1453
+ key={'f' + ii}
1454
+ style={[
1455
+ styles.debugOverlayBase,
1456
+ styles.debugOverlayFrame,
1457
+ {
1458
+ top: f.offset * normalize,
1459
+ height: f.length * normalize,
1460
+ },
1461
+ ]}
1462
+ />
1463
+ ))}
1464
+ <View
1465
+ style={[
1466
+ styles.debugOverlayBase,
1467
+ styles.debugOverlayFrameLast,
1468
+ {
1469
+ top: windowTop * normalize,
1470
+ height: windowLen * normalize,
1471
+ },
1472
+ ]}
1473
+ />
1474
+ <View
1475
+ style={[
1476
+ styles.debugOverlayBase,
1477
+ styles.debugOverlayFrameVis,
1478
+ {
1479
+ top: visTop * normalize,
1480
+ height: visLen * normalize,
1481
+ },
1482
+ ]}
1483
+ />
1484
+ </View>
1485
+ );
1486
+ }
1487
+
1488
+ _selectLength(
1489
+ metrics: $ReadOnly<{
1490
+ height: number,
1491
+ width: number,
1492
+ ...
1493
+ }>,
1494
+ ): number {
1495
+ return !horizontalOrDefault(this.props.horizontal)
1496
+ ? metrics.height
1497
+ : metrics.width;
1498
+ }
1499
+
1500
+ _selectOffset(
1501
+ metrics: $ReadOnly<{
1502
+ x: number,
1503
+ y: number,
1504
+ ...
1505
+ }>,
1506
+ ): number {
1507
+ return !horizontalOrDefault(this.props.horizontal) ? metrics.y : metrics.x;
1508
+ }
1509
+
1510
+ _maybeCallOnEdgeReached() {
1511
+ const {
1512
+ data,
1513
+ getItemCount,
1514
+ onStartReached,
1515
+ onStartReachedThreshold,
1516
+ onEndReached,
1517
+ onEndReachedThreshold,
1518
+ initialScrollIndex,
1519
+ } = this.props;
1520
+ const {contentLength, visibleLength, offset} = this._scrollMetrics;
1521
+ let distanceFromStart = offset;
1522
+ let distanceFromEnd = contentLength - visibleLength - offset;
1523
+
1524
+ // Especially when oERT is zero it's necessary to 'floor' very small distance values to be 0
1525
+ // since debouncing causes us to not fire this event for every single "pixel" we scroll and can thus
1526
+ // be at the edge of the list with a distance approximating 0 but not quite there.
1527
+ if (distanceFromStart < ON_EDGE_REACHED_EPSILON) {
1528
+ distanceFromStart = 0;
1529
+ }
1530
+ if (distanceFromEnd < ON_EDGE_REACHED_EPSILON) {
1531
+ distanceFromEnd = 0;
1532
+ }
1533
+
1534
+ // TODO: T121172172 Look into why we're "defaulting" to a threshold of 2px
1535
+ // when oERT is not present (different from 2 viewports used elsewhere)
1536
+ const DEFAULT_THRESHOLD_PX = 2;
1537
+
1538
+ const startThreshold =
1539
+ onStartReachedThreshold != null
1540
+ ? onStartReachedThreshold * visibleLength
1541
+ : DEFAULT_THRESHOLD_PX;
1542
+ const endThreshold =
1543
+ onEndReachedThreshold != null
1544
+ ? onEndReachedThreshold * visibleLength
1545
+ : DEFAULT_THRESHOLD_PX;
1546
+ const isWithinStartThreshold = distanceFromStart <= startThreshold;
1547
+ const isWithinEndThreshold = distanceFromEnd <= endThreshold;
1548
+
1549
+ // First check if the user just scrolled within the end threshold
1550
+ // and call onEndReached only once for a given content length,
1551
+ // and only if onStartReached is not being executed
1552
+ if (
1553
+ onEndReached &&
1554
+ this.state.cellsAroundViewport.last === getItemCount(data) - 1 &&
1555
+ isWithinEndThreshold &&
1556
+ this._scrollMetrics.contentLength !== this._sentEndForContentLength
1557
+ ) {
1558
+ this._sentEndForContentLength = this._scrollMetrics.contentLength;
1559
+ onEndReached({distanceFromEnd});
1560
+ }
1561
+
1562
+ // Next check if the user just scrolled within the start threshold
1563
+ // and call onStartReached only once for a given content length,
1564
+ // and only if onEndReached is not being executed
1565
+ else if (
1566
+ onStartReached != null &&
1567
+ this.state.cellsAroundViewport.first === 0 &&
1568
+ isWithinStartThreshold &&
1569
+ this._scrollMetrics.contentLength !== this._sentStartForContentLength
1570
+ ) {
1571
+ // On initial mount when using initialScrollIndex the offset will be 0 initially
1572
+ // and will trigger an unexpected onStartReached. To avoid this we can use
1573
+ // timestamp to differentiate between the initial scroll metrics and when we actually
1574
+ // received the first scroll event.
1575
+ if (!initialScrollIndex || this._scrollMetrics.timestamp !== 0) {
1576
+ this._sentStartForContentLength = this._scrollMetrics.contentLength;
1577
+ onStartReached({distanceFromStart});
1578
+ }
1579
+ }
1580
+
1581
+ // If the user scrolls away from the start or end and back again,
1582
+ // cause onStartReached or onEndReached to be triggered again
1583
+ else {
1584
+ this._sentStartForContentLength = isWithinStartThreshold
1585
+ ? this._sentStartForContentLength
1586
+ : 0;
1587
+ this._sentEndForContentLength = isWithinEndThreshold
1588
+ ? this._sentEndForContentLength
1589
+ : 0;
1590
+ }
1591
+ }
1592
+
1593
+ _onContentSizeChange = (width: number, height: number) => {
1594
+ if (
1595
+ width > 0 &&
1596
+ height > 0 &&
1597
+ this.props.initialScrollIndex != null &&
1598
+ this.props.initialScrollIndex > 0 &&
1599
+ !this._hasTriggeredInitialScrollToIndex
1600
+ ) {
1601
+ if (this.props.contentOffset == null) {
1602
+ if (
1603
+ this.props.initialScrollIndex <
1604
+ this.props.getItemCount(this.props.data)
1605
+ ) {
1606
+ this.scrollToIndex({
1607
+ animated: false,
1608
+ index: nullthrows(this.props.initialScrollIndex),
1609
+ });
1610
+ } else {
1611
+ this.scrollToEnd({animated: false});
1612
+ }
1613
+ }
1614
+ this._hasTriggeredInitialScrollToIndex = true;
1615
+ }
1616
+ if (this.props.onContentSizeChange) {
1617
+ this.props.onContentSizeChange(width, height);
1618
+ }
1619
+ this._scrollMetrics.contentLength = this._selectLength({height, width});
1620
+ this._scheduleCellsToRenderUpdate();
1621
+ this._maybeCallOnEdgeReached();
1622
+ };
1623
+
1624
+ /* Translates metrics from a scroll event in a parent VirtualizedList into
1625
+ * coordinates relative to the child list.
1626
+ */
1627
+ _convertParentScrollMetrics = (metrics: {
1628
+ visibleLength: number,
1629
+ offset: number,
1630
+ ...
1631
+ }): $FlowFixMe => {
1632
+ // Offset of the top of the nested list relative to the top of its parent's viewport
1633
+ const offset = metrics.offset - this._offsetFromParentVirtualizedList;
1634
+ // Child's visible length is the same as its parent's
1635
+ const visibleLength = metrics.visibleLength;
1636
+ const dOffset = offset - this._scrollMetrics.offset;
1637
+ const contentLength = this._scrollMetrics.contentLength;
1638
+
1639
+ return {
1640
+ visibleLength,
1641
+ contentLength,
1642
+ offset,
1643
+ dOffset,
1644
+ };
1645
+ };
1646
+
1647
+ _onScroll = (e: Object) => {
1648
+ this._nestedChildLists.forEach(childList => {
1649
+ childList._onScroll(e);
1650
+ });
1651
+ if (this.props.onScroll) {
1652
+ this.props.onScroll(e);
1653
+ }
1654
+ const timestamp = e.timeStamp;
1655
+ let visibleLength = this._selectLength(e.nativeEvent.layoutMeasurement);
1656
+ let contentLength = this._selectLength(e.nativeEvent.contentSize);
1657
+ let offset = this._selectOffset(e.nativeEvent.contentOffset);
1658
+ let dOffset = offset - this._scrollMetrics.offset;
1659
+
1660
+ if (this._isNestedWithSameOrientation()) {
1661
+ if (this._scrollMetrics.contentLength === 0) {
1662
+ // Ignore scroll events until onLayout has been called and we
1663
+ // know our offset from our offset from our parent
1664
+ return;
1665
+ }
1666
+ ({visibleLength, contentLength, offset, dOffset} =
1667
+ this._convertParentScrollMetrics({
1668
+ visibleLength,
1669
+ offset,
1670
+ }));
1671
+ }
1672
+
1673
+ const dt = this._scrollMetrics.timestamp
1674
+ ? Math.max(1, timestamp - this._scrollMetrics.timestamp)
1675
+ : 1;
1676
+ const velocity = dOffset / dt;
1677
+
1678
+ if (
1679
+ dt > 500 &&
1680
+ this._scrollMetrics.dt > 500 &&
1681
+ contentLength > 5 * visibleLength &&
1682
+ !this._hasWarned.perf
1683
+ ) {
1684
+ infoLog(
1685
+ 'VirtualizedList: You have a large list that is slow to update - make sure your ' +
1686
+ 'renderItem function renders components that follow React performance best practices ' +
1687
+ 'like PureComponent, shouldComponentUpdate, etc.',
1688
+ {dt, prevDt: this._scrollMetrics.dt, contentLength},
1689
+ );
1690
+ this._hasWarned.perf = true;
1691
+ }
1692
+
1693
+ // For invalid negative values (w/ RTL), set this to 1.
1694
+ const zoomScale = e.nativeEvent.zoomScale < 0 ? 1 : e.nativeEvent.zoomScale;
1695
+ this._scrollMetrics = {
1696
+ contentLength,
1697
+ dt,
1698
+ dOffset,
1699
+ offset,
1700
+ timestamp,
1701
+ velocity,
1702
+ visibleLength,
1703
+ zoomScale,
1704
+ };
1705
+ this._updateViewableItems(this.props, this.state.cellsAroundViewport);
1706
+ if (!this.props) {
1707
+ return;
1708
+ }
1709
+ this._maybeCallOnEdgeReached();
1710
+ if (velocity !== 0) {
1711
+ this._fillRateHelper.activate();
1712
+ }
1713
+ this._computeBlankness();
1714
+ this._scheduleCellsToRenderUpdate();
1715
+ };
1716
+
1717
+ _scheduleCellsToRenderUpdate() {
1718
+ const {first, last} = this.state.cellsAroundViewport;
1719
+ const {offset, visibleLength, velocity} = this._scrollMetrics;
1720
+ const itemCount = this.props.getItemCount(this.props.data);
1721
+ let hiPri = false;
1722
+ const onStartReachedThreshold = onStartReachedThresholdOrDefault(
1723
+ this.props.onStartReachedThreshold,
1724
+ );
1725
+ const onEndReachedThreshold = onEndReachedThresholdOrDefault(
1726
+ this.props.onEndReachedThreshold,
1727
+ );
1728
+ // Mark as high priority if we're close to the start of the first item
1729
+ // But only if there are items before the first rendered item
1730
+ if (first > 0) {
1731
+ const distTop =
1732
+ offset - this.__getFrameMetricsApprox(first, this.props).offset;
1733
+ hiPri =
1734
+ distTop < 0 ||
1735
+ (velocity < -2 &&
1736
+ distTop <
1737
+ getScrollingThreshold(onStartReachedThreshold, visibleLength));
1738
+ }
1739
+ // Mark as high priority if we're close to the end of the last item
1740
+ // But only if there are items after the last rendered item
1741
+ if (!hiPri && last >= 0 && last < itemCount - 1) {
1742
+ const distBottom =
1743
+ this.__getFrameMetricsApprox(last, this.props).offset -
1744
+ (offset + visibleLength);
1745
+ hiPri =
1746
+ distBottom < 0 ||
1747
+ (velocity > 2 &&
1748
+ distBottom <
1749
+ getScrollingThreshold(onEndReachedThreshold, visibleLength));
1750
+ }
1751
+ // Only trigger high-priority updates if we've actually rendered cells,
1752
+ // and with that size estimate, accurately compute how many cells we should render.
1753
+ // Otherwise, it would just render as many cells as it can (of zero dimension),
1754
+ // each time through attempting to render more (limited by maxToRenderPerBatch),
1755
+ // starving the renderer from actually laying out the objects and computing _averageCellLength.
1756
+ // If this is triggered in an `componentDidUpdate` followed by a hiPri cellToRenderUpdate
1757
+ // We shouldn't do another hipri cellToRenderUpdate
1758
+ if (
1759
+ hiPri &&
1760
+ (this._averageCellLength || this.props.getItemLayout) &&
1761
+ !this._hiPriInProgress
1762
+ ) {
1763
+ this._hiPriInProgress = true;
1764
+ // Don't worry about interactions when scrolling quickly; focus on filling content as fast
1765
+ // as possible.
1766
+ this._updateCellsToRenderBatcher.dispose({abort: true});
1767
+ this._updateCellsToRender();
1768
+ return;
1769
+ } else {
1770
+ this._updateCellsToRenderBatcher.schedule();
1771
+ }
1772
+ }
1773
+
1774
+ _onScrollBeginDrag = (e: ScrollEvent): void => {
1775
+ this._nestedChildLists.forEach(childList => {
1776
+ childList._onScrollBeginDrag(e);
1777
+ });
1778
+ this._viewabilityTuples.forEach(tuple => {
1779
+ tuple.viewabilityHelper.recordInteraction();
1780
+ });
1781
+ this._hasInteracted = true;
1782
+ this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
1783
+ };
1784
+
1785
+ _onScrollEndDrag = (e: ScrollEvent): void => {
1786
+ this._nestedChildLists.forEach(childList => {
1787
+ childList._onScrollEndDrag(e);
1788
+ });
1789
+ const {velocity} = e.nativeEvent;
1790
+ if (velocity) {
1791
+ this._scrollMetrics.velocity = this._selectOffset(velocity);
1792
+ }
1793
+ this._computeBlankness();
1794
+ this.props.onScrollEndDrag && this.props.onScrollEndDrag(e);
1795
+ };
1796
+
1797
+ _onMomentumScrollBegin = (e: ScrollEvent): void => {
1798
+ this._nestedChildLists.forEach(childList => {
1799
+ childList._onMomentumScrollBegin(e);
1800
+ });
1801
+ this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e);
1802
+ };
1803
+
1804
+ _onMomentumScrollEnd = (e: ScrollEvent): void => {
1805
+ this._nestedChildLists.forEach(childList => {
1806
+ childList._onMomentumScrollEnd(e);
1807
+ });
1808
+ this._scrollMetrics.velocity = 0;
1809
+ this._computeBlankness();
1810
+ this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd(e);
1811
+ };
1812
+
1813
+ _updateCellsToRender = () => {
1814
+ this._updateViewableItems(this.props, this.state.cellsAroundViewport);
1815
+
1816
+ this.setState((state, props) => {
1817
+ const cellsAroundViewport = this._adjustCellsAroundViewport(
1818
+ props,
1819
+ state.cellsAroundViewport,
1820
+ );
1821
+ const renderMask = VirtualizedList._createRenderMask(
1822
+ props,
1823
+ cellsAroundViewport,
1824
+ this._getNonViewportRenderRegions(props),
1825
+ );
1826
+
1827
+ if (
1828
+ cellsAroundViewport.first === state.cellsAroundViewport.first &&
1829
+ cellsAroundViewport.last === state.cellsAroundViewport.last &&
1830
+ renderMask.equals(state.renderMask)
1831
+ ) {
1832
+ return null;
1833
+ }
1834
+
1835
+ return {cellsAroundViewport, renderMask};
1836
+ });
1837
+ };
1838
+
1839
+ _createViewToken = (
1840
+ index: number,
1841
+ isViewable: boolean,
1842
+ props: FrameMetricProps,
1843
+ // $FlowFixMe[missing-local-annot]
1844
+ ) => {
1845
+ const {data, getItem} = props;
1846
+ const item = getItem(data, index);
1847
+ return {
1848
+ index,
1849
+ item,
1850
+ key: this._keyExtractor(item, index, props),
1851
+ isViewable,
1852
+ };
1853
+ };
1854
+
1855
+ /**
1856
+ * Gets an approximate offset to an item at a given index. Supports
1857
+ * fractional indices.
1858
+ */
1859
+ _getOffsetApprox = (index: number, props: FrameMetricProps): number => {
1860
+ if (Number.isInteger(index)) {
1861
+ return this.__getFrameMetricsApprox(index, props).offset;
1862
+ } else {
1863
+ const frameMetrics = this.__getFrameMetricsApprox(
1864
+ Math.floor(index),
1865
+ props,
1866
+ );
1867
+ const remainder = index - Math.floor(index);
1868
+ return frameMetrics.offset + remainder * frameMetrics.length;
1869
+ }
1870
+ };
1871
+
1872
+ __getFrameMetricsApprox: (
1873
+ index: number,
1874
+ props: FrameMetricProps,
1875
+ ) => {
1876
+ length: number,
1877
+ offset: number,
1878
+ ...
1879
+ } = (index, props) => {
1880
+ const frame = this._getFrameMetrics(index, props);
1881
+ if (frame && frame.index === index) {
1882
+ // check for invalid frames due to row re-ordering
1883
+ return frame;
1884
+ } else {
1885
+ const {data, getItemCount, getItemLayout} = props;
1886
+ invariant(
1887
+ index >= 0 && index < getItemCount(data),
1888
+ 'Tried to get frame for out of range index ' + index,
1889
+ );
1890
+ invariant(
1891
+ !getItemLayout,
1892
+ 'Should not have to estimate frames when a measurement metrics function is provided',
1893
+ );
1894
+ return {
1895
+ length: this._averageCellLength,
1896
+ offset: this._averageCellLength * index,
1897
+ };
1898
+ }
1899
+ };
1900
+
1901
+ _getFrameMetrics = (
1902
+ index: number,
1903
+ props: FrameMetricProps,
1904
+ ): ?{
1905
+ length: number,
1906
+ offset: number,
1907
+ index: number,
1908
+ inLayout?: boolean,
1909
+ ...
1910
+ } => {
1911
+ const {data, getItem, getItemCount, getItemLayout} = props;
1912
+ invariant(
1913
+ index >= 0 && index < getItemCount(data),
1914
+ 'Tried to get frame for out of range index ' + index,
1915
+ );
1916
+ const item = getItem(data, index);
1917
+ const frame = this._frames[this._keyExtractor(item, index, props)];
1918
+ if (!frame || frame.index !== index) {
1919
+ if (getItemLayout) {
1920
+ /* $FlowFixMe[prop-missing] (>=0.63.0 site=react_native_fb) This comment
1921
+ * suppresses an error found when Flow v0.63 was deployed. To see the error
1922
+ * delete this comment and run Flow. */
1923
+ return getItemLayout(data, index);
1924
+ }
1925
+ }
1926
+ return frame;
1927
+ };
1928
+
1929
+ _getNonViewportRenderRegions = (
1930
+ props: FrameMetricProps,
1931
+ ): $ReadOnlyArray<{
1932
+ first: number,
1933
+ last: number,
1934
+ }> => {
1935
+ // Keep a viewport's worth of content around the last focused cell to allow
1936
+ // random navigation around it without any blanking. E.g. tabbing from one
1937
+ // focused item out of viewport to another.
1938
+ if (
1939
+ !(this._lastFocusedCellKey && this._cellRefs[this._lastFocusedCellKey])
1940
+ ) {
1941
+ return [];
1942
+ }
1943
+
1944
+ const lastFocusedCellRenderer = this._cellRefs[this._lastFocusedCellKey];
1945
+ const focusedCellIndex = lastFocusedCellRenderer.props.index;
1946
+ const itemCount = props.getItemCount(props.data);
1947
+
1948
+ // The last cell we rendered may be at a new index. Bail if we don't know
1949
+ // where it is.
1950
+ if (
1951
+ focusedCellIndex >= itemCount ||
1952
+ this._keyExtractor(
1953
+ props.getItem(props.data, focusedCellIndex),
1954
+ focusedCellIndex,
1955
+ props,
1956
+ ) !== this._lastFocusedCellKey
1957
+ ) {
1958
+ return [];
1959
+ }
1960
+
1961
+ let first = focusedCellIndex;
1962
+ let heightOfCellsBeforeFocused = 0;
1963
+ for (
1964
+ let i = first - 1;
1965
+ i >= 0 && heightOfCellsBeforeFocused < this._scrollMetrics.visibleLength;
1966
+ i--
1967
+ ) {
1968
+ first--;
1969
+ heightOfCellsBeforeFocused += this.__getFrameMetricsApprox(
1970
+ i,
1971
+ props,
1972
+ ).length;
1973
+ }
1974
+
1975
+ let last = focusedCellIndex;
1976
+ let heightOfCellsAfterFocused = 0;
1977
+ for (
1978
+ let i = last + 1;
1979
+ i < itemCount &&
1980
+ heightOfCellsAfterFocused < this._scrollMetrics.visibleLength;
1981
+ i++
1982
+ ) {
1983
+ last++;
1984
+ heightOfCellsAfterFocused += this.__getFrameMetricsApprox(
1985
+ i,
1986
+ props,
1987
+ ).length;
1988
+ }
1989
+
1990
+ return [{first, last}];
1991
+ };
1992
+
1993
+ _updateViewableItems(
1994
+ props: FrameMetricProps,
1995
+ cellsAroundViewport: {first: number, last: number},
1996
+ ) {
1997
+ this._viewabilityTuples.forEach(tuple => {
1998
+ tuple.viewabilityHelper.onUpdate(
1999
+ props,
2000
+ this._scrollMetrics.offset,
2001
+ this._scrollMetrics.visibleLength,
2002
+ this._getFrameMetrics,
2003
+ this._createViewToken,
2004
+ tuple.onViewableItemsChanged,
2005
+ cellsAroundViewport,
2006
+ );
2007
+ });
2008
+ }
2009
+ }
2010
+
2011
+ const styles = StyleSheet.create({
2012
+ verticallyInverted: {
2013
+ transform: 'scaleY(-1)',
2014
+ },
2015
+ horizontallyInverted: {
2016
+ transform: 'scaleX(-1)',
2017
+ },
2018
+ debug: {
2019
+ flex: 1,
2020
+ },
2021
+ debugOverlayBase: {
2022
+ position: 'absolute',
2023
+ top: 0,
2024
+ right: 0,
2025
+ },
2026
+ debugOverlay: {
2027
+ bottom: 0,
2028
+ width: 20,
2029
+ borderColor: 'blue',
2030
+ borderWidth: 1,
2031
+ },
2032
+ debugOverlayFrame: {
2033
+ left: 0,
2034
+ backgroundColor: 'orange',
2035
+ },
2036
+ debugOverlayFrameLast: {
2037
+ left: 0,
2038
+ borderColor: 'green',
2039
+ borderWidth: 2,
2040
+ },
2041
+ debugOverlayFrameVis: {
2042
+ left: 0,
2043
+ borderColor: 'red',
2044
+ borderWidth: 2,
2045
+ },
2046
+ });
2047
+
2048
+ export default VirtualizedList;