react-native-gesture-handler 1.10.3 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (382) hide show
  1. package/README.md +7 -6
  2. package/android/build.gradle +49 -1
  3. package/android/common/src/main/java/com/swmansion/common/GestureHandlerStateManager.kt +5 -0
  4. package/android/gradle.properties +19 -0
  5. package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.kt +18 -0
  6. package/android/lib/src/main/java/com/swmansion/gesturehandler/Extensions.kt +11 -0
  7. package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.kt +96 -0
  8. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +713 -0
  9. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.kt +8 -0
  10. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +562 -0
  11. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.kt +8 -0
  12. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.kt +21 -0
  13. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.kt +49 -0
  14. package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.kt +97 -0
  15. package/android/lib/src/main/java/com/swmansion/gesturehandler/ManualGestureHandler.kt +11 -0
  16. package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.kt +129 -0
  17. package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.kt +9 -0
  18. package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +289 -0
  19. package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +88 -0
  20. package/android/lib/src/main/java/com/swmansion/gesturehandler/{PointerEventsConfig.java → PointerEventsConfig.kt} +3 -5
  21. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.kt +125 -0
  22. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +79 -0
  23. package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.kt +167 -0
  24. package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.kt +10 -0
  25. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +348 -0
  26. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +57 -0
  27. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +59 -0
  28. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.kt +8 -0
  29. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +61 -0
  30. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +686 -0
  31. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.kt +17 -0
  32. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +95 -0
  33. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +132 -0
  34. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.kt +5 -0
  35. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +68 -0
  36. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +34 -0
  37. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +66 -0
  38. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +69 -0
  39. package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +51 -0
  40. package/ios/Handlers/RNFlingHandler.m +78 -5
  41. package/ios/Handlers/RNForceTouchHandler.m +29 -4
  42. package/ios/Handlers/RNLongPressHandler.m +105 -3
  43. package/ios/Handlers/RNManualHandler.h +4 -0
  44. package/ios/Handlers/RNManualHandler.m +73 -0
  45. package/ios/Handlers/RNNativeViewHandler.m +30 -2
  46. package/ios/Handlers/RNPanHandler.m +64 -4
  47. package/ios/Handlers/RNPinchHandler.m +61 -2
  48. package/ios/Handlers/RNRotationHandler.m +60 -1
  49. package/ios/Handlers/RNTapHandler.m +55 -8
  50. package/ios/RNGestureHandler.h +18 -4
  51. package/ios/RNGestureHandler.m +123 -13
  52. package/ios/RNGestureHandlerEvents.h +9 -0
  53. package/ios/RNGestureHandlerEvents.m +34 -0
  54. package/ios/RNGestureHandlerManager.h +7 -0
  55. package/ios/RNGestureHandlerManager.m +62 -34
  56. package/ios/RNGestureHandlerModule.m +39 -3
  57. package/ios/RNGestureHandlerPointerTracker.h +25 -0
  58. package/ios/RNGestureHandlerPointerTracker.m +237 -0
  59. package/ios/RNGestureHandlerRegistry.h +1 -0
  60. package/ios/RNGestureHandlerRegistry.m +10 -0
  61. package/ios/RNGestureHandlerStateManager.h +5 -0
  62. package/ios/RNManualActivationRecognizer.h +10 -0
  63. package/ios/RNManualActivationRecognizer.m +80 -0
  64. package/ios/RNRootViewGestureRecognizer.m +1 -1
  65. package/ios/RNTouchEventType.h +9 -0
  66. package/lib/commonjs/EventType.js +16 -0
  67. package/lib/commonjs/EventType.js.map +1 -0
  68. package/lib/commonjs/GestureHandlerRootView.android.js +1 -13
  69. package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
  70. package/lib/commonjs/GestureHandlerRootView.js +11 -3
  71. package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
  72. package/lib/commonjs/RNGestureHandlerModule.js +3 -1
  73. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  74. package/lib/commonjs/RNGestureHandlerModule.web.js +2 -2
  75. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  76. package/lib/commonjs/components/DrawerLayout.js +41 -37
  77. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  78. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  79. package/lib/commonjs/components/GestureComponents.js +31 -12
  80. package/lib/commonjs/components/GestureComponents.js.map +1 -1
  81. package/lib/commonjs/components/Swipeable.js +10 -6
  82. package/lib/commonjs/components/Swipeable.js.map +1 -1
  83. package/lib/commonjs/components/touchables/GenericTouchable.js +2 -1
  84. package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
  85. package/lib/commonjs/components/touchables/TouchableOpacity.js +1 -1
  86. package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
  87. package/lib/commonjs/gestureHandlerRootHOC.js +1 -1
  88. package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -1
  89. package/lib/commonjs/handlers/FlingGestureHandler.js +23 -0
  90. package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -0
  91. package/lib/commonjs/handlers/ForceTouchGestureHandler.js +44 -0
  92. package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -0
  93. package/lib/commonjs/handlers/LongPressGestureHandler.js +23 -0
  94. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -0
  95. package/lib/commonjs/handlers/NativeViewGestureHandler.js +6 -4
  96. package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
  97. package/lib/commonjs/handlers/PanGestureHandler.js +121 -0
  98. package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -0
  99. package/lib/commonjs/handlers/PinchGestureHandler.js +21 -0
  100. package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -0
  101. package/lib/commonjs/handlers/RotationGestureHandler.js +21 -0
  102. package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -0
  103. package/lib/commonjs/handlers/TapGestureHandler.js +23 -0
  104. package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -0
  105. package/lib/commonjs/handlers/createHandler.js +52 -83
  106. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  107. package/lib/commonjs/handlers/gestureHandlerCommon.js +80 -0
  108. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -0
  109. package/lib/commonjs/handlers/gestures/GestureDetector.js +440 -0
  110. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -0
  111. package/lib/commonjs/handlers/gestures/eventReceiver.js +135 -0
  112. package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -0
  113. package/lib/commonjs/handlers/gestures/flingGesture.js +34 -0
  114. package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -0
  115. package/lib/commonjs/handlers/gestures/forceTouchGesture.js +65 -0
  116. package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -0
  117. package/lib/commonjs/handlers/gestures/gesture.js +193 -0
  118. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -0
  119. package/lib/commonjs/handlers/gestures/gestureComposition.js +94 -0
  120. package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -0
  121. package/lib/commonjs/handlers/gestures/gestureObjects.js +85 -0
  122. package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -0
  123. package/lib/commonjs/handlers/gestures/gestureStateManager.js +58 -0
  124. package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -0
  125. package/lib/commonjs/handlers/gestures/longPressGesture.js +34 -0
  126. package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -0
  127. package/lib/commonjs/handlers/gestures/manualGesture.js +31 -0
  128. package/lib/commonjs/handlers/gestures/manualGesture.js.map +1 -0
  129. package/lib/commonjs/handlers/gestures/nativeGesture.js +34 -0
  130. package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -0
  131. package/lib/commonjs/handlers/gestures/panGesture.js +144 -0
  132. package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -0
  133. package/lib/commonjs/handlers/gestures/pinchGesture.js +45 -0
  134. package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -0
  135. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +24 -0
  136. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -0
  137. package/lib/commonjs/handlers/gestures/rotationGesture.js +45 -0
  138. package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -0
  139. package/lib/commonjs/handlers/gestures/tapGesture.js +59 -0
  140. package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -0
  141. package/lib/commonjs/handlers/handlersRegistry.js +31 -0
  142. package/lib/commonjs/handlers/handlersRegistry.js.map +1 -0
  143. package/lib/commonjs/index.js +146 -8
  144. package/lib/commonjs/index.js.map +1 -1
  145. package/lib/commonjs/init.js +13 -0
  146. package/lib/commonjs/init.js.map +1 -0
  147. package/lib/commonjs/mocks.js +31 -2
  148. package/lib/commonjs/mocks.js.map +1 -1
  149. package/lib/commonjs/utils.js +15 -0
  150. package/lib/commonjs/utils.js.map +1 -0
  151. package/lib/commonjs/web/Errors.js +1 -1
  152. package/lib/commonjs/web/Errors.js.map +1 -1
  153. package/lib/commonjs/web/GestureHandler.js +4 -6
  154. package/lib/commonjs/web/GestureHandler.js.map +1 -1
  155. package/lib/commonjs/web/NodeManager.js +8 -2
  156. package/lib/commonjs/web/NodeManager.js.map +1 -1
  157. package/lib/module/EventType.js +8 -0
  158. package/lib/module/EventType.js.map +1 -0
  159. package/lib/module/GestureHandlerRootView.android.js +2 -14
  160. package/lib/module/GestureHandlerRootView.android.js.map +1 -1
  161. package/lib/module/GestureHandlerRootView.js +5 -1
  162. package/lib/module/GestureHandlerRootView.js.map +1 -1
  163. package/lib/module/RNGestureHandlerModule.js +3 -1
  164. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  165. package/lib/module/RNGestureHandlerModule.web.js +2 -2
  166. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  167. package/lib/module/components/DrawerLayout.js +43 -40
  168. package/lib/module/components/DrawerLayout.js.map +1 -1
  169. package/lib/module/components/GestureButtons.js.map +1 -1
  170. package/lib/module/components/GestureComponents.js +29 -11
  171. package/lib/module/components/GestureComponents.js.map +1 -1
  172. package/lib/module/components/Swipeable.js +9 -6
  173. package/lib/module/components/Swipeable.js.map +1 -1
  174. package/lib/module/components/touchables/GenericTouchable.js +2 -1
  175. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  176. package/lib/module/components/touchables/TouchableOpacity.js +1 -1
  177. package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
  178. package/lib/module/gestureHandlerRootHOC.js +1 -1
  179. package/lib/module/gestureHandlerRootHOC.js.map +1 -1
  180. package/lib/module/handlers/FlingGestureHandler.js +10 -0
  181. package/lib/module/handlers/FlingGestureHandler.js.map +1 -0
  182. package/lib/module/handlers/ForceTouchGestureHandler.js +29 -0
  183. package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -0
  184. package/lib/module/handlers/LongPressGestureHandler.js +10 -0
  185. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -0
  186. package/lib/module/handlers/NativeViewGestureHandler.js +4 -3
  187. package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
  188. package/lib/module/handlers/PanGestureHandler.js +106 -0
  189. package/lib/module/handlers/PanGestureHandler.js.map +1 -0
  190. package/lib/module/handlers/PinchGestureHandler.js +9 -0
  191. package/lib/module/handlers/PinchGestureHandler.js.map +1 -0
  192. package/lib/module/handlers/RotationGestureHandler.js +9 -0
  193. package/lib/module/handlers/RotationGestureHandler.js.map +1 -0
  194. package/lib/module/handlers/TapGestureHandler.js +10 -0
  195. package/lib/module/handlers/TapGestureHandler.js.map +1 -0
  196. package/lib/module/handlers/createHandler.js +41 -76
  197. package/lib/module/handlers/createHandler.js.map +1 -1
  198. package/lib/module/handlers/gestureHandlerCommon.js +66 -0
  199. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -0
  200. package/lib/module/handlers/gestures/GestureDetector.js +402 -0
  201. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -0
  202. package/lib/module/handlers/gestures/eventReceiver.js +120 -0
  203. package/lib/module/handlers/gestures/eventReceiver.js.map +1 -0
  204. package/lib/module/handlers/gestures/flingGesture.js +24 -0
  205. package/lib/module/handlers/gestures/flingGesture.js.map +1 -0
  206. package/lib/module/handlers/gestures/forceTouchGesture.js +56 -0
  207. package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -0
  208. package/lib/module/handlers/gestures/gesture.js +175 -0
  209. package/lib/module/handlers/gestures/gesture.js.map +1 -0
  210. package/lib/module/handlers/gestures/gestureComposition.js +79 -0
  211. package/lib/module/handlers/gestures/gestureComposition.js.map +1 -0
  212. package/lib/module/handlers/gestures/gestureObjects.js +67 -0
  213. package/lib/module/handlers/gestures/gestureObjects.js.map +1 -0
  214. package/lib/module/handlers/gestures/gestureStateManager.js +48 -0
  215. package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -0
  216. package/lib/module/handlers/gestures/longPressGesture.js +24 -0
  217. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -0
  218. package/lib/module/handlers/gestures/manualGesture.js +22 -0
  219. package/lib/module/handlers/gestures/manualGesture.js.map +1 -0
  220. package/lib/module/handlers/gestures/nativeGesture.js +24 -0
  221. package/lib/module/handlers/gestures/nativeGesture.js.map +1 -0
  222. package/lib/module/handlers/gestures/panGesture.js +135 -0
  223. package/lib/module/handlers/gestures/panGesture.js.map +1 -0
  224. package/lib/module/handlers/gestures/pinchGesture.js +36 -0
  225. package/lib/module/handlers/gestures/pinchGesture.js.map +1 -0
  226. package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -0
  227. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -0
  228. package/lib/module/handlers/gestures/rotationGesture.js +36 -0
  229. package/lib/module/handlers/gestures/rotationGesture.js.map +1 -0
  230. package/lib/module/handlers/gestures/tapGesture.js +49 -0
  231. package/lib/module/handlers/gestures/tapGesture.js.map +1 -0
  232. package/lib/module/handlers/handlersRegistry.js +16 -0
  233. package/lib/module/handlers/handlersRegistry.js.map +1 -0
  234. package/lib/module/index.js +22 -1
  235. package/lib/module/index.js.map +1 -1
  236. package/lib/module/init.js +5 -0
  237. package/lib/module/init.js.map +1 -0
  238. package/lib/module/mocks.js +31 -2
  239. package/lib/module/mocks.js.map +1 -1
  240. package/lib/module/utils.js +8 -0
  241. package/lib/module/utils.js.map +1 -0
  242. package/lib/module/web/Errors.js +1 -1
  243. package/lib/module/web/Errors.js.map +1 -1
  244. package/lib/module/web/GestureHandler.js +4 -6
  245. package/lib/module/web/GestureHandler.js.map +1 -1
  246. package/lib/module/web/NodeManager.js +8 -2
  247. package/lib/module/web/NodeManager.js.map +1 -1
  248. package/lib/typescript/EventType.d.ts +8 -0
  249. package/lib/typescript/GestureHandlerRootView.android.d.ts +2 -4
  250. package/lib/typescript/GestureHandlerRootView.d.ts +5 -2
  251. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -1
  252. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
  253. package/lib/typescript/components/DrawerLayout.d.ts +50 -1
  254. package/lib/typescript/components/GestureButtons.d.ts +36 -0
  255. package/lib/typescript/components/GestureComponents.d.ts +8 -35
  256. package/lib/typescript/components/Swipeable.d.ts +73 -6
  257. package/lib/typescript/components/touchables/GenericTouchable.d.ts +2 -2
  258. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
  259. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
  260. package/lib/typescript/handlers/FlingGestureHandler.d.ts +33 -0
  261. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +43 -0
  262. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +55 -0
  263. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +19 -4
  264. package/lib/typescript/handlers/PanGestureHandler.d.ts +137 -0
  265. package/lib/typescript/handlers/PinchGestureHandler.d.ts +28 -0
  266. package/lib/typescript/handlers/RotationGestureHandler.d.ts +28 -0
  267. package/lib/typescript/handlers/TapGestureHandler.d.ts +56 -0
  268. package/lib/typescript/handlers/createHandler.d.ts +1 -1
  269. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +62 -0
  270. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +8 -1
  271. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +16 -0
  272. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
  273. package/lib/typescript/handlers/gestures/flingGesture.d.ts +9 -0
  274. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +16 -0
  275. package/lib/typescript/handlers/gestures/gesture.d.ts +97 -0
  276. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
  277. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +39 -0
  278. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +9 -0
  279. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +9 -0
  280. package/lib/typescript/handlers/gestures/manualGesture.d.ts +7 -0
  281. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +9 -0
  282. package/lib/typescript/handlers/gestures/panGesture.d.ts +26 -0
  283. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +12 -0
  284. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +14 -0
  285. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +12 -0
  286. package/lib/typescript/handlers/gestures/tapGesture.d.ts +14 -0
  287. package/lib/typescript/handlers/handlersRegistry.d.ts +6 -0
  288. package/lib/typescript/index.d.ts +29 -2
  289. package/lib/typescript/init.d.ts +1 -0
  290. package/lib/typescript/mocks.d.ts +21 -2
  291. package/lib/typescript/utils.d.ts +1 -0
  292. package/lib/typescript/web/FlingGestureHandler.d.ts +0 -1
  293. package/lib/typescript/web/GestureHandler.d.ts +0 -1
  294. package/lib/typescript/web/PanGestureHandler.d.ts +0 -1
  295. package/lib/typescript/web/PinchGestureHandler.d.ts +0 -1
  296. package/lib/typescript/web/PressGestureHandler.d.ts +0 -1
  297. package/lib/typescript/web/RotationGestureHandler.d.ts +0 -1
  298. package/lib/typescript/web/TapGestureHandler.d.ts +0 -1
  299. package/package.json +8 -5
  300. package/src/EventType.ts +10 -0
  301. package/src/GestureHandlerRootView.android.tsx +9 -25
  302. package/src/GestureHandlerRootView.tsx +11 -2
  303. package/src/RNGestureHandlerModule.ts +5 -1
  304. package/src/RNGestureHandlerModule.web.ts +1 -0
  305. package/src/components/DrawerLayout.tsx +114 -41
  306. package/src/components/GestureButtons.tsx +45 -5
  307. package/src/components/GestureComponents.tsx +47 -41
  308. package/src/components/Swipeable.tsx +108 -21
  309. package/src/components/touchables/GenericTouchable.tsx +2 -1
  310. package/src/components/touchables/TouchableOpacity.tsx +1 -1
  311. package/src/handlers/FlingGestureHandler.ts +57 -0
  312. package/src/handlers/ForceTouchGestureHandler.ts +83 -0
  313. package/src/handlers/LongPressGestureHandler.ts +84 -0
  314. package/src/handlers/NativeViewGestureHandler.ts +31 -7
  315. package/src/handlers/PanGestureHandler.ts +321 -0
  316. package/src/handlers/PinchGestureHandler.ts +46 -0
  317. package/src/handlers/RotationGestureHandler.ts +46 -0
  318. package/src/handlers/TapGestureHandler.ts +90 -0
  319. package/src/handlers/createHandler.ts +54 -79
  320. package/src/handlers/gestureHandlerCommon.ts +185 -0
  321. package/src/handlers/gestureHandlerTypesCompat.ts +19 -5
  322. package/src/handlers/gestures/GestureDetector.tsx +519 -0
  323. package/src/handlers/gestures/eventReceiver.ts +151 -0
  324. package/src/handlers/gestures/flingGesture.ts +27 -0
  325. package/src/handlers/gestures/forceTouchGesture.ts +74 -0
  326. package/src/handlers/gestures/gesture.ts +292 -0
  327. package/src/handlers/gestures/gestureComposition.ts +109 -0
  328. package/src/handlers/gestures/gestureObjects.ts +79 -0
  329. package/src/handlers/gestures/gestureStateManager.ts +60 -0
  330. package/src/handlers/gestures/longPressGesture.ts +27 -0
  331. package/src/handlers/gestures/manualGesture.ts +31 -0
  332. package/src/handlers/gestures/nativeGesture.ts +27 -0
  333. package/src/handlers/gestures/panGesture.ts +147 -0
  334. package/src/handlers/gestures/pinchGesture.ts +51 -0
  335. package/src/handlers/gestures/reanimatedWrapper.ts +45 -0
  336. package/src/handlers/gestures/rotationGesture.ts +51 -0
  337. package/src/handlers/gestures/tapGesture.ts +52 -0
  338. package/src/handlers/handlersRegistry.ts +22 -0
  339. package/src/index.ts +57 -17
  340. package/src/init.ts +5 -0
  341. package/src/mocks.ts +42 -2
  342. package/src/utils.ts +7 -0
  343. package/src/web/GestureHandler.ts +1 -2
  344. package/src/web/NodeManager.ts +5 -0
  345. package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.java +0 -23
  346. package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.java +0 -110
  347. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.java +0 -531
  348. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.java +0 -8
  349. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.java +0 -543
  350. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.java +0 -10
  351. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.java +0 -29
  352. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.java +0 -53
  353. package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.java +0 -81
  354. package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.java +0 -110
  355. package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.java +0 -8
  356. package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.java +0 -312
  357. package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.java +0 -109
  358. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.java +0 -169
  359. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.java +0 -96
  360. package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.java +0 -172
  361. package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.java +0 -10
  362. package/android/src/main/java/com/facebook/react/views/modal/RNGHModalUtils.java +0 -21
  363. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java +0 -296
  364. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java +0 -72
  365. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.java +0 -77
  366. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.java +0 -8
  367. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.java +0 -86
  368. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java +0 -731
  369. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.java +0 -31
  370. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.java +0 -101
  371. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.java +0 -151
  372. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.java +0 -7
  373. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.java +0 -76
  374. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java +0 -49
  375. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.java +0 -82
  376. package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.java +0 -61
  377. package/lib/commonjs/handlers/gestureHandlers.js +0 -236
  378. package/lib/commonjs/handlers/gestureHandlers.js.map +0 -1
  379. package/lib/module/handlers/gestureHandlers.js +0 -216
  380. package/lib/module/handlers/gestureHandlers.js.map +0 -1
  381. package/lib/typescript/handlers/gestureHandlers.d.ts +0 -158
  382. package/src/handlers/gestureHandlers.ts +0 -511
@@ -1 +1 @@
1
- {"version":3,"sources":["createHandler.ts"],"names":["findNodeHandle","node","Platform","OS","UIManager","NativeModules","customGHEventsConfig","onGestureHandlerEvent","registrationName","onGestureHandlerStateChange","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","RNGestureHandlerModule","handleSetJSResponder","handleClearJSResponder","handlerTag","handlerIDToTag","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","res","forEach","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","Array","isArray","map","current","filter","handle","handlerID","hasUnresolvedRefs","extract","refs","some","r","stateToPropMappings","State","UNDETERMINED","BEGAN","FAILED","CANCELLED","ACTIVE","END","createHandler","allowedProps","config","transformProps","customNativeProps","Handler","React","Component","constructor","event","nativeEvent","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","propsRef","updateGestureHandler","createRef","id","Error","componentDidMount","updateEnqueued","setImmediate","update","componentDidUpdate","componentWillUnmount","dropGestureHandler","clearImmediate","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","grandChildren","Touchable","TOUCH_TARGET_DEBUG","type","displayName","toArray","push","renderDebugView","color","hitSlop","cloneElement","refHandler","collapsable"],"mappings":";;;;;;;AAAA;;AACA;;AAOA;;AACA;;AAEA;;;;;;;;;;;;AASA,SAASA,cAAT,CACEC,IADF,EAEyE;AACvE,MAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B,OAAOF,IAAP;AAC3B,SAAO,iCAAiBA,IAAjB,CAAP;AACD;;AAED,MAAM;AAAEG,EAAAA,SAAS,GAAG;AAAd,IAAqBC,0BAA3B;AAEA,MAAMC,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BC,EAAAA,2BAA2B,EAAE;AAC3BD,IAAAA,gBAAgB,EAAE;AADS;AAFF,CAA7B,C,CAOA;AACA;AACA;AACA;;AACAJ,SAAS,CAACM,uBAAV,GAAoC,EAClC,GAAGN,SAAS,CAACM,uBADqB;A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N;AAGD;AACF;;AACD,YAAMe,MAAM,GAAG;AACbvG,QAAAA,qBAAqB,EAAEqG,mBADV;AAEbnG,QAAAA,2BAA2B,EAAEoG;AAFhB,OAAf;AAKA,WAAKlB,QAAL,CAAc5C,OAAd,GAAwB+D,MAAxB;AAEA,YAAM7B,KAAU,GAAGX,KAAK,CAACY,QAAN,CAAeC,IAAf,CAAoB,KAAKpD,KAAL,CAAWqD,QAA/B,CAAnB;AACA,UAAI2B,aAAa,GAAG9B,KAAK,CAAClD,KAAN,CAAYqD,QAAhC;;AACA,UACE4B,uBAAUC,kBAAV,IACAhC,KAAK,CAACiC,IADN,KAECjC,KAAK,CAACiC,IAAN,KAAe,wBAAf,IACCjC,KAAK,CAACiC,IAAN,CAAWvF,IAAX,KAAoB,MADrB,IAECsD,KAAK,CAACiC,IAAN,CAAWC,WAAX,KAA2B,MAJ7B,CADF,EAME;AACAJ,QAAAA,aAAa,GAAGzC,KAAK,CAACY,QAAN,CAAekC,OAAf,CAAuBL,aAAvB,CAAhB;AACAA,QAAAA,aAAa,CAACM,IAAd,CACEL,uBAAUM,eAAV,CAA0B;AACxBC,UAAAA,KAAK,EAAE,mBADiB;AAExBC,UAAAA,OAAO,EAAEvC,KAAK,CAAClD,KAAN,CAAYyF;AAFG,SAA1B,CADF;AAMD;;AAED,0BAAOlD,KAAK,CAACmD,YAAN,CACLxC,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAKqC,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,WAAGb;AAHL,OAFK,EAOLC,aAPK,CAAP;AASD;;AA1Q8D;;AADS,kBACpE1C,OADoE,iBAEnD1C,IAFmD;;AA6Q1E,SAAO0C,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n findNodeHandle as findNodeHandleRN,\n NativeModules,\n Platform,\n Touchable,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'fbjs/lib/areEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\n\nimport {\n BaseGestureHandlerProps,\n GestureEvent,\n HandlerStateChangeEvent,\n} from './gestureHandlers';\nimport { ValueOf } from '../typeUtils';\n\nfunction findNodeHandle(\n node: null | number | React.Component<any, any> | React.ComponentClass<any>\n): null | number | React.Component<any, any> | React.ComponentClass<any> {\n if (Platform.OS === 'web') return node;\n return findNodeHandleRN(node);\n}\n\nconst { UIManager = {} } = NativeModules;\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManager.genericDirectEventTypes = {\n ...UIManager.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManager.getViewManagerConfig?.('getConstants') ??\n UIManager.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManager;\nUIManager.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManager.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet handlerTag = 1;\nconst handlerIDToTag: Record<string, number> = {};\n\nfunction isConfigParam(param: unknown, name: string) {\n // param !== Object(param) returns false if `param` is a function\n // or an object and returns true if `param` is null\n return (\n param !== undefined &&\n (param !== Object(param) ||\n !('__isNative' in (param as Record<string, unknown>))) &&\n name !== 'onHandlerStateChange' &&\n name !== 'onGestureEvent'\n );\n}\n\nfunction filterConfig(\n props: Record<string, unknown>,\n validProps: string[],\n defaults: Record<string, unknown> = {}\n) {\n const res = { ...defaults };\n validProps.forEach((key) => {\n const value = props[key];\n if (isConfigParam(value, key)) {\n let value = props[key];\n if (key === 'simultaneousHandlers' || key === 'waitFor') {\n value = transformIntoHandlerTags(props[key]);\n } else if (key === 'hitSlop') {\n if (typeof value !== 'object') {\n value = { top: value, left: value, bottom: value, right: value };\n }\n }\n res[key] = value;\n }\n });\n return res;\n}\n\nfunction transformIntoHandlerTags(handlerIDs: any) {\n if (!Array.isArray(handlerIDs)) {\n handlerIDs = [handlerIDs];\n }\n\n if (Platform.OS === 'web') {\n return handlerIDs\n .map(({ current }: { current: any }) => current)\n .filter((handle: any) => handle);\n }\n // converts handler string IDs into their numeric tags\n return handlerIDs\n .map(\n (handlerID: any) =>\n handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1\n )\n .filter((handlerTag: number) => handlerTag > 0);\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<\n HandlerPropsT extends Record<string, unknown>\n> = Readonly<{\n name: string;\n allowedProps: Readonly<Extract<keyof HandlerPropsT, string>[]>;\n config: Readonly<Record<string, unknown>>;\n transformProps?: (props: HandlerPropsT) => HandlerPropsT;\n customNativeProps?: Readonly<string[]>;\n}>;\n\n// TODO(TS) fix event types\ntype InternalEventHandlers = {\n onGestureHandlerEvent?: (event: any) => void;\n onGestureHandlerStateChange?: (event: any) => void;\n};\n\n// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.\nexport default function createHandler<\n T extends BaseGestureHandlerProps<U>,\n U extends Record<string, unknown>\n>({\n name,\n allowedProps = [],\n config = {},\n transformProps,\n customNativeProps = [],\n}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {\n class Handler extends React.Component<T & InternalEventHandlers> {\n static displayName = name;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private viewNode: any;\n private viewTag?: number;\n private updateEnqueued: ReturnType<typeof setImmediate> | null = null;\n\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = handlerTag++;\n this.config = {};\n this.propsRef = React.createRef();\n if (props.id) {\n if (handlerIDToTag[props.id] !== undefined) {\n throw new Error(`Handler with ID \"${props.id}\" already registered`);\n }\n handlerIDToTag[props.id] = this.handlerTag;\n }\n }\n\n componentDidMount() {\n const props: HandlerProps<U> = this.props;\n if (hasUnresolvedRefs(props)) {\n // If there are unresolved refs (e.g. \".current\" has not yet been set)\n // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to\n // _update method that will try to update native handler props using\n // setImmediate. This makes it so _update function gets called after all\n // react components are mounted and we expect the missing ref object to\n // be resolved by then.\n this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update();\n });\n }\n\n this.createGestureHandler(\n filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n )\n );\n\n this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null\n }\n\n componentDidUpdate() {\n const viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle\n }\n this.update();\n }\n\n componentWillUnmount() {\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n if (this.updateEnqueued) {\n clearImmediate(this.updateEnqueued);\n }\n // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context\n const handlerID: string | undefined = this.props.id;\n if (handlerID) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete handlerIDToTag[handlerID];\n }\n }\n\n private onGestureHandlerEvent = (event: GestureEvent<U>) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n this.props.onGestureEvent?.(event);\n } else {\n this.props.onGestureHandlerEvent?.(event);\n }\n };\n\n // TODO(TS) - make sure this is right type for event\n private onGestureHandlerStateChange = (\n event: HandlerStateChangeEvent<U>\n ) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n this.props.onHandlerStateChange?.(event);\n\n const state: ValueOf<typeof State> = event.nativeEvent.state;\n const stateEventName = stateToPropMappings[state];\n const eventHandler = stateEventName && this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n this.props.onGestureHandlerStateChange?.(event);\n }\n };\n\n private refHandler = (node: any) => {\n this.viewNode = node;\n\n const child = React.Children.only(this.props.children);\n // TODO(TS) fix ref type\n const { ref }: any = child;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n };\n\n private createGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.createGestureHandler(\n name,\n this.handlerTag,\n newConfig\n );\n };\n\n private attachGestureHandler = (newViewTag: number) => {\n this.viewTag = newViewTag;\n\n if (Platform.OS === 'web') {\n // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch\n (RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(\n this.handlerTag,\n newViewTag,\n this.propsRef\n );\n } else {\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag\n );\n }\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\n };\n\n private update() {\n const newConfig = filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n );\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n\n setNativeProps(updates: any) {\n const mergedProps = { ...this.props, ...updates };\n const newConfig = filterConfig(\n transformProps ? transformProps(mergedProps) : mergedProps,\n [...allowedProps, ...customNativeProps],\n config\n );\n this.updateGestureHandler(newConfig);\n }\n\n render() {\n let gestureEventHandler = this.onGestureHandlerEvent;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureEventHandlers = {\n onGestureEvent?: BaseGestureHandlerProps<U>['onGestureEvent'];\n onGestureHandlerEvent?: InternalEventHandlers['onGestureHandlerEvent'];\n };\n const {\n onGestureEvent,\n onGestureHandlerEvent,\n }: OnGestureEventHandlers = this.props;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerEvent) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (\n onGestureHandlerEvent &&\n typeof onGestureHandlerEvent !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n\n let gestureStateEventHandler = this.onGestureHandlerStateChange;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureStateChangeHandlers = {\n onHandlerStateChange?: BaseGestureHandlerProps<U>['onHandlerStateChange'];\n onGestureHandlerStateChange?: InternalEventHandlers['onGestureHandlerStateChange'];\n };\n const {\n onHandlerStateChange,\n onGestureHandlerStateChange,\n }: OnGestureStateChangeHandlers = this.props;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerStateChange) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (\n onGestureHandlerStateChange &&\n typeof onGestureHandlerStateChange !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n const events = {\n onGestureHandlerEvent: gestureEventHandler,\n onGestureHandlerStateChange: gestureStateEventHandler,\n };\n\n this.propsRef.current = events;\n\n const child: any = React.Children.only(this.props.children);\n let grandChildren = child.props.children;\n if (\n Touchable.TOUCH_TARGET_DEBUG &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n Touchable.renderDebugView({\n color: 'mediumspringgreen',\n hitSlop: child.props.hitSlop,\n })\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
1
+ {"version":3,"sources":["createHandler.ts"],"names":["UIManagerAny","UIManager","customGHEventsConfig","onGestureHandlerEvent","registrationName","onGestureHandlerStateChange","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","RNGestureHandlerModule","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","Platform","OS","DeviceEventEmitter","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","State","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","React","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","propsRef","updateGestureHandler","createRef","id","handlerIDToTag","Error","componentDidMount","inspectorToggleListener","setState","_","update","updateEnqueued","setImmediate","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","clearImmediate","handlerID","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","grandChildren","Touchable","TOUCH_TARGET_DEBUG","type","displayName","toArray","push","renderDebugView","color","hitSlop","cloneElement","refHandler","collapsable"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AAEA;;AACA;;AAEA;;;;;;;;;;;;AASA,MAAMA,YAAY,GAAGC,sBAArB;AAEA,MAAMC,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BC,EAAAA,2BAA2B,EAAE;AAC3BD,IAAAA,gBAAgB,EAAE;AADS;AAFF,CAA7B,C,CAOA;AACA;AACA;AACA;;AACAJ,YAAY,CAACM,uBAAb,GAAuC,EACrC,GAAGN,YAAY,CAACM,uBADqB;AAErC,KAAGJ;AAFkC,CAAvC,C,CAIA;AACA;AACA;;AACA,MAAMK,kBAAkB,sDACtBP,YAAY,CAACQ,oBADS,2DACtB,4BAAAR,YAAY,EAAwB,cAAxB,CADU,kGAEtBA,YAAY,CAACS,YAFS,0DAEtB,2BAAAT,YAAY,CAFd;;AAIA,IAAIO,kBAAJ,EAAwB;AACtBA,EAAAA,kBAAkB,CAACD,uBAAnB,GAA6C,EAC3C,GAAG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AK,CAACc,QAAN,CAAeC,IAAf,CAAoB,KAAKvC,KAAL,CAAWwC,QAA/B,CAAnB;AACA,UAAIiC,aAAa,GAAGpC,KAAK,CAACrC,KAAN,CAAYwC,QAAhC;;AACA,UACEkC,uBAAUC,kBAAV,IACAtC,KAAK,CAACuC,IADN,KAECvC,KAAK,CAACuC,IAAN,KAAe,wBAAf,IACCvC,KAAK,CAACuC,IAAN,CAAW1D,IAAX,KAAoB,MADrB,IAECmB,KAAK,CAACuC,IAAN,CAAWC,WAAX,KAA2B,MAJ7B,CADF,EAME;AACAJ,QAAAA,aAAa,GAAGjD,KAAK,CAACc,QAAN,CAAewC,OAAf,CAAuBL,aAAvB,CAAhB;AACAA,QAAAA,aAAa,CAACM,IAAd,CACEL,uBAAUM,eAAV,CAA0B;AACxBC,UAAAA,KAAK,EAAE,mBADiB;AAExBC,UAAAA,OAAO,EAAE7C,KAAK,CAACrC,KAAN,CAAYkF;AAFG,SAA1B,CADF;AAMD;;AAED,0BAAO1D,KAAK,CAAC2D,YAAN,CACL9C,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAK2C,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,WAAGb;AAHL,OAFK,EAOLC,aAPK,CAAP;AASD;;AA7RD;;AAPwE,kBAIpElD,OAJoE,iBAQnDL,IARmD;;AAsS1E,SAAOK,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n Touchable,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\nimport { handlerIDToTag, getNextHandlerTag } from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\n\nconst UIManagerAny = UIManager as any;\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManagerAny.genericDirectEventTypes = {\n ...UIManagerAny.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManagerAny.getViewManagerConfig?.('getConstants') ??\n UIManagerAny.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManagerAny;\nUIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet allowTouches = true;\nconst DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\n// Toggled inspector blocks touch events in order to allow inspecting on Android\n// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', () => {\n allowTouches = !allowTouches;\n });\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<\n HandlerPropsT extends Record<string, unknown>\n> = Readonly<{\n name: string;\n allowedProps: Readonly<Extract<keyof HandlerPropsT, string>[]>;\n config: Readonly<Record<string, unknown>>;\n transformProps?: (props: HandlerPropsT) => HandlerPropsT;\n customNativeProps?: Readonly<string[]>;\n}>;\n\n// TODO(TS) fix event types\ntype InternalEventHandlers = {\n onGestureHandlerEvent?: (event: any) => void;\n onGestureHandlerStateChange?: (event: any) => void;\n};\n\n// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.\nexport default function createHandler<\n T extends BaseGestureHandlerProps<U>,\n U extends Record<string, unknown>\n>({\n name,\n allowedProps = [],\n config = {},\n transformProps,\n customNativeProps = [],\n}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {\n interface HandlerState {\n allowTouches: boolean;\n }\n class Handler extends React.Component<\n T & InternalEventHandlers,\n HandlerState\n > {\n static displayName = name;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private viewNode: any;\n private viewTag?: number;\n private updateEnqueued: ReturnType<typeof setImmediate> | null = null;\n private inspectorToggleListener?: EmitterSubscription;\n\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = getNextHandlerTag();\n this.config = {};\n this.propsRef = React.createRef();\n this.state = { allowTouches };\n if (props.id) {\n if (handlerIDToTag[props.id] !== undefined) {\n throw new Error(`Handler with ID \"${props.id}\" already registered`);\n }\n handlerIDToTag[props.id] = this.handlerTag;\n }\n }\n\n componentDidMount() {\n const props: HandlerProps<U> = this.props;\n\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener(\n 'toggleElementInspector',\n () => {\n this.setState((_) => ({ allowTouches }));\n this.update();\n }\n );\n }\n if (hasUnresolvedRefs(props)) {\n // If there are unresolved refs (e.g. \".current\" has not yet been set)\n // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to\n // _update method that will try to update native handler props using\n // setImmediate. This makes it so update() function gets called after all\n // react components are mounted and we expect the missing ref object to\n // be resolved by then.\n this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update();\n });\n }\n\n this.createGestureHandler(\n filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n )\n );\n\n this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null\n }\n\n componentDidUpdate() {\n const viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle\n }\n this.update();\n }\n\n componentWillUnmount() {\n this.inspectorToggleListener?.remove();\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n if (this.updateEnqueued) {\n clearImmediate(this.updateEnqueued);\n }\n // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context\n const handlerID: string | undefined = this.props.id;\n if (handlerID) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete handlerIDToTag[handlerID];\n }\n }\n\n private onGestureHandlerEvent = (event: GestureEvent<U>) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n this.props.onGestureEvent?.(event);\n } else {\n this.props.onGestureHandlerEvent?.(event);\n }\n };\n\n // TODO(TS) - make sure this is right type for event\n private onGestureHandlerStateChange = (\n event: HandlerStateChangeEvent<U>\n ) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n this.props.onHandlerStateChange?.(event);\n\n const state: ValueOf<typeof State> = event.nativeEvent.state;\n const stateEventName = stateToPropMappings[state];\n const eventHandler = stateEventName && this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n this.props.onGestureHandlerStateChange?.(event);\n }\n };\n\n private refHandler = (node: any) => {\n this.viewNode = node;\n\n const child = React.Children.only(this.props.children);\n // TODO(TS) fix ref type\n const { ref }: any = child;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n };\n\n private createGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.createGestureHandler(\n name,\n this.handlerTag,\n newConfig\n );\n };\n\n private attachGestureHandler = (newViewTag: number) => {\n this.viewTag = newViewTag;\n\n if (Platform.OS === 'web') {\n // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch\n (RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(\n this.handlerTag,\n newViewTag,\n false,\n this.propsRef\n );\n } else {\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag,\n false\n );\n }\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\n };\n\n private update() {\n const newConfig = filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n );\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n\n setNativeProps(updates: any) {\n const mergedProps = { ...this.props, ...updates };\n const newConfig = filterConfig(\n transformProps ? transformProps(mergedProps) : mergedProps,\n [...allowedProps, ...customNativeProps],\n config\n );\n this.updateGestureHandler(newConfig);\n }\n\n render() {\n let gestureEventHandler = this.onGestureHandlerEvent;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureEventHandlers = {\n onGestureEvent?: BaseGestureHandlerProps<U>['onGestureEvent'];\n onGestureHandlerEvent?: InternalEventHandlers['onGestureHandlerEvent'];\n };\n const {\n onGestureEvent,\n onGestureHandlerEvent,\n }: OnGestureEventHandlers = this.props;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerEvent) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (\n onGestureHandlerEvent &&\n typeof onGestureHandlerEvent !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n\n let gestureStateEventHandler = this.onGestureHandlerStateChange;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureStateChangeHandlers = {\n onHandlerStateChange?: BaseGestureHandlerProps<U>['onHandlerStateChange'];\n onGestureHandlerStateChange?: InternalEventHandlers['onGestureHandlerStateChange'];\n };\n const {\n onHandlerStateChange,\n onGestureHandlerStateChange,\n }: OnGestureStateChangeHandlers = this.props;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerStateChange) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (\n onGestureHandlerStateChange &&\n typeof onGestureHandlerStateChange !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n const events = {\n onGestureHandlerEvent: this.state.allowTouches\n ? gestureEventHandler\n : undefined,\n onGestureHandlerStateChange: this.state.allowTouches\n ? gestureStateEventHandler\n : undefined,\n };\n\n this.propsRef.current = events;\n\n const child: any = React.Children.only(this.props.children);\n let grandChildren = child.props.children;\n if (\n Touchable.TOUCH_TARGET_DEBUG &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n Touchable.renderDebugView({\n color: 'mediumspringgreen',\n hitSlop: child.props.hitSlop,\n })\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterConfig = filterConfig;
7
+ exports.findNodeHandle = findNodeHandle;
8
+ exports.baseGestureHandlerWithMonitorProps = exports.baseGestureHandlerProps = void 0;
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _handlersRegistry = require("./handlersRegistry");
13
+
14
+ var _utils = require("../utils");
15
+
16
+ // Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.
17
+ // Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof
18
+ // e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.
19
+ // See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.
20
+ const commonProps = ['id', 'enabled', 'shouldCancelWhenOutside', 'hitSlop'];
21
+ const componentInteractionProps = ['waitFor', 'simultaneousHandlers'];
22
+ const baseGestureHandlerProps = [...commonProps, ...componentInteractionProps, 'onBegan', 'onFailed', 'onCancelled', 'onActivated', 'onEnded', 'onGestureEvent', 'onHandlerStateChange'];
23
+ exports.baseGestureHandlerProps = baseGestureHandlerProps;
24
+ const baseGestureHandlerWithMonitorProps = [...commonProps, 'needsPointerData', 'manualActivation'];
25
+ exports.baseGestureHandlerWithMonitorProps = baseGestureHandlerWithMonitorProps;
26
+
27
+ function isConfigParam(param, name) {
28
+ // param !== Object(param) returns false if `param` is a function
29
+ // or an object and returns true if `param` is null
30
+ return param !== undefined && (param !== Object(param) || !('__isNative' in param)) && name !== 'onHandlerStateChange' && name !== 'onGestureEvent';
31
+ }
32
+
33
+ function filterConfig(props, validProps, defaults = {}) {
34
+ const filteredConfig = { ...defaults
35
+ };
36
+
37
+ for (const key of validProps) {
38
+ let value = props[key];
39
+
40
+ if (isConfigParam(value, key)) {
41
+ if (key === 'simultaneousHandlers' || key === 'waitFor') {
42
+ value = transformIntoHandlerTags(props[key]);
43
+ } else if (key === 'hitSlop' && typeof value !== 'object') {
44
+ value = {
45
+ top: value,
46
+ left: value,
47
+ bottom: value,
48
+ right: value
49
+ };
50
+ }
51
+
52
+ filteredConfig[key] = value;
53
+ }
54
+ }
55
+
56
+ return filteredConfig;
57
+ }
58
+
59
+ function transformIntoHandlerTags(handlerIDs) {
60
+ handlerIDs = (0, _utils.toArray)(handlerIDs);
61
+
62
+ if (_reactNative.Platform.OS === 'web') {
63
+ return handlerIDs.map(({
64
+ current
65
+ }) => current).filter(handle => handle);
66
+ } // converts handler string IDs into their numeric tags
67
+
68
+
69
+ return handlerIDs.map(handlerID => {
70
+ var _handlerID$current;
71
+
72
+ return _handlersRegistry.handlerIDToTag[handlerID] || ((_handlerID$current = handlerID.current) === null || _handlerID$current === void 0 ? void 0 : _handlerID$current.handlerTag) || -1;
73
+ }).filter(handlerTag => handlerTag > 0);
74
+ }
75
+
76
+ function findNodeHandle(node) {
77
+ if (_reactNative.Platform.OS === 'web') return node;
78
+ return (0, _reactNative.findNodeHandle)(node);
79
+ }
80
+ //# sourceMappingURL=gestureHandlerCommon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["gestureHandlerCommon.ts"],"names":["commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithMonitorProps","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","filteredConfig","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","Platform","OS","map","current","filter","handle","handlerID","handlerIDToTag","handlerTag","findNodeHandle","node"],"mappings":";;;;;;;;;AAKA;;AAKA;;AACA;;AAXA;AACA;AACA;AACA;AAUA,MAAMA,WAAW,GAAG,CAClB,IADkB,EAElB,SAFkB,EAGlB,yBAHkB,EAIlB,SAJkB,CAApB;AAOA,MAAMC,yBAAyB,GAAG,CAAC,SAAD,EAAY,sBAAZ,CAAlC;AAEO,MAAMC,uBAAuB,GAAG,CACrC,GAAGF,WADkC,EAErC,GAAGC,yBAFkC,EAGrC,SAHqC,EAIrC,UAJqC,EAKrC,aALqC,EAMrC,aANqC,EAOrC,SAPqC,EAQrC,gBARqC,EASrC,sBATqC,CAAhC;;AAYA,MAAME,kCAAkC,GAAG,CAChD,GAAGH,WAD6C,EAEhD,kBAFgD,EAGhD,kBAHgD,CAA3C;;;AAgGP,SAASI,aAAT,CAAuBC,KAAvB,EAAuCC,IAAvC,EAAqD;AACnD;AACA;AACA,SACED,KAAK,KAAKE,SAAV,KACCF,KAAK,KAAKG,MAAM,CAACH,KAAD,CAAhB,IACC,EAAE,gBAAiBA,KAAnB,CAFF,KAGAC,IAAI,KAAK,sBAHT,IAIAA,IAAI,KAAK,gBALX;AAOD;;AAEM,SAASG,YAAT,CACLC,KADK,EAELC,UAFK,EAGLC,QAAiC,GAAG,EAH/B,EAIL;AACA,QAAMC,cAAc,GAAG,EAAE,GAAGD;AAAL,GAAvB;;AACA,OAAK,MAAME,GAAX,IAAkBH,UAAlB,EAA8B;AAC5B,QAAII,KAAK,GAAGL,KAAK,CAACI,GAAD,CAAjB;;AACA,QAAIV,aAAa,CAACW,KAAD,EAAQD,GAAR,CAAjB,EAA+B;AAC7B,UAAIA,GAAG,KAAK,sBAAR,IAAkCA,GAAG,KAAK,SAA9C,EAAyD;AACvDC,QAAAA,KAAK,GAAGC,wBAAwB,CAACN,KAAK,CAACI,GAAD,CAAN,CAAhC;AACD,OAFD,MAEO,IAAIA,GAAG,KAAK,SAAR,IAAqB,OAAOC,KAAP,KAAiB,QAA1C,EAAoD;AACzDA,QAAAA,KAAK,GAAG;AAAEE,UAAAA,GAAG,EAAEF,KAAP;AAAcG,UAAAA,IAAI,EAAEH,KAApB;AAA2BI,UAAAA,MAAM,EAAEJ,KAAnC;AAA0CK,UAAAA,KAAK,EAAEL;AAAjD,SAAR;AACD;;AACDF,MAAAA,cAAc,CAACC,GAAD,CAAd,GAAsBC,KAAtB;AACD;AACF;;AACD,SAAOF,cAAP;AACD;;AAED,SAASG,wBAAT,CAAkCK,UAAlC,EAAmD;AACjDA,EAAAA,UAAU,GAAG,oBAAQA,UAAR,CAAb;;AAEA,MAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOF,UAAU,CACdG,GADI,CACA,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAmCA,OADnC,EAEJC,MAFI,CAEIC,MAAD,IAAiBA,MAFpB,CAAP;AAGD,GAPgD,CAQjD;;;AACA,SAAON,UAAU,CACdG,GADI,CAEFI,SAAD;AAAA;;AAAA,WACEC,iCAAeD,SAAf,4BAA6BA,SAAS,CAACH,OAAvC,uDAA6B,mBAAmBK,UAAhD,KAA8D,CAAC,CADjE;AAAA,GAFG,EAKJJ,MALI,CAKII,UAAD,IAAwBA,UAAU,GAAG,CALxC,CAAP;AAMD;;AAEM,SAASC,cAAT,CACLC,IADK,EAEkE;AACvE,MAAIV,sBAASC,EAAT,KAAgB,KAApB,EAA2B,OAAOS,IAAP;AAC3B,SAAO,iCAAiBA,IAAjB,CAAP;AACD","sourcesContent":["// Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.\n// Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof\n// e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.\n// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.\nimport * as React from 'react';\nimport { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';\n\nimport { State } from '../State';\nimport { EventType } from '../EventType';\nimport { ValueOf } from '../typeUtils';\nimport { handlerIDToTag } from './handlersRegistry';\nimport { toArray } from '../utils';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n] as const;\n\nconst componentInteractionProps = ['waitFor', 'simultaneousHandlers'] as const;\n\nexport const baseGestureHandlerProps = [\n ...commonProps,\n ...componentInteractionProps,\n 'onBegan',\n 'onFailed',\n 'onCancelled',\n 'onActivated',\n 'onEnded',\n 'onGestureEvent',\n 'onHandlerStateChange',\n] as const;\n\nexport const baseGestureHandlerWithMonitorProps = [\n ...commonProps,\n 'needsPointerData',\n 'manualActivation',\n];\n\nexport interface GestureEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\n}\n\nexport interface HandlerStateChangeEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\n oldState: ValueOf<typeof State>;\n}\n\nexport type HitSlop =\n | number\n | Partial<\n Record<\n 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal',\n number\n >\n >\n | Record<'width' | 'left', number>\n | Record<'width' | 'right', number>\n | Record<'height' | 'top', number>\n | Record<'height' | 'bottom', number>;\n\n//TODO(TS) events in handlers\n\nexport interface GestureEvent<ExtraEventPayloadT = Record<string, unknown>> {\n nativeEvent: Readonly<GestureEventPayload & ExtraEventPayloadT>;\n}\nexport interface HandlerStateChangeEvent<\n ExtraEventPayloadT = Record<string, unknown>\n> {\n nativeEvent: Readonly<HandlerStateChangeEventPayload & ExtraEventPayloadT>;\n}\n\nexport type TouchData = {\n id: number;\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type GestureTouchEvent = {\n handlerTag: number;\n numberOfTouches: number;\n state: ValueOf<typeof State>;\n eventType: EventType;\n allTouches: TouchData[];\n changedTouches: TouchData[];\n};\n\nexport type GestureUpdateEvent<\n GestureEventPayloadT = Record<string, unknown>\n> = GestureEventPayload & GestureEventPayloadT;\n\nexport type GestureStateChangeEvent<\n GestureStateChangeEventPayloadT = Record<string, unknown>\n> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT;\n\nexport type CommonGestureConfig = {\n enabled?: boolean;\n shouldCancelWhenOutside?: boolean;\n hitSlop?: HitSlop;\n};\n\n// Events payloads are types instead of interfaces due to TS limitation.\n// See https://github.com/microsoft/TypeScript/issues/15300 for more info.\nexport type BaseGestureHandlerProps<\n ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown>\n> = CommonGestureConfig & {\n id?: string;\n waitFor?: React.Ref<unknown> | React.Ref<unknown>[];\n simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];\n // TODO(TS) - fix event types\n onBegan?: (event: HandlerStateChangeEvent) => void;\n onFailed?: (event: HandlerStateChangeEvent) => void;\n onCancelled?: (event: HandlerStateChangeEvent) => void;\n onActivated?: (event: HandlerStateChangeEvent) => void;\n onEnded?: (event: HandlerStateChangeEvent) => void;\n\n //TODO(TS) consider using NativeSyntheticEvent\n onGestureEvent?: (event: GestureEvent<ExtraEventPayloadT>) => void;\n onHandlerStateChange?: (\n event: HandlerStateChangeEvent<ExtraEventPayloadT>\n ) => void;\n};\n\nfunction isConfigParam(param: unknown, name: string) {\n // param !== Object(param) returns false if `param` is a function\n // or an object and returns true if `param` is null\n return (\n param !== undefined &&\n (param !== Object(param) ||\n !('__isNative' in (param as Record<string, unknown>))) &&\n name !== 'onHandlerStateChange' &&\n name !== 'onGestureEvent'\n );\n}\n\nexport function filterConfig(\n props: Record<string, unknown>,\n validProps: string[],\n defaults: Record<string, unknown> = {}\n) {\n const filteredConfig = { ...defaults };\n for (const key of validProps) {\n let value = props[key];\n if (isConfigParam(value, key)) {\n if (key === 'simultaneousHandlers' || key === 'waitFor') {\n value = transformIntoHandlerTags(props[key]);\n } else if (key === 'hitSlop' && typeof value !== 'object') {\n value = { top: value, left: value, bottom: value, right: value };\n }\n filteredConfig[key] = value;\n }\n }\n return filteredConfig;\n}\n\nfunction transformIntoHandlerTags(handlerIDs: any) {\n handlerIDs = toArray(handlerIDs);\n\n if (Platform.OS === 'web') {\n return handlerIDs\n .map(({ current }: { current: any }) => current)\n .filter((handle: any) => handle);\n }\n // converts handler string IDs into their numeric tags\n return handlerIDs\n .map(\n (handlerID: any) =>\n handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1\n )\n .filter((handlerTag: number) => handlerTag > 0);\n}\n\nexport function findNodeHandle(\n node: null | number | React.Component<any, any> | React.ComponentClass<any>\n): null | number | React.Component<any, any> | React.ComponentClass<any> {\n if (Platform.OS === 'web') return node;\n return findNodeHandleRN(node);\n}\n"]}