react-native-gesture-handler 3.1.0 → 3.2.0-nightly-20260720-9c6135950

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 (84) hide show
  1. package/lib/module/components/GestureButtons.js +7 -6
  2. package/lib/module/components/GestureButtons.js.map +1 -1
  3. package/lib/module/components/GestureComponents.js +2 -0
  4. package/lib/module/components/GestureComponents.js.map +1 -1
  5. package/lib/module/components/Pressable/Pressable.js +2 -0
  6. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  7. package/lib/module/components/ReanimatedDrawerLayout.js +4 -2
  8. package/lib/module/components/ReanimatedDrawerLayout.js.map +1 -1
  9. package/lib/module/components/Text.js.map +1 -1
  10. package/lib/module/components/touchables/TouchableHighlight.js +2 -2
  11. package/lib/module/components/touchables/TouchableHighlight.js.map +1 -1
  12. package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
  13. package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -1
  14. package/lib/module/specs/RNGestureHandlerButtonNativeComponent.ts +55 -51
  15. package/lib/module/specs/RNGestureHandlerDetectorNativeComponent.ts +39 -44
  16. package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -5
  17. package/lib/module/v3/components/GestureButtons.js +7 -10
  18. package/lib/module/v3/components/GestureButtons.js.map +1 -1
  19. package/lib/module/v3/components/GestureComponents.js.map +1 -1
  20. package/lib/module/v3/components/Pressable.js +2 -0
  21. package/lib/module/v3/components/Pressable.js.map +1 -1
  22. package/lib/module/v3/detectors/HostGestureDetector.web.js.map +1 -1
  23. package/lib/module/v3/detectors/NativeDetector.js.map +1 -1
  24. package/lib/module/v3/detectors/VirtualDetector/InterceptingGestureDetector.js.map +1 -1
  25. package/lib/module/v3/detectors/common.js.map +1 -1
  26. package/lib/typescript/components/GestureButtons.d.ts +1 -1
  27. package/lib/typescript/components/GestureButtons.d.ts.map +1 -1
  28. package/lib/typescript/components/GestureComponents.d.ts +3 -10
  29. package/lib/typescript/components/GestureComponents.d.ts.map +1 -1
  30. package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
  31. package/lib/typescript/components/Pressable/PressableProps.d.ts +1 -1
  32. package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
  33. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts.map +1 -1
  34. package/lib/typescript/components/touchables/TouchableHighlight.d.ts.map +1 -1
  35. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +1 -1
  36. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts.map +1 -1
  37. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +2 -2
  38. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts.map +1 -1
  39. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +7 -8
  40. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts.map +1 -1
  41. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +45 -46
  42. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts.map +1 -1
  43. package/lib/typescript/specs/RNGestureHandlerDetectorNativeComponent.d.ts +36 -37
  44. package/lib/typescript/specs/RNGestureHandlerDetectorNativeComponent.d.ts.map +1 -1
  45. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +3 -4
  46. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts.map +1 -1
  47. package/lib/typescript/v3/components/GestureButtons.d.ts.map +1 -1
  48. package/lib/typescript/v3/components/GestureButtonsProps.d.ts +1 -1
  49. package/lib/typescript/v3/components/GestureButtonsProps.d.ts.map +1 -1
  50. package/lib/typescript/v3/components/GestureComponents.d.ts +4 -112
  51. package/lib/typescript/v3/components/GestureComponents.d.ts.map +1 -1
  52. package/lib/typescript/v3/components/Pressable.d.ts.map +1 -1
  53. package/lib/typescript/v3/detectors/HostGestureDetector.d.ts +1 -1
  54. package/lib/typescript/v3/detectors/HostGestureDetector.d.ts.map +1 -1
  55. package/lib/typescript/v3/detectors/HostGestureDetector.web.d.ts.map +1 -1
  56. package/lib/typescript/v3/detectors/NativeDetector.d.ts.map +1 -1
  57. package/lib/typescript/v3/detectors/VirtualDetector/InterceptingGestureDetector.d.ts.map +1 -1
  58. package/lib/typescript/v3/detectors/common.d.ts +2 -2
  59. package/lib/typescript/v3/detectors/common.d.ts.map +1 -1
  60. package/lib/typescript/v3/types/EventTypes.d.ts +4 -1
  61. package/lib/typescript/v3/types/EventTypes.d.ts.map +1 -1
  62. package/package.json +1 -1
  63. package/src/components/GestureButtons.tsx +14 -8
  64. package/src/components/GestureComponents.tsx +11 -6
  65. package/src/components/Pressable/Pressable.tsx +2 -0
  66. package/src/components/Pressable/PressableProps.tsx +1 -1
  67. package/src/components/ReanimatedDrawerLayout.tsx +3 -1
  68. package/src/components/Text.tsx +3 -3
  69. package/src/components/touchables/TouchableHighlight.tsx +6 -3
  70. package/src/components/touchables/TouchableNativeFeedback.android.tsx +8 -2
  71. package/src/handlers/gestures/reanimatedWrapper.ts +2 -2
  72. package/src/specs/NativeRNGestureHandlerModule.ts +24 -13
  73. package/src/specs/RNGestureHandlerButtonNativeComponent.ts +55 -51
  74. package/src/specs/RNGestureHandlerDetectorNativeComponent.ts +39 -44
  75. package/src/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -5
  76. package/src/v3/components/GestureButtons.tsx +10 -10
  77. package/src/v3/components/GestureButtonsProps.ts +1 -1
  78. package/src/v3/components/GestureComponents.tsx +26 -12
  79. package/src/v3/components/Pressable.tsx +2 -0
  80. package/src/v3/detectors/HostGestureDetector.web.tsx +3 -1
  81. package/src/v3/detectors/NativeDetector.tsx +10 -6
  82. package/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx +10 -6
  83. package/src/v3/detectors/common.ts +4 -2
  84. package/src/v3/types/EventTypes.ts +3 -1
@@ -23,8 +23,11 @@ import { NativeWrapperProps } from '../hooks/utils';
23
23
  import type { NativeWrapperProperties } from '../types/NativeWrapperType';
24
24
  import ScrollViewResponderInterceptor from './ScrollViewResponderInterceptor';
25
25
 
26
- export const RefreshControl = createNativeWrapper<
27
- RNRefreshControl,
26
+ export const RefreshControl: React.ComponentType<
27
+ RNRefreshControlProps &
28
+ NativeWrapperProperties<React.ComponentRef<typeof RNRefreshControl> | null>
29
+ > = createNativeWrapper<
30
+ React.ComponentRef<typeof RNRefreshControl>,
28
31
  RNRefreshControlProps
29
32
  >(
30
33
  RNRefreshControl,
@@ -39,7 +42,7 @@ export const RefreshControl = createNativeWrapper<
39
42
  export type RefreshControl = typeof RefreshControl & RNRefreshControl;
40
43
 
41
44
  const GHScrollView = createNativeWrapper<
42
- RNScrollView,
45
+ React.ComponentRef<typeof RNScrollView>,
43
46
  PropsWithChildren<RNScrollViewProps>
44
47
  >(
45
48
  RNScrollView,
@@ -51,7 +54,8 @@ const GHScrollView = createNativeWrapper<
51
54
  );
52
55
 
53
56
  export const ScrollView = (
54
- props: RNScrollViewProps & NativeWrapperProperties<RNScrollView | null>
57
+ props: RNScrollViewProps &
58
+ NativeWrapperProperties<React.ComponentRef<typeof RNScrollView> | null>
55
59
  ) => {
56
60
  const {
57
61
  children,
@@ -101,18 +105,28 @@ export const ScrollView = (
101
105
  // eslint-disable-next-line @typescript-eslint/no-redeclare
102
106
  export type ScrollView = typeof ScrollView & RNScrollView;
103
107
 
104
- export const Switch = createNativeWrapper<RNSwitch, RNSwitchProps>(RNSwitch, {
105
- shouldCancelWhenOutside: false,
106
- shouldActivateOnStart: true,
107
- disallowInterruption: true,
108
- });
108
+ export const Switch: React.ComponentType<
109
+ RNSwitchProps &
110
+ NativeWrapperProperties<React.ComponentRef<typeof RNSwitch> | null>
111
+ > = createNativeWrapper<React.ComponentRef<typeof RNSwitch>, RNSwitchProps>(
112
+ RNSwitch,
113
+ {
114
+ shouldCancelWhenOutside: false,
115
+ shouldActivateOnStart: true,
116
+ disallowInterruption: true,
117
+ }
118
+ );
109
119
 
110
120
  // eslint-disable-next-line @typescript-eslint/no-redeclare
111
121
  export type Switch = typeof Switch & RNSwitch;
112
122
 
113
- export const TextInput = createNativeWrapper<RNTextInput, RNTextInputProps>(
114
- RNTextInput
115
- );
123
+ export const TextInput: React.ComponentType<
124
+ RNTextInputProps &
125
+ NativeWrapperProperties<React.ComponentRef<typeof RNTextInput> | null>
126
+ > = createNativeWrapper<
127
+ React.ComponentRef<typeof RNTextInput>,
128
+ RNTextInputProps
129
+ >(RNTextInput);
116
130
 
117
131
  // eslint-disable-next-line @typescript-eslint/no-redeclare
118
132
  export type TextInput = typeof TextInput & RNTextInput;
@@ -77,6 +77,7 @@ const Pressable = (props: PressableProps) => {
77
77
  simultaneousWith,
78
78
  requireToFail,
79
79
  block,
80
+ ref,
80
81
  ...remainingProps
81
82
  } = props;
82
83
 
@@ -426,6 +427,7 @@ const Pressable = (props: PressableProps) => {
426
427
  <GestureDetector gesture={gesture}>
427
428
  <PureNativeButton
428
429
  {...remainingProps}
430
+ ref={ref as React.Ref<React.ComponentRef<typeof PureNativeButton>>}
429
431
  {...tvProps}
430
432
  onLayout={setDimensions}
431
433
  accessible={accessible !== false}
@@ -349,7 +349,9 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
349
349
  }, [refs]);
350
350
 
351
351
  return (
352
- <View style={{ display: 'contents' }} ref={viewRef as Ref<View>}>
352
+ <View
353
+ style={{ display: 'contents' }}
354
+ ref={viewRef as Ref<React.ComponentRef<typeof View>>}>
353
355
  {children}
354
356
  </View>
355
357
  );
@@ -5,7 +5,9 @@ import { useJSResponderHandler } from '../hooks/useJSResponderHandler';
5
5
  import { isComposedGesture } from '../hooks/utils/relationUtils';
6
6
  import type { NativeDetectorProps } from './common';
7
7
  import { AnimatedNativeDetector, nativeDetectorStyles } from './common';
8
- import HostGestureDetector from './HostGestureDetector';
8
+ import HostGestureDetector, {
9
+ type RNGestureHandlerDetectorNativeComponentProps,
10
+ } from './HostGestureDetector';
9
11
  import { ReanimatedNativeDetector } from './ReanimatedNativeDetector';
10
12
  import { useDetectorAttachmentGuard } from './useDetectorAttachmentGuard';
11
13
  import { useGestureRelationsUpdater } from './useGestureRelationsUpdater';
@@ -24,11 +26,13 @@ export function NativeDetector<
24
26
  }: NativeDetectorProps<TConfig, THandlerData, TExtendedHandlerData>) {
25
27
  const { handleStartShouldSetResponder } = useJSResponderHandler(gesture);
26
28
 
27
- const NativeDetectorComponent = gesture.config.dispatchesAnimatedEvents
28
- ? AnimatedNativeDetector
29
- : gesture.config.shouldUseReanimatedDetector
30
- ? ReanimatedNativeDetector
31
- : HostGestureDetector;
29
+ const NativeDetectorComponent = (
30
+ gesture.config.dispatchesAnimatedEvents
31
+ ? AnimatedNativeDetector
32
+ : gesture.config.shouldUseReanimatedDetector
33
+ ? ReanimatedNativeDetector
34
+ : HostGestureDetector
35
+ ) as React.FunctionComponent<RNGestureHandlerDetectorNativeComponentProps>;
32
36
 
33
37
  ensureNativeDetectorComponent(NativeDetectorComponent);
34
38
  useGestureRelationsUpdater(gesture);
@@ -15,7 +15,9 @@ import type {
15
15
  } from '../../types';
16
16
  import type { InterceptingGestureDetectorProps } from '../common';
17
17
  import { AnimatedNativeDetector, nativeDetectorStyles } from '../common';
18
- import HostGestureDetector from '../HostGestureDetector';
18
+ import HostGestureDetector, {
19
+ type RNGestureHandlerDetectorNativeComponentProps,
20
+ } from '../HostGestureDetector';
19
21
  import { ReanimatedNativeDetector } from '../ReanimatedNativeDetector';
20
22
  import { useDetectorAttachmentGuard } from '../useDetectorAttachmentGuard';
21
23
  import { useEnsureGestureHandlerRootView } from '../useEnsureGestureHandlerRootView';
@@ -85,11 +87,13 @@ export function InterceptingGestureDetector<
85
87
  mode === InterceptingDetectorMode.REANIMATED;
86
88
  const dispatchesAnimatedEvents = mode === InterceptingDetectorMode.ANIMATED;
87
89
 
88
- const NativeDetectorComponent = dispatchesAnimatedEvents
89
- ? AnimatedNativeDetector
90
- : shouldUseReanimatedDetector
91
- ? ReanimatedNativeDetector
92
- : HostGestureDetector;
90
+ const NativeDetectorComponent = (
91
+ dispatchesAnimatedEvents
92
+ ? AnimatedNativeDetector
93
+ : shouldUseReanimatedDetector
94
+ ? ReanimatedNativeDetector
95
+ : HostGestureDetector
96
+ ) as React.FunctionComponent<RNGestureHandlerDetectorNativeComponentProps>;
93
97
 
94
98
  const register = useCallback((child: VirtualChild) => {
95
99
  setVirtualChildren((prev) => {
@@ -7,7 +7,9 @@ import type {
7
7
  } from '../../handlers/gestureHandlerCommon';
8
8
  import type { GestureDetectorProps as LegacyDetectorProps } from '../../handlers/gestures/GestureDetector';
9
9
  import type { Gesture } from '../types';
10
- import HostGestureDetector from './HostGestureDetector';
10
+ import HostGestureDetector, {
11
+ type RNGestureHandlerDetectorNativeComponentProps,
12
+ } from './HostGestureDetector';
11
13
 
12
14
  export enum GestureDetectorType {
13
15
  Native,
@@ -59,7 +61,7 @@ export type GestureDetectorProps<
59
61
  >
60
62
  | LegacyDetectorProps;
61
63
 
62
- export const AnimatedNativeDetector =
64
+ export const AnimatedNativeDetector: React.ComponentType<RNGestureHandlerDetectorNativeComponentProps> =
63
65
  Animated.createAnimatedComponent(HostGestureDetector);
64
66
 
65
67
  export const nativeDetectorStyles = StyleSheet.create({
@@ -71,8 +71,10 @@ export type UnpackedGestureHandlerEvent<THandlerData> =
71
71
  // This is not how Animated.event is typed in React Native. We add _argMapping in order to
72
72
  // have access to the _argMapping property to check for usage of `change*` callbacks.
73
73
  // It's also not typed as a function, which is breaking Gesture Handler type definitions.
74
+ type AnimatedMapping = { [key: string]: AnimatedMapping } | Animated.Value;
75
+
74
76
  export type AnimatedEvent = {
75
- _argMapping: (Animated.Mapping | null)[];
77
+ _argMapping: (AnimatedMapping | null)[];
76
78
  };
77
79
 
78
80
  export type ChangeCalculatorType<TExtendedHandlerData> = (