react-native-keyboard-controller 1.1.0 → 1.3.0

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 (101) hide show
  1. package/android/build.gradle +32 -3
  2. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +25 -0
  3. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +32 -0
  4. package/android/src/fabric/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +25 -0
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt +6 -6
  6. package/android/src/main/java/com/reactnativekeyboardcontroller/{KeyboardControllerModule.kt → KeyboardControllerModuleImpl.kt} +5 -17
  7. package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +45 -4
  8. package/android/src/main/java/com/reactnativekeyboardcontroller/{KeyboardControllerViewManager.kt → KeyboardControllerViewManagerImpl.kt} +8 -9
  9. package/android/src/main/java/com/reactnativekeyboardcontroller/{StatusBarManagerCompatModule.kt → StatusBarManagerCompatImpl.kt} +10 -14
  10. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +31 -0
  11. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +26 -0
  12. package/android/src/paper/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +34 -0
  13. package/ios/.clang-format +1 -1
  14. package/ios/KeyboardController.xcodeproj/project.pbxproj +20 -16
  15. package/ios/KeyboardControllerModule-Header.h +6 -2
  16. package/ios/KeyboardControllerModule.mm +105 -0
  17. package/ios/KeyboardControllerView.h +23 -0
  18. package/ios/KeyboardControllerView.mm +81 -0
  19. package/ios/{KeyboardControllerViewManager.m → KeyboardControllerViewManager.mm} +0 -0
  20. package/ios/KeyboardControllerViewManager.swift +2 -2
  21. package/ios/KeyboardMoveEvent.h +18 -0
  22. package/ios/KeyboardMoveEvent.m +74 -0
  23. package/lib/commonjs/animated.js +14 -59
  24. package/lib/commonjs/animated.js.map +1 -1
  25. package/lib/commonjs/context.js +28 -0
  26. package/lib/commonjs/context.js.map +1 -0
  27. package/lib/commonjs/hooks.js +39 -0
  28. package/lib/commonjs/hooks.js.map +1 -0
  29. package/lib/commonjs/index.js +39 -0
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/internal.js +27 -0
  32. package/lib/commonjs/internal.js.map +1 -0
  33. package/lib/commonjs/monkey-patch.js +3 -1
  34. package/lib/commonjs/monkey-patch.js.map +1 -1
  35. package/lib/commonjs/native.js +24 -19
  36. package/lib/commonjs/native.js.map +1 -1
  37. package/lib/commonjs/replicas.js +2 -2
  38. package/lib/commonjs/replicas.js.map +1 -1
  39. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +16 -0
  40. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
  41. package/lib/commonjs/specs/NativeKeyboardController.js +13 -0
  42. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -0
  43. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +13 -0
  44. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -0
  45. package/lib/commonjs/types.js +6 -0
  46. package/lib/commonjs/types.js.map +1 -0
  47. package/lib/module/animated.js +12 -50
  48. package/lib/module/animated.js.map +1 -1
  49. package/lib/module/context.js +18 -0
  50. package/lib/module/context.js.map +1 -0
  51. package/lib/module/hooks.js +20 -0
  52. package/lib/module/hooks.js.map +1 -0
  53. package/lib/module/index.js +3 -0
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/internal.js +19 -0
  56. package/lib/module/internal.js.map +1 -0
  57. package/lib/module/monkey-patch.js +4 -2
  58. package/lib/module/monkey-patch.js.map +1 -1
  59. package/lib/module/native.js +23 -16
  60. package/lib/module/native.js.map +1 -1
  61. package/lib/module/replicas.js +1 -1
  62. package/lib/module/replicas.js.map +1 -1
  63. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +4 -0
  64. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
  65. package/lib/module/specs/NativeKeyboardController.js +3 -0
  66. package/lib/module/specs/NativeKeyboardController.js.map +1 -0
  67. package/lib/module/specs/NativeStatusBarManagerCompat.js +3 -0
  68. package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -0
  69. package/lib/module/types.js +2 -0
  70. package/lib/module/types.js.map +1 -0
  71. package/lib/typescript/animated.d.ts +1 -17
  72. package/lib/typescript/context.d.ts +16 -0
  73. package/lib/typescript/hooks.d.ts +4 -0
  74. package/lib/typescript/index.d.ts +3 -0
  75. package/lib/typescript/internal.d.ts +4 -0
  76. package/lib/typescript/native.d.ts +15 -27
  77. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +13 -0
  78. package/lib/typescript/specs/NativeKeyboardController.d.ts +10 -0
  79. package/lib/typescript/specs/NativeStatusBarManagerCompat.d.ts +10 -0
  80. package/lib/typescript/types.d.ts +23 -0
  81. package/package.json +20 -8
  82. package/react-native-keyboard-controller.podspec +21 -1
  83. package/src/animated.tsx +12 -75
  84. package/src/context.ts +28 -0
  85. package/src/hooks.ts +28 -0
  86. package/src/index.ts +3 -0
  87. package/src/internal.ts +27 -0
  88. package/src/{monkey-patch.tsx → monkey-patch.ts} +3 -2
  89. package/src/native.ts +37 -61
  90. package/src/replicas.ts +1 -1
  91. package/src/specs/KeyboardControllerViewNativeComponent.ts +23 -0
  92. package/src/specs/NativeKeyboardController.ts +16 -0
  93. package/src/specs/NativeStatusBarManagerCompat.ts +13 -0
  94. package/src/types.ts +42 -0
  95. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  96. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  97. package/android/gradlew +0 -185
  98. package/android/gradlew.bat +0 -89
  99. package/ios/KeyboardControllerModule.m +0 -21
  100. package/ios/KeyboardControllerModule.swift +0 -53
  101. package/ios/KeyboardMoveEvent.swift +0 -41
@@ -0,0 +1,105 @@
1
+ //
2
+ // KeyboardControllerModule.m
3
+ // KeyboardController
4
+ //
5
+ // Created by Kiryl Ziusko on 22.04.22.
6
+ // Copyright © 2022 Facebook. All rights reserved.
7
+ //
8
+
9
+ #import <React/RCTBridgeModule.h>
10
+ #import <React/RCTEventEmitter.h>
11
+
12
+ // Thanks to this guard, we won't import this header when we build for the old architecture.
13
+ #ifdef RCT_NEW_ARCH_ENABLED
14
+ #import <FBReactNativeSpec/FBReactNativeSpec.h>
15
+ #import <reactnativekeyboardcontroller/reactnativekeyboardcontroller.h>
16
+ #endif
17
+
18
+ #import "KeyboardControllerModule-Header.h"
19
+
20
+ #import <React/RCTEventDispatcherProtocol.h>
21
+
22
+ #ifdef RCT_NEW_ARCH_ENABLED
23
+ @interface KeyboardController () <NativeKeyboardControllerSpec>
24
+ @end
25
+ #endif
26
+
27
+ @implementation KeyboardController {
28
+ bool hasListeners;
29
+ }
30
+
31
+ static KeyboardController *shared = nil;
32
+
33
+ RCT_EXPORT_MODULE()
34
+
35
+ - (instancetype)init
36
+ {
37
+ self = [super init];
38
+ shared = self;
39
+
40
+ return self;
41
+ }
42
+
43
+ + (BOOL)requiresMainQueueSetup
44
+ {
45
+ return NO;
46
+ }
47
+
48
+ #ifdef RCT_NEW_ARCH_ENABLED
49
+ - (void)setDefaultMode
50
+ #else
51
+ RCT_EXPORT_METHOD(setDefaultMode)
52
+ #endif
53
+ {
54
+ }
55
+
56
+ #ifdef RCT_NEW_ARCH_ENABLED
57
+ - (void)setInputMode:(double)mode
58
+ #else
59
+ RCT_EXPORT_METHOD(setInputMode : (nonnull NSNumber *)mode)
60
+ #endif
61
+ {
62
+ }
63
+
64
+ + (KeyboardController *)shared
65
+ {
66
+ return shared;
67
+ }
68
+
69
+ - (void)startObserving
70
+ {
71
+ hasListeners = YES;
72
+ }
73
+
74
+ - (void)stopObserving
75
+ {
76
+ hasListeners = NO;
77
+ }
78
+
79
+ - (void)sendEvent:(NSString *)name body:(id)body
80
+ {
81
+ if (hasListeners) {
82
+ [self sendEventWithName:name body:body];
83
+ }
84
+ }
85
+
86
+ - (NSArray<NSString *> *)supportedEvents
87
+ {
88
+ return @[
89
+ @"KeyboardController::keyboardWillShow",
90
+ @"KeyboardController::keyboardDidShow",
91
+ @"KeyboardController::keyboardWillHide",
92
+ @"KeyboardController::keyboardDidHide",
93
+ ];
94
+ }
95
+
96
+ // Thanks to this guard, we won't compile this code when we build for the old architecture.
97
+ #ifdef RCT_NEW_ARCH_ENABLED
98
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
99
+ (const facebook::react::ObjCTurboModule::InitParams &)params
100
+ {
101
+ return std::make_shared<facebook::react::NativeKeyboardControllerSpecJSI>(params);
102
+ }
103
+ #endif
104
+
105
+ @end
@@ -0,0 +1,23 @@
1
+ //
2
+ // KeyboardControllerView.h
3
+ // KeyboardController
4
+ //
5
+ // Created by Kiryl Ziusko on 2.08.22.
6
+ // Copyright © 2022 Facebook. All rights reserved.
7
+ //
8
+
9
+ #pragma once
10
+
11
+ // This guard prevent this file to be compiled in the old architecture.
12
+ #ifdef RCT_NEW_ARCH_ENABLED
13
+ #import <React/RCTViewComponentView.h>
14
+ #import <UIKit/UIKit.h>
15
+
16
+ NS_ASSUME_NONNULL_BEGIN
17
+
18
+ @interface KeyboardControllerView : RCTViewComponentView
19
+ @end
20
+
21
+ NS_ASSUME_NONNULL_END
22
+
23
+ #endif /* RCT_NEW_ARCH_ENABLED */
@@ -0,0 +1,81 @@
1
+ //
2
+ // KeyboardControllerView.mm
3
+ // KeyboardController
4
+ //
5
+ // Created by Kiryl Ziusko on 2.08.22.
6
+ // Copyright © 2022 Facebook. All rights reserved.
7
+ //
8
+
9
+ // This guard prevent the code from being compiled in the old architecture
10
+ #ifdef RCT_NEW_ARCH_ENABLED
11
+ #import "KeyboardControllerView.h"
12
+ #import "KeyboardMoveEvent.h"
13
+ #import "react_native_keyboard_controller-Swift.h"
14
+
15
+ #import <react/renderer/components/reactnativekeyboardcontroller/ComponentDescriptors.h>
16
+ #import <react/renderer/components/reactnativekeyboardcontroller/EventEmitters.h>
17
+ #import <react/renderer/components/reactnativekeyboardcontroller/Props.h>
18
+ #import <react/renderer/components/reactnativekeyboardcontroller/RCTComponentViewHelpers.h>
19
+
20
+ #import <React/RCTBridge+Private.h>
21
+
22
+ #import "KeyboardControllerModule-Header.h"
23
+ #import "RCTFabricComponentsPlugins.h"
24
+
25
+ using namespace facebook::react;
26
+
27
+ @interface KeyboardControllerView () <RCTKeyboardControllerViewViewProtocol>
28
+
29
+ @end
30
+
31
+ @implementation KeyboardControllerView {
32
+ KeyboardMovementObserver *observer;
33
+ }
34
+
35
+ + (ComponentDescriptorProvider)componentDescriptorProvider
36
+ {
37
+ return concreteComponentDescriptorProvider<KeyboardControllerViewComponentDescriptor>();
38
+ }
39
+
40
+ - (instancetype)initWithFrame:(CGRect)frame
41
+ {
42
+ if (self = [super initWithFrame:frame]) {
43
+ static const auto defaultProps = std::make_shared<const KeyboardControllerViewProps>();
44
+ _props = defaultProps;
45
+
46
+ observer = [[KeyboardMovementObserver alloc]
47
+ initWithHandler:^(NSNumber *height, NSNumber *progress) {
48
+ if (self->_eventEmitter) {
49
+ std::dynamic_pointer_cast<const facebook::react::KeyboardControllerViewEventEmitter>(
50
+ self->_eventEmitter)
51
+ ->onKeyboardMove(
52
+ facebook::react::KeyboardControllerViewEventEmitter::OnKeyboardMove{
53
+ .height = [height intValue], .progress = static_cast<Float>(self.tag)});
54
+ }
55
+
56
+ // TODO: use built-in _eventEmitter once NativeAnimated module will use ModernEventemitter
57
+ RCTBridge *bridge = [RCTBridge currentBridge];
58
+ if (bridge) {
59
+ KeyboardMoveEvent *keyboardMoveEvent =
60
+ [[KeyboardMoveEvent alloc] initWithReactTag:@(self.tag)
61
+ height:height
62
+ progress:progress];
63
+ [bridge.eventDispatcher sendEvent:keyboardMoveEvent];
64
+ }
65
+ }
66
+ onNotify:^(NSString *event, NSDictionary *data) {
67
+ [KeyboardController.shared sendEvent:event body:data];
68
+ }];
69
+ [observer mount];
70
+ }
71
+
72
+ return self;
73
+ }
74
+
75
+ Class<RCTComponentViewProtocol> KeyboardControllerViewCls(void)
76
+ {
77
+ return KeyboardControllerView.class;
78
+ }
79
+
80
+ @end
81
+ #endif
@@ -42,7 +42,7 @@ class KeyboardControllerView: UIView {
42
42
  func onEvent(height: NSNumber, progress: NSNumber) {
43
43
  eventDispatcher.send(
44
44
  KeyboardMoveEvent(
45
- viewTag: reactTag,
45
+ reactTag: reactTag,
46
46
  height: height,
47
47
  progress: progress
48
48
  )
@@ -50,6 +50,6 @@ class KeyboardControllerView: UIView {
50
50
  }
51
51
 
52
52
  func onNotify(event: String, data: Any) {
53
- KeyboardController.shared?.sendEvent(withName: event, body: data)
53
+ KeyboardController.shared()?.sendEvent(event, body: data)
54
54
  }
55
55
  }
@@ -0,0 +1,18 @@
1
+ //
2
+ // KeyboardMoveEvent.h
3
+ // KeyboardController
4
+ //
5
+ // Created by Kiryl Ziusko on 6.08.22.
6
+ // Copyright © 2022 Facebook. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import <React/RCTEventDispatcherProtocol.h>
11
+
12
+ @interface KeyboardMoveEvent : NSObject <RCTEvent>
13
+
14
+ - (instancetype)initWithReactTag:(NSNumber *)reactTag
15
+ height:(NSNumber *)height
16
+ progress:(NSNumber *)progress;
17
+
18
+ @end
@@ -0,0 +1,74 @@
1
+ //
2
+ // KeyboardMoveEvent.m
3
+ // KeyboardController
4
+ //
5
+ // Created by Kiryl Ziusko on 6.08.22.
6
+ // Copyright © 2022 Facebook. All rights reserved.
7
+ //
8
+
9
+ #import "KeyboardMoveEvent.h"
10
+ #import <React/RCTAssert.h>
11
+
12
+ @implementation KeyboardMoveEvent {
13
+ NSNumber *_progress;
14
+ NSNumber *_height;
15
+ uint16_t _coalescingKey;
16
+ }
17
+
18
+ @synthesize viewTag = _viewTag;
19
+ @synthesize eventName = _eventName;
20
+
21
+ - (instancetype)initWithReactTag:(NSNumber *)reactTag
22
+ height:(NSNumber *)height
23
+ progress:(NSNumber *)progress
24
+ {
25
+ RCTAssertParam(reactTag);
26
+
27
+ if ((self = [super init])) {
28
+ _eventName = @"onKeyboardMove";
29
+ _viewTag = reactTag;
30
+ _progress = progress;
31
+ _height = height;
32
+ _coalescingKey = 0;
33
+ }
34
+ return self;
35
+ }
36
+
37
+ RCT_NOT_IMPLEMENTED(-(instancetype)init)
38
+
39
+ - (uint16_t)coalescingKey
40
+ {
41
+ return _coalescingKey;
42
+ }
43
+
44
+ - (NSDictionary *)body
45
+ {
46
+ NSDictionary *body = @{
47
+ @"progress" : _progress,
48
+ @"height" : _height,
49
+ };
50
+
51
+ return body;
52
+ }
53
+
54
+ - (BOOL)canCoalesce
55
+ {
56
+ return NO;
57
+ }
58
+
59
+ - (KeyboardMoveEvent *)coalesceWithEvent:(KeyboardMoveEvent *)newEvent
60
+ {
61
+ return newEvent;
62
+ }
63
+
64
+ + (NSString *)moduleDotMethod
65
+ {
66
+ return @"RCTEventEmitter.receiveEvent";
67
+ }
68
+
69
+ - (NSArray *)arguments
70
+ {
71
+ return @[ self.viewTag, RCTNormalizeInputEventName(self.eventName), [self body] ];
72
+ }
73
+
74
+ @end
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useReanimatedKeyboardAnimation = exports.useKeyboardAnimation = exports.styles = exports.KeyboardProvider = exports.KeyboardContext = void 0;
6
+ exports.styles = exports.KeyboardProvider = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
@@ -11,6 +11,10 @@ var _reactNative = require("react-native");
11
11
 
12
12
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
13
13
 
14
+ var _context = require("./context");
15
+
16
+ var _internal = require("./internal");
17
+
14
18
  var _native = require("./native");
15
19
 
16
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -19,59 +23,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
19
23
 
20
24
  const KeyboardControllerViewAnimated = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.Animated.createAnimatedComponent(_native.KeyboardControllerView));
21
25
 
22
- const defaultContext = {
23
- animated: {
24
- progress: new _reactNative.Animated.Value(0),
25
- height: new _reactNative.Animated.Value(0)
26
- },
27
- reanimated: {
28
- progress: {
29
- value: 0
30
- },
31
- height: {
32
- value: 0
33
- }
34
- }
35
- };
36
-
37
- const KeyboardContext = /*#__PURE__*/_react.default.createContext(defaultContext);
38
-
39
- exports.KeyboardContext = KeyboardContext;
40
-
41
- const useKeyboardAnimation = () => {
42
- (0, _native.useResizeMode)();
43
- const context = (0, _react.useContext)(KeyboardContext);
44
- return context.animated;
45
- };
46
-
47
- exports.useKeyboardAnimation = useKeyboardAnimation;
48
-
49
- const useReanimatedKeyboardAnimation = () => {
50
- (0, _native.useResizeMode)();
51
- const context = (0, _react.useContext)(KeyboardContext);
52
- return context.reanimated;
53
- };
54
-
55
- exports.useReanimatedKeyboardAnimation = useReanimatedKeyboardAnimation;
56
-
57
- function useAnimatedKeyboardHandler(handlers, dependencies) {
58
- const {
59
- context,
60
- doDependenciesDiffer
61
- } = (0, _reactNativeReanimated.useHandler)(handlers, dependencies);
62
- return (0, _reactNativeReanimated.useEvent)(event => {
63
- 'worklet';
64
-
65
- const {
66
- onKeyboardMove
67
- } = handlers;
68
-
69
- if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
70
- onKeyboardMove(event, context);
71
- }
72
- }, ['onKeyboardMove'], doDependenciesDiffer);
73
- }
74
-
75
26
  const styles = _reactNative.StyleSheet.create({
76
27
  container: {
77
28
  flex: 1
@@ -89,10 +40,13 @@ const KeyboardProvider = _ref => {
89
40
  children,
90
41
  statusBarTranslucent
91
42
  } = _ref;
43
+ // animated values
92
44
  const progress = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
93
- const height = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
45
+ const height = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current; // shared values
46
+
94
47
  const progressSV = (0, _reactNativeReanimated.useSharedValue)(0);
95
- const heightSV = (0, _reactNativeReanimated.useSharedValue)(0);
48
+ const heightSV = (0, _reactNativeReanimated.useSharedValue)(0); // memo
49
+
96
50
  const context = (0, _react.useMemo)(() => ({
97
51
  animated: {
98
52
  progress: progress,
@@ -117,8 +71,9 @@ const KeyboardProvider = _ref => {
117
71
  }
118
72
  }], {
119
73
  useNativeDriver: true
120
- }), []);
121
- const handler = useAnimatedKeyboardHandler({
74
+ }), []); // handlers
75
+
76
+ const handler = (0, _internal.useAnimatedKeyboardHandler)({
122
77
  onKeyboardMove: event => {
123
78
  'worklet';
124
79
 
@@ -126,7 +81,7 @@ const KeyboardProvider = _ref => {
126
81
  heightSV.value = event.height;
127
82
  }
128
83
  }, []);
129
- return /*#__PURE__*/_react.default.createElement(KeyboardContext.Provider, {
84
+ return /*#__PURE__*/_react.default.createElement(_context.KeyboardContext.Provider, {
130
85
  value: context
131
86
  }, /*#__PURE__*/_react.default.createElement(KeyboardControllerViewAnimated, {
132
87
  onKeyboardMoveReanimated: handler,
@@ -1 +1 @@
1
- {"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","defaultContext","animated","progress","Value","height","reanimated","value","KeyboardContext","React","createContext","useKeyboardAnimation","useResizeMode","context","useContext","useReanimatedKeyboardAnimation","useAnimatedKeyboardHandler","handlers","dependencies","doDependenciesDiffer","useHandler","useEvent","event","onKeyboardMove","eventName","endsWith","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","useRef","current","progressSV","useSharedValue","heightSV","useMemo","style","transform","translateX","translateY","nativeEvent","useNativeDriver","handler"],"sources":["animated.tsx"],"sourcesContent":["import React, { useContext, useMemo, useRef } from 'react';\nimport { Animated, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, {\n useEvent,\n useHandler,\n useSharedValue,\n} from 'react-native-reanimated';\nimport {\n EventWithName,\n KeyboardControllerProps,\n KeyboardControllerView,\n NativeEvent,\n useResizeMode,\n} from './native';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype AnimatedContext = {\n progress: Animated.Value;\n height: Animated.Value;\n};\ntype ReanimatedContext = {\n progress: Reanimated.SharedValue<number>;\n height: Reanimated.SharedValue<number>;\n};\ntype KeyboardAnimationContext = {\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n};\nconst defaultContext: KeyboardAnimationContext = {\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: { value: 0 },\n height: { value: 0 },\n },\n};\nexport const KeyboardContext = React.createContext(defaultContext);\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.reanimated;\n};\n\nfunction useAnimatedKeyboardHandler<TContext extends Record<string, unknown>>(\n handlers: {\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: ReadonlyArray<unknown>\n) {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event: EventWithName<NativeEvent>) => {\n 'worklet';\n const { onKeyboardMove } = handlers;\n\n if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {\n onKeyboardMove(event, context);\n }\n },\n ['onKeyboardMove'],\n doDependenciesDiffer\n );\n}\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nexport const styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: 'none',\n position: 'absolute',\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n}: KeyboardProviderProps) => {\n const progress = useRef(new Animated.Value(0)).current;\n const height = useRef(new Animated.Value(0)).current;\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: height },\n reanimated: { progress: progressSV, height: heightSV },\n }),\n []\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n\n const handler = useAnimatedKeyboardHandler(\n {\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n progressSV.value = event.progress;\n heightSV.value = event.height;\n },\n },\n []\n );\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMove={onKeyboardMove}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n >\n <>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n {children}\n </>\n </KeyboardControllerViewAnimated>\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":"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"}
1
+ {"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","progress","useRef","Value","current","height","progressSV","useSharedValue","heightSV","context","useMemo","animated","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","handler","useAnimatedKeyboardHandler","value"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { Animated, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport { useAnimatedKeyboardHandler } from './internal';\nimport { KeyboardControllerView } from './native';\n\nimport type { KeyboardControllerProps, NativeEvent } from './types';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nexport const styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: 'none',\n position: 'absolute',\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n}: KeyboardProviderProps) => {\n // animated values\n const progress = useRef(new Animated.Value(0)).current;\n const height = useRef(new Animated.Value(0)).current;\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n // memo\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: height },\n reanimated: { progress: progressSV, height: heightSV },\n }),\n []\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const handler = useAnimatedKeyboardHandler(\n {\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n progressSV.value = event.progress;\n heightSV.value = event.height;\n },\n },\n []\n );\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMove={onKeyboardMove}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n >\n <>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n {children}\n </>\n </KeyboardControllerViewAnimated>\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;AAIA,MAAMA,8BAA8B,GAAGC,8BAAA,CAAWC,uBAAX,CACrCC,qBAAA,CAASD,uBAAT,CACEE,8BADF,CADqC,CAAvC;;AAWO,MAAMC,MAAM,GAAGC,uBAAA,CAAWC,MAAX,CAA0B;EAC9CC,SAAS,EAAE;IACTC,IAAI,EAAE;EADG,CADmC;EAI9CC,MAAM,EAAE;IACNC,OAAO,EAAE,MADH;IAENC,QAAQ,EAAE;EAFJ;AAJsC,CAA1B,CAAf;;;;AAwBA,MAAMC,gBAAgB,GAAG,QAGH;EAAA,IAHI;IAC/BC,QAD+B;IAE/BC;EAF+B,CAGJ;EAC3B;EACA,MAAMC,QAAQ,GAAG,IAAAC,aAAA,EAAO,IAAId,qBAAA,CAASe,KAAb,CAAmB,CAAnB,CAAP,EAA8BC,OAA/C;EACA,MAAMC,MAAM,GAAG,IAAAH,aAAA,EAAO,IAAId,qBAAA,CAASe,KAAb,CAAmB,CAAnB,CAAP,EAA8BC,OAA7C,CAH2B,CAI3B;;EACA,MAAME,UAAU,GAAG,IAAAC,qCAAA,EAAe,CAAf,CAAnB;EACA,MAAMC,QAAQ,GAAG,IAAAD,qCAAA,EAAe,CAAf,CAAjB,CAN2B,CAO3B;;EACA,MAAME,OAAO,GAAG,IAAAC,cAAA,EACd,OAAO;IACLC,QAAQ,EAAE;MAAEV,QAAQ,EAAEA,QAAZ;MAAsBI,MAAM,EAAEA;IAA9B,CADL;IAELO,UAAU,EAAE;MAAEX,QAAQ,EAAEK,UAAZ;MAAwBD,MAAM,EAAEG;IAAhC;EAFP,CAAP,CADc,EAKd,EALc,CAAhB;EAOA,MAAMK,KAAK,GAAG,IAAAH,cAAA,EACZ,MAAM,CACJpB,MAAM,CAACK,MADH,EAEJ;IAAEmB,SAAS,EAAE,CAAC;MAAEC,UAAU,EAAEV;IAAd,CAAD,EAAyB;MAAEW,UAAU,EAAEf;IAAd,CAAzB;EAAb,CAFI,CADM,EAKZ,EALY,CAAd;EAOA,MAAMgB,cAAc,GAAG,IAAAP,cAAA,EACrB,MACEtB,qBAAA,CAAS8B,KAAT,CACE,CACE;IACEC,WAAW,EAAE;MACXlB,QADW;MAEXI;IAFW;EADf,CADF,CADF,EASE;IAAEe,eAAe,EAAE;EAAnB,CATF,CAFmB,EAarB,EAbqB,CAAvB,CAtB2B,CAqC3B;;EACA,MAAMC,OAAO,GAAG,IAAAC,oCAAA,EACd;IACEL,cAAc,EAAGC,KAAD,IAAwB;MACtC;;MACAZ,UAAU,CAACiB,KAAX,GAAmBL,KAAK,CAACjB,QAAzB;MACAO,QAAQ,CAACe,KAAT,GAAiBL,KAAK,CAACb,MAAvB;IACD;EALH,CADc,EAQd,EARc,CAAhB;EAWA,oBACE,6BAAC,wBAAD,CAAiB,QAAjB;IAA0B,KAAK,EAAEI;EAAjC,gBACE,6BAAC,8BAAD;IACE,wBAAwB,EAAEY,OAD5B;IAEE,cAAc,EAAEJ,cAFlB;IAGE,oBAAoB,EAAEjB,oBAHxB;IAIE,KAAK,EAAEV,MAAM,CAACG;EAJhB,gBAME,yEACE,6BAAC,qBAAD,CAAU,IAAV;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEoB;EATT,EADF,EAYGd,QAZH,CANF,CADF,CADF;AAyBD,CA7EM"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.KeyboardContext = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ const defaultContext = {
13
+ animated: {
14
+ progress: new _reactNative.Animated.Value(0),
15
+ height: new _reactNative.Animated.Value(0)
16
+ },
17
+ reanimated: {
18
+ progress: {
19
+ value: 0
20
+ },
21
+ height: {
22
+ value: 0
23
+ }
24
+ }
25
+ };
26
+ const KeyboardContext = /*#__PURE__*/(0, _react.createContext)(defaultContext);
27
+ exports.KeyboardContext = KeyboardContext;
28
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["defaultContext","animated","progress","Animated","Value","height","reanimated","value","KeyboardContext","createContext"],"sources":["context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\n\nimport type { SharedValue } from 'react-native-reanimated';\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.Value;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n};\nconst defaultContext: KeyboardAnimationContext = {\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: { value: 0 },\n height: { value: 0 },\n },\n};\nexport const KeyboardContext = createContext(defaultContext);\n"],"mappings":";;;;;;;AAAA;;AACA;;AAgBA,MAAMA,cAAwC,GAAG;EAC/CC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIC,qBAAA,CAASC,KAAb,CAAmB,CAAnB,CADF;IAERC,MAAM,EAAE,IAAIF,qBAAA,CAASC,KAAb,CAAmB,CAAnB;EAFA,CADqC;EAK/CE,UAAU,EAAE;IACVJ,QAAQ,EAAE;MAAEK,KAAK,EAAE;IAAT,CADA;IAEVF,MAAM,EAAE;MAAEE,KAAK,EAAE;IAAT;EAFE;AALmC,CAAjD;AAUO,MAAMC,eAAe,gBAAG,IAAAC,oBAAA,EAAcT,cAAd,CAAxB"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useResizeMode = exports.useReanimatedKeyboardAnimation = exports.useKeyboardAnimation = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _context = require("./context");
11
+
12
+ var _native = require("./native");
13
+
14
+ const useResizeMode = () => {
15
+ (0, _react.useEffect)(() => {
16
+ _native.KeyboardController.setInputMode(_native.AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
17
+
18
+ return () => _native.KeyboardController.setDefaultMode();
19
+ }, []);
20
+ };
21
+
22
+ exports.useResizeMode = useResizeMode;
23
+
24
+ const useKeyboardAnimation = () => {
25
+ useResizeMode();
26
+ const context = (0, _react.useContext)(_context.KeyboardContext);
27
+ return context.animated;
28
+ };
29
+
30
+ exports.useKeyboardAnimation = useKeyboardAnimation;
31
+
32
+ const useReanimatedKeyboardAnimation = () => {
33
+ useResizeMode();
34
+ const context = (0, _react.useContext)(_context.KeyboardContext);
35
+ return context.reanimated;
36
+ };
37
+
38
+ exports.useReanimatedKeyboardAnimation = useReanimatedKeyboardAnimation;
39
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useResizeMode","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","useContext","KeyboardContext","animated","useReanimatedKeyboardAnimation","reanimated"],"sources":["hooks.ts"],"sourcesContent":["import { useContext, useEffect } from 'react';\n\nimport { AnimatedContext, KeyboardContext, ReanimatedContext } from './context';\nimport { AndroidSoftInputModes, KeyboardController } from './native';\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.reanimated;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEO,MAAMA,aAAa,GAAG,MAAM;EACjC,IAAAC,gBAAA,EAAU,MAAM;IACdC,0BAAA,CAAmBC,YAAnB,CACEC,6BAAA,CAAsBC,wBADxB;;IAIA,OAAO,MAAMH,0BAAA,CAAmBI,cAAnB,EAAb;EACD,CAND,EAMG,EANH;AAOD,CARM;;;;AAUA,MAAMC,oBAAoB,GAAG,MAAuB;EACzDP,aAAa;EACb,MAAMQ,OAAO,GAAG,IAAAC,iBAAA,EAAWC,wBAAX,CAAhB;EAEA,OAAOF,OAAO,CAACG,QAAf;AACD,CALM;;;;AAOA,MAAMC,8BAA8B,GAAG,MAAyB;EACrEZ,aAAa;EACb,MAAMQ,OAAO,GAAG,IAAAC,iBAAA,EAAWC,wBAAX,CAAhB;EAEA,OAAOF,OAAO,CAACK,UAAf;AACD,CALM"}
@@ -44,4 +44,43 @@ Object.keys(_replicas).forEach(function (key) {
44
44
  }
45
45
  });
46
46
  });
47
+
48
+ var _context = require("./context");
49
+
50
+ Object.keys(_context).forEach(function (key) {
51
+ if (key === "default" || key === "__esModule") return;
52
+ if (key in exports && exports[key] === _context[key]) return;
53
+ Object.defineProperty(exports, key, {
54
+ enumerable: true,
55
+ get: function () {
56
+ return _context[key];
57
+ }
58
+ });
59
+ });
60
+
61
+ var _hooks = require("./hooks");
62
+
63
+ Object.keys(_hooks).forEach(function (key) {
64
+ if (key === "default" || key === "__esModule") return;
65
+ if (key in exports && exports[key] === _hooks[key]) return;
66
+ Object.defineProperty(exports, key, {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _hooks[key];
70
+ }
71
+ });
72
+ });
73
+
74
+ var _types = require("./types");
75
+
76
+ Object.keys(_types).forEach(function (key) {
77
+ if (key === "default" || key === "__esModule") return;
78
+ if (key in exports && exports[key] === _types[key]) return;
79
+ Object.defineProperty(exports, key, {
80
+ enumerable: true,
81
+ get: function () {
82
+ return _types[key];
83
+ }
84
+ });
85
+ });
47
86
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './native';\nexport * from './animated';\nexport * from './replicas';\n"],"mappings":";;;;;;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './native';\nexport * from './animated';\nexport * from './replicas';\nexport * from './context';\nexport * from './hooks';\nexport * from './types';\n"],"mappings":";;;;;;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useAnimatedKeyboardHandler = useAnimatedKeyboardHandler;
7
+
8
+ var _reactNativeReanimated = require("react-native-reanimated");
9
+
10
+ function useAnimatedKeyboardHandler(handlers, dependencies) {
11
+ const {
12
+ context,
13
+ doDependenciesDiffer
14
+ } = (0, _reactNativeReanimated.useHandler)(handlers, dependencies);
15
+ return (0, _reactNativeReanimated.useEvent)(event => {
16
+ 'worklet';
17
+
18
+ const {
19
+ onKeyboardMove
20
+ } = handlers;
21
+
22
+ if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
23
+ onKeyboardMove(event, context);
24
+ }
25
+ }, ['onKeyboardMove'], doDependenciesDiffer);
26
+ }
27
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","useHandler","useEvent","event","onKeyboardMove","eventName","endsWith"],"sources":["internal.ts"],"sourcesContent":["import { useEvent, useHandler } from 'react-native-reanimated';\n\nimport type { EventWithName, NativeEvent } from './types';\n\nexport function useAnimatedKeyboardHandler<\n TContext extends Record<string, unknown>\n>(\n handlers: {\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: ReadonlyArray<unknown>\n) {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event: EventWithName<NativeEvent>) => {\n 'worklet';\n const { onKeyboardMove } = handlers;\n\n if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {\n onKeyboardMove(event, context);\n }\n },\n ['onKeyboardMove'],\n doDependenciesDiffer\n );\n}\n"],"mappings":";;;;;;;AAAA;;AAIO,SAASA,0BAAT,CAGLC,QAHK,EAMLC,YANK,EAOL;EACA,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAoC,IAAAC,iCAAA,EAAWJ,QAAX,EAAqBC,YAArB,CAA1C;EAEA,OAAO,IAAAI,+BAAA,EACJC,KAAD,IAAuC;IACrC;;IACA,MAAM;MAAEC;IAAF,IAAqBP,QAA3B;;IAEA,IAAIO,cAAc,IAAID,KAAK,CAACE,SAAN,CAAgBC,QAAhB,CAAyB,gBAAzB,CAAtB,EAAkE;MAChEF,cAAc,CAACD,KAAD,EAAQJ,OAAR,CAAd;IACD;EACF,CARI,EASL,CAAC,gBAAD,CATK,EAULC,oBAVK,CAAP;AAYD"}
@@ -10,10 +10,12 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
10
10
 
11
11
  // @ts-expect-error because there is no corresponding type definition
12
12
  const getConstants = NativeAndroidManager.default.getConstants;
13
- const RCTStatusBarManagerCompat = _reactNative.NativeModules.StatusBarManagerCompat; // On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
13
+
14
+ const RCTStatusBarManagerCompat = require('./specs/NativeStatusBarManagerCompat').default; // On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
14
15
  // in order to use library on all available platforms we have to monkey patch
15
16
  // default RN implementation and use modern `WindowInsetsControllerCompat`.
16
17
 
18
+
17
19
  if (_reactNative.Platform.OS === 'android') {
18
20
  NativeAndroidManager.default = {
19
21
  getConstants,