react-native-keyboard-controller 1.12.2 → 1.12.3

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 (59) hide show
  1. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +11 -0
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +11 -2
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/WindowDimensionListener.kt +57 -0
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +9 -9
  5. package/ios/traversal/KeyboardView.swift +5 -8
  6. package/jest/index.js +3 -1
  7. package/lib/commonjs/bindings.js +6 -1
  8. package/lib/commonjs/bindings.js.map +1 -1
  9. package/lib/commonjs/bindings.native.js +4 -1
  10. package/lib/commonjs/bindings.native.js.map +1 -1
  11. package/lib/commonjs/components/KeyboardAvoidingView/index.js +2 -1
  12. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  13. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +4 -3
  14. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  15. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js +11 -1
  16. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -1
  17. package/lib/commonjs/{hooks.js → hooks/index.js} +27 -5
  18. package/lib/commonjs/hooks/index.js.map +1 -0
  19. package/lib/commonjs/hooks/useWindowDimensions/index.android.js +29 -0
  20. package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -0
  21. package/lib/commonjs/hooks/useWindowDimensions/index.js +13 -0
  22. package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -0
  23. package/lib/commonjs/types.js.map +1 -1
  24. package/lib/module/bindings.js +5 -0
  25. package/lib/module/bindings.js.map +1 -1
  26. package/lib/module/bindings.native.js +3 -0
  27. package/lib/module/bindings.native.js.map +1 -1
  28. package/lib/module/components/KeyboardAvoidingView/index.js +2 -1
  29. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  30. package/lib/module/components/KeyboardAwareScrollView/index.js +6 -5
  31. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  32. package/lib/module/components/KeyboardAwareScrollView/utils.js +9 -0
  33. package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -1
  34. package/lib/module/{hooks.js → hooks/index.js} +6 -5
  35. package/lib/module/hooks/index.js.map +1 -0
  36. package/lib/module/hooks/useWindowDimensions/index.android.js +22 -0
  37. package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -0
  38. package/lib/module/hooks/useWindowDimensions/index.js +2 -0
  39. package/lib/module/hooks/useWindowDimensions/index.js.map +1 -0
  40. package/lib/module/types.js.map +1 -1
  41. package/lib/typescript/bindings.d.ts +2 -1
  42. package/lib/typescript/bindings.native.d.ts +2 -1
  43. package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +1 -0
  44. package/lib/typescript/{hooks.d.ts → hooks/index.d.ts} +4 -3
  45. package/lib/typescript/hooks/useWindowDimensions/index.android.d.ts +2 -0
  46. package/lib/typescript/hooks/useWindowDimensions/index.d.ts +1 -0
  47. package/lib/typescript/types.d.ts +8 -0
  48. package/package.json +1 -1
  49. package/src/bindings.native.ts +5 -0
  50. package/src/bindings.ts +4 -0
  51. package/src/components/KeyboardAvoidingView/index.tsx +3 -1
  52. package/src/components/KeyboardAwareScrollView/index.tsx +13 -4
  53. package/src/components/KeyboardAwareScrollView/utils.ts +15 -0
  54. package/src/{hooks.ts → hooks/index.ts} +8 -6
  55. package/src/hooks/useWindowDimensions/index.android.ts +33 -0
  56. package/src/hooks/useWindowDimensions/index.ts +1 -0
  57. package/src/types.ts +11 -0
  58. package/lib/commonjs/hooks.js.map +0 -1
  59. package/lib/module/hooks.js.map +0 -1
@@ -2,15 +2,26 @@ package com.reactnativekeyboardcontroller.extensions
2
2
 
3
3
  import android.util.Log
4
4
  import android.view.View
5
+ import android.view.ViewGroup
5
6
  import com.facebook.react.bridge.WritableMap
6
7
  import com.facebook.react.uimanager.ThemedReactContext
7
8
  import com.facebook.react.uimanager.UIManagerHelper
8
9
  import com.facebook.react.uimanager.events.Event
9
10
  import com.facebook.react.uimanager.events.EventDispatcher
11
+ import com.reactnativekeyboardcontroller.listeners.WindowDimensionListener
10
12
 
11
13
  val ThemedReactContext.rootView: View?
12
14
  get() = this.currentActivity?.window?.decorView?.rootView
13
15
 
16
+ val ThemedReactContext.content: ViewGroup?
17
+ get() = this.currentActivity?.window?.decorView?.rootView?.findViewById(
18
+ androidx.appcompat.R.id.action_bar_root,
19
+ )
20
+
21
+ fun ThemedReactContext.setupWindowDimensionsListener() {
22
+ WindowDimensionListener(this)
23
+ }
24
+
14
25
  fun ThemedReactContext?.dispatchEvent(viewId: Int, event: Event<*>) {
15
26
  val eventDispatcher: EventDispatcher? =
16
27
  UIManagerHelper.getEventDispatcherForReactTag(this, viewId)
@@ -32,6 +32,7 @@ class KeyboardAnimationCallback(
32
32
  val deferredInsetTypes: Int,
33
33
  dispatchMode: Int = DISPATCH_MODE_STOP,
34
34
  val context: ThemedReactContext?,
35
+ val hasTranslucentNavigationBar: Boolean = false,
35
36
  ) : WindowInsetsAnimationCompat.Callback(dispatchMode), OnApplyWindowInsetsListener {
36
37
  private val surfaceId = UIManagerHelper.getSurfaceId(view)
37
38
 
@@ -205,10 +206,13 @@ class KeyboardAnimationCallback(
205
206
  // First we get the insets which are potentially deferred
206
207
  val typesInset = insets.getInsets(deferredInsetTypes)
207
208
  // Then we get the persistent inset types which are applied as padding during layout
208
- val otherInset = insets.getInsets(persistentInsetTypes)
209
+ var otherInset = insets.getInsets(persistentInsetTypes)
209
210
 
210
211
  // Now that we subtract the two insets, to calculate the difference. We also coerce
211
212
  // the insets to be >= 0, to make sure we don't use negative insets.
213
+ if (hasTranslucentNavigationBar) {
214
+ otherInset = Insets.NONE
215
+ }
212
216
  val diff = Insets.subtract(typesInset, otherInset).let {
213
217
  Insets.max(it, Insets.NONE)
214
218
  }
@@ -358,7 +362,12 @@ class KeyboardAnimationCallback(
358
362
  private fun getCurrentKeyboardHeight(): Double {
359
363
  val insets = ViewCompat.getRootWindowInsets(view)
360
364
  val keyboardHeight = insets?.getInsets(WindowInsetsCompat.Type.ime())?.bottom ?: 0
361
- val navigationBar = insets?.getInsets(WindowInsetsCompat.Type.navigationBars())?.bottom ?: 0
365
+ val navigationBar =
366
+ if (hasTranslucentNavigationBar) {
367
+ 0
368
+ } else {
369
+ insets?.getInsets(WindowInsetsCompat.Type.navigationBars())?.bottom ?: 0
370
+ }
362
371
 
363
372
  // on hide it will be negative value, so we are using max function
364
373
  return (keyboardHeight - navigationBar).toFloat().dp.coerceAtLeast(0.0)
@@ -0,0 +1,57 @@
1
+ package com.reactnativekeyboardcontroller.listeners
2
+
3
+ import android.view.ViewGroup
4
+ import androidx.core.view.marginTop
5
+ import com.facebook.react.bridge.Arguments
6
+ import com.facebook.react.uimanager.ThemedReactContext
7
+ import com.reactnativekeyboardcontroller.extensions.content
8
+ import com.reactnativekeyboardcontroller.extensions.dp
9
+ import com.reactnativekeyboardcontroller.extensions.emitEvent
10
+
11
+ data class Dimensions(val width: Double, val height: Double)
12
+
13
+ class WindowDimensionListener(private val context: ThemedReactContext?) {
14
+ private var lastDispatchedDimensions = Dimensions(0.0, 0.0)
15
+
16
+ init {
17
+ // attach to content view only once
18
+ if (!isListenerAttached) {
19
+ isListenerAttached = true
20
+
21
+ val content = context?.content
22
+
23
+ updateWindowDimensions(content)
24
+
25
+ content?.viewTreeObserver?.addOnGlobalLayoutListener {
26
+ updateWindowDimensions(content)
27
+ }
28
+ }
29
+ }
30
+
31
+ private fun updateWindowDimensions(content: ViewGroup?) {
32
+ if (content == null) {
33
+ return
34
+ }
35
+
36
+ val newDimensions = Dimensions(
37
+ content.width.toFloat().dp,
38
+ content.height.toFloat().dp + content.marginTop.toFloat().dp,
39
+ )
40
+
41
+ if (newDimensions != lastDispatchedDimensions) {
42
+ lastDispatchedDimensions = newDimensions
43
+
44
+ context.emitEvent(
45
+ "KeyboardController::windowDidResize",
46
+ Arguments.createMap().apply {
47
+ putDouble("height", newDimensions.height)
48
+ putDouble("width", newDimensions.width)
49
+ },
50
+ )
51
+ }
52
+ }
53
+
54
+ companion object {
55
+ private var isListenerAttached = false
56
+ }
57
+ }
@@ -5,16 +5,17 @@ import android.os.Handler
5
5
  import android.os.Looper
6
6
  import android.util.Log
7
7
  import android.widget.FrameLayout
8
- import androidx.appcompat.widget.FitWindowsLinearLayout
9
8
  import androidx.core.view.ViewCompat
10
9
  import androidx.core.view.WindowCompat
11
10
  import androidx.core.view.WindowInsetsAnimationCompat
12
11
  import androidx.core.view.WindowInsetsCompat
13
12
  import com.facebook.react.uimanager.ThemedReactContext
14
13
  import com.facebook.react.views.view.ReactViewGroup
14
+ import com.reactnativekeyboardcontroller.extensions.content
15
15
  import com.reactnativekeyboardcontroller.extensions.removeSelf
16
16
  import com.reactnativekeyboardcontroller.extensions.requestApplyInsetsWhenAttached
17
17
  import com.reactnativekeyboardcontroller.extensions.rootView
18
+ import com.reactnativekeyboardcontroller.extensions.setupWindowDimensionsListener
18
19
  import com.reactnativekeyboardcontroller.listeners.KeyboardAnimationCallback
19
20
 
20
21
  private val TAG = EdgeToEdgeReactViewGroup::class.qualifiedName
@@ -32,6 +33,10 @@ class EdgeToEdgeReactViewGroup(private val reactContext: ThemedReactContext) : R
32
33
  private var wasMounted = false
33
34
  private var callback: KeyboardAnimationCallback? = null
34
35
 
36
+ init {
37
+ reactContext.setupWindowDimensionsListener()
38
+ }
39
+
35
40
  // region View life cycles
36
41
  override fun onAttachedToWindow() {
37
42
  super.onAttachedToWindow()
@@ -57,7 +62,7 @@ class EdgeToEdgeReactViewGroup(private val reactContext: ThemedReactContext) : R
57
62
  val rootView = reactContext.rootView
58
63
  if (rootView != null) {
59
64
  ViewCompat.setOnApplyWindowInsetsListener(rootView) { v, insets ->
60
- val content = getContentView()
65
+ val content = reactContext.content
61
66
  val params = FrameLayout.LayoutParams(
62
67
  FrameLayout.LayoutParams.MATCH_PARENT,
63
68
  FrameLayout.LayoutParams.MATCH_PARENT,
@@ -112,7 +117,7 @@ class EdgeToEdgeReactViewGroup(private val reactContext: ThemedReactContext) : R
112
117
 
113
118
  if (activity != null) {
114
119
  eventView = ReactViewGroup(context)
115
- val root = this.getContentView()
120
+ val root = reactContext.content
116
121
  root?.addView(eventView)
117
122
 
118
123
  callback = KeyboardAnimationCallback(
@@ -121,6 +126,7 @@ class EdgeToEdgeReactViewGroup(private val reactContext: ThemedReactContext) : R
121
126
  deferredInsetTypes = WindowInsetsCompat.Type.ime(),
122
127
  dispatchMode = WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_CONTINUE_ON_SUBTREE,
123
128
  context = reactContext,
129
+ hasTranslucentNavigationBar = isNavigationBarTranslucent,
124
130
  )
125
131
 
126
132
  eventView?.let {
@@ -147,12 +153,6 @@ class EdgeToEdgeReactViewGroup(private val reactContext: ThemedReactContext) : R
147
153
  // for more details
148
154
  Handler(Looper.getMainLooper()).post { view.removeSelf() }
149
155
  }
150
-
151
- private fun getContentView(): FitWindowsLinearLayout? {
152
- return reactContext.currentActivity?.window?.decorView?.rootView?.findViewById(
153
- androidx.appcompat.R.id.action_bar_root,
154
- )
155
- }
156
156
  // endregion
157
157
 
158
158
  // region State managers
@@ -10,27 +10,24 @@ import Foundation
10
10
  import UIKit
11
11
 
12
12
  enum KeyboardView {
13
- // https://stackoverflow.com/questions/32598490/show-uiview-with-buttons-over-keyboard-like-in-skype-viber-messengers-swift-i
13
+ // inspired by https://stackoverflow.com/questions/32598490/show-uiview-with-buttons-over-keyboard-like-in-skype-viber-messengers-swift-i
14
14
  static func find() -> UIView? {
15
- var result: UIView?
16
-
17
15
  let windows = UIApplication.shared.windows
18
16
  for window in windows {
19
17
  if window.description.hasPrefix("<UITextEffectsWindow") {
20
18
  for subview in window.subviews {
21
19
  if subview.description.hasPrefix("<UIInputSetContainerView") {
22
20
  for hostView in subview.subviews {
23
- if hostView.description.hasPrefix("<UIInputSetHostView") {
24
- result = hostView
25
- break
21
+ if hostView.description.hasPrefix("<UIInputSetHostView"), hostView.frame.height != 0 {
22
+ return hostView
26
23
  }
27
24
  }
28
25
  break
29
26
  }
30
27
  }
31
- break
32
28
  }
33
29
  }
34
- return result
30
+
31
+ return nil
35
32
  }
36
33
  }
package/jest/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Animated, ScrollView, View } from "react-native";
1
+ import { Animated, ScrollView, View, useWindowDimensions } from "react-native";
2
2
 
3
3
  const values = {
4
4
  animated: {
@@ -43,6 +43,8 @@ const mock = {
43
43
  useKeyboardController: jest
44
44
  .fn()
45
45
  .mockReturnValue({ setEnabled: jest.fn(), enabled: true }),
46
+ // internal
47
+ useWindowDimensions,
46
48
  // modules
47
49
  KeyboardController: {
48
50
  setInputMode: jest.fn(),
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardController = exports.FocusedInputEvents = void 0;
6
+ exports.WindowDimensionsEvents = exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardController = exports.FocusedInputEvents = void 0;
7
7
  var _reactNative = require("react-native");
8
8
  const NOOP = () => {};
9
9
  const KeyboardController = exports.KeyboardController = {
@@ -28,6 +28,11 @@ const FocusedInputEvents = exports.FocusedInputEvents = {
28
28
  remove: NOOP
29
29
  })
30
30
  };
31
+ const WindowDimensionsEvents = exports.WindowDimensionsEvents = {
32
+ addListener: () => ({
33
+ remove: NOOP
34
+ })
35
+ };
31
36
  const KeyboardControllerView = exports.KeyboardControllerView = _reactNative.View;
32
37
  const KeyboardGestureArea = exports.KeyboardGestureArea = _reactNative.View;
33
38
  //# sourceMappingURL=bindings.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","NOOP","KeyboardController","exports","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","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} 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 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;AAWA,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,sBAAsB,GAAAV,OAAA,CAAAU,sBAAA,GACjCC,iBAAoD;AAC/C,MAAMC,mBAAmB,GAAAZ,OAAA,CAAAY,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 = () => {};\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":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardController = exports.FocusedInputEvents = void 0;
6
+ exports.WindowDimensionsEvents = exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardController = exports.FocusedInputEvents = void 0;
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",
@@ -27,6 +27,9 @@ const KeyboardEvents = exports.KeyboardEvents = {
27
27
  const FocusedInputEvents = exports.FocusedInputEvents = {
28
28
  addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
29
29
  };
30
+ const WindowDimensionsEvents = exports.WindowDimensionsEvents = {
31
+ addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
32
+ };
30
33
  const KeyboardControllerView = exports.KeyboardControllerView = require("./specs/KeyboardControllerViewNativeComponent").default;
31
34
  const KeyboardGestureArea = exports.KeyboardGestureArea = _reactNative.Platform.OS === "android" && _reactNative.Platform.Version >= 30 ? require("./specs/KeyboardGestureAreaNativeComponent").default : ({
32
35
  children
@@ -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","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} 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 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;AAUA,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,sBAAyD,GAAAZ,OAAA,CAAAY,sBAAA,GACpEpB,OAAO,CAAC,+CAA+C,CAAC,CAACK,OAAO;AAC3D,MAAMgB,mBAAuD,GAAAb,OAAA,CAAAa,mBAAA,GAClEnB,qBAAQ,CAACoB,EAAE,KAAK,SAAS,IAAIpB,qBAAQ,CAACqB,OAAO,IAAI,EAAE,GAC/CvB,OAAO,CAAC,4CAA4C,CAAC,CAACK,OAAO,GAC7D,CAAC;EAAEmB;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;\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":[]}
@@ -7,6 +7,7 @@ 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 _reactNativeKeyboardController = require("react-native-keyboard-controller");
10
11
  var _hooks = require("./hooks");
11
12
  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); }
12
13
  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; }
@@ -37,7 +38,7 @@ const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)(({
37
38
  const keyboard = (0, _hooks.useKeyboardAnimation)();
38
39
  const {
39
40
  height: screenHeight
40
- } = (0, _reactNative.useWindowDimensions)();
41
+ } = (0, _reactNativeKeyboardController.useWindowDimensions)();
41
42
  const relativeKeyboardHeight = (0, _react.useCallback)(() => {
42
43
  "worklet";
43
44
 
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_hooks","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","defaultLayout","x","y","width","height","KeyboardAvoidingView","forwardRef","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","ref","initialFrame","useSharedValue","frame","useDerivedValue","value","keyboard","useKeyboardAnimation","screenHeight","useWindowDimensions","relativeKeyboardHeight","useCallback","keyboardY","heightWhenOpened","Math","max","onLayoutWorklet","layout","isClosed","runOnUI","nativeEvent","animatedStyle","useAnimatedStyle","bottom","interpolate","progress","bottomHeight","flex","paddingBottom","isPositionBehavior","containerStyle","combinedStyles","useMemo","createElement","View","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { View, useWindowDimensions } from \"react-native\";\nimport Reanimated, {\n interpolate,\n runOnUI,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { useKeyboardAnimation } from \"./hooks\";\n\nimport type { LayoutRectangle, ViewProps } from \"react-native\";\n\nexport type KeyboardAvoidingViewProps = {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"height\" | \"position\" | \"padding\";\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps[\"style\"];\n\n /**\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\n * This is useful when more than one is on the screen. Defaults to true.\n */\n enabled?: boolean;\n\n /**\n * Distance between the top of the user screen and the React Native view. This\n * may be non-zero in some cases. Defaults to 0.\n */\n keyboardVerticalOffset?: number;\n} & ViewProps;\n\nconst defaultLayout: LayoutRectangle = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n};\n\n/**\n * View that moves out of the way when the keyboard appears by automatically\n * adjusting its height, position, or bottom padding.\n */\nconst KeyboardAvoidingView = forwardRef<\n View,\n React.PropsWithChildren<KeyboardAvoidingViewProps>\n>(\n (\n {\n behavior,\n children,\n contentContainerStyle,\n enabled = true,\n keyboardVerticalOffset = 0,\n style,\n onLayout: onLayoutProps,\n ...props\n },\n ref,\n ) => {\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\n\n const keyboard = useKeyboardAnimation();\n const { height: screenHeight } = useWindowDimensions();\n\n const relativeKeyboardHeight = useCallback(() => {\n \"worklet\";\n\n const keyboardY =\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\n\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\n }, [screenHeight, keyboardVerticalOffset]);\n\n const onLayoutWorklet = useCallback((layout: LayoutRectangle) => {\n \"worklet\";\n\n if (keyboard.isClosed.value || initialFrame.value === null) {\n initialFrame.value = layout;\n }\n }, []);\n const onLayout = useCallback<NonNullable<ViewProps[\"onLayout\"]>>(\n (e) => {\n runOnUI(onLayoutWorklet)(e.nativeEvent.layout);\n onLayoutProps?.(e);\n },\n [onLayoutProps],\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n const bottom = interpolate(\n keyboard.progress.value,\n [0, 1],\n [0, relativeKeyboardHeight()],\n );\n const bottomHeight = enabled ? bottom : 0;\n\n switch (behavior) {\n case \"height\":\n if (!keyboard.isClosed.value) {\n return {\n height: frame.value.height - bottomHeight,\n flex: 0,\n };\n }\n\n return {};\n\n case \"position\":\n return { bottom: bottomHeight };\n\n case \"padding\":\n return { paddingBottom: bottomHeight };\n\n default:\n return {};\n }\n }, [behavior, enabled, relativeKeyboardHeight]);\n const isPositionBehavior = behavior === \"position\";\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\n const combinedStyles = useMemo(\n () => [containerStyle, animatedStyle],\n [containerStyle, animatedStyle],\n );\n\n if (isPositionBehavior) {\n return (\n <View ref={ref} style={style} onLayout={onLayout} {...props}>\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\n </View>\n );\n }\n\n return (\n <Reanimated.View\n ref={ref}\n onLayout={onLayout}\n style={combinedStyles}\n {...props}\n >\n {children}\n </Reanimated.View>\n );\n },\n);\n\nexport default KeyboardAvoidingView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAQA,IAAAG,MAAA,GAAAH,OAAA;AAA+C,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,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AU;EAClD,MAAMuC,cAAc,GAAGD,kBAAkB,GAAGpC,qBAAqB,GAAGG,KAAK;EACzE,MAAMmC,cAAc,GAAG,IAAAC,cAAO,EAC5B,MAAM,CAACF,cAAc,EAAET,aAAa,CAAC,EACrC,CAACS,cAAc,EAAET,aAAa,CAChC,CAAC;EAED,IAAIQ,kBAAkB,EAAE;IACtB,oBACEjF,MAAA,CAAAY,OAAA,CAAAyE,aAAA,CAAClF,YAAA,CAAAmF,IAAI,EAAA3D,QAAA;MAACyB,GAAG,EAAEA,GAAI;MAACJ,KAAK,EAAEA,KAAM;MAACC,QAAQ,EAAEA;IAAS,GAAKE,KAAK,gBACzDnD,MAAA,CAAAY,OAAA,CAAAyE,aAAA,CAACjF,sBAAA,CAAAQ,OAAU,CAAC0E,IAAI;MAACtC,KAAK,EAAEmC;IAAe,GAAEvC,QAA0B,CAC/D,CAAC;EAEX;EAEA,oBACE5C,MAAA,CAAAY,OAAA,CAAAyE,aAAA,CAACjF,sBAAA,CAAAQ,OAAU,CAAC0E,IAAI,EAAA3D,QAAA;IACdyB,GAAG,EAAEA,GAAI;IACTH,QAAQ,EAAEA,QAAS;IACnBD,KAAK,EAAEmC;EAAe,GAClBhC,KAAK,GAERP,QACc,CAAC;AAEtB,CACF,CAAC;AAAC,IAAA2C,QAAA,GAAAC,OAAA,CAAA5E,OAAA,GAEa6B,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_reactNativeKeyboardController","_hooks","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","defaultLayout","x","y","width","height","KeyboardAvoidingView","forwardRef","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","ref","initialFrame","useSharedValue","frame","useDerivedValue","value","keyboard","useKeyboardAnimation","screenHeight","useWindowDimensions","relativeKeyboardHeight","useCallback","keyboardY","heightWhenOpened","Math","max","onLayoutWorklet","layout","isClosed","runOnUI","nativeEvent","animatedStyle","useAnimatedStyle","bottom","interpolate","progress","bottomHeight","flex","paddingBottom","isPositionBehavior","containerStyle","combinedStyles","useMemo","createElement","View","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { View } from \"react-native\";\nimport Reanimated, {\n interpolate,\n runOnUI,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { useWindowDimensions } from \"react-native-keyboard-controller\";\n\nimport { useKeyboardAnimation } from \"./hooks\";\n\nimport type { LayoutRectangle, ViewProps } from \"react-native\";\n\nexport type KeyboardAvoidingViewProps = {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"height\" | \"position\" | \"padding\";\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps[\"style\"];\n\n /**\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\n * This is useful when more than one is on the screen. Defaults to true.\n */\n enabled?: boolean;\n\n /**\n * Distance between the top of the user screen and the React Native view. This\n * may be non-zero in some cases. Defaults to 0.\n */\n keyboardVerticalOffset?: number;\n} & ViewProps;\n\nconst defaultLayout: LayoutRectangle = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n};\n\n/**\n * View that moves out of the way when the keyboard appears by automatically\n * adjusting its height, position, or bottom padding.\n */\nconst KeyboardAvoidingView = forwardRef<\n View,\n React.PropsWithChildren<KeyboardAvoidingViewProps>\n>(\n (\n {\n behavior,\n children,\n contentContainerStyle,\n enabled = true,\n keyboardVerticalOffset = 0,\n style,\n onLayout: onLayoutProps,\n ...props\n },\n ref,\n ) => {\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\n\n const keyboard = useKeyboardAnimation();\n const { height: screenHeight } = useWindowDimensions();\n\n const relativeKeyboardHeight = useCallback(() => {\n \"worklet\";\n\n const keyboardY =\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\n\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\n }, [screenHeight, keyboardVerticalOffset]);\n\n const onLayoutWorklet = useCallback((layout: LayoutRectangle) => {\n \"worklet\";\n\n if (keyboard.isClosed.value || initialFrame.value === null) {\n initialFrame.value = layout;\n }\n }, []);\n const onLayout = useCallback<NonNullable<ViewProps[\"onLayout\"]>>(\n (e) => {\n runOnUI(onLayoutWorklet)(e.nativeEvent.layout);\n onLayoutProps?.(e);\n },\n [onLayoutProps],\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n const bottom = interpolate(\n keyboard.progress.value,\n [0, 1],\n [0, relativeKeyboardHeight()],\n );\n const bottomHeight = enabled ? bottom : 0;\n\n switch (behavior) {\n case \"height\":\n if (!keyboard.isClosed.value) {\n return {\n height: frame.value.height - bottomHeight,\n flex: 0,\n };\n }\n\n return {};\n\n case \"position\":\n return { bottom: bottomHeight };\n\n case \"padding\":\n return { paddingBottom: bottomHeight };\n\n default:\n return {};\n }\n }, [behavior, enabled, relativeKeyboardHeight]);\n const isPositionBehavior = behavior === \"position\";\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\n const combinedStyles = useMemo(\n () => [containerStyle, animatedStyle],\n [containerStyle, animatedStyle],\n );\n\n if (isPositionBehavior) {\n return (\n <View ref={ref} style={style} onLayout={onLayout} {...props}>\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\n </View>\n );\n }\n\n return (\n <Reanimated.View\n ref={ref}\n onLayout={onLayout}\n style={combinedStyles}\n {...props}\n >\n {children}\n </Reanimated.View>\n );\n },\n);\n\nexport default KeyboardAvoidingView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAA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O;UAAEJ,MAAM,EAAEG;QAAa,CAAC;MAEjC,KAAK,SAAS;QACZ,OAAO;UAAEE,aAAa,EAAEF;QAAa,CAAC;MAExC;QACE,OAAO,CAAC,CAAC;IACb;EACF,CAAC,EAAE,CAACnC,QAAQ,EAAEG,OAAO,EAAEgB,sBAAsB,CAAC,CAAC;EAC/C,MAAMmB,kBAAkB,GAAGtC,QAAQ,KAAK,UAAU;EAClD,MAAMuC,cAAc,GAAGD,kBAAkB,GAAGpC,qBAAqB,GAAGG,KAAK;EACzE,MAAMmC,cAAc,GAAG,IAAAC,cAAO,EAC5B,MAAM,CAACF,cAAc,EAAET,aAAa,CAAC,EACrC,CAACS,cAAc,EAAET,aAAa,CAChC,CAAC;EAED,IAAIQ,kBAAkB,EAAE;IACtB,oBACElF,MAAA,CAAAa,OAAA,CAAAyE,aAAA,CAACnF,YAAA,CAAAoF,IAAI,EAAA3D,QAAA;MAACyB,GAAG,EAAEA,GAAI;MAACJ,KAAK,EAAEA,KAAM;MAACC,QAAQ,EAAEA;IAAS,GAAKE,KAAK,gBACzDpD,MAAA,CAAAa,OAAA,CAAAyE,aAAA,CAAClF,sBAAA,CAAAS,OAAU,CAAC0E,IAAI;MAACtC,KAAK,EAAEmC;IAAe,GAAEvC,QAA0B,CAC/D,CAAC;EAEX;EAEA,oBACE7C,MAAA,CAAAa,OAAA,CAAAyE,aAAA,CAAClF,sBAAA,CAAAS,OAAU,CAAC0E,IAAI,EAAA3D,QAAA;IACdyB,GAAG,EAAEA,GAAI;IACTH,QAAQ,EAAEA,QAAS;IACnBD,KAAK,EAAEmC;EAAe,GAClBhC,KAAK,GAERP,QACc,CAAC;AAEtB,CACF,CAAC;AAAC,IAAA2C,QAAA,GAAAC,OAAA,CAAA5E,OAAA,GAEa6B,oBAAoB","ignoreList":[]}
@@ -77,7 +77,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
77
77
  const layout = (0, _reactNativeReanimated.useSharedValue)(null);
78
78
  const {
79
79
  height
80
- } = (0, _reactNative.useWindowDimensions)();
80
+ } = (0, _reactNativeKeyboardController.useWindowDimensions)();
81
81
  const onScroll = (0, _react.useCallback)(event => {
82
82
  position.value = event.nativeEvent.contentOffset.y;
83
83
  onScrollProps === null || onScrollProps === void 0 || onScrollProps(event);
@@ -115,7 +115,8 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
115
115
  const inputHeight = ((_layout$value3 = layout.value) === null || _layout$value3 === void 0 ? void 0 : _layout$value3.layout.height) || 0;
116
116
  const point = absoluteY + inputHeight;
117
117
  if (visibleRect - point <= bottomOffset) {
118
- const interpolatedScrollTo = (0, _reactNativeReanimated.interpolate)(e, [initialKeyboardSize.value, keyboardHeight.value], [0, keyboardHeight.value - (height - point) + bottomOffset]);
118
+ const relativeScrollTo = keyboardHeight.value - (height - point) + bottomOffset;
119
+ const interpolatedScrollTo = (0, _reactNativeReanimated.interpolate)(e, [initialKeyboardSize.value, keyboardHeight.value], [0, (0, _utils.scrollDistanceWithRespectToSnapPoints)(relativeScrollTo + scrollPosition.value, rest.snapToOffsets) - scrollPosition.value]);
119
120
  const targetScrollY = Math.max(interpolatedScrollTo, 0) + scrollPosition.value;
120
121
  (0, _reactNativeReanimated.scrollTo)(scrollViewAnimatedRef, 0, targetScrollY, animated);
121
122
  return interpolatedScrollTo;
@@ -126,7 +127,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
126
127
  (0, _reactNativeReanimated.scrollTo)(scrollViewAnimatedRef, 0, topOfScreen - positionOnScreen, animated);
127
128
  }
128
129
  return 0;
129
- }, [bottomOffset, enabled]);
130
+ }, [bottomOffset, enabled, rest.snapToOffsets]);
130
131
  const onChangeText = (0, _react.useCallback)(() => {
131
132
  "worklet";
132
133
 
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_reactNativeKeyboardController","_useSmoothKeyboardHandler","_utils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","KeyboardAwareScrollView","forwardRef","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","onScroll","onScrollProps","extraKeyboardSpace","rest","ref","scrollViewAnimatedRef","useAnimatedRef","scrollViewTarget","useSharedValue","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","useReanimatedFocusedInput","layout","height","useWindowDimensions","useCallback","event","value","nativeEvent","contentOffset","y","onRef","assignedRef","current","onScrollViewLayout","findNodeHandle","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","interpolatedScrollTo","interpolate","targetScrollY","Math","max","scrollTo","positionOnScreen","topOfScreen","onChangeText","_layout$value4","_input$value","prevScrollPosition","prevLayout","onChangeTextHandler","useMemo","debounce","useFocusedInputHandler","useSmoothKeyboardHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","onMove","keyboardFrame","onEnd","useAnimatedReaction","previous","view","useAnimatedStyle","paddingBottom","createElement","ScrollView","scrollEventThrottle","View","style","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { findNodeHandle, useWindowDimensions } from \"react-native\";\nimport Reanimated, {\n interpolate,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedStyle,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n} from \"react-native-keyboard-controller\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce } from \"./utils\";\n\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type { FocusedInputLayoutChangedEvent } from \"react-native-keyboard-controller\";\n\nexport type KeyboardAwareScrollViewProps = {\n /** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */\n bottomOffset?: number;\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\n disableScrollOnKeyboardHide?: boolean;\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */\n enabled?: boolean;\n /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */\n extraKeyboardSpace?: number;\n} & ScrollViewProps;\n\n/*\n * Everything begins from `onStart` handler. This handler is called every time,\n * when keyboard changes its size or when focused `TextInput` was changed. In\n * this handler we are calculating/memoizing values which later will be used\n * during layout movement. For that we calculate:\n * - layout of focused field (`layout`) - to understand whether there will be overlap\n * - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n * - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n * - current scroll position (`scrollPosition`) - used to scroll from this point\n *\n * Once we've calculated all necessary variables - we can actually start to use them.\n * It happens in `onMove` handler - this function simply calls `maybeScroll` with\n * current keyboard frame height. This functions makes the smooth transition.\n *\n * When the transition has finished we go to `onEnd` handler. In this handler\n * we verify, that the current field is not overlapped within a keyboard frame.\n * For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n * however there could be some cases, when `onMove` is not called:\n * - on iOS when TextInput was changed - keyboard transition is instant\n * - on Android when TextInput was changed and keyboard size wasn't changed\n * So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n *\n * ====================================================================================================================+\n * -----------------------------------------------------Flow chart-----------------------------------------------------+\n * ====================================================================================================================+\n *\n * +============================+ +============================+ +==================================+\n * + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n * + + + (run `onStart`) + + `onMove` is getting called +\n * +============================+ +============================+ +==================================+\n *\n *\n * +============================+ +============================+ +=====================================+\n * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n * +============================+ +============================+ +=====================================+\n *\n */\nconst KeyboardAwareScrollView = forwardRef<\n ScrollView,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n onScroll: onScrollProps,\n extraKeyboardSpace = 0,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const position = useSharedValue(0);\n const currentKeyboardFrameHeight = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const keyboardWillAppear = useSharedValue(false);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onScroll = useCallback<NonNullable<ScrollViewProps[\"onScroll\"]>>(\n (event) => {\n position.value = event.nativeEvent.contentOffset.y;\n\n onScrollProps?.(event);\n },\n [onScrollProps],\n );\n\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\n if (typeof ref === \"function\") {\n ref(assignedRef);\n } else if (ref) {\n ref.current = assignedRef;\n }\n\n scrollViewAnimatedRef(assignedRef);\n }, []);\n const onScrollViewLayout = useCallback(\n (e: LayoutChangeEvent) => {\n scrollViewTarget.value = findNodeHandle(scrollViewAnimatedRef.current);\n\n onLayout?.(e);\n },\n [onLayout],\n );\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n \"worklet\";\n\n if (!enabled) {\n return 0;\n }\n\n // input belongs to ScrollView\n if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {\n return 0;\n }\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [0, keyboardHeight.value - (height - point) + bottomOffset],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (absoluteY < 0) {\n const positionOnScreen = visibleRect - inputHeight - bottomOffset;\n const topOfScreen = scrollPosition.value + absoluteY;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled],\n );\n\n const onChangeText = useCallback(() => {\n \"worklet\";\n\n // if typing a text caused layout shift, then we need to ignore this handler\n // because this event will be handled in `useAnimatedReaction` below\n if (layout.value?.layout.height !== input.value?.layout.height) {\n return;\n }\n\n const prevScrollPosition = scrollPosition.value;\n const prevLayout = layout.value;\n\n scrollPosition.value = position.value;\n layout.value = input.value;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScrollPosition;\n layout.value = prevLayout;\n }, [maybeScroll]);\n\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n\n useFocusedInputHandler(\n {\n onChangeText: onChangeTextHandler,\n },\n [onChangeTextHandler],\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) ||\n keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n }\n\n if (\n keyboardWillAppear.value ||\n keyboardWillChangeSize ||\n focusWasChanged\n ) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n\n // save position of focused text input when keyboard starts to move\n layout.value = input.value;\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && !keyboardWillAppear.value) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n const keyboardFrame = interpolate(\n e.height,\n [0, keyboardHeight.value],\n [0, keyboardHeight.value + extraKeyboardSpace],\n );\n currentKeyboardFrameHeight.value = keyboardFrame;\n\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\n if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\n maybeScroll(e.height);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n },\n },\n [height, maybeScroll, disableScrollOnKeyboardHide, extraKeyboardSpace],\n );\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n const prevLayout = layout.value;\n\n layout.value = input.value;\n scrollPosition.value += maybeScroll(keyboardHeight.value, true);\n layout.value = prevLayout;\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () =>\n enabled\n ? {\n // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\n // re-calculation on every animation frame and it helps to achieve smooth animation.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n paddingBottom: currentKeyboardFrameHeight.value + 1,\n }\n : {},\n [enabled],\n );\n\n return (\n <Reanimated.ScrollView\n ref={onRef}\n {...rest}\n onLayout={onScrollViewLayout}\n onScroll={onScroll}\n scrollEventThrottle={16}\n >\n {children}\n <Reanimated.View style={view} />\n </Reanimated.ScrollView>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AASA,IAAAG,8BAAA,GAAAH,OAAA;AAKA,IAAAI,yBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAmC,SAAAM,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,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,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CAAA9G,OAAA,GAEawB,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_reactNativeKeyboardController","_useSmoothKeyboardHandler","_utils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","KeyboardAwareScrollView","forwardRef","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","onScroll","onScrollProps","extraKeyboardSpace","rest","ref","scrollViewAnimatedRef","useAnimatedRef","scrollViewTarget","useSharedValue","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","useReanimatedFocusedInput","layout","height","useWindowDimensions","useCallback","event","value","nativeEvent","contentOffset","y","onRef","assignedRef","current","onScrollViewLayout","findNodeHandle","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","interpolate","scrollDistanceWithRespectToSnapPoints","snapToOffsets","targetScrollY","Math","max","scrollTo","positionOnScreen","topOfScreen","onChangeText","_layout$value4","_input$value","prevScrollPosition","prevLayout","onChangeTextHandler","useMemo","debounce","useFocusedInputHandler","useSmoothKeyboardHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","onMove","keyboardFrame","onEnd","useAnimatedReaction","previous","view","useAnimatedStyle","paddingBottom","createElement","ScrollView","scrollEventThrottle","View","style","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { findNodeHandle } from \"react-native\";\nimport Reanimated, {\n interpolate,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedStyle,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n useWindowDimensions,\n} from \"react-native-keyboard-controller\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce, scrollDistanceWithRespectToSnapPoints } from \"./utils\";\n\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type { FocusedInputLayoutChangedEvent } from \"react-native-keyboard-controller\";\n\nexport type KeyboardAwareScrollViewProps = {\n /** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */\n bottomOffset?: number;\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\n disableScrollOnKeyboardHide?: boolean;\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */\n enabled?: boolean;\n /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */\n extraKeyboardSpace?: number;\n} & ScrollViewProps;\n\n/*\n * Everything begins from `onStart` handler. This handler is called every time,\n * when keyboard changes its size or when focused `TextInput` was changed. In\n * this handler we are calculating/memoizing values which later will be used\n * during layout movement. For that we calculate:\n * - layout of focused field (`layout`) - to understand whether there will be overlap\n * - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n * - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n * - current scroll position (`scrollPosition`) - used to scroll from this point\n *\n * Once we've calculated all necessary variables - we can actually start to use them.\n * It happens in `onMove` handler - this function simply calls `maybeScroll` with\n * current keyboard frame height. This functions makes the smooth transition.\n *\n * When the transition has finished we go to `onEnd` handler. In this handler\n * we verify, that the current field is not overlapped within a keyboard frame.\n * For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n * however there could be some cases, when `onMove` is not called:\n * - on iOS when TextInput was changed - keyboard transition is instant\n * - on Android when TextInput was changed and keyboard size wasn't changed\n * So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n *\n * ====================================================================================================================+\n * -----------------------------------------------------Flow chart-----------------------------------------------------+\n * ====================================================================================================================+\n *\n * +============================+ +============================+ +==================================+\n * + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n * + + + (run `onStart`) + + `onMove` is getting called +\n * +============================+ +============================+ +==================================+\n *\n *\n * +============================+ +============================+ +=====================================+\n * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n * +============================+ +============================+ +=====================================+\n *\n */\nconst KeyboardAwareScrollView = forwardRef<\n ScrollView,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n onScroll: onScrollProps,\n extraKeyboardSpace = 0,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const position = useSharedValue(0);\n const currentKeyboardFrameHeight = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const keyboardWillAppear = useSharedValue(false);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onScroll = useCallback<NonNullable<ScrollViewProps[\"onScroll\"]>>(\n (event) => {\n position.value = event.nativeEvent.contentOffset.y;\n\n onScrollProps?.(event);\n },\n [onScrollProps],\n );\n\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\n if (typeof ref === \"function\") {\n ref(assignedRef);\n } else if (ref) {\n ref.current = assignedRef;\n }\n\n scrollViewAnimatedRef(assignedRef);\n }, []);\n const onScrollViewLayout = useCallback(\n (e: LayoutChangeEvent) => {\n scrollViewTarget.value = findNodeHandle(scrollViewAnimatedRef.current);\n\n onLayout?.(e);\n },\n [onLayout],\n );\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n \"worklet\";\n\n if (!enabled) {\n return 0;\n }\n\n // input belongs to ScrollView\n if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {\n return 0;\n }\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const relativeScrollTo =\n keyboardHeight.value - (height - point) + bottomOffset;\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [\n 0,\n scrollDistanceWithRespectToSnapPoints(\n relativeScrollTo + scrollPosition.value,\n rest.snapToOffsets,\n ) - scrollPosition.value,\n ],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (absoluteY < 0) {\n const positionOnScreen = visibleRect - inputHeight - bottomOffset;\n const topOfScreen = scrollPosition.value + absoluteY;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled, rest.snapToOffsets],\n );\n\n const onChangeText = useCallback(() => {\n \"worklet\";\n\n // if typing a text caused layout shift, then we need to ignore this handler\n // because this event will be handled in `useAnimatedReaction` below\n if (layout.value?.layout.height !== input.value?.layout.height) {\n return;\n }\n\n const prevScrollPosition = scrollPosition.value;\n const prevLayout = layout.value;\n\n scrollPosition.value = position.value;\n layout.value = input.value;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScrollPosition;\n layout.value = prevLayout;\n }, [maybeScroll]);\n\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n\n useFocusedInputHandler(\n {\n onChangeText: onChangeTextHandler,\n },\n [onChangeTextHandler],\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) ||\n keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n }\n\n if (\n keyboardWillAppear.value ||\n keyboardWillChangeSize ||\n focusWasChanged\n ) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n\n // save position of focused text input when keyboard starts to move\n layout.value = input.value;\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && !keyboardWillAppear.value) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n const keyboardFrame = interpolate(\n e.height,\n [0, keyboardHeight.value],\n [0, keyboardHeight.value + extraKeyboardSpace],\n );\n currentKeyboardFrameHeight.value = keyboardFrame;\n\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\n if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\n maybeScroll(e.height);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n },\n },\n [height, maybeScroll, disableScrollOnKeyboardHide, extraKeyboardSpace],\n );\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n const prevLayout = layout.value;\n\n layout.value = input.value;\n scrollPosition.value += maybeScroll(keyboardHeight.value, true);\n layout.value = prevLayout;\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () =>\n enabled\n ? {\n // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\n // re-calculation on every animation frame and it helps to achieve smooth animation.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n paddingBottom: currentKeyboardFrameHeight.value + 1,\n }\n : {},\n [enabled],\n );\n\n return (\n <Reanimated.ScrollView\n ref={onRef}\n {...rest}\n onLayout={onScrollViewLayout}\n onScroll={onScroll}\n scrollEventThrottle={16}\n >\n {children}\n <Reanimated.View style={view} />\n </Reanimated.ScrollView>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AASA,IAAAG,8BAAA,GAAAH,OAAA;AAMA,IAAAI,yBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAA0E,SAAAM,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,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAA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0BAA0B,CAACa,KAAK,GAAG;EACpD,CAAC,GACD,CAAC,CAAC,EACR,CAACzB,OAAO,CACV,CAAC;EAED,oBACE5C,MAAA,CAAAc,OAAA,CAAA2G,aAAA,CAACrH,sBAAA,CAAAU,OAAU,CAAC4G,UAAU,EAAA7F,QAAA;IACpBoB,GAAG,EAAEwB;EAAM,GACPzB,IAAI;IACRP,QAAQ,EAAEmC,kBAAmB;IAC7B/B,QAAQ,EAAEA,QAAS;IACnB8E,mBAAmB,EAAE;EAAG,IAEvBnF,QAAQ,eACTxC,MAAA,CAAAc,OAAA,CAAA2G,aAAA,CAACrH,sBAAA,CAAAU,OAAU,CAAC8G,IAAI;IAACC,KAAK,EAAEP;EAAK,CAAE,CACV,CAAC;AAE5B,CACF,CAAC;AAAC,IAAAQ,QAAA,GAAAC,OAAA,CAAAjH,OAAA,GAEawB,uBAAuB","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.debounce = void 0;
6
+ exports.scrollDistanceWithRespectToSnapPoints = exports.debounce = void 0;
7
7
  const debounce = (worklet, wait = 0) => {
8
8
  "worklet";
9
9
 
@@ -24,4 +24,14 @@ const debounce = (worklet, wait = 0) => {
24
24
  };
25
25
  };
26
26
  exports.debounce = debounce;
27
+ const scrollDistanceWithRespectToSnapPoints = (defaultScrollValue, snapPoints) => {
28
+ "worklet";
29
+
30
+ let snapPoint;
31
+ if (snapPoints) {
32
+ snapPoint = snapPoints.find(offset => offset >= defaultScrollValue);
33
+ }
34
+ return snapPoint ?? defaultScrollValue;
35
+ };
36
+ exports.scrollDistanceWithRespectToSnapPoints = scrollDistanceWithRespectToSnapPoints;
27
37
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["debounce","worklet","wait","value","time","args","t","Date","now","exports"],"sources":["utils.ts"],"sourcesContent":["export const debounce = <F extends (...args: Parameters<F>) => ReturnType<F>>(\n worklet: F,\n wait = 0,\n) => {\n \"worklet\";\n\n const value = {\n time: 0,\n };\n\n return (...args: Parameters<F>): ReturnType<F> | void => {\n \"worklet\";\n\n const t = Date.now();\n const now = t - value.time;\n\n if (now < wait) {\n value.time = t;\n return;\n }\n\n value.time = t;\n\n return worklet(...args);\n };\n};\n"],"mappings":";;;;;;AAAO,MAAMA,QAAQ,GAAGA,CACtBC,OAAU,EACVC,IAAI,GAAG,CAAC,KACL;EACH,SAAS;;EAET,MAAMC,KAAK,GAAG;IACZC,IAAI,EAAE;EACR,CAAC;EAED,OAAO,CAAC,GAAGC,IAAmB,KAA2B;IACvD,SAAS;;IAET,MAAMC,CAAC,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;IACpB,MAAMA,GAAG,GAAGF,CAAC,GAAGH,KAAK,CAACC,IAAI;IAE1B,IAAII,GAAG,GAAGN,IAAI,EAAE;MACdC,KAAK,CAACC,IAAI,GAAGE,CAAC;MACd;IACF;IAEAH,KAAK,CAACC,IAAI,GAAGE,CAAC;IAEd,OAAOL,OAAO,CAAC,GAAGI,IAAI,CAAC;EACzB,CAAC;AACH,CAAC;AAACI,OAAA,CAAAT,QAAA,GAAAA,QAAA","ignoreList":[]}
1
+ {"version":3,"names":["debounce","worklet","wait","value","time","args","t","Date","now","exports","scrollDistanceWithRespectToSnapPoints","defaultScrollValue","snapPoints","snapPoint","find","offset"],"sources":["utils.ts"],"sourcesContent":["export const debounce = <F extends (...args: Parameters<F>) => ReturnType<F>>(\n worklet: F,\n wait = 0,\n) => {\n \"worklet\";\n\n const value = {\n time: 0,\n };\n\n return (...args: Parameters<F>): ReturnType<F> | void => {\n \"worklet\";\n\n const t = Date.now();\n const now = t - value.time;\n\n if (now < wait) {\n value.time = t;\n return;\n }\n\n value.time = t;\n\n return worklet(...args);\n };\n};\n\nexport const scrollDistanceWithRespectToSnapPoints = (\n defaultScrollValue: number,\n snapPoints?: number[],\n) => {\n \"worklet\";\n\n let snapPoint: number | undefined;\n\n if (snapPoints) {\n snapPoint = snapPoints.find((offset) => offset >= defaultScrollValue);\n }\n\n return snapPoint ?? defaultScrollValue;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,QAAQ,GAAGA,CACtBC,OAAU,EACVC,IAAI,GAAG,CAAC,KACL;EACH,SAAS;;EAET,MAAMC,KAAK,GAAG;IACZC,IAAI,EAAE;EACR,CAAC;EAED,OAAO,CAAC,GAAGC,IAAmB,KAA2B;IACvD,SAAS;;IAET,MAAMC,CAAC,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;IACpB,MAAMA,GAAG,GAAGF,CAAC,GAAGH,KAAK,CAACC,IAAI;IAE1B,IAAII,GAAG,GAAGN,IAAI,EAAE;MACdC,KAAK,CAACC,IAAI,GAAGE,CAAC;MACd;IACF;IAEAH,KAAK,CAACC,IAAI,GAAGE,CAAC;IAEd,OAAOL,OAAO,CAAC,GAAGI,IAAI,CAAC;EACzB,CAAC;AACH,CAAC;AAACI,OAAA,CAAAT,QAAA,GAAAA,QAAA;AAEK,MAAMU,qCAAqC,GAAGA,CACnDC,kBAA0B,EAC1BC,UAAqB,KAClB;EACH,SAAS;;EAET,IAAIC,SAA6B;EAEjC,IAAID,UAAU,EAAE;IACdC,SAAS,GAAGD,UAAU,CAACE,IAAI,CAAEC,MAAM,IAAKA,MAAM,IAAIJ,kBAAkB,CAAC;EACvE;EAEA,OAAOE,SAAS,IAAIF,kBAAkB;AACxC,CAAC;AAACF,OAAA,CAAAC,qCAAA,GAAAA,qCAAA","ignoreList":[]}
@@ -3,6 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ useResizeMode: true,
8
+ useKeyboardAnimation: true,
9
+ useReanimatedKeyboardAnimation: true,
10
+ useGenericKeyboardHandler: true,
11
+ useKeyboardHandler: true,
12
+ useKeyboardController: true,
13
+ useReanimatedFocusedInput: true,
14
+ useFocusedInputHandler: true
15
+ };
6
16
  exports.useFocusedInputHandler = useFocusedInputHandler;
7
17
  exports.useGenericKeyboardHandler = useGenericKeyboardHandler;
8
18
  exports.useKeyboardAnimation = void 0;
@@ -11,10 +21,22 @@ exports.useKeyboardHandler = useKeyboardHandler;
11
21
  exports.useReanimatedFocusedInput = useReanimatedFocusedInput;
12
22
  exports.useResizeMode = exports.useReanimatedKeyboardAnimation = void 0;
13
23
  var _react = require("react");
14
- var _bindings = require("./bindings");
15
- var _constants = require("./constants");
16
- var _context = require("./context");
17
- var _utils = require("./utils");
24
+ var _bindings = require("../bindings");
25
+ var _constants = require("../constants");
26
+ var _context = require("../context");
27
+ var _utils = require("../utils");
28
+ var _useWindowDimensions = require("./useWindowDimensions");
29
+ Object.keys(_useWindowDimensions).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
32
+ if (key in exports && exports[key] === _useWindowDimensions[key]) return;
33
+ Object.defineProperty(exports, key, {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _useWindowDimensions[key];
37
+ }
38
+ });
39
+ });
18
40
  const useResizeMode = () => {
19
41
  (0, _react.useEffect)(() => {
20
42
  _bindings.KeyboardController.setInputMode(_constants.AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
@@ -79,4 +101,4 @@ function useFocusedInputHandler(handler, deps) {
79
101
  };
80
102
  }, deps);
81
103
  }
82
- //# sourceMappingURL=hooks.js.map
104
+ //# sourceMappingURL=index.js.map