react-native-gesture-handler 2.18.1 → 2.20.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/android/build.gradle +11 -29
- package/android/fabric/src/main/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +1 -1
- package/android/paper/src/main/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +1 -1
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +21 -21
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +2 -2
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureUtils.kt +1 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/HoverGestureHandler.kt +16 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/LongPressGestureHandler.kt +80 -4
- package/android/src/main/java/com/swmansion/gesturehandler/core/PanGestureHandler.kt +8 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/PinchGestureHandler.kt +2 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/ScaleGestureDetector.java +10 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/StylusData.kt +103 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/Vector.kt +2 -2
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +24 -15
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +3 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/HoverGestureHandlerEventDataBuilder.kt +7 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/PanGestureHandlerEventDataBuilder.kt +7 -0
- package/android/src/main/jni/CMakeLists.txt +18 -9
- package/apple/Handlers/RNFlingHandler.h +1 -0
- package/apple/Handlers/RNFlingHandler.m +153 -19
- package/apple/Handlers/RNHoverHandler.m +44 -2
- package/apple/Handlers/RNLongPressHandler.m +111 -20
- package/apple/Handlers/RNManualHandler.m +53 -29
- package/apple/Handlers/RNNativeViewHandler.mm +22 -15
- package/apple/Handlers/RNPanHandler.m +57 -7
- package/apple/Handlers/RNRotationHandler.m +1 -1
- package/apple/RNGHStylusData.h +77 -0
- package/apple/RNGHStylusData.m +37 -0
- package/apple/RNGHUIKit.h +2 -0
- package/apple/RNGHVector.h +31 -0
- package/apple/RNGHVector.m +67 -0
- package/apple/RNGestureHandler.h +7 -0
- package/apple/{RNGestureHandler.m → RNGestureHandler.mm} +63 -1
- package/apple/RNGestureHandlerButtonComponentView.mm +41 -0
- package/apple/RNGestureHandlerDirection.h +25 -0
- package/apple/RNGestureHandlerEvents.h +3 -1
- package/apple/RNGestureHandlerEvents.m +11 -3
- package/lib/commonjs/PointerType.js +2 -1
- package/lib/commonjs/PointerType.js.map +1 -1
- package/lib/commonjs/components/GestureButtons.js +5 -1
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.js.map +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js +66 -78
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/components/Pressable/index.js +0 -8
- package/lib/commonjs/components/Pressable/index.js.map +1 -1
- package/lib/commonjs/components/Pressable/utils.js +1 -23
- package/lib/commonjs/components/Pressable/utils.js.map +1 -1
- package/lib/commonjs/components/ReanimatedSwipeable.js +60 -41
- package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/commonjs/handlers/GestureHandlerEventPayload.js +4 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js +1 -1
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +2 -1
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/hoverGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/longPressGesture.js +10 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/commonjs/jestUtils/jestUtils.js +12 -4
- package/lib/commonjs/jestUtils/jestUtils.js.map +1 -1
- package/lib/commonjs/mocks.js +16 -3
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/utils.js +4 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/constants.js +3 -3
- package/lib/commonjs/web/constants.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +2 -3
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/HoverGestureHandler.js +18 -1
- package/lib/commonjs/web/handlers/HoverGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js +43 -9
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +14 -3
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +12 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/EventManager.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +55 -11
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web/tools/KeyboardEventManager.js +110 -0
- package/lib/commonjs/web/tools/KeyboardEventManager.js.map +1 -0
- package/lib/commonjs/web/tools/PointerEventManager.js +3 -37
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/Vector.js +4 -2
- package/lib/commonjs/web/tools/Vector.js.map +1 -1
- package/lib/commonjs/web/utils.js +187 -13
- package/lib/commonjs/web/utils.js.map +1 -1
- package/lib/module/PointerType.js +2 -1
- package/lib/module/PointerType.js.map +1 -1
- package/lib/module/components/GestureButtons.js +5 -1
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/GestureComponents.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +67 -78
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/Pressable/index.js +0 -1
- package/lib/module/components/Pressable/index.js.map +1 -1
- package/lib/module/components/Pressable/utils.js +1 -22
- package/lib/module/components/Pressable/utils.js.map +1 -1
- package/lib/module/components/ReanimatedSwipeable.js +58 -37
- package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/module/handlers/GestureHandlerEventPayload.js +1 -1
- package/lib/module/handlers/LongPressGestureHandler.js +1 -1
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/handlers/createHandler.js +2 -1
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/utils.js +2 -2
- package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/gestures/hoverGesture.js.map +1 -1
- package/lib/module/handlers/gestures/longPressGesture.js +10 -0
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/module/jestUtils/jestUtils.js +12 -4
- package/lib/module/jestUtils/jestUtils.js.map +1 -1
- package/lib/module/mocks.js +13 -3
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/utils.js +1 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/constants.js +1 -1
- package/lib/module/web/constants.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +2 -3
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/HoverGestureHandler.js +18 -1
- package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/LongPressGestureHandler.js +43 -9
- package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +14 -3
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +12 -1
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/EventManager.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js +54 -10
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web/tools/KeyboardEventManager.js +96 -0
- package/lib/module/web/tools/KeyboardEventManager.js.map +1 -0
- package/lib/module/web/tools/PointerEventManager.js +4 -38
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/Vector.js +5 -3
- package/lib/module/web/tools/Vector.js.map +1 -1
- package/lib/module/web/utils.js +184 -13
- package/lib/module/web/utils.js.map +1 -1
- package/lib/typescript/PointerType.d.ts +2 -1
- package/lib/typescript/components/GestureComponents.d.ts +1 -1
- package/lib/typescript/components/Pressable/index.d.ts +1 -1
- package/lib/typescript/components/Pressable/utils.d.ts +3 -5
- package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +35 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +5 -1
- package/lib/typescript/handlers/gestures/gesture.d.ts +2 -2
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -6
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +5 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +1 -1
- package/lib/typescript/jestUtils/jestUtils.d.ts +1 -1
- package/lib/typescript/mocks.d.ts +4 -3
- package/lib/typescript/utils.d.ts +1 -0
- package/lib/typescript/web/constants.d.ts +1 -1
- package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -1
- package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +2 -0
- package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +3 -0
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +3 -1
- package/lib/typescript/web/interfaces.d.ts +9 -4
- package/lib/typescript/web/tools/EventManager.d.ts +2 -2
- package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +1 -0
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +6 -0
- package/lib/typescript/web/tools/KeyboardEventManager.d.ts +13 -0
- package/lib/typescript/web/utils.d.ts +2 -1
- package/package.json +3 -3
- package/src/PointerType.ts +1 -0
- package/src/components/GestureButtons.tsx +2 -1
- package/src/components/GestureComponents.tsx +1 -1
- package/src/components/Pressable/Pressable.tsx +77 -70
- package/src/components/Pressable/index.ts +1 -1
- package/src/components/Pressable/utils.ts +5 -49
- package/src/components/ReanimatedSwipeable.tsx +70 -47
- package/src/handlers/GestureHandlerEventPayload.ts +42 -0
- package/src/handlers/LongPressGestureHandler.ts +6 -0
- package/src/handlers/createHandler.tsx +1 -0
- package/src/handlers/gestures/GestureDetector/utils.ts +2 -2
- package/src/handlers/gestures/gesture.ts +3 -1
- package/src/handlers/gestures/hoverGesture.ts +1 -7
- package/src/handlers/gestures/longPressGesture.ts +9 -0
- package/src/jestUtils/jestUtils.ts +9 -1
- package/src/{mocks.ts → mocks.tsx} +8 -3
- package/src/utils.ts +2 -0
- package/src/web/constants.ts +1 -1
- package/src/web/handlers/GestureHandler.ts +4 -2
- package/src/web/handlers/HoverGestureHandler.ts +16 -2
- package/src/web/handlers/LongPressGestureHandler.ts +49 -10
- package/src/web/handlers/NativeViewGestureHandler.ts +14 -4
- package/src/web/handlers/PanGestureHandler.ts +14 -1
- package/src/web/interfaces.ts +10 -4
- package/src/web/tools/EventManager.ts +2 -4
- package/src/web/tools/GestureHandlerDelegate.ts +1 -0
- package/src/web/tools/GestureHandlerWebDelegate.ts +67 -10
- package/src/web/tools/KeyboardEventManager.ts +91 -0
- package/src/web/tools/PointerEventManager.ts +2 -38
- package/src/web/tools/Vector.ts +4 -3
- package/src/web/utils.ts +188 -13
- package/lib/commonjs/web/tools/TouchEventManager.js +0 -164
- package/lib/commonjs/web/tools/TouchEventManager.js.map +0 -1
- package/lib/module/web/tools/TouchEventManager.js +0 -149
- package/lib/module/web/tools/TouchEventManager.js.map +0 -1
- package/lib/typescript/web/tools/TouchEventManager.d.ts +0 -11
- package/src/web/tools/TouchEventManager.ts +0 -175
@@ -21,6 +21,12 @@ using namespace facebook::react;
|
|
21
21
|
RNGestureHandlerButton *_buttonView;
|
22
22
|
}
|
23
23
|
|
24
|
+
// Needed because of this: https://github.com/facebook/react-native/pull/37274
|
25
|
+
+ (void)load
|
26
|
+
{
|
27
|
+
[super load];
|
28
|
+
}
|
29
|
+
|
24
30
|
- (instancetype)initWithFrame:(CGRect)frame
|
25
31
|
{
|
26
32
|
if (self = [super initWithFrame:frame]) {
|
@@ -44,6 +50,41 @@ using namespace facebook::react;
|
|
44
50
|
[_buttonView unmountChildComponentView:childComponentView index:index];
|
45
51
|
}
|
46
52
|
|
53
|
+
- (LayoutMetrics)buildWrapperMetrics:(const LayoutMetrics &)metrics
|
54
|
+
{
|
55
|
+
LayoutMetrics result = metrics;
|
56
|
+
result.borderWidth = EdgeInsets::ZERO;
|
57
|
+
result.contentInsets = EdgeInsets::ZERO;
|
58
|
+
return result;
|
59
|
+
}
|
60
|
+
|
61
|
+
- (LayoutMetrics)buildButtonMetrics:(const LayoutMetrics &)metrics
|
62
|
+
{
|
63
|
+
LayoutMetrics result = metrics;
|
64
|
+
result.frame.origin = {0, 0};
|
65
|
+
return result;
|
66
|
+
}
|
67
|
+
|
68
|
+
- (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics
|
69
|
+
oldLayoutMetrics:(const facebook::react::LayoutMetrics &)oldLayoutMetrics
|
70
|
+
{
|
71
|
+
// due to nested structure of Button and ComponentView, layout metrics for both
|
72
|
+
// need to be modified:
|
73
|
+
// - wrapper shouldn't have any insets as they should be applied to the button
|
74
|
+
// so that it can intercept touches on padding and borders, applying them
|
75
|
+
// twice breaks expected layout
|
76
|
+
// - frame origin needs to be zeroes on metrics of the button as it should fill
|
77
|
+
// the entirety of the wrapper component
|
78
|
+
const LayoutMetrics wrapperMetrics = [self buildWrapperMetrics:layoutMetrics];
|
79
|
+
const LayoutMetrics oldWrapperMetrics = [self buildWrapperMetrics:oldLayoutMetrics];
|
80
|
+
|
81
|
+
const LayoutMetrics buttonMetrics = [self buildButtonMetrics:layoutMetrics];
|
82
|
+
const LayoutMetrics oldbuttonMetrics = [self buildButtonMetrics:oldLayoutMetrics];
|
83
|
+
|
84
|
+
[super updateLayoutMetrics:wrapperMetrics oldLayoutMetrics:oldWrapperMetrics];
|
85
|
+
[_buttonView updateLayoutMetrics:buttonMetrics oldLayoutMetrics:oldbuttonMetrics];
|
86
|
+
}
|
87
|
+
|
47
88
|
#pragma mark - RCTComponentViewProtocol
|
48
89
|
|
49
90
|
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
@@ -1,8 +1,33 @@
|
|
1
1
|
#import <Foundation/Foundation.h>
|
2
2
|
|
3
|
+
#ifndef RNGestureHandlerDirection_h
|
4
|
+
#define RNGestureHandlerDirection_h
|
5
|
+
|
3
6
|
typedef NS_ENUM(NSInteger, RNGestureHandlerDirection) {
|
4
7
|
RNGestureHandlerDirectionRight = 1,
|
5
8
|
RNGestureHandlerDirectionLeft = 2,
|
6
9
|
RNGestureHandlerDirectionUp = 4,
|
7
10
|
RNGestureHandlerDirectionDown = 8,
|
11
|
+
RNGestureHandlerDirectionUpLeft = RNGestureHandlerDirectionUp | RNGestureHandlerDirectionLeft,
|
12
|
+
RNGestureHandlerDirectionUpRight = RNGestureHandlerDirectionUp | RNGestureHandlerDirectionRight,
|
13
|
+
RNGestureHandlerDirectionDownLeft = RNGestureHandlerDirectionDown | RNGestureHandlerDirectionLeft,
|
14
|
+
RNGestureHandlerDirectionDownRight = RNGestureHandlerDirectionDown | RNGestureHandlerDirectionRight,
|
15
|
+
};
|
16
|
+
|
17
|
+
static NSInteger axialDirections[] = {
|
18
|
+
RNGestureHandlerDirectionRight,
|
19
|
+
RNGestureHandlerDirectionLeft,
|
20
|
+
RNGestureHandlerDirectionUp,
|
21
|
+
RNGestureHandlerDirectionDown,
|
8
22
|
};
|
23
|
+
|
24
|
+
static NSInteger diagonalDirections[] = {
|
25
|
+
RNGestureHandlerDirectionUpLeft,
|
26
|
+
RNGestureHandlerDirectionUpRight,
|
27
|
+
RNGestureHandlerDirectionDownLeft,
|
28
|
+
RNGestureHandlerDirectionDownRight,
|
29
|
+
};
|
30
|
+
|
31
|
+
static NSInteger directionsSize = 4;
|
32
|
+
|
33
|
+
#endif
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
#import <Foundation/Foundation.h>
|
4
4
|
|
5
|
+
#import "RNGHStylusData.h"
|
5
6
|
#import "RNGHTouchEventType.h"
|
6
7
|
#import "RNGHUIKit.h"
|
7
8
|
#import "RNGestureHandlerState.h"
|
@@ -29,7 +30,8 @@
|
|
29
30
|
withTranslation:(CGPoint)translation
|
30
31
|
withVelocity:(CGPoint)velocity
|
31
32
|
withNumberOfTouches:(NSUInteger)numberOfTouches
|
32
|
-
withPointerType:(NSInteger)pointerType
|
33
|
+
withPointerType:(NSInteger)pointerType
|
34
|
+
withStylusData:(NSDictionary *)stylusData;
|
33
35
|
+ (RNGestureHandlerEventExtraData *)forForce:(CGFloat)force
|
34
36
|
forPosition:(CGPoint)position
|
35
37
|
withAbsolutePosition:(CGPoint)absolutePosition
|
@@ -63,8 +63,9 @@
|
|
63
63
|
withVelocity:(CGPoint)velocity
|
64
64
|
withNumberOfTouches:(NSUInteger)numberOfTouches
|
65
65
|
withPointerType:(NSInteger)pointerType
|
66
|
+
withStylusData:(NSDictionary *)stylusData
|
66
67
|
{
|
67
|
-
|
68
|
+
NSMutableDictionary *data = [@{
|
68
69
|
@"x" : @(position.x),
|
69
70
|
@"y" : @(position.y),
|
70
71
|
@"absoluteX" : @(absolutePosition.x),
|
@@ -74,8 +75,15 @@
|
|
74
75
|
@"velocityX" : SAFE_VELOCITY(velocity.x),
|
75
76
|
@"velocityY" : SAFE_VELOCITY(velocity.y),
|
76
77
|
@"numberOfPointers" : @(numberOfTouches),
|
77
|
-
@"pointerType" : @(pointerType)
|
78
|
-
}];
|
78
|
+
@"pointerType" : @(pointerType),
|
79
|
+
} mutableCopy];
|
80
|
+
|
81
|
+
// Add the stylusData to the dictionary only if necessary
|
82
|
+
if (stylusData != nil) {
|
83
|
+
data[@"stylusData"] = stylusData;
|
84
|
+
}
|
85
|
+
|
86
|
+
return [[RNGestureHandlerEventExtraData alloc] initWithData:data];
|
79
87
|
}
|
80
88
|
|
81
89
|
+ (RNGestureHandlerEventExtraData *)forForce:(CGFloat)force
|
@@ -11,6 +11,7 @@ exports.PointerType = PointerType;
|
|
11
11
|
PointerType[PointerType["TOUCH"] = 0] = "TOUCH";
|
12
12
|
PointerType[PointerType["STYLUS"] = 1] = "STYLUS";
|
13
13
|
PointerType[PointerType["MOUSE"] = 2] = "MOUSE";
|
14
|
-
PointerType[PointerType["
|
14
|
+
PointerType[PointerType["KEY"] = 3] = "KEY";
|
15
|
+
PointerType[PointerType["OTHER"] = 4] = "OTHER";
|
15
16
|
})(PointerType || (exports.PointerType = PointerType = {}));
|
16
17
|
//# sourceMappingURL=PointerType.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["PointerType.ts"],"names":["PointerType"],"mappings":";;;;;;IAAYA,W;;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W","sourcesContent":["export enum PointerType {\n TOUCH,\n STYLUS,\n MOUSE,\n OTHER,\n}\n"]}
|
1
|
+
{"version":3,"sources":["PointerType.ts"],"names":["PointerType"],"mappings":";;;;;;IAAYA,W;;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W","sourcesContent":["export enum PointerType {\n TOUCH,\n STYLUS,\n MOUSE,\n KEY,\n OTHER,\n}\n"]}
|
@@ -113,11 +113,15 @@ class InnerBaseButton extends React.Component {
|
|
113
113
|
render() {
|
114
114
|
const {
|
115
115
|
rippleColor,
|
116
|
+
style,
|
116
117
|
...rest
|
117
118
|
} = this.props;
|
118
119
|
return /*#__PURE__*/React.createElement(RawButton, _extends({
|
119
120
|
ref: this.props.innerRef,
|
120
|
-
rippleColor: (0, _reactNative.processColor)(rippleColor)
|
121
|
+
rippleColor: (0, _reactNative.processColor)(rippleColor),
|
122
|
+
style: [style, _reactNative.Platform.OS === 'ios' && {
|
123
|
+
cursor: undefined
|
124
|
+
}]
|
121
125
|
}, rest, {
|
122
126
|
onGestureEvent: this.onGestureEvent,
|
123
127
|
onHandlerStateChange: this.onHandlerStateChange
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["GestureButtons.tsx"],"names":["RawButton","GestureHandlerButton","shouldCancelWhenOutside","shouldActivateOnStart","InnerBaseButton","React","Component","constructor","props","nativeEvent","state","oldState","pointerInside","active","State","ACTIVE","lastActive","onActiveStateChange","longPressDetected","CANCELLED","onPress","Platform","OS","BEGAN","onLongPress","longPressTimeout","setTimeout","delayLongPress","undefined","clearTimeout","END","FAILED","e","onHandlerStateChange","handleEvent","onGestureEvent","render","rippleColor","rest","innerRef","BaseButton","forwardRef","ref","AnimatedBaseButton","Animated","createAnimatedComponent","btnStyles","StyleSheet","create","underlay","position","left","right","bottom","top","InnerRectButton","opacity","setValue","activeOpacity","Value","children","style","resolvedStyle","flatten","backgroundColor","underlayColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","RectButton","InnerBorderlessButton","borderless","BorderlessButton"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;AAgBO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AAL,CAAWkD,aAAd,GAA+B,CAA3D;AACD;;AAED,qDAAKlD,KAAL,EAAWS,mBAAX,qGAAiCJ,MAAjC;AACD,KAXyC;;AAExC,SAAK2C,OAAL,GAAe,IAAIZ,sBAASe,KAAb,CAAmB,CAAnB,CAAf;AACD;;AAUDvB,EAAAA,MAAM,GAAG;AACP,UAAM;AAAEwB,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBtB,MAAAA,QAAnB;AAA6B,SAAGD;AAAhC,QAAyC,KAAK9B,KAApD;AAEA,wBACE,oBAAC,kBAAD,eACM8B,IADN;AAEE;AACA;AACA,MAAA,QAAQ,EAAEC,QAJZ;AAKE,MAAA,mBAAmB,EAAE,KAAKtB,mBAL5B;AAME,MAAA,KAAK,EAAE,CAAC4C,KAAD,EAAQxC,sBAASC,EAAT,KAAgB,KAAhB,IAAyB;AAAEkC,QAAAA,OAAO,EAAE,KAAKA;AAAhB,OAAjC;AANT,QAOGI,QAPH,CADF;AAWD;;AAnC+E;;gBAA5EY,qB,kBACkB;AACpBd,EAAAA,aAAa,EAAE,GADK;AAEpBe,EAAAA,UAAU,EAAE;AAFQ,C;;AAqCjB,MAAMC,gBAAgB,gBAAGrE,KAAK,CAACoC,UAAN,CAG9B,CAACjC,KAAD,EAAQkC,GAAR,kBAAgB,oBAAC,qBAAD;AAAuB,EAAA,QAAQ,EAAEA;AAAjC,GAA0ClC,KAA1C,EAHc,CAAzB","sourcesContent":["import * as React from 'react';\nimport { Animated, Platform, processColor, StyleSheet } from 'react-native';\n\nimport createNativeWrapper from '../handlers/createNativeWrapper';\nimport GestureHandlerButton from './GestureHandlerButton';\nimport { State } from '../State';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport type { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload';\nimport type {\n BaseButtonWithRefProps,\n BaseButtonProps,\n RectButtonWithRefProps,\n RectButtonProps,\n BorderlessButtonWithRefProps,\n BorderlessButtonProps,\n} from './GestureButtonsProps';\n\nexport const RawButton = createNativeWrapper(GestureHandlerButton, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: false,\n});\n\nclass InnerBaseButton extends React.Component<BaseButtonWithRefProps> {\n static defaultProps = {\n delayLongPress: 600,\n };\n\n private lastActive: boolean;\n private longPressTimeout: ReturnType<typeof setTimeout> | undefined;\n private longPressDetected: boolean;\n\n constructor(props: BaseButtonProps) {\n super(props);\n this.lastActive = false;\n this.longPressDetected = false;\n }\n\n private handleEvent = ({\n nativeEvent,\n }: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>) => {\n const { state, oldState, pointerInside } = nativeEvent;\n const active = pointerInside && state === State.ACTIVE;\n\n if (active !== this.lastActive && this.props.onActiveStateChange) {\n this.props.onActiveStateChange(active);\n }\n\n if (\n !this.longPressDetected &&\n oldState === State.ACTIVE &&\n state !== State.CANCELLED &&\n this.lastActive &&\n this.props.onPress\n ) {\n this.props.onPress(pointerInside);\n }\n\n if (\n !this.lastActive &&\n // NativeViewGestureHandler sends different events based on platform\n state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&\n pointerInside\n ) {\n this.longPressDetected = false;\n if (this.props.onLongPress) {\n this.longPressTimeout = setTimeout(\n this.onLongPress,\n this.props.delayLongPress\n );\n }\n } else if (\n // Cancel longpress timeout if it's set and the finger moved out of the view\n state === State.ACTIVE &&\n !pointerInside &&\n this.longPressTimeout !== undefined\n ) {\n clearTimeout(this.longPressTimeout);\n this.longPressTimeout = undefined;\n } else if (\n // Cancel longpress timeout if it's set and the gesture has finished\n this.longPressTimeout !== undefined &&\n (state === State.END ||\n state === State.CANCELLED ||\n state === State.FAILED)\n ) {\n clearTimeout(this.longPressTimeout);\n this.longPressTimeout = undefined;\n }\n\n this.lastActive = active;\n };\n\n private onLongPress = () => {\n this.longPressDetected = true;\n this.props.onLongPress?.();\n };\n\n // Normally, the parent would execute it's handler first, then forward the\n // event to listeners. However, here our handler is virtually only forwarding\n // events to listeners, so we reverse the order to keep the proper order of\n // the callbacks (from \"raw\" ones to \"processed\").\n private onHandlerStateChange = (\n e: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>\n ) => {\n this.props.onHandlerStateChange?.(e);\n this.handleEvent(e);\n };\n\n private onGestureEvent = (\n e: GestureEvent<NativeViewGestureHandlerPayload>\n ) => {\n this.props.onGestureEvent?.(e);\n this.handleEvent(\n e as HandlerStateChangeEvent<NativeViewGestureHandlerPayload>\n ); // TODO: maybe it is not correct\n };\n\n render() {\n const { rippleColor, ...rest } = this.props;\n\n return (\n <RawButton\n ref={this.props.innerRef}\n rippleColor={processColor(rippleColor)}\n {...rest}\n onGestureEvent={this.onGestureEvent}\n onHandlerStateChange={this.onHandlerStateChange}\n />\n );\n }\n}\n\nexport const BaseButton = React.forwardRef<\n any,\n Omit<BaseButtonProps, 'innerRef'>\n>((props, ref) => <InnerBaseButton innerRef={ref} {...props} />);\n\nconst AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);\n\nconst btnStyles = StyleSheet.create({\n underlay: {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: 0,\n top: 0,\n },\n});\n\nclass InnerRectButton extends React.Component<RectButtonWithRefProps> {\n static defaultProps = {\n activeOpacity: 0.105,\n underlayColor: 'black',\n };\n\n private opacity: Animated.Value;\n\n constructor(props: RectButtonProps) {\n super(props);\n this.opacity = new Animated.Value(0);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 0);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, ...rest } = this.props;\n\n const resolvedStyle = StyleSheet.flatten(style ?? {});\n\n return (\n <BaseButton\n {...rest}\n ref={this.props.innerRef}\n style={resolvedStyle}\n onActiveStateChange={this.onActiveStateChange}>\n <Animated.View\n style={[\n btnStyles.underlay,\n {\n opacity: this.opacity,\n backgroundColor: this.props.underlayColor,\n borderRadius: resolvedStyle.borderRadius,\n borderTopLeftRadius: resolvedStyle.borderTopLeftRadius,\n borderTopRightRadius: resolvedStyle.borderTopRightRadius,\n borderBottomLeftRadius: resolvedStyle.borderBottomLeftRadius,\n borderBottomRightRadius: resolvedStyle.borderBottomRightRadius,\n },\n ]}\n />\n {children}\n </BaseButton>\n );\n }\n}\n\nexport const RectButton = React.forwardRef<\n any,\n Omit<RectButtonProps, 'innerRef'>\n>((props, ref) => <InnerRectButton innerRef={ref} {...props} />);\n\nclass InnerBorderlessButton extends React.Component<BorderlessButtonWithRefProps> {\n static defaultProps = {\n activeOpacity: 0.3,\n borderless: true,\n };\n\n private opacity: Animated.Value;\n\n constructor(props: BorderlessButtonProps) {\n super(props);\n this.opacity = new Animated.Value(1);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 1);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, innerRef, ...rest } = this.props;\n\n return (\n <AnimatedBaseButton\n {...rest}\n // @ts-ignore We don't want `innerRef` to be accessible from public API.\n // However in this case we need to set it indirectly on `BaseButton`, hence we use ts-ignore\n innerRef={innerRef}\n onActiveStateChange={this.onActiveStateChange}\n style={[style, Platform.OS === 'ios' && { opacity: this.opacity }]}>\n {children}\n </AnimatedBaseButton>\n );\n }\n}\n\nexport const BorderlessButton = React.forwardRef<\n any,\n Omit<BorderlessButtonProps, 'innerRef'>\n>((props, ref) => <InnerBorderlessButton innerRef={ref} {...props} />);\n\nexport { default as PureNativeButton } from './GestureHandlerButton';\n"]}
|
1
|
+
{"version":3,"sources":["GestureButtons.tsx"],"names":["RawButton","GestureHandlerButton","shouldCancelWhenOutside","shouldActivateOnStart","InnerBaseButton","React","Component","constructor","props","nativeEvent","state","oldState","pointerInside","active","State","ACTIVE","lastActive","onActiveStateChange","longPressDetected","CANCELLED","onPress","Platform","OS","BEGAN","onLongPress","longPressTimeout","setTimeout","delayLongPress","undefined","clearTimeout","END","FAILED","e","onHandlerStateChange","handleEvent","onGestureEvent","render","rippleColor","style","rest","innerRef","cursor","BaseButton","forwardRef","ref","AnimatedBaseButton","Animated","createAnimatedComponent","btnStyles","StyleSheet","create","underlay","position","left","right","bottom","top","InnerRectButton","opacity","setValue","activeOpacity","Value","children","resolvedStyle","flatten","backgroundColor","underlayColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","RectButton","InnerBorderlessButton","borderless","BorderlessButton"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;AAgBO,MAAMA,SAAS,GAAG,kCAAoBC,6BAApB,EAA0C;AACjEC,EAAAA,uBAAuB,EAAE,KADwC;AAEjEC,EAAAA,qBAAqB,EAAE;AAF0C,CAA1C,CAAlB;;;AAKP,MAAMC,eAAN,SAA8BC,KAAK,CAACC,SAApC,CAAsE;AASpEC,EAAAA,WAAW,CAACC,KAAD,EAAyB;AAClC,UAAMA,KAAN;;AADkC;;AAAA;;AAAA;;AAAA,yCAMd,CAAC;AACrBC,MAAAA;AADqB,KAAD,KAE0C;AAC9D,YAAM;AAAEC,QAAAA,KAAF;AAASC,QAAAA,QAAT;AAAmBC,QAAAA;AAAnB,UAAqCH,WAA3C;AACA,YAAMI,MAAM,GAAGD,aAAa,IAAIF,KAAK,KAAKI,aAAMC,MAAhD;;AAEA,UAAIF,MAAM,KAAK,KAAKG,UAAhB,IAA8B,KAAKR,KAAL,CAAWS,mBAA7C,EAAkE;AAChE,aAAKT,KAAL,CAAWS,mBAAX,CAA+BJ,MAA/B;AACD;;AAED,UACE,CAAC,KAAKK,iBAAN,IACAP,QAAQ,KAAKG,aAAMC,MADnB,IAEAL,KAAK,KAAKI,aAAMK,SAFhB,IAGA,KAAKH,UAHL,IAIA,KAAKR,KAAL,CAAWY,OALb,EAME;AACA,aAAKZ,KAAL,CAAWY,OAAX,CAAmBR,aAAnB;AACD;;AAED,UACE,CAAC,KA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EAAE;AAFQ,C;;AAqCjB,MAAMC,gBAAgB,gBAAGtE,KAAK,CAACsC,UAAN,CAG9B,CAACnC,KAAD,EAAQoC,GAAR,kBAAgB,oBAAC,qBAAD;AAAuB,EAAA,QAAQ,EAAEA;AAAjC,GAA0CpC,KAA1C,EAHc,CAAzB","sourcesContent":["import * as React from 'react';\nimport { Animated, Platform, processColor, StyleSheet } from 'react-native';\n\nimport createNativeWrapper from '../handlers/createNativeWrapper';\nimport GestureHandlerButton from './GestureHandlerButton';\nimport { State } from '../State';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport type { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload';\nimport type {\n BaseButtonWithRefProps,\n BaseButtonProps,\n RectButtonWithRefProps,\n RectButtonProps,\n BorderlessButtonWithRefProps,\n BorderlessButtonProps,\n} from './GestureButtonsProps';\n\nexport const RawButton = createNativeWrapper(GestureHandlerButton, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: false,\n});\n\nclass InnerBaseButton extends React.Component<BaseButtonWithRefProps> {\n static defaultProps = {\n delayLongPress: 600,\n };\n\n private lastActive: boolean;\n private longPressTimeout: ReturnType<typeof setTimeout> | undefined;\n private longPressDetected: boolean;\n\n constructor(props: BaseButtonProps) {\n super(props);\n this.lastActive = false;\n this.longPressDetected = false;\n }\n\n private handleEvent = ({\n nativeEvent,\n }: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>) => {\n const { state, oldState, pointerInside } = nativeEvent;\n const active = pointerInside && state === State.ACTIVE;\n\n if (active !== this.lastActive && this.props.onActiveStateChange) {\n this.props.onActiveStateChange(active);\n }\n\n if (\n !this.longPressDetected &&\n oldState === State.ACTIVE &&\n state !== State.CANCELLED &&\n this.lastActive &&\n this.props.onPress\n ) {\n this.props.onPress(pointerInside);\n }\n\n if (\n !this.lastActive &&\n // NativeViewGestureHandler sends different events based on platform\n state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&\n pointerInside\n ) {\n this.longPressDetected = false;\n if (this.props.onLongPress) {\n this.longPressTimeout = setTimeout(\n this.onLongPress,\n this.props.delayLongPress\n );\n }\n } else if (\n // Cancel longpress timeout if it's set and the finger moved out of the view\n state === State.ACTIVE &&\n !pointerInside &&\n this.longPressTimeout !== undefined\n ) {\n clearTimeout(this.longPressTimeout);\n this.longPressTimeout = undefined;\n } else if (\n // Cancel longpress timeout if it's set and the gesture has finished\n this.longPressTimeout !== undefined &&\n (state === State.END ||\n state === State.CANCELLED ||\n state === State.FAILED)\n ) {\n clearTimeout(this.longPressTimeout);\n this.longPressTimeout = undefined;\n }\n\n this.lastActive = active;\n };\n\n private onLongPress = () => {\n this.longPressDetected = true;\n this.props.onLongPress?.();\n };\n\n // Normally, the parent would execute it's handler first, then forward the\n // event to listeners. However, here our handler is virtually only forwarding\n // events to listeners, so we reverse the order to keep the proper order of\n // the callbacks (from \"raw\" ones to \"processed\").\n private onHandlerStateChange = (\n e: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>\n ) => {\n this.props.onHandlerStateChange?.(e);\n this.handleEvent(e);\n };\n\n private onGestureEvent = (\n e: GestureEvent<NativeViewGestureHandlerPayload>\n ) => {\n this.props.onGestureEvent?.(e);\n this.handleEvent(\n e as HandlerStateChangeEvent<NativeViewGestureHandlerPayload>\n ); // TODO: maybe it is not correct\n };\n\n render() {\n const { rippleColor, style, ...rest } = this.props;\n\n return (\n <RawButton\n ref={this.props.innerRef}\n rippleColor={processColor(rippleColor)}\n style={[style, Platform.OS === 'ios' && { cursor: undefined }]}\n {...rest}\n onGestureEvent={this.onGestureEvent}\n onHandlerStateChange={this.onHandlerStateChange}\n />\n );\n }\n}\n\nexport const BaseButton = React.forwardRef<\n any,\n Omit<BaseButtonProps, 'innerRef'>\n>((props, ref) => <InnerBaseButton innerRef={ref} {...props} />);\n\nconst AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);\n\nconst btnStyles = StyleSheet.create({\n underlay: {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: 0,\n top: 0,\n },\n});\n\nclass InnerRectButton extends React.Component<RectButtonWithRefProps> {\n static defaultProps = {\n activeOpacity: 0.105,\n underlayColor: 'black',\n };\n\n private opacity: Animated.Value;\n\n constructor(props: RectButtonProps) {\n super(props);\n this.opacity = new Animated.Value(0);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 0);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, ...rest } = this.props;\n\n const resolvedStyle = StyleSheet.flatten(style ?? {});\n\n return (\n <BaseButton\n {...rest}\n ref={this.props.innerRef}\n style={resolvedStyle}\n onActiveStateChange={this.onActiveStateChange}>\n <Animated.View\n style={[\n btnStyles.underlay,\n {\n opacity: this.opacity,\n backgroundColor: this.props.underlayColor,\n borderRadius: resolvedStyle.borderRadius,\n borderTopLeftRadius: resolvedStyle.borderTopLeftRadius,\n borderTopRightRadius: resolvedStyle.borderTopRightRadius,\n borderBottomLeftRadius: resolvedStyle.borderBottomLeftRadius,\n borderBottomRightRadius: resolvedStyle.borderBottomRightRadius,\n },\n ]}\n />\n {children}\n </BaseButton>\n );\n }\n}\n\nexport const RectButton = React.forwardRef<\n any,\n Omit<RectButtonProps, 'innerRef'>\n>((props, ref) => <InnerRectButton innerRef={ref} {...props} />);\n\nclass InnerBorderlessButton extends React.Component<BorderlessButtonWithRefProps> {\n static defaultProps = {\n activeOpacity: 0.3,\n borderless: true,\n };\n\n private opacity: Animated.Value;\n\n constructor(props: BorderlessButtonProps) {\n super(props);\n this.opacity = new Animated.Value(1);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 1);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, innerRef, ...rest } = this.props;\n\n return (\n <AnimatedBaseButton\n {...rest}\n // @ts-ignore We don't want `innerRef` to be accessible from public API.\n // However in this case we need to set it indirectly on `BaseButton`, hence we use ts-ignore\n innerRef={innerRef}\n onActiveStateChange={this.onActiveStateChange}\n style={[style, Platform.OS === 'ios' && { opacity: this.opacity }]}>\n {children}\n </AnimatedBaseButton>\n );\n }\n}\n\nexport const BorderlessButton = React.forwardRef<\n any,\n Omit<BorderlessButtonProps, 'innerRef'>\n>((props, ref) => <InnerBorderlessButton innerRef={ref} {...props} />);\n\nexport { default as PureNativeButton } from './GestureHandlerButton';\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["GestureComponents.tsx"],"names":["RefreshControl","RNRefreshControl","disallowInterruption","shouldCancelWhenOutside","GHScrollView","RNScrollView","ScrollView","React","forwardRef","props","ref","refreshControlGestureRef","useRef","refreshControl","waitFor","rest","cloneElement","undefined","Switch","RNSwitch","shouldActivateOnStart","TextInput","RNTextInput","DrawerLayoutAndroid","RNDrawerLayoutAndroid","FlatList","flatListProps","scrollViewProps","propName","value","Object","entries","nativeViewProps","includes","scrollProps"],"mappings":";;;;;;;AAAA;;AAOA;;AAcA;;AAEA;;AAKA;;;;;;;;;;AAEO,MAAMA,cAAc,GAAG,kCAAoBC,2BAApB,EAAsC;AAClEC,EAAAA,oBAAoB,EAAE,IAD4C;AAElEC,EAAAA,uBAAuB,EAAE;AAFyC,CAAtC,CAAvB,C,CAIP;;;AAGA,MAAMC,YAAY,GAAG,kCACnBC,uBADmB,EAEnB;AACEH,EAAAA,oBAAoB,EAAE,IADxB;AAEEC,EAAAA,uBAAuB,EAAE;AAF3B,CAFmB,CAArB;AAOO,MAAMG,UAAU,gBAAGC,KAAK,CAACC,UAAN,CAGxB,CAACC,KAAD,EAAQC,GAAR,KAAgB;AAChB,QAAMC,wBAAwB,GAAGJ,KAAK,CAACK,MAAN,CAA6B,IAA7B,CAAjC;AACA,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,OAAlB;AAA2B,OAAGC;AAA9B,MAAuCN,K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AhD,CAAJ,EAA+D;AAC7D;AACA;AACAD,MAAAA,eAAe,CAACC,QAAD,CAAf,GAA4BC,KAA5B;AACD,KAJD,MAIO;AACL;AACA;AACAH,MAAAA,aAAa,CAACE,QAAD,CAAb,GAA0BC,KAA1B;AACD;AACF;;AAED;AAAA;AACE;AACA,wBAAC,qBAAD;AACE,MAAA,GAAG,EAAEnB;AADP,OAEMgB,aAFN;AAGE,MAAA,qBAAqB,EAAGQ,WAAD,iBACrB,oBAAC,UAAD,eAEOA,WAFP,EAGOP,eAHP;AAIIb,QAAAA,OAAO,EAAE,CAAC,GAAG,oBAAQA,OAAR,aAAQA,OAAR,cAAQA,OAAR,GAAmB,EAAnB,CAAJ,EAA4BH,wBAA5B;AAJb,SAJJ,CAYE;AAZF;AAaE,MAAA,cAAc,EACZE,cAAc,gBACVN,KAAK,CAACS,YAAN,CAAmBH,cAAnB,EAAmC;AACjC;AACAH,QAAAA,GAAG,EAAEC;AAF4B,OAAnC,CADU,GAKVM;AAnBR;AAFF;AAyBD,CA7CuB,CAAjB,C,CAqDP","sourcesContent":["import * as React from 'react';\nimport {\n PropsWithChildren,\n ForwardedRef,\n RefAttributes,\n ReactElement,\n} from 'react';\nimport {\n ScrollView as RNScrollView,\n ScrollViewProps as RNScrollViewProps,\n Switch as RNSwitch,\n SwitchProps as RNSwitchProps,\n TextInput as RNTextInput,\n TextInputProps as RNTextInputProps,\n DrawerLayoutAndroid as RNDrawerLayoutAndroid,\n DrawerLayoutAndroidProps as RNDrawerLayoutAndroidProps,\n FlatList as RNFlatList,\n FlatListProps as RNFlatListProps,\n RefreshControl as RNRefreshControl,\n} from 'react-native';\n\nimport createNativeWrapper from '../handlers/createNativeWrapper';\n\nimport {\n NativeViewGestureHandlerProps,\n nativeViewProps,\n} from '../handlers/NativeViewGestureHandler';\n\nimport { toArray } from '../utils';\n\nexport const RefreshControl = createNativeWrapper(RNRefreshControl, {\n disallowInterruption: true,\n shouldCancelWhenOutside: false,\n});\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type RefreshControl = typeof RefreshControl & RNRefreshControl;\n\nconst GHScrollView = createNativeWrapper<PropsWithChildren<RNScrollViewProps>>(\n RNScrollView,\n {\n disallowInterruption: true,\n shouldCancelWhenOutside: false,\n }\n);\nexport const ScrollView = React.forwardRef<\n RNScrollView,\n RNScrollViewProps & NativeViewGestureHandlerProps\n>((props, ref) => {\n const refreshControlGestureRef = React.useRef<RefreshControl>(null);\n const { refreshControl, waitFor, ...rest } = props;\n\n return (\n <GHScrollView\n {...rest}\n // @ts-ignore `ref` exists on `GHScrollView`\n ref={ref}\n waitFor={[...toArray(waitFor ?? []), refreshControlGestureRef]}\n // @ts-ignore we don't pass `refreshing` prop as we only want to override the ref\n refreshControl={\n refreshControl\n ? React.cloneElement(refreshControl, {\n // @ts-ignore for reasons unknown to me, `ref` doesn't exist on the type inferred by TS\n ref: refreshControlGestureRef,\n })\n : undefined\n }\n />\n );\n});\n// Backward type compatibility with https://github.com/software-mansion/react-native-gesture-handler/blob/db78d3ca7d48e8ba57482d3fe9b0a15aa79d9932/react-native-gesture-handler.d.ts#L440-L457\n// include methods of wrapped components by creating an intersection type with the RN component instead of duplicating them.\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type ScrollView = typeof GHScrollView & RNScrollView;\n\nexport const Switch = createNativeWrapper<RNSwitchProps>(RNSwitch, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: true,\n disallowInterruption: true,\n});\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type Switch = typeof Switch & RNSwitch;\n\nexport const TextInput = createNativeWrapper<RNTextInputProps>(RNTextInput);\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type TextInput = typeof TextInput & RNTextInput;\n\nexport const DrawerLayoutAndroid = createNativeWrapper<\n PropsWithChildren<RNDrawerLayoutAndroidProps>\n>(RNDrawerLayoutAndroid, { disallowInterruption: true });\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type DrawerLayoutAndroid = typeof DrawerLayoutAndroid &\n RNDrawerLayoutAndroid;\n\nexport const FlatList = React.forwardRef((props, ref) => {\n const refreshControlGestureRef = React.useRef<RefreshControl>(null);\n\n const { waitFor, refreshControl, ...rest } = props;\n\n const flatListProps = {};\n const scrollViewProps = {};\n for (const [propName, value] of Object.entries(rest)) {\n // https://github.com/microsoft/TypeScript/issues/26255\n if ((nativeViewProps as readonly string[]).includes(propName)) {\n // @ts-ignore - this function cannot have generic type so we have to ignore this error\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n scrollViewProps[propName] = value;\n } else {\n // @ts-ignore - this function cannot have generic type so we have to ignore this error\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n flatListProps[propName] = value;\n }\n }\n\n return (\n // @ts-ignore - this function cannot have generic type so we have to ignore this error\n <RNFlatList\n ref={ref}\n {...flatListProps}\n renderScrollComponent={(scrollProps) => (\n <ScrollView\n {...{\n ...scrollProps,\n ...scrollViewProps,\n waitFor: [...toArray(waitFor ?? []), refreshControlGestureRef],\n }}\n />\n )}\n // @ts-ignore we don't pass `refreshing` prop as we only want to override the ref\n refreshControl={\n refreshControl\n ? React.cloneElement(refreshControl, {\n // @ts-ignore for reasons unknown to me, `ref` doesn't exist on the type inferred by TS\n ref: refreshControlGestureRef,\n })\n : undefined\n }\n />\n );\n}) as <ItemT = any>(\n props: PropsWithChildren<\n RNFlatListProps<ItemT> &\n RefAttributes<FlatList<ItemT>> &\n NativeViewGestureHandlerProps\n >,\n ref: ForwardedRef<FlatList<ItemT>>\n) => ReactElement | null;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type FlatList<ItemT = any> = typeof FlatList & RNFlatList<ItemT>;\n"]}
|
1
|
+
{"version":3,"sources":["GestureComponents.tsx"],"names":["RefreshControl","RNRefreshControl","disallowInterruption","shouldCancelWhenOutside","GHScrollView","RNScrollView","ScrollView","React","forwardRef","props","ref","refreshControlGestureRef","useRef","refreshControl","waitFor","rest","cloneElement","undefined","Switch","RNSwitch","shouldActivateOnStart","TextInput","RNTextInput","DrawerLayoutAndroid","RNDrawerLayoutAndroid","FlatList","flatListProps","scrollViewProps","propName","value","Object","entries","nativeViewProps","includes","scrollProps"],"mappings":";;;;;;;AAAA;;AAOA;;AAcA;;AAEA;;AAKA;;;;;;;;;;AAEO,MAAMA,cAAc,GAAG,kCAAoBC,2BAApB,EAAsC;AAClEC,EAAAA,oBAAoB,EAAE,IAD4C;AAElEC,EAAAA,uBAAuB,EAAE;AAFyC,CAAtC,CAAvB,C,CAIP;;;AAGA,MAAMC,YAAY,GAAG,kCACnBC,uBADmB,EAEnB;AACEH,EAAAA,oBAAoB,EAAE,IADxB;AAEEC,EAAAA,uBAAuB,EAAE;AAF3B,CAFmB,CAArB;AAOO,MAAMG,UAAU,gBAAGC,KAAK,CAACC,UAAN,CAGxB,CAACC,KAAD,EAAQC,GAAR,KAAgB;AAChB,QAAMC,wBAAwB,GAAGJ,KAAK,CAACK,MAAN,CAA6B,IAA7B,CAAjC;AACA,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,OAAlB;AAA2B,OAAGC;AAA9B,MAAuCN,KAA7C;AAEA,sBACE,oBAAC,YAAD,eACMM,IADN;AAEE;AACA,IAAA,GAAG,EAAEL,GAHP;AAIE,IAAA,OAAO,EAAE,CAAC,GAAG,oBAAQI,OAAR,aAAQA,OAAR,cAAQA,OAAR,GAAmB,EAAnB,CAAJ,EAA4BH,wBAA5B,CAJX,CAKE;AALF;AAME,IAAA,cAAc,EACZE,cAAc,gBACVN,KAAK,CAACS,YAAN,CAAmBH,cAAnB,EAAmC;AACjC;AACAH,MAAAA,GAAG,EAAEC;AAF4B,KAAnC,CADU,GAKVM;AAZR,KADF;AAiBD,CAxByB,CAAnB,C,CAyBP;AACA;AACA;;;AAGO,MAAMC,MAAM,GAAG,kCAAmCC,mBAAnC,EAA6C;AACjEhB,EAAAA,uBAAuB,EAAE,KADwC;AAEjEiB,EAAAA,qBAAqB,EAAE,IAF0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AACS,YAAN,CAAmBH,cAAnB,EAAmC;AACjC;AACAH,QAAAA,GAAG,EAAEC;AAF4B,OAAnC,CADU,GAKVM;AAnBR;AAFF;AAyBD,CA7CuB,CAAjB,C,CAqDP","sourcesContent":["import * as React from 'react';\nimport {\n PropsWithChildren,\n ForwardedRef,\n RefAttributes,\n ReactElement,\n} from 'react';\nimport {\n ScrollView as RNScrollView,\n ScrollViewProps as RNScrollViewProps,\n Switch as RNSwitch,\n SwitchProps as RNSwitchProps,\n TextInput as RNTextInput,\n TextInputProps as RNTextInputProps,\n DrawerLayoutAndroid as RNDrawerLayoutAndroid,\n DrawerLayoutAndroidProps as RNDrawerLayoutAndroidProps,\n FlatList as RNFlatList,\n FlatListProps as RNFlatListProps,\n RefreshControl as RNRefreshControl,\n} from 'react-native';\n\nimport createNativeWrapper from '../handlers/createNativeWrapper';\n\nimport {\n NativeViewGestureHandlerProps,\n nativeViewProps,\n} from '../handlers/NativeViewGestureHandler';\n\nimport { toArray } from '../utils';\n\nexport const RefreshControl = createNativeWrapper(RNRefreshControl, {\n disallowInterruption: true,\n shouldCancelWhenOutside: false,\n});\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type RefreshControl = typeof RefreshControl & RNRefreshControl;\n\nconst GHScrollView = createNativeWrapper<PropsWithChildren<RNScrollViewProps>>(\n RNScrollView,\n {\n disallowInterruption: true,\n shouldCancelWhenOutside: false,\n }\n);\nexport const ScrollView = React.forwardRef<\n RNScrollView,\n RNScrollViewProps & NativeViewGestureHandlerProps\n>((props, ref) => {\n const refreshControlGestureRef = React.useRef<RefreshControl>(null);\n const { refreshControl, waitFor, ...rest } = props;\n\n return (\n <GHScrollView\n {...rest}\n // @ts-ignore `ref` exists on `GHScrollView`\n ref={ref}\n waitFor={[...toArray(waitFor ?? []), refreshControlGestureRef]}\n // @ts-ignore we don't pass `refreshing` prop as we only want to override the ref\n refreshControl={\n refreshControl\n ? React.cloneElement(refreshControl, {\n // @ts-ignore for reasons unknown to me, `ref` doesn't exist on the type inferred by TS\n ref: refreshControlGestureRef,\n })\n : undefined\n }\n />\n );\n});\n// Backward type compatibility with https://github.com/software-mansion/react-native-gesture-handler/blob/db78d3ca7d48e8ba57482d3fe9b0a15aa79d9932/react-native-gesture-handler.d.ts#L440-L457\n// include methods of wrapped components by creating an intersection type with the RN component instead of duplicating them.\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type ScrollView = typeof GHScrollView & RNScrollView;\n\nexport const Switch = createNativeWrapper<RNSwitchProps>(RNSwitch, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: true,\n disallowInterruption: true,\n});\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type Switch = typeof Switch & RNSwitch;\n\nexport const TextInput = createNativeWrapper<RNTextInputProps>(RNTextInput);\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type TextInput = typeof TextInput & RNTextInput;\n\nexport const DrawerLayoutAndroid = createNativeWrapper<\n PropsWithChildren<RNDrawerLayoutAndroidProps>\n>(RNDrawerLayoutAndroid, { disallowInterruption: true });\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type DrawerLayoutAndroid = typeof DrawerLayoutAndroid &\n RNDrawerLayoutAndroid;\n\nexport const FlatList = React.forwardRef((props, ref) => {\n const refreshControlGestureRef = React.useRef<RefreshControl>(null);\n\n const { waitFor, refreshControl, ...rest } = props;\n\n const flatListProps = {};\n const scrollViewProps = {};\n for (const [propName, value] of Object.entries(rest)) {\n // https://github.com/microsoft/TypeScript/issues/26255\n if ((nativeViewProps as readonly string[]).includes(propName)) {\n // @ts-ignore - this function cannot have generic type so we have to ignore this error\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n scrollViewProps[propName] = value;\n } else {\n // @ts-ignore - this function cannot have generic type so we have to ignore this error\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n flatListProps[propName] = value;\n }\n }\n\n return (\n // @ts-ignore - this function cannot have generic type so we have to ignore this error\n <RNFlatList\n ref={ref}\n {...flatListProps}\n renderScrollComponent={(scrollProps) => (\n <ScrollView\n {...{\n ...scrollProps,\n ...scrollViewProps,\n waitFor: [...toArray(waitFor ?? []), refreshControlGestureRef],\n }}\n />\n )}\n // @ts-ignore we don't pass `refreshing` prop as we only want to override the ref\n refreshControl={\n refreshControl\n ? React.cloneElement(refreshControl, {\n // @ts-ignore for reasons unknown to me, `ref` doesn't exist on the type inferred by TS\n ref: refreshControlGestureRef,\n })\n : undefined\n }\n />\n );\n}) as <ItemT = any>(\n props: PropsWithChildren<\n Omit<RNFlatListProps<ItemT>, 'renderScrollComponent'> &\n RefAttributes<FlatList<ItemT>> &\n NativeViewGestureHandlerProps\n >,\n ref: ForwardedRef<FlatList<ItemT>>\n) => ReactElement | null;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type FlatList<ItemT = any> = typeof FlatList & RNFlatList<ItemT>;\n"]}
|
@@ -19,78 +19,81 @@ var _utils = require("./utils");
|
|
19
19
|
|
20
20
|
var _PressabilityDebugView = require("../../handlers/PressabilityDebugView");
|
21
21
|
|
22
|
+
var _utils2 = require("../../utils");
|
23
|
+
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
25
|
|
24
26
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
25
27
|
|
26
28
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
27
29
|
|
30
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
31
|
+
|
28
32
|
const DEFAULT_LONG_PRESS_DURATION = 500;
|
29
33
|
|
30
34
|
function Pressable(props) {
|
31
|
-
var
|
32
|
-
|
33
|
-
const
|
35
|
+
var _android_ripple$color, _android_ripple$radiu;
|
36
|
+
|
37
|
+
const {
|
38
|
+
testOnly_pressed,
|
39
|
+
hitSlop,
|
40
|
+
pressRetentionOffset,
|
41
|
+
delayHoverIn,
|
42
|
+
onHoverIn,
|
43
|
+
delayHoverOut,
|
44
|
+
onHoverOut,
|
45
|
+
delayLongPress,
|
46
|
+
unstable_pressDelay,
|
47
|
+
onPress,
|
48
|
+
onPressIn,
|
49
|
+
onPressOut,
|
50
|
+
onLongPress,
|
51
|
+
style,
|
52
|
+
children,
|
53
|
+
android_disableSound,
|
54
|
+
android_ripple,
|
55
|
+
disabled,
|
56
|
+
...remainingProps
|
57
|
+
} = props;
|
58
|
+
const [pressedState, setPressedState] = (0, _react.useState)(testOnly_pressed !== null && testOnly_pressed !== void 0 ? testOnly_pressed : false);
|
34
59
|
const pressableRef = (0, _react.useRef)(null); // Disabled when onLongPress has been called
|
35
60
|
|
36
61
|
const isPressCallbackEnabled = (0, _react.useRef)(true);
|
37
62
|
const hasPassedBoundsChecks = (0, _react.useRef)(false);
|
38
63
|
const shouldPreventNativeEffects = (0, _react.useRef)(false);
|
39
|
-
const normalizedHitSlop = (0, _react.useMemo)(() => {
|
40
|
-
|
41
|
-
|
42
|
-
return typeof props.hitSlop === 'number' ? (0, _utils.numberAsInset)(props.hitSlop) : (_props$hitSlop = props.hitSlop) !== null && _props$hitSlop !== void 0 ? _props$hitSlop : {};
|
43
|
-
}, [props.hitSlop]);
|
44
|
-
const normalizedPressRetentionOffset = (0, _react.useMemo)(() => {
|
45
|
-
var _props$pressRetention;
|
46
|
-
|
47
|
-
return typeof props.pressRetentionOffset === 'number' ? (0, _utils.numberAsInset)(props.pressRetentionOffset) : (_props$pressRetention = props.pressRetentionOffset) !== null && _props$pressRetention !== void 0 ? _props$pressRetention : {};
|
48
|
-
}, [props.pressRetentionOffset]);
|
64
|
+
const normalizedHitSlop = (0, _react.useMemo)(() => typeof hitSlop === 'number' ? (0, _utils.numberAsInset)(hitSlop) : hitSlop !== null && hitSlop !== void 0 ? hitSlop : {}, [hitSlop]);
|
65
|
+
const normalizedPressRetentionOffset = (0, _react.useMemo)(() => typeof pressRetentionOffset === 'number' ? (0, _utils.numberAsInset)(pressRetentionOffset) : pressRetentionOffset !== null && pressRetentionOffset !== void 0 ? pressRetentionOffset : {}, [pressRetentionOffset]);
|
49
66
|
const hoverInTimeout = (0, _react.useRef)(null);
|
50
67
|
const hoverOutTimeout = (0, _react.useRef)(null);
|
51
68
|
const hoverGesture = (0, _react.useMemo)(() => _gestureObjects.GestureObjects.Hover().manualActivation(true) // Stops Hover from blocking Native gesture activation on web
|
52
69
|
.cancelsTouchesInView(false).onBegin(event => {
|
53
|
-
var _props$onHoverIn2;
|
54
|
-
|
55
70
|
if (hoverOutTimeout.current) {
|
56
71
|
clearTimeout(hoverOutTimeout.current);
|
57
72
|
}
|
58
73
|
|
59
|
-
if (
|
60
|
-
hoverInTimeout.current = setTimeout(() =>
|
61
|
-
var _props$onHoverIn;
|
62
|
-
|
63
|
-
return (_props$onHoverIn = props.onHoverIn) === null || _props$onHoverIn === void 0 ? void 0 : _props$onHoverIn.call(props, (0, _utils.gestureToPressableEvent)(event));
|
64
|
-
}, props.delayHoverIn);
|
74
|
+
if (delayHoverIn) {
|
75
|
+
hoverInTimeout.current = setTimeout(() => onHoverIn === null || onHoverIn === void 0 ? void 0 : onHoverIn((0, _utils.gestureToPressableEvent)(event)), delayHoverIn);
|
65
76
|
return;
|
66
77
|
}
|
67
78
|
|
68
|
-
|
79
|
+
onHoverIn === null || onHoverIn === void 0 ? void 0 : onHoverIn((0, _utils.gestureToPressableEvent)(event));
|
69
80
|
}).onFinalize(event => {
|
70
|
-
var _props$onHoverOut2;
|
71
|
-
|
72
81
|
if (hoverInTimeout.current) {
|
73
82
|
clearTimeout(hoverInTimeout.current);
|
74
83
|
}
|
75
84
|
|
76
|
-
if (
|
77
|
-
hoverOutTimeout.current = setTimeout(() =>
|
78
|
-
var _props$onHoverOut;
|
79
|
-
|
80
|
-
return (_props$onHoverOut = props.onHoverOut) === null || _props$onHoverOut === void 0 ? void 0 : _props$onHoverOut.call(props, (0, _utils.gestureToPressableEvent)(event));
|
81
|
-
}, props.delayHoverOut);
|
85
|
+
if (delayHoverOut) {
|
86
|
+
hoverOutTimeout.current = setTimeout(() => onHoverOut === null || onHoverOut === void 0 ? void 0 : onHoverOut((0, _utils.gestureToPressableEvent)(event)), delayHoverOut);
|
82
87
|
return;
|
83
88
|
}
|
84
89
|
|
85
|
-
|
86
|
-
}), [
|
90
|
+
onHoverOut === null || onHoverOut === void 0 ? void 0 : onHoverOut((0, _utils.gestureToPressableEvent)(event));
|
91
|
+
}), [delayHoverIn, delayHoverOut, onHoverIn, onHoverOut]);
|
87
92
|
const pressDelayTimeoutRef = (0, _react.useRef)(null);
|
88
93
|
const isTouchPropagationAllowed = (0, _react.useRef)(false); // iOS only: due to varying flow of gestures, events sometimes have to be saved for later use
|
89
94
|
|
90
95
|
const deferredEventPayload = (0, _react.useRef)(null);
|
91
96
|
const pressInHandler = (0, _react.useCallback)(event => {
|
92
|
-
var _props$onPressIn;
|
93
|
-
|
94
97
|
if (handlingOnTouchesDown.current) {
|
95
98
|
deferredEventPayload.current = event;
|
96
99
|
}
|
@@ -100,19 +103,17 @@ function Pressable(props) {
|
|
100
103
|
}
|
101
104
|
|
102
105
|
deferredEventPayload.current = null;
|
103
|
-
|
106
|
+
onPressIn === null || onPressIn === void 0 ? void 0 : onPressIn(event);
|
104
107
|
isPressCallbackEnabled.current = true;
|
105
108
|
pressDelayTimeoutRef.current = null;
|
106
109
|
setPressedState(true);
|
107
|
-
}, [
|
110
|
+
}, [onPressIn]);
|
108
111
|
const pressOutHandler = (0, _react.useCallback)(event => {
|
109
|
-
var _props$onPressOut;
|
110
|
-
|
111
112
|
if (!hasPassedBoundsChecks.current || event.nativeEvent.touches.length > event.nativeEvent.changedTouches.length) {
|
112
113
|
return;
|
113
114
|
}
|
114
115
|
|
115
|
-
if (
|
116
|
+
if (unstable_pressDelay && pressDelayTimeoutRef.current !== null) {
|
116
117
|
// When delay is preemptively finished by lifting touches,
|
117
118
|
// we want to immediately activate it's effects - pressInHandler,
|
118
119
|
// even though we are located at the pressOutHandler
|
@@ -121,18 +122,14 @@ function Pressable(props) {
|
|
121
122
|
}
|
122
123
|
|
123
124
|
if (deferredEventPayload.current) {
|
124
|
-
|
125
|
-
|
126
|
-
(_props$onPressIn2 = props.onPressIn) === null || _props$onPressIn2 === void 0 ? void 0 : _props$onPressIn2.call(props, deferredEventPayload.current);
|
125
|
+
onPressIn === null || onPressIn === void 0 ? void 0 : onPressIn(deferredEventPayload.current);
|
127
126
|
deferredEventPayload.current = null;
|
128
127
|
}
|
129
128
|
|
130
|
-
|
129
|
+
onPressOut === null || onPressOut === void 0 ? void 0 : onPressOut(event);
|
131
130
|
|
132
131
|
if (isPressCallbackEnabled.current) {
|
133
|
-
|
134
|
-
|
135
|
-
(_props$onPress = props.onPress) === null || _props$onPress === void 0 ? void 0 : _props$onPress.call(props, event);
|
132
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(event);
|
136
133
|
}
|
137
134
|
|
138
135
|
if (longPressTimeoutRef.current) {
|
@@ -144,7 +141,7 @@ function Pressable(props) {
|
|
144
141
|
hasPassedBoundsChecks.current = false;
|
145
142
|
isPressCallbackEnabled.current = true;
|
146
143
|
setPressedState(false);
|
147
|
-
}, [pressInHandler,
|
144
|
+
}, [onPress, onPressIn, onPressOut, pressInHandler, unstable_pressDelay]);
|
148
145
|
const handlingOnTouchesDown = (0, _react.useRef)(false);
|
149
146
|
const onEndHandlingTouchesDown = (0, _react.useRef)(null);
|
150
147
|
const cancelledMidPress = (0, _react.useRef)(false);
|
@@ -154,9 +151,7 @@ function Pressable(props) {
|
|
154
151
|
}
|
155
152
|
|
156
153
|
if (hasPassedBoundsChecks.current) {
|
157
|
-
|
158
|
-
|
159
|
-
(_props$onLongPress = props.onLongPress) === null || _props$onLongPress === void 0 ? void 0 : _props$onLongPress.call(props, (0, _utils.gestureTouchToPressableEvent)(event));
|
154
|
+
onLongPress === null || onLongPress === void 0 ? void 0 : onLongPress((0, _utils.gestureTouchToPressableEvent)(event));
|
160
155
|
isPressCallbackEnabled.current = false;
|
161
156
|
}
|
162
157
|
|
@@ -164,11 +159,11 @@ function Pressable(props) {
|
|
164
159
|
clearTimeout(longPressTimeoutRef.current);
|
165
160
|
longPressTimeoutRef.current = null;
|
166
161
|
}
|
167
|
-
}, [
|
162
|
+
}, [onLongPress]);
|
168
163
|
const longPressTimeoutRef = (0, _react.useRef)(null);
|
169
|
-
const longPressMinDuration = (
|
170
|
-
const pressAndTouchGesture = (0, _react.useMemo)(() => _gestureObjects.GestureObjects.LongPress().minDuration(
|
171
|
-
.maxDistance(
|
164
|
+
const longPressMinDuration = (delayLongPress !== null && delayLongPress !== void 0 ? delayLongPress : DEFAULT_LONG_PRESS_DURATION) + (unstable_pressDelay !== null && unstable_pressDelay !== void 0 ? unstable_pressDelay : 0);
|
165
|
+
const pressAndTouchGesture = (0, _react.useMemo)(() => _gestureObjects.GestureObjects.LongPress().minDuration(_utils2.INT32_MAX) // Stops long press from blocking native gesture
|
166
|
+
.maxDistance(_utils2.INT32_MAX) // Stops long press from cancelling after set distance
|
172
167
|
.cancelsTouchesInView(false).onTouchesDown(event => {
|
173
168
|
var _pressableRef$current;
|
174
169
|
|
@@ -193,10 +188,10 @@ function Pressable(props) {
|
|
193
188
|
longPressTimeoutRef.current = setTimeout(() => activateLongPress(event), longPressMinDuration);
|
194
189
|
}
|
195
190
|
|
196
|
-
if (
|
191
|
+
if (unstable_pressDelay) {
|
197
192
|
pressDelayTimeoutRef.current = setTimeout(() => {
|
198
193
|
pressInHandler((0, _utils.gestureTouchToPressableEvent)(event));
|
199
|
-
},
|
194
|
+
}, unstable_pressDelay);
|
200
195
|
} else {
|
201
196
|
pressInHandler((0, _utils.gestureTouchToPressableEvent)(event));
|
202
197
|
}
|
@@ -235,7 +230,7 @@ function Pressable(props) {
|
|
235
230
|
}
|
236
231
|
|
237
232
|
pressOutHandler((0, _utils.gestureTouchToPressableEvent)(event));
|
238
|
-
}), [activateLongPress, longPressMinDuration, normalizedHitSlop, pressInHandler, pressOutHandler,
|
233
|
+
}), [activateLongPress, longPressMinDuration, normalizedHitSlop, pressInHandler, pressOutHandler, unstable_pressDelay]); // RNButton is placed inside ButtonGesture to enable Android's ripple and to capture non-propagating events
|
239
234
|
|
240
235
|
const buttonGesture = (0, _react.useMemo)(() => _gestureObjects.GestureObjects.Native().onBegin(() => {
|
241
236
|
// Android sets BEGAN state on press down
|
@@ -279,7 +274,7 @@ function Pressable(props) {
|
|
279
274
|
isTouchPropagationAllowed.current = true;
|
280
275
|
}), [pressInHandler, pressOutHandler]);
|
281
276
|
const appliedHitSlop = (0, _utils.addInsets)(normalizedHitSlop, normalizedPressRetentionOffset);
|
282
|
-
const isPressableEnabled =
|
277
|
+
const isPressableEnabled = disabled !== true;
|
283
278
|
const gestures = [pressAndTouchGesture, hoverGesture, buttonGesture];
|
284
279
|
|
285
280
|
for (const gesture of gestures) {
|
@@ -298,37 +293,30 @@ function Pressable(props) {
|
|
298
293
|
|
299
294
|
const gesture = _gestureObjects.GestureObjects.Simultaneous(...gestures);
|
300
295
|
|
301
|
-
const defaultRippleColor =
|
296
|
+
const defaultRippleColor = android_ripple ? undefined : 'transparent'; // `cursor: 'pointer'` on `RNButton` crashes iOS
|
302
297
|
|
303
298
|
const pointerStyle = _reactNative.Platform.OS === 'web' ? {
|
304
299
|
cursor: 'pointer'
|
305
300
|
} : {};
|
306
|
-
const styleProp = typeof
|
301
|
+
const styleProp = typeof style === 'function' ? style({
|
307
302
|
pressed: pressedState
|
308
|
-
}) :
|
309
|
-
const childrenProp = typeof
|
303
|
+
}) : style;
|
304
|
+
const childrenProp = typeof children === 'function' ? children({
|
310
305
|
pressed: pressedState
|
311
|
-
}) :
|
312
|
-
|
313
|
-
const flattenedStyles = _reactNative.StyleSheet.flatten(styleProp !== null && styleProp !== void 0 ? styleProp : {});
|
314
|
-
|
315
|
-
const [innerStyles, outerStyles] = (0, _utils.splitStyles)(flattenedStyles);
|
316
|
-
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
317
|
-
style: outerStyles
|
318
|
-
}, /*#__PURE__*/_react.default.createElement(_GestureDetector.GestureDetector, {
|
306
|
+
}) : children;
|
307
|
+
return /*#__PURE__*/_react.default.createElement(_GestureDetector.GestureDetector, {
|
319
308
|
gesture: gesture
|
320
|
-
}, /*#__PURE__*/_react.default.createElement(_GestureHandlerButton.default, {
|
309
|
+
}, /*#__PURE__*/_react.default.createElement(_GestureHandlerButton.default, _extends({}, remainingProps, {
|
321
310
|
ref: pressableRef,
|
322
|
-
testID: props.testID,
|
323
311
|
hitSlop: appliedHitSlop,
|
324
312
|
enabled: isPressableEnabled,
|
325
|
-
touchSoundDisabled:
|
326
|
-
rippleColor: (0, _reactNative.processColor)((
|
327
|
-
rippleRadius: (
|
328
|
-
style: [
|
329
|
-
}, childrenProp, __DEV__ ? /*#__PURE__*/_react.default.createElement(_PressabilityDebugView.PressabilityDebugView, {
|
313
|
+
touchSoundDisabled: android_disableSound !== null && android_disableSound !== void 0 ? android_disableSound : undefined,
|
314
|
+
rippleColor: (0, _reactNative.processColor)((_android_ripple$color = android_ripple === null || android_ripple === void 0 ? void 0 : android_ripple.color) !== null && _android_ripple$color !== void 0 ? _android_ripple$color : defaultRippleColor),
|
315
|
+
rippleRadius: (_android_ripple$radiu = android_ripple === null || android_ripple === void 0 ? void 0 : android_ripple.radius) !== null && _android_ripple$radiu !== void 0 ? _android_ripple$radiu : undefined,
|
316
|
+
style: [pointerStyle, styleProp]
|
317
|
+
}), childrenProp, __DEV__ ? /*#__PURE__*/_react.default.createElement(_PressabilityDebugView.PressabilityDebugView, {
|
330
318
|
color: "red",
|
331
319
|
hitSlop: normalizedHitSlop
|
332
|
-
}) : null))
|
320
|
+
}) : null));
|
333
321
|
}
|
334
322
|
//# sourceMappingURL=Pressable.js.map
|