react-native-gesture-handler 2.21.2 → 2.22.0-rc.1

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 (195) hide show
  1. package/README.md +1 -3
  2. package/android/build.gradle +10 -0
  3. package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +3 -2
  4. package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerDelegate.java +3 -2
  5. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +16 -0
  6. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +1 -1
  7. package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +45 -8
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +18 -0
  9. package/apple/Handlers/RNFlingHandler.m +0 -1
  10. package/apple/Handlers/RNForceTouchHandler.m +0 -1
  11. package/apple/Handlers/RNLongPressHandler.m +0 -1
  12. package/apple/Handlers/RNManualHandler.m +0 -1
  13. package/apple/Handlers/RNPanHandler.m +0 -3
  14. package/apple/Handlers/RNPinchHandler.m +0 -1
  15. package/apple/Handlers/RNRotationHandler.m +0 -1
  16. package/apple/Handlers/RNTapHandler.m +0 -1
  17. package/apple/RNGestureHandlerButton.h +1 -0
  18. package/apple/RNGestureHandlerButton.mm +51 -0
  19. package/apple/RNGestureHandlerManager.mm +6 -1
  20. package/apple/RNManualActivationRecognizer.m +1 -0
  21. package/lib/commonjs/ActionType.js.map +1 -1
  22. package/lib/commonjs/Directions.js.map +1 -1
  23. package/lib/commonjs/EnableNewWebImplementation.js +14 -1
  24. package/lib/commonjs/EnableNewWebImplementation.js.map +1 -1
  25. package/lib/commonjs/State.js.map +1 -1
  26. package/lib/commonjs/TouchEventType.js.map +1 -1
  27. package/lib/commonjs/components/Pressable/Pressable.js +1 -1
  28. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  29. package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
  30. package/lib/commonjs/components/Swipeable.js.map +1 -1
  31. package/lib/commonjs/components/Text.js +61 -0
  32. package/lib/commonjs/components/Text.js.map +1 -0
  33. package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
  34. package/lib/commonjs/getShadowNodeFromRef.js +10 -2
  35. package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
  36. package/lib/commonjs/ghQueueMicrotask.js.map +1 -1
  37. package/lib/commonjs/handlers/createHandler.js +12 -0
  38. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  39. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  40. package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js +4 -0
  41. package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -1
  42. package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js +4 -0
  43. package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -1
  44. package/lib/commonjs/handlers/gestures/GestureDetector/index.js +3 -0
  45. package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
  46. package/lib/commonjs/handlers/gestures/GestureDetector/useMountReactions.js +48 -0
  47. package/lib/commonjs/handlers/gestures/GestureDetector/useMountReactions.js.map +1 -0
  48. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  49. package/lib/commonjs/handlers/utils.js +1 -0
  50. package/lib/commonjs/handlers/utils.js.map +1 -1
  51. package/lib/commonjs/index.js +8 -0
  52. package/lib/commonjs/index.js.map +1 -1
  53. package/lib/commonjs/jestUtils/jestUtils.js.map +1 -1
  54. package/lib/commonjs/mountRegistry.js +49 -0
  55. package/lib/commonjs/mountRegistry.js.map +1 -0
  56. package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
  57. package/lib/commonjs/web/handlers/FlingGestureHandler.js +0 -4
  58. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  59. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  60. package/lib/commonjs/web/handlers/HoverGestureHandler.js +0 -14
  61. package/lib/commonjs/web/handlers/HoverGestureHandler.js.map +1 -1
  62. package/lib/commonjs/web/handlers/ManualGestureHandler.js +0 -14
  63. package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
  64. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +3 -5
  65. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
  66. package/lib/commonjs/web/handlers/PanGestureHandler.js +0 -4
  67. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  68. package/lib/commonjs/web/handlers/PinchGestureHandler.js +0 -10
  69. package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
  70. package/lib/commonjs/web/handlers/RotationGestureHandler.js +0 -14
  71. package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
  72. package/lib/commonjs/web/handlers/TapGestureHandler.js +0 -4
  73. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  74. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  75. package/lib/commonjs/web_hammer/GestureHandler.js.map +1 -1
  76. package/lib/commonjs/web_hammer/PressGestureHandler.js.map +1 -1
  77. package/lib/module/ActionType.js.map +1 -1
  78. package/lib/module/Directions.js.map +1 -1
  79. package/lib/module/EnableNewWebImplementation.js +14 -1
  80. package/lib/module/EnableNewWebImplementation.js.map +1 -1
  81. package/lib/module/State.js.map +1 -1
  82. package/lib/module/TouchEventType.js.map +1 -1
  83. package/lib/module/components/Pressable/Pressable.js +1 -1
  84. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  85. package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
  86. package/lib/module/components/Swipeable.js.map +1 -1
  87. package/lib/module/components/Text.js +44 -0
  88. package/lib/module/components/Text.js.map +1 -0
  89. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  90. package/lib/module/getShadowNodeFromRef.js +10 -2
  91. package/lib/module/getShadowNodeFromRef.js.map +1 -1
  92. package/lib/module/ghQueueMicrotask.js.map +1 -1
  93. package/lib/module/handlers/createHandler.js +11 -0
  94. package/lib/module/handlers/createHandler.js.map +1 -1
  95. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  96. package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js +3 -0
  97. package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -1
  98. package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js +2 -0
  99. package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -1
  100. package/lib/module/handlers/gestures/GestureDetector/index.js +2 -0
  101. package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
  102. package/lib/module/handlers/gestures/GestureDetector/useMountReactions.js +39 -0
  103. package/lib/module/handlers/gestures/GestureDetector/useMountReactions.js.map +1 -0
  104. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  105. package/lib/module/handlers/utils.js +1 -3
  106. package/lib/module/handlers/utils.js.map +1 -1
  107. package/lib/module/index.js +1 -0
  108. package/lib/module/index.js.map +1 -1
  109. package/lib/module/jestUtils/jestUtils.js.map +1 -1
  110. package/lib/module/mountRegistry.js +40 -0
  111. package/lib/module/mountRegistry.js.map +1 -0
  112. package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
  113. package/lib/module/web/handlers/FlingGestureHandler.js +0 -4
  114. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  115. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  116. package/lib/module/web/handlers/HoverGestureHandler.js +0 -14
  117. package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
  118. package/lib/module/web/handlers/ManualGestureHandler.js +0 -14
  119. package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
  120. package/lib/module/web/handlers/NativeViewGestureHandler.js +3 -5
  121. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  122. package/lib/module/web/handlers/PanGestureHandler.js +0 -4
  123. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  124. package/lib/module/web/handlers/PinchGestureHandler.js +0 -10
  125. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  126. package/lib/module/web/handlers/RotationGestureHandler.js +0 -14
  127. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  128. package/lib/module/web/handlers/TapGestureHandler.js +0 -4
  129. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  130. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  131. package/lib/module/web_hammer/GestureHandler.js.map +1 -1
  132. package/lib/module/web_hammer/PressGestureHandler.js.map +1 -1
  133. package/lib/typescript/ActionType.d.ts +1 -1
  134. package/lib/typescript/Directions.d.ts +2 -2
  135. package/lib/typescript/EnableNewWebImplementation.d.ts +6 -0
  136. package/lib/typescript/State.d.ts +1 -1
  137. package/lib/typescript/TouchEventType.d.ts +1 -1
  138. package/lib/typescript/components/GestureButtonsProps.d.ts +2 -2
  139. package/lib/typescript/components/Text.d.ts +4 -0
  140. package/lib/typescript/components/touchables/GenericTouchable.d.ts +1 -1
  141. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +2 -2
  142. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +2 -0
  143. package/lib/typescript/handlers/gestures/gesture.d.ts +1 -1
  144. package/lib/typescript/handlers/utils.d.ts +1 -0
  145. package/lib/typescript/index.d.ts +1 -0
  146. package/lib/typescript/mocks.d.ts +3 -3
  147. package/lib/typescript/mountRegistry.d.ts +17 -0
  148. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -2
  149. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -4
  150. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -4
  151. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
  152. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +0 -2
  153. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -2
  154. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -3
  155. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +0 -2
  156. package/package.json +16 -17
  157. package/src/ActionType.ts +1 -1
  158. package/src/Directions.ts +2 -2
  159. package/src/EnableNewWebImplementation.ts +18 -0
  160. package/src/State.ts +1 -1
  161. package/src/TouchEventType.ts +2 -1
  162. package/src/components/GestureButtonsProps.ts +4 -2
  163. package/src/components/Pressable/Pressable.tsx +3 -3
  164. package/src/components/ReanimatedSwipeable.tsx +8 -8
  165. package/src/components/Swipeable.tsx +4 -4
  166. package/src/components/Text.tsx +60 -0
  167. package/src/components/touchables/GenericTouchable.tsx +1 -1
  168. package/src/getShadowNodeFromRef.ts +8 -2
  169. package/src/ghQueueMicrotask.ts +2 -2
  170. package/src/handlers/GestureHandlerEventPayload.ts +2 -2
  171. package/src/handlers/createHandler.tsx +14 -1
  172. package/src/handlers/gestureHandlerCommon.ts +3 -3
  173. package/src/handlers/gestures/GestureDetector/attachHandlers.ts +3 -0
  174. package/src/handlers/gestures/GestureDetector/dropHandlers.ts +3 -0
  175. package/src/handlers/gestures/GestureDetector/index.tsx +3 -0
  176. package/src/handlers/gestures/GestureDetector/useMountReactions.ts +51 -0
  177. package/src/handlers/gestures/gesture.ts +3 -3
  178. package/src/handlers/utils.ts +2 -1
  179. package/src/index.ts +1 -0
  180. package/src/jestUtils/jestUtils.ts +10 -12
  181. package/src/mountRegistry.ts +51 -0
  182. package/src/web/detectors/ScaleGestureDetector.ts +1 -1
  183. package/src/web/handlers/FlingGestureHandler.ts +0 -4
  184. package/src/web/handlers/GestureHandler.ts +1 -3
  185. package/src/web/handlers/HoverGestureHandler.ts +1 -9
  186. package/src/web/handlers/ManualGestureHandler.ts +1 -9
  187. package/src/web/handlers/NativeViewGestureHandler.ts +5 -5
  188. package/src/web/handlers/PanGestureHandler.ts +0 -4
  189. package/src/web/handlers/PinchGestureHandler.ts +1 -5
  190. package/src/web/handlers/RotationGestureHandler.ts +1 -9
  191. package/src/web/handlers/TapGestureHandler.ts +0 -4
  192. package/src/web/tools/GestureHandlerWebDelegate.ts +4 -4
  193. package/src/web_hammer/GestureHandler.ts +1 -1
  194. package/src/web_hammer/PressGestureHandler.ts +7 -4
  195. package/android/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +0 -86
@@ -2,5 +2,6 @@ import * as React from 'react';
2
2
  export declare function filterConfig(props: Record<string, unknown>, validProps: string[], defaults?: Record<string, unknown>): {
3
3
  [x: string]: unknown;
4
4
  };
5
+ export declare function transformIntoHandlerTags(handlerIDs: any): any;
5
6
  export declare function findNodeHandle(node: null | number | React.Component<any, any> | React.ComponentClass<any>): null | number | React.Component<any, any> | React.ComponentClass<any>;
6
7
  export declare function scheduleFlushOperations(): void;
@@ -46,6 +46,7 @@ export { RawButton, BaseButton, RectButton, BorderlessButton, PureNativeButton,
46
46
  export type { TouchableHighlightProps, TouchableOpacityProps, TouchableWithoutFeedbackProps, } from './components/touchables';
47
47
  export { TouchableHighlight, TouchableNativeFeedback, TouchableOpacity, TouchableWithoutFeedback, } from './components/touchables';
48
48
  export { ScrollView, Switch, TextInput, DrawerLayoutAndroid, FlatList, RefreshControl, } from './components/GestureComponents';
49
+ export { Text } from './components/Text';
49
50
  export { HoverEffect } from './handlers/gestures/hoverGesture';
50
51
  export type { GestureHandlerGestureEvent, GestureHandlerStateChangeEvent, GestureHandlerGestureEventNativeEvent, GestureHandlerStateChangeNativeEvent, NativeViewGestureHandlerGestureEvent, NativeViewGestureHandlerStateChangeEvent, TapGestureHandlerGestureEvent, TapGestureHandlerStateChangeEvent, ForceTouchGestureHandlerGestureEvent, ForceTouchGestureHandlerStateChangeEvent, LongPressGestureHandlerGestureEvent, LongPressGestureHandlerStateChangeEvent, PanGestureHandlerGestureEvent, PanGestureHandlerStateChangeEvent, PinchGestureHandlerGestureEvent, PinchGestureHandlerStateChangeEvent, RotationGestureHandlerGestureEvent, RotationGestureHandlerStateChangeEvent, FlingGestureHandlerGestureEvent, FlingGestureHandlerStateChangeEvent, NativeViewGestureHandlerProperties, TapGestureHandlerProperties, LongPressGestureHandlerProperties, PanGestureHandlerProperties, PinchGestureHandlerProperties, RotationGestureHandlerProperties, FlingGestureHandlerProperties, ForceTouchGestureHandlerProperties, RawButtonProperties, BaseButtonProperties, RectButtonProperties, BorderlessButtonProperties, } from './handlers/gestureHandlerTypesCompat';
51
52
  export type { SwipeableProps } from './components/Swipeable';
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import { TouchableHighlight, TouchableNativeFeedback, TouchableOpacity, TouchableWithoutFeedback, ScrollView, FlatList, Switch, TextInput, DrawerLayoutAndroid, View } from 'react-native';
2
+ import { TouchableNativeFeedback, TouchableWithoutFeedback, ScrollView, FlatList, Switch, TextInput, DrawerLayoutAndroid, View } from 'react-native';
3
3
  declare const _default: {
4
- readonly TouchableHighlight: typeof TouchableHighlight;
4
+ readonly TouchableHighlight: React.ForwardRefExoticComponent<import("react-native").TouchableHighlightProps & React.RefAttributes<View>>;
5
5
  readonly TouchableNativeFeedback: typeof TouchableNativeFeedback;
6
- readonly TouchableOpacity: typeof TouchableOpacity;
6
+ readonly TouchableOpacity: React.ForwardRefExoticComponent<import("react-native").TouchableOpacityProps & React.RefAttributes<View>>;
7
7
  readonly TouchableWithoutFeedback: typeof TouchableWithoutFeedback;
8
8
  readonly ScrollView: typeof ScrollView;
9
9
  readonly FlatList: typeof FlatList;
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { GestureType } from './handlers/gestures/gesture';
3
+ interface ReactComponentWithHandlerTag extends React.Component {
4
+ handlerTag: number;
5
+ }
6
+ export type GestureMountListener = (gesture: GestureType | ReactComponentWithHandlerTag) => void;
7
+ export declare class MountRegistry {
8
+ private static mountListeners;
9
+ private static unmountListeners;
10
+ static addMountListener(listener: GestureMountListener): () => void;
11
+ static addUnmountListener(listener: GestureMountListener): () => void;
12
+ static gestureHandlerWillMount(handler: React.Component): void;
13
+ static gestureHandlerWillUnmount(handler: React.Component): void;
14
+ static gestureWillMount(gesture: GestureType): void;
15
+ static gestureWillUnmount(gesture: GestureType): void;
16
+ }
17
+ export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { AdaptedEvent, Config } from '../interfaces';
3
2
  import GestureHandler from './GestureHandler';
4
3
  export default class FlingGestureHandler extends GestureHandler {
@@ -9,7 +8,6 @@ export default class FlingGestureHandler extends GestureHandler {
9
8
  private delayTimeout;
10
9
  private maxNumberOfPointersSimultaneously;
11
10
  private keyPointer;
12
- init(ref: number, propsRef: React.RefObject<unknown>): void;
13
11
  updateGestureConfig({ enabled, ...props }: Config): void;
14
12
  private startFling;
15
13
  private tryEndFling;
@@ -1,11 +1,8 @@
1
- /// <reference types="react" />
2
- import { AdaptedEvent, Config } from '../interfaces';
1
+ import { AdaptedEvent } from '../interfaces';
3
2
  import GestureHandler from './GestureHandler';
4
3
  export default class HoverGestureHandler extends GestureHandler {
5
4
  private stylusData;
6
- init(ref: number, propsRef: React.RefObject<unknown>): void;
7
5
  protected transformNativeEvent(): Record<string, unknown>;
8
- updateGestureConfig({ enabled, ...props }: Config): void;
9
6
  protected onPointerMoveOver(event: AdaptedEvent): void;
10
7
  protected onPointerMoveOut(event: AdaptedEvent): void;
11
8
  protected onPointerMove(event: AdaptedEvent): void;
@@ -1,9 +1,6 @@
1
- /// <reference types="react" />
2
- import { AdaptedEvent, Config } from '../interfaces';
1
+ import { AdaptedEvent } from '../interfaces';
3
2
  import GestureHandler from './GestureHandler';
4
3
  export default class ManualGestureHandler extends GestureHandler {
5
- init(ref: number, propsRef: React.RefObject<unknown>): void;
6
- updateGestureConfig({ enabled, ...props }: Config): void;
7
4
  protected onPointerDown(event: AdaptedEvent): void;
8
5
  protected onPointerAdd(event: AdaptedEvent): void;
9
6
  protected onPointerMove(event: AdaptedEvent): void;
@@ -11,7 +11,6 @@ export default class NativeViewGestureHandler extends GestureHandler {
11
11
  init(ref: number, propsRef: React.RefObject<unknown>): void;
12
12
  updateGestureConfig({ enabled, ...props }: Config): void;
13
13
  private restoreViewStyles;
14
- protected resetConfig(): void;
15
14
  protected onPointerDown(event: AdaptedEvent): void;
16
15
  protected onPointerAdd(event: AdaptedEvent): void;
17
16
  private newPointerAction;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { AdaptedEvent, Config, StylusData } from '../interfaces';
3
2
  import GestureHandler from './GestureHandler';
4
3
  export default class PanGestureHandler extends GestureHandler {
@@ -31,7 +30,6 @@ export default class PanGestureHandler extends GestureHandler {
31
30
  private enableTrackpadTwoFingerGesture;
32
31
  private endWheelTimeout;
33
32
  private wheelDevice;
34
- init(ref: number, propsRef: React.RefObject<unknown>): void;
35
33
  updateGestureConfig({ enabled, ...props }: Config): void;
36
34
  protected resetConfig(): void;
37
35
  protected transformNativeEvent(): {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { AdaptedEvent, Config } from '../interfaces';
2
+ import { AdaptedEvent } from '../interfaces';
3
3
  import GestureHandler from './GestureHandler';
4
4
  export default class PinchGestureHandler extends GestureHandler {
5
5
  private scale;
@@ -9,7 +9,6 @@ export default class PinchGestureHandler extends GestureHandler {
9
9
  private scaleDetectorListener;
10
10
  private scaleGestureDetector;
11
11
  init(ref: number, propsRef: React.RefObject<unknown>): void;
12
- updateGestureConfig({ enabled, ...props }: Config): void;
13
12
  protected transformNativeEvent(): {
14
13
  focalX: number;
15
14
  focalY: number;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { AdaptedEvent, Config } from '../interfaces';
2
+ import { AdaptedEvent } from '../interfaces';
3
3
  import GestureHandler from './GestureHandler';
4
4
  export default class RotationGestureHandler extends GestureHandler {
5
5
  private rotation;
@@ -9,7 +9,6 @@ export default class RotationGestureHandler extends GestureHandler {
9
9
  private rotationGestureListener;
10
10
  private rotationGestureDetector;
11
11
  init(ref: number, propsRef: React.RefObject<unknown>): void;
12
- updateGestureConfig({ enabled, ...props }: Config): void;
13
12
  protected transformNativeEvent(): {
14
13
  rotation: number;
15
14
  anchorX: number;
@@ -25,6 +24,5 @@ export default class RotationGestureHandler extends GestureHandler {
25
24
  protected onPointerUp(event: AdaptedEvent): void;
26
25
  protected onPointerRemove(event: AdaptedEvent): void;
27
26
  protected tryBegin(): void;
28
- activate(_force?: boolean): void;
29
27
  protected onReset(): void;
30
28
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { AdaptedEvent, Config } from '../interfaces';
3
2
  import GestureHandler from './GestureHandler';
4
3
  export default class TapGestureHandler extends GestureHandler {
@@ -19,7 +18,6 @@ export default class TapGestureHandler extends GestureHandler {
19
18
  private waitTimeout;
20
19
  private delayTimeout;
21
20
  private tapsSoFar;
22
- init(ref: number, propsRef: React.RefObject<unknown>): void;
23
21
  updateGestureConfig({ enabled, ...props }: Config): void;
24
22
  protected resetConfig(): void;
25
23
  private clearTimeouts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gesture-handler",
3
- "version": "2.21.2",
3
+ "version": "2.22.0-rc.1",
4
4
  "description": "Declarative API exposing native platform touch and gesture system to React Native",
5
5
  "scripts": {
6
6
  "prepare": "bob build && husky install",
@@ -66,44 +66,38 @@
66
66
  "dependencies": {
67
67
  "@egjs/hammerjs": "^2.0.17",
68
68
  "hoist-non-react-statics": "^3.3.0",
69
- "invariant": "^2.2.4",
70
- "prop-types": "^15.7.2"
69
+ "invariant": "^2.2.4"
71
70
  },
72
71
  "devDependencies": {
73
- "@babel/core": "^7.12.9",
74
- "@babel/plugin-proposal-class-properties": "^7.12.1",
75
- "@babel/preset-env": "^7.12.11",
72
+ "@babel/core": "^7.25.2",
73
+ "@babel/preset-env": "^7.25.3",
76
74
  "@babel/preset-typescript": "^7.12.7",
77
- "@babel/runtime": "^7.12.5",
78
- "@react-native/babel-preset": "^0.74.85",
79
- "@testing-library/jest-native": "^5.4.3",
75
+ "@react-native/babel-preset": "0.77.0-rc.3",
80
76
  "@testing-library/react-native": "^12.5.1",
81
- "@types/hammerjs": "^2.0.38",
82
77
  "@types/hoist-non-react-statics": "^3.3.1",
78
+ "@types/invariant": "^2.2.37",
83
79
  "@types/jest": "^27.0.3",
84
80
  "@types/react": "^18.2.6",
85
81
  "@types/react-test-renderer": "^17.0.0",
86
82
  "@typescript-eslint/eslint-plugin": "^4.33.0",
87
83
  "@typescript-eslint/parser": "^4.33.0",
88
- "babel-jest": "^26.6.3",
84
+ "babel-plugin-module-resolver": "^5.0.2",
89
85
  "clang-format": "^1.8.0",
90
86
  "eslint": "^7.32.0",
91
87
  "eslint-config-satya164": "^3.1.8",
92
88
  "eslint-import-resolver-babel-module": "^5.2.0",
93
- "eslint-plugin-import": "^2.22.1",
94
89
  "eslint-plugin-jest": "^26.0.0",
90
+ "eslint-plugin-prettier": "^5.2.1",
95
91
  "expo": "^35.0.1",
96
92
  "husky": "^8.0.1",
97
93
  "jest": "^28.1.0",
98
94
  "lint-staged": "^12.3.2",
99
95
  "madge": "^6.1.0",
100
- "prettier": "2.7.1",
101
- "react": "18.2.0",
102
- "react-dom": "^16.12.0",
103
- "react-native": "0.74.3",
96
+ "prettier": "3.3.3",
97
+ "react": "18.3.1",
98
+ "react-native": "0.77.0-rc.3",
104
99
  "react-native-builder-bob": "^0.17.1",
105
100
  "react-native-reanimated": "^3.12.0",
106
- "react-native-web": "^0.11.7",
107
101
  "react-test-renderer": "18.2.0",
108
102
  "release-it": "^13.6.5",
109
103
  "typescript": "5.0.4"
@@ -150,6 +144,11 @@
150
144
  "jsSrcsDir": "./src/specs",
151
145
  "android": {
152
146
  "javaPackageName": "com.swmansion.gesturehandler"
147
+ },
148
+ "ios": {
149
+ "componentProvider": {
150
+ "RNGestureHandlerButton": "RNGestureHandlerButtonComponentView"
151
+ }
153
152
  }
154
153
  },
155
154
  "packageManager": "yarn@1.22.22"
package/src/ActionType.ts CHANGED
@@ -6,4 +6,4 @@ export const ActionType = {
6
6
  } as const;
7
7
 
8
8
  // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
9
- export type ActionType = typeof ActionType[keyof typeof ActionType];
9
+ export type ActionType = (typeof ActionType)[keyof typeof ActionType];
package/src/Directions.ts CHANGED
@@ -20,7 +20,7 @@ export const DiagonalDirections = {
20
20
  } as const;
21
21
 
22
22
  // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
23
- export type Directions = typeof Directions[keyof typeof Directions];
23
+ export type Directions = (typeof Directions)[keyof typeof Directions];
24
24
  // eslint-disable-next-line @typescript-eslint/no-redeclare
25
25
  export type DiagonalDirections =
26
- typeof DiagonalDirections[keyof typeof DiagonalDirections];
26
+ (typeof DiagonalDirections)[keyof typeof DiagonalDirections];
@@ -1,17 +1,35 @@
1
1
  import { Platform } from 'react-native';
2
+ import { tagMessage } from './utils';
2
3
 
3
4
  let useNewWebImplementation = true;
4
5
  let getWasCalled = false;
5
6
 
7
+ /**
8
+ * @deprecated new web implementation is enabled by default. This function will be removed in Gesture Handler 3
9
+ */
6
10
  export function enableExperimentalWebImplementation(
7
11
  _shouldEnable = true
8
12
  ): void {
9
13
  // NO-OP since the new implementation is now the default
14
+ console.warn(
15
+ tagMessage(
16
+ 'New web implementation is enabled by default. This function will be removed in Gesture Handler 3.'
17
+ )
18
+ );
10
19
  }
11
20
 
21
+ /**
22
+ * @deprecated legacy implementation is no longer supported. This function will be removed in Gesture Handler 3
23
+ */
12
24
  export function enableLegacyWebImplementation(
13
25
  shouldUseLegacyImplementation = true
14
26
  ): void {
27
+ console.warn(
28
+ tagMessage(
29
+ 'Legacy web implementation is deprecated. This function will be removed in Gesture Handler 3.'
30
+ )
31
+ );
32
+
15
33
  if (
16
34
  Platform.OS !== 'web' ||
17
35
  useNewWebImplementation === !shouldUseLegacyImplementation
package/src/State.ts CHANGED
@@ -10,4 +10,4 @@ export const State = {
10
10
  } as const;
11
11
 
12
12
  // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
13
- export type State = typeof State[keyof typeof State];
13
+ export type State = (typeof State)[keyof typeof State];
@@ -7,4 +7,5 @@ export const TouchEventType = {
7
7
  } as const;
8
8
 
9
9
  // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
10
- export type TouchEventType = typeof TouchEventType[keyof typeof TouchEventType];
10
+ export type TouchEventType =
11
+ (typeof TouchEventType)[keyof typeof TouchEventType];
@@ -1,8 +1,10 @@
1
1
  import * as React from 'react';
2
- import { StyleProp, ViewStyle } from 'react-native';
2
+ import { AccessibilityProps, StyleProp, ViewStyle } from 'react-native';
3
3
  import type { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler';
4
4
 
5
- export interface RawButtonProps extends NativeViewGestureHandlerProps {
5
+ export interface RawButtonProps
6
+ extends NativeViewGestureHandlerProps,
7
+ AccessibilityProps {
6
8
  /**
7
9
  * Defines if more than one button could be pressed simultaneously. By default
8
10
  * set true.
@@ -58,7 +58,7 @@ export default function Pressable(props: PressableProps) {
58
58
 
59
59
  const normalizedHitSlop: Insets = useMemo(
60
60
  () =>
61
- typeof hitSlop === 'number' ? numberAsInset(hitSlop) : hitSlop ?? {},
61
+ typeof hitSlop === 'number' ? numberAsInset(hitSlop) : (hitSlop ?? {}),
62
62
  [hitSlop]
63
63
  );
64
64
 
@@ -66,7 +66,7 @@ export default function Pressable(props: PressableProps) {
66
66
  () =>
67
67
  typeof pressRetentionOffset === 'number'
68
68
  ? numberAsInset(pressRetentionOffset)
69
- : pressRetentionOffset ?? {},
69
+ : (pressRetentionOffset ?? {}),
70
70
  [pressRetentionOffset]
71
71
  );
72
72
 
@@ -352,7 +352,7 @@ export default function Pressable(props: PressableProps) {
352
352
 
353
353
  const isPressableEnabled = disabled !== true;
354
354
 
355
- const gestures = [pressAndTouchGesture, hoverGesture, buttonGesture];
355
+ const gestures = [buttonGesture, pressAndTouchGesture, hoverGesture];
356
356
 
357
357
  for (const gesture of gestures) {
358
358
  gesture.enabled(isPressableEnabled);
@@ -280,8 +280,8 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
280
280
  rowState.value === 1
281
281
  ? leftWidth.value
282
282
  : rowState.value === -1
283
- ? -rightWidth.value
284
- : 0;
283
+ ? -rightWidth.value
284
+ : 0;
285
285
 
286
286
  const offsetDrag = userDrag.value / friction + startOffset;
287
287
 
@@ -387,8 +387,8 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
387
387
  ? rightWidth.value
388
388
  : leftWidth.value
389
389
  : moveToRight
390
- ? leftWidth.value
391
- : rightWidth.value;
390
+ ? leftWidth.value
391
+ : rightWidth.value;
392
392
 
393
393
  const progressSpringConfig = {
394
394
  ...translationSpringConfig,
@@ -614,10 +614,10 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
614
614
  rowState.value === -1
615
615
  ? SwipeDirection.RIGHT
616
616
  : rowState.value === 1
617
- ? SwipeDirection.LEFT
618
- : event.translationX > 0
619
- ? SwipeDirection.RIGHT
620
- : SwipeDirection.LEFT;
617
+ ? SwipeDirection.LEFT
618
+ : event.translationX > 0
619
+ ? SwipeDirection.RIGHT
620
+ : SwipeDirection.LEFT;
621
621
 
622
622
  if (!dragStarted.value) {
623
623
  dragStarted.value = true;
@@ -362,10 +362,10 @@ export default class Swipeable extends Component<
362
362
  rowState === -1
363
363
  ? 'right'
364
364
  : rowState === 1
365
- ? 'left'
366
- : translationX > 0
367
- ? 'left'
368
- : 'right';
365
+ ? 'left'
366
+ : translationX > 0
367
+ ? 'left'
368
+ : 'right';
369
369
 
370
370
  if (rowState === 0) {
371
371
  this.props.onSwipeableOpenStartDrag?.(direction);
@@ -0,0 +1,60 @@
1
+ import React, {
2
+ ForwardedRef,
3
+ forwardRef,
4
+ RefObject,
5
+ useEffect,
6
+ useRef,
7
+ } from 'react';
8
+ import {
9
+ Platform,
10
+ Text as RNText,
11
+ TextProps as RNTextProps,
12
+ } from 'react-native';
13
+
14
+ import { Gesture, GestureDetector } from '../';
15
+
16
+ export const Text = forwardRef(
17
+ (props: RNTextProps, ref: ForwardedRef<RNText>) => {
18
+ const { onPress, ...rest } = props;
19
+ const textRef = useRef<RNText | null>(null);
20
+ const native = Gesture.Native().runOnJS(true);
21
+
22
+ const refHandler = (node: any) => {
23
+ textRef.current = node;
24
+
25
+ if (ref === null) {
26
+ return;
27
+ }
28
+
29
+ if (typeof ref === 'function') {
30
+ ref(node);
31
+ } else {
32
+ ref.current = node;
33
+ }
34
+ };
35
+
36
+ useEffect(() => {
37
+ if (Platform.OS !== 'web') {
38
+ return;
39
+ }
40
+
41
+ const textElement = ref
42
+ ? (ref as RefObject<RNText>).current
43
+ : textRef.current;
44
+
45
+ // At this point we are sure that textElement is div in HTML tree
46
+ (textElement as unknown as HTMLDivElement)?.setAttribute(
47
+ 'rnghtext',
48
+ 'true'
49
+ );
50
+ }, []);
51
+
52
+ return (
53
+ <GestureDetector gesture={native}>
54
+ <RNText onPress={onPress} ref={refHandler} {...rest} />
55
+ </GestureDetector>
56
+ );
57
+ }
58
+ );
59
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
60
+ export type Text = typeof Text & RNText;
@@ -26,7 +26,7 @@ export const TOUCHABLE_STATE = {
26
26
  MOVED_OUTSIDE: 2,
27
27
  } as const;
28
28
 
29
- type TouchableState = typeof TOUCHABLE_STATE[keyof typeof TOUCHABLE_STATE];
29
+ type TouchableState = (typeof TOUCHABLE_STATE)[keyof typeof TOUCHABLE_STATE];
30
30
 
31
31
  interface InternalProps {
32
32
  extraButtonProps: TouchableNativeFeedbackExtraProps;
@@ -11,10 +11,16 @@ export function getShadowNodeFromRef(ref: unknown) {
11
11
  // Load findHostInstance_DEPRECATED lazily because it may not be available before render
12
12
  if (findHostInstance_DEPRECATED === undefined) {
13
13
  try {
14
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment
15
+ const ReactFabric = require('react-native/Libraries/Renderer/shims/ReactFabric');
16
+ // Since RN 0.77 ReactFabric exports findHostInstance_DEPRECATED in default object so we're trying to
17
+ // access it first, then fallback on named export
14
18
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
15
19
  findHostInstance_DEPRECATED =
16
- // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
17
- require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
20
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
21
+ ReactFabric?.default?.findHostInstance_DEPRECATED ||
22
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
23
+ ReactFabric?.findHostInstance_DEPRECATED;
18
24
  } catch (e) {
19
25
  findHostInstance_DEPRECATED = (_ref: unknown) => null;
20
26
  }
@@ -4,5 +4,5 @@ export const ghQueueMicrotask =
4
4
  typeof setImmediate === 'function'
5
5
  ? setImmediate.bind(null)
6
6
  : typeof requestAnimationFrame === 'function'
7
- ? requestAnimationFrame.bind(null)
8
- : queueMicrotask.bind(null);
7
+ ? requestAnimationFrame.bind(null)
8
+ : queueMicrotask.bind(null);
@@ -126,7 +126,7 @@ export type PanGestureHandlerEventPayload = {
126
126
  /**
127
127
  * Object containing additional stylus data.
128
128
  */
129
- stylusData: StylusData | undefined;
129
+ stylusData?: StylusData;
130
130
  };
131
131
 
132
132
  export type PinchGestureHandlerEventPayload = {
@@ -222,5 +222,5 @@ export type HoverGestureHandlerEventPayload = {
222
222
  /**
223
223
  * Object containing additional stylus data.
224
224
  */
225
- stylusData: StylusData | undefined;
225
+ stylusData?: StylusData;
226
226
  };
@@ -24,6 +24,7 @@ import { ActionType } from '../ActionType';
24
24
  import { PressabilityDebugView } from './PressabilityDebugView';
25
25
  import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
26
26
  import { ghQueueMicrotask } from '../ghQueueMicrotask';
27
+ import { MountRegistry } from '../mountRegistry';
27
28
 
28
29
  const UIManagerAny = UIManager as any;
29
30
 
@@ -160,7 +161,7 @@ const UNRESOLVED_REFS_RETRY_LIMIT = 1;
160
161
  // TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
161
162
  export default function createHandler<
162
163
  T extends BaseGestureHandlerProps<U>,
163
- U extends Record<string, unknown>
164
+ U extends Record<string, unknown>,
164
165
  >({
165
166
  name,
166
167
  allowedProps = [],
@@ -234,6 +235,12 @@ export default function createHandler<
234
235
  )
235
236
  );
236
237
 
238
+ if (!this.viewNode) {
239
+ throw new Error(
240
+ `[Gesture Handler] Failed to obtain view for ${Handler.displayName}. Note that old API doesn't support functional components.`
241
+ );
242
+ }
243
+
237
244
  this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null
238
245
  }
239
246
 
@@ -256,6 +263,8 @@ export default function createHandler<
256
263
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
257
264
  delete handlerIDToTag[handlerID];
258
265
  }
266
+
267
+ MountRegistry.gestureHandlerWillUnmount(this);
259
268
  }
260
269
 
261
270
  private onGestureHandlerEvent = (event: GestureEvent<U>) => {
@@ -367,6 +376,10 @@ export default function createHandler<
367
376
  }
368
377
 
369
378
  scheduleFlushOperations();
379
+
380
+ ghQueueMicrotask(() => {
381
+ MountRegistry.gestureHandlerWillMount(this);
382
+ });
370
383
  };
371
384
 
372
385
  private updateGestureHandler = (
@@ -142,7 +142,7 @@ export interface GestureEvent<ExtraEventPayloadT = Record<string, unknown>> {
142
142
  nativeEvent: Readonly<GestureEventPayload & ExtraEventPayloadT>;
143
143
  }
144
144
  export interface HandlerStateChangeEvent<
145
- ExtraEventPayloadT = Record<string, unknown>
145
+ ExtraEventPayloadT = Record<string, unknown>,
146
146
  > {
147
147
  nativeEvent: Readonly<HandlerStateChangeEventPayload & ExtraEventPayloadT>;
148
148
  }
@@ -169,7 +169,7 @@ export type GestureUpdateEvent<GestureEventPayloadT = Record<string, unknown>> =
169
169
  GestureEventPayload & GestureEventPayloadT;
170
170
 
171
171
  export type GestureStateChangeEvent<
172
- GestureStateChangeEventPayloadT = Record<string, unknown>
172
+ GestureStateChangeEventPayloadT = Record<string, unknown>,
173
173
  > = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT;
174
174
 
175
175
  export type CommonGestureConfig = {
@@ -186,7 +186,7 @@ export type CommonGestureConfig = {
186
186
  // Events payloads are types instead of interfaces due to TS limitation.
187
187
  // See https://github.com/microsoft/TypeScript/issues/15300 for more info.
188
188
  export type BaseGestureHandlerProps<
189
- ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown>
189
+ ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown>,
190
190
  > = CommonGestureConfig & {
191
191
  id?: string;
192
192
  waitFor?: React.Ref<unknown> | React.Ref<unknown>[];
@@ -14,6 +14,7 @@ import {
14
14
  checkGestureCallbacksForWorklets,
15
15
  ALLOWED_PROPS,
16
16
  } from './utils';
17
+ import { MountRegistry } from '../../../mountRegistry';
17
18
 
18
19
  interface AttachHandlersConfig {
19
20
  preparedGesture: AttachedGestureState;
@@ -93,6 +94,8 @@ export function attachHandlers({
93
94
  actionType
94
95
  );
95
96
  }
97
+
98
+ MountRegistry.gestureWillMount(gesture);
96
99
  }
97
100
 
98
101
  preparedGesture.attachedGestures = gesturesToAttach;
@@ -2,12 +2,15 @@ import { unregisterHandler } from '../../handlersRegistry';
2
2
  import RNGestureHandlerModule from '../../../RNGestureHandlerModule';
3
3
  import { scheduleFlushOperations } from '../../utils';
4
4
  import { AttachedGestureState } from './types';
5
+ import { MountRegistry } from '../../../mountRegistry';
5
6
 
6
7
  export function dropHandlers(preparedGesture: AttachedGestureState) {
7
8
  for (const handler of preparedGesture.attachedGestures) {
8
9
  RNGestureHandlerModule.dropGestureHandler(handler.handlerTag);
9
10
 
10
11
  unregisterHandler(handler.handlerTag, handler.config.testId);
12
+
13
+ MountRegistry.gestureWillUnmount(handler);
11
14
  }
12
15
 
13
16
  scheduleFlushOperations();