react-native-gesture-handler 2.16.1 → 2.17.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 (369) hide show
  1. package/README.md +9 -3
  2. package/android/build.gradle +105 -0
  3. package/android/gradle.properties +7 -0
  4. package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +7 -7
  5. package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +16 -8
  6. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +9 -5
  7. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +4 -0
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +1 -1
  9. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +1 -0
  10. package/apple/RNGestureHandlerButtonComponentView.mm +10 -0
  11. package/apple/RNGestureHandlerModule.mm +2 -3
  12. package/lib/commonjs/RNGestureHandlerModule.js +4 -97
  13. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  14. package/lib/commonjs/RNGestureHandlerModule.web.js +109 -0
  15. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -0
  16. package/lib/commonjs/RNRenderer.js +10 -5
  17. package/lib/commonjs/RNRenderer.js.map +1 -1
  18. package/lib/commonjs/RNRenderer.web.js +11 -0
  19. package/lib/commonjs/RNRenderer.web.js.map +1 -0
  20. package/lib/commonjs/components/GestureButtons.js +27 -12
  21. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  22. package/lib/commonjs/components/GestureComponents.js +82 -19
  23. package/lib/commonjs/components/GestureComponents.js.map +1 -1
  24. package/lib/commonjs/components/GestureComponents.web.js +52 -0
  25. package/lib/commonjs/components/GestureComponents.web.js.map +1 -0
  26. package/lib/commonjs/components/GestureHandlerButton.js +3 -13
  27. package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
  28. package/lib/commonjs/components/GestureHandlerButton.web.js +24 -0
  29. package/lib/commonjs/components/GestureHandlerButton.web.js.map +1 -0
  30. package/lib/commonjs/components/GestureHandlerRootView.js +6 -0
  31. package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
  32. package/lib/commonjs/components/{GestureHandlerRootView.native.js → GestureHandlerRootView.web.js} +1 -7
  33. package/lib/commonjs/components/GestureHandlerRootView.web.js.map +1 -0
  34. package/lib/commonjs/getReactNativeVersion.js +12 -1
  35. package/lib/commonjs/getReactNativeVersion.js.map +1 -1
  36. package/lib/commonjs/getReactNativeVersion.web.js +11 -0
  37. package/lib/commonjs/getReactNativeVersion.web.js.map +1 -0
  38. package/lib/commonjs/getShadowNodeFromRef.js +34 -5
  39. package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
  40. package/lib/commonjs/getShadowNodeFromRef.web.js +15 -0
  41. package/lib/commonjs/getShadowNodeFromRef.web.js.map +1 -0
  42. package/lib/commonjs/handlers/PressabilityDebugView.js +7 -5
  43. package/lib/commonjs/handlers/PressabilityDebugView.js.map +1 -1
  44. package/lib/commonjs/handlers/PressabilityDebugView.web.js +12 -0
  45. package/lib/commonjs/handlers/PressabilityDebugView.web.js.map +1 -0
  46. package/lib/commonjs/handlers/createHandler.js +1 -3
  47. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  48. package/lib/commonjs/handlers/customDirectEventTypes.js +8 -5
  49. package/lib/commonjs/handlers/customDirectEventTypes.js.map +1 -1
  50. package/lib/commonjs/handlers/customDirectEventTypes.web.js +11 -0
  51. package/lib/commonjs/handlers/customDirectEventTypes.web.js.map +1 -0
  52. package/lib/commonjs/handlers/gestureHandlerCommon.js +3 -3
  53. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  54. package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js +42 -0
  55. package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js.map +1 -0
  56. package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js +83 -0
  57. package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -0
  58. package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js +25 -0
  59. package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -0
  60. package/lib/commonjs/handlers/gestures/GestureDetector/index.js +143 -0
  61. package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -0
  62. package/lib/commonjs/handlers/gestures/GestureDetector/needsToReattach.js +25 -0
  63. package/lib/commonjs/handlers/gestures/GestureDetector/needsToReattach.js.map +1 -0
  64. package/lib/commonjs/handlers/gestures/GestureDetector/types.js +6 -0
  65. package/lib/commonjs/handlers/gestures/GestureDetector/types.js.map +1 -0
  66. package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js +80 -0
  67. package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -0
  68. package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js +180 -0
  69. package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -0
  70. package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js +55 -0
  71. package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -0
  72. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +47 -0
  73. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -0
  74. package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +176 -0
  75. package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -0
  76. package/lib/commonjs/handlers/gestures/gestureComposition.js +3 -1
  77. package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -1
  78. package/lib/commonjs/handlers/gestures/gestureStateManager.js +8 -0
  79. package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
  80. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
  81. package/lib/commonjs/utils.js +36 -0
  82. package/lib/commonjs/utils.js.map +1 -1
  83. package/lib/commonjs/web/detectors/RotationGestureDetector.js +6 -8
  84. package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
  85. package/lib/commonjs/web/detectors/ScaleGestureDetector.js +5 -6
  86. package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
  87. package/lib/commonjs/web/handlers/FlingGestureHandler.js +1 -0
  88. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  89. package/lib/commonjs/web/handlers/GestureHandler.js +56 -64
  90. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  91. package/lib/commonjs/web/handlers/LongPressGestureHandler.js +1 -0
  92. package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
  93. package/lib/commonjs/web/handlers/ManualGestureHandler.js +1 -0
  94. package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
  95. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +7 -4
  96. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
  97. package/lib/commonjs/web/handlers/PanGestureHandler.js +28 -18
  98. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  99. package/lib/commonjs/web/handlers/PinchGestureHandler.js +1 -0
  100. package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
  101. package/lib/commonjs/web/handlers/RotationGestureHandler.js +1 -0
  102. package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
  103. package/lib/commonjs/web/handlers/TapGestureHandler.js +18 -12
  104. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  105. package/lib/commonjs/web/interfaces.js.map +1 -1
  106. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -6
  107. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  108. package/lib/commonjs/web/tools/PointerEventManager.js +7 -2
  109. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  110. package/lib/commonjs/web/tools/PointerTracker.js +89 -57
  111. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
  112. package/lib/commonjs/web/tools/TouchEventManager.js +6 -2
  113. package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
  114. package/lib/commonjs/web/tools/Vector.js +2 -1
  115. package/lib/commonjs/web/tools/Vector.js.map +1 -1
  116. package/lib/commonjs/web/utils.js +31 -0
  117. package/lib/commonjs/web/utils.js.map +1 -1
  118. package/lib/module/RNGestureHandlerModule.js +4 -84
  119. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  120. package/lib/module/RNGestureHandlerModule.web.js +85 -0
  121. package/lib/module/RNGestureHandlerModule.web.js.map +1 -0
  122. package/lib/module/RNRenderer.js +3 -3
  123. package/lib/module/RNRenderer.js.map +1 -1
  124. package/lib/module/RNRenderer.web.js +4 -0
  125. package/lib/module/RNRenderer.web.js.map +1 -0
  126. package/lib/module/components/GestureButtons.js +24 -6
  127. package/lib/module/components/GestureButtons.js.map +1 -1
  128. package/lib/module/components/GestureComponents.js +80 -18
  129. package/lib/module/components/GestureComponents.js.map +1 -1
  130. package/lib/module/components/GestureComponents.web.js +28 -0
  131. package/lib/module/components/GestureComponents.web.js.map +1 -0
  132. package/lib/module/components/GestureHandlerButton.js +2 -8
  133. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  134. package/lib/module/components/GestureHandlerButton.web.js +9 -0
  135. package/lib/module/components/GestureHandlerButton.web.js.map +1 -0
  136. package/lib/module/components/GestureHandlerRootView.js +5 -0
  137. package/lib/module/components/GestureHandlerRootView.js.map +1 -1
  138. package/lib/module/components/{GestureHandlerRootView.native.js → GestureHandlerRootView.web.js} +1 -6
  139. package/lib/module/components/GestureHandlerRootView.web.js.map +1 -0
  140. package/lib/module/getReactNativeVersion.js +7 -1
  141. package/lib/module/getReactNativeVersion.js.map +1 -1
  142. package/lib/module/getReactNativeVersion.web.js +4 -0
  143. package/lib/module/getReactNativeVersion.web.js.map +1 -0
  144. package/lib/module/getShadowNodeFromRef.js +33 -4
  145. package/lib/module/getShadowNodeFromRef.js.map +1 -1
  146. package/lib/module/getShadowNodeFromRef.web.js +8 -0
  147. package/lib/module/getShadowNodeFromRef.web.js.map +1 -0
  148. package/lib/module/handlers/PressabilityDebugView.js +2 -4
  149. package/lib/module/handlers/PressabilityDebugView.js.map +1 -1
  150. package/lib/module/handlers/PressabilityDebugView.web.js +5 -0
  151. package/lib/module/handlers/PressabilityDebugView.web.js.map +1 -0
  152. package/lib/module/handlers/createHandler.js +2 -4
  153. package/lib/module/handlers/createHandler.js.map +1 -1
  154. package/lib/module/handlers/customDirectEventTypes.js +2 -4
  155. package/lib/module/handlers/customDirectEventTypes.js.map +1 -1
  156. package/lib/module/handlers/customDirectEventTypes.web.js +5 -0
  157. package/lib/module/handlers/customDirectEventTypes.web.js.map +1 -0
  158. package/lib/module/handlers/gestureHandlerCommon.js +1 -1
  159. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  160. package/lib/module/handlers/gestures/GestureDetector/Wrap.js +26 -0
  161. package/lib/module/handlers/gestures/GestureDetector/Wrap.js.map +1 -0
  162. package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js +65 -0
  163. package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -0
  164. package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js +12 -0
  165. package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -0
  166. package/lib/module/handlers/gestures/GestureDetector/index.js +115 -0
  167. package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -0
  168. package/lib/module/handlers/gestures/GestureDetector/needsToReattach.js +18 -0
  169. package/lib/module/handlers/gestures/GestureDetector/needsToReattach.js.map +1 -0
  170. package/lib/module/handlers/gestures/GestureDetector/types.js +2 -0
  171. package/lib/module/handlers/gestures/GestureDetector/types.js.map +1 -0
  172. package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js +64 -0
  173. package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -0
  174. package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js +165 -0
  175. package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -0
  176. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +41 -0
  177. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -0
  178. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +36 -0
  179. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -0
  180. package/lib/module/handlers/gestures/GestureDetector/utils.js +142 -0
  181. package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -0
  182. package/lib/module/handlers/gestures/gestureComposition.js +3 -1
  183. package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
  184. package/lib/module/handlers/gestures/gestureStateManager.js +8 -0
  185. package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
  186. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
  187. package/lib/module/utils.js +34 -0
  188. package/lib/module/utils.js.map +1 -1
  189. package/lib/module/web/detectors/RotationGestureDetector.js +6 -8
  190. package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
  191. package/lib/module/web/detectors/ScaleGestureDetector.js +5 -6
  192. package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
  193. package/lib/module/web/handlers/FlingGestureHandler.js +1 -0
  194. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  195. package/lib/module/web/handlers/GestureHandler.js +56 -64
  196. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  197. package/lib/module/web/handlers/LongPressGestureHandler.js +1 -0
  198. package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
  199. package/lib/module/web/handlers/ManualGestureHandler.js +1 -0
  200. package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
  201. package/lib/module/web/handlers/NativeViewGestureHandler.js +7 -4
  202. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  203. package/lib/module/web/handlers/PanGestureHandler.js +28 -18
  204. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  205. package/lib/module/web/handlers/PinchGestureHandler.js +1 -0
  206. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  207. package/lib/module/web/handlers/RotationGestureHandler.js +1 -0
  208. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  209. package/lib/module/web/handlers/TapGestureHandler.js +18 -12
  210. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  211. package/lib/module/web/interfaces.js.map +1 -1
  212. package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -6
  213. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  214. package/lib/module/web/tools/PointerEventManager.js +8 -3
  215. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  216. package/lib/module/web/tools/PointerTracker.js +89 -57
  217. package/lib/module/web/tools/PointerTracker.js.map +1 -1
  218. package/lib/module/web/tools/TouchEventManager.js +7 -3
  219. package/lib/module/web/tools/TouchEventManager.js.map +1 -1
  220. package/lib/module/web/tools/Vector.js +2 -1
  221. package/lib/module/web/tools/Vector.js.map +1 -1
  222. package/lib/module/web/utils.js +29 -0
  223. package/lib/module/web/utils.js.map +1 -1
  224. package/lib/typescript/RNGestureHandlerModule.d.ts +2 -15
  225. package/lib/typescript/RNGestureHandlerModule.web.d.ts +15 -0
  226. package/lib/typescript/RNRenderer.d.ts +1 -3
  227. package/lib/typescript/RNRenderer.web.d.ts +3 -0
  228. package/lib/typescript/components/GestureButtons.d.ts +3 -34
  229. package/lib/typescript/components/GestureComponents.d.ts +21 -7
  230. package/lib/typescript/components/GestureComponents.web.d.ts +8 -0
  231. package/lib/typescript/components/GestureHandlerButton.d.ts +3 -3
  232. package/lib/typescript/components/GestureHandlerButton.web.d.ts +4 -0
  233. package/lib/typescript/getReactNativeVersion.d.ts +4 -1
  234. package/lib/typescript/getReactNativeVersion.web.d.ts +1 -0
  235. package/lib/typescript/getShadowNodeFromRef.d.ts +1 -1
  236. package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
  237. package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -1
  238. package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +1 -0
  239. package/lib/typescript/handlers/customDirectEventTypes.d.ts +1 -2
  240. package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +2 -0
  241. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +3 -2
  242. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +13 -0
  243. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +13 -0
  244. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +2 -0
  245. package/lib/typescript/handlers/gestures/{GestureDetector.d.ts → GestureDetector/index.d.ts} +4 -12
  246. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +3 -0
  247. package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +20 -0
  248. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +4 -0
  249. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +2 -0
  250. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +5 -0
  251. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +3 -0
  252. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +12 -0
  253. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +1 -1
  254. package/lib/typescript/utils.d.ts +10 -0
  255. package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
  256. package/lib/typescript/web/interfaces.d.ts +1 -0
  257. package/lib/typescript/web/tools/PointerTracker.d.ts +34 -31
  258. package/lib/typescript/web/utils.d.ts +4 -0
  259. package/package.json +5 -5
  260. package/src/RNGestureHandlerModule.ts +4 -104
  261. package/src/RNGestureHandlerModule.web.ts +105 -0
  262. package/src/RNRenderer.ts +3 -3
  263. package/src/RNRenderer.web.ts +3 -0
  264. package/src/components/GestureButtons.tsx +36 -4
  265. package/src/components/GestureComponents.tsx +131 -24
  266. package/src/components/GestureComponents.web.tsx +41 -0
  267. package/src/components/GestureHandlerButton.tsx +4 -5
  268. package/src/components/GestureHandlerButton.web.tsx +6 -0
  269. package/src/components/GestureHandlerRootView.tsx +6 -0
  270. package/src/components/{GestureHandlerRootView.native.tsx → GestureHandlerRootView.web.tsx} +0 -6
  271. package/src/getReactNativeVersion.ts +9 -1
  272. package/src/getReactNativeVersion.web.ts +3 -0
  273. package/src/getShadowNodeFromRef.ts +41 -4
  274. package/src/getShadowNodeFromRef.web.ts +7 -0
  275. package/src/handlers/PressabilityDebugView.tsx +2 -4
  276. package/src/handlers/PressabilityDebugView.web.tsx +4 -0
  277. package/src/handlers/createHandler.tsx +1 -3
  278. package/src/handlers/customDirectEventTypes.ts +2 -5
  279. package/src/handlers/customDirectEventTypes.web.ts +5 -0
  280. package/src/handlers/gestureHandlerCommon.ts +4 -1
  281. package/src/handlers/gestures/GestureDetector/Wrap.tsx +35 -0
  282. package/src/handlers/gestures/GestureDetector/attachHandlers.ts +112 -0
  283. package/src/handlers/gestures/GestureDetector/dropHandlers.ts +14 -0
  284. package/src/handlers/gestures/GestureDetector/index.tsx +187 -0
  285. package/src/handlers/gestures/GestureDetector/needsToReattach.ts +27 -0
  286. package/src/handlers/gestures/GestureDetector/types.ts +32 -0
  287. package/src/handlers/gestures/GestureDetector/updateHandlers.ts +94 -0
  288. package/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts +206 -0
  289. package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +69 -0
  290. package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +54 -0
  291. package/src/handlers/gestures/GestureDetector/utils.ts +185 -0
  292. package/src/handlers/gestures/gestureComposition.ts +2 -0
  293. package/src/handlers/gestures/gestureStateManager.ts +12 -4
  294. package/src/handlers/gestures/reanimatedWrapper.ts +19 -17
  295. package/src/utils.ts +39 -0
  296. package/src/web/detectors/RotationGestureDetector.ts +6 -8
  297. package/src/web/detectors/ScaleGestureDetector.ts +5 -6
  298. package/src/web/handlers/FlingGestureHandler.ts +2 -0
  299. package/src/web/handlers/GestureHandler.ts +53 -62
  300. package/src/web/handlers/LongPressGestureHandler.ts +2 -0
  301. package/src/web/handlers/ManualGestureHandler.ts +2 -0
  302. package/src/web/handlers/NativeViewGestureHandler.ts +8 -4
  303. package/src/web/handlers/PanGestureHandler.ts +32 -19
  304. package/src/web/handlers/PinchGestureHandler.ts +2 -0
  305. package/src/web/handlers/RotationGestureHandler.ts +2 -0
  306. package/src/web/handlers/TapGestureHandler.ts +20 -12
  307. package/src/web/interfaces.ts +1 -0
  308. package/src/web/tools/GestureHandlerOrchestrator.ts +1 -7
  309. package/src/web/tools/PointerEventManager.ts +10 -3
  310. package/src/web/tools/PointerTracker.ts +81 -74
  311. package/src/web/tools/TouchEventManager.ts +5 -3
  312. package/src/web/tools/Vector.ts +2 -4
  313. package/src/web/utils.ts +34 -0
  314. package/lib/commonjs/RNGestureHandlerModule.native.js +0 -16
  315. package/lib/commonjs/RNGestureHandlerModule.native.js.map +0 -1
  316. package/lib/commonjs/RNRenderer.native.js +0 -16
  317. package/lib/commonjs/RNRenderer.native.js.map +0 -1
  318. package/lib/commonjs/components/GestureComponents.native.js +0 -115
  319. package/lib/commonjs/components/GestureComponents.native.js.map +0 -1
  320. package/lib/commonjs/components/GestureHandlerButton.native.js +0 -14
  321. package/lib/commonjs/components/GestureHandlerButton.native.js.map +0 -1
  322. package/lib/commonjs/components/GestureHandlerRootView.native.js.map +0 -1
  323. package/lib/commonjs/getReactNativeVersion.native.js +0 -22
  324. package/lib/commonjs/getReactNativeVersion.native.js.map +0 -1
  325. package/lib/commonjs/getShadowNodeFromRef.native.js +0 -44
  326. package/lib/commonjs/getShadowNodeFromRef.native.js.map +0 -1
  327. package/lib/commonjs/handlers/PressabilityDebugView.native.js +0 -14
  328. package/lib/commonjs/handlers/PressabilityDebugView.native.js.map +0 -1
  329. package/lib/commonjs/handlers/customDirectEventTypes.native.js +0 -14
  330. package/lib/commonjs/handlers/customDirectEventTypes.native.js.map +0 -1
  331. package/lib/commonjs/handlers/gestures/GestureDetector.js +0 -704
  332. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +0 -1
  333. package/lib/module/RNGestureHandlerModule.native.js +0 -5
  334. package/lib/module/RNGestureHandlerModule.native.js.map +0 -1
  335. package/lib/module/RNRenderer.native.js +0 -4
  336. package/lib/module/RNRenderer.native.js.map +0 -1
  337. package/lib/module/components/GestureComponents.native.js +0 -90
  338. package/lib/module/components/GestureComponents.native.js.map +0 -1
  339. package/lib/module/components/GestureHandlerButton.native.js +0 -3
  340. package/lib/module/components/GestureHandlerButton.native.js.map +0 -1
  341. package/lib/module/components/GestureHandlerRootView.native.js.map +0 -1
  342. package/lib/module/getReactNativeVersion.native.js +0 -10
  343. package/lib/module/getReactNativeVersion.native.js.map +0 -1
  344. package/lib/module/getShadowNodeFromRef.native.js +0 -37
  345. package/lib/module/getShadowNodeFromRef.native.js.map +0 -1
  346. package/lib/module/handlers/PressabilityDebugView.native.js +0 -3
  347. package/lib/module/handlers/PressabilityDebugView.native.js.map +0 -1
  348. package/lib/module/handlers/customDirectEventTypes.native.js +0 -3
  349. package/lib/module/handlers/customDirectEventTypes.native.js.map +0 -1
  350. package/lib/module/handlers/gestures/GestureDetector.js +0 -654
  351. package/lib/module/handlers/gestures/GestureDetector.js.map +0 -1
  352. package/lib/typescript/RNGestureHandlerModule.native.d.ts +0 -2
  353. package/lib/typescript/RNRenderer.native.d.ts +0 -1
  354. package/lib/typescript/components/GestureComponents.native.d.ts +0 -22
  355. package/lib/typescript/components/GestureHandlerButton.native.d.ts +0 -4
  356. package/lib/typescript/getReactNativeVersion.native.d.ts +0 -4
  357. package/lib/typescript/getShadowNodeFromRef.native.d.ts +0 -1
  358. package/lib/typescript/handlers/PressabilityDebugView.native.d.ts +0 -1
  359. package/lib/typescript/handlers/customDirectEventTypes.native.d.ts +0 -1
  360. package/src/RNGestureHandlerModule.native.ts +0 -5
  361. package/src/RNRenderer.native.ts +0 -3
  362. package/src/components/GestureComponents.native.tsx +0 -148
  363. package/src/components/GestureHandlerButton.native.tsx +0 -5
  364. package/src/getReactNativeVersion.native.ts +0 -11
  365. package/src/getShadowNodeFromRef.native.ts +0 -44
  366. package/src/handlers/PressabilityDebugView.native.tsx +0 -2
  367. package/src/handlers/customDirectEventTypes.native.ts +0 -2
  368. package/src/handlers/gestures/GestureDetector.tsx +0 -894
  369. /package/lib/typescript/components/{GestureHandlerRootView.native.d.ts → GestureHandlerRootView.web.d.ts} +0 -0
@@ -1,105 +1,5 @@
1
- import React from 'react';
1
+ // Reexport the native module spec used by codegen. The relevant files are inluded on Android
2
+ // to ensure the compatibility with the old arch, while iOS doesn't require those at all.
2
3
 
3
- import type { ActionType } from './ActionType';
4
- import { isNewWebImplementationEnabled } from './EnableNewWebImplementation';
5
- import { Gestures, HammerGestures } from './web/Gestures';
6
- import type { Config } from './web/interfaces';
7
- import InteractionManager from './web/tools/InteractionManager';
8
- import NodeManager from './web/tools/NodeManager';
9
- import * as HammerNodeManager from './web_hammer/NodeManager';
10
- import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
11
-
12
- export default {
13
- handleSetJSResponder(tag: number, blockNativeResponder: boolean) {
14
- console.warn('handleSetJSResponder: ', tag, blockNativeResponder);
15
- },
16
- handleClearJSResponder() {
17
- console.warn('handleClearJSResponder: ');
18
- },
19
- createGestureHandler<T>(
20
- handlerName: keyof typeof Gestures,
21
- handlerTag: number,
22
- config: T
23
- ) {
24
- if (isNewWebImplementationEnabled()) {
25
- if (!(handlerName in Gestures)) {
26
- throw new Error(
27
- `react-native-gesture-handler: ${handlerName} is not supported on web.`
28
- );
29
- }
30
-
31
- const GestureClass = Gestures[handlerName];
32
- NodeManager.createGestureHandler(
33
- handlerTag,
34
- new GestureClass(new GestureHandlerWebDelegate())
35
- );
36
- InteractionManager.getInstance().configureInteractions(
37
- NodeManager.getHandler(handlerTag),
38
- config as unknown as Config
39
- );
40
- } else {
41
- if (!(handlerName in HammerGestures)) {
42
- throw new Error(
43
- `react-native-gesture-handler: ${handlerName} is not supported on web.`
44
- );
45
- }
46
-
47
- // @ts-ignore If it doesn't exist, the error is thrown
48
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
49
- const GestureClass = HammerGestures[handlerName];
50
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
51
- HammerNodeManager.createGestureHandler(handlerTag, new GestureClass());
52
- }
53
-
54
- this.updateGestureHandler(handlerTag, config as unknown as Config);
55
- },
56
- attachGestureHandler(
57
- handlerTag: number,
58
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
- newView: any,
60
- _actionType: ActionType,
61
- propsRef: React.RefObject<unknown>
62
- ) {
63
- if (
64
- !(newView instanceof HTMLElement || newView instanceof React.Component)
65
- ) {
66
- return;
67
- }
68
-
69
- if (isNewWebImplementationEnabled()) {
70
- //@ts-ignore Types should be HTMLElement or React.Component
71
- NodeManager.getHandler(handlerTag).init(newView, propsRef);
72
- } else {
73
- //@ts-ignore Types should be HTMLElement or React.Component
74
- HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef);
75
- }
76
- },
77
- updateGestureHandler(handlerTag: number, newConfig: Config) {
78
- if (isNewWebImplementationEnabled()) {
79
- NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
80
-
81
- InteractionManager.getInstance().configureInteractions(
82
- NodeManager.getHandler(handlerTag),
83
- newConfig
84
- );
85
- } else {
86
- HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
87
- }
88
- },
89
- getGestureHandlerNode(handlerTag: number) {
90
- if (isNewWebImplementationEnabled()) {
91
- return NodeManager.getHandler(handlerTag);
92
- } else {
93
- return HammerNodeManager.getHandler(handlerTag);
94
- }
95
- },
96
- dropGestureHandler(handlerTag: number) {
97
- if (isNewWebImplementationEnabled()) {
98
- NodeManager.dropGestureHandler(handlerTag);
99
- } else {
100
- HammerNodeManager.dropGestureHandler(handlerTag);
101
- }
102
- },
103
- // eslint-disable-next-line @typescript-eslint/no-empty-function
104
- flushOperations() {},
105
- };
4
+ import Module from './specs/NativeRNGestureHandlerModule';
5
+ export default Module;
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+
3
+ import type { ActionType } from './ActionType';
4
+ import { isNewWebImplementationEnabled } from './EnableNewWebImplementation';
5
+ import { Gestures, HammerGestures } from './web/Gestures';
6
+ import type { Config } from './web/interfaces';
7
+ import InteractionManager from './web/tools/InteractionManager';
8
+ import NodeManager from './web/tools/NodeManager';
9
+ import * as HammerNodeManager from './web_hammer/NodeManager';
10
+ import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
11
+
12
+ export default {
13
+ handleSetJSResponder(tag: number, blockNativeResponder: boolean) {
14
+ console.warn('handleSetJSResponder: ', tag, blockNativeResponder);
15
+ },
16
+ handleClearJSResponder() {
17
+ console.warn('handleClearJSResponder: ');
18
+ },
19
+ createGestureHandler<T>(
20
+ handlerName: keyof typeof Gestures,
21
+ handlerTag: number,
22
+ config: T
23
+ ) {
24
+ if (isNewWebImplementationEnabled()) {
25
+ if (!(handlerName in Gestures)) {
26
+ throw new Error(
27
+ `react-native-gesture-handler: ${handlerName} is not supported on web.`
28
+ );
29
+ }
30
+
31
+ const GestureClass = Gestures[handlerName];
32
+ NodeManager.createGestureHandler(
33
+ handlerTag,
34
+ new GestureClass(new GestureHandlerWebDelegate())
35
+ );
36
+ InteractionManager.getInstance().configureInteractions(
37
+ NodeManager.getHandler(handlerTag),
38
+ config as unknown as Config
39
+ );
40
+ } else {
41
+ if (!(handlerName in HammerGestures)) {
42
+ throw new Error(
43
+ `react-native-gesture-handler: ${handlerName} is not supported on web.`
44
+ );
45
+ }
46
+
47
+ // @ts-ignore If it doesn't exist, the error is thrown
48
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
49
+ const GestureClass = HammerGestures[handlerName];
50
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
51
+ HammerNodeManager.createGestureHandler(handlerTag, new GestureClass());
52
+ }
53
+
54
+ this.updateGestureHandler(handlerTag, config as unknown as Config);
55
+ },
56
+ attachGestureHandler(
57
+ handlerTag: number,
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ newView: any,
60
+ _actionType: ActionType,
61
+ propsRef: React.RefObject<unknown>
62
+ ) {
63
+ if (
64
+ !(newView instanceof HTMLElement || newView instanceof React.Component)
65
+ ) {
66
+ return;
67
+ }
68
+
69
+ if (isNewWebImplementationEnabled()) {
70
+ //@ts-ignore Types should be HTMLElement or React.Component
71
+ NodeManager.getHandler(handlerTag).init(newView, propsRef);
72
+ } else {
73
+ //@ts-ignore Types should be HTMLElement or React.Component
74
+ HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef);
75
+ }
76
+ },
77
+ updateGestureHandler(handlerTag: number, newConfig: Config) {
78
+ if (isNewWebImplementationEnabled()) {
79
+ NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
80
+
81
+ InteractionManager.getInstance().configureInteractions(
82
+ NodeManager.getHandler(handlerTag),
83
+ newConfig
84
+ );
85
+ } else {
86
+ HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
87
+ }
88
+ },
89
+ getGestureHandlerNode(handlerTag: number) {
90
+ if (isNewWebImplementationEnabled()) {
91
+ return NodeManager.getHandler(handlerTag);
92
+ } else {
93
+ return HammerNodeManager.getHandler(handlerTag);
94
+ }
95
+ },
96
+ dropGestureHandler(handlerTag: number) {
97
+ if (isNewWebImplementationEnabled()) {
98
+ NodeManager.dropGestureHandler(handlerTag);
99
+ } else {
100
+ HammerNodeManager.dropGestureHandler(handlerTag);
101
+ }
102
+ },
103
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
104
+ flushOperations() {},
105
+ };
package/src/RNRenderer.ts CHANGED
@@ -1,3 +1,3 @@
1
- export const RNRenderer = {
2
- findHostInstance_DEPRECATED: (_ref: any) => null,
3
- };
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
3
+ export { default as RNRenderer } from 'react-native/Libraries/Renderer/shims/ReactNative';
@@ -0,0 +1,3 @@
1
+ export const RNRenderer = {
2
+ findHostInstance_DEPRECATED: (_ref: any) => null,
3
+ };
@@ -65,6 +65,10 @@ export interface RawButtonProps extends NativeViewGestureHandlerProps {
65
65
  touchSoundDisabled?: boolean;
66
66
  }
67
67
 
68
+ interface ButtonWithRefProps {
69
+ innerRef?: React.ForwardedRef<React.ComponentType<any>>;
70
+ }
71
+
68
72
  export interface BaseButtonProps extends RawButtonProps {
69
73
  /**
70
74
  * Called when the button gets pressed (analogous to `onPress` in
@@ -94,6 +98,8 @@ export interface BaseButtonProps extends RawButtonProps {
94
98
  delayLongPress?: number;
95
99
  }
96
100
 
101
+ interface BaseButtonWithRefProps extends BaseButtonProps, ButtonWithRefProps {}
102
+
97
103
  export interface RectButtonProps extends BaseButtonProps {
98
104
  /**
99
105
  * Background color that will be dimmed when button is in active state.
@@ -108,6 +114,8 @@ export interface RectButtonProps extends BaseButtonProps {
108
114
  activeOpacity?: number;
109
115
  }
110
116
 
117
+ interface RectButtonWithRefProps extends RectButtonProps, ButtonWithRefProps {}
118
+
111
119
  export interface BorderlessButtonProps extends BaseButtonProps {
112
120
  /**
113
121
  * iOS only.
@@ -117,12 +125,16 @@ export interface BorderlessButtonProps extends BaseButtonProps {
117
125
  activeOpacity?: number;
118
126
  }
119
127
 
128
+ interface BorderlessButtonWithRefProps
129
+ extends BorderlessButtonProps,
130
+ ButtonWithRefProps {}
131
+
120
132
  export const RawButton = createNativeWrapper(GestureHandlerButton, {
121
133
  shouldCancelWhenOutside: false,
122
134
  shouldActivateOnStart: false,
123
135
  });
124
136
 
125
- export class BaseButton extends React.Component<BaseButtonProps> {
137
+ class InnerBaseButton extends React.Component<BaseButtonWithRefProps> {
126
138
  static defaultProps = {
127
139
  delayLongPress: 600,
128
140
  };
@@ -222,6 +234,7 @@ export class BaseButton extends React.Component<BaseButtonProps> {
222
234
 
223
235
  return (
224
236
  <RawButton
237
+ ref={this.props.innerRef}
225
238
  rippleColor={processColor(rippleColor)}
226
239
  {...rest}
227
240
  onGestureEvent={this.onGestureEvent}
@@ -231,6 +244,11 @@ export class BaseButton extends React.Component<BaseButtonProps> {
231
244
  }
232
245
  }
233
246
 
247
+ export const BaseButton = React.forwardRef<
248
+ any,
249
+ Omit<BaseButtonProps, 'innerRef'>
250
+ >((props, ref) => <InnerBaseButton innerRef={ref} {...props} />);
251
+
234
252
  const AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);
235
253
 
236
254
  const btnStyles = StyleSheet.create({
@@ -243,7 +261,7 @@ const btnStyles = StyleSheet.create({
243
261
  },
244
262
  });
245
263
 
246
- export class RectButton extends React.Component<RectButtonProps> {
264
+ class InnerRectButton extends React.Component<RectButtonWithRefProps> {
247
265
  static defaultProps = {
248
266
  activeOpacity: 0.105,
249
267
  underlayColor: 'black',
@@ -272,6 +290,7 @@ export class RectButton extends React.Component<RectButtonProps> {
272
290
  return (
273
291
  <BaseButton
274
292
  {...rest}
293
+ ref={this.props.innerRef}
275
294
  style={resolvedStyle}
276
295
  onActiveStateChange={this.onActiveStateChange}>
277
296
  <Animated.View
@@ -294,7 +313,12 @@ export class RectButton extends React.Component<RectButtonProps> {
294
313
  }
295
314
  }
296
315
 
297
- export class BorderlessButton extends React.Component<BorderlessButtonProps> {
316
+ export const RectButton = React.forwardRef<
317
+ any,
318
+ Omit<RectButtonProps, 'innerRef'>
319
+ >((props, ref) => <InnerRectButton innerRef={ref} {...props} />);
320
+
321
+ class InnerBorderlessButton extends React.Component<BorderlessButtonWithRefProps> {
298
322
  static defaultProps = {
299
323
  activeOpacity: 0.3,
300
324
  borderless: true,
@@ -316,11 +340,14 @@ export class BorderlessButton extends React.Component<BorderlessButtonProps> {
316
340
  };
317
341
 
318
342
  render() {
319
- const { children, style, ...rest } = this.props;
343
+ const { children, style, innerRef, ...rest } = this.props;
320
344
 
321
345
  return (
322
346
  <AnimatedBaseButton
323
347
  {...rest}
348
+ // @ts-ignore We don't want `innerRef` to be accessible from public API.
349
+ // However in this case we need to set it indirectly on `BaseButton`, hence we use ts-ignore
350
+ innerRef={innerRef}
324
351
  onActiveStateChange={this.onActiveStateChange}
325
352
  style={[style, Platform.OS === 'ios' && { opacity: this.opacity }]}>
326
353
  {children}
@@ -329,4 +356,9 @@ export class BorderlessButton extends React.Component<BorderlessButtonProps> {
329
356
  }
330
357
  }
331
358
 
359
+ export const BorderlessButton = React.forwardRef<
360
+ any,
361
+ Omit<BorderlessButtonProps, 'innerRef'>
362
+ >((props, ref) => <InnerBorderlessButton innerRef={ref} {...props} />);
363
+
332
364
  export { default as PureNativeButton } from './GestureHandlerButton';
@@ -1,41 +1,148 @@
1
1
  import * as React from 'react';
2
2
  import {
3
- FlatList as RNFlatList,
3
+ PropsWithChildren,
4
+ ForwardedRef,
5
+ RefAttributes,
6
+ ReactElement,
7
+ } from 'react';
8
+ import {
9
+ ScrollView as RNScrollView,
10
+ ScrollViewProps as RNScrollViewProps,
4
11
  Switch as RNSwitch,
12
+ SwitchProps as RNSwitchProps,
5
13
  TextInput as RNTextInput,
6
- ScrollView as RNScrollView,
7
- FlatListProps,
8
- View,
14
+ TextInputProps as RNTextInputProps,
15
+ DrawerLayoutAndroid as RNDrawerLayoutAndroid,
16
+ DrawerLayoutAndroidProps as RNDrawerLayoutAndroidProps,
17
+ FlatList as RNFlatList,
18
+ FlatListProps as RNFlatListProps,
19
+ RefreshControl as RNRefreshControl,
9
20
  } from 'react-native';
10
21
 
11
22
  import createNativeWrapper from '../handlers/createNativeWrapper';
12
23
 
13
- export const ScrollView = createNativeWrapper(RNScrollView, {
14
- disallowInterruption: false,
24
+ import {
25
+ NativeViewGestureHandlerProps,
26
+ nativeViewProps,
27
+ } from '../handlers/NativeViewGestureHandler';
28
+
29
+ import { toArray } from '../utils';
30
+
31
+ export const RefreshControl = createNativeWrapper(RNRefreshControl, {
32
+ disallowInterruption: true,
33
+ shouldCancelWhenOutside: false,
15
34
  });
35
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
36
+ export type RefreshControl = typeof RefreshControl & RNRefreshControl;
37
+
38
+ const GHScrollView = createNativeWrapper<PropsWithChildren<RNScrollViewProps>>(
39
+ RNScrollView,
40
+ {
41
+ disallowInterruption: true,
42
+ shouldCancelWhenOutside: false,
43
+ }
44
+ );
45
+ export const ScrollView = React.forwardRef<
46
+ RNScrollView,
47
+ RNScrollViewProps & NativeViewGestureHandlerProps
48
+ >((props, ref) => {
49
+ const refreshControlGestureRef = React.useRef<RefreshControl>(null);
50
+ const { refreshControl, waitFor, ...rest } = props;
16
51
 
17
- export const Switch = createNativeWrapper(RNSwitch, {
52
+ return (
53
+ <GHScrollView
54
+ {...rest}
55
+ // @ts-ignore `ref` exists on `GHScrollView`
56
+ ref={ref}
57
+ waitFor={[...toArray(waitFor ?? []), refreshControlGestureRef]}
58
+ // @ts-ignore we don't pass `refreshing` prop as we only want to override the ref
59
+ refreshControl={
60
+ refreshControl
61
+ ? React.cloneElement(refreshControl, {
62
+ // @ts-ignore for reasons unknown to me, `ref` doesn't exist on the type inferred by TS
63
+ ref: refreshControlGestureRef,
64
+ })
65
+ : undefined
66
+ }
67
+ />
68
+ );
69
+ });
70
+ // backward type compatibility with https://github.com/software-mansion/react-native-gesture-handler/blob/db78d3ca7d48e8ba57482d3fe9b0a15aa79d9932/react-native-gesture-handler.d.ts#L440-L457
71
+ // include methods of wrapped components by creating an intersection type with the RN component instead of duplicating them.
72
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
73
+ export type ScrollView = typeof GHScrollView & RNScrollView;
74
+
75
+ export const Switch = createNativeWrapper<RNSwitchProps>(RNSwitch, {
18
76
  shouldCancelWhenOutside: false,
19
77
  shouldActivateOnStart: true,
20
78
  disallowInterruption: true,
21
79
  });
22
- export const TextInput = createNativeWrapper(RNTextInput);
23
- export const DrawerLayoutAndroid = () => {
24
- console.warn('DrawerLayoutAndroid is not supported on web!');
25
- return <View />;
26
- };
27
-
28
- // RefreshControl is implemented as a functional component, rendering a View
29
- // NativeViewGestureHandler needs to set a ref on its child, which cannot be done
30
- // on functional components
31
- export const RefreshControl = createNativeWrapper(View);
32
-
33
- export const FlatList = React.forwardRef(
34
- <ItemT extends any>(props: FlatListProps<ItemT>, ref: any) => (
80
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
81
+ export type Switch = typeof Switch & RNSwitch;
82
+
83
+ export const TextInput = createNativeWrapper<RNTextInputProps>(RNTextInput);
84
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
85
+ export type TextInput = typeof TextInput & RNTextInput;
86
+
87
+ export const DrawerLayoutAndroid = createNativeWrapper<
88
+ PropsWithChildren<RNDrawerLayoutAndroidProps>
89
+ >(RNDrawerLayoutAndroid, { disallowInterruption: true });
90
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
91
+ export type DrawerLayoutAndroid = typeof DrawerLayoutAndroid &
92
+ RNDrawerLayoutAndroid;
93
+
94
+ export const FlatList = React.forwardRef((props, ref) => {
95
+ const refreshControlGestureRef = React.useRef<RefreshControl>(null);
96
+
97
+ const { waitFor, refreshControl, ...rest } = props;
98
+
99
+ const flatListProps = {};
100
+ const scrollViewProps = {};
101
+ for (const [propName, value] of Object.entries(rest)) {
102
+ // https://github.com/microsoft/TypeScript/issues/26255
103
+ if ((nativeViewProps as readonly string[]).includes(propName)) {
104
+ // @ts-ignore - this function cannot have generic type so we have to ignore this error
105
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
106
+ scrollViewProps[propName] = value;
107
+ } else {
108
+ // @ts-ignore - this function cannot have generic type so we have to ignore this error
109
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
110
+ flatListProps[propName] = value;
111
+ }
112
+ }
113
+
114
+ return (
115
+ // @ts-ignore - this function cannot have generic type so we have to ignore this error
35
116
  <RNFlatList
36
117
  ref={ref}
37
- {...props}
38
- renderScrollComponent={(scrollProps) => <ScrollView {...scrollProps} />}
118
+ {...flatListProps}
119
+ renderScrollComponent={(scrollProps) => (
120
+ <ScrollView
121
+ {...{
122
+ ...scrollProps,
123
+ ...scrollViewProps,
124
+ waitFor: [...toArray(waitFor ?? []), refreshControlGestureRef],
125
+ }}
126
+ />
127
+ )}
128
+ // @ts-ignore we don't pass `refreshing` prop as we only want to override the ref
129
+ refreshControl={
130
+ refreshControl
131
+ ? React.cloneElement(refreshControl, {
132
+ // @ts-ignore for reasons unknown to me, `ref` doesn't exist on the type inferred by TS
133
+ ref: refreshControlGestureRef,
134
+ })
135
+ : undefined
136
+ }
39
137
  />
40
- )
41
- );
138
+ );
139
+ }) as <ItemT = any>(
140
+ props: PropsWithChildren<
141
+ RNFlatListProps<ItemT> &
142
+ RefAttributes<FlatList<ItemT>> &
143
+ NativeViewGestureHandlerProps
144
+ >,
145
+ ref: ForwardedRef<FlatList<ItemT>>
146
+ ) => ReactElement | null;
147
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
148
+ export type FlatList<ItemT = any> = typeof FlatList & RNFlatList<ItemT>;
@@ -0,0 +1,41 @@
1
+ import * as React from 'react';
2
+ import {
3
+ FlatList as RNFlatList,
4
+ Switch as RNSwitch,
5
+ TextInput as RNTextInput,
6
+ ScrollView as RNScrollView,
7
+ FlatListProps,
8
+ View,
9
+ } from 'react-native';
10
+
11
+ import createNativeWrapper from '../handlers/createNativeWrapper';
12
+
13
+ export const ScrollView = createNativeWrapper(RNScrollView, {
14
+ disallowInterruption: false,
15
+ });
16
+
17
+ export const Switch = createNativeWrapper(RNSwitch, {
18
+ shouldCancelWhenOutside: false,
19
+ shouldActivateOnStart: true,
20
+ disallowInterruption: true,
21
+ });
22
+ export const TextInput = createNativeWrapper(RNTextInput);
23
+ export const DrawerLayoutAndroid = () => {
24
+ console.warn('DrawerLayoutAndroid is not supported on web!');
25
+ return <View />;
26
+ };
27
+
28
+ // RefreshControl is implemented as a functional component, rendering a View
29
+ // NativeViewGestureHandler needs to set a ref on its child, which cannot be done
30
+ // on functional components
31
+ export const RefreshControl = createNativeWrapper(View);
32
+
33
+ export const FlatList = React.forwardRef(
34
+ <ItemT extends any>(props: FlatListProps<ItemT>, ref: any) => (
35
+ <RNFlatList
36
+ ref={ref}
37
+ {...props}
38
+ renderScrollComponent={(scrollProps) => <ScrollView {...scrollProps} />}
39
+ />
40
+ )
41
+ );
@@ -1,6 +1,5 @@
1
- import * as React from 'react';
2
- import { View } from 'react-native';
1
+ import { HostComponent } from 'react-native';
2
+ import { RawButtonProps } from './GestureButtons';
3
+ import RNGestureHandlerButtonNativeComponent from '../specs/RNGestureHandlerButtonNativeComponent';
3
4
 
4
- export default React.forwardRef<View>((props, ref) => (
5
- <View ref={ref} accessibilityRole="button" {...props} />
6
- ));
5
+ export default RNGestureHandlerButtonNativeComponent as HostComponent<RawButtonProps>;
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ import { View } from 'react-native';
3
+
4
+ export default React.forwardRef<View>((props, ref) => (
5
+ <View ref={ref} accessibilityRole="button" {...props} />
6
+ ));
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
3
  import { View, ViewProps, StyleSheet } from 'react-native';
4
+ import { maybeInitializeFabric } from '../init';
4
5
  import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
5
6
 
6
7
  export interface GestureHandlerRootViewProps
@@ -10,6 +11,11 @@ export default function GestureHandlerRootView({
10
11
  style,
11
12
  ...rest
12
13
  }: GestureHandlerRootViewProps) {
14
+ // try initialize fabric on the first render, at this point we can
15
+ // reliably check if fabric is enabled (the function contains a flag
16
+ // to make sure it's called only once)
17
+ maybeInitializeFabric();
18
+
13
19
  return (
14
20
  <GestureHandlerRootViewContext.Provider value>
15
21
  <View style={style ?? styles.container} {...rest} />
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
3
  import { View, ViewProps, StyleSheet } from 'react-native';
4
- import { maybeInitializeFabric } from '../init';
5
4
  import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
6
5
 
7
6
  export interface GestureHandlerRootViewProps
@@ -11,11 +10,6 @@ export default function GestureHandlerRootView({
11
10
  style,
12
11
  ...rest
13
12
  }: GestureHandlerRootViewProps) {
14
- // try initialize fabric on the first render, at this point we can
15
- // reliably check if fabric is enabled (the function contains a flag
16
- // to make sure it's called only once)
17
- maybeInitializeFabric();
18
-
19
13
  return (
20
14
  <GestureHandlerRootViewContext.Provider value>
21
15
  <View style={style ?? styles.container} {...rest} />
@@ -1,3 +1,11 @@
1
+ import pack from 'react-native/package.json';
2
+
3
+ const [majorStr, minorStr] = pack.version.split('.');
4
+ const REACT_NATIVE_VERSION = {
5
+ major: parseInt(majorStr, 10),
6
+ minor: parseInt(minorStr, 10),
7
+ };
8
+
1
9
  export function getReactNativeVersion() {
2
- throw new Error('getReactNativeVersion is not supported on web');
10
+ return REACT_NATIVE_VERSION;
3
11
  }
@@ -0,0 +1,3 @@
1
+ export function getReactNativeVersion() {
2
+ throw new Error('getReactNativeVersion is not supported on web');
3
+ }