react-native-gesture-handler 2.27.1 → 2.28.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 (426) hide show
  1. package/RNGestureHandler.podspec +3 -2
  2. package/ReanimatedSwipeable/package.json +4 -4
  3. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +14 -8
  4. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +10 -5
  5. package/android/src/main/jni/CMakeLists.txt +5 -0
  6. package/android/src/main/jni/cpp-adapter.cpp +6 -0
  7. package/apple/RNGestureHandler.h +4 -0
  8. package/apple/RNGestureHandler.mm +41 -6
  9. package/apple/RNGestureHandlerModule.mm +5 -0
  10. package/jestSetup.js +22 -3
  11. package/lib/commonjs/components/Pressable/Pressable.js +12 -21
  12. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  13. package/lib/commonjs/components/Pressable/StateMachine.js +8 -2
  14. package/lib/commonjs/components/Pressable/StateMachine.js.map +1 -1
  15. package/lib/commonjs/components/Pressable/stateDefinitions.js +22 -23
  16. package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -1
  17. package/lib/commonjs/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +30 -39
  18. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
  19. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +12 -0
  20. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
  21. package/lib/commonjs/components/ReanimatedSwipeable/index.js +21 -0
  22. package/lib/commonjs/components/ReanimatedSwipeable/index.js.map +1 -0
  23. package/lib/commonjs/components/gestureHandlerRootHOC.js +4 -1
  24. package/lib/commonjs/components/gestureHandlerRootHOC.js.map +1 -1
  25. package/lib/commonjs/handlers/createHandler.js +1 -1
  26. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  27. package/lib/commonjs/handlers/gestures/GestureDetector/index.js +1 -1
  28. package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
  29. package/lib/commonjs/mocks/Pressable.js +13 -0
  30. package/lib/commonjs/mocks/Pressable.js.map +1 -0
  31. package/lib/commonjs/{mocks.js → mocks/mocks.js} +8 -11
  32. package/lib/commonjs/mocks/mocks.js.map +1 -0
  33. package/lib/commonjs/web/handlers/GestureHandler.js +5 -2
  34. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  35. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +0 -5
  36. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  37. package/lib/commonjs/web/tools/KeyboardEventManager.js +34 -8
  38. package/lib/commonjs/web/tools/KeyboardEventManager.js.map +1 -1
  39. package/lib/module/components/Pressable/Pressable.js +14 -23
  40. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  41. package/lib/module/components/Pressable/StateMachine.js +8 -2
  42. package/lib/module/components/Pressable/StateMachine.js.map +1 -1
  43. package/lib/module/components/Pressable/stateDefinitions.js +21 -22
  44. package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
  45. package/lib/module/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +24 -33
  46. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
  47. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +8 -0
  48. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
  49. package/lib/module/components/ReanimatedSwipeable/index.js +5 -0
  50. package/lib/module/components/ReanimatedSwipeable/index.js.map +1 -0
  51. package/lib/module/components/gestureHandlerRootHOC.js +5 -0
  52. package/lib/module/components/gestureHandlerRootHOC.js.map +1 -1
  53. package/lib/module/handlers/createHandler.js +1 -1
  54. package/lib/module/handlers/createHandler.js.map +1 -1
  55. package/lib/module/handlers/gestures/GestureDetector/index.js +1 -1
  56. package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
  57. package/lib/module/mocks/Pressable.js +4 -0
  58. package/lib/module/mocks/Pressable.js.map +1 -0
  59. package/lib/module/{mocks.js → mocks/mocks.js} +7 -11
  60. package/lib/module/mocks/mocks.js.map +1 -0
  61. package/lib/module/web/handlers/GestureHandler.js +5 -2
  62. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  63. package/lib/module/web/tools/GestureHandlerWebDelegate.js +0 -5
  64. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  65. package/lib/module/web/tools/KeyboardEventManager.js +34 -8
  66. package/lib/module/web/tools/KeyboardEventManager.js.map +1 -1
  67. package/lib/typescript/ActionType.d.ts +1 -0
  68. package/lib/typescript/Directions.d.ts +1 -0
  69. package/lib/typescript/EnableNewWebImplementation.d.ts +1 -0
  70. package/lib/typescript/GestureHandlerRootViewContext.d.ts +1 -0
  71. package/lib/typescript/PlatformConstants.d.ts +1 -0
  72. package/lib/typescript/PlatformConstants.web.d.ts +1 -0
  73. package/lib/typescript/PointerType.d.ts +1 -0
  74. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
  75. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
  76. package/lib/typescript/RNGestureHandlerModule.windows.d.ts +1 -0
  77. package/lib/typescript/RNRenderer.d.ts +1 -0
  78. package/lib/typescript/RNRenderer.web.d.ts +1 -0
  79. package/lib/typescript/State.d.ts +1 -0
  80. package/lib/typescript/TouchEventType.d.ts +1 -0
  81. package/lib/typescript/components/DrawerLayout.d.ts +1 -0
  82. package/lib/typescript/components/GestureButtons.d.ts +1 -0
  83. package/lib/typescript/components/GestureButtonsProps.d.ts +10 -1
  84. package/lib/typescript/components/GestureButtonsProps.d.ts.map +1 -1
  85. package/lib/typescript/components/GestureComponents.d.ts +1 -0
  86. package/lib/typescript/components/GestureComponents.web.d.ts +1 -0
  87. package/lib/typescript/components/GestureHandlerButton.d.ts +1 -0
  88. package/lib/typescript/components/GestureHandlerButton.web.d.ts +1 -0
  89. package/lib/typescript/components/GestureHandlerRootView.android.d.ts +1 -0
  90. package/lib/typescript/components/GestureHandlerRootView.d.ts +1 -0
  91. package/lib/typescript/components/GestureHandlerRootView.web.d.ts +1 -0
  92. package/lib/typescript/components/Pressable/Pressable.d.ts +1 -0
  93. package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
  94. package/lib/typescript/components/Pressable/PressableProps.d.ts +3 -4
  95. package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
  96. package/lib/typescript/components/Pressable/StateMachine.d.ts +4 -2
  97. package/lib/typescript/components/Pressable/StateMachine.d.ts.map +1 -1
  98. package/lib/typescript/components/Pressable/index.d.ts +1 -0
  99. package/lib/typescript/components/Pressable/stateDefinitions.d.ts +3 -2
  100. package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
  101. package/lib/typescript/components/Pressable/utils.d.ts +1 -0
  102. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +1 -0
  103. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts +6 -0
  104. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -0
  105. package/lib/typescript/components/{ReanimatedSwipeable.d.ts → ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts} +10 -7
  106. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts.map +1 -0
  107. package/lib/typescript/components/ReanimatedSwipeable/index.d.ts +3 -0
  108. package/lib/typescript/components/ReanimatedSwipeable/index.d.ts.map +1 -0
  109. package/lib/typescript/components/Swipeable.d.ts +1 -0
  110. package/lib/typescript/components/Text.d.ts +1 -0
  111. package/lib/typescript/components/gestureHandlerRootHOC.d.ts +5 -0
  112. package/lib/typescript/components/gestureHandlerRootHOC.d.ts.map +1 -1
  113. package/lib/typescript/components/touchables/ExtraButtonProps.d.ts +1 -0
  114. package/lib/typescript/components/touchables/GenericTouchable.d.ts +1 -0
  115. package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +1 -0
  116. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
  117. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +1 -0
  118. package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +1 -0
  119. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +1 -0
  120. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
  121. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +1 -0
  122. package/lib/typescript/components/touchables/index.d.ts +1 -0
  123. package/lib/typescript/components/utils.d.ts +1 -0
  124. package/lib/typescript/findNodeHandle.d.ts +1 -0
  125. package/lib/typescript/findNodeHandle.web.d.ts +1 -0
  126. package/lib/typescript/getShadowNodeFromRef.d.ts +1 -0
  127. package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
  128. package/lib/typescript/ghQueueMicrotask.d.ts +1 -0
  129. package/lib/typescript/handlers/FlingGestureHandler.d.ts +1 -0
  130. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +1 -0
  131. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +1 -0
  132. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +1 -0
  133. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -0
  134. package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -0
  135. package/lib/typescript/handlers/PinchGestureHandler.d.ts +1 -0
  136. package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -0
  137. package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +1 -0
  138. package/lib/typescript/handlers/RotationGestureHandler.d.ts +1 -0
  139. package/lib/typescript/handlers/TapGestureHandler.d.ts +1 -0
  140. package/lib/typescript/handlers/createHandler.d.ts +1 -0
  141. package/lib/typescript/handlers/createNativeWrapper.d.ts +1 -0
  142. package/lib/typescript/handlers/customDirectEventTypes.d.ts +1 -0
  143. package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +1 -0
  144. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +1 -0
  145. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +1 -0
  146. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +1 -0
  147. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +1 -0
  148. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +1 -0
  149. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +1 -0
  150. package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts +1 -0
  151. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +1 -0
  152. package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +1 -0
  153. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +1 -0
  154. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +1 -0
  155. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +1 -0
  156. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +1 -0
  157. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +1 -0
  158. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +1 -0
  159. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +1 -0
  160. package/lib/typescript/handlers/gestures/flingGesture.d.ts +1 -0
  161. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +1 -0
  162. package/lib/typescript/handlers/gestures/gesture.d.ts +1 -0
  163. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +1 -0
  164. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +1 -0
  165. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +1 -0
  166. package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts +1 -0
  167. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -0
  168. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +1 -0
  169. package/lib/typescript/handlers/gestures/manualGesture.d.ts +1 -0
  170. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +1 -0
  171. package/lib/typescript/handlers/gestures/panGesture.d.ts +1 -0
  172. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +1 -0
  173. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +1 -0
  174. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +1 -0
  175. package/lib/typescript/handlers/gestures/tapGesture.d.ts +1 -0
  176. package/lib/typescript/handlers/getNextHandlerTag.d.ts +1 -0
  177. package/lib/typescript/handlers/handlersRegistry.d.ts +1 -0
  178. package/lib/typescript/handlers/utils.d.ts +1 -0
  179. package/lib/typescript/index.d.ts +1 -0
  180. package/lib/typescript/init.d.ts +1 -0
  181. package/lib/typescript/jestUtils/index.d.ts +1 -0
  182. package/lib/typescript/jestUtils/jestUtils.d.ts +1 -0
  183. package/lib/typescript/mocks/Pressable.d.ts +2 -0
  184. package/lib/typescript/mocks/Pressable.d.ts.map +1 -0
  185. package/lib/typescript/{mocks.d.ts → mocks/mocks.d.ts} +5 -4
  186. package/lib/typescript/mocks/mocks.d.ts.map +1 -0
  187. package/lib/typescript/mountRegistry.d.ts +1 -0
  188. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +1 -0
  189. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +1 -0
  190. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +1 -0
  191. package/lib/typescript/typeUtils.d.ts +1 -0
  192. package/lib/typescript/utils.d.ts +1 -0
  193. package/lib/typescript/web/Gestures.d.ts +1 -0
  194. package/lib/typescript/web/constants.d.ts +1 -0
  195. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +1 -0
  196. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +1 -0
  197. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +1 -0
  198. package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
  199. package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
  200. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -0
  201. package/lib/typescript/web/handlers/IGestureHandler.d.ts +1 -0
  202. package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +1 -0
  203. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -0
  204. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -0
  205. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +1 -0
  206. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -0
  207. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -0
  208. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +1 -0
  209. package/lib/typescript/web/interfaces.d.ts +1 -0
  210. package/lib/typescript/web/tools/CircularBuffer.d.ts +1 -0
  211. package/lib/typescript/web/tools/EventManager.d.ts +1 -0
  212. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +1 -0
  213. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +1 -0
  214. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +1 -0
  215. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts.map +1 -1
  216. package/lib/typescript/web/tools/InteractionManager.d.ts +1 -0
  217. package/lib/typescript/web/tools/KeyboardEventManager.d.ts +7 -3
  218. package/lib/typescript/web/tools/KeyboardEventManager.d.ts.map +1 -1
  219. package/lib/typescript/web/tools/LeastSquareSolver.d.ts +1 -0
  220. package/lib/typescript/web/tools/NodeManager.d.ts +1 -0
  221. package/lib/typescript/web/tools/PointerEventManager.d.ts +1 -0
  222. package/lib/typescript/web/tools/PointerTracker.d.ts +1 -0
  223. package/lib/typescript/web/tools/Vector.d.ts +1 -0
  224. package/lib/typescript/web/tools/VelocityTracker.d.ts +1 -0
  225. package/lib/typescript/web/tools/WheelEventManager.d.ts +1 -0
  226. package/lib/typescript/web/utils.d.ts +1 -0
  227. package/lib/typescript/web_hammer/DiscreteGestureHandler.d.ts +1 -0
  228. package/lib/typescript/web_hammer/DraggingGestureHandler.d.ts +1 -0
  229. package/lib/typescript/web_hammer/Errors.d.ts +1 -0
  230. package/lib/typescript/web_hammer/FlingGestureHandler.d.ts +1 -0
  231. package/lib/typescript/web_hammer/GestureHandler.d.ts +1 -0
  232. package/lib/typescript/web_hammer/IndiscreteGestureHandler.d.ts +1 -0
  233. package/lib/typescript/web_hammer/LongPressGestureHandler.d.ts +1 -0
  234. package/lib/typescript/web_hammer/NativeViewGestureHandler.d.ts +1 -0
  235. package/lib/typescript/web_hammer/NodeManager.d.ts +1 -0
  236. package/lib/typescript/web_hammer/PanGestureHandler.d.ts +1 -0
  237. package/lib/typescript/web_hammer/PinchGestureHandler.d.ts +1 -0
  238. package/lib/typescript/web_hammer/PressGestureHandler.d.ts +1 -0
  239. package/lib/typescript/web_hammer/RotationGestureHandler.d.ts +1 -0
  240. package/lib/typescript/web_hammer/TapGestureHandler.d.ts +1 -0
  241. package/lib/typescript/web_hammer/constants.d.ts +1 -0
  242. package/lib/typescript/web_hammer/utils.d.ts +1 -0
  243. package/package.json +4 -3
  244. package/scripts/gesture_handler_utils.rb +25 -0
  245. package/src/components/GestureButtonsProps.ts +10 -0
  246. package/src/components/Pressable/Pressable.tsx +20 -31
  247. package/src/components/Pressable/PressableProps.tsx +2 -4
  248. package/src/components/Pressable/StateMachine.tsx +12 -4
  249. package/src/components/Pressable/stateDefinitions.ts +23 -23
  250. package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +603 -0
  251. package/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +199 -0
  252. package/src/components/ReanimatedSwipeable/index.ts +6 -0
  253. package/src/components/gestureHandlerRootHOC.tsx +4 -0
  254. package/src/handlers/createHandler.tsx +1 -1
  255. package/src/handlers/gestures/GestureDetector/index.tsx +1 -1
  256. package/src/mocks/Pressable.tsx +1 -0
  257. package/src/{mocks.tsx → mocks/mocks.tsx} +7 -11
  258. package/src/web/handlers/GestureHandler.ts +8 -3
  259. package/src/web/tools/GestureHandlerWebDelegate.ts +0 -5
  260. package/src/web/tools/KeyboardEventManager.ts +50 -8
  261. package/lib/commonjs/components/ReanimatedSwipeable.js.map +0 -1
  262. package/lib/commonjs/mocks.js.map +0 -1
  263. package/lib/module/components/ReanimatedSwipeable.js.map +0 -1
  264. package/lib/module/mocks.js.map +0 -1
  265. package/lib/typescript/ActionType.js +0 -6
  266. package/lib/typescript/Directions.js +0 -18
  267. package/lib/typescript/EnableNewWebImplementation.js +0 -30
  268. package/lib/typescript/GestureHandlerRootViewContext.js +0 -2
  269. package/lib/typescript/PlatformConstants.js +0 -3
  270. package/lib/typescript/PlatformConstants.web.js +0 -5
  271. package/lib/typescript/PointerType.js +0 -8
  272. package/lib/typescript/RNGestureHandlerModule.js +0 -4
  273. package/lib/typescript/RNGestureHandlerModule.web.js +0 -92
  274. package/lib/typescript/RNGestureHandlerModule.windows.js +0 -47
  275. package/lib/typescript/RNRenderer.js +0 -3
  276. package/lib/typescript/RNRenderer.web.js +0 -3
  277. package/lib/typescript/State.js +0 -9
  278. package/lib/typescript/TouchEventType.js +0 -7
  279. package/lib/typescript/components/DrawerLayout.js +0 -417
  280. package/lib/typescript/components/GestureButtons.js +0 -165
  281. package/lib/typescript/components/GestureButtonsProps.js +0 -1
  282. package/lib/typescript/components/GestureComponents.js +0 -67
  283. package/lib/typescript/components/GestureComponents.web.js +0 -21
  284. package/lib/typescript/components/GestureHandlerButton.js +0 -2
  285. package/lib/typescript/components/GestureHandlerButton.web.js +0 -3
  286. package/lib/typescript/components/GestureHandlerRootView.android.js +0 -17
  287. package/lib/typescript/components/GestureHandlerRootView.js +0 -16
  288. package/lib/typescript/components/GestureHandlerRootView.web.js +0 -11
  289. package/lib/typescript/components/Pressable/Pressable.js +0 -231
  290. package/lib/typescript/components/Pressable/PressableProps.js +0 -1
  291. package/lib/typescript/components/Pressable/StateMachine.js +0 -34
  292. package/lib/typescript/components/Pressable/index.js +0 -1
  293. package/lib/typescript/components/Pressable/stateDefinitions.js +0 -104
  294. package/lib/typescript/components/Pressable/utils.js +0 -80
  295. package/lib/typescript/components/ReanimatedDrawerLayout.js +0 -364
  296. package/lib/typescript/components/ReanimatedSwipeable.d.ts.map +0 -1
  297. package/lib/typescript/components/ReanimatedSwipeable.js +0 -400
  298. package/lib/typescript/components/Swipeable.js +0 -287
  299. package/lib/typescript/components/Text.js +0 -38
  300. package/lib/typescript/components/gestureHandlerRootHOC.js +0 -18
  301. package/lib/typescript/components/touchables/ExtraButtonProps.js +0 -1
  302. package/lib/typescript/components/touchables/GenericTouchable.js +0 -221
  303. package/lib/typescript/components/touchables/GenericTouchableProps.js +0 -1
  304. package/lib/typescript/components/touchables/TouchableHighlight.js +0 -75
  305. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.js +0 -65
  306. package/lib/typescript/components/touchables/TouchableNativeFeedback.js +0 -6
  307. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.js +0 -1
  308. package/lib/typescript/components/touchables/TouchableOpacity.js +0 -51
  309. package/lib/typescript/components/touchables/TouchableWithoutFeedback.js +0 -10
  310. package/lib/typescript/components/touchables/index.js +0 -4
  311. package/lib/typescript/components/utils.js +0 -11
  312. package/lib/typescript/findNodeHandle.js +0 -2
  313. package/lib/typescript/findNodeHandle.web.js +0 -31
  314. package/lib/typescript/getShadowNodeFromRef.js +0 -45
  315. package/lib/typescript/getShadowNodeFromRef.web.js +0 -7
  316. package/lib/typescript/ghQueueMicrotask.js +0 -7
  317. package/lib/typescript/handlers/FlingGestureHandler.js +0 -19
  318. package/lib/typescript/handlers/ForceTouchGestureHandler.js +0 -37
  319. package/lib/typescript/handlers/GestureHandlerEventPayload.js +0 -1
  320. package/lib/typescript/handlers/LongPressGestureHandler.js +0 -22
  321. package/lib/typescript/handlers/NativeViewGestureHandler.js +0 -20
  322. package/lib/typescript/handlers/PanGestureHandler.js +0 -128
  323. package/lib/typescript/handlers/PinchGestureHandler.js +0 -12
  324. package/lib/typescript/handlers/PressabilityDebugView.js +0 -2
  325. package/lib/typescript/handlers/PressabilityDebugView.web.js +0 -4
  326. package/lib/typescript/handlers/RotationGestureHandler.js +0 -12
  327. package/lib/typescript/handlers/TapGestureHandler.js +0 -26
  328. package/lib/typescript/handlers/createHandler.js +0 -375
  329. package/lib/typescript/handlers/createNativeWrapper.js +0 -67
  330. package/lib/typescript/handlers/customDirectEventTypes.js +0 -2
  331. package/lib/typescript/handlers/customDirectEventTypes.web.js +0 -4
  332. package/lib/typescript/handlers/gestureHandlerCommon.js +0 -42
  333. package/lib/typescript/handlers/gestureHandlerTypesCompat.js +0 -1
  334. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.js +0 -22
  335. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.js +0 -24
  336. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.js +0 -55
  337. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.js +0 -12
  338. package/lib/typescript/handlers/gestures/GestureDetector/index.js +0 -114
  339. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.js +0 -18
  340. package/lib/typescript/handlers/gestures/GestureDetector/types.js +0 -1
  341. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.js +0 -54
  342. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.js +0 -137
  343. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.js +0 -48
  344. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.js +0 -35
  345. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.js +0 -32
  346. package/lib/typescript/handlers/gestures/GestureDetector/utils.js +0 -140
  347. package/lib/typescript/handlers/gestures/eventReceiver.js +0 -105
  348. package/lib/typescript/handlers/gestures/flingGesture.js +0 -27
  349. package/lib/typescript/handlers/gestures/forceTouchGesture.js +0 -57
  350. package/lib/typescript/handlers/gestures/gesture.js +0 -303
  351. package/lib/typescript/handlers/gestures/gestureComposition.js +0 -78
  352. package/lib/typescript/handlers/gestures/gestureObjects.js +0 -125
  353. package/lib/typescript/handlers/gestures/gestureStateManager.js +0 -60
  354. package/lib/typescript/handlers/gestures/gestureStateManager.web.js +0 -19
  355. package/lib/typescript/handlers/gestures/hoverGesture.js +0 -45
  356. package/lib/typescript/handlers/gestures/longPressGesture.js +0 -35
  357. package/lib/typescript/handlers/gestures/manualGesture.js +0 -16
  358. package/lib/typescript/handlers/gestures/nativeGesture.js +0 -24
  359. package/lib/typescript/handlers/gestures/panGesture.js +0 -181
  360. package/lib/typescript/handlers/gestures/pinchGesture.js +0 -27
  361. package/lib/typescript/handlers/gestures/reanimatedWrapper.js +0 -23
  362. package/lib/typescript/handlers/gestures/rotationGesture.js +0 -27
  363. package/lib/typescript/handlers/gestures/tapGesture.js +0 -72
  364. package/lib/typescript/handlers/getNextHandlerTag.js +0 -4
  365. package/lib/typescript/handlers/handlersRegistry.js +0 -36
  366. package/lib/typescript/handlers/utils.js +0 -58
  367. package/lib/typescript/index.js +0 -28
  368. package/lib/typescript/init.js +0 -15
  369. package/lib/typescript/jestUtils/index.js +0 -1
  370. package/lib/typescript/jestUtils/jestUtils.js +0 -290
  371. package/lib/typescript/mocks.d.ts.map +0 -1
  372. package/lib/typescript/mocks.js +0 -59
  373. package/lib/typescript/mountRegistry.js +0 -29
  374. package/lib/typescript/specs/NativeRNGestureHandlerModule.js +0 -2
  375. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.js +0 -2
  376. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.js +0 -2
  377. package/lib/typescript/typeUtils.js +0 -1
  378. package/lib/typescript/utils.js +0 -80
  379. package/lib/typescript/web/Gestures.js +0 -38
  380. package/lib/typescript/web/constants.js +0 -2
  381. package/lib/typescript/web/detectors/RotationGestureDetector.js +0 -122
  382. package/lib/typescript/web/detectors/ScaleGestureDetector.js +0 -117
  383. package/lib/typescript/web/handlers/FlingGestureHandler.js +0 -133
  384. package/lib/typescript/web/handlers/GestureHandler.js +0 -656
  385. package/lib/typescript/web/handlers/HoverGestureHandler.js +0 -37
  386. package/lib/typescript/web/handlers/IGestureHandler.js +0 -1
  387. package/lib/typescript/web/handlers/LongPressGestureHandler.js +0 -136
  388. package/lib/typescript/web/handlers/ManualGestureHandler.js +0 -29
  389. package/lib/typescript/web/handlers/NativeViewGestureHandler.js +0 -133
  390. package/lib/typescript/web/handlers/PanGestureHandler.js +0 -420
  391. package/lib/typescript/web/handlers/PinchGestureHandler.js +0 -117
  392. package/lib/typescript/web/handlers/RotationGestureHandler.js +0 -122
  393. package/lib/typescript/web/handlers/TapGestureHandler.js +0 -202
  394. package/lib/typescript/web/interfaces.js +0 -25
  395. package/lib/typescript/web/tools/CircularBuffer.js +0 -37
  396. package/lib/typescript/web/tools/EventManager.js +0 -85
  397. package/lib/typescript/web/tools/GestureHandlerDelegate.js +0 -1
  398. package/lib/typescript/web/tools/GestureHandlerOrchestrator.js +0 -273
  399. package/lib/typescript/web/tools/GestureHandlerWebDelegate.js +0 -169
  400. package/lib/typescript/web/tools/InteractionManager.js +0 -91
  401. package/lib/typescript/web/tools/KeyboardEventManager.js +0 -73
  402. package/lib/typescript/web/tools/LeastSquareSolver.js +0 -147
  403. package/lib/typescript/web/tools/NodeManager.js +0 -28
  404. package/lib/typescript/web/tools/PointerEventManager.js +0 -179
  405. package/lib/typescript/web/tools/PointerTracker.js +0 -161
  406. package/lib/typescript/web/tools/Vector.js +0 -43
  407. package/lib/typescript/web/tools/VelocityTracker.js +0 -76
  408. package/lib/typescript/web/tools/WheelEventManager.js +0 -40
  409. package/lib/typescript/web/utils.js +0 -233
  410. package/lib/typescript/web_hammer/DiscreteGestureHandler.js +0 -48
  411. package/lib/typescript/web_hammer/DraggingGestureHandler.js +0 -25
  412. package/lib/typescript/web_hammer/Errors.js +0 -5
  413. package/lib/typescript/web_hammer/FlingGestureHandler.js +0 -119
  414. package/lib/typescript/web_hammer/GestureHandler.js +0 -469
  415. package/lib/typescript/web_hammer/IndiscreteGestureHandler.js +0 -26
  416. package/lib/typescript/web_hammer/LongPressGestureHandler.js +0 -46
  417. package/lib/typescript/web_hammer/NativeViewGestureHandler.js +0 -40
  418. package/lib/typescript/web_hammer/NodeManager.js +0 -28
  419. package/lib/typescript/web_hammer/PanGestureHandler.js +0 -151
  420. package/lib/typescript/web_hammer/PinchGestureHandler.js +0 -19
  421. package/lib/typescript/web_hammer/PressGestureHandler.js +0 -133
  422. package/lib/typescript/web_hammer/RotationGestureHandler.js +0 -20
  423. package/lib/typescript/web_hammer/TapGestureHandler.js +0 -142
  424. package/lib/typescript/web_hammer/constants.js +0 -42
  425. package/lib/typescript/web_hammer/utils.js +0 -15
  426. package/src/components/ReanimatedSwipeable.tsx +0 -811
@@ -1,37 +0,0 @@
1
- import React from 'react';
2
- import { tagMessage } from '../utils';
3
- import PlatformConstants from '../PlatformConstants';
4
- import createHandler from './createHandler';
5
- import { baseGestureHandlerProps, } from './gestureHandlerCommon';
6
- export const forceTouchGestureHandlerProps = [
7
- 'minForce',
8
- 'maxForce',
9
- 'feedbackOnActivation',
10
- ];
11
- // implicit `children` prop has been removed in @types/react^18.0.0
12
- class ForceTouchFallback extends React.Component {
13
- static forceTouchAvailable = false;
14
- componentDidMount() {
15
- console.warn(tagMessage('ForceTouchGestureHandler is not available on this platform. Please use ForceTouchGestureHandler.forceTouchAvailable to conditionally render other components that would provide a fallback behavior specific to your usecase'));
16
- }
17
- render() {
18
- return this.props.children;
19
- }
20
- }
21
- export const forceTouchHandlerName = 'ForceTouchGestureHandler';
22
- /**
23
- * @deprecated ForceTouchGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.ForceTouch()` instead.
24
- */
25
- // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
26
- export const ForceTouchGestureHandler = PlatformConstants?.forceTouchAvailable
27
- ? createHandler({
28
- name: forceTouchHandlerName,
29
- allowedProps: [
30
- ...baseGestureHandlerProps,
31
- ...forceTouchGestureHandlerProps,
32
- ],
33
- config: {},
34
- })
35
- : ForceTouchFallback;
36
- ForceTouchGestureHandler.forceTouchAvailable =
37
- PlatformConstants?.forceTouchAvailable || false;
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- import createHandler from './createHandler';
2
- import { baseGestureHandlerProps, } from './gestureHandlerCommon';
3
- export const longPressGestureHandlerProps = [
4
- 'minDurationMs',
5
- 'maxDist',
6
- 'numberOfPointers',
7
- ];
8
- export const longPressHandlerName = 'LongPressGestureHandler';
9
- /**
10
- * @deprecated LongPressGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.LongPress()` instead.
11
- */
12
- // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
13
- export const LongPressGestureHandler = createHandler({
14
- name: longPressHandlerName,
15
- allowedProps: [
16
- ...baseGestureHandlerProps,
17
- ...longPressGestureHandlerProps,
18
- ],
19
- config: {
20
- shouldCancelWhenOutside: true,
21
- },
22
- });
@@ -1,20 +0,0 @@
1
- import createHandler from './createHandler';
2
- import { baseGestureHandlerProps, } from './gestureHandlerCommon';
3
- export const nativeViewGestureHandlerProps = [
4
- 'shouldActivateOnStart',
5
- 'disallowInterruption',
6
- ];
7
- export const nativeViewProps = [
8
- ...baseGestureHandlerProps,
9
- ...nativeViewGestureHandlerProps,
10
- ];
11
- export const nativeViewHandlerName = 'NativeViewGestureHandler';
12
- /**
13
- * @deprecated NativeViewGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Native()` instead.
14
- */
15
- // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
16
- export const NativeViewGestureHandler = createHandler({
17
- name: nativeViewHandlerName,
18
- allowedProps: nativeViewProps,
19
- config: {},
20
- });
@@ -1,128 +0,0 @@
1
- import createHandler from './createHandler';
2
- import { baseGestureHandlerProps, } from './gestureHandlerCommon';
3
- export const panGestureHandlerProps = [
4
- 'activeOffsetY',
5
- 'activeOffsetX',
6
- 'failOffsetY',
7
- 'failOffsetX',
8
- 'minDist',
9
- 'minVelocity',
10
- 'minVelocityX',
11
- 'minVelocityY',
12
- 'minPointers',
13
- 'maxPointers',
14
- 'avgTouches',
15
- 'enableTrackpadTwoFingerGesture',
16
- 'activateAfterLongPress',
17
- ];
18
- export const panGestureHandlerCustomNativeProps = [
19
- 'activeOffsetYStart',
20
- 'activeOffsetYEnd',
21
- 'activeOffsetXStart',
22
- 'activeOffsetXEnd',
23
- 'failOffsetYStart',
24
- 'failOffsetYEnd',
25
- 'failOffsetXStart',
26
- 'failOffsetXEnd',
27
- ];
28
- export const panHandlerName = 'PanGestureHandler';
29
- /**
30
- * @deprecated PanGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Pan()` instead.
31
- */
32
- // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
33
- export const PanGestureHandler = createHandler({
34
- name: panHandlerName,
35
- allowedProps: [
36
- ...baseGestureHandlerProps,
37
- ...panGestureHandlerProps,
38
- ],
39
- config: {},
40
- transformProps: managePanProps,
41
- customNativeProps: panGestureHandlerCustomNativeProps,
42
- });
43
- function validatePanGestureHandlerProps(props) {
44
- if (Array.isArray(props.activeOffsetX) &&
45
- (props.activeOffsetX[0] > 0 || props.activeOffsetX[1] < 0)) {
46
- throw new Error(`First element of activeOffsetX should be negative, a the second one should be positive`);
47
- }
48
- if (Array.isArray(props.activeOffsetY) &&
49
- (props.activeOffsetY[0] > 0 || props.activeOffsetY[1] < 0)) {
50
- throw new Error(`First element of activeOffsetY should be negative, a the second one should be positive`);
51
- }
52
- if (Array.isArray(props.failOffsetX) &&
53
- (props.failOffsetX[0] > 0 || props.failOffsetX[1] < 0)) {
54
- throw new Error(`First element of failOffsetX should be negative, a the second one should be positive`);
55
- }
56
- if (Array.isArray(props.failOffsetY) &&
57
- (props.failOffsetY[0] > 0 || props.failOffsetY[1] < 0)) {
58
- throw new Error(`First element of failOffsetY should be negative, a the second one should be positive`);
59
- }
60
- if (props.minDist && (props.failOffsetX || props.failOffsetY)) {
61
- throw new Error(`It is not supported to use minDist with failOffsetX or failOffsetY, use activeOffsetX and activeOffsetY instead`);
62
- }
63
- if (props.minDist && (props.activeOffsetX || props.activeOffsetY)) {
64
- throw new Error(`It is not supported to use minDist with activeOffsetX or activeOffsetY`);
65
- }
66
- }
67
- function transformPanGestureHandlerProps(props) {
68
- const res = { ...props };
69
- if (props.activeOffsetX !== undefined) {
70
- delete res.activeOffsetX;
71
- if (Array.isArray(props.activeOffsetX)) {
72
- res.activeOffsetXStart = props.activeOffsetX[0];
73
- res.activeOffsetXEnd = props.activeOffsetX[1];
74
- }
75
- else if (props.activeOffsetX < 0) {
76
- res.activeOffsetXStart = props.activeOffsetX;
77
- }
78
- else {
79
- res.activeOffsetXEnd = props.activeOffsetX;
80
- }
81
- }
82
- if (props.activeOffsetY !== undefined) {
83
- delete res.activeOffsetY;
84
- if (Array.isArray(props.activeOffsetY)) {
85
- res.activeOffsetYStart = props.activeOffsetY[0];
86
- res.activeOffsetYEnd = props.activeOffsetY[1];
87
- }
88
- else if (props.activeOffsetY < 0) {
89
- res.activeOffsetYStart = props.activeOffsetY;
90
- }
91
- else {
92
- res.activeOffsetYEnd = props.activeOffsetY;
93
- }
94
- }
95
- if (props.failOffsetX !== undefined) {
96
- delete res.failOffsetX;
97
- if (Array.isArray(props.failOffsetX)) {
98
- res.failOffsetXStart = props.failOffsetX[0];
99
- res.failOffsetXEnd = props.failOffsetX[1];
100
- }
101
- else if (props.failOffsetX < 0) {
102
- res.failOffsetXStart = props.failOffsetX;
103
- }
104
- else {
105
- res.failOffsetXEnd = props.failOffsetX;
106
- }
107
- }
108
- if (props.failOffsetY !== undefined) {
109
- delete res.failOffsetY;
110
- if (Array.isArray(props.failOffsetY)) {
111
- res.failOffsetYStart = props.failOffsetY[0];
112
- res.failOffsetYEnd = props.failOffsetY[1];
113
- }
114
- else if (props.failOffsetY < 0) {
115
- res.failOffsetYStart = props.failOffsetY;
116
- }
117
- else {
118
- res.failOffsetYEnd = props.failOffsetY;
119
- }
120
- }
121
- return res;
122
- }
123
- export function managePanProps(props) {
124
- if (__DEV__) {
125
- validatePanGestureHandlerProps(props);
126
- }
127
- return transformPanGestureHandlerProps(props);
128
- }
@@ -1,12 +0,0 @@
1
- import createHandler from './createHandler';
2
- import { baseGestureHandlerProps, } from './gestureHandlerCommon';
3
- export const pinchHandlerName = 'PinchGestureHandler';
4
- /**
5
- * @deprecated PinchGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Pinch()` instead.
6
- */
7
- // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
8
- export const PinchGestureHandler = createHandler({
9
- name: pinchHandlerName,
10
- allowedProps: baseGestureHandlerProps,
11
- config: {},
12
- });
@@ -1,2 +0,0 @@
1
- // @ts-ignore it's not exported so we need to import it from path
2
- export { PressabilityDebugView } from 'react-native/Libraries/Pressability/PressabilityDebug';
@@ -1,4 +0,0 @@
1
- // PressabilityDebugView is not implemented in react-native-web
2
- export function PressabilityDebugView() {
3
- return null;
4
- }
@@ -1,12 +0,0 @@
1
- import createHandler from './createHandler';
2
- import { baseGestureHandlerProps, } from './gestureHandlerCommon';
3
- export const rotationHandlerName = 'RotationGestureHandler';
4
- /**
5
- * @deprecated RotationGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Rotation()` instead.
6
- */
7
- // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
8
- export const RotationGestureHandler = createHandler({
9
- name: rotationHandlerName,
10
- allowedProps: baseGestureHandlerProps,
11
- config: {},
12
- });
@@ -1,26 +0,0 @@
1
- import createHandler from './createHandler';
2
- import { baseGestureHandlerProps, } from './gestureHandlerCommon';
3
- export const tapGestureHandlerProps = [
4
- 'maxDurationMs',
5
- 'maxDelayMs',
6
- 'numberOfTaps',
7
- 'maxDeltaX',
8
- 'maxDeltaY',
9
- 'maxDist',
10
- 'minPointers',
11
- ];
12
- export const tapHandlerName = 'TapGestureHandler';
13
- /**
14
- * @deprecated TapGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Tap()` instead.
15
- */
16
- // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
17
- export const TapGestureHandler = createHandler({
18
- name: tapHandlerName,
19
- allowedProps: [
20
- ...baseGestureHandlerProps,
21
- ...tapGestureHandlerProps,
22
- ],
23
- config: {
24
- shouldCancelWhenOutside: true,
25
- },
26
- });
@@ -1,375 +0,0 @@
1
- import * as React from 'react';
2
- import { Platform, UIManager, DeviceEventEmitter, } from 'react-native';
3
- import { customDirectEventTypes } from './customDirectEventTypes';
4
- import RNGestureHandlerModule from '../RNGestureHandlerModule';
5
- import { State } from '../State';
6
- import { handlerIDToTag, registerOldGestureHandler, unregisterOldGestureHandler, } from './handlersRegistry';
7
- import { getNextHandlerTag } from './getNextHandlerTag';
8
- import { filterConfig, scheduleFlushOperations } from './utils';
9
- import findNodeHandle from '../findNodeHandle';
10
- import { deepEqual, isFabric, isReact19, isTestEnv, tagMessage, } from '../utils';
11
- import { ActionType } from '../ActionType';
12
- import { PressabilityDebugView } from './PressabilityDebugView';
13
- import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
14
- import { ghQueueMicrotask } from '../ghQueueMicrotask';
15
- import { MountRegistry } from '../mountRegistry';
16
- const UIManagerAny = UIManager;
17
- customDirectEventTypes.topGestureHandlerEvent = {
18
- registrationName: 'onGestureHandlerEvent',
19
- };
20
- const customGHEventsConfigFabricAndroid = {
21
- topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },
22
- topOnGestureHandlerStateChange: {
23
- registrationName: 'onGestureHandlerStateChange',
24
- },
25
- };
26
- const customGHEventsConfig = {
27
- onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },
28
- onGestureHandlerStateChange: {
29
- registrationName: 'onGestureHandlerStateChange',
30
- },
31
- // When using React Native Gesture Handler for Animated.event with useNativeDriver: true
32
- // on Android with Fabric enabled, the native part still sends the native events to JS
33
- // but prefixed with "top". We cannot simply rename the events above so they are prefixed
34
- // with "top" instead of "on" because in such case Animated.events would not be registered.
35
- // That's why we need to register another pair of event names.
36
- // The incoming events will be queued but never handled.
37
- // Without this piece of code below, you'll get the following JS error:
38
- // Unsupported top level event type "topOnGestureHandlerEvent" dispatched
39
- ...(isFabric() &&
40
- Platform.OS === 'android' &&
41
- customGHEventsConfigFabricAndroid),
42
- };
43
- // Add gesture specific events to genericDirectEventTypes object exported from UIManager
44
- // native module.
45
- // Once new event types are registered with react it is possible to dispatch these
46
- // events to all kind of native views.
47
- UIManagerAny.genericDirectEventTypes = {
48
- ...UIManagerAny.genericDirectEventTypes,
49
- ...customGHEventsConfig,
50
- };
51
- const UIManagerConstants = UIManagerAny.getViewManagerConfig?.('getConstants');
52
- if (UIManagerConstants) {
53
- UIManagerConstants.genericDirectEventTypes = {
54
- ...UIManagerConstants.genericDirectEventTypes,
55
- ...customGHEventsConfig,
56
- };
57
- }
58
- // Wrap JS responder calls and notify gesture handler manager
59
- const { setJSResponder: oldSetJSResponder = () => {
60
- // no-op
61
- }, clearJSResponder: oldClearJSResponder = () => {
62
- // no-op
63
- }, } = UIManagerAny;
64
- UIManagerAny.setJSResponder = (tag, blockNativeResponder) => {
65
- RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);
66
- oldSetJSResponder(tag, blockNativeResponder);
67
- };
68
- UIManagerAny.clearJSResponder = () => {
69
- RNGestureHandlerModule.handleClearJSResponder();
70
- oldClearJSResponder();
71
- };
72
- let allowTouches = true;
73
- const DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';
74
- // Toggled inspector blocks touch events in order to allow inspecting on Android
75
- // This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component
76
- if (DEV_ON_ANDROID) {
77
- DeviceEventEmitter.addListener('toggleElementInspector', () => {
78
- allowTouches = !allowTouches;
79
- });
80
- }
81
- function hasUnresolvedRefs(props) {
82
- // TODO(TS) - add type for extract arg
83
- const extract = (refs) => {
84
- if (!Array.isArray(refs)) {
85
- return refs && refs.current === null;
86
- }
87
- return refs.some((r) => r && r.current === null);
88
- };
89
- return extract(props['simultaneousHandlers']) || extract(props['waitFor']);
90
- }
91
- const stateToPropMappings = {
92
- [State.UNDETERMINED]: undefined,
93
- [State.BEGAN]: 'onBegan',
94
- [State.FAILED]: 'onFailed',
95
- [State.CANCELLED]: 'onCancelled',
96
- [State.ACTIVE]: 'onActivated',
97
- [State.END]: 'onEnded',
98
- };
99
- const UNRESOLVED_REFS_RETRY_LIMIT = 1;
100
- // TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
101
- export default function createHandler({ name, allowedProps = [], config = {}, transformProps, customNativeProps = [], }) {
102
- class Handler extends React.Component {
103
- static displayName = name;
104
- static contextType = GestureHandlerRootViewContext;
105
- handlerTag = -1;
106
- config;
107
- propsRef;
108
- isMountedRef;
109
- viewNode;
110
- viewTag;
111
- inspectorToggleListener;
112
- constructor(props) {
113
- super(props);
114
- this.config = {};
115
- this.propsRef = React.createRef();
116
- this.isMountedRef = React.createRef();
117
- this.state = { allowTouches };
118
- if (props.id) {
119
- if (handlerIDToTag[props.id] !== undefined) {
120
- throw new Error(`Handler with ID "${props.id}" already registered`);
121
- }
122
- handlerIDToTag[props.id] = this.handlerTag;
123
- }
124
- }
125
- componentDidMount() {
126
- const props = this.props;
127
- this.isMountedRef.current = true;
128
- if (DEV_ON_ANDROID) {
129
- this.inspectorToggleListener = DeviceEventEmitter.addListener('toggleElementInspector', () => {
130
- this.setState((_) => ({ allowTouches }));
131
- this.update(UNRESOLVED_REFS_RETRY_LIMIT);
132
- });
133
- }
134
- if (hasUnresolvedRefs(props)) {
135
- // If there are unresolved refs (e.g. ".current" has not yet been set)
136
- // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to
137
- // _update method that will try to update native handler props using
138
- // queueMicrotask. This makes it so update() function gets called after all
139
- // react components are mounted and we expect the missing ref object to
140
- // be resolved by then.
141
- ghQueueMicrotask(() => {
142
- this.update(UNRESOLVED_REFS_RETRY_LIMIT);
143
- });
144
- }
145
- this.createGestureHandler(filterConfig(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config));
146
- if (!this.viewNode) {
147
- throw new Error(`[Gesture Handler] Failed to obtain view for ${Handler.displayName}. Note that old API doesn't support functional components.`);
148
- }
149
- this.attachGestureHandler(findNodeHandle(this.viewNode)); // TODO(TS) - check if this can be null
150
- }
151
- componentDidUpdate() {
152
- const viewTag = findNodeHandle(this.viewNode);
153
- if (this.viewTag !== viewTag) {
154
- this.attachGestureHandler(viewTag); // TODO(TS) - check interaction between _viewTag & findNodeHandle
155
- }
156
- this.update(UNRESOLVED_REFS_RETRY_LIMIT);
157
- }
158
- componentWillUnmount() {
159
- this.inspectorToggleListener?.remove();
160
- this.isMountedRef.current = false;
161
- if (Platform.OS !== 'web') {
162
- unregisterOldGestureHandler(this.handlerTag);
163
- }
164
- RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
165
- scheduleFlushOperations();
166
- // 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
167
- const handlerID = this.props.id;
168
- if (handlerID) {
169
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
170
- delete handlerIDToTag[handlerID];
171
- }
172
- MountRegistry.gestureHandlerWillUnmount(this);
173
- }
174
- onGestureHandlerEvent = (event) => {
175
- if (event.nativeEvent.handlerTag === this.handlerTag) {
176
- if (typeof this.props.onGestureEvent === 'function') {
177
- this.props.onGestureEvent?.(event);
178
- }
179
- }
180
- else {
181
- this.props.onGestureHandlerEvent?.(event);
182
- }
183
- };
184
- // TODO(TS) - make sure this is right type for event
185
- onGestureHandlerStateChange = (event) => {
186
- if (event.nativeEvent.handlerTag === this.handlerTag) {
187
- if (typeof this.props.onHandlerStateChange === 'function') {
188
- this.props.onHandlerStateChange?.(event);
189
- }
190
- const state = event.nativeEvent.state;
191
- const stateEventName = stateToPropMappings[state];
192
- const eventHandler = stateEventName && this.props[stateEventName];
193
- if (eventHandler && typeof eventHandler === 'function') {
194
- eventHandler(event);
195
- }
196
- }
197
- else {
198
- this.props.onGestureHandlerStateChange?.(event);
199
- }
200
- };
201
- refHandler = (node) => {
202
- this.viewNode = node;
203
- const child = React.Children.only(this.props.children);
204
- // @ts-ignore Since React 19 ref is accessible as standard prop
205
- // https://react.dev/blog/2024/04/25/react-19-upgrade-guide#deprecated-element-ref
206
- const ref = isReact19() ? child.props?.ref : child?.ref;
207
- if (!ref) {
208
- return;
209
- }
210
- if (typeof ref === 'function') {
211
- ref(node);
212
- }
213
- else {
214
- ref.current = node;
215
- }
216
- };
217
- createGestureHandler = (newConfig) => {
218
- this.handlerTag = getNextHandlerTag();
219
- this.config = newConfig;
220
- RNGestureHandlerModule.createGestureHandler(name, this.handlerTag, newConfig);
221
- };
222
- attachGestureHandler = (newViewTag) => {
223
- this.viewTag = newViewTag;
224
- if (Platform.OS === 'web') {
225
- // Typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch
226
- RNGestureHandlerModule.attachGestureHandler(this.handlerTag, newViewTag, ActionType.JS_FUNCTION_OLD_API, // ignored on web
227
- this.propsRef);
228
- }
229
- else {
230
- registerOldGestureHandler(this.handlerTag, {
231
- onGestureEvent: this.onGestureHandlerEvent,
232
- onGestureStateChange: this.onGestureHandlerStateChange,
233
- });
234
- const actionType = (() => {
235
- const onGestureEvent = this.props?.onGestureEvent;
236
- const isGestureHandlerWorklet = onGestureEvent &&
237
- ('current' in onGestureEvent ||
238
- 'workletEventHandler' in onGestureEvent);
239
- const onHandlerStateChange = this.props?.onHandlerStateChange;
240
- const isStateChangeHandlerWorklet = onHandlerStateChange &&
241
- ('current' in onHandlerStateChange ||
242
- 'workletEventHandler' in onHandlerStateChange);
243
- const isReanimatedHandler = isGestureHandlerWorklet || isStateChangeHandlerWorklet;
244
- if (isReanimatedHandler) {
245
- // Reanimated worklet
246
- return ActionType.REANIMATED_WORKLET;
247
- }
248
- else if (onGestureEvent && '__isNative' in onGestureEvent) {
249
- // Animated.event with useNativeDriver: true
250
- return ActionType.NATIVE_ANIMATED_EVENT;
251
- }
252
- else {
253
- // JS callback or Animated.event with useNativeDriver: false
254
- return ActionType.JS_FUNCTION_OLD_API;
255
- }
256
- })();
257
- RNGestureHandlerModule.attachGestureHandler(this.handlerTag, newViewTag, actionType);
258
- }
259
- scheduleFlushOperations();
260
- ghQueueMicrotask(() => {
261
- MountRegistry.gestureHandlerWillMount(this);
262
- });
263
- };
264
- updateGestureHandler = (newConfig) => {
265
- this.config = newConfig;
266
- RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);
267
- scheduleFlushOperations();
268
- };
269
- update(remainingTries) {
270
- if (!this.isMountedRef.current) {
271
- return;
272
- }
273
- const props = this.props;
274
- // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of
275
- // `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying
276
- // again is easy enough fix.
277
- if (hasUnresolvedRefs(props) && remainingTries > 0) {
278
- ghQueueMicrotask(() => {
279
- this.update(remainingTries - 1);
280
- });
281
- }
282
- else {
283
- const newConfig = filterConfig(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config);
284
- if (!deepEqual(this.config, newConfig)) {
285
- this.updateGestureHandler(newConfig);
286
- }
287
- }
288
- }
289
- // eslint-disable-next-line @eslint-react/no-unused-class-component-members
290
- setNativeProps(updates) {
291
- const mergedProps = { ...this.props, ...updates };
292
- const newConfig = filterConfig(transformProps ? transformProps(mergedProps) : mergedProps, [...allowedProps, ...customNativeProps], config);
293
- this.updateGestureHandler(newConfig);
294
- }
295
- render() {
296
- if (__DEV__ && !this.context && !isTestEnv() && Platform.OS !== 'web') {
297
- throw new Error(name +
298
- ' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.');
299
- }
300
- let gestureEventHandler = this.onGestureHandlerEvent;
301
- const { onGestureEvent, onGestureHandlerEvent } = this.props;
302
- if (onGestureEvent && typeof onGestureEvent !== 'function') {
303
- // If it's not a method it should be an native Animated.event
304
- // object. We set it directly as the handler for the view
305
- // In this case nested handlers are not going to be supported
306
- if (onGestureHandlerEvent) {
307
- throw new Error('Nesting touch handlers with native animated driver is not supported yet');
308
- }
309
- gestureEventHandler = onGestureEvent;
310
- }
311
- else {
312
- if (onGestureHandlerEvent &&
313
- typeof onGestureHandlerEvent !== 'function') {
314
- throw new Error('Nesting touch handlers with native animated driver is not supported yet');
315
- }
316
- }
317
- let gestureStateEventHandler = this.onGestureHandlerStateChange;
318
- const { onHandlerStateChange, onGestureHandlerStateChange, } = this.props;
319
- if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {
320
- // If it's not a method it should be an native Animated.event
321
- // object. We set it directly as the handler for the view
322
- // In this case nested handlers are not going to be supported
323
- if (onGestureHandlerStateChange) {
324
- throw new Error('Nesting touch handlers with native animated driver is not supported yet');
325
- }
326
- gestureStateEventHandler = onHandlerStateChange;
327
- }
328
- else {
329
- if (onGestureHandlerStateChange &&
330
- typeof onGestureHandlerStateChange !== 'function') {
331
- throw new Error('Nesting touch handlers with native animated driver is not supported yet');
332
- }
333
- }
334
- const events = {
335
- onGestureHandlerEvent: this.state.allowTouches
336
- ? gestureEventHandler
337
- : undefined,
338
- onGestureHandlerStateChange: this.state.allowTouches
339
- ? gestureStateEventHandler
340
- : undefined,
341
- };
342
- this.propsRef.current = events;
343
- let child = null;
344
- try {
345
- child = React.Children.only(this.props.children);
346
- }
347
- catch (e) {
348
- throw new Error(tagMessage(`${name} got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`));
349
- }
350
- let grandChildren = child.props.children;
351
- if (__DEV__ &&
352
- child.type &&
353
- (child.type === 'RNGestureHandlerButton' ||
354
- child.type.name === 'View' ||
355
- child.type.displayName === 'View')) {
356
- grandChildren = React.Children.toArray(grandChildren);
357
- grandChildren.push(<PressabilityDebugView key="pressabilityDebugView" color="mediumspringgreen" hitSlop={child.props.hitSlop}/>);
358
- }
359
- return React.cloneElement(child, {
360
- ref: this.refHandler,
361
- collapsable: false,
362
- ...(isTestEnv()
363
- ? {
364
- handlerType: name,
365
- handlerTag: this.handlerTag,
366
- enabled: this.props.enabled,
367
- }
368
- : {}),
369
- testID: this.props.testID ?? child.props.testID,
370
- ...events,
371
- }, grandChildren);
372
- }
373
- }
374
- return Handler;
375
- }