react-native-keyboard-controller 1.12.6 → 1.13.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 (152) hide show
  1. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +5 -0
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ReactContext.kt +13 -0
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +0 -10
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/Interpolator.kt +2 -1
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/IosInterpolator.kt +2 -1
  6. package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/LinearInterpolator.kt +1 -0
  7. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +15 -8
  8. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +71 -59
  9. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +4 -0
  10. package/android/src/main/java/com/reactnativekeyboardcontroller/modal/ModalAttachedWatcher.kt +80 -0
  11. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/StatusBarManagerCompatModuleImpl.kt +6 -12
  12. package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +31 -4
  13. package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +7 -0
  14. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +5 -0
  15. package/ios/core/KeyboardAnimation.swift +1 -1
  16. package/ios/core/TimingAnimation.swift +108 -0
  17. package/ios/extensions/UIApplication.swift +29 -0
  18. package/ios/extensions/UIView.swift +10 -0
  19. package/ios/observers/FocusedInputObserver.swift +2 -0
  20. package/ios/observers/KeyboardMovementObserver.swift +19 -10
  21. package/ios/traversal/ViewHierarchyNavigator.swift +1 -1
  22. package/ios/views/KeyboardControllerView.mm +30 -39
  23. package/lib/commonjs/animated.js +16 -30
  24. package/lib/commonjs/animated.js.map +1 -1
  25. package/lib/commonjs/bindings.js.map +1 -1
  26. package/lib/commonjs/bindings.native.js.map +1 -1
  27. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +3 -14
  28. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
  29. package/lib/commonjs/components/KeyboardAvoidingView/index.js +5 -4
  30. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  31. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +42 -16
  32. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  33. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +1 -0
  34. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  35. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -1
  36. package/lib/commonjs/components/KeyboardStickyView/index.js +2 -2
  37. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  38. package/lib/commonjs/components/KeyboardToolbar/Arrow.js +2 -2
  39. package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
  40. package/lib/commonjs/components/KeyboardToolbar/Button.js +12 -12
  41. package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
  42. package/lib/commonjs/components/KeyboardToolbar/index.js +33 -27
  43. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  44. package/lib/commonjs/components/index.js +2 -2
  45. package/lib/commonjs/components/index.js.map +1 -1
  46. package/lib/commonjs/context.js +3 -2
  47. package/lib/commonjs/context.js.map +1 -1
  48. package/lib/commonjs/event-handler.js +19 -0
  49. package/lib/commonjs/event-handler.js.map +1 -0
  50. package/lib/commonjs/event-handler.web.js +10 -0
  51. package/lib/commonjs/event-handler.web.js.map +1 -0
  52. package/lib/commonjs/event-mappings.js +9 -0
  53. package/lib/commonjs/event-mappings.js.map +1 -0
  54. package/lib/commonjs/hooks/index.js +8 -21
  55. package/lib/commonjs/hooks/index.js.map +1 -1
  56. package/lib/commonjs/hooks/useSyncEffect/index.js +37 -0
  57. package/lib/commonjs/hooks/useSyncEffect/index.js.map +1 -0
  58. package/lib/commonjs/internal.js +20 -43
  59. package/lib/commonjs/internal.js.map +1 -1
  60. package/lib/commonjs/monkey-patch.android.js +1 -1
  61. package/lib/commonjs/monkey-patch.android.js.map +1 -1
  62. package/lib/commonjs/monkey-patch.js.map +1 -1
  63. package/lib/commonjs/reanimated.js +1 -3
  64. package/lib/commonjs/reanimated.js.map +1 -1
  65. package/lib/commonjs/reanimated.native.js +1 -35
  66. package/lib/commonjs/reanimated.native.js.map +1 -1
  67. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +1 -1
  68. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  69. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +1 -1
  70. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  71. package/lib/commonjs/types.js.map +1 -1
  72. package/lib/module/animated.js +17 -32
  73. package/lib/module/animated.js.map +1 -1
  74. package/lib/module/bindings.js.map +1 -1
  75. package/lib/module/bindings.native.js.map +1 -1
  76. package/lib/module/components/KeyboardAvoidingView/hooks.js +3 -14
  77. package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
  78. package/lib/module/components/KeyboardAvoidingView/index.js +4 -3
  79. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  80. package/lib/module/components/KeyboardAwareScrollView/index.js +41 -15
  81. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  82. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +1 -0
  83. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  84. package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -1
  85. package/lib/module/components/KeyboardStickyView/index.js +1 -1
  86. package/lib/module/components/KeyboardToolbar/Button.js +10 -10
  87. package/lib/module/components/KeyboardToolbar/Button.js.map +1 -1
  88. package/lib/module/components/KeyboardToolbar/index.js +31 -25
  89. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  90. package/lib/module/context.js +3 -2
  91. package/lib/module/context.js.map +1 -1
  92. package/lib/module/event-handler.js +13 -0
  93. package/lib/module/event-handler.js.map +1 -0
  94. package/lib/module/event-handler.web.js +5 -0
  95. package/lib/module/event-handler.web.js.map +1 -0
  96. package/lib/module/event-mappings.js +3 -0
  97. package/lib/module/event-mappings.js.map +1 -0
  98. package/lib/module/hooks/index.js +7 -21
  99. package/lib/module/hooks/index.js.map +1 -1
  100. package/lib/module/hooks/useSyncEffect/index.js +31 -0
  101. package/lib/module/hooks/useSyncEffect/index.js.map +1 -0
  102. package/lib/module/internal.js +21 -44
  103. package/lib/module/internal.js.map +1 -1
  104. package/lib/module/monkey-patch.js.map +1 -1
  105. package/lib/module/reanimated.js +0 -2
  106. package/lib/module/reanimated.js.map +1 -1
  107. package/lib/module/reanimated.native.js +0 -32
  108. package/lib/module/reanimated.native.js.map +1 -1
  109. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  110. package/lib/module/types.js.map +1 -1
  111. package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -2
  112. package/lib/typescript/components/KeyboardToolbar/index.d.ts +4 -3
  113. package/lib/typescript/context.d.ts +3 -3
  114. package/lib/typescript/event-handler.d.ts +3 -0
  115. package/lib/typescript/event-mappings.d.ts +2 -0
  116. package/lib/typescript/hooks/index.d.ts +1 -1
  117. package/lib/typescript/hooks/useSyncEffect/index.d.ts +14 -0
  118. package/lib/typescript/internal.d.ts +5 -19
  119. package/lib/typescript/reanimated.d.ts +1 -3
  120. package/lib/typescript/reanimated.native.d.ts +1 -3
  121. package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +2 -1
  122. package/lib/typescript/types.d.ts +6 -0
  123. package/package.json +14 -7
  124. package/src/animated.tsx +21 -43
  125. package/src/bindings.native.ts +1 -0
  126. package/src/bindings.ts +1 -0
  127. package/src/components/KeyboardAvoidingView/hooks.ts +3 -13
  128. package/src/components/KeyboardAvoidingView/index.tsx +2 -1
  129. package/src/components/KeyboardAwareScrollView/index.tsx +51 -13
  130. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +2 -0
  131. package/src/components/KeyboardAwareScrollView/utils.ts +1 -0
  132. package/src/components/KeyboardToolbar/Button.tsx +11 -11
  133. package/src/components/KeyboardToolbar/index.tsx +45 -25
  134. package/src/context.ts +8 -6
  135. package/src/event-handler.js +15 -0
  136. package/src/event-handler.ts +8 -0
  137. package/src/event-handler.web.js +5 -0
  138. package/src/event-mappings.ts +14 -0
  139. package/src/hooks/index.ts +9 -16
  140. package/src/hooks/useSyncEffect/index.ts +36 -0
  141. package/src/internal.ts +34 -53
  142. package/src/monkey-patch.ts +1 -0
  143. package/src/reanimated.native.ts +0 -50
  144. package/src/reanimated.ts +1 -12
  145. package/src/specs/KeyboardGestureAreaNativeComponent.ts +5 -1
  146. package/src/types.ts +6 -0
  147. package/lib/commonjs/utils.js +0 -9
  148. package/lib/commonjs/utils.js.map +0 -1
  149. package/lib/module/utils.js +0 -2
  150. package/lib/module/utils.js.map +0 -1
  151. package/lib/typescript/utils.d.ts +0 -1
  152. package/src/utils.ts +0 -1
@@ -0,0 +1,108 @@
1
+ //
2
+ // TimingAnimation.swift
3
+ // react-native-keyboard-controller
4
+ //
5
+ // Created by Kiryl Ziusko on 02/05/2024.
6
+ //
7
+
8
+ import Foundation
9
+ import QuartzCore
10
+
11
+ // swiftlint:disable identifier_name
12
+ /**
13
+ * A class that handles timing animations using Bézier curves.
14
+ *
15
+ * This class calculates the progress of animations based on Bézier curve control points.
16
+ * For more details on the Bézier curves, see [Desmos Graph](https://www.desmos.com/calculator/eynenh1aga?lang=en).
17
+ */
18
+ public class TimingAnimation: KeyboardAnimation {
19
+ private let p1: CGPoint
20
+ private let p2: CGPoint
21
+
22
+ init(animation: CABasicAnimation, fromValue: Double, toValue: Double) {
23
+ let timingFunction = animation.timingFunction
24
+ var controlPoints: [Float] = [0, 0, 0, 0]
25
+ timingFunction?.getControlPoint(at: 1, values: &controlPoints[0])
26
+ timingFunction?.getControlPoint(at: 2, values: &controlPoints[2])
27
+ let p1 = CGPoint(x: CGFloat(controlPoints[0]), y: CGFloat(controlPoints[1]))
28
+ let p2 = CGPoint(x: CGFloat(controlPoints[2]), y: CGFloat(controlPoints[3]))
29
+
30
+ self.p1 = p1
31
+ self.p2 = p2
32
+
33
+ super.init(fromValue: fromValue, toValue: toValue, animation: animation)
34
+ }
35
+
36
+ func bezier(t: CGFloat, valueForPoint: (CGPoint) -> CGFloat) -> CGFloat {
37
+ let u = 1 - t
38
+ let tt = t * t
39
+ let uu = u * u
40
+
41
+ // Calculate the terms for the Bézier curve
42
+ // term0 is evaluated as `0`, because P0(0, 0)
43
+ // let term0 = uu * u * valueForPoint(p0) // P0
44
+ let term1 = 3 * uu * t * valueForPoint(p1) // P1
45
+ let term2 = 3 * u * tt * valueForPoint(p2) // P2
46
+ let term3 = tt * t // * valueForPoint(p3), because P3(1, 1)
47
+
48
+ // Sum all terms to get the Bézier value
49
+ return term1 + term2 + term3
50
+ }
51
+
52
+ func bezierY(t: CGFloat) -> CGFloat {
53
+ return bezier(t: t) { $0.y }
54
+ }
55
+
56
+ func bezierX(t: CGFloat) -> CGFloat {
57
+ return bezier(t: t) { $0.x }
58
+ }
59
+
60
+ // public functions
61
+ override func valueAt(time: Double) -> Double {
62
+ let x = time * Double(speed)
63
+ let frames = (animation?.duration ?? 0.0) * Double(speed)
64
+ let fraction = min(x / frames, 1)
65
+ let t = findTForX(xTarget: fraction)
66
+
67
+ let progress = bezierY(t: t)
68
+
69
+ return fromValue + (toValue - fromValue) * CGFloat(progress)
70
+ }
71
+
72
+ func findTForX(xTarget: CGFloat, epsilon: CGFloat = 0.0001, maxIterations: Int = 100) -> CGFloat {
73
+ var t: CGFloat = 0.5 // Start with an initial guess of t = 0.5
74
+ for _ in 0 ..< maxIterations {
75
+ let currentX = bezierX(t: t) // Compute the x-coordinate at t
76
+ let derivativeX = bezierXDerivative(t: t) // Compute the derivative at t
77
+ let xError = currentX - xTarget
78
+ if abs(xError) < epsilon {
79
+ return t
80
+ }
81
+ t -= xError / derivativeX // Newton-Raphson step
82
+ t = max(min(t, 1), 0) // Ensure t stays within bounds
83
+ }
84
+ return t // Return the approximation of t
85
+ }
86
+
87
+ func bezierDerivative(t: CGFloat, valueForPoint: (CGPoint) -> CGFloat) -> CGFloat {
88
+ let u = 1 - t
89
+ let uu = u * u
90
+ let tt = t * t
91
+ let tu = t * u
92
+
93
+ // term0 is evaluated as `0`, because P0(0, 0)
94
+ // let term0 = -3 * uu * valueForPoint(p0)
95
+ let term1 = (3 * uu - 6 * tu) * valueForPoint(p1)
96
+ let term2 = (6 * tu - 3 * tt) * valueForPoint(p2)
97
+ let term3 = 3 * tt // * valueForPoint(p3), because P3(1, 1)
98
+
99
+ // Sum all terms to get the derivative
100
+ return term1 + term2 + term3
101
+ }
102
+
103
+ func bezierXDerivative(t: CGFloat) -> CGFloat {
104
+ return bezierDerivative(t: t) { $0.x }
105
+ }
106
+ }
107
+
108
+ // swiftlint:enable identifier_name
@@ -0,0 +1,29 @@
1
+ //
2
+ // UIApplication.swift
3
+ // react-native-keyboard-controller
4
+ //
5
+ // Created by Kiryl Ziusko on 18/07/2024.
6
+ //
7
+
8
+ import Foundation
9
+ import UIKit
10
+
11
+ public extension UIApplication {
12
+ static func topViewController(
13
+ base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController
14
+ ) -> UIViewController? {
15
+ if let nav = base as? UINavigationController {
16
+ return topViewController(base: nav.visibleViewController)
17
+ }
18
+
19
+ if let tab = base as? UITabBarController, let selected = tab.selectedViewController {
20
+ return topViewController(base: selected)
21
+ }
22
+
23
+ if let presented = base?.presentedViewController, !presented.isBeingDismissed {
24
+ return topViewController(base: presented)
25
+ }
26
+
27
+ return base
28
+ }
29
+ }
@@ -15,3 +15,13 @@ public extension UIView {
15
15
  return superview?.convert(frame, to: rootView)
16
16
  }
17
17
  }
18
+
19
+ public extension Optional where Wrapped == UIView {
20
+ var framePositionInWindow: (Double, Double) {
21
+ let frameY = self?.layer.presentation()?.frame.origin.y ?? 0
22
+ let windowH = self?.window?.bounds.size.height ?? 0
23
+ let position = windowH - frameY
24
+
25
+ return (position, frameY)
26
+ }
27
+ }
@@ -233,6 +233,8 @@ public class FocusedInputObserver: NSObject {
233
233
  return
234
234
  }
235
235
 
236
+ syncUpLayout()
237
+
236
238
  let target: [String: Any] = [
237
239
  "target": (currentResponder as UIResponder?).reactViewTag,
238
240
  ]
@@ -143,6 +143,8 @@ public class KeyboardMovementObserver: NSObject {
143
143
  return
144
144
  }
145
145
 
146
+ prevKeyboardPosition = position
147
+
146
148
  onEvent(
147
149
  "onKeyboardMoveInteractive",
148
150
  position as NSNumber,
@@ -208,21 +210,24 @@ public class KeyboardMovementObserver: NSObject {
208
210
 
209
211
  @objc func keyboardDidAppear(_ notification: Notification) {
210
212
  if let keyboardFrame: NSValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
213
+ let (position, _) = keyboardView.framePositionInWindow
211
214
  let keyboardHeight = keyboardFrame.cgRectValue.size.height
212
215
  tag = UIResponder.current.reactViewTag
213
216
  self.keyboardHeight = keyboardHeight
214
217
  let duration = Int(
215
218
  (notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double ?? 0) * 1000
216
219
  )
220
+ // always limit progress to the maximum possible value
221
+ let progress = min(position / self.keyboardHeight, 1.0)
217
222
 
218
223
  var data = [AnyHashable: Any]()
219
- data["height"] = keyboardHeight
224
+ data["height"] = position
220
225
  data["duration"] = duration
221
226
  data["timestamp"] = Date.currentTimeStamp
222
227
  data["target"] = tag
223
228
 
224
229
  onCancelAnimation()
225
- onEvent("onKeyboardMoveEnd", keyboardHeight as NSNumber, 1, duration as NSNumber, tag)
230
+ onEvent("onKeyboardMoveEnd", position as NSNumber, progress as NSNumber, duration as NSNumber, tag)
226
231
  onNotify("KeyboardController::keyboardDidShow", data)
227
232
 
228
233
  removeKeyboardWatcher()
@@ -269,11 +274,13 @@ public class KeyboardMovementObserver: NSObject {
269
274
  }
270
275
 
271
276
  func initializeAnimation(fromValue: Double, toValue: Double) {
272
- let positionAnimation = keyboardView?.layer.presentation()?.animation(forKey: "position") as? CASpringAnimation
273
- guard let keyboardAnimation = positionAnimation else {
274
- return
277
+ guard let positionAnimation = keyboardView?.layer.presentation()?.animation(forKey: "position") else { return }
278
+
279
+ if let springAnimation = positionAnimation as? CASpringAnimation {
280
+ animation = SpringAnimation(animation: springAnimation, fromValue: fromValue, toValue: toValue)
281
+ } else if let basicAnimation = positionAnimation as? CABasicAnimation {
282
+ animation = TimingAnimation(animation: basicAnimation, fromValue: fromValue, toValue: toValue)
275
283
  }
276
- animation = SpringAnimation(animation: keyboardAnimation, fromValue: fromValue, toValue: toValue)
277
284
  }
278
285
 
279
286
  @objc func updateKeyboardFrame(link: CADisplayLink) {
@@ -281,14 +288,17 @@ public class KeyboardMovementObserver: NSObject {
281
288
  return
282
289
  }
283
290
 
284
- let keyboardFrameY = keyboardView?.layer.presentation()?.frame.origin.y ?? 0
285
- let keyboardWindowH = keyboardView?.window?.bounds.size.height ?? 0
286
- var keyboardPosition = keyboardWindowH - keyboardFrameY
291
+ let (visibleKeyboardHeight, keyboardFrameY) = keyboardView.framePositionInWindow
292
+ var keyboardPosition = visibleKeyboardHeight
287
293
 
288
294
  if keyboardPosition == prevKeyboardPosition || keyboardFrameY == 0 {
289
295
  return
290
296
  }
291
297
 
298
+ if animation == nil {
299
+ initializeAnimation(fromValue: prevKeyboardPosition, toValue: keyboardHeight)
300
+ }
301
+
292
302
  prevKeyboardPosition = keyboardPosition
293
303
 
294
304
  if let animation = animation {
@@ -307,7 +317,6 @@ public class KeyboardMovementObserver: NSObject {
307
317
  #endif
308
318
 
309
319
  let position = CGFloat(animation.valueAt(time: duration))
310
-
311
320
  // handles a case when final frame has final destination (i. e. 0 or 291)
312
321
  // but CASpringAnimation can never get to this final destination
313
322
  let race: (CGFloat, CGFloat) -> CGFloat = animation.isIncreasing ? max : min
@@ -29,7 +29,7 @@ public class ViewHierarchyNavigator: NSObject {
29
29
  public static func getAllInputFields() -> [TextInput] {
30
30
  var textInputs = [TextInput]()
31
31
 
32
- guard let rootView = UIApplication.shared.keyWindow?.rootViewController?.view else {
32
+ guard let rootView = UIApplication.topViewController()?.view else {
33
33
  return []
34
34
  }
35
35
 
@@ -25,8 +25,6 @@
25
25
  #import <react/renderer/components/reactnativekeyboardcontroller/Props.h>
26
26
  #import <react/renderer/components/reactnativekeyboardcontroller/RCTComponentViewHelpers.h>
27
27
 
28
- #import <React/RCTBridge+Private.h>
29
-
30
28
  #import "KeyboardControllerModule-Header.h"
31
29
  #import "RCTFabricComponentsPlugins.h"
32
30
 
@@ -79,14 +77,10 @@ using namespace facebook::react;
79
77
  .width = width,
80
78
  .x = x,
81
79
  .y = y}});
82
- // TODO: use built-in _eventEmitter once NativeAnimated module will use
83
- // ModernEventEmitter
84
- RCTBridge *bridge = [RCTBridge currentBridge];
85
- if (bridge) {
86
- FocusedInputLayoutChangedEvent *inputChangedEvent =
87
- [[FocusedInputLayoutChangedEvent alloc] initWithReactTag:@(self.tag) event:event];
88
- [bridge.eventDispatcher sendEvent:inputChangedEvent];
89
- }
80
+
81
+ FocusedInputLayoutChangedEvent *inputChangedEvent =
82
+ [[FocusedInputLayoutChangedEvent alloc] initWithReactTag:@(self.tag) event:event];
83
+ [self postNotificationForEventDispatcherObserversWithEvent:inputChangedEvent];
90
84
  }
91
85
  }
92
86
  onTextChangedHandler:^(NSString *text) {
@@ -97,14 +91,9 @@ using namespace facebook::react;
97
91
  facebook::react::KeyboardControllerViewEventEmitter::OnFocusedInputTextChanged{
98
92
  .text = std::string([text UTF8String])});
99
93
 
100
- // TODO: use built-in _eventEmitter once NativeAnimated module will use
101
- // ModernEventEmitter
102
- RCTBridge *bridge = [RCTBridge currentBridge];
103
- if (bridge) {
104
- FocusedInputTextChangedEvent *textChangedEvent =
105
- [[FocusedInputTextChangedEvent alloc] initWithReactTag:@(self.tag) text:text];
106
- [bridge.eventDispatcher sendEvent:textChangedEvent];
107
- }
94
+ FocusedInputTextChangedEvent *textChangedEvent =
95
+ [[FocusedInputTextChangedEvent alloc] initWithReactTag:@(self.tag) text:text];
96
+ [self postNotificationForEventDispatcherObserversWithEvent:textChangedEvent];
108
97
  }
109
98
  }
110
99
  onSelectionChangedHandler:^(NSDictionary *event) {
@@ -132,15 +121,11 @@ using namespace facebook::react;
132
121
  .end = facebook::react::KeyboardControllerViewEventEmitter::
133
122
  OnFocusedInputSelectionChangedSelectionEnd{
134
123
  .x = endX, .y = endY, .position = end}}});
135
- // TODO: use built-in _eventEmitter once NativeAnimated module will use
136
- // ModernEventEmitter
137
- RCTBridge *bridge = [RCTBridge currentBridge];
138
- if (bridge) {
139
- FocusedInputSelectionChangedEvent *selectionChangedEvent =
140
- [[FocusedInputSelectionChangedEvent alloc] initWithReactTag:@(self.tag)
141
- event:event];
142
- [bridge.eventDispatcher sendEvent:selectionChangedEvent];
143
- }
124
+
125
+ FocusedInputSelectionChangedEvent *selectionChangedEvent =
126
+ [[FocusedInputSelectionChangedEvent alloc] initWithReactTag:@(self.tag)
127
+ event:event];
128
+ [self postNotificationForEventDispatcherObserversWithEvent:selectionChangedEvent];
144
129
  }
145
130
  }
146
131
  onFocusDidSet:^(NSDictionary *data) {
@@ -197,18 +182,14 @@ using namespace facebook::react;
197
182
  .target = [target intValue]});
198
183
  }
199
184
 
200
- // TODO: use built-in _eventEmitter once NativeAnimated module will use ModernEventEmitter
201
- RCTBridge *bridge = [RCTBridge currentBridge];
202
- if (bridge) {
203
- KeyboardMoveEvent *keyboardMoveEvent =
204
- [[KeyboardMoveEvent alloc] initWithReactTag:@(self.tag)
205
- event:event
206
- height:height
207
- progress:progress
208
- duration:duration
209
- target:target];
210
- [bridge.eventDispatcher sendEvent:keyboardMoveEvent];
211
- }
185
+ KeyboardMoveEvent *keyboardMoveEvent =
186
+ [[KeyboardMoveEvent alloc] initWithReactTag:@(self.tag)
187
+ event:event
188
+ height:height
189
+ progress:progress
190
+ duration:duration
191
+ target:target];
192
+ [self postNotificationForEventDispatcherObserversWithEvent:keyboardMoveEvent];
212
193
  }
213
194
  onNotify:^(NSString *event, NSDictionary *data) {
214
195
  [KeyboardController.shared sendEvent:event body:data];
@@ -261,6 +242,16 @@ using namespace facebook::react;
261
242
  [keyboardObserver unmount];
262
243
  }
263
244
 
245
+ // TODO: once Fabric implements proper NativeAnimationDriver, this should be removed.
246
+ - (void)postNotificationForEventDispatcherObserversWithEvent:(NSObject<RCTEvent> *)event
247
+ {
248
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:event, @"event", nil];
249
+ [[NSNotificationCenter defaultCenter]
250
+ postNotificationName:@"RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED"
251
+ object:nil
252
+ userInfo:userInfo];
253
+ }
254
+
264
255
  Class<RCTComponentViewProtocol> KeyboardControllerViewCls(void)
265
256
  {
266
257
  return KeyboardControllerView.class;
@@ -9,11 +9,14 @@ var _reactNative = require("react-native");
9
9
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
10
  var _bindings = require("./bindings");
11
11
  var _context = require("./context");
12
+ var _eventMappings = require("./event-mappings");
12
13
  var _internal = require("./internal");
13
14
  var _monkeyPatch = require("./monkey-patch");
14
15
  var _reanimated = require("./reanimated");
15
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ /* eslint react/jsx-sort-props: off */
19
+
17
20
  const KeyboardControllerViewAnimated = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.Animated.createAnimatedComponent(_bindings.KeyboardControllerView));
18
21
  const styles = _reactNative.StyleSheet.create({
19
22
  container: {
@@ -33,6 +36,8 @@ const KeyboardProvider = ({
33
36
  navigationBarTranslucent,
34
37
  enabled: initiallyEnabled = true
35
38
  }) => {
39
+ // ref
40
+ const viewTagRef = (0, _react.useRef)(null);
36
41
  // state
37
42
  const [enabled, setEnabled] = (0, _react.useState)(initiallyEnabled);
38
43
  // animated values
@@ -42,8 +47,8 @@ const KeyboardProvider = ({
42
47
  const progressSV = (0, _reactNativeReanimated.useSharedValue)(0);
43
48
  const heightSV = (0, _reactNativeReanimated.useSharedValue)(0);
44
49
  const layout = (0, _reactNativeReanimated.useSharedValue)(null);
45
- const [setKeyboardHandlers, broadcastKeyboardEvents] = (0, _internal.useSharedHandlers)();
46
- const [setInputHandlers, broadcastInputEvents] = (0, _internal.useSharedHandlers)();
50
+ const setKeyboardHandlers = (0, _internal.useEventHandlerRegistration)(_eventMappings.keyboardEventsMap, viewTagRef);
51
+ const setInputHandlers = (0, _internal.useEventHandlerRegistration)(_eventMappings.focusedInputEventsMap, viewTagRef);
47
52
  // memo
48
53
  const context = (0, _react.useMemo)(() => ({
49
54
  enabled,
@@ -80,6 +85,7 @@ const KeyboardProvider = ({
80
85
  "worklet";
81
86
 
82
87
  if (platforms.includes(OS)) {
88
+ // eslint-disable-next-line react-compiler/react-compiler
83
89
  progressSV.value = event.progress;
84
90
  heightSV.value = -event.height;
85
91
  }
@@ -88,25 +94,17 @@ const KeyboardProvider = ({
88
94
  onKeyboardMoveStart: event => {
89
95
  "worklet";
90
96
 
91
- broadcastKeyboardEvents("onStart", event);
92
97
  updateSharedValues(event, ["ios"]);
93
98
  },
94
99
  onKeyboardMove: event => {
95
100
  "worklet";
96
101
 
97
- broadcastKeyboardEvents("onMove", event);
98
102
  updateSharedValues(event, ["android"]);
99
103
  },
100
- onKeyboardMoveEnd: event => {
101
- "worklet";
102
-
103
- broadcastKeyboardEvents("onEnd", event);
104
- },
105
104
  onKeyboardMoveInteractive: event => {
106
105
  "worklet";
107
106
 
108
107
  updateSharedValues(event, ["android", "ios"]);
109
- broadcastKeyboardEvents("onInteractive", event);
110
108
  }
111
109
  }, []);
112
110
  const inputLayoutHandler = (0, _reanimated.useFocusedInputLayoutHandler)({
@@ -120,20 +118,7 @@ const KeyboardProvider = ({
120
118
  }
121
119
  }
122
120
  }, []);
123
- const inputTextHandler = (0, _reanimated.useFocusedInputTextHandler)({
124
- onFocusedInputTextChanged: e => {
125
- "worklet";
126
-
127
- broadcastInputEvents("onChangeText", e);
128
- }
129
- }, []);
130
- const inputSelectionHandler = (0, _reanimated.useFocusedInputSelectionHandler)({
131
- onFocusedInputSelectionChanged: e => {
132
- "worklet";
133
121
 
134
- broadcastInputEvents("onSelectionChange", e);
135
- }
136
- }, []);
137
122
  // effects
138
123
  (0, _react.useEffect)(() => {
139
124
  if (enabled) {
@@ -145,17 +130,18 @@ const KeyboardProvider = ({
145
130
  return /*#__PURE__*/_react.default.createElement(_context.KeyboardContext.Provider, {
146
131
  value: context
147
132
  }, /*#__PURE__*/_react.default.createElement(KeyboardControllerViewAnimated, {
133
+ ref: viewTagRef,
148
134
  enabled: enabled,
135
+ navigationBarTranslucent: navigationBarTranslucent,
136
+ statusBarTranslucent: statusBarTranslucent,
137
+ style: styles.container
138
+ // on*Reanimated prop must precede animated handlers to work correctly
139
+ ,
149
140
  onKeyboardMoveReanimated: keyboardHandler,
150
141
  onKeyboardMoveStart: OS === "ios" ? onKeyboardMove : undefined,
151
142
  onKeyboardMove: OS === "android" ? onKeyboardMove : undefined,
152
143
  onKeyboardMoveInteractive: onKeyboardMove,
153
- onFocusedInputLayoutChangedReanimated: inputLayoutHandler,
154
- onFocusedInputTextChangedReanimated: inputTextHandler,
155
- onFocusedInputSelectionChangedReanimated: inputSelectionHandler,
156
- navigationBarTranslucent: navigationBarTranslucent,
157
- statusBarTranslucent: statusBarTranslucent,
158
- style: styles.container
144
+ onFocusedInputLayoutChangedReanimated: inputLayoutHandler
159
145
  }, children), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
160
146
  // we are using this small hack, because if the component (where
161
147
  // animated value has been used) is unmounted, then animation will
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_bindings","_context","_internal","_monkeyPatch","_reanimated","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","OS","Platform","KeyboardProvider","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","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","target","inputTextHandler","useFocusedInputTextHandler","onFocusedInputTextChanged","inputSelectionHandler","useFocusedInputSelectionHandler","onFocusedInputSelectionChanged","useEffect","applyMonkeyPatch","revertMonkeyPatch","createElement","KeyboardContext","Provider","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","onFocusedInputTextChangedReanimated","onFocusedInputSelectionChangedReanimated","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 useFocusedInputSelectionHandler,\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\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\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(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 const inputSelectionHandler = useFocusedInputSelectionHandler(\n {\n onFocusedInputSelectionChanged: (e) => {\n \"worklet\";\n\n broadcastInputEvents(\"onSelectionChange\", 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={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n onFocusedInputTextChangedReanimated={inputTextHandler}\n onFocusedInputSelectionChangedReanimated={inputSelectionHandler}\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;AAKsB,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK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EAAEA,wBAAyB;IACnDD,oBAAoB,EAAEA,oBAAqB;IAC3CuB,KAAK,EAAEnC,MAAM,CAACG;EAAU,GAEvBQ,QAC6B,CAAC,eACjC/C,MAAA,CAAAgB,OAAA,CAAAqF,aAAA,CAAClG,YAAA,CAAA+B,QAAQ,CAAC2E,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAtC,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAACuC,OAAA,CAAAhE,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_bindings","_context","_eventMappings","_internal","_monkeyPatch","_reanimated","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","OS","Platform","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","viewTagRef","useRef","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","useEventHandlerRegistration","keyboardEventsMap","setInputHandlers","focusedInputEventsMap","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","target","useEffect","applyMonkeyPatch","revertMonkeyPatch","createElement","KeyboardContext","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View","exports"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useEffect, useMemo, useRef, 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 { focusedInputEventsMap, keyboardEventsMap } from \"./event-mappings\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { applyMonkeyPatch, revertMonkeyPatch } from \"./monkey-patch\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\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(KeyboardControllerView),\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\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\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 = useEventHandlerRegistration<KeyboardHandler>(\n keyboardEventsMap,\n viewTagRef,\n );\n const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(\n focusedInputEventsMap,\n viewTagRef,\n );\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(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\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 updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\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\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 ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\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":";;;;;;AACA,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,cAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,W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A;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAAC+B,OAAA,CAAA1D,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","NOOP","KeyboardController","exports","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","View","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n WindowDimensionsEventsModule,\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 setFocusTo: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\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;AAYA,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACd,MAAMC,kBAA4C,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAC1DE,cAAc,EAAEH,IAAI;EACpBI,YAAY,EAAEJ,IAAI;EAClBK,OAAO,EAAEL,IAAI;EACbM,UAAU,EAAEN,IAAI;EAChBO,WAAW,EAAEP,IAAI;EACjBQ,eAAe,EAAER;AACnB,CAAC;AACM,MAAMS,cAAoC,GAAAP,OAAA,CAAAO,cAAA,GAAG;EAClDF,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMW,kBAA4C,GAAAT,OAAA,CAAAS,kBAAA,GAAG;EAC1DJ,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACM,MAAMY,sBAAoD,GAAAV,OAAA,CAAAU,sBAAA,GAAG;EAClEL,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACM,MAAMa,sBAAsB,GAAAX,OAAA,CAAAW,sBAAA,GACjCC,iBAAoD;AAC/C,MAAMC,mBAAmB,GAAAb,OAAA,CAAAa,mBAAA,GAC9BD,iBAAqD","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","NOOP","KeyboardController","exports","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","View","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\nimport type { EmitterSubscription } from \"react-native\";\n\nconst NOOP = () => {};\n\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n dismiss: NOOP,\n setFocusTo: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\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;AAYA,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAEd,MAAMC,kBAA4C,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAC1DE,cAAc,EAAEH,IAAI;EACpBI,YAAY,EAAEJ,IAAI;EAClBK,OAAO,EAAEL,IAAI;EACbM,UAAU,EAAEN,IAAI;EAChBO,WAAW,EAAEP,IAAI;EACjBQ,eAAe,EAAER;AACnB,CAAC;AACM,MAAMS,cAAoC,GAAAP,OAAA,CAAAO,cAAA,GAAG;EAClDF,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMW,kBAA4C,GAAAT,OAAA,CAAAS,kBAAA,GAAG;EAC1DJ,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACM,MAAMY,sBAAoD,GAAAV,OAAA,CAAAU,sBAAA,GAAG;EAClEL,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACM,MAAMa,sBAAsB,GAAAX,OAAA,CAAAW,sBAAA,GACjCC,iBAAoD;AAC/C,MAAMC,mBAAmB,GAAAb,OAAA,CAAAa,mBAAA,GAC9BD,iBAAqD","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","RCTKeyboardController","KeyboardController","exports","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","NativeEventEmitter","KeyboardEvents","addListener","name","cb","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","OS","Version","children"],"sources":["bindings.native.ts"],"sourcesContent":["import { NativeEventEmitter, Platform } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n WindowDimensionsEventsModule,\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 KEYBOARD_CONTROLLER_NAMESPACE = \"KeyboardController::\";\nconst eventEmitter = new NativeEventEmitter(KeyboardController);\n\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + 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;AAWA,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,GAAAC,OAAA,CAAAD,kBAAA,GAC7BD,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CACF,CACuB;AAE7B,MAAMW,6BAA6B,GAAG,sBAAsB;AAC5D,MAAMC,YAAY,GAAG,IAAIC,+BAAkB,CAACP,kBAAkB,CAAC;AAExD,MAAMQ,cAAoC,GAAAP,OAAA,CAAAO,cAAA,GAAG;EAClDC,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAACJ,6BAA6B,GAAGK,IAAI,EAAEC,EAAE;AACrE,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMC,kBAA4C,GAAAX,OAAA,CAAAW,kBAAA,GAAG;EAC1DH,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAACJ,6BAA6B,GAAGK,IAAI,EAAEC,EAAE;AACrE,CAAC;AACM,MAAME,sBAAoD,GAAAZ,OAAA,CAAAY,sBAAA,GAAG;EAClEJ,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAACJ,6BAA6B,GAAGK,IAAI,EAAEC,EAAE;AACrE,CAAC;AACM,MAAMG,sBAAyD,GAAAb,OAAA,CAAAa,sBAAA,GACpErB,OAAO,CAAC,+CAA+C,CAAC,CAACK,OAAO;AAC3D,MAAMiB,mBAAuD,GAAAd,OAAA,CAAAc,mBAAA,GAClEpB,qBAAQ,CAACqB,EAAE,KAAK,SAAS,IAAIrB,qBAAQ,CAACsB,OAAO,IAAI,EAAE,GAC/CxB,OAAO,CAAC,4CAA4C,CAAC,CAACK,OAAO,GAC7D,CAAC;EAAEoB;AAAmC,CAAC,KAAKA,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","RCTKeyboardController","KeyboardController","exports","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","NativeEventEmitter","KeyboardEvents","addListener","name","cb","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","OS","Version","children"],"sources":["bindings.native.ts"],"sourcesContent":["import { NativeEventEmitter, Platform } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n WindowDimensionsEventsModule,\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;\n\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 KEYBOARD_CONTROLLER_NAMESPACE = \"KeyboardController::\";\nconst eventEmitter = new NativeEventEmitter(KeyboardController);\n\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + 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;AAWA,MAAMC,aAAa,GACjB,2FAA2F,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;AAE9C,MAAME,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAC7BD,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CACF,CACuB;AAE7B,MAAMW,6BAA6B,GAAG,sBAAsB;AAC5D,MAAMC,YAAY,GAAG,IAAIC,+BAAkB,CAACP,kBAAkB,CAAC;AAExD,MAAMQ,cAAoC,GAAAP,OAAA,CAAAO,cAAA,GAAG;EAClDC,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAACJ,6BAA6B,GAAGK,IAAI,EAAEC,EAAE;AACrE,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMC,kBAA4C,GAAAX,OAAA,CAAAW,kBAAA,GAAG;EAC1DH,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAACJ,6BAA6B,GAAGK,IAAI,EAAEC,EAAE;AACrE,CAAC;AACM,MAAME,sBAAoD,GAAAZ,OAAA,CAAAY,sBAAA,GAAG;EAClEJ,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAACJ,6BAA6B,GAAGK,IAAI,EAAEC,EAAE;AACrE,CAAC;AACM,MAAMG,sBAAyD,GAAAb,OAAA,CAAAa,sBAAA,GACpErB,OAAO,CAAC,+CAA+C,CAAC,CAACK,OAAO;AAC3D,MAAMiB,mBAAuD,GAAAd,OAAA,CAAAc,mBAAA,GAClEpB,qBAAQ,CAACqB,EAAE,KAAK,SAAS,IAAIrB,qBAAQ,CAACsB,OAAO,IAAI,EAAE,GAC/CxB,OAAO,CAAC,4CAA4C,CAAC,CAACK,OAAO,GAC7D,CAAC;EAAEoB;AAAmC,CAAC,KAAKA,QAAQ","ignoreList":[]}
@@ -19,6 +19,7 @@ const useKeyboardAnimation = () => {
19
19
  "worklet";
20
20
 
21
21
  if (e.height > 0) {
22
+ // eslint-disable-next-line react-compiler/react-compiler
22
23
  isClosed.value = false;
23
24
  heightWhenOpened.value = e.height;
24
25
  }
@@ -33,20 +34,8 @@ const useKeyboardAnimation = () => {
33
34
  "worklet";
34
35
 
35
36
  isClosed.value = e.height === 0;
36
-
37
- // `height` update happens in `onMove` handler
38
- // in `onEnd` we need to update only if `onMove`
39
- // wasn't called (i. e. duration === 0)
40
- //
41
- // we can not call this code without condition below
42
- // because in some corner cases (iOS with `secureTextEntry`)
43
- // `onEnd` can be emitted before `onMove` and in this case
44
- // it may lead to choppy/glitchy/jumpy UI
45
- // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327
46
- if (e.duration === 0) {
47
- progress.value = e.progress;
48
- height.value = e.height;
49
- }
37
+ height.value = e.height;
38
+ progress.value = e.progress;
50
39
  }
51
40
  }, []);
52
41
  return {
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeReanimated","require","_reactNativeKeyboardController","useKeyboardAnimation","reanimated","useKeyboardContext","heightWhenOpened","useSharedValue","height","value","progress","isClosed","useKeyboardHandler","onStart","e","onMove","onEnd","duration","exports"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport {\n useKeyboardContext,\n useKeyboardHandler,\n} from \"react-native-keyboard-controller\";\n\nexport const useKeyboardAnimation = () => {\n const { reanimated } = useKeyboardContext();\n const heightWhenOpened = useSharedValue(-reanimated.height.value);\n const height = useSharedValue(-reanimated.height.value);\n const progress = useSharedValue(reanimated.progress.value);\n const isClosed = useSharedValue(reanimated.progress.value === 0);\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 // `height` update happens in `onMove` handler\n // in `onEnd` we need to update only if `onMove`\n // wasn't called (i. e. duration === 0)\n //\n // we can not call this code without condition below\n // because in some corner cases (iOS with `secureTextEntry`)\n // `onEnd` can be emitted before `onMove` and in this case\n // it may lead to choppy/glitchy/jumpy UI\n // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327\n if (e.duration === 0) {\n progress.value = e.progress;\n height.value = e.height;\n }\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,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ACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEA,MAAM;IAAEE,QAAQ;IAAEJ,gBAAgB;IAAEK;EAAS,CAAC;AACzD,CAAC;AAACO,OAAA,CAAAf,oBAAA,GAAAA,oBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeReanimated","require","_reactNativeKeyboardController","useKeyboardAnimation","reanimated","useKeyboardContext","heightWhenOpened","useSharedValue","height","value","progress","isClosed","useKeyboardHandler","onStart","e","onMove","onEnd","exports"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport {\n useKeyboardContext,\n useKeyboardHandler,\n} from \"react-native-keyboard-controller\";\n\nexport const useKeyboardAnimation = () => {\n const { reanimated } = useKeyboardContext();\n const heightWhenOpened = useSharedValue(-reanimated.height.value);\n const height = useSharedValue(-reanimated.height.value);\n const progress = useSharedValue(reanimated.progress.value);\n const isClosed = useSharedValue(reanimated.progress.value === 0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height > 0) {\n // eslint-disable-next-line react-compiler/react-compiler\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 height.value = e.height;\n progress.value = e.progress;\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAEA,IAAAC,8BAAA,GAAAD,OAAA;AAKO,MAAME,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAW,CAAC,GAAG,IAAAC,iDAAkB,EAAC,CAAC;EAC3C,MAAMC,gBAAgB,GAAG,IAAAC,qCAAc,EAAC,CAACH,UAAU,CAACI,MAAM,CAACC,KAAK,CAAC;EACjE,MAAMD,MAAM,GAAG,IAAAD,qCAAc,EAA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