react-native-gesture-handler 2.27.1 → 2.27.2

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 (394) hide show
  1. package/ReanimatedSwipeable/package.json +4 -4
  2. package/android/build.gradle +8 -1
  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/apple/RNGestureHandler.h +4 -0
  6. package/apple/RNGestureHandler.mm +41 -6
  7. package/jestSetup.js +22 -3
  8. package/lib/commonjs/components/Pressable/Pressable.js +12 -21
  9. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  10. package/lib/commonjs/components/Pressable/StateMachine.js +8 -2
  11. package/lib/commonjs/components/Pressable/StateMachine.js.map +1 -1
  12. package/lib/commonjs/components/Pressable/stateDefinitions.js +22 -23
  13. package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -1
  14. package/lib/commonjs/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +30 -39
  15. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
  16. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +12 -0
  17. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
  18. package/lib/commonjs/components/ReanimatedSwipeable/index.js +21 -0
  19. package/lib/commonjs/components/ReanimatedSwipeable/index.js.map +1 -0
  20. package/lib/commonjs/mocks/Pressable.js +13 -0
  21. package/lib/commonjs/mocks/Pressable.js.map +1 -0
  22. package/lib/commonjs/{mocks.js → mocks/mocks.js} +8 -11
  23. package/lib/commonjs/mocks/mocks.js.map +1 -0
  24. package/lib/commonjs/web/handlers/GestureHandler.js +1 -0
  25. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  26. package/lib/module/components/Pressable/Pressable.js +14 -23
  27. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  28. package/lib/module/components/Pressable/StateMachine.js +8 -2
  29. package/lib/module/components/Pressable/StateMachine.js.map +1 -1
  30. package/lib/module/components/Pressable/stateDefinitions.js +21 -22
  31. package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
  32. package/lib/module/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +24 -33
  33. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
  34. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +8 -0
  35. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
  36. package/lib/module/components/ReanimatedSwipeable/index.js +5 -0
  37. package/lib/module/components/ReanimatedSwipeable/index.js.map +1 -0
  38. package/lib/module/mocks/Pressable.js +4 -0
  39. package/lib/module/mocks/Pressable.js.map +1 -0
  40. package/lib/module/{mocks.js → mocks/mocks.js} +7 -11
  41. package/lib/module/mocks/mocks.js.map +1 -0
  42. package/lib/module/web/handlers/GestureHandler.js +1 -0
  43. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  44. package/lib/typescript/ActionType.d.ts +1 -0
  45. package/lib/typescript/Directions.d.ts +1 -0
  46. package/lib/typescript/EnableNewWebImplementation.d.ts +1 -0
  47. package/lib/typescript/GestureHandlerRootViewContext.d.ts +1 -0
  48. package/lib/typescript/PlatformConstants.d.ts +1 -0
  49. package/lib/typescript/PlatformConstants.web.d.ts +1 -0
  50. package/lib/typescript/PointerType.d.ts +1 -0
  51. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
  52. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
  53. package/lib/typescript/RNGestureHandlerModule.windows.d.ts +1 -0
  54. package/lib/typescript/RNRenderer.d.ts +1 -0
  55. package/lib/typescript/RNRenderer.web.d.ts +1 -0
  56. package/lib/typescript/State.d.ts +1 -0
  57. package/lib/typescript/TouchEventType.d.ts +1 -0
  58. package/lib/typescript/components/DrawerLayout.d.ts +1 -0
  59. package/lib/typescript/components/GestureButtons.d.ts +1 -0
  60. package/lib/typescript/components/GestureButtonsProps.d.ts +10 -1
  61. package/lib/typescript/components/GestureButtonsProps.d.ts.map +1 -1
  62. package/lib/typescript/components/GestureComponents.d.ts +1 -0
  63. package/lib/typescript/components/GestureComponents.web.d.ts +1 -0
  64. package/lib/typescript/components/GestureHandlerButton.d.ts +1 -0
  65. package/lib/typescript/components/GestureHandlerButton.web.d.ts +1 -0
  66. package/lib/typescript/components/GestureHandlerRootView.android.d.ts +1 -0
  67. package/lib/typescript/components/GestureHandlerRootView.d.ts +1 -0
  68. package/lib/typescript/components/GestureHandlerRootView.web.d.ts +1 -0
  69. package/lib/typescript/components/Pressable/Pressable.d.ts +1 -0
  70. package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
  71. package/lib/typescript/components/Pressable/PressableProps.d.ts +3 -4
  72. package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
  73. package/lib/typescript/components/Pressable/StateMachine.d.ts +4 -2
  74. package/lib/typescript/components/Pressable/StateMachine.d.ts.map +1 -1
  75. package/lib/typescript/components/Pressable/index.d.ts +1 -0
  76. package/lib/typescript/components/Pressable/stateDefinitions.d.ts +3 -2
  77. package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
  78. package/lib/typescript/components/Pressable/utils.d.ts +1 -0
  79. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +1 -0
  80. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts +6 -0
  81. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -0
  82. package/lib/typescript/components/{ReanimatedSwipeable.d.ts → ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts} +10 -7
  83. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts.map +1 -0
  84. package/lib/typescript/components/ReanimatedSwipeable/index.d.ts +3 -0
  85. package/lib/typescript/components/ReanimatedSwipeable/index.d.ts.map +1 -0
  86. package/lib/typescript/components/Swipeable.d.ts +1 -0
  87. package/lib/typescript/components/Text.d.ts +1 -0
  88. package/lib/typescript/components/gestureHandlerRootHOC.d.ts +1 -0
  89. package/lib/typescript/components/touchables/ExtraButtonProps.d.ts +1 -0
  90. package/lib/typescript/components/touchables/GenericTouchable.d.ts +1 -0
  91. package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +1 -0
  92. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
  93. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +1 -0
  94. package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +1 -0
  95. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +1 -0
  96. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
  97. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +1 -0
  98. package/lib/typescript/components/touchables/index.d.ts +1 -0
  99. package/lib/typescript/components/utils.d.ts +1 -0
  100. package/lib/typescript/findNodeHandle.d.ts +1 -0
  101. package/lib/typescript/findNodeHandle.web.d.ts +1 -0
  102. package/lib/typescript/getShadowNodeFromRef.d.ts +1 -0
  103. package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
  104. package/lib/typescript/ghQueueMicrotask.d.ts +1 -0
  105. package/lib/typescript/handlers/FlingGestureHandler.d.ts +1 -0
  106. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +1 -0
  107. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +1 -0
  108. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +1 -0
  109. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -0
  110. package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -0
  111. package/lib/typescript/handlers/PinchGestureHandler.d.ts +1 -0
  112. package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -0
  113. package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +1 -0
  114. package/lib/typescript/handlers/RotationGestureHandler.d.ts +1 -0
  115. package/lib/typescript/handlers/TapGestureHandler.d.ts +1 -0
  116. package/lib/typescript/handlers/createHandler.d.ts +1 -0
  117. package/lib/typescript/handlers/createNativeWrapper.d.ts +1 -0
  118. package/lib/typescript/handlers/customDirectEventTypes.d.ts +1 -0
  119. package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +1 -0
  120. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +1 -0
  121. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +1 -0
  122. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +1 -0
  123. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +1 -0
  124. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +1 -0
  125. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +1 -0
  126. package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts +1 -0
  127. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +1 -0
  128. package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +1 -0
  129. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +1 -0
  130. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +1 -0
  131. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +1 -0
  132. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +1 -0
  133. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +1 -0
  134. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +1 -0
  135. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +1 -0
  136. package/lib/typescript/handlers/gestures/flingGesture.d.ts +1 -0
  137. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +1 -0
  138. package/lib/typescript/handlers/gestures/gesture.d.ts +1 -0
  139. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +1 -0
  140. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +1 -0
  141. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +1 -0
  142. package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts +1 -0
  143. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -0
  144. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +1 -0
  145. package/lib/typescript/handlers/gestures/manualGesture.d.ts +1 -0
  146. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +1 -0
  147. package/lib/typescript/handlers/gestures/panGesture.d.ts +1 -0
  148. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +1 -0
  149. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +1 -0
  150. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +1 -0
  151. package/lib/typescript/handlers/gestures/tapGesture.d.ts +1 -0
  152. package/lib/typescript/handlers/getNextHandlerTag.d.ts +1 -0
  153. package/lib/typescript/handlers/handlersRegistry.d.ts +1 -0
  154. package/lib/typescript/handlers/utils.d.ts +1 -0
  155. package/lib/typescript/index.d.ts +1 -0
  156. package/lib/typescript/init.d.ts +1 -0
  157. package/lib/typescript/jestUtils/index.d.ts +1 -0
  158. package/lib/typescript/jestUtils/jestUtils.d.ts +1 -0
  159. package/lib/typescript/mocks/Pressable.d.ts +2 -0
  160. package/lib/typescript/mocks/Pressable.d.ts.map +1 -0
  161. package/lib/typescript/{mocks.d.ts → mocks/mocks.d.ts} +5 -4
  162. package/lib/typescript/mocks/mocks.d.ts.map +1 -0
  163. package/lib/typescript/mountRegistry.d.ts +1 -0
  164. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +1 -0
  165. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +1 -0
  166. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +1 -0
  167. package/lib/typescript/typeUtils.d.ts +1 -0
  168. package/lib/typescript/utils.d.ts +1 -0
  169. package/lib/typescript/web/Gestures.d.ts +1 -0
  170. package/lib/typescript/web/constants.d.ts +1 -0
  171. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +1 -0
  172. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +1 -0
  173. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +1 -0
  174. package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
  175. package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
  176. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -0
  177. package/lib/typescript/web/handlers/IGestureHandler.d.ts +1 -0
  178. package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +1 -0
  179. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -0
  180. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -0
  181. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +1 -0
  182. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -0
  183. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -0
  184. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +1 -0
  185. package/lib/typescript/web/interfaces.d.ts +1 -0
  186. package/lib/typescript/web/tools/CircularBuffer.d.ts +1 -0
  187. package/lib/typescript/web/tools/EventManager.d.ts +1 -0
  188. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +1 -0
  189. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +1 -0
  190. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +1 -0
  191. package/lib/typescript/web/tools/InteractionManager.d.ts +1 -0
  192. package/lib/typescript/web/tools/KeyboardEventManager.d.ts +1 -0
  193. package/lib/typescript/web/tools/LeastSquareSolver.d.ts +1 -0
  194. package/lib/typescript/web/tools/NodeManager.d.ts +1 -0
  195. package/lib/typescript/web/tools/PointerEventManager.d.ts +1 -0
  196. package/lib/typescript/web/tools/PointerTracker.d.ts +1 -0
  197. package/lib/typescript/web/tools/Vector.d.ts +1 -0
  198. package/lib/typescript/web/tools/VelocityTracker.d.ts +1 -0
  199. package/lib/typescript/web/tools/WheelEventManager.d.ts +1 -0
  200. package/lib/typescript/web/utils.d.ts +1 -0
  201. package/lib/typescript/web_hammer/DiscreteGestureHandler.d.ts +1 -0
  202. package/lib/typescript/web_hammer/DraggingGestureHandler.d.ts +1 -0
  203. package/lib/typescript/web_hammer/Errors.d.ts +1 -0
  204. package/lib/typescript/web_hammer/FlingGestureHandler.d.ts +1 -0
  205. package/lib/typescript/web_hammer/GestureHandler.d.ts +1 -0
  206. package/lib/typescript/web_hammer/IndiscreteGestureHandler.d.ts +1 -0
  207. package/lib/typescript/web_hammer/LongPressGestureHandler.d.ts +1 -0
  208. package/lib/typescript/web_hammer/NativeViewGestureHandler.d.ts +1 -0
  209. package/lib/typescript/web_hammer/NodeManager.d.ts +1 -0
  210. package/lib/typescript/web_hammer/PanGestureHandler.d.ts +1 -0
  211. package/lib/typescript/web_hammer/PinchGestureHandler.d.ts +1 -0
  212. package/lib/typescript/web_hammer/PressGestureHandler.d.ts +1 -0
  213. package/lib/typescript/web_hammer/RotationGestureHandler.d.ts +1 -0
  214. package/lib/typescript/web_hammer/TapGestureHandler.d.ts +1 -0
  215. package/lib/typescript/web_hammer/constants.d.ts +1 -0
  216. package/lib/typescript/web_hammer/utils.d.ts +1 -0
  217. package/package.json +1 -1
  218. package/src/components/GestureButtonsProps.ts +10 -0
  219. package/src/components/Pressable/Pressable.tsx +20 -31
  220. package/src/components/Pressable/PressableProps.tsx +2 -4
  221. package/src/components/Pressable/StateMachine.tsx +12 -4
  222. package/src/components/Pressable/stateDefinitions.ts +23 -23
  223. package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +603 -0
  224. package/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +199 -0
  225. package/src/components/ReanimatedSwipeable/index.ts +6 -0
  226. package/src/mocks/Pressable.tsx +1 -0
  227. package/src/{mocks.tsx → mocks/mocks.tsx} +7 -11
  228. package/src/web/handlers/GestureHandler.ts +1 -0
  229. package/lib/commonjs/components/ReanimatedSwipeable.js.map +0 -1
  230. package/lib/commonjs/mocks.js.map +0 -1
  231. package/lib/module/components/ReanimatedSwipeable.js.map +0 -1
  232. package/lib/module/mocks.js.map +0 -1
  233. package/lib/typescript/ActionType.js +0 -6
  234. package/lib/typescript/Directions.js +0 -18
  235. package/lib/typescript/EnableNewWebImplementation.js +0 -30
  236. package/lib/typescript/GestureHandlerRootViewContext.js +0 -2
  237. package/lib/typescript/PlatformConstants.js +0 -3
  238. package/lib/typescript/PlatformConstants.web.js +0 -5
  239. package/lib/typescript/PointerType.js +0 -8
  240. package/lib/typescript/RNGestureHandlerModule.js +0 -4
  241. package/lib/typescript/RNGestureHandlerModule.web.js +0 -92
  242. package/lib/typescript/RNGestureHandlerModule.windows.js +0 -47
  243. package/lib/typescript/RNRenderer.js +0 -3
  244. package/lib/typescript/RNRenderer.web.js +0 -3
  245. package/lib/typescript/State.js +0 -9
  246. package/lib/typescript/TouchEventType.js +0 -7
  247. package/lib/typescript/components/DrawerLayout.js +0 -417
  248. package/lib/typescript/components/GestureButtons.js +0 -165
  249. package/lib/typescript/components/GestureButtonsProps.js +0 -1
  250. package/lib/typescript/components/GestureComponents.js +0 -67
  251. package/lib/typescript/components/GestureComponents.web.js +0 -21
  252. package/lib/typescript/components/GestureHandlerButton.js +0 -2
  253. package/lib/typescript/components/GestureHandlerButton.web.js +0 -3
  254. package/lib/typescript/components/GestureHandlerRootView.android.js +0 -17
  255. package/lib/typescript/components/GestureHandlerRootView.js +0 -16
  256. package/lib/typescript/components/GestureHandlerRootView.web.js +0 -11
  257. package/lib/typescript/components/Pressable/Pressable.js +0 -231
  258. package/lib/typescript/components/Pressable/PressableProps.js +0 -1
  259. package/lib/typescript/components/Pressable/StateMachine.js +0 -34
  260. package/lib/typescript/components/Pressable/index.js +0 -1
  261. package/lib/typescript/components/Pressable/stateDefinitions.js +0 -104
  262. package/lib/typescript/components/Pressable/utils.js +0 -80
  263. package/lib/typescript/components/ReanimatedDrawerLayout.js +0 -364
  264. package/lib/typescript/components/ReanimatedSwipeable.d.ts.map +0 -1
  265. package/lib/typescript/components/ReanimatedSwipeable.js +0 -400
  266. package/lib/typescript/components/Swipeable.js +0 -287
  267. package/lib/typescript/components/Text.js +0 -38
  268. package/lib/typescript/components/gestureHandlerRootHOC.js +0 -18
  269. package/lib/typescript/components/touchables/ExtraButtonProps.js +0 -1
  270. package/lib/typescript/components/touchables/GenericTouchable.js +0 -221
  271. package/lib/typescript/components/touchables/GenericTouchableProps.js +0 -1
  272. package/lib/typescript/components/touchables/TouchableHighlight.js +0 -75
  273. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.js +0 -65
  274. package/lib/typescript/components/touchables/TouchableNativeFeedback.js +0 -6
  275. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.js +0 -1
  276. package/lib/typescript/components/touchables/TouchableOpacity.js +0 -51
  277. package/lib/typescript/components/touchables/TouchableWithoutFeedback.js +0 -10
  278. package/lib/typescript/components/touchables/index.js +0 -4
  279. package/lib/typescript/components/utils.js +0 -11
  280. package/lib/typescript/findNodeHandle.js +0 -2
  281. package/lib/typescript/findNodeHandle.web.js +0 -31
  282. package/lib/typescript/getShadowNodeFromRef.js +0 -45
  283. package/lib/typescript/getShadowNodeFromRef.web.js +0 -7
  284. package/lib/typescript/ghQueueMicrotask.js +0 -7
  285. package/lib/typescript/handlers/FlingGestureHandler.js +0 -19
  286. package/lib/typescript/handlers/ForceTouchGestureHandler.js +0 -37
  287. package/lib/typescript/handlers/GestureHandlerEventPayload.js +0 -1
  288. package/lib/typescript/handlers/LongPressGestureHandler.js +0 -22
  289. package/lib/typescript/handlers/NativeViewGestureHandler.js +0 -20
  290. package/lib/typescript/handlers/PanGestureHandler.js +0 -128
  291. package/lib/typescript/handlers/PinchGestureHandler.js +0 -12
  292. package/lib/typescript/handlers/PressabilityDebugView.js +0 -2
  293. package/lib/typescript/handlers/PressabilityDebugView.web.js +0 -4
  294. package/lib/typescript/handlers/RotationGestureHandler.js +0 -12
  295. package/lib/typescript/handlers/TapGestureHandler.js +0 -26
  296. package/lib/typescript/handlers/createHandler.js +0 -375
  297. package/lib/typescript/handlers/createNativeWrapper.js +0 -67
  298. package/lib/typescript/handlers/customDirectEventTypes.js +0 -2
  299. package/lib/typescript/handlers/customDirectEventTypes.web.js +0 -4
  300. package/lib/typescript/handlers/gestureHandlerCommon.js +0 -42
  301. package/lib/typescript/handlers/gestureHandlerTypesCompat.js +0 -1
  302. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.js +0 -22
  303. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.js +0 -24
  304. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.js +0 -55
  305. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.js +0 -12
  306. package/lib/typescript/handlers/gestures/GestureDetector/index.js +0 -114
  307. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.js +0 -18
  308. package/lib/typescript/handlers/gestures/GestureDetector/types.js +0 -1
  309. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.js +0 -54
  310. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.js +0 -137
  311. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.js +0 -48
  312. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.js +0 -35
  313. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.js +0 -32
  314. package/lib/typescript/handlers/gestures/GestureDetector/utils.js +0 -140
  315. package/lib/typescript/handlers/gestures/eventReceiver.js +0 -105
  316. package/lib/typescript/handlers/gestures/flingGesture.js +0 -27
  317. package/lib/typescript/handlers/gestures/forceTouchGesture.js +0 -57
  318. package/lib/typescript/handlers/gestures/gesture.js +0 -303
  319. package/lib/typescript/handlers/gestures/gestureComposition.js +0 -78
  320. package/lib/typescript/handlers/gestures/gestureObjects.js +0 -125
  321. package/lib/typescript/handlers/gestures/gestureStateManager.js +0 -60
  322. package/lib/typescript/handlers/gestures/gestureStateManager.web.js +0 -19
  323. package/lib/typescript/handlers/gestures/hoverGesture.js +0 -45
  324. package/lib/typescript/handlers/gestures/longPressGesture.js +0 -35
  325. package/lib/typescript/handlers/gestures/manualGesture.js +0 -16
  326. package/lib/typescript/handlers/gestures/nativeGesture.js +0 -24
  327. package/lib/typescript/handlers/gestures/panGesture.js +0 -181
  328. package/lib/typescript/handlers/gestures/pinchGesture.js +0 -27
  329. package/lib/typescript/handlers/gestures/reanimatedWrapper.js +0 -23
  330. package/lib/typescript/handlers/gestures/rotationGesture.js +0 -27
  331. package/lib/typescript/handlers/gestures/tapGesture.js +0 -72
  332. package/lib/typescript/handlers/getNextHandlerTag.js +0 -4
  333. package/lib/typescript/handlers/handlersRegistry.js +0 -36
  334. package/lib/typescript/handlers/utils.js +0 -58
  335. package/lib/typescript/index.js +0 -28
  336. package/lib/typescript/init.js +0 -15
  337. package/lib/typescript/jestUtils/index.js +0 -1
  338. package/lib/typescript/jestUtils/jestUtils.js +0 -290
  339. package/lib/typescript/mocks.d.ts.map +0 -1
  340. package/lib/typescript/mocks.js +0 -59
  341. package/lib/typescript/mountRegistry.js +0 -29
  342. package/lib/typescript/specs/NativeRNGestureHandlerModule.js +0 -2
  343. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.js +0 -2
  344. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.js +0 -2
  345. package/lib/typescript/typeUtils.js +0 -1
  346. package/lib/typescript/utils.js +0 -80
  347. package/lib/typescript/web/Gestures.js +0 -38
  348. package/lib/typescript/web/constants.js +0 -2
  349. package/lib/typescript/web/detectors/RotationGestureDetector.js +0 -122
  350. package/lib/typescript/web/detectors/ScaleGestureDetector.js +0 -117
  351. package/lib/typescript/web/handlers/FlingGestureHandler.js +0 -133
  352. package/lib/typescript/web/handlers/GestureHandler.js +0 -656
  353. package/lib/typescript/web/handlers/HoverGestureHandler.js +0 -37
  354. package/lib/typescript/web/handlers/IGestureHandler.js +0 -1
  355. package/lib/typescript/web/handlers/LongPressGestureHandler.js +0 -136
  356. package/lib/typescript/web/handlers/ManualGestureHandler.js +0 -29
  357. package/lib/typescript/web/handlers/NativeViewGestureHandler.js +0 -133
  358. package/lib/typescript/web/handlers/PanGestureHandler.js +0 -420
  359. package/lib/typescript/web/handlers/PinchGestureHandler.js +0 -117
  360. package/lib/typescript/web/handlers/RotationGestureHandler.js +0 -122
  361. package/lib/typescript/web/handlers/TapGestureHandler.js +0 -202
  362. package/lib/typescript/web/interfaces.js +0 -25
  363. package/lib/typescript/web/tools/CircularBuffer.js +0 -37
  364. package/lib/typescript/web/tools/EventManager.js +0 -85
  365. package/lib/typescript/web/tools/GestureHandlerDelegate.js +0 -1
  366. package/lib/typescript/web/tools/GestureHandlerOrchestrator.js +0 -273
  367. package/lib/typescript/web/tools/GestureHandlerWebDelegate.js +0 -169
  368. package/lib/typescript/web/tools/InteractionManager.js +0 -91
  369. package/lib/typescript/web/tools/KeyboardEventManager.js +0 -73
  370. package/lib/typescript/web/tools/LeastSquareSolver.js +0 -147
  371. package/lib/typescript/web/tools/NodeManager.js +0 -28
  372. package/lib/typescript/web/tools/PointerEventManager.js +0 -179
  373. package/lib/typescript/web/tools/PointerTracker.js +0 -161
  374. package/lib/typescript/web/tools/Vector.js +0 -43
  375. package/lib/typescript/web/tools/VelocityTracker.js +0 -76
  376. package/lib/typescript/web/tools/WheelEventManager.js +0 -40
  377. package/lib/typescript/web/utils.js +0 -233
  378. package/lib/typescript/web_hammer/DiscreteGestureHandler.js +0 -48
  379. package/lib/typescript/web_hammer/DraggingGestureHandler.js +0 -25
  380. package/lib/typescript/web_hammer/Errors.js +0 -5
  381. package/lib/typescript/web_hammer/FlingGestureHandler.js +0 -119
  382. package/lib/typescript/web_hammer/GestureHandler.js +0 -469
  383. package/lib/typescript/web_hammer/IndiscreteGestureHandler.js +0 -26
  384. package/lib/typescript/web_hammer/LongPressGestureHandler.js +0 -46
  385. package/lib/typescript/web_hammer/NativeViewGestureHandler.js +0 -40
  386. package/lib/typescript/web_hammer/NodeManager.js +0 -28
  387. package/lib/typescript/web_hammer/PanGestureHandler.js +0 -151
  388. package/lib/typescript/web_hammer/PinchGestureHandler.js +0 -19
  389. package/lib/typescript/web_hammer/PressGestureHandler.js +0 -133
  390. package/lib/typescript/web_hammer/RotationGestureHandler.js +0 -20
  391. package/lib/typescript/web_hammer/TapGestureHandler.js +0 -142
  392. package/lib/typescript/web_hammer/constants.js +0 -42
  393. package/lib/typescript/web_hammer/utils.js +0 -15
  394. package/src/components/ReanimatedSwipeable.tsx +0 -811
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- import { View } from 'react-native';
3
- export default React.forwardRef((props, ref) => <View ref={ref} accessibilityRole="button" {...props}/>);
@@ -1,17 +0,0 @@
1
- import * as React from 'react';
2
- import { StyleSheet } from 'react-native';
3
- import { maybeInitializeFabric } from '../init';
4
- import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
5
- import GestureHandlerRootViewNativeComponent from '../specs/RNGestureHandlerRootViewNativeComponent';
6
- export default function GestureHandlerRootView({ style, ...rest }) {
7
- // Try initialize fabric on the first render, at this point we can
8
- // reliably check if fabric is enabled (the function contains a flag
9
- // to make sure it's called only once)
10
- maybeInitializeFabric();
11
- return (<GestureHandlerRootViewContext.Provider value>
12
- <GestureHandlerRootViewNativeComponent style={style ?? styles.container} {...rest}/>
13
- </GestureHandlerRootViewContext.Provider>);
14
- }
15
- const styles = StyleSheet.create({
16
- container: { flex: 1 },
17
- });
@@ -1,16 +0,0 @@
1
- import * as React from 'react';
2
- import { View, StyleSheet } from 'react-native';
3
- import { maybeInitializeFabric } from '../init';
4
- import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
5
- export default function GestureHandlerRootView({ style, ...rest }) {
6
- // Try initialize fabric on the first render, at this point we can
7
- // reliably check if fabric is enabled (the function contains a flag
8
- // to make sure it's called only once)
9
- maybeInitializeFabric();
10
- return (<GestureHandlerRootViewContext.Provider value>
11
- <View style={style ?? styles.container} {...rest}/>
12
- </GestureHandlerRootViewContext.Provider>);
13
- }
14
- const styles = StyleSheet.create({
15
- container: { flex: 1 },
16
- });
@@ -1,11 +0,0 @@
1
- import * as React from 'react';
2
- import { View, StyleSheet } from 'react-native';
3
- import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
4
- export default function GestureHandlerRootView({ style, ...rest }) {
5
- return (<GestureHandlerRootViewContext.Provider value>
6
- <View style={style ?? styles.container} {...rest}/>
7
- </GestureHandlerRootViewContext.Provider>);
8
- }
9
- const styles = StyleSheet.create({
10
- container: { flex: 1 },
11
- });
@@ -1,231 +0,0 @@
1
- import React, { useCallback, useLayoutEffect, useMemo, useRef, useState, } from 'react';
2
- import { GestureObjects as Gesture } from '../../handlers/gestures/gestureObjects';
3
- import { GestureDetector } from '../../handlers/gestures/GestureDetector';
4
- import { Platform, processColor, } from 'react-native';
5
- import NativeButton from '../GestureHandlerButton';
6
- import { gestureToPressableEvent, addInsets, numberAsInset, gestureTouchToPressableEvent, isTouchWithinInset, } from './utils';
7
- import { PressabilityDebugView } from '../../handlers/PressabilityDebugView';
8
- import { INT32_MAX, isFabric, isTestEnv } from '../../utils';
9
- import { applyRelationProp, } from '../utils';
10
- import { getConfiguredStateMachine, StateMachineEvent, } from './stateDefinitions';
11
- const DEFAULT_LONG_PRESS_DURATION = 500;
12
- const IS_TEST_ENV = isTestEnv();
13
- let IS_FABRIC = null;
14
- const Pressable = (props) => {
15
- const { ref, testOnly_pressed, hitSlop, pressRetentionOffset, delayHoverIn, delayHoverOut, delayLongPress, unstable_pressDelay, onHoverIn, onHoverOut, onPress, onPressIn, onPressOut, onLongPress, style, children, android_disableSound, android_ripple, disabled, accessible, simultaneousWithExternalGesture, requireExternalGestureToFail, blocksExternalGesture, dimensionsAfterResize, ...remainingProps } = props;
16
- const relationProps = {
17
- simultaneousWithExternalGesture,
18
- requireExternalGestureToFail,
19
- blocksExternalGesture,
20
- };
21
- // used only if `ref` is undefined
22
- const fallbackRef = useRef(null);
23
- const [pressedState, setPressedState] = useState(testOnly_pressed ?? false);
24
- const longPressTimeoutRef = useRef(null);
25
- const pressDelayTimeoutRef = useRef(null);
26
- const isOnPressAllowed = useRef(true);
27
- const isCurrentlyPressed = useRef(false);
28
- const dimensions = useRef({ width: 0, height: 0 });
29
- const normalizedHitSlop = useMemo(() => typeof hitSlop === 'number' ? numberAsInset(hitSlop) : (hitSlop ?? {}), [hitSlop]);
30
- const normalizedPressRetentionOffset = useMemo(() => typeof pressRetentionOffset === 'number'
31
- ? numberAsInset(pressRetentionOffset)
32
- : (pressRetentionOffset ?? {}), [pressRetentionOffset]);
33
- const appliedHitSlop = addInsets(normalizedHitSlop, normalizedPressRetentionOffset);
34
- useLayoutEffect(() => {
35
- if (dimensionsAfterResize) {
36
- dimensions.current = dimensionsAfterResize;
37
- }
38
- else {
39
- requestAnimationFrame(() => {
40
- (ref ?? fallbackRef).current?.measure((_x, _y, width, height) => {
41
- dimensions.current = {
42
- width,
43
- height,
44
- };
45
- });
46
- });
47
- }
48
- }, [dimensionsAfterResize, ref]);
49
- const cancelLongPress = useCallback(() => {
50
- if (longPressTimeoutRef.current) {
51
- clearTimeout(longPressTimeoutRef.current);
52
- longPressTimeoutRef.current = null;
53
- isOnPressAllowed.current = true;
54
- }
55
- }, []);
56
- const cancelDelayedPress = useCallback(() => {
57
- if (pressDelayTimeoutRef.current) {
58
- clearTimeout(pressDelayTimeoutRef.current);
59
- pressDelayTimeoutRef.current = null;
60
- }
61
- }, []);
62
- const startLongPress = useCallback((event) => {
63
- if (onLongPress) {
64
- cancelLongPress();
65
- longPressTimeoutRef.current = setTimeout(() => {
66
- isOnPressAllowed.current = false;
67
- onLongPress(event);
68
- }, delayLongPress ?? DEFAULT_LONG_PRESS_DURATION);
69
- }
70
- }, [onLongPress, cancelLongPress, delayLongPress]);
71
- const innerHandlePressIn = useCallback((event) => {
72
- onPressIn?.(event);
73
- startLongPress(event);
74
- setPressedState(true);
75
- if (pressDelayTimeoutRef.current) {
76
- clearTimeout(pressDelayTimeoutRef.current);
77
- pressDelayTimeoutRef.current = null;
78
- }
79
- }, [onPressIn, startLongPress]);
80
- const handleFinalize = useCallback(() => {
81
- isCurrentlyPressed.current = false;
82
- cancelLongPress();
83
- cancelDelayedPress();
84
- setPressedState(false);
85
- }, [cancelDelayedPress, cancelLongPress]);
86
- const handlePressIn = useCallback((event) => {
87
- if (!isTouchWithinInset(dimensions.current, normalizedHitSlop, event.nativeEvent.changedTouches.at(-1))) {
88
- // Ignoring pressIn within pressRetentionOffset
89
- return;
90
- }
91
- isCurrentlyPressed.current = true;
92
- if (unstable_pressDelay) {
93
- pressDelayTimeoutRef.current = setTimeout(() => {
94
- innerHandlePressIn(event);
95
- }, unstable_pressDelay);
96
- }
97
- else {
98
- innerHandlePressIn(event);
99
- }
100
- }, [innerHandlePressIn, normalizedHitSlop, unstable_pressDelay]);
101
- const handlePressOut = useCallback((event, success = true) => {
102
- if (!isCurrentlyPressed.current) {
103
- // Some prop configurations may lead to handlePressOut being called mutliple times.
104
- return;
105
- }
106
- isCurrentlyPressed.current = false;
107
- if (pressDelayTimeoutRef.current) {
108
- innerHandlePressIn(event);
109
- }
110
- onPressOut?.(event);
111
- if (isOnPressAllowed.current && success) {
112
- onPress?.(event);
113
- }
114
- handleFinalize();
115
- }, [handleFinalize, innerHandlePressIn, onPress, onPressOut]);
116
- const stateMachine = useMemo(() => getConfiguredStateMachine(handlePressIn, handlePressOut), [handlePressIn, handlePressOut]);
117
- const hoverInTimeout = useRef(null);
118
- const hoverOutTimeout = useRef(null);
119
- const hoverGesture = useMemo(() => Gesture.Hover()
120
- .manualActivation(true) // Prevents Hover blocking Gesture.Native() on web
121
- .cancelsTouchesInView(false)
122
- .onBegin((event) => {
123
- if (hoverOutTimeout.current) {
124
- clearTimeout(hoverOutTimeout.current);
125
- }
126
- if (delayHoverIn) {
127
- hoverInTimeout.current = setTimeout(() => onHoverIn?.(gestureToPressableEvent(event)), delayHoverIn);
128
- return;
129
- }
130
- onHoverIn?.(gestureToPressableEvent(event));
131
- })
132
- .onFinalize((event) => {
133
- if (hoverInTimeout.current) {
134
- clearTimeout(hoverInTimeout.current);
135
- }
136
- if (delayHoverOut) {
137
- hoverOutTimeout.current = setTimeout(() => onHoverOut?.(gestureToPressableEvent(event)), delayHoverOut);
138
- return;
139
- }
140
- onHoverOut?.(gestureToPressableEvent(event));
141
- }), [delayHoverIn, delayHoverOut, onHoverIn, onHoverOut]);
142
- const pressAndTouchGesture = useMemo(() => Gesture.LongPress()
143
- .minDuration(INT32_MAX) // Stops long press from blocking Gesture.Native()
144
- .maxDistance(INT32_MAX) // Stops long press from cancelling on touch move
145
- .cancelsTouchesInView(false)
146
- .onTouchesDown((event) => {
147
- const pressableEvent = gestureTouchToPressableEvent(event);
148
- stateMachine.handleEvent(StateMachineEvent.LONG_PRESS_TOUCHES_DOWN, pressableEvent);
149
- })
150
- .onTouchesUp(() => {
151
- if (Platform.OS === 'android') {
152
- // Prevents potential soft-locks
153
- stateMachine.reset();
154
- handleFinalize();
155
- }
156
- })
157
- .onTouchesCancelled((event) => {
158
- const pressableEvent = gestureTouchToPressableEvent(event);
159
- stateMachine.reset();
160
- handlePressOut(pressableEvent, false);
161
- })
162
- .onFinalize(() => {
163
- if (Platform.OS === 'web') {
164
- stateMachine.handleEvent(StateMachineEvent.FINALIZE);
165
- handleFinalize();
166
- }
167
- }), [stateMachine, handleFinalize, handlePressOut]);
168
- // RNButton is placed inside ButtonGesture to enable Android's ripple and to capture non-propagating events
169
- const buttonGesture = useMemo(() => Gesture.Native()
170
- .onTouchesCancelled((event) => {
171
- if (Platform.OS !== 'macos' && Platform.OS !== 'web') {
172
- // On MacOS cancel occurs in middle of gesture
173
- // On Web cancel occurs on mouse move, which is unwanted
174
- const pressableEvent = gestureTouchToPressableEvent(event);
175
- stateMachine.reset();
176
- handlePressOut(pressableEvent, false);
177
- }
178
- })
179
- .onBegin(() => {
180
- stateMachine.handleEvent(StateMachineEvent.NATIVE_BEGIN);
181
- })
182
- .onStart(() => {
183
- if (Platform.OS !== 'android') {
184
- // Gesture.Native().onStart() is broken with Android + hitSlop
185
- stateMachine.handleEvent(StateMachineEvent.NATIVE_START);
186
- }
187
- })
188
- .onFinalize(() => {
189
- if (Platform.OS !== 'web') {
190
- // On Web we use LongPress().onFinalize() instead of Native().onFinalize(),
191
- // as Native cancels on mouse move, and LongPress does not.
192
- stateMachine.handleEvent(StateMachineEvent.FINALIZE);
193
- handleFinalize();
194
- }
195
- }), [stateMachine, handlePressOut, handleFinalize]);
196
- const isPressableEnabled = disabled !== true;
197
- const gestures = [buttonGesture, pressAndTouchGesture, hoverGesture];
198
- for (const gesture of gestures) {
199
- gesture.enabled(isPressableEnabled);
200
- gesture.runOnJS(true);
201
- gesture.hitSlop(appliedHitSlop);
202
- gesture.shouldCancelWhenOutside(Platform.OS !== 'web');
203
- Object.entries(relationProps).forEach(([relationName, relation]) => {
204
- applyRelationProp(gesture, relationName, relation);
205
- });
206
- }
207
- const gesture = Gesture.Simultaneous(...gestures);
208
- // `cursor: 'pointer'` on `RNButton` crashes iOS
209
- const pointerStyle = Platform.OS === 'web' ? { cursor: 'pointer' } : {};
210
- const styleProp = typeof style === 'function' ? style({ pressed: pressedState }) : style;
211
- const childrenProp = typeof children === 'function'
212
- ? children({ pressed: pressedState })
213
- : children;
214
- const rippleColor = useMemo(() => {
215
- if (IS_FABRIC === null) {
216
- IS_FABRIC = isFabric();
217
- }
218
- const defaultRippleColor = android_ripple ? undefined : 'transparent';
219
- const unprocessedRippleColor = android_ripple?.color ?? defaultRippleColor;
220
- return IS_FABRIC
221
- ? unprocessedRippleColor
222
- : processColor(unprocessedRippleColor);
223
- }, [android_ripple]);
224
- return (<GestureDetector gesture={gesture}>
225
- <NativeButton {...remainingProps} ref={ref ?? fallbackRef} accessible={accessible !== false} hitSlop={appliedHitSlop} enabled={isPressableEnabled} touchSoundDisabled={android_disableSound ?? undefined} rippleColor={rippleColor} rippleRadius={android_ripple?.radius ?? undefined} style={[pointerStyle, styleProp]} testOnly_onPress={IS_TEST_ENV ? onPress : undefined} testOnly_onPressIn={IS_TEST_ENV ? onPressIn : undefined} testOnly_onPressOut={IS_TEST_ENV ? onPressOut : undefined} testOnly_onLongPress={IS_TEST_ENV ? onLongPress : undefined}>
226
- {childrenProp}
227
- {__DEV__ ? (<PressabilityDebugView color="red" hitSlop={normalizedHitSlop}/>) : null}
228
- </NativeButton>
229
- </GestureDetector>);
230
- };
231
- export default Pressable;
@@ -1 +0,0 @@
1
- export {};
@@ -1,34 +0,0 @@
1
- class PressableStateMachine {
2
- states;
3
- currentStepIndex;
4
- eventPayload;
5
- constructor(steps) {
6
- this.states = steps;
7
- this.currentStepIndex = 0;
8
- this.eventPayload = null;
9
- }
10
- reset() {
11
- this.currentStepIndex = 0;
12
- this.eventPayload = null;
13
- }
14
- handleEvent(eventName, eventPayload) {
15
- const step = this.states[this.currentStepIndex];
16
- this.eventPayload = eventPayload || this.eventPayload;
17
- if (step.eventName !== eventName) {
18
- if (this.currentStepIndex > 0) {
19
- // retry with position at index 0
20
- this.reset();
21
- this.handleEvent(eventName, eventPayload);
22
- }
23
- return;
24
- }
25
- if (this.eventPayload && step.callback) {
26
- step.callback(this.eventPayload);
27
- }
28
- this.currentStepIndex++;
29
- if (this.currentStepIndex === this.states.length) {
30
- this.reset();
31
- }
32
- }
33
- }
34
- export { PressableStateMachine };
@@ -1 +0,0 @@
1
- export { default } from './Pressable';
@@ -1,104 +0,0 @@
1
- import { Platform } from 'react-native';
2
- import { PressableStateMachine } from './StateMachine';
3
- export var StateMachineEvent;
4
- (function (StateMachineEvent) {
5
- StateMachineEvent["NATIVE_BEGIN"] = "nativeBegin";
6
- StateMachineEvent["NATIVE_START"] = "nativeStart";
7
- StateMachineEvent["FINALIZE"] = "finalize";
8
- StateMachineEvent["LONG_PRESS_TOUCHES_DOWN"] = "longPressTouchesDown";
9
- })(StateMachineEvent || (StateMachineEvent = {}));
10
- function getAndroidStateMachine(handlePressIn, handlePressOut) {
11
- return new PressableStateMachine([
12
- {
13
- eventName: StateMachineEvent.NATIVE_BEGIN,
14
- },
15
- {
16
- eventName: StateMachineEvent.LONG_PRESS_TOUCHES_DOWN,
17
- callback: handlePressIn,
18
- },
19
- {
20
- eventName: StateMachineEvent.FINALIZE,
21
- callback: handlePressOut,
22
- },
23
- ]);
24
- }
25
- function getIosStateMachine(handlePressIn, handlePressOut) {
26
- return new PressableStateMachine([
27
- {
28
- eventName: StateMachineEvent.LONG_PRESS_TOUCHES_DOWN,
29
- },
30
- {
31
- eventName: StateMachineEvent.NATIVE_START,
32
- callback: handlePressIn,
33
- },
34
- {
35
- eventName: StateMachineEvent.FINALIZE,
36
- callback: handlePressOut,
37
- },
38
- ]);
39
- }
40
- function getWebStateMachine(handlePressIn, handlePressOut) {
41
- return new PressableStateMachine([
42
- {
43
- eventName: StateMachineEvent.NATIVE_BEGIN,
44
- },
45
- {
46
- eventName: StateMachineEvent.NATIVE_START,
47
- },
48
- {
49
- eventName: StateMachineEvent.LONG_PRESS_TOUCHES_DOWN,
50
- callback: handlePressIn,
51
- },
52
- {
53
- eventName: StateMachineEvent.FINALIZE,
54
- callback: handlePressOut,
55
- },
56
- ]);
57
- }
58
- function getMacosStateMachine(handlePressIn, handlePressOut) {
59
- return new PressableStateMachine([
60
- {
61
- eventName: StateMachineEvent.LONG_PRESS_TOUCHES_DOWN,
62
- },
63
- {
64
- eventName: StateMachineEvent.NATIVE_BEGIN,
65
- callback: handlePressIn,
66
- },
67
- {
68
- eventName: StateMachineEvent.NATIVE_START,
69
- },
70
- {
71
- eventName: StateMachineEvent.FINALIZE,
72
- callback: handlePressOut,
73
- },
74
- ]);
75
- }
76
- function getUniversalStateMachine(handlePressIn, handlePressOut) {
77
- return new PressableStateMachine([
78
- {
79
- eventName: StateMachineEvent.FINALIZE,
80
- callback: (event) => {
81
- handlePressIn(event);
82
- handlePressOut(event);
83
- },
84
- },
85
- ]);
86
- }
87
- export function getConfiguredStateMachine(handlePressIn, handlePressOut) {
88
- if (Platform.OS === 'android') {
89
- return getAndroidStateMachine(handlePressIn, handlePressOut);
90
- }
91
- else if (Platform.OS === 'ios') {
92
- return getIosStateMachine(handlePressIn, handlePressOut);
93
- }
94
- else if (Platform.OS === 'web') {
95
- return getWebStateMachine(handlePressIn, handlePressOut);
96
- }
97
- else if (Platform.OS === 'macos') {
98
- return getMacosStateMachine(handlePressIn, handlePressOut);
99
- }
100
- else {
101
- // Unknown platform - using minimal universal setup.
102
- return getUniversalStateMachine(handlePressIn, handlePressOut);
103
- }
104
- }
@@ -1,80 +0,0 @@
1
- const numberAsInset = (value) => ({
2
- left: value,
3
- right: value,
4
- top: value,
5
- bottom: value,
6
- });
7
- const addInsets = (a, b) => ({
8
- left: (a.left ?? 0) + (b.left ?? 0),
9
- right: (a.right ?? 0) + (b.right ?? 0),
10
- top: (a.top ?? 0) + (b.top ?? 0),
11
- bottom: (a.bottom ?? 0) + (b.bottom ?? 0),
12
- });
13
- const touchDataToPressEvent = (data, timestamp, targetId) => ({
14
- identifier: data.id,
15
- locationX: data.x,
16
- locationY: data.y,
17
- pageX: data.absoluteX,
18
- pageY: data.absoluteY,
19
- target: targetId,
20
- timestamp: timestamp,
21
- touches: [], // Always empty - legacy compatibility
22
- changedTouches: [], // Always empty - legacy compatibility
23
- });
24
- const gestureToPressEvent = (event, timestamp, targetId) => ({
25
- identifier: event.handlerTag,
26
- locationX: event.x,
27
- locationY: event.y,
28
- pageX: event.absoluteX,
29
- pageY: event.absoluteY,
30
- target: targetId,
31
- timestamp: timestamp,
32
- touches: [], // Always empty - legacy compatibility
33
- changedTouches: [], // Always empty - legacy compatibility
34
- });
35
- const isTouchWithinInset = (dimensions, inset, touch) => (touch?.locationX ?? 0) < (inset.right ?? 0) + dimensions.width &&
36
- (touch?.locationY ?? 0) < (inset.bottom ?? 0) + dimensions.height &&
37
- (touch?.locationX ?? 0) > -(inset.left ?? 0) &&
38
- (touch?.locationY ?? 0) > -(inset.top ?? 0);
39
- const gestureToPressableEvent = (event) => {
40
- const timestamp = Date.now();
41
- // As far as I can see, there isn't a conventional way of getting targetId with the data we get
42
- const targetId = 0;
43
- const pressEvent = gestureToPressEvent(event, timestamp, targetId);
44
- return {
45
- nativeEvent: {
46
- touches: [pressEvent],
47
- changedTouches: [pressEvent],
48
- identifier: pressEvent.identifier,
49
- locationX: event.x,
50
- locationY: event.y,
51
- pageX: event.absoluteX,
52
- pageY: event.absoluteY,
53
- target: targetId,
54
- timestamp: timestamp,
55
- force: undefined,
56
- },
57
- };
58
- };
59
- const gestureTouchToPressableEvent = (event) => {
60
- const timestamp = Date.now();
61
- // As far as I can see, there isn't a conventional way of getting targetId with the data we get
62
- const targetId = 0;
63
- const touchesList = event.allTouches.map((touch) => touchDataToPressEvent(touch, timestamp, targetId));
64
- const changedTouchesList = event.changedTouches.map((touch) => touchDataToPressEvent(touch, timestamp, targetId));
65
- return {
66
- nativeEvent: {
67
- touches: touchesList,
68
- changedTouches: changedTouchesList,
69
- identifier: event.handlerTag,
70
- locationX: event.allTouches.at(0)?.x ?? -1,
71
- locationY: event.allTouches.at(0)?.y ?? -1,
72
- pageX: event.allTouches.at(0)?.absoluteX ?? -1,
73
- pageY: event.allTouches.at(0)?.absoluteY ?? -1,
74
- target: targetId,
75
- timestamp: timestamp,
76
- force: undefined,
77
- },
78
- };
79
- };
80
- export { numberAsInset, addInsets, isTouchWithinInset, gestureToPressableEvent, gestureTouchToPressableEvent, };