react-native-gesture-handler 2.14.1 → 2.16.0-rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. package/README.md +1 -0
  2. package/RNGestureHandler.podspec +3 -24
  3. package/android/build.gradle +1 -1
  4. package/android/paper/src/main/java/com/swmansion/gesturehandler/NativeRNGestureHandlerModuleSpec.java +55 -0
  5. package/android/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +69 -4
  6. package/android/src/main/java/com/swmansion/gesturehandler/core/FlingGestureHandler.kt +4 -0
  7. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +69 -0
  8. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +37 -21
  9. package/android/src/main/java/com/swmansion/gesturehandler/core/LongPressGestureHandler.kt +5 -1
  10. package/android/src/main/java/com/swmansion/gesturehandler/core/PanGestureHandler.kt +5 -1
  11. package/android/src/main/java/com/swmansion/gesturehandler/core/TapGestureHandler.kt +7 -3
  12. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +61 -24
  13. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +3 -2
  14. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/GestureHandlerEventDataBuilder.kt +3 -0
  15. package/android/src/main/jni/cpp-adapter.cpp +18 -22
  16. package/{ios → apple}/Handlers/RNFlingHandler.m +29 -8
  17. package/{ios → apple}/Handlers/RNForceTouchHandler.m +28 -8
  18. package/{ios → apple}/Handlers/RNHoverHandler.m +28 -2
  19. package/{ios → apple}/Handlers/RNLongPressHandler.m +27 -5
  20. package/{ios → apple}/Handlers/RNManualHandler.m +25 -4
  21. package/{ios → apple}/Handlers/RNNativeViewHandler.mm +51 -13
  22. package/{ios → apple}/Handlers/RNPanHandler.m +106 -16
  23. package/apple/Handlers/RNPinchHandler.m +175 -0
  24. package/apple/Handlers/RNRotationHandler.m +169 -0
  25. package/{ios → apple}/Handlers/RNTapHandler.m +98 -26
  26. package/apple/RNGHUIKit.h +27 -0
  27. package/{ios → apple}/RNGestureHandler.h +12 -3
  28. package/{ios → apple}/RNGestureHandler.m +68 -7
  29. package/{ios → apple}/RNGestureHandlerButton.h +4 -1
  30. package/{ios → apple}/RNGestureHandlerButton.m +12 -4
  31. package/{ios → apple}/RNGestureHandlerButtonManager.m +4 -2
  32. package/{ios → apple}/RNGestureHandlerEvents.h +19 -10
  33. package/{ios → apple}/RNGestureHandlerEvents.m +29 -11
  34. package/{ios → apple}/RNGestureHandlerManager.h +7 -2
  35. package/{ios → apple}/RNGestureHandlerManager.mm +78 -17
  36. package/apple/RNGestureHandlerModule.h +19 -0
  37. package/{ios → apple}/RNGestureHandlerModule.mm +69 -69
  38. package/{ios → apple}/RNGestureHandlerPointerTracker.h +5 -5
  39. package/{ios → apple}/RNGestureHandlerPointerTracker.m +19 -14
  40. package/apple/RNGestureHandlerPointerType.h +8 -0
  41. package/{ios → apple}/RNGestureHandlerRegistry.h +1 -1
  42. package/{ios → apple}/RNGestureHandlerRegistry.m +1 -1
  43. package/{ios → apple}/RNManualActivationRecognizer.h +8 -0
  44. package/{ios → apple}/RNManualActivationRecognizer.m +27 -7
  45. package/{ios → apple}/RNRootViewGestureRecognizer.m +72 -4
  46. package/lib/commonjs/PointerType.js +16 -0
  47. package/lib/commonjs/PointerType.js.map +1 -0
  48. package/lib/commonjs/RNGestureHandlerModule.js +5 -18
  49. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  50. package/lib/commonjs/RNGestureHandlerModule.windows.js +10 -102
  51. package/lib/commonjs/RNGestureHandlerModule.windows.js.map +1 -1
  52. package/lib/commonjs/components/DrawerLayout.js +2 -0
  53. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  54. package/lib/commonjs/components/GestureHandlerRootView.android.js +17 -2
  55. package/lib/commonjs/components/GestureHandlerRootView.android.js.map +1 -1
  56. package/lib/commonjs/components/GestureHandlerRootView.js +15 -2
  57. package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
  58. package/lib/commonjs/components/GestureHandlerRootView.web.js +15 -2
  59. package/lib/commonjs/components/GestureHandlerRootView.web.js.map +1 -1
  60. package/lib/commonjs/getShadowNodeFromRef.js +19 -2
  61. package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
  62. package/lib/commonjs/handlers/createHandler.js +5 -0
  63. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  64. package/lib/commonjs/handlers/gestureHandlerCommon.js +1 -1
  65. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  66. package/lib/commonjs/handlers/gestures/GestureDetector.js +11 -1
  67. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  68. package/lib/commonjs/handlers/gestures/gesture.js +5 -0
  69. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  70. package/lib/commonjs/index.js +16 -0
  71. package/lib/commonjs/index.js.map +1 -1
  72. package/lib/commonjs/specs/NativeRNGestureHandlerModule.js +13 -0
  73. package/lib/commonjs/specs/NativeRNGestureHandlerModule.js.map +1 -0
  74. package/lib/commonjs/web/handlers/FlingGestureHandler.js +4 -0
  75. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  76. package/lib/commonjs/web/handlers/GestureHandler.js +19 -4
  77. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  78. package/lib/commonjs/web/handlers/LongPressGestureHandler.js +8 -6
  79. package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
  80. package/lib/commonjs/web/handlers/PanGestureHandler.js +4 -0
  81. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  82. package/lib/commonjs/web/handlers/TapGestureHandler.js +4 -0
  83. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  84. package/lib/commonjs/web/interfaces.js +12 -24
  85. package/lib/commonjs/web/interfaces.js.map +1 -1
  86. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +3 -3
  87. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  88. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +35 -0
  89. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  90. package/lib/commonjs/web/tools/NodeManager.js +3 -2
  91. package/lib/commonjs/web/tools/NodeManager.js.map +1 -1
  92. package/lib/commonjs/web/tools/PointerEventManager.js +40 -10
  93. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  94. package/lib/commonjs/web/tools/TouchEventManager.js +3 -2
  95. package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
  96. package/lib/commonjs/web/utils.js +6 -0
  97. package/lib/commonjs/web/utils.js.map +1 -1
  98. package/lib/module/PointerType.js +9 -0
  99. package/lib/module/PointerType.js.map +1 -0
  100. package/lib/module/RNGestureHandlerModule.js +4 -18
  101. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  102. package/lib/module/RNGestureHandlerModule.windows.js +10 -81
  103. package/lib/module/RNGestureHandlerModule.windows.js.map +1 -1
  104. package/lib/module/components/DrawerLayout.js +2 -0
  105. package/lib/module/components/DrawerLayout.js.map +1 -1
  106. package/lib/module/components/GestureHandlerRootView.android.js +15 -2
  107. package/lib/module/components/GestureHandlerRootView.android.js.map +1 -1
  108. package/lib/module/components/GestureHandlerRootView.js +15 -3
  109. package/lib/module/components/GestureHandlerRootView.js.map +1 -1
  110. package/lib/module/components/GestureHandlerRootView.web.js +15 -3
  111. package/lib/module/components/GestureHandlerRootView.web.js.map +1 -1
  112. package/lib/module/getShadowNodeFromRef.js +19 -2
  113. package/lib/module/getShadowNodeFromRef.js.map +1 -1
  114. package/lib/module/handlers/createHandler.js +6 -1
  115. package/lib/module/handlers/createHandler.js.map +1 -1
  116. package/lib/module/handlers/gestureHandlerCommon.js +1 -1
  117. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  118. package/lib/module/handlers/gestures/GestureDetector.js +11 -1
  119. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  120. package/lib/module/handlers/gestures/gesture.js +5 -0
  121. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  122. package/lib/module/index.js +2 -0
  123. package/lib/module/index.js.map +1 -1
  124. package/lib/module/specs/NativeRNGestureHandlerModule.js +3 -0
  125. package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -0
  126. package/lib/module/web/handlers/FlingGestureHandler.js +4 -0
  127. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  128. package/lib/module/web/handlers/GestureHandler.js +18 -4
  129. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  130. package/lib/module/web/handlers/LongPressGestureHandler.js +8 -5
  131. package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
  132. package/lib/module/web/handlers/PanGestureHandler.js +4 -0
  133. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  134. package/lib/module/web/handlers/TapGestureHandler.js +4 -0
  135. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  136. package/lib/module/web/interfaces.js +9 -20
  137. package/lib/module/web/interfaces.js.map +1 -1
  138. package/lib/module/web/tools/GestureHandlerOrchestrator.js +2 -2
  139. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  140. package/lib/module/web/tools/GestureHandlerWebDelegate.js +34 -0
  141. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  142. package/lib/module/web/tools/NodeManager.js +3 -2
  143. package/lib/module/web/tools/NodeManager.js.map +1 -1
  144. package/lib/module/web/tools/PointerEventManager.js +41 -12
  145. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  146. package/lib/module/web/tools/TouchEventManager.js +2 -2
  147. package/lib/module/web/tools/TouchEventManager.js.map +1 -1
  148. package/lib/module/web/utils.js +2 -0
  149. package/lib/module/web/utils.js.map +1 -1
  150. package/lib/typescript/PointerType.d.ts +6 -0
  151. package/lib/typescript/RNGestureHandlerModule.d.ts +2 -13
  152. package/lib/typescript/RNGestureHandlerModule.windows.d.ts +5 -21
  153. package/lib/typescript/components/DrawerLayout.d.ts +11 -0
  154. package/lib/typescript/components/GestureHandlerRootView.android.d.ts +1 -1
  155. package/lib/typescript/components/GestureHandlerRootView.d.ts +1 -1
  156. package/lib/typescript/components/GestureHandlerRootView.web.d.ts +1 -1
  157. package/lib/typescript/getShadowNodeFromRef.d.ts +1 -1
  158. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
  159. package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -1
  160. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +6 -1
  161. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +2 -1
  162. package/lib/typescript/handlers/gestures/gesture.d.ts +2 -0
  163. package/lib/typescript/index.d.ts +2 -0
  164. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +14 -0
  165. package/lib/typescript/web/handlers/GestureHandler.d.ts +4 -1
  166. package/lib/typescript/web/interfaces.d.ts +10 -14
  167. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +2 -0
  168. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +7 -0
  169. package/lib/typescript/web/tools/PointerEventManager.d.ts +2 -0
  170. package/lib/typescript/web/utils.d.ts +2 -0
  171. package/package.json +14 -11
  172. package/src/PointerType.ts +6 -0
  173. package/src/RNGestureHandlerModule.ts +4 -49
  174. package/src/RNGestureHandlerModule.windows.ts +18 -100
  175. package/src/components/DrawerLayout.tsx +15 -0
  176. package/src/components/GestureHandlerRootView.android.tsx +13 -5
  177. package/src/components/GestureHandlerRootView.tsx +10 -5
  178. package/src/components/GestureHandlerRootView.web.tsx +10 -5
  179. package/src/getShadowNodeFromRef.ts +28 -6
  180. package/src/handlers/createHandler.tsx +6 -0
  181. package/src/handlers/gestureHandlerCommon.ts +7 -0
  182. package/src/handlers/gestures/GestureDetector.tsx +16 -2
  183. package/src/handlers/gestures/gesture.ts +6 -0
  184. package/src/index.ts +2 -0
  185. package/src/specs/NativeRNGestureHandlerModule.ts +26 -0
  186. package/src/web/handlers/FlingGestureHandler.ts +4 -0
  187. package/src/web/handlers/GestureHandler.ts +20 -2
  188. package/src/web/handlers/LongPressGestureHandler.ts +8 -5
  189. package/src/web/handlers/PanGestureHandler.ts +4 -0
  190. package/src/web/handlers/TapGestureHandler.ts +4 -0
  191. package/src/web/interfaces.ts +12 -17
  192. package/src/web/tools/GestureHandlerDelegate.ts +3 -0
  193. package/src/web/tools/GestureHandlerOrchestrator.ts +2 -2
  194. package/src/web/tools/GestureHandlerWebDelegate.ts +39 -0
  195. package/src/web/tools/NodeManager.ts +5 -1
  196. package/src/web/tools/PointerEventManager.ts +46 -10
  197. package/src/web/tools/TouchEventManager.ts +2 -8
  198. package/src/web/utils.ts +9 -0
  199. package/ios/Handlers/RNPinchHandler.m +0 -95
  200. package/ios/Handlers/RNRotationHandler.m +0 -93
  201. package/ios/RNGestureHandlerModule.h +0 -7
  202. package/lib/commonjs/RNGestureHandlerModule.macos.js +0 -149
  203. package/lib/commonjs/RNGestureHandlerModule.macos.js.map +0 -1
  204. package/lib/module/RNGestureHandlerModule.macos.js +0 -110
  205. package/lib/module/RNGestureHandlerModule.macos.js.map +0 -1
  206. package/lib/typescript/RNGestureHandlerModule.macos.d.ts +0 -47
  207. package/src/RNGestureHandlerModule.macos.ts +0 -133
  208. /package/{ios → apple}/Handlers/RNFlingHandler.h +0 -0
  209. /package/{ios → apple}/Handlers/RNForceTouchHandler.h +0 -0
  210. /package/{ios → apple}/Handlers/RNHoverHandler.h +0 -0
  211. /package/{ios → apple}/Handlers/RNLongPressHandler.h +0 -0
  212. /package/{ios → apple}/Handlers/RNManualHandler.h +0 -0
  213. /package/{ios → apple}/Handlers/RNNativeViewHandler.h +0 -0
  214. /package/{ios → apple}/Handlers/RNPanHandler.h +0 -0
  215. /package/{ios → apple}/Handlers/RNPinchHandler.h +0 -0
  216. /package/{ios → apple}/Handlers/RNRotationHandler.h +0 -0
  217. /package/{ios → apple}/Handlers/RNTapHandler.h +0 -0
  218. /package/{ios → apple}/RNGHTouchEventType.h +0 -0
  219. /package/{ios → apple}/RNGestureHandler.xcodeproj/project.pbxproj +0 -0
  220. /package/{ios → apple}/RNGestureHandler.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  221. /package/{ios → apple}/RNGestureHandlerActionType.h +0 -0
  222. /package/{ios → apple}/RNGestureHandlerButtonComponentView.h +0 -0
  223. /package/{ios → apple}/RNGestureHandlerButtonComponentView.mm +0 -0
  224. /package/{ios → apple}/RNGestureHandlerButtonManager.h +0 -0
  225. /package/{ios → apple}/RNGestureHandlerDirection.h +0 -0
  226. /package/{ios → apple}/RNGestureHandlerRootViewComponentView.mm +0 -0
  227. /package/{ios → apple}/RNGestureHandlerState.h +0 -0
  228. /package/{ios → apple}/RNGestureHandlerStateManager.h +0 -0
  229. /package/{ios → apple}/RNRootViewGestureRecognizer.h +0 -0
@@ -1,5 +1,6 @@
1
1
  import type GestureHandler from '../handlers/GestureHandler';
2
2
  import { GestureHandlerDelegate, MeasureResult } from './GestureHandlerDelegate';
3
+ import { Config } from '../interfaces';
3
4
  export declare class GestureHandlerWebDelegate implements GestureHandlerDelegate<HTMLElement> {
4
5
  private view;
5
6
  private gestureHandler;
@@ -13,9 +14,15 @@ export declare class GestureHandlerWebDelegate implements GestureHandlerDelegate
13
14
  measureView(): MeasureResult;
14
15
  reset(): void;
15
16
  tryResetCursor(): void;
17
+ private shouldDisableContextMenu;
18
+ private addContextMenuListeners;
19
+ private removeContextMenuListeners;
20
+ private disableContextMenu;
21
+ private enableContextMenu;
16
22
  onBegin(): void;
17
23
  onActivate(): void;
18
24
  onEnd(): void;
19
25
  onCancel(): void;
20
26
  onFail(): void;
27
+ destroy(config: Config): void;
21
28
  }
@@ -2,6 +2,8 @@ import { AdaptedEvent, EventTypes } from '../interfaces';
2
2
  import EventManager from './EventManager';
3
3
  export default class PointerEventManager extends EventManager<HTMLElement> {
4
4
  private trackedPointers;
5
+ private readonly mouseButtonsMapper;
6
+ constructor(view: HTMLElement);
5
7
  setListeners(): void;
6
8
  protected mapEvent(event: PointerEvent, eventType: EventTypes): AdaptedEvent;
7
9
  resetManager(): void;
@@ -1,4 +1,6 @@
1
+ import { PointerType } from '../PointerType';
1
2
  export declare function isPointerInBounds(view: HTMLElement, { x, y }: {
2
3
  x: number;
3
4
  y: number;
4
5
  }): boolean;
6
+ export declare const PointerTypeMapping: Map<string, PointerType>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gesture-handler",
3
- "version": "2.14.1",
3
+ "version": "2.16.0-rc.0",
4
4
  "description": "Experimental implementation of a new declarative API for gesture handling in react-native",
5
5
  "scripts": {
6
6
  "prepare": "bob build && husky install",
@@ -9,10 +9,10 @@
9
9
  "precommit": "lint-staged",
10
10
  "release": "npm login && release-it",
11
11
  "ts-check": "yarn tsc --noEmit",
12
- "format:js": "prettier --write --list-different './{src,example,FabricExample}/**/*.{js,jsx,ts,tsx}'",
12
+ "format:js": "prettier --write --list-different './{src,example,FabricExample,MacOSExample}/**/*.{js,jsx,ts,tsx}'",
13
13
  "format:android": "node ./scripts/format-android.js",
14
- "format:ios": "find ios/ -iname *.h -o -iname *.m -o -iname *.cpp -o -iname *.mm | xargs clang-format -i",
15
- "lint:js": "eslint --ext '.js,.ts,.tsx' src/ example/src FabricExample/src && yarn prettier --check './{src,example,FabricExample}/**/*.{js,jsx,ts,tsx}'",
14
+ "format:ios": "find apple/ -iname *.h -o -iname *.m -o -iname *.cpp -o -iname *.mm | xargs clang-format -i",
15
+ "lint:js": "eslint --ext '.js,.ts,.tsx' src/ example/src FabricExample/src MacOSExample/src && yarn prettier --check './{src,example,FabricExample,MacOSExample}/**/*.{js,jsx,ts,tsx}'",
16
16
  "lint:js-root": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check './src/**/*.{js,jsx,ts,tsx}'",
17
17
  "lint:android": "./android/gradlew -p android spotlessCheck -q"
18
18
  },
@@ -36,7 +36,7 @@
36
36
  "android/common/src/main/java/",
37
37
  "android/reanimated/src/main/java/",
38
38
  "android/noreanimated/src/main/java/",
39
- "ios/",
39
+ "apple/",
40
40
  "Swipeable/",
41
41
  "jest-utils/",
42
42
  "DrawerLayout/",
@@ -77,7 +77,7 @@
77
77
  "@babel/preset-env": "^7.12.11",
78
78
  "@babel/preset-typescript": "^7.12.7",
79
79
  "@babel/runtime": "^7.12.5",
80
- "@react-native/babel-preset": "^0.73.18",
80
+ "@react-native/babel-preset": "^0.73.19",
81
81
  "@testing-library/jest-native": "^4.0.4",
82
82
  "@testing-library/react-native": "^9.0.0",
83
83
  "@types/hammerjs": "^2.0.38",
@@ -101,7 +101,7 @@
101
101
  "prettier": "^2.7.1",
102
102
  "react": "18.2.0",
103
103
  "react-dom": "^16.12.0",
104
- "react-native": "0.73.0-rc.5",
104
+ "react-native": "0.73.2",
105
105
  "react-native-builder-bob": "^0.17.1",
106
106
  "react-native-reanimated": "^2.3.1",
107
107
  "react-native-web": "^0.11.7",
@@ -114,9 +114,9 @@
114
114
  "react-native": "*"
115
115
  },
116
116
  "lint-staged": {
117
- "./{src,example,FabricExample}/**/*.{ts,tsx}": "yarn format:js",
117
+ "./{src,example,FabricExample,MacOSExample}/**/*.{ts,tsx}": "yarn format:js",
118
118
  "android/**/*.kt": "yarn format:android",
119
- "ios/**/*.{h,m,mm,cpp}": "yarn format:ios"
119
+ "apple/**/*.{h,m,mm,cpp}": "yarn format:ios"
120
120
  },
121
121
  "release-it": {
122
122
  "hooks": {
@@ -146,7 +146,10 @@
146
146
  ],
147
147
  "codegenConfig": {
148
148
  "name": "rngesturehandler_codegen",
149
- "type": "components",
150
- "jsSrcsDir": "./src/specs"
149
+ "type": "all",
150
+ "jsSrcsDir": "./src/specs",
151
+ "android": {
152
+ "javaPackageName": "com.swmansion.gesturehandler"
153
+ }
151
154
  }
152
155
  }
@@ -0,0 +1,6 @@
1
+ export enum PointerType {
2
+ TOUCH,
3
+ STYLUS,
4
+ MOUSE,
5
+ OTHER,
6
+ }
@@ -1,50 +1,5 @@
1
- import { NativeModules } from 'react-native';
2
- import { ActionType } from './ActionType';
3
- import { tagMessage } from './utils';
4
- const { RNGestureHandlerModule } = NativeModules;
1
+ // Reexport the native module spec used by codegen. The relevant files are inluded on Android
2
+ // to ensure the compatibility with the old arch, while iOS doesn't require those at all.
5
3
 
6
- if (RNGestureHandlerModule == null) {
7
- console.error(
8
- tagMessage(
9
- `react-native-gesture-handler module was not found. Make sure you're running your app on the native platform and your code is linked properly (cd ios && pod install && cd ..).
10
-
11
- For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`
12
- .split('\n')
13
- .map((line) => line.trim())
14
- .join('\n')
15
- )
16
- );
17
- }
18
-
19
- if (
20
- RNGestureHandlerModule &&
21
- RNGestureHandlerModule.flushOperations === undefined
22
- ) {
23
- RNGestureHandlerModule.flushOperations = () => {
24
- // NO-OP if not defined
25
- };
26
- }
27
-
28
- export type RNGestureHandlerModuleProps = {
29
- handleSetJSResponder: (tag: number, blockNativeResponder: boolean) => void;
30
- handleClearJSResponder: () => void;
31
- createGestureHandler: (
32
- handlerName: string,
33
- handlerTag: number,
34
- config: Readonly<Record<string, unknown>>
35
- ) => void;
36
- attachGestureHandler: (
37
- handlerTag: number,
38
- newView: number,
39
- actionType: ActionType
40
- ) => void;
41
- updateGestureHandler: (
42
- handlerTag: number,
43
- newConfig: Readonly<Record<string, unknown>>
44
- ) => void;
45
- dropGestureHandler: (handlerTag: number) => void;
46
- install: () => void;
47
- flushOperations: () => void;
48
- };
49
-
50
- export default RNGestureHandlerModule as RNGestureHandlerModuleProps;
4
+ import Module from './specs/NativeRNGestureHandlerModule';
5
+ export default Module;
@@ -1,11 +1,8 @@
1
1
  import React from 'react';
2
2
 
3
3
  import { ActionType } from './ActionType';
4
- import { isNewWebImplementationEnabled } from './EnableNewWebImplementation';
5
4
 
6
- //GestureHandlers
7
- import InteractionManager from './web/tools/InteractionManager';
8
- import NodeManager from './web/tools/NodeManager';
5
+ // GestureHandlers
9
6
  import PanGestureHandler from './web/handlers/PanGestureHandler';
10
7
  import TapGestureHandler from './web/handlers/TapGestureHandler';
11
8
  import LongPressGestureHandler from './web/handlers/LongPressGestureHandler';
@@ -14,18 +11,7 @@ import RotationGestureHandler from './web/handlers/RotationGestureHandler';
14
11
  import FlingGestureHandler from './web/handlers/FlingGestureHandler';
15
12
  import NativeViewGestureHandler from './web/handlers/NativeViewGestureHandler';
16
13
  import ManualGestureHandler from './web/handlers/ManualGestureHandler';
17
-
18
- //Hammer Handlers
19
- import * as HammerNodeManager from './web_hammer/NodeManager';
20
- import HammerNativeViewGestureHandler from './web_hammer/NativeViewGestureHandler';
21
- import HammerPanGestureHandler from './web_hammer/PanGestureHandler';
22
- import HammerTapGestureHandler from './web_hammer/TapGestureHandler';
23
- import HammerLongPressGestureHandler from './web_hammer/LongPressGestureHandler';
24
- import HammerPinchGestureHandler from './web_hammer/PinchGestureHandler';
25
- import HammerRotationGestureHandler from './web_hammer/RotationGestureHandler';
26
- import HammerFlingGestureHandler from './web_hammer/FlingGestureHandler';
27
14
  import { Config } from './web/interfaces';
28
- import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
29
15
 
30
16
  export const Gestures = {
31
17
  NativeViewGestureHandler,
@@ -38,16 +24,6 @@ export const Gestures = {
38
24
  ManualGestureHandler,
39
25
  };
40
26
 
41
- export const HammerGestures = {
42
- NativeViewGestureHandler: HammerNativeViewGestureHandler,
43
- PanGestureHandler: HammerPanGestureHandler,
44
- TapGestureHandler: HammerTapGestureHandler,
45
- LongPressGestureHandler: HammerLongPressGestureHandler,
46
- PinchGestureHandler: HammerPinchGestureHandler,
47
- RotationGestureHandler: HammerRotationGestureHandler,
48
- FlingGestureHandler: HammerFlingGestureHandler,
49
- };
50
-
51
27
  export default {
52
28
  handleSetJSResponder(_tag: number, _blockNativeResponder: boolean) {
53
29
  // NO-OP
@@ -56,89 +32,31 @@ export default {
56
32
  // NO-OP
57
33
  },
58
34
  createGestureHandler<T>(
59
- handlerName: keyof typeof Gestures,
60
- handlerTag: number,
61
- config: T
35
+ _handlerName: keyof typeof Gestures,
36
+ _handlerTag: number,
37
+ _config: T
62
38
  ) {
63
- if (isNewWebImplementationEnabled()) {
64
- if (!(handlerName in Gestures)) {
65
- throw new Error(
66
- `react-native-gesture-handler: ${handlerName} is not supported on web.`
67
- );
68
- }
69
-
70
- const GestureClass = Gestures[handlerName];
71
- NodeManager.createGestureHandler(
72
- handlerTag,
73
- new GestureClass(new GestureHandlerWebDelegate())
74
- );
75
- InteractionManager.getInstance().configureInteractions(
76
- NodeManager.getHandler(handlerTag),
77
- config as unknown as Config
78
- );
79
- } else {
80
- if (!(handlerName in HammerGestures)) {
81
- throw new Error(
82
- `react-native-gesture-handler: ${handlerName} is not supported on web.`
83
- );
84
- }
85
-
86
- // @ts-ignore If it doesn't exist, the error is thrown
87
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
88
- const GestureClass = HammerGestures[handlerName];
89
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
90
- HammerNodeManager.createGestureHandler(handlerTag, new GestureClass());
91
- }
92
-
93
- this.updateGestureHandler(handlerTag, config as unknown as Config);
39
+ // NO-OP
94
40
  },
95
41
  attachGestureHandler(
96
- handlerTag: number,
42
+ _handlerTag: number,
97
43
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- newView: any,
44
+ _newView: any,
99
45
  _actionType: ActionType,
100
- propsRef: React.RefObject<unknown>
46
+ _propsRef: React.RefObject<unknown>
101
47
  ) {
102
- if (
103
- !(newView instanceof HTMLElement || newView instanceof React.Component)
104
- ) {
105
- return;
106
- }
107
-
108
- if (isNewWebImplementationEnabled()) {
109
- //@ts-ignore Types should be HTMLElement or React.Component
110
- NodeManager.getHandler(handlerTag).init(newView, propsRef);
111
- } else {
112
- //@ts-ignore Types should be HTMLElement or React.Component
113
- HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef);
114
- }
48
+ // NO-OP
115
49
  },
116
- updateGestureHandler(handlerTag: number, newConfig: Config) {
117
- if (isNewWebImplementationEnabled()) {
118
- NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
119
-
120
- InteractionManager.getInstance().configureInteractions(
121
- NodeManager.getHandler(handlerTag),
122
- newConfig
123
- );
124
- } else {
125
- HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
126
- }
50
+ updateGestureHandler(_handlerTag: number, _newConfig: Config) {
51
+ // NO-OP
127
52
  },
128
- getGestureHandlerNode(handlerTag: number) {
129
- if (isNewWebImplementationEnabled()) {
130
- return NodeManager.getHandler(handlerTag);
131
- } else {
132
- return HammerNodeManager.getHandler(handlerTag);
133
- }
53
+ getGestureHandlerNode(_handlerTag: number) {
54
+ // NO-OP
134
55
  },
135
- dropGestureHandler(handlerTag: number) {
136
- if (isNewWebImplementationEnabled()) {
137
- NodeManager.dropGestureHandler(handlerTag);
138
- } else {
139
- HammerNodeManager.dropGestureHandler(handlerTag);
140
- }
56
+ dropGestureHandler(_handlerTag: number) {
57
+ // NO-OP
58
+ },
59
+ flushOperations() {
60
+ // NO-OP
141
61
  },
142
- // eslint-disable-next-line @typescript-eslint/no-empty-function
143
- flushOperations() {},
144
62
  };
@@ -38,6 +38,7 @@ import {
38
38
  TapGestureHandlerEventPayload,
39
39
  } from '../handlers/TapGestureHandler';
40
40
  import { State } from '../State';
41
+ import { MouseButton } from '../web/interfaces';
41
42
 
42
43
  const DRAG_TOSS = 0.05;
43
44
 
@@ -173,6 +174,18 @@ export interface DrawerLayoutProps {
173
174
  * Values: see CSS cursor values
174
175
  */
175
176
  activeCursor?: ActiveCursor;
177
+
178
+ /**
179
+ * @default 'MouseButton.LEFT'
180
+ * Allows to choose which mouse button should underlying pan handler react to.
181
+ */
182
+ mouseButton?: MouseButton;
183
+
184
+ /**
185
+ * @default 'false if MouseButton.RIGHT is specified'
186
+ * Allows to enable/disable context menu.
187
+ */
188
+ enableContextMenu?: boolean;
176
189
  }
177
190
 
178
191
  export type DrawerLayoutState = {
@@ -700,6 +713,8 @@ export default class DrawerLayout extends Component<
700
713
  // @ts-ignore could be fixed in handler types
701
714
  userSelect={this.props.userSelect}
702
715
  activeCursor={this.props.activeCursor}
716
+ mouseButton={this.props.mouseButton}
717
+ enableContextMenu={this.props.enableContextMenu}
703
718
  ref={this.setPanGestureRef}
704
719
  hitSlop={hitSlop}
705
720
  activeOffsetX={gestureOrientation * minSwipeDistance!}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
- import { ViewProps } from 'react-native';
3
+ import { ViewProps, StyleSheet } from 'react-native';
4
4
  import { maybeInitializeFabric } from '../init';
5
5
  import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
6
6
  import GestureHandlerRootViewNativeComponent from '../specs/RNGestureHandlerRootViewNativeComponent';
@@ -8,9 +8,10 @@ import GestureHandlerRootViewNativeComponent from '../specs/RNGestureHandlerRoot
8
8
  export interface GestureHandlerRootViewProps
9
9
  extends PropsWithChildren<ViewProps> {}
10
10
 
11
- export default function GestureHandlerRootView(
12
- props: GestureHandlerRootViewProps
13
- ) {
11
+ export default function GestureHandlerRootView({
12
+ style,
13
+ ...rest
14
+ }: GestureHandlerRootViewProps) {
14
15
  // try initialize fabric on the first render, at this point we can
15
16
  // reliably check if fabric is enabled (the function contains a flag
16
17
  // to make sure it's called only once)
@@ -18,7 +19,14 @@ export default function GestureHandlerRootView(
18
19
 
19
20
  return (
20
21
  <GestureHandlerRootViewContext.Provider value>
21
- <GestureHandlerRootViewNativeComponent {...props} />
22
+ <GestureHandlerRootViewNativeComponent
23
+ style={style ?? styles.container}
24
+ {...rest}
25
+ />
22
26
  </GestureHandlerRootViewContext.Provider>
23
27
  );
24
28
  }
29
+
30
+ const styles = StyleSheet.create({
31
+ container: { flex: 1 },
32
+ });
@@ -1,15 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
- import { View, ViewProps } from 'react-native';
3
+ import { View, ViewProps, StyleSheet } from 'react-native';
4
4
  import { maybeInitializeFabric } from '../init';
5
5
  import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
6
6
 
7
7
  export interface GestureHandlerRootViewProps
8
8
  extends PropsWithChildren<ViewProps> {}
9
9
 
10
- export default function GestureHandlerRootView(
11
- props: GestureHandlerRootViewProps
12
- ) {
10
+ export default function GestureHandlerRootView({
11
+ style,
12
+ ...rest
13
+ }: GestureHandlerRootViewProps) {
13
14
  // try initialize fabric on the first render, at this point we can
14
15
  // reliably check if fabric is enabled (the function contains a flag
15
16
  // to make sure it's called only once)
@@ -17,7 +18,11 @@ export default function GestureHandlerRootView(
17
18
 
18
19
  return (
19
20
  <GestureHandlerRootViewContext.Provider value>
20
- <View {...props} />
21
+ <View style={style ?? styles.container} {...rest} />
21
22
  </GestureHandlerRootViewContext.Provider>
22
23
  );
23
24
  }
25
+
26
+ const styles = StyleSheet.create({
27
+ container: { flex: 1 },
28
+ });
@@ -1,17 +1,22 @@
1
1
  import * as React from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
- import { View, ViewProps } from 'react-native';
3
+ import { View, ViewProps, StyleSheet } from 'react-native';
4
4
  import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
5
5
 
6
6
  export interface GestureHandlerRootViewProps
7
7
  extends PropsWithChildren<ViewProps> {}
8
8
 
9
- export default function GestureHandlerRootView(
10
- props: GestureHandlerRootViewProps
11
- ) {
9
+ export default function GestureHandlerRootView({
10
+ style,
11
+ ...rest
12
+ }: GestureHandlerRootViewProps) {
12
13
  return (
13
14
  <GestureHandlerRootViewContext.Provider value>
14
- <View {...props} />
15
+ <View style={style ?? styles.container} {...rest} />
15
16
  </GestureHandlerRootViewContext.Provider>
16
17
  );
17
18
  }
19
+
20
+ const styles = StyleSheet.create({
21
+ container: { flex: 1 },
22
+ });
@@ -2,21 +2,43 @@
2
2
  // attached view may get flattened on Fabric. This implementation causes errors
3
3
  // on web due to the static resolution of `require` statements by webpack breaking
4
4
  // the conditional importing. Solved by making .web file.
5
- let findHostInstance_DEPRECATED: (ref: any) => void;
5
+ let findHostInstance_DEPRECATED: (ref: unknown) => void;
6
+ let getInternalInstanceHandleFromPublicInstance: (ref: unknown) => {
7
+ stateNode: { node: unknown };
8
+ };
6
9
 
7
- export function getShadowNodeFromRef(ref: any) {
10
+ export function getShadowNodeFromRef(ref: unknown) {
8
11
  // load findHostInstance_DEPRECATED lazily because it may not be available before render
9
12
  if (findHostInstance_DEPRECATED === undefined) {
10
13
  try {
14
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
11
15
  findHostInstance_DEPRECATED =
12
- // eslint-disable-next-line @typescript-eslint/no-var-requires
16
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
13
17
  require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
14
18
  } catch (e) {
15
- findHostInstance_DEPRECATED = (_ref: any) => null;
19
+ findHostInstance_DEPRECATED = (_ref: unknown) => null;
20
+ }
21
+ }
22
+
23
+ // load findHostInstance_DEPRECATED lazily because it may not be available before render
24
+ if (getInternalInstanceHandleFromPublicInstance === undefined) {
25
+ try {
26
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
27
+ getInternalInstanceHandleFromPublicInstance =
28
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
29
+ require('react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance')
30
+ .getInternalInstanceHandleFromPublicInstance ??
31
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
32
+ ((ref: any) => ref._internalInstanceHandle);
33
+ } catch (e) {
34
+ getInternalInstanceHandleFromPublicInstance = (ref: any) =>
35
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
36
+ ref._internalInstanceHandle;
16
37
  }
17
38
  }
18
39
 
19
40
  // @ts-ignore Fabric
20
- return findHostInstance_DEPRECATED(ref)._internalInstanceHandle.stateNode
21
- .node;
41
+ return getInternalInstanceHandleFromPublicInstance(
42
+ findHostInstance_DEPRECATED(ref)
43
+ ).stateNode.node;
22
44
  }
@@ -5,6 +5,8 @@ import {
5
5
  DeviceEventEmitter,
6
6
  EmitterSubscription,
7
7
  } from 'react-native';
8
+ // @ts-ignore - its taken straight from RN
9
+ import { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry';
8
10
  // @ts-ignore - it isn't typed by TS & don't have definitelyTyped types
9
11
  import deepEqual from 'lodash/isEqual';
10
12
  import RNGestureHandlerModule from '../RNGestureHandlerModule';
@@ -33,6 +35,10 @@ import { ghQueueMicrotask } from '../ghQueueMicrotask';
33
35
 
34
36
  const UIManagerAny = UIManager as any;
35
37
 
38
+ customDirectEventTypes.topGestureHandlerEvent = {
39
+ registrationName: 'onGestureHandlerEvent',
40
+ };
41
+
36
42
  const customGHEventsConfigFabricAndroid = {
37
43
  topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },
38
44
  topOnGestureHandlerStateChange: {
@@ -12,6 +12,8 @@ import { handlerIDToTag } from './handlersRegistry';
12
12
  import { toArray } from '../utils';
13
13
  import RNGestureHandlerModule from '../RNGestureHandlerModule';
14
14
  import { ghQueueMicrotask } from '../ghQueueMicrotask';
15
+ import { MouseButton } from '../web/interfaces';
16
+ import { PointerType } from '../PointerType';
15
17
 
16
18
  const commonProps = [
17
19
  'id',
@@ -21,6 +23,8 @@ const commonProps = [
21
23
  'cancelsTouchesInView',
22
24
  'userSelect',
23
25
  'activeCursor',
26
+ 'mouseButton',
27
+ 'enableContextMenu',
24
28
  ] as const;
25
29
 
26
30
  const componentInteractionProps = [
@@ -51,6 +55,7 @@ export interface GestureEventPayload {
51
55
  handlerTag: number;
52
56
  numberOfPointers: number;
53
57
  state: ValueOf<typeof State>;
58
+ pointerType: PointerType;
54
59
  }
55
60
  export interface HandlerStateChangeEventPayload extends GestureEventPayload {
56
61
  oldState: ValueOf<typeof State>;
@@ -149,6 +154,8 @@ export type CommonGestureConfig = {
149
154
  hitSlop?: HitSlop;
150
155
  userSelect?: UserSelect;
151
156
  activeCursor?: ActiveCursor;
157
+ mouseButton?: MouseButton;
158
+ enableContextMenu?: boolean;
152
159
  };
153
160
 
154
161
  // Events payloads are types instead of interfaces due to TS limitation.
@@ -605,10 +605,20 @@ const applyUserSelectProp = (
605
605
  }
606
606
  };
607
607
 
608
+ const applyEnableContextMenuProp = (
609
+ enableContextMenu: boolean,
610
+ gesture: ComposedGesture | GestureType
611
+ ): void => {
612
+ for (const g of gesture.toGestureArray()) {
613
+ g.config.enableContextMenu = enableContextMenu;
614
+ }
615
+ };
616
+
608
617
  interface GestureDetectorProps {
609
618
  gesture: ComposedGesture | GestureType;
610
- userSelect?: UserSelect;
611
619
  children?: React.ReactNode;
620
+ userSelect?: UserSelect;
621
+ enableContextMenu?: boolean;
612
622
  }
613
623
  interface GestureDetectorState {
614
624
  firstRender: boolean;
@@ -630,6 +640,10 @@ export const GestureDetector = (props: GestureDetectorProps) => {
630
640
  applyUserSelectProp(props.userSelect, gestureConfig);
631
641
  }
632
642
 
643
+ if (props.enableContextMenu !== undefined) {
644
+ applyEnableContextMenuProp(props.enableContextMenu, gestureConfig);
645
+ }
646
+
633
647
  const gesture = gestureConfig.toGestureArray();
634
648
  const useReanimatedHook = gesture.some((g) => g.shouldUseReanimated);
635
649
 
@@ -763,7 +777,7 @@ export const GestureDetector = (props: GestureDetectorProps) => {
763
777
  // in case the view has changed, while config update would be handled be the `useEffect` above
764
778
  onHandlersUpdate(true);
765
779
 
766
- if (isFabric()) {
780
+ if (isFabric() && global.isFormsStackingContext) {
767
781
  const node = getShadowNodeFromRef(ref);
768
782
  if (global.isFormsStackingContext(node) === false) {
769
783
  console.error(
@@ -17,6 +17,7 @@ import { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';
17
17
  import { TapGestureHandlerEventPayload } from '../TapGestureHandler';
18
18
  import { NativeViewGestureHandlerPayload } from '../NativeViewGestureHandler';
19
19
  import { isRemoteDebuggingEnabled } from '../../utils';
20
+ import { MouseButton } from '../../web/interfaces';
20
21
 
21
22
  export type GestureType =
22
23
  | BaseGesture<Record<string, unknown>>
@@ -257,6 +258,11 @@ export abstract class BaseGesture<
257
258
  return this;
258
259
  }
259
260
 
261
+ mouseButton(mouseButton: MouseButton) {
262
+ this.config.mouseButton = mouseButton;
263
+ return this;
264
+ }
265
+
260
266
  runOnJS(runOnJS: boolean) {
261
267
  this.config.runOnJS = runOnJS;
262
268
  return this;
package/src/index.ts CHANGED
@@ -2,6 +2,8 @@ import { initialize } from './init';
2
2
 
3
3
  export { Directions } from './Directions';
4
4
  export { State } from './State';
5
+ export { MouseButton } from './web/interfaces';
6
+ export { PointerType } from './PointerType';
5
7
  export { default as gestureHandlerRootHOC } from './components/gestureHandlerRootHOC';
6
8
  export { default as GestureHandlerRootView } from './components/GestureHandlerRootView';
7
9
  export type {