react-native-keyboard-controller 1.9.5 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +1 -1
  2. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +4 -0
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputTextChangedEvent.kt +20 -0
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +36 -0
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/WindowInsetsAnimationCompat.kt +7 -0
  6. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +17 -0
  7. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +12 -0
  8. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +2 -0
  9. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +13 -0
  10. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -0
  11. package/ios/.clang-format +30 -30
  12. package/ios/.swiftlint.yml +1 -1
  13. package/ios/KeyboardController.xcodeproj/project.pbxproj +10 -0
  14. package/ios/KeyboardControllerModule.mm +14 -0
  15. package/ios/events/FocusedInputTextChangedEvent.h +16 -0
  16. package/ios/events/FocusedInputTextChangedEvent.m +72 -0
  17. package/ios/observers/FocusedInputObserver.swift +29 -14
  18. package/ios/observers/TextChangeObserver.swift +41 -0
  19. package/ios/views/KeyboardControllerView.mm +53 -31
  20. package/ios/views/KeyboardControllerViewManager.mm +1 -0
  21. package/ios/views/KeyboardControllerViewManager.swift +21 -10
  22. package/jest/index.js +6 -4
  23. package/lib/commonjs/animated.js +33 -27
  24. package/lib/commonjs/animated.js.map +1 -1
  25. package/lib/commonjs/bindings.js +1 -0
  26. package/lib/commonjs/bindings.js.map +1 -1
  27. package/lib/commonjs/bindings.native.js +6 -6
  28. package/lib/commonjs/bindings.native.js.map +1 -1
  29. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +5 -3
  30. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
  31. package/lib/commonjs/components/KeyboardAvoidingView/index.js +17 -9
  32. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  33. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +199 -0
  34. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -0
  35. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +100 -0
  36. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  37. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js +28 -0
  38. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -0
  39. package/lib/commonjs/components/KeyboardStickyView/index.js +7 -4
  40. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  41. package/lib/commonjs/components/hooks/useKeyboardInterpolation.js +81 -0
  42. package/lib/commonjs/components/hooks/useKeyboardInterpolation.js.map +1 -0
  43. package/lib/commonjs/components/index.js +7 -0
  44. package/lib/commonjs/components/index.js.map +1 -1
  45. package/lib/commonjs/constants.js.map +1 -1
  46. package/lib/commonjs/context.js +2 -1
  47. package/lib/commonjs/context.js.map +1 -1
  48. package/lib/commonjs/hooks.js +17 -2
  49. package/lib/commonjs/hooks.js.map +1 -1
  50. package/lib/commonjs/index.js +8 -1
  51. package/lib/commonjs/index.js.map +1 -1
  52. package/lib/commonjs/internal.js +3 -6
  53. package/lib/commonjs/internal.js.map +1 -1
  54. package/lib/commonjs/monkey-patch.android.js +1 -1
  55. package/lib/commonjs/monkey-patch.android.js.map +1 -1
  56. package/lib/commonjs/monkey-patch.js.map +1 -1
  57. package/lib/commonjs/reanimated.js +5 -3
  58. package/lib/commonjs/reanimated.js.map +1 -1
  59. package/lib/commonjs/reanimated.native.js +29 -12
  60. package/lib/commonjs/reanimated.native.js.map +1 -1
  61. package/lib/commonjs/replicas.js +7 -5
  62. package/lib/commonjs/replicas.js.map +1 -1
  63. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +1 -1
  64. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  65. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +2 -2
  66. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  67. package/lib/commonjs/specs/NativeKeyboardController.js +1 -1
  68. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
  69. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +1 -1
  70. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -1
  71. package/lib/commonjs/types.js.map +1 -1
  72. package/lib/commonjs/utils.js.map +1 -1
  73. package/lib/module/animated.js +41 -35
  74. package/lib/module/animated.js.map +1 -1
  75. package/lib/module/bindings.js +2 -1
  76. package/lib/module/bindings.js.map +1 -1
  77. package/lib/module/bindings.native.js +7 -7
  78. package/lib/module/bindings.native.js.map +1 -1
  79. package/lib/module/components/KeyboardAvoidingView/hooks.js +7 -5
  80. package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
  81. package/lib/module/components/KeyboardAvoidingView/index.js +20 -13
  82. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  83. package/lib/module/components/KeyboardAwareScrollView/index.js +190 -0
  84. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -0
  85. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +93 -0
  86. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  87. package/lib/module/components/KeyboardAwareScrollView/utils.js +21 -0
  88. package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -0
  89. package/lib/module/components/KeyboardStickyView/index.js +9 -7
  90. package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
  91. package/lib/module/components/hooks/useKeyboardInterpolation.js +74 -0
  92. package/lib/module/components/hooks/useKeyboardInterpolation.js.map +1 -0
  93. package/lib/module/components/index.js +3 -2
  94. package/lib/module/components/index.js.map +1 -1
  95. package/lib/module/context.js +4 -3
  96. package/lib/module/context.js.map +1 -1
  97. package/lib/module/hooks.js +21 -7
  98. package/lib/module/hooks.js.map +1 -1
  99. package/lib/module/index.js +8 -8
  100. package/lib/module/index.js.map +1 -1
  101. package/lib/module/internal.js +6 -9
  102. package/lib/module/internal.js.map +1 -1
  103. package/lib/module/monkey-patch.android.js +2 -2
  104. package/lib/module/monkey-patch.android.js.map +1 -1
  105. package/lib/module/monkey-patch.js.map +1 -1
  106. package/lib/module/reanimated.js +2 -1
  107. package/lib/module/reanimated.js.map +1 -1
  108. package/lib/module/reanimated.native.js +27 -11
  109. package/lib/module/reanimated.native.js.map +1 -1
  110. package/lib/module/replicas.js +13 -11
  111. package/lib/module/replicas.js.map +1 -1
  112. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +2 -2
  113. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  114. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +3 -3
  115. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  116. package/lib/module/specs/NativeKeyboardController.js +2 -2
  117. package/lib/module/specs/NativeKeyboardController.js.map +1 -1
  118. package/lib/module/specs/NativeStatusBarManagerCompat.js +2 -2
  119. package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -1
  120. package/lib/module/types.js.map +1 -1
  121. package/lib/module/utils.js.map +1 -1
  122. package/lib/typescript/animated.d.ts +1 -1
  123. package/lib/typescript/bindings.d.ts +1 -1
  124. package/lib/typescript/bindings.native.d.ts +1 -1
  125. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +4 -4
  126. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +45 -0
  127. package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +6 -0
  128. package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +1 -0
  129. package/lib/typescript/components/KeyboardStickyView/index.d.ts +2 -2
  130. package/lib/typescript/components/hooks/useKeyboardInterpolation.d.ts +20 -0
  131. package/lib/typescript/components/index.d.ts +3 -2
  132. package/lib/typescript/context.d.ts +6 -5
  133. package/lib/typescript/hooks.d.ts +4 -3
  134. package/lib/typescript/index.d.ts +8 -8
  135. package/lib/typescript/internal.d.ts +9 -6
  136. package/lib/typescript/reanimated.d.ts +3 -2
  137. package/lib/typescript/reanimated.native.d.ts +3 -2
  138. package/lib/typescript/replicas.d.ts +1 -1
  139. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +7 -3
  140. package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +4 -4
  141. package/lib/typescript/specs/NativeKeyboardController.d.ts +2 -1
  142. package/lib/typescript/specs/NativeStatusBarManagerCompat.d.ts +1 -1
  143. package/lib/typescript/types.d.ts +18 -5
  144. package/package.json +12 -11
  145. package/react-native-keyboard-controller.podspec +1 -1
  146. package/src/animated.tsx +59 -42
  147. package/src/bindings.native.ts +11 -11
  148. package/src/bindings.ts +4 -3
  149. package/src/components/KeyboardAvoidingView/hooks.ts +9 -6
  150. package/src/components/KeyboardAvoidingView/index.tsx +30 -27
  151. package/src/components/KeyboardAwareScrollView/index.tsx +262 -0
  152. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +123 -0
  153. package/src/components/KeyboardAwareScrollView/utils.ts +26 -0
  154. package/src/components/KeyboardStickyView/index.tsx +12 -18
  155. package/src/components/hooks/useKeyboardInterpolation.ts +96 -0
  156. package/src/components/index.ts +3 -2
  157. package/src/context.ts +15 -9
  158. package/src/hooks.ts +30 -13
  159. package/src/index.ts +12 -8
  160. package/src/internal.ts +22 -13
  161. package/src/monkey-patch.android.ts +2 -2
  162. package/src/reanimated.native.ts +43 -18
  163. package/src/reanimated.ts +9 -3
  164. package/src/replicas.ts +18 -17
  165. package/src/specs/KeyboardControllerViewNativeComponent.ts +12 -5
  166. package/src/specs/KeyboardGestureAreaNativeComponent.ts +7 -7
  167. package/src/specs/NativeKeyboardController.ts +4 -3
  168. package/src/specs/NativeStatusBarManagerCompat.ts +3 -3
  169. package/src/types.ts +45 -19
@@ -10,6 +10,7 @@
10
10
  #ifdef RCT_NEW_ARCH_ENABLED
11
11
  #import "KeyboardControllerView.h"
12
12
  #import "FocusedInputLayoutChangedEvent.h"
13
+ #import "FocusedInputTextChangedEvent.h"
13
14
  #import "KeyboardMoveEvent.h"
14
15
  #import "react_native_keyboard_controller-Swift.h"
15
16
 
@@ -45,38 +46,59 @@ using namespace facebook::react;
45
46
  static const auto defaultProps = std::make_shared<const KeyboardControllerViewProps>();
46
47
  _props = defaultProps;
47
48
 
48
- inputObserver = [[FocusedInputObserver alloc] initWithHandler:^(NSDictionary *event) {
49
- if (self->_eventEmitter) {
50
- int target = [event[@"target"] integerValue];
51
- double absoluteY = [event[@"layout"][@"absoluteY"] doubleValue];
52
- double absoulteX = [event[@"layout"][@"absoluteX"] doubleValue];
53
- double y = [event[@"layout"][@"y"] doubleValue];
54
- double x = [event[@"layout"][@"x"] doubleValue];
55
- double width = [event[@"layout"][@"width"] doubleValue];
56
- double height = [event[@"layout"][@"height"] doubleValue];
57
-
58
- std::dynamic_pointer_cast<const facebook::react::KeyboardControllerViewEventEmitter>(
59
- self->_eventEmitter)
60
- ->onFocusedInputLayoutChanged(
61
- facebook::react::KeyboardControllerViewEventEmitter::OnFocusedInputLayoutChanged{
62
- .target = target,
63
- .layout = facebook::react::KeyboardControllerViewEventEmitter::
64
- OnFocusedInputLayoutChangedLayout{
65
- .absoluteY = absoluteY,
66
- .absoluteX = absoulteX,
67
- .height = height,
68
- .width = width,
69
- .x = x,
70
- .y = y}});
71
- // TODO: use built-in _eventEmitter once NativeAnimated module will use ModernEventemitter
72
- RCTBridge *bridge = [RCTBridge currentBridge];
73
- if (bridge && [bridge valueForKey:@"_jsThread"]) {
74
- FocusedInputLayoutChangedEvent *inputChangedEvent =
75
- [[FocusedInputLayoutChangedEvent alloc] initWithReactTag:@(self.tag) event:event];
76
- [bridge.eventDispatcher sendEvent:inputChangedEvent];
49
+ inputObserver = [[FocusedInputObserver alloc]
50
+ initOnLayoutChangedHandler:^(NSDictionary *event) {
51
+ if (self->_eventEmitter) {
52
+ int target = [event[@"target"] integerValue];
53
+ double absoluteY = [event[@"layout"][@"absoluteY"] doubleValue];
54
+ double absoulteX = [event[@"layout"][@"absoluteX"] doubleValue];
55
+ double y = [event[@"layout"][@"y"] doubleValue];
56
+ double x = [event[@"layout"][@"x"] doubleValue];
57
+ double width = [event[@"layout"][@"width"] doubleValue];
58
+ double height = [event[@"layout"][@"height"] doubleValue];
59
+
60
+ std::dynamic_pointer_cast<const facebook::react::KeyboardControllerViewEventEmitter>(
61
+ self->_eventEmitter)
62
+ ->onFocusedInputLayoutChanged(
63
+ facebook::react::KeyboardControllerViewEventEmitter::
64
+ OnFocusedInputLayoutChanged{
65
+ .target = target,
66
+ .layout = facebook::react::KeyboardControllerViewEventEmitter::
67
+ OnFocusedInputLayoutChangedLayout{
68
+ .absoluteY = absoluteY,
69
+ .absoluteX = absoulteX,
70
+ .height = height,
71
+ .width = width,
72
+ .x = x,
73
+ .y = y}});
74
+ // TODO: use built-in _eventEmitter once NativeAnimated module will use
75
+ // ModernEventemitter
76
+ RCTBridge *bridge = [RCTBridge currentBridge];
77
+ if (bridge && [bridge valueForKey:@"_jsThread"]) {
78
+ FocusedInputLayoutChangedEvent *inputChangedEvent =
79
+ [[FocusedInputLayoutChangedEvent alloc] initWithReactTag:@(self.tag) event:event];
80
+ [bridge.eventDispatcher sendEvent:inputChangedEvent];
81
+ }
82
+ }
77
83
  }
78
- }
79
- }];
84
+ onTextChangedHandler:^(NSString *text) {
85
+ if (self->_eventEmitter) {
86
+ std::dynamic_pointer_cast<const facebook::react::KeyboardControllerViewEventEmitter>(
87
+ self->_eventEmitter)
88
+ ->onFocusedInputTextChanged(
89
+ facebook::react::KeyboardControllerViewEventEmitter::OnFocusedInputTextChanged{
90
+ .text = std::string([text UTF8String])});
91
+
92
+ // TODO: use built-in _eventEmitter once NativeAnimated module will use
93
+ // ModernEventemitter
94
+ RCTBridge *bridge = [RCTBridge currentBridge];
95
+ if (bridge && [bridge valueForKey:@"_jsThread"]) {
96
+ FocusedInputTextChangedEvent *textChangedEvent =
97
+ [[FocusedInputTextChangedEvent alloc] initWithReactTag:@(self.tag) text:text];
98
+ [bridge.eventDispatcher sendEvent:textChangedEvent];
99
+ }
100
+ }
101
+ }];
80
102
  keyboardObserver = [[KeyboardMovementObserver alloc]
81
103
  initWithHandler:^(
82
104
  NSString *event,
@@ -13,5 +13,6 @@ RCT_EXPORT_VIEW_PROPERTY(onKeyboardMoveEnd, RCTDirectEventBlock);
13
13
  RCT_EXPORT_VIEW_PROPERTY(onKeyboardMoveInteractive, RCTDirectEventBlock);
14
14
  /// input callbacks
15
15
  RCT_EXPORT_VIEW_PROPERTY(onFocusedInputLayoutChanged, RCTDirectEventBlock);
16
+ RCT_EXPORT_VIEW_PROPERTY(onFocusedInputTextChanged, RCTDirectEventBlock);
16
17
 
17
18
  @end
@@ -16,10 +16,14 @@ class KeyboardControllerView: UIView {
16
16
  private var eventDispatcher: RCTEventDispatcherProtocol
17
17
  private var bridge: RCTBridge
18
18
  // react callbacks
19
+ /// keyboard
19
20
  @objc var onKeyboardMoveStart: RCTDirectEventBlock?
20
21
  @objc var onKeyboardMove: RCTDirectEventBlock?
21
22
  @objc var onKeyboardMoveEnd: RCTDirectEventBlock?
22
23
  @objc var onKeyboardMoveInteractive: RCTDirectEventBlock?
24
+ /// focused input
25
+ @objc var onFocusedInputLayoutChanged: RCTDirectEventBlock?
26
+ @objc var onFocusedInputTextChanged: RCTDirectEventBlock?
23
27
  // react props
24
28
  @objc var enabled: ObjCBool = true {
25
29
  didSet {
@@ -35,7 +39,7 @@ class KeyboardControllerView: UIView {
35
39
  self.bridge = bridge
36
40
  eventDispatcher = bridge.eventDispatcher()
37
41
  super.init(frame: frame)
38
- inputObserver = FocusedInputObserver(handler: onInput)
42
+ inputObserver = FocusedInputObserver(onLayoutChangedHandler: onLayoutChanged, onTextChangedHandler: onTextChanged)
39
43
  keyboardObserver = KeyboardMovementObserver(handler: onEvent, onNotify: onNotify)
40
44
  }
41
45
 
@@ -58,19 +62,21 @@ class KeyboardControllerView: UIView {
58
62
  }
59
63
  }
60
64
 
61
- func onInput(event: NSObject) {
62
- // we don't want to send event to JS before the JS thread is ready
63
- if bridge.value(forKey: "_jsThread") == nil {
64
- return
65
- }
65
+ func onLayoutChanged(event: NSObject) {
66
+ guard isJSThreadReady() else { return }
67
+
66
68
  eventDispatcher.send(FocusedInputLayoutChangedEvent(reactTag: reactTag, event: event))
67
69
  }
68
70
 
71
+ func onTextChanged(text: String) {
72
+ guard isJSThreadReady() else { return }
73
+
74
+ eventDispatcher.send(FocusedInputTextChangedEvent(reactTag: reactTag, text: text))
75
+ }
76
+
69
77
  func onEvent(event: NSString, height: NSNumber, progress: NSNumber, duration: NSNumber, target: NSNumber) {
70
- // we don't want to send event to JS before the JS thread is ready
71
- if bridge.value(forKey: "_jsThread") == nil {
72
- return
73
- }
78
+ guard isJSThreadReady() else { return }
79
+
74
80
  eventDispatcher.send(
75
81
  KeyboardMoveEvent(
76
82
  reactTag: reactTag,
@@ -96,4 +102,9 @@ class KeyboardControllerView: UIView {
96
102
  inputObserver?.unmount()
97
103
  keyboardObserver?.unmount()
98
104
  }
105
+
106
+ private func isJSThreadReady() -> Bool {
107
+ // we don't want to send event to JS before the JS thread is ready
108
+ return bridge.value(forKey: "_jsThread") != nil
109
+ }
99
110
  }
package/jest/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Animated } from 'react-native';
1
+ import { Animated } from "react-native";
2
2
 
3
3
  const values = {
4
4
  animated: {
@@ -34,19 +34,21 @@ const mock = {
34
34
  useGenericKeyboardHandler: jest.fn(),
35
35
  useKeyboardHandler: jest.fn(),
36
36
  useReanimatedFocusedInput: jest.fn().mockReturnValue(focusedInput),
37
+ useFocusedInputHandler: jest.fn(),
37
38
  // modules
38
39
  KeyboardController: {
39
40
  setInputMode: jest.fn(),
40
41
  setDefaultMode: jest.fn(),
42
+ dismiss: jest.fn(),
41
43
  },
42
44
  KeyboardEvents: {
43
45
  addListener: jest.fn(() => ({ remove: jest.fn() })),
44
46
  },
45
47
  // views
46
- KeyboardControllerView: 'KeyboardControllerView',
47
- KeyboardGestureArea: 'KeyboardGestureArea',
48
+ KeyboardControllerView: "KeyboardControllerView",
49
+ KeyboardGestureArea: "KeyboardGestureArea",
48
50
  // providers
49
- KeyboardProvider: 'KeyboardProvider',
51
+ KeyboardProvider: "KeyboardProvider",
50
52
  };
51
53
 
52
54
  module.exports = mock;
@@ -20,8 +20,8 @@ const styles = _reactNative.StyleSheet.create({
20
20
  flex: 1
21
21
  },
22
22
  hidden: {
23
- display: 'none',
24
- position: 'absolute'
23
+ display: "none",
24
+ position: "absolute"
25
25
  }
26
26
  });
27
27
  const KeyboardProvider = _ref => {
@@ -31,6 +31,7 @@ const KeyboardProvider = _ref => {
31
31
  navigationBarTranslucent,
32
32
  enabled: initiallyEnabled = true
33
33
  } = _ref;
34
+ // state
34
35
  const [enabled, setEnabled] = (0, _react.useState)(initiallyEnabled);
35
36
  // animated values
36
37
  const progress = (0, _internal.useAnimatedValue)(0);
@@ -39,10 +40,8 @@ const KeyboardProvider = _ref => {
39
40
  const progressSV = (0, _reactNativeReanimated.useSharedValue)(0);
40
41
  const heightSV = (0, _reactNativeReanimated.useSharedValue)(0);
41
42
  const layout = (0, _reactNativeReanimated.useSharedValue)(null);
42
- const {
43
- setHandlers,
44
- broadcast
45
- } = (0, _internal.useSharedHandlers)();
43
+ const [setKeyboardHandlers, broadcastKeyboardEvents] = (0, _internal.useSharedHandlers)();
44
+ const [setInputHandlers, broadcastInputEvents] = (0, _internal.useSharedHandlers)();
46
45
  // memo
47
46
  const context = (0, _react.useMemo)(() => ({
48
47
  enabled,
@@ -55,7 +54,8 @@ const KeyboardProvider = _ref => {
55
54
  height: heightSV
56
55
  },
57
56
  layout,
58
- setHandlers,
57
+ setKeyboardHandlers,
58
+ setInputHandlers,
59
59
  setEnabled
60
60
  }), [enabled]);
61
61
  const style = (0, _react.useMemo)(() => [styles.hidden, {
@@ -75,7 +75,7 @@ const KeyboardProvider = _ref => {
75
75
  }), []);
76
76
  // handlers
77
77
  const updateSharedValues = (event, platforms) => {
78
- 'worklet';
78
+ "worklet";
79
79
 
80
80
  if (platforms.includes(_reactNative.Platform.OS)) {
81
81
  progressSV.value = event.progress;
@@ -84,32 +84,32 @@ const KeyboardProvider = _ref => {
84
84
  };
85
85
  const keyboardHandler = (0, _reanimated.useAnimatedKeyboardHandler)({
86
86
  onKeyboardMoveStart: event => {
87
- 'worklet';
87
+ "worklet";
88
88
 
89
- broadcast('onStart', event);
90
- updateSharedValues(event, ['ios']);
89
+ broadcastKeyboardEvents("onStart", event);
90
+ updateSharedValues(event, ["ios"]);
91
91
  },
92
92
  onKeyboardMove: event => {
93
- 'worklet';
93
+ "worklet";
94
94
 
95
- broadcast('onMove', event);
96
- updateSharedValues(event, ['android']);
95
+ broadcastKeyboardEvents("onMove", event);
96
+ updateSharedValues(event, ["android"]);
97
97
  },
98
98
  onKeyboardMoveEnd: event => {
99
- 'worklet';
99
+ "worklet";
100
100
 
101
- broadcast('onEnd', event);
101
+ broadcastKeyboardEvents("onEnd", event);
102
102
  },
103
103
  onKeyboardMoveInteractive: event => {
104
- 'worklet';
104
+ "worklet";
105
105
 
106
- updateSharedValues(event, ['android', 'ios']);
107
- broadcast('onInteractive', event);
106
+ updateSharedValues(event, ["android", "ios"]);
107
+ broadcastKeyboardEvents("onInteractive", event);
108
108
  }
109
109
  }, []);
110
- const inputHandler = (0, _reanimated.useFocusedInputHandler)({
110
+ const inputLayoutHandler = (0, _reanimated.useFocusedInputLayoutHandler)({
111
111
  onFocusedInputLayoutChanged: e => {
112
- 'worklet';
112
+ "worklet";
113
113
 
114
114
  if (e.target !== -1) {
115
115
  layout.value = e;
@@ -118,6 +118,13 @@ const KeyboardProvider = _ref => {
118
118
  }
119
119
  }
120
120
  }, []);
121
+ const inputTextHandler = (0, _reanimated.useFocusedInputTextHandler)({
122
+ onFocusedInputTextChanged: e => {
123
+ "worklet";
124
+
125
+ broadcastInputEvents("onChangeText", e);
126
+ }
127
+ }, []);
121
128
  // effects
122
129
  (0, _react.useEffect)(() => {
123
130
  if (enabled) {
@@ -131,14 +138,13 @@ const KeyboardProvider = _ref => {
131
138
  }, /*#__PURE__*/_react.default.createElement(KeyboardControllerViewAnimated, {
132
139
  enabled: enabled,
133
140
  onKeyboardMoveReanimated: keyboardHandler,
134
- onKeyboardMoveStart: _reactNative.Platform.OS === 'ios' ? onKeyboardMove : undefined,
135
- onKeyboardMove: _reactNative.Platform.OS === 'android' ? onKeyboardMove : undefined,
141
+ onKeyboardMoveStart: _reactNative.Platform.OS === "ios" ? onKeyboardMove : undefined,
142
+ onKeyboardMove: _reactNative.Platform.OS === "android" ? onKeyboardMove : undefined,
136
143
  onKeyboardMoveInteractive: onKeyboardMove,
137
- onFocusedInputLayoutChangedReanimated: inputHandler,
144
+ onFocusedInputLayoutChangedReanimated: inputLayoutHandler,
145
+ onFocusedInputTextChangedReanimated: inputTextHandler,
138
146
  navigationBarTranslucent: navigationBarTranslucent,
139
- statusBarTranslucent: statusBarTranslucent
140
- // @ts-expect-error https://github.com/software-mansion/react-native-reanimated/pull/4923
141
- ,
147
+ statusBarTranslucent: statusBarTranslucent,
142
148
  style: styles.container
143
149
  }, children), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
144
150
  // we are using this small hack, because if the component (where
@@ -1 +1 @@
1
- {"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setHandlers","broadcast","useSharedHandlers","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","Platform","OS","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","inputHandler","useFocusedInputHandler","onFocusedInputLayoutChanged","e","target","useEffect","applyMonkeyPatch","revertMonkeyPatch","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport { Animated, Platform, StyleSheet } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardControllerView } from './bindings';\nimport { KeyboardContext } from './context';\nimport { useAnimatedValue, useSharedHandlers } from './internal';\nimport { applyMonkeyPatch, revertMonkeyPatch } from './monkey-patch';\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputHandler,\n} from './reanimated';\n\nimport type { KeyboardAnimationContext } from './context';\nimport type {\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\nimport type { ViewStyle } from 'react-native';\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\nconst 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 * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n * @platform android\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state,\n * i. e. if you try to change this prop after component mount it will not have any effect.\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const { setHandlers, broadcast } = useSharedHandlers<KeyboardHandler>();\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setHandlers,\n setEnabled,\n }),\n [enabled]\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 updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n 'worklet';\n\n if (platforms.includes(Platform.OS)) {\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onStart', event);\n updateSharedValues(event, ['ios']);\n },\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onMove', event);\n updateSharedValues(event, ['android']);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onEnd', event);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n 'worklet';\n\n updateSharedValues(event, ['android', 'ios']);\n broadcast('onInteractive', event);\n },\n },\n []\n );\n const inputHandler = useFocusedInputHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n 'worklet';\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n []\n );\n // effects\n useEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n enabled={enabled}\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputHandler}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n // @ts-expect-error https://github.com/software-mansion/react-native-reanimated/pull/4923\n style={styles.container}\n >\n {children}\n </KeyboardControllerViewAnimated>\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 </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAGsB;AAAA;AAWtB,MAAMA,8BAA8B,GAAGC,8BAAU,CAACC,uBAAuB,CACvEC,qBAAQ,CAACD,uBAAuB,CAC9BE,gCAAsB,CACvB,CACF;AAOD,MAAMC,MAAM,GAAGC,uBAAU,CAACC,MAAM,CAA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CACH;EACD,MAAMc,YAAY,GAAG,IAAAC,kCAAsB,EACzC;IACEC,2BAA2B,EAAGC,CAAC,IAAK;MAClC,SAAS;;MAET,IAAIA,CAAC,CAACC,MAAM,KAAK,CAAC,CAAC,EAAE;QACnBhC,MAAM,CAACsB,KAAK,GAAGS,CAAC;MAClB,CAAC,MAAM;QACL/B,MAAM,CAACsB,KAAK,GAAG,IAAI;MACrB;IACF;EACF,CAAC,EACD,EAAE,CACH;EACD;EACA,IAAAW,gBAAS,EAAC,MAAM;IACd,IAAI3C,OAAO,EAAE;MACX,IAAA4C,6BAAgB,GAAE;IACpB,CAAC,MAAM;MACL,IAAAC,8BAAiB,GAAE;IACrB;EACF,CAAC,EAAE,CAAC7C,OAAO,CAAC,CAAC;EAEb,oBACE,6BAAC,wBAAe,CAAC,QAAQ;IAAC,KAAK,EAAEc;EAAQ,gBACvC,6BAAC,8BAA8B;IAC7B,OAAO,EAAEd,OAAQ;IACjB,wBAAwB,EAAEiC,eAAgB;IAC1C,mBAAmB,EAAEH,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAGR,cAAc,GAAGuB,SAAU;IACxE,cAAc,EAAEhB,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAGR,cAAc,GAAGuB,SAAU;IACvE,yBAAyB,EAAEvB,cAAe;IAC1C,qCAAqC,EAAEe,YAAa;IACpD,wBAAwB,EAAEvC,wBAAyB;IACnD,oBAAoB,EAAED;IACtB;IAAA;IACA,KAAK,EAAEV,MAAM,CAACG;EAAU,GAEvBM,QAAQ,CACsB,eACjC,6BAAC,qBAAQ,CAAC,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEsB;EAAM,EACb,CACuB;AAE/B,CAAC;AAAC"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_bindings","_context","_internal","_monkeyPatch","_reanimated","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","_ref","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","broadcastKeyboardEvents","useSharedHandlers","setInputHandlers","broadcastInputEvents","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","Platform","OS","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","e","target","inputTextHandler","useFocusedInputTextHandler","onFocusedInputTextChanged","useEffect","applyMonkeyPatch","revertMonkeyPatch","createElement","KeyboardContext","Provider","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","onFocusedInputTextChangedReanimated","View","exports"],"sources":["animated.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from \"react\";\nimport { Animated, Platform, StyleSheet } from \"react-native\";\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\n\nimport { KeyboardControllerView } from \"./bindings\";\nimport { KeyboardContext } from \"./context\";\nimport { useAnimatedValue, useSharedHandlers } from \"./internal\";\nimport { applyMonkeyPatch, revertMonkeyPatch } from \"./monkey-patch\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\n useFocusedInputTextHandler,\n} from \"./reanimated\";\n\nimport type { KeyboardAnimationContext } from \"./context\";\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from \"./types\";\nimport type { ViewStyle } from \"react-native\";\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\nconst 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 * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n * @platform android\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state,\n * i. e. if you try to change this prop after component mount it will not have any effect.\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const [setKeyboardHandlers, broadcastKeyboardEvents] =\n useSharedHandlers<KeyboardHandler>();\n const [setInputHandlers, broadcastInputEvents] =\n useSharedHandlers<FocusedInputHandler>();\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled],\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 updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n \"worklet\";\n\n if (platforms.includes(Platform.OS)) {\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n \"worklet\";\n\n broadcastKeyboardEvents(\"onStart\", event);\n updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n broadcastKeyboardEvents(\"onMove\", event);\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n \"worklet\";\n\n broadcastKeyboardEvents(\"onEnd\", event);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\n broadcastKeyboardEvents(\"onInteractive\", event);\n },\n },\n [],\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n \"worklet\";\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n [],\n );\n const inputTextHandler = useFocusedInputTextHandler(\n {\n onFocusedInputTextChanged: (e) => {\n \"worklet\";\n\n broadcastInputEvents(\"onChangeText\", e);\n },\n },\n [],\n );\n // effects\n useEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n enabled={enabled}\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={Platform.OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n onFocusedInputTextChangedReanimated={inputTextHandler}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n >\n {children}\n </KeyboardControllerViewAnimated>\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 </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAIsB,SAAAQ,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAV,wBAAAc,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CA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CAAC;AAACsC,OAAA,CAAAhE,gBAAA,GAAAA,gBAAA"}
@@ -9,6 +9,7 @@ const NOOP = () => {};
9
9
  const KeyboardController = {
10
10
  setDefaultMode: NOOP,
11
11
  setInputMode: NOOP,
12
+ dismiss: NOOP,
12
13
  addListener: NOOP,
13
14
  removeListeners: NOOP
14
15
  };
@@ -1 +1 @@
1
- {"version":3,"names":["NOOP","KeyboardController","setDefaultMode","setInputMode","addListener","removeListeners","KeyboardEvents","remove","KeyboardControllerView","View","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { View } from 'react-native';\n\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from './types';\nimport type { EmitterSubscription } from 'react-native';\n\nconst NOOP = () => {};\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\n"],"mappings":";;;;;;AAAA;AAUA,MAAMA,IAAI,GAAG,MAAM,CAAC,CAAC;AACd,MAAMC,kBAA4C,GAAG;EAC1DC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,WAAW,EAAEJ,IAAI;EACjBK,eAAe,EAAEL;AACnB,CAAC;AAAC;AACK,MAAMM,cAAoC,GAAG;EAClDF,WAAW,EAAE,OAAO;IAAEG,MAAM,EAAEP;EAAK,CAAC;AACtC,CAAC;AAAC;AACK,MAAMQ,sBAAsB,GACjCC,iBAAoD;AAAC;AAChD,MAAMC,mBAAmB,GAC9BD,iBAAqD;AAAC"}
1
+ {"version":3,"names":["_reactNative","require","NOOP","KeyboardController","setDefaultMode","setInputMode","dismiss","addListener","removeListeners","exports","KeyboardEvents","remove","KeyboardControllerView","View","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from \"./types\";\nimport type { EmitterSubscription } from \"react-native\";\n\nconst NOOP = () => {};\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n dismiss: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAUA,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACd,MAAMC,kBAA4C,GAAG;EAC1DC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,OAAO,EAAEJ,IAAI;EACbK,WAAW,EAAEL,IAAI;EACjBM,eAAe,EAAEN;AACnB,CAAC;AAACO,OAAA,CAAAN,kBAAA,GAAAA,kBAAA;AACK,MAAMO,cAAoC,GAAG;EAClDH,WAAW,EAAEA,CAAA,MAAO;IAAEI,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AAACO,OAAA,CAAAC,cAAA,GAAAA,cAAA;AACK,MAAME,sBAAsB,GACjCC,iBAAoD;AAACJ,OAAA,CAAAG,sBAAA,GAAAA,sBAAA;AAChD,MAAME,mBAAmB,GAC9BD,iBAAqD;AAACJ,OAAA,CAAAK,mBAAA,GAAAA,mBAAA"}
@@ -7,9 +7,9 @@ exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControlle
7
7
  var _reactNative = require("react-native");
8
8
  const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
9
9
  ios: "- You have run 'pod install'\n",
10
- default: ''
11
- }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
12
- const RCTKeyboardController = require('./specs/NativeKeyboardController').default;
10
+ default: ""
11
+ }) + "- You rebuilt the app after installing the package\n" + "- You are not using Expo Go\n";
12
+ const RCTKeyboardController = require("./specs/NativeKeyboardController").default;
13
13
  const KeyboardController = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
14
14
  get() {
15
15
  throw new Error(LINKING_ERROR);
@@ -18,12 +18,12 @@ const KeyboardController = RCTKeyboardController ? RCTKeyboardController : new P
18
18
  exports.KeyboardController = KeyboardController;
19
19
  const eventEmitter = new _reactNative.NativeEventEmitter(KeyboardController);
20
20
  const KeyboardEvents = {
21
- addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
21
+ addListener: (name, cb) => eventEmitter.addListener("KeyboardController::" + name, cb)
22
22
  };
23
23
  exports.KeyboardEvents = KeyboardEvents;
24
- const KeyboardControllerView = require('./specs/KeyboardControllerViewNativeComponent').default;
24
+ const KeyboardControllerView = require("./specs/KeyboardControllerViewNativeComponent").default;
25
25
  exports.KeyboardControllerView = KeyboardControllerView;
26
- const KeyboardGestureArea = _reactNative.Platform.OS === 'android' && _reactNative.Platform.Version >= 30 ? require('./specs/KeyboardGestureAreaNativeComponent').default : _ref => {
26
+ const KeyboardGestureArea = _reactNative.Platform.OS === "android" && _reactNative.Platform.Version >= 30 ? require("./specs/KeyboardGestureAreaNativeComponent").default : _ref => {
27
27
  let {
28
28
  children
29
29
  } = _ref;
@@ -1 +1 @@
1
- {"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","RCTKeyboardController","require","KeyboardController","Proxy","get","Error","eventEmitter","NativeEventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView","KeyboardGestureArea","OS","Version","children"],"sources":["bindings.native.ts"],"sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from './types';\n\nconst LINKING_ERROR =\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\nconst RCTKeyboardController =\n require('./specs/NativeKeyboardController').default;\nexport const KeyboardController = (\n RCTKeyboardController\n ? RCTKeyboardController\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n )\n) as KeyboardControllerModule;\n\nconst eventEmitter = new NativeEventEmitter(KeyboardController);\n\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener('KeyboardController::' + name, cb),\n};\nexport const KeyboardControllerView: React.FC<KeyboardControllerProps> =\n require('./specs/KeyboardControllerViewNativeComponent').default;\nexport const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =\n Platform.OS === 'android' && Platform.Version >= 30\n ? require('./specs/KeyboardGestureAreaNativeComponent').default\n : ({ children }: KeyboardGestureAreaProps) => children;\n"],"mappings":";;;;;;AAAA;AASA,MAAMA,aAAa,GAChB,2FAA0F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,qBAAqB,GACzBC,OAAO,CAAC,kCAAkC,CAAC,CAACF,OAAO;AAC9C,MAAMG,kBAAkB,GAC7BF,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CAAC,CAEoB;AAAC;AAE9B,MAAMW,YAAY,GAAG,IAAIC,+BAAkB,CAACL,kBAAkB,CAAC;AAExD,MAAMM,cAAoC,GAAG;EAClDC,WAAW,EAAE,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAAC,sBAAsB,GAAGC,IAAI,EAAEC,EAAE;AAC9D,CAAC;AAAC;AACK,MAAMC,sBAAyD,GACpEX,OAAO,CAAC,+CAA+C,CAAC,CAACF,OAAO;AAAC;AAC5D,MAAMc,mBAAuD,GAClEjB,qBAAQ,CAACkB,EAAE,KAAK,SAAS,IAAIlB,qBAAQ,CAACmB,OAAO,IAAI,EAAE,GAC/Cd,OAAO,CAAC,4CAA4C,CAAC,CAACF,OAAO,GAC7D;EAAA,IAAC;IAAEiB;EAAmC,CAAC;EAAA,OAAKA,QAAQ;AAAA;AAAC"}
1
+ {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","RCTKeyboardController","KeyboardController","Proxy","get","Error","exports","eventEmitter","NativeEventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView","KeyboardGestureArea","OS","Version","_ref","children"],"sources":["bindings.native.ts"],"sourcesContent":["import { NativeEventEmitter, Platform } from \"react-native\";\n\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from \"./types\";\n\nconst LINKING_ERROR =\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: \"\" }) +\n \"- You rebuilt the app after installing the package\\n\" +\n \"- You are not using Expo Go\\n\";\n\nconst RCTKeyboardController =\n require(\"./specs/NativeKeyboardController\").default;\nexport const KeyboardController = (\n RCTKeyboardController\n ? RCTKeyboardController\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n },\n )\n) as KeyboardControllerModule;\n\nconst eventEmitter = new NativeEventEmitter(KeyboardController);\n\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(\"KeyboardController::\" + name, cb),\n};\nexport const KeyboardControllerView: React.FC<KeyboardControllerProps> =\n require(\"./specs/KeyboardControllerViewNativeComponent\").default;\nexport const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =\n Platform.OS === \"android\" && Platform.Version >= 30\n ? require(\"./specs/KeyboardGestureAreaNativeComponent\").default\n : ({ children }: KeyboardGestureAreaProps) => children;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASA,MAAMC,aAAa,GAChB,2FAA0F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,qBAAqB,GACzBN,OAAO,CAAC,kCAAkC,CAAC,CAACK,OAAO;AAC9C,MAAME,kBAAkB,GAC7BD,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CACuB;AAACU,OAAA,CAAAJ,kBAAA,GAAAA,kBAAA;AAE9B,MAAMK,YAAY,GAAG,IAAIC,+BAAkB,CAACN,kBAAkB,CAAC;AAExD,MAAMO,cAAoC,GAAG;EAClDC,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAAC,sBAAsB,GAAGC,IAAI,EAAEC,EAAE;AAC9D,CAAC;AAACN,OAAA,CAAAG,cAAA,GAAAA,cAAA;AACK,MAAMI,sBAAyD,GACpElB,OAAO,CAAC,+CAA+C,CAAC,CAACK,OAAO;AAACM,OAAA,CAAAO,sBAAA,GAAAA,sBAAA;AAC5D,MAAMC,mBAAuD,GAClEjB,qBAAQ,CAACkB,EAAE,KAAK,SAAS,IAAIlB,qBAAQ,CAACmB,OAAO,IAAI,EAAE,GAC/CrB,OAAO,CAAC,4CAA4C,CAAC,CAACK,OAAO,GAC7DiB,IAAA;EAAA,IAAC;IAAEC;EAAmC,CAAC,GAAAD,IAAA;EAAA,OAAKC,QAAQ;AAAA;AAACZ,OAAA,CAAAQ,mBAAA,GAAAA,mBAAA"}
@@ -13,7 +13,7 @@ const useKeyboardAnimation = () => {
13
13
  const isClosed = (0, _reactNativeReanimated.useSharedValue)(true);
14
14
  (0, _hooks.useKeyboardHandler)({
15
15
  onStart: e => {
16
- 'worklet';
16
+ "worklet";
17
17
 
18
18
  if (e.height > 0) {
19
19
  isClosed.value = false;
@@ -21,15 +21,17 @@ const useKeyboardAnimation = () => {
21
21
  }
22
22
  },
23
23
  onMove: e => {
24
- 'worklet';
24
+ "worklet";
25
25
 
26
26
  progress.value = e.progress;
27
27
  height.value = e.height;
28
28
  },
29
29
  onEnd: e => {
30
- 'worklet';
30
+ "worklet";
31
31
 
32
32
  isClosed.value = e.height === 0;
33
+ progress.value = e.progress;
34
+ height.value = e.height;
33
35
  }
34
36
  }, []);
35
37
  return {
@@ -1 +1 @@
1
- {"version":3,"names":["useKeyboardAnimation","heightWhenOpened","useSharedValue","height","progress","isClosed","useKeyboardHandler","onStart","e","value","onMove","onEnd"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from 'react-native-reanimated';\n\nimport { useKeyboardHandler } from '../../hooks';\n\nexport const useKeyboardAnimation = () => {\n const heightWhenOpened = useSharedValue(0);\n const height = useSharedValue(0);\n const progress = useSharedValue(0);\n const isClosed = useSharedValue(true);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n 'worklet';\n\n if (e.height > 0) {\n isClosed.value = false;\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n 'worklet';\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n 'worklet';\n\n isClosed.value = e.height === 0;\n },\n },\n []\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAEO,MAAMA,oBAAoB,GAAG,MAAM;EACxC,MAAMC,gBAAgB,GAAG,IAAAC,qCAAc,EAAC,CAAC,CAAC;EAC1C,MAAMC,MAAM,GAAG,IAAAD,qCAAc,EAAC,CAAC,CAAC;EAChC,MAAME,QAAQ,GAAG,IAAAF,qCAAc,EAAC,CAAC,CAAC;EAClC,MAAMG,QAAQ,GAAG,IAAAH,qCAAc,EAAC,IAAI,CAAC;EAErC,IAAAI,yBAAkB,EAChB;IACEC,OAAO,EAAGC,CAAC,IAAK;MACd,SAAS;;MAET,IAAIA,CAAC,CAACL,MAAM,GAAG,CAAC,EAAE;QAChBE,QAAQ,CAACI,KAAK,GAAG,KAAK;QACtBR,gBAAgB,CAACQ,KAAK,GAAGD,CAAC,CAACL,MAAM;MACnC;IACF,CAAC;IACDO,MAAM,EAAGF,CAAC,IAAK;MACb,SAAS;;MAETJ,QAAQ,CAACK,KAAK,GAAGD,CAAC,CAACJ,QAAQ;MAC3BD,MAAM,CAACM,KAAK,GAAGD,CAAC,CAACL,MAAM;IACzB,CAAC;IACDQ,KAAK,EAAGH,CAAC,IAAK;MACZ,SAAS;;MAETH,QAAQ,CAACI,KAAK,GAAGD,CAAC,CAACL,MAAM,KAAK,CAAC;IACjC;EACF,CAAC,EACD,EAAE,CACH;EAED,OAAO;IAAEA,MAAM;IAAEC,QAAQ;IAAEH,gBAAgB;IAAEI;EAAS,CAAC;AACzD,CAAC;AAAC"}
1
+ {"version":3,"names":["_reactNativeReanimated","require","_hooks","useKeyboardAnimation","heightWhenOpened","useSharedValue","height","progress","isClosed","useKeyboardHandler","onStart","e","value","onMove","onEnd","exports"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport { useKeyboardHandler } from \"../../hooks\";\n\nexport const useKeyboardAnimation = () => {\n const heightWhenOpened = useSharedValue(0);\n const height = useSharedValue(0);\n const progress = useSharedValue(0);\n const isClosed = useSharedValue(true);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height > 0) {\n isClosed.value = false;\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n \"worklet\";\n\n isClosed.value = e.height === 0;\n\n progress.value = e.progress;\n height.value = e.height;\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAMC,gBAAgB,GAAG,IAAAC,qCAAc,EAAC,CAAC,CAAC;EAC1C,MAAMC,MAAM,GAAG,IAAAD,qCAAc,EAAC,CAAC,CAAC;EAChC,MAAME,QAAQ,GAAG,IAAAF,qCAAc,EAAC,CAAC,CAAC;EAClC,MAAMG,QAAQ,GAAG,IAAAH,qCAAc,EAAC,IAAI,CAAC;EAErC,IAAAI,yBAAkB,EAChB;IACEC,OAAO,EAAGC,CAAC,IAAK;MACd,SAAS;;MAET,IAAIA,CAAC,CAACL,MAAM,GAAG,CAAC,EAAE;QAChBE,QAAQ,CAACI,KAAK,GAAG,KAAK;QACtBR,gBAAgB,CAACQ,KAAK,GAAGD,CAAC,CAACL,MAAM;MACnC;IACF,CAAC;IACDO,MAAM,EAAGF,CAAC,IAAK;MACb,SAAS;;MAETJ,QAAQ,CAACK,KAAK,GAAGD,CAAC,CAACJ,QAAQ;MAC3BD,MAAM,CAACM,KAAK,GAAGD,CAAC,CAACL,MAAM;IACzB,CAAC;IACDQ,KAAK,EAAGH,CAAC,IAAK;MACZ,SAAS;;MAETH,QAAQ,CAACI,KAAK,GAAGD,CAAC,CAACL,MAAM,KAAK,CAAC;MAE/BC,QAAQ,CAACK,KAAK,GAAGD,CAAC,CAACJ,QAAQ;MAC3BD,MAAM,CAACM,KAAK,GAAGD,CAAC,CAACL,MAAM;IACzB;EACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEA,MAAM;IAAEC,QAAQ;IAAEH,gBAAgB;IAAEI;EAAS,CAAC;AACzD,CAAC;AAACO,OAAA,CAAAZ,oBAAA,GAAAA,oBAAA"}
@@ -7,7 +7,9 @@ exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _useKeyboardInterpolation = _interopRequireDefault(require("../hooks/useKeyboardInterpolation"));
10
11
  var _hooks = require("./hooks");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
13
  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); }
12
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
13
15
  function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
@@ -39,24 +41,31 @@ const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
39
41
  const {
40
42
  height: screenHeight
41
43
  } = (0, _reactNative.useWindowDimensions)();
42
- const relativeKeyboardHeight = (0, _reactNativeReanimated.useWorkletCallback)(() => {
44
+ const relativeKeyboardHeight = (0, _react.useCallback)(() => {
45
+ "worklet";
46
+
43
47
  const keyboardY = screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;
44
48
  return Math.max(frame.value.y + frame.value.height - keyboardY, 0);
45
49
  }, [screenHeight, keyboardVerticalOffset]);
46
- const onLayoutWorklet = (0, _reactNativeReanimated.useWorkletCallback)(layout => {
50
+ const {
51
+ interpolate
52
+ } = (0, _useKeyboardInterpolation.default)();
53
+ const onLayoutWorklet = (0, _react.useCallback)(layout => {
54
+ "worklet";
55
+
47
56
  if (keyboard.isClosed.value) {
48
57
  initialFrame.value = layout;
49
58
  }
50
- });
59
+ }, []);
51
60
  const onLayout = (0, _react.useCallback)(e => {
52
61
  (0, _reactNativeReanimated.runOnUI)(onLayoutWorklet)(e.nativeEvent.layout);
53
62
  onLayoutProps === null || onLayoutProps === void 0 ? void 0 : onLayoutProps(e);
54
63
  }, [onLayoutProps]);
55
64
  const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
56
- const bottom = (0, _reactNativeReanimated.interpolate)(keyboard.progress.value, [0, 1], [0, relativeKeyboardHeight()]);
65
+ const bottom = interpolate(keyboard.height.value, [0, relativeKeyboardHeight()]);
57
66
  const bottomHeight = enabled ? bottom : 0;
58
67
  switch (behavior) {
59
- case 'height':
68
+ case "height":
60
69
  if (!keyboard.isClosed.value) {
61
70
  return {
62
71
  height: frame.value.height - bottomHeight,
@@ -64,11 +73,11 @@ const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
64
73
  };
65
74
  }
66
75
  return {};
67
- case 'position':
76
+ case "position":
68
77
  return {
69
78
  bottom: bottomHeight
70
79
  };
71
- case 'padding':
80
+ case "padding":
72
81
  return {
73
82
  paddingBottom: bottomHeight
74
83
  };
@@ -76,7 +85,7 @@ const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
76
85
  return {};
77
86
  }
78
87
  }, [behavior, enabled, relativeKeyboardHeight]);
79
- const isPositionBehavior = behavior === 'position';
88
+ const isPositionBehavior = behavior === "position";
80
89
  const containerStyle = isPositionBehavior ? contentContainerStyle : style;
81
90
  const combinedStyles = (0, _react.useMemo)(() => [containerStyle, animatedStyle], [containerStyle, animatedStyle]);
82
91
  if (isPositionBehavior) {
@@ -89,7 +98,6 @@ const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
89
98
  }, children));
90
99
  }
91
100
  return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, _extends({
92
- // @ts-expect-error because `ref` from reanimated is not compatible with react-native
93
101
  ref: ref,
94
102
  onLayout: onLayout,
95
103
  style: combinedStyles