react-native-keyboard-controller 1.21.2 → 1.21.4

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 (54) hide show
  1. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +2 -0
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/WindowDimensionListener.kt +1 -0
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +5 -1
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +8 -0
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/views/ClippingScrollViewDecoratorView.kt +18 -1
  6. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +2 -0
  7. package/ios/KeyboardControllerModule.mm +12 -0
  8. package/ios/observers/FocusedInputObserver.swift +9 -2
  9. package/ios/views/KeyboardExtenderContainerView.swift +15 -2
  10. package/lib/commonjs/bindings.js +4 -1
  11. package/lib/commonjs/bindings.js.map +1 -1
  12. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +69 -17
  13. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  14. package/lib/commonjs/components/KeyboardAwareScrollView/types.js +6 -0
  15. package/lib/commonjs/components/KeyboardAwareScrollView/types.js.map +1 -0
  16. package/lib/commonjs/components/KeyboardToolbar/constants.js +2 -2
  17. package/lib/commonjs/components/KeyboardToolbar/constants.js.map +1 -1
  18. package/lib/commonjs/components/index.js.map +1 -1
  19. package/lib/commonjs/constants.js +3 -1
  20. package/lib/commonjs/constants.js.map +1 -1
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
  23. package/lib/commonjs/types/module.js.map +1 -1
  24. package/lib/module/bindings.js +4 -1
  25. package/lib/module/bindings.js.map +1 -1
  26. package/lib/module/components/KeyboardAwareScrollView/index.js +70 -18
  27. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  28. package/lib/module/components/KeyboardAwareScrollView/types.js +2 -0
  29. package/lib/module/components/KeyboardAwareScrollView/types.js.map +1 -0
  30. package/lib/module/components/KeyboardToolbar/constants.js +2 -2
  31. package/lib/module/components/KeyboardToolbar/constants.js.map +1 -1
  32. package/lib/module/components/index.js.map +1 -1
  33. package/lib/module/constants.js +3 -0
  34. package/lib/module/constants.js.map +1 -1
  35. package/lib/module/index.js.map +1 -1
  36. package/lib/module/specs/NativeKeyboardController.js.map +1 -1
  37. package/lib/module/types/module.js.map +1 -1
  38. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -24
  39. package/lib/typescript/components/KeyboardAwareScrollView/types.d.ts +27 -0
  40. package/lib/typescript/components/index.d.ts +1 -1
  41. package/lib/typescript/constants.d.ts +1 -0
  42. package/lib/typescript/index.d.ts +1 -1
  43. package/lib/typescript/specs/NativeKeyboardController.d.ts +3 -1
  44. package/lib/typescript/types/module.d.ts +3 -0
  45. package/package.json +1 -1
  46. package/src/bindings.ts +3 -0
  47. package/src/components/KeyboardAwareScrollView/index.tsx +106 -58
  48. package/src/components/KeyboardAwareScrollView/types.ts +29 -0
  49. package/src/components/KeyboardToolbar/constants.ts +2 -3
  50. package/src/components/index.ts +2 -1
  51. package/src/constants.ts +4 -0
  52. package/src/index.ts +1 -0
  53. package/src/specs/NativeKeyboardController.ts +3 -1
  54. package/src/types/module.ts +4 -0
@@ -11,6 +11,8 @@ class KeyboardControllerModule(
11
11
 
12
12
  override fun getName(): String = KeyboardControllerModuleImpl.NAME
13
13
 
14
+ override fun getTypedExportedConstants(): Map<String, Any> = module.getConstants()
15
+
14
16
  override fun setInputMode(mode: Double) {
15
17
  module.setInputMode(mode.toInt())
16
18
  }
@@ -43,6 +43,7 @@ class WindowDimensionListener(
43
43
  attachedContent?.viewTreeObserver?.removeOnGlobalLayoutListener(layoutListener)
44
44
  attachedContent = null
45
45
  layoutListener = null
46
+ listenerID = -1
46
47
  }
47
48
 
48
49
  private fun updateWindowDimensions(content: ViewGroup?) {
@@ -13,11 +13,14 @@ import com.reactnativekeyboardcontroller.views.EdgeToEdgeReactViewGroup
13
13
 
14
14
  class KeyboardControllerViewManagerImpl {
15
15
  private var listener: WindowDimensionListener? = null
16
+ private var listenerContext: ThemedReactContext? = null
16
17
 
17
18
  fun createViewInstance(reactContext: ThemedReactContext): EdgeToEdgeReactViewGroup {
18
- if (listener == null) {
19
+ if (listener == null || listenerContext !== reactContext) {
20
+ listener?.detachListener()
19
21
  listener = WindowDimensionListener(reactContext)
20
22
  listener?.attachListener()
23
+ listenerContext = reactContext
21
24
  }
22
25
  return EdgeToEdgeReactViewGroup(reactContext)
23
26
  }
@@ -25,6 +28,7 @@ class KeyboardControllerViewManagerImpl {
25
28
  fun invalidate() {
26
29
  listener?.detachListener()
27
30
  listener = null
31
+ listenerContext = null
28
32
  }
29
33
 
30
34
  fun synchronizeFocusedInputLayout(view: EdgeToEdgeReactViewGroup) {
@@ -23,6 +23,7 @@ class KeyboardControllerModuleImpl(
23
23
  private val controller = KeyboardAnimationController()
24
24
  private val mDefaultMode: Int = getCurrentMode()
25
25
 
26
+ // region Module methods
26
27
  fun setInputMode(mode: Int) {
27
28
  setSoftInputMode(mode)
28
29
  }
@@ -102,7 +103,9 @@ class KeyboardControllerModuleImpl(
102
103
  promise.resolve(map)
103
104
  }
104
105
  }
106
+ // endregion
105
107
 
108
+ // region Helpers
106
109
  private fun setSoftInputMode(mode: Int) {
107
110
  UiThreadUtil.runOnUiThread {
108
111
  if (getCurrentMode() != mode) {
@@ -118,8 +121,13 @@ class KeyboardControllerModuleImpl(
118
121
  ?.attributes
119
122
  ?.softInputMode
120
123
  ?: WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED
124
+ // endregion
125
+
126
+ // region Module constants
127
+ fun getConstants(): MutableMap<String, Any> = mutableMapOf("keyboardBorderRadius" to 0)
121
128
 
122
129
  companion object {
123
130
  const val NAME = "KeyboardController"
124
131
  }
132
+ // endregion
125
133
  }
@@ -1,6 +1,7 @@
1
1
  package com.reactnativekeyboardcontroller.views
2
2
 
3
3
  import android.annotation.SuppressLint
4
+ import android.view.View
4
5
  import android.view.ViewGroup
5
6
  import android.widget.ScrollView
6
7
  import com.facebook.react.uimanager.ThemedReactContext
@@ -37,7 +38,7 @@ class ClippingScrollViewDecoratorView(
37
38
  }
38
39
 
39
40
  private fun decorateScrollView() {
40
- val scrollView = getChildAt(0) as? ScrollView ?: return
41
+ val scrollView = findScrollView(this) ?: return
41
42
 
42
43
  scrollView.clipToPadding = false
43
44
 
@@ -66,4 +67,20 @@ class ClippingScrollViewDecoratorView(
66
67
 
67
68
  appliedTopInsetPx = newTopInsetPx
68
69
  }
70
+
71
+ private fun findScrollView(view: View?): ScrollView? {
72
+ var result: ScrollView? = null
73
+
74
+ if (view is ScrollView) {
75
+ result = view
76
+ } else if (view is ViewGroup) {
77
+ var i = 0
78
+ while (i < view.childCount && result == null) {
79
+ result = findScrollView(view.getChildAt(i))
80
+ i++
81
+ }
82
+ }
83
+
84
+ return result
85
+ }
69
86
  }
@@ -13,6 +13,8 @@ class KeyboardControllerModule(
13
13
 
14
14
  override fun getName(): String = KeyboardControllerModuleImpl.NAME
15
15
 
16
+ override fun getConstants(): MutableMap<String, Any> = module.getConstants()
17
+
16
18
  @ReactMethod
17
19
  fun setInputMode(mode: Int) {
18
20
  module.setInputMode(mode)
@@ -53,6 +53,18 @@ RCT_EXPORT_MODULE()
53
53
  return NO;
54
54
  }
55
55
 
56
+ - (NSDictionary *)constantsToExport
57
+ {
58
+ return @{
59
+ @"keyboardBorderRadius" : @([KeyboardExtenderContainerView keyboardBorderRadius]),
60
+ };
61
+ }
62
+
63
+ - (NSDictionary *)getConstants
64
+ {
65
+ return [self constantsToExport];
66
+ }
67
+
56
68
  #ifdef RCT_NEW_ARCH_ENABLED
57
69
  - (void)setDefaultMode
58
70
  #else
@@ -112,9 +112,16 @@ public class FocusedInputObserver: NSObject {
112
112
  NotificationCenter.default.removeObserver(self)
113
113
  }
114
114
 
115
- @objc func didReceiveFocus(_: Notification) {
115
+ @objc func didReceiveFocus(_ notification: Notification) {
116
116
  if UIResponder.current == currentResponder {
117
- // focus was already handled by keyboard event
117
+ // The same input is still focused — no need to re-run the full onFocus()
118
+ // setup (observers, delegate substitution, focusDidSet event). However,
119
+ // keyboardWillShowNotification also fires when the keyboard *resizes*
120
+ // (e.g. switching between text and emoji keyboards). In that case we must
121
+ // refresh the layout so consumers receive an up-to-date absoluteY.
122
+ if notification.name == UIResponder.keyboardWillShowNotification {
123
+ syncUpLayout()
124
+ }
118
125
  return
119
126
  }
120
127
 
@@ -9,13 +9,26 @@ import UIKit
9
9
 
10
10
  @objc
11
11
  public class KeyboardExtenderContainerView: NSObject {
12
- @objc public static func create(frame: CGRect, contentView: UIView) -> UIView {
12
+ private static func usesModernKeyboard() -> Bool {
13
13
  #if canImport(UIKit.UIGlassEffect)
14
14
  if #available(iOS 26.0, *) {
15
- return ModernContainerView(frame: frame, contentView: contentView)
15
+ let requiresCompat = Bundle.main.object(forInfoDictionaryKey: "UIDesignRequiresCompatibility") as? Bool ?? false
16
+ return !requiresCompat
16
17
  }
17
18
  #endif
19
+ return false
20
+ }
21
+
22
+ @objc public static func keyboardBorderRadius() -> CGFloat {
23
+ return usesModernKeyboard() ? 30 : 0
24
+ }
18
25
 
26
+ @objc public static func create(frame: CGRect, contentView: UIView) -> UIView {
27
+ if usesModernKeyboard() {
28
+ if #available(iOS 26.0, *) {
29
+ return ModernContainerView(frame: frame, contentView: contentView)
30
+ }
31
+ }
19
32
  return LegacyContainerView(frame: frame, contentView: contentView)
20
33
  }
21
34
  }
@@ -19,7 +19,10 @@ const KeyboardControllerNative = exports.KeyboardControllerNative = {
19
19
  height: 0
20
20
  }),
21
21
  addListener: NOOP,
22
- removeListeners: NOOP
22
+ removeListeners: NOOP,
23
+ getConstants: () => ({
24
+ keyboardBorderRadius: 0
25
+ })
23
26
  };
24
27
  /**
25
28
  * An event emitter that provides a way to subscribe to next keyboard events:
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","NOOP","KeyboardControllerNative","exports","setDefaultMode","setInputMode","preload","dismiss","setFocusTo","viewPositionInWindow","Promise","resolve","x","y","width","height","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","View","KeyboardControllerViewCommands","synchronizeFocusedInputLayout","_ref","KeyboardGestureArea","RCTOverKeyboardView","KeyboardBackgroundView","RCTKeyboardExtender","ClippingScrollView","RCTKeyboardToolbarGroupView"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n ClippingScrollViewProps,\n FocusedInputEventsModule,\n KeyboardBackgroundViewProps,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardExtenderProps,\n KeyboardGestureAreaProps,\n KeyboardToolbarGroupViewProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\nimport type { EmitterSubscription } from \"react-native\";\n\nconst NOOP = () => {};\n\nexport const KeyboardControllerNative: KeyboardControllerNativeModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n preload: NOOP,\n dismiss: NOOP,\n setFocusTo: NOOP,\n viewPositionInWindow: () =>\n Promise.resolve({ x: 0, y: 0, width: 0, height: 0 }),\n addListener: NOOP,\n removeListeners: NOOP,\n};\n/**\n * An event emitter that provides a way to subscribe to next keyboard events:\n * - `keyboardWillShow`;\n * - `keyboardDidShow`;\n * - `keyboardWillHide`;\n * - `keyboardDidHide`.\n *\n * Use `addListener` function to add your event listener for a specific keyboard event.\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};\n/**\n * A view that sends events whenever keyboard or focused events are happening.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|Documentation} page for more details.\n */\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardControllerViewCommands = {\n synchronizeFocusedInputLayout: (\n _ref: React.Component<KeyboardControllerProps> | null,\n ) => {},\n};\n/**\n * A view that defines a region on the screen, where gestures will control the keyboard position.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-gesture-area|Documentation} page for more details.\n */\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\nexport const RCTOverKeyboardView =\n View as unknown as React.FC<OverKeyboardViewProps>;\n/**\n * A view that matches keyboard background.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-background-view|Documentation} page for more details.\n */\nexport const KeyboardBackgroundView =\n View as unknown as React.FC<KeyboardBackgroundViewProps>;\n/**\n * A container that will embed its children into the keyboard\n * and will always show them above the keyboard.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-extender|Documentation} page for more details.\n */\nexport const RCTKeyboardExtender =\n View as unknown as React.FC<KeyboardExtenderProps>;\n/**\n * A decorator that will clip the content of the `ScrollView`. It helps to simulate `contentInset` behavior on Android\n * Supports only `bottom` property (`paddingBottom` is not supported property of `ScrollView.style`).\n * Using this component we can modify bottom inset without having a fake view.\n *\n * On iOS we use swizzling to apply runtime patches to fix some broken internal methods.\n * Ideally this component shouldn't exist and all its fixes/polyfills must be added directly to react-native and\n * we will port features/fixes back to upstream, but at the moment we use this view to\n * deliver desired functionality regardless of react-native version used.\n */\nexport const ClippingScrollView =\n View as unknown as React.FC<ClippingScrollViewProps>;\n/**\n * A View that defines a group of `TextInput`s.\n * Used in toolbar navigation to assure that you can navigate only between inputs withing the same group.\n */\nexport const RCTKeyboardToolbarGroupView =\n View as unknown as React.FC<KeyboardToolbarGroupViewProps>;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAiBA,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAEd,MAAMC,wBAAwD,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACtEE,cAAc,EAAEH,IAAI;EACpBI,YAAY,EAAEJ,IAAI;EAClBK,OAAO,EAAEL,IAAI;EACbM,OAAO,EAAEN,IAAI;EACbO,UAAU,EAAEP,IAAI;EAChBQ,oBAAoB,EAAEA,CAAA,KACpBC,OAAO,CAACC,OAAO,CAAC;IAAEC,CAAC,EAAE,CAAC;IAAEC,CAAC,EAAE,CAAC;IAAEC,KAAK,EAAE,CAAC;IAAEC,MAAM,EAAE;EAAE,CAAC,CAAC;EACtDC,WAAW,EAAEf,IAAI;EACjBgB,eAAe,EAAEhB;AACnB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMiB,cAAoC,GAAAf,OAAA,CAAAe,cAAA,GAAG;EAClDF,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAElB;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMmB,kBAA4C,GAAAjB,OAAA,CAAAiB,kBAAA,GAAG;EAC1DJ,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAElB;EAAK,CAAC;AACtC,CAAC;AACM,MAAMoB,sBAAoD,GAAAlB,OAAA,CAAAkB,sBAAA,GAAG;EAClEL,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAElB;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,MAAMqB,sBAAsB,GAAAnB,OAAA,CAAAmB,sBAAA,GACjCC,iBAAoD;AAC/C,MAAMC,8BAA8B,GAAArB,OAAA,CAAAqB,8BAAA,GAAG;EAC5CC,6BAA6B,EAC3BC,IAAqD,IAClD,CAAC;AACR,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,MAAMC,mBAAmB,GAAAxB,OAAA,CAAAwB,mBAAA,GAC9BJ,iBAAqD;AAChD,MAAMK,mBAAmB,GAAAzB,OAAA,CAAAyB,mBAAA,GAC9BL,iBAAkD;AACpD;AACA;AACA;AACA;AACA;AACO,MAAMM,sBAAsB,GAAA1B,OAAA,CAAA0B,sBAAA,GACjCN,iBAAwD;AAC1D;AACA;AACA;AACA;AACA;AACA;AACO,MAAMO,mBAAmB,GAAA3B,OAAA,CAAA2B,mBAAA,GAC9BP,iBAAkD;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMQ,kBAAkB,GAAA5B,OAAA,CAAA4B,kBAAA,GAC7BR,iBAAoD;AACtD;AACA;AACA;AACA;AACO,MAAMS,2BAA2B,GAAA7B,OAAA,CAAA6B,2BAAA,GACtCT,iBAA0D","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","NOOP","KeyboardControllerNative","exports","setDefaultMode","setInputMode","preload","dismiss","setFocusTo","viewPositionInWindow","Promise","resolve","x","y","width","height","addListener","removeListeners","getConstants","keyboardBorderRadius","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","View","KeyboardControllerViewCommands","synchronizeFocusedInputLayout","_ref","KeyboardGestureArea","RCTOverKeyboardView","KeyboardBackgroundView","RCTKeyboardExtender","ClippingScrollView","RCTKeyboardToolbarGroupView"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n ClippingScrollViewProps,\n FocusedInputEventsModule,\n KeyboardBackgroundViewProps,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardExtenderProps,\n KeyboardGestureAreaProps,\n KeyboardToolbarGroupViewProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\nimport type { EmitterSubscription } from \"react-native\";\n\nconst NOOP = () => {};\n\nexport const KeyboardControllerNative: KeyboardControllerNativeModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n preload: NOOP,\n dismiss: NOOP,\n setFocusTo: NOOP,\n viewPositionInWindow: () =>\n Promise.resolve({ x: 0, y: 0, width: 0, height: 0 }),\n addListener: NOOP,\n removeListeners: NOOP,\n getConstants: () => ({\n keyboardBorderRadius: 0,\n }),\n};\n/**\n * An event emitter that provides a way to subscribe to next keyboard events:\n * - `keyboardWillShow`;\n * - `keyboardDidShow`;\n * - `keyboardWillHide`;\n * - `keyboardDidHide`.\n *\n * Use `addListener` function to add your event listener for a specific keyboard event.\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};\n/**\n * A view that sends events whenever keyboard or focused events are happening.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|Documentation} page for more details.\n */\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardControllerViewCommands = {\n synchronizeFocusedInputLayout: (\n _ref: React.Component<KeyboardControllerProps> | null,\n ) => {},\n};\n/**\n * A view that defines a region on the screen, where gestures will control the keyboard position.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-gesture-area|Documentation} page for more details.\n */\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\nexport const RCTOverKeyboardView =\n View as unknown as React.FC<OverKeyboardViewProps>;\n/**\n * A view that matches keyboard background.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-background-view|Documentation} page for more details.\n */\nexport const KeyboardBackgroundView =\n View as unknown as React.FC<KeyboardBackgroundViewProps>;\n/**\n * A container that will embed its children into the keyboard\n * and will always show them above the keyboard.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-extender|Documentation} page for more details.\n */\nexport const RCTKeyboardExtender =\n View as unknown as React.FC<KeyboardExtenderProps>;\n/**\n * A decorator that will clip the content of the `ScrollView`. It helps to simulate `contentInset` behavior on Android\n * Supports only `bottom` property (`paddingBottom` is not supported property of `ScrollView.style`).\n * Using this component we can modify bottom inset without having a fake view.\n *\n * On iOS we use swizzling to apply runtime patches to fix some broken internal methods.\n * Ideally this component shouldn't exist and all its fixes/polyfills must be added directly to react-native and\n * we will port features/fixes back to upstream, but at the moment we use this view to\n * deliver desired functionality regardless of react-native version used.\n */\nexport const ClippingScrollView =\n View as unknown as React.FC<ClippingScrollViewProps>;\n/**\n * A View that defines a group of `TextInput`s.\n * Used in toolbar navigation to assure that you can navigate only between inputs withing the same group.\n */\nexport const RCTKeyboardToolbarGroupView =\n View as unknown as React.FC<KeyboardToolbarGroupViewProps>;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAiBA,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAEd,MAAMC,wBAAwD,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACtEE,cAAc,EAAEH,IAAI;EACpBI,YAAY,EAAEJ,IAAI;EAClBK,OAAO,EAAEL,IAAI;EACbM,OAAO,EAAEN,IAAI;EACbO,UAAU,EAAEP,IAAI;EAChBQ,oBAAoB,EAAEA,CAAA,KACpBC,OAAO,CAACC,OAAO,CAAC;IAAEC,CAAC,EAAE,CAAC;IAAEC,CAAC,EAAE,CAAC;IAAEC,KAAK,EAAE,CAAC;IAAEC,MAAM,EAAE;EAAE,CAAC,CAAC;EACtDC,WAAW,EAAEf,IA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AA,GAC7BR,iBAAoD;AACtD;AACA;AACA;AACA;AACO,MAAMS,2BAA2B,GAAA/B,OAAA,CAAA+B,2BAAA,GACtCT,iBAA0D","ignoreList":[]}
@@ -77,6 +77,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
77
77
  disableScrollOnKeyboardHide = false,
78
78
  enabled = true,
79
79
  extraKeyboardSpace = 0,
80
+ mode = "insets",
80
81
  ScrollViewComponent = _reactNativeReanimated.default.ScrollView,
81
82
  snapToOffsets,
82
83
  ...rest
@@ -105,6 +106,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
105
106
  const lastSelection = (0, _reactNativeReanimated.useSharedValue)(null);
106
107
  const ghostViewSpace = (0, _reactNativeReanimated.useSharedValue)(-1);
107
108
  const pendingSelectionForFocus = (0, _reactNativeReanimated.useSharedValue)(false);
109
+ const selectionUpdatedSinceHide = (0, _reactNativeReanimated.useSharedValue)(false);
108
110
  const scrollViewPageY = (0, _reactNativeReanimated.useSharedValue)(0);
109
111
  const {
110
112
  height
@@ -161,15 +163,21 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
161
163
  const removeGhostPadding = (0, _react.useCallback)(e => {
162
164
  "worklet";
163
165
 
164
- // new `ScrollViewWithBottomPadding` behavior: if we hide keyboard and we are in the end of `ScrollView`
165
- // then we always need to scroll back, because we apply a padding that doesn't change layout, so we will
166
- // not have auto scroll back in this case
166
+ // layout mode: the spacer view participates in layout, so the ScrollView
167
+ // reflows naturally when it shrinks no manual scroll correction needed.
168
+ if (mode === "layout") {
169
+ return false;
170
+ }
171
+
172
+ // insets mode: `ScrollViewWithBottomPadding` extends scrollable area without
173
+ // changing layout, so when the keyboard hides and we're at the end of the
174
+ // ScrollView we must manually scroll back.
167
175
  if (!keyboardWillAppear.value && ghostViewSpace.value > 0) {
168
176
  (0, _reactNativeReanimated.scrollTo)(scrollViewAnimatedRef, 0, scrollPosition.value - (0, _reactNativeReanimated.interpolate)(e, [initialKeyboardSize.value, keyboardHeight.value], [ghostViewSpace.value, 0]), false);
169
177
  return true;
170
178
  }
171
179
  return false;
172
- }, []);
180
+ }, [mode]);
173
181
  const performScrollWithPositionRestoration = (0, _react.useCallback)(newPosition => {
174
182
  "worklet";
175
183
 
@@ -228,7 +236,8 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
228
236
  const lastTarget = (_lastSelection$value2 = lastSelection.value) === null || _lastSelection$value2 === void 0 ? void 0 : _lastSelection$value2.target;
229
237
  const latestSelection = (_lastSelection$value3 = lastSelection.value) === null || _lastSelection$value3 === void 0 ? void 0 : _lastSelection$value3.selection;
230
238
  lastSelection.value = e;
231
- if (e.target !== lastTarget) {
239
+ selectionUpdatedSinceHide.value = true;
240
+ if (e.target !== lastTarget || pendingSelectionForFocus.value) {
232
241
  if (pendingSelectionForFocus.value) {
233
242
  // selection arrived after onStart - complete the deferred setup
234
243
  pendingSelectionForFocus.value = false;
@@ -278,22 +287,34 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
278
287
  scrollPosition.value = position.value;
279
288
  // just persist height - later will be used in interpolation
280
289
  keyboardHeight.value = e.height;
281
- // and update keyboard spacer size
282
- syncKeyboardFrame(e);
290
+
291
+ // insets mode: set the full contentInset upfront so that maybeScroll
292
+ // calculations are correct from the very first onMove frame.
293
+ // layout mode: do NOT set it here — the spacer must grow frame-by-frame
294
+ // in onMove to avoid a premature full-height jump before the keyboard moves.
295
+ if (mode === "insets") {
296
+ syncKeyboardFrame(e);
297
+ }
283
298
  }
284
299
 
285
300
  // focus was changed
286
301
  if (focusWasChanged) {
287
302
  var _lastSelection$value4;
288
303
  tag.value = e.target;
289
- if (((_lastSelection$value4 = lastSelection.value) === null || _lastSelection$value4 === void 0 ? void 0 : _lastSelection$value4.target) === e.target) {
290
- // selection arrived before onStart - use it to update layout
304
+ if (((_lastSelection$value4 = lastSelection.value) === null || _lastSelection$value4 === void 0 ? void 0 : _lastSelection$value4.target) === e.target && selectionUpdatedSinceHide.value) {
305
+ // fresh selection arrived before onStart - use it to update layout
291
306
  updateLayoutFromSelection();
292
307
  pendingSelectionForFocus.value = false;
293
308
  } else {
294
- // selection hasn't arrived yet for the new target.
295
- // use input layout as-is; will be refined when selection arrives.
296
- if (input.value) {
309
+ var _lastSelection$value5;
310
+ // selection hasn't arrived yet for the new target (iOS 15),
311
+ // or it's stale from previous session (Android refocus same input).
312
+ // Use stale selection as best-effort fallback if available for same target,
313
+ // otherwise fall back to full input layout.
314
+ // Will be corrected if a fresh onSelectionChange arrives.
315
+ if (((_lastSelection$value5 = lastSelection.value) === null || _lastSelection$value5 === void 0 ? void 0 : _lastSelection$value5.target) === e.target) {
316
+ updateLayoutFromSelection();
317
+ } else if (input.value) {
297
318
  layout.value = input.value;
298
319
  }
299
320
  pendingSelectionForFocus.value = true;
@@ -310,9 +331,11 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
310
331
  position.value += maybeScroll(e.height, true);
311
332
  }
312
333
  }
313
- ghostViewSpace.value = position.value + scrollViewLayout.value.height - scrollViewContentSize.value.height;
314
- if (ghostViewSpace.value > 0) {
315
- scrollPosition.value = position.value;
334
+ if (mode === "insets") {
335
+ ghostViewSpace.value = position.value + scrollViewLayout.value.height - scrollViewContentSize.value.height;
336
+ if (ghostViewSpace.value > 0) {
337
+ scrollPosition.value = position.value;
338
+ }
316
339
  }
317
340
  },
318
341
  onMove: e => {
@@ -322,6 +345,11 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
322
345
  return;
323
346
  }
324
347
 
348
+ // layout mode: drive the spacer view animation frame-by-frame
349
+ if (mode === "layout") {
350
+ syncKeyboardFrame(e);
351
+ }
352
+
325
353
  // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens
326
354
  if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {
327
355
  maybeScroll(e.height);
@@ -334,11 +362,18 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
334
362
  keyboardHeight.value = e.height;
335
363
  scrollPosition.value = position.value;
336
364
  if (e.height === 0) {
337
- lastSelection.value = null;
365
+ selectionUpdatedSinceHide.value = false;
366
+ } else if (keyboardWillAppear.value) {
367
+ // keyboard fully shown after appearing from hidden state — clear
368
+ // pending flag to prevent leaking into next focus-change session.
369
+ // Only when the keyboard was actually appearing (not a focus switch
370
+ // with same keyboard height), otherwise we'd clear the flag before
371
+ // onSelectionChange has a chance to process it.
372
+ pendingSelectionForFocus.value = false;
338
373
  }
339
374
  syncKeyboardFrame(e);
340
375
  }
341
- }, [maybeScroll, removeGhostPadding, disableScrollOnKeyboardHide, syncKeyboardFrame]);
376
+ }, [mode, maybeScroll, removeGhostPadding, disableScrollOnKeyboardHide, syncKeyboardFrame]);
342
377
  const synchronize = (0, _react.useCallback)(async () => {
343
378
  await update();
344
379
  (0, _reactNativeReanimated.runOnUI)(() => {
@@ -374,6 +409,23 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
374
409
  }
375
410
  }, []);
376
411
  const padding = (0, _reactNativeReanimated.useDerivedValue)(() => enabled ? currentKeyboardFrameHeight.value : 0, [enabled]);
412
+ // layout mode only: a spacer view whose paddingBottom grows with the keyboard.
413
+ // The `+ 1` ensures the scroll view never reaches its absolute end during animation,
414
+ // avoiding the layout recalculation that triggers on every frame at the boundary.
415
+ // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342
416
+ const layoutSpacerStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => enabled && mode === "layout" ? {
417
+ paddingBottom: currentKeyboardFrameHeight.value + 1
418
+ } : {}, [enabled, mode]);
419
+ if (mode === "layout") {
420
+ return /*#__PURE__*/_react.default.createElement(ScrollViewComponent, _extends({
421
+ ref: onRef
422
+ }, rest, {
423
+ scrollEventThrottle: 16,
424
+ onLayout: onScrollViewLayout
425
+ }), children, enabled && /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
426
+ style: layoutSpacerStyle
427
+ }));
428
+ }
377
429
  return /*#__PURE__*/_react.default.createElement(_ScrollViewWithBottomPadding.default, _extends({
378
430
  ref: onRef
379
431
  }, rest, {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_bindings","_hooks","_findNodeHandle","_useCombinedRef","_interopRequireDefault","_useScrollState","_ScrollViewWithBottomPadding","_useSmoothKeyboardHandler","_utils","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","KeyboardAwareScrollView","forwardRef","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","Reanimated","ScrollView","snapToOffsets","rest","ref","scrollViewAnimatedRef","useAnimatedRef","scrollViewRef","React","useRef","onRef","useCombinedRef","scrollViewTarget","useSharedValue","scrollPosition","offset","position","layout","scrollViewLayout","size","scrollViewContentSize","useScrollState","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","update","useReanimatedFocusedInput","lastSelection","ghostViewSpace","pendingSelectionForFocus","scrollViewPageY","height","useWindowDimensions","onScrollViewLayout","useCallback","handle","findNodeHandle","current","value","y","KeyboardControllerNative","viewPositionInWindow","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","interpolate","scrollDistanceWithRespectToSnapPoints","targetScrollY","Math","max","scrollTo","positionOnScreen","topOfScreen","removeGhostPadding","performScrollWithPositionRestoration","newPosition","prevScroll","syncKeyboardFrame","keyboardFrame","updateLayoutFromSelection","_lastSelection$value","_input$value","customHeight","selection","end","clamp","scrollFromCurrentPosition","prevLayout","onChangeText","onChangeTextHandler","useMemo","debounce","onSelectionChange","_lastSelection$value2","_lastSelection$value3","lastTarget","target","latestSelection","start","useFocusedInputHandler","useSmoothKeyboardHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","_lastSelection$value4","onMove","onEnd","synchronize","runOnUI","useImperativeHandle","scrollView","scrollViewWithMethods","assureFocusedInputVisible","useEffect","useAnimatedReaction","previous","padding","useDerivedValue","createElement","bottomPadding","scrollEventThrottle","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n} from \"react\";\nimport Reanimated, {\n clamp,\n interpolate,\n runOnUI,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { KeyboardControllerNative } from \"../../bindings\";\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n useWindowDimensions,\n} from \"../../hooks\";\nimport { findNodeHandle } from \"../../utils/findNodeHandle\";\nimport useCombinedRef from \"../hooks/useCombinedRef\";\nimport useScrollState from \"../hooks/useScrollState\";\nimport ScrollViewWithBottomPadding from \"../ScrollViewWithBottomPadding\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce, scrollDistanceWithRespectToSnapPoints } from \"./utils\";\n\nimport type { AnimatedScrollViewComponent } from \"../ScrollViewWithBottomPadding\";\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type {\n FocusedInputLayoutChangedEvent,\n FocusedInputSelectionChangedEvent,\n NativeEvent,\n} from \"react-native-keyboard-controller\";\n\nexport type KeyboardAwareScrollViewProps = {\n /** The distance between the keyboard and the caret inside a focused `TextInput` when the 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 /** Custom component for `ScrollView`. Default is `ScrollView`. */\n ScrollViewComponent?: AnimatedScrollViewComponent;\n} & ScrollViewProps;\nexport type KeyboardAwareScrollViewRef = {\n assureFocusedInputVisible: () => void;\n} & ScrollView;\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// + 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\n/**\n * A ScrollView component that automatically handles keyboard appearance and disappearance\n * by adjusting its content position to ensure the focused input remains visible.\n *\n * The component uses a sophisticated animation system to smoothly handle keyboard transitions\n * and maintain proper scroll position during keyboard interactions.\n *\n * @returns A ScrollView component that handles keyboard interactions.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-aware-scroll-view|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardAwareScrollView bottomOffset={20}>\n * <TextInput placeholder=\"Enter text\" />\n * <TextInput placeholder=\"Another input\" />\n * </KeyboardAwareScrollView>\n * ```\n */\nconst KeyboardAwareScrollView = forwardRef<\n KeyboardAwareScrollViewRef,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n extraKeyboardSpace = 0,\n ScrollViewComponent = Reanimated.ScrollView,\n snapToOffsets,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewRef = React.useRef<ScrollView>(null);\n const onRef = useCombinedRef(scrollViewAnimatedRef, scrollViewRef);\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const {\n offset: position,\n layout: scrollViewLayout,\n size: scrollViewContentSize,\n } = useScrollState(scrollViewAnimatedRef);\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, update } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const lastSelection =\n useSharedValue<FocusedInputSelectionChangedEvent | null>(null);\n const ghostViewSpace = useSharedValue(-1);\n const pendingSelectionForFocus = useSharedValue(false);\n const scrollViewPageY = useSharedValue(0);\n\n const { height } = useWindowDimensions();\n\n const onScrollViewLayout = useCallback(\n async (e: LayoutChangeEvent) => {\n const handle = findNodeHandle(scrollViewAnimatedRef.current);\n\n scrollViewTarget.value = handle;\n\n onLayout?.(e);\n\n if (handle !== null) {\n try {\n const { y } = await KeyboardControllerNative.viewPositionInWindow(\n handle,\n );\n\n scrollViewPageY.value = y;\n } catch {\n // ignore\n }\n }\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 snapToOffsets,\n ) - scrollPosition.value,\n ],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (point < scrollViewPageY.value) {\n const positionOnScreen = visibleRect - bottomOffset;\n const topOfScreen = scrollPosition.value + point;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled, height, snapToOffsets],\n );\n const removeGhostPadding = useCallback((e: number) => {\n \"worklet\";\n\n // new `ScrollViewWithBottomPadding` behavior: if we hide keyboard and we are in the end of `ScrollView`\n // then we always need to scroll back, because we apply a padding that doesn't change layout, so we will\n // not have auto scroll back in this case\n if (!keyboardWillAppear.value && ghostViewSpace.value > 0) {\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n scrollPosition.value -\n interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [ghostViewSpace.value, 0],\n ),\n false,\n );\n\n return true;\n }\n\n return false;\n }, []);\n const performScrollWithPositionRestoration = useCallback(\n (newPosition: number) => {\n \"worklet\";\n\n const prevScroll = scrollPosition.value;\n\n // eslint-disable-next-line react-compiler/react-compiler\n scrollPosition.value = newPosition;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScroll;\n },\n [scrollPosition, keyboardHeight, maybeScroll],\n );\n const syncKeyboardFrame = useCallback(\n (e: NativeEvent) => {\n \"worklet\";\n\n const keyboardFrame = interpolate(\n e.height,\n [0, keyboardHeight.value],\n [0, keyboardHeight.value + extraKeyboardSpace],\n );\n\n currentKeyboardFrameHeight.value = keyboardFrame;\n },\n [extraKeyboardSpace],\n );\n\n const updateLayoutFromSelection = useCallback(() => {\n \"worklet\";\n\n const customHeight = lastSelection.value?.selection.end.y;\n\n if (!input.value?.layout || !customHeight) {\n return false;\n }\n\n layout.value = {\n ...input.value,\n layout: {\n ...input.value.layout,\n // when we have multiline input with limited amount of lines, then custom height can be very big\n // so we clamp it to max input height\n height: clamp(customHeight, 0, input.value.layout.height),\n },\n };\n\n return true;\n }, [input, lastSelection, layout]);\n const scrollFromCurrentPosition = useCallback(() => {\n \"worklet\";\n\n const prevLayout = layout.value;\n\n if (!updateLayoutFromSelection()) {\n return;\n }\n\n performScrollWithPositionRestoration(position.value);\n\n layout.value = prevLayout;\n }, [performScrollWithPositionRestoration]);\n const onChangeText = useCallback(() => {\n \"worklet\";\n scrollFromCurrentPosition();\n }, [scrollFromCurrentPosition]);\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n const onSelectionChange = useCallback(\n (e: FocusedInputSelectionChangedEvent) => {\n \"worklet\";\n\n const lastTarget = lastSelection.value?.target;\n const latestSelection = lastSelection.value?.selection;\n\n lastSelection.value = e;\n\n if (e.target !== lastTarget) {\n if (pendingSelectionForFocus.value) {\n // selection arrived after onStart - complete the deferred setup\n pendingSelectionForFocus.value = false;\n updateLayoutFromSelection();\n\n // if keyboard was already visible (focus change, no onMove expected),\n // perform the deferred scroll now\n if (!keyboardWillAppear.value && keyboardHeight.value > 0) {\n position.value += maybeScroll(keyboardHeight.value, true);\n }\n }\n\n return;\n }\n // caret in the end + end coordinates has been changed -> we moved to a new line\n // so input may grow\n if (\n e.selection.end.position === e.selection.start.position &&\n latestSelection?.end.y !== e.selection.end.y\n ) {\n return scrollFromCurrentPosition();\n }\n // selection has been changed\n if (e.selection.start.position !== e.selection.end.position) {\n return scrollFromCurrentPosition();\n }\n\n onChangeTextHandler();\n },\n [\n scrollFromCurrentPosition,\n onChangeTextHandler,\n updateLayoutFromSelection,\n maybeScroll,\n ],\n );\n\n useFocusedInputHandler(\n {\n onSelectionChange: onSelectionChange,\n },\n [onSelectionChange],\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\n\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 pendingSelectionForFocus.value = false;\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 // and update keyboard spacer size\n syncKeyboardFrame(e);\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n\n if (lastSelection.value?.target === e.target) {\n // selection arrived before onStart - use it to update layout\n updateLayoutFromSelection();\n pendingSelectionForFocus.value = false;\n } else {\n // selection hasn't arrived yet for the new target.\n // use input layout as-is; will be refined when selection arrives.\n if (input.value) {\n layout.value = input.value;\n }\n pendingSelectionForFocus.value = true;\n }\n\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 if (!pendingSelectionForFocus.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\n ghostViewSpace.value =\n position.value +\n scrollViewLayout.value.height -\n scrollViewContentSize.value.height;\n\n if (ghostViewSpace.value > 0) {\n scrollPosition.value = position.value;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n if (removeGhostPadding(e.height)) {\n return;\n }\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 removeGhostPadding(e.height);\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n\n if (e.height === 0) {\n lastSelection.value = null;\n }\n\n syncKeyboardFrame(e);\n },\n },\n [\n maybeScroll,\n removeGhostPadding,\n disableScrollOnKeyboardHide,\n syncKeyboardFrame,\n ],\n );\n\n const synchronize = useCallback(async () => {\n await update();\n\n runOnUI(() => {\n \"worklet\";\n\n scrollFromCurrentPosition();\n })();\n }, [update, scrollFromCurrentPosition]);\n\n useImperativeHandle(\n ref,\n () => {\n const scrollView = scrollViewRef.current;\n\n if (scrollView) {\n const scrollViewWithMethods =\n scrollView as KeyboardAwareScrollViewRef;\n\n scrollViewWithMethods.assureFocusedInputVisible = () => {\n synchronize();\n };\n\n return scrollViewWithMethods;\n }\n\n return {\n assureFocusedInputVisible: () => {\n synchronize();\n },\n } as KeyboardAwareScrollViewRef;\n },\n [synchronize],\n );\n\n useEffect(() => {\n synchronize();\n }, [bottomOffset]);\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 // input has changed layout - let's check if we need to scroll\n // may happen when you paste text, then onSelectionChange will be\n // fired earlier than text actually changes its layout\n scrollFromCurrentPosition();\n }\n },\n [],\n );\n\n const padding = useDerivedValue(\n () => (enabled ? currentKeyboardFrameHeight.value : 0),\n [enabled],\n );\n\n return (\n <ScrollViewWithBottomPadding\n ref={onRef}\n {...rest}\n bottomPadding={padding}\n scrollEventThrottle={16}\n ScrollViewComponent={ScrollViewComponent}\n onLayout={onScrollViewLayout}\n >\n {children}\n </ScrollViewWithBottomPadding>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,sBAAA,GAAAF,uBAAA,CAAAC,OAAA;AAWA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAKA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,eAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,4BAAA,GAAAF,sBAAA,CAAAN,OAAA;AAEA,IAAAS,yBAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAA0E,SAAAM,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAZ,wBAAAY,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAhB,uBAAA,YAAAA,CAAAY,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,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F,CAAC;AAAC,IAAA0H,QAAA,GAAAC,OAAA,CAAApJ,OAAA,GAEauB,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_bindings","_hooks","_findNodeHandle","_useCombinedRef","_interopRequireDefault","_useScrollState","_ScrollViewWithBottomPadding","_useSmoothKeyboardHandler","_utils","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","KeyboardAwareScrollView","forwardRef","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","mode","ScrollViewComponent","Reanimated","ScrollView","snapToOffsets","rest","ref","scrollViewAnimatedRef","useAnimatedRef","scrollViewRef","React","useRef","onRef","useCombinedRef","scrollViewTarget","useSharedValue","scrollPosition","offset","position","layout","scrollViewLayout","size","scrollViewContentSize","useScrollState","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","update","useReanimatedFocusedInput","lastSelection","ghostViewSpace","pendingSelectionForFocus","selectionUpdatedSinceHide","scrollViewPageY","height","useWindowDimensions","onScrollViewLayout","useCallback","handle","findNodeHandle","current","value","y","KeyboardControllerNative","viewPositionInWindow","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","interpolate","scrollDistanceWithRespectToSnapPoints","targetScrollY","Math","max","scrollTo","positionOnScreen","topOfScreen","removeGhostPadding","performScrollWithPositionRestoration","newPosition","prevScroll","syncKeyboardFrame","keyboardFrame","updateLayoutFromSelection","_lastSelection$value","_input$value","customHeight","selection","end","clamp","scrollFromCurrentPosition","prevLayout","onChangeText","onChangeTextHandler","useMemo","debounce","onSelectionChange","_lastSelection$value2","_lastSelection$value3","lastTarget","target","latestSelection","start","useFocusedInputHandler","useSmoothKeyboardHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","_lastSelection$value4","_lastSelection$value5","onMove","onEnd","synchronize","runOnUI","useImperativeHandle","scrollView","scrollViewWithMethods","assureFocusedInputVisible","useEffect","useAnimatedReaction","previous","padding","useDerivedValue","layoutSpacerStyle","useAnimatedStyle","paddingBottom","createElement","scrollEventThrottle","View","style","bottomPadding","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n} from \"react\";\nimport Reanimated, {\n clamp,\n interpolate,\n runOnUI,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { KeyboardControllerNative } from \"../../bindings\";\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n useWindowDimensions,\n} from \"../../hooks\";\nimport { findNodeHandle } from \"../../utils/findNodeHandle\";\nimport useCombinedRef from \"../hooks/useCombinedRef\";\nimport useScrollState from \"../hooks/useScrollState\";\nimport ScrollViewWithBottomPadding from \"../ScrollViewWithBottomPadding\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce, scrollDistanceWithRespectToSnapPoints } from \"./utils\";\n\nimport type { LayoutChangeEvent, ScrollView } from \"react-native\";\nimport type {\n FocusedInputLayoutChangedEvent,\n FocusedInputSelectionChangedEvent,\n KeyboardAwareScrollViewProps,\n KeyboardAwareScrollViewRef,\n NativeEvent,\n} from \"react-native-keyboard-controller\";\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// + 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\n/**\n * A ScrollView component that automatically handles keyboard appearance and disappearance\n * by adjusting its content position to ensure the focused input remains visible.\n *\n * The component uses a sophisticated animation system to smoothly handle keyboard transitions\n * and maintain proper scroll position during keyboard interactions.\n *\n * @returns A ScrollView component that handles keyboard interactions.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-aware-scroll-view|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardAwareScrollView bottomOffset={20}>\n * <TextInput placeholder=\"Enter text\" />\n * <TextInput placeholder=\"Another input\" />\n * </KeyboardAwareScrollView>\n * ```\n */\nconst KeyboardAwareScrollView = forwardRef<\n KeyboardAwareScrollViewRef,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n extraKeyboardSpace = 0,\n mode = \"insets\",\n ScrollViewComponent = Reanimated.ScrollView,\n snapToOffsets,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewRef = React.useRef<ScrollView>(null);\n const onRef = useCombinedRef(scrollViewAnimatedRef, scrollViewRef);\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const {\n offset: position,\n layout: scrollViewLayout,\n size: scrollViewContentSize,\n } = useScrollState(scrollViewAnimatedRef);\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, update } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const lastSelection =\n useSharedValue<FocusedInputSelectionChangedEvent | null>(null);\n const ghostViewSpace = useSharedValue(-1);\n const pendingSelectionForFocus = useSharedValue(false);\n const selectionUpdatedSinceHide = useSharedValue(false);\n const scrollViewPageY = useSharedValue(0);\n\n const { height } = useWindowDimensions();\n\n const onScrollViewLayout = useCallback(\n async (e: LayoutChangeEvent) => {\n const handle = findNodeHandle(scrollViewAnimatedRef.current);\n\n scrollViewTarget.value = handle;\n\n onLayout?.(e);\n\n if (handle !== null) {\n try {\n const { y } = await KeyboardControllerNative.viewPositionInWindow(\n handle,\n );\n\n scrollViewPageY.value = y;\n } catch {\n // ignore\n }\n }\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 snapToOffsets,\n ) - scrollPosition.value,\n ],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (point < scrollViewPageY.value) {\n const positionOnScreen = visibleRect - bottomOffset;\n const topOfScreen = scrollPosition.value + point;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled, height, snapToOffsets],\n );\n const removeGhostPadding = useCallback(\n (e: number) => {\n \"worklet\";\n\n // layout mode: the spacer view participates in layout, so the ScrollView\n // reflows naturally when it shrinks — no manual scroll correction needed.\n if (mode === \"layout\") {\n return false;\n }\n\n // insets mode: `ScrollViewWithBottomPadding` extends scrollable area without\n // changing layout, so when the keyboard hides and we're at the end of the\n // ScrollView we must manually scroll back.\n if (!keyboardWillAppear.value && ghostViewSpace.value > 0) {\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n scrollPosition.value -\n interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [ghostViewSpace.value, 0],\n ),\n false,\n );\n\n return true;\n }\n\n return false;\n },\n [mode],\n );\n const performScrollWithPositionRestoration = useCallback(\n (newPosition: number) => {\n \"worklet\";\n\n const prevScroll = scrollPosition.value;\n\n // eslint-disable-next-line react-compiler/react-compiler\n scrollPosition.value = newPosition;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScroll;\n },\n [scrollPosition, keyboardHeight, maybeScroll],\n );\n const syncKeyboardFrame = useCallback(\n (e: NativeEvent) => {\n \"worklet\";\n\n const keyboardFrame = interpolate(\n e.height,\n [0, keyboardHeight.value],\n [0, keyboardHeight.value + extraKeyboardSpace],\n );\n\n currentKeyboardFrameHeight.value = keyboardFrame;\n },\n [extraKeyboardSpace],\n );\n\n const updateLayoutFromSelection = useCallback(() => {\n \"worklet\";\n\n const customHeight = lastSelection.value?.selection.end.y;\n\n if (!input.value?.layout || !customHeight) {\n return false;\n }\n\n layout.value = {\n ...input.value,\n layout: {\n ...input.value.layout,\n // when we have multiline input with limited amount of lines, then custom height can be very big\n // so we clamp it to max input height\n height: clamp(customHeight, 0, input.value.layout.height),\n },\n };\n\n return true;\n }, [input, lastSelection, layout]);\n const scrollFromCurrentPosition = useCallback(() => {\n \"worklet\";\n\n const prevLayout = layout.value;\n\n if (!updateLayoutFromSelection()) {\n return;\n }\n\n performScrollWithPositionRestoration(position.value);\n\n layout.value = prevLayout;\n }, [performScrollWithPositionRestoration]);\n const onChangeText = useCallback(() => {\n \"worklet\";\n scrollFromCurrentPosition();\n }, [scrollFromCurrentPosition]);\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n const onSelectionChange = useCallback(\n (e: FocusedInputSelectionChangedEvent) => {\n \"worklet\";\n\n const lastTarget = lastSelection.value?.target;\n const latestSelection = lastSelection.value?.selection;\n\n lastSelection.value = e;\n selectionUpdatedSinceHide.value = true;\n\n if (e.target !== lastTarget || pendingSelectionForFocus.value) {\n if (pendingSelectionForFocus.value) {\n // selection arrived after onStart - complete the deferred setup\n pendingSelectionForFocus.value = false;\n updateLayoutFromSelection();\n\n // if keyboard was already visible (focus change, no onMove expected),\n // perform the deferred scroll now\n if (!keyboardWillAppear.value && keyboardHeight.value > 0) {\n position.value += maybeScroll(keyboardHeight.value, true);\n }\n }\n\n return;\n }\n // caret in the end + end coordinates has been changed -> we moved to a new line\n // so input may grow\n if (\n e.selection.end.position === e.selection.start.position &&\n latestSelection?.end.y !== e.selection.end.y\n ) {\n return scrollFromCurrentPosition();\n }\n // selection has been changed\n if (e.selection.start.position !== e.selection.end.position) {\n return scrollFromCurrentPosition();\n }\n\n onChangeTextHandler();\n },\n [\n scrollFromCurrentPosition,\n onChangeTextHandler,\n updateLayoutFromSelection,\n maybeScroll,\n ],\n );\n\n useFocusedInputHandler(\n {\n onSelectionChange: onSelectionChange,\n },\n [onSelectionChange],\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\n\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 pendingSelectionForFocus.value = false;\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 // insets mode: set the full contentInset upfront so that maybeScroll\n // calculations are correct from the very first onMove frame.\n // layout mode: do NOT set it here — the spacer must grow frame-by-frame\n // in onMove to avoid a premature full-height jump before the keyboard moves.\n if (mode === \"insets\") {\n syncKeyboardFrame(e);\n }\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n\n if (\n lastSelection.value?.target === e.target &&\n selectionUpdatedSinceHide.value\n ) {\n // fresh selection arrived before onStart - use it to update layout\n updateLayoutFromSelection();\n pendingSelectionForFocus.value = false;\n } else {\n // selection hasn't arrived yet for the new target (iOS 15),\n // or it's stale from previous session (Android refocus same input).\n // Use stale selection as best-effort fallback if available for same target,\n // otherwise fall back to full input layout.\n // Will be corrected if a fresh onSelectionChange arrives.\n if (lastSelection.value?.target === e.target) {\n updateLayoutFromSelection();\n } else if (input.value) {\n layout.value = input.value;\n }\n pendingSelectionForFocus.value = true;\n }\n\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 if (!pendingSelectionForFocus.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\n if (mode === \"insets\") {\n ghostViewSpace.value =\n position.value +\n scrollViewLayout.value.height -\n scrollViewContentSize.value.height;\n\n if (ghostViewSpace.value > 0) {\n scrollPosition.value = position.value;\n }\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n if (removeGhostPadding(e.height)) {\n return;\n }\n\n // layout mode: drive the spacer view animation frame-by-frame\n if (mode === \"layout\") {\n syncKeyboardFrame(e);\n }\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 removeGhostPadding(e.height);\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n\n if (e.height === 0) {\n selectionUpdatedSinceHide.value = false;\n } else if (keyboardWillAppear.value) {\n // keyboard fully shown after appearing from hidden state — clear\n // pending flag to prevent leaking into next focus-change session.\n // Only when the keyboard was actually appearing (not a focus switch\n // with same keyboard height), otherwise we'd clear the flag before\n // onSelectionChange has a chance to process it.\n pendingSelectionForFocus.value = false;\n }\n\n syncKeyboardFrame(e);\n },\n },\n [\n mode,\n maybeScroll,\n removeGhostPadding,\n disableScrollOnKeyboardHide,\n syncKeyboardFrame,\n ],\n );\n\n const synchronize = useCallback(async () => {\n await update();\n\n runOnUI(() => {\n \"worklet\";\n\n scrollFromCurrentPosition();\n })();\n }, [update, scrollFromCurrentPosition]);\n\n useImperativeHandle(\n ref,\n () => {\n const scrollView = scrollViewRef.current;\n\n if (scrollView) {\n const scrollViewWithMethods =\n scrollView as KeyboardAwareScrollViewRef;\n\n scrollViewWithMethods.assureFocusedInputVisible = () => {\n synchronize();\n };\n\n return scrollViewWithMethods;\n }\n\n return {\n assureFocusedInputVisible: () => {\n synchronize();\n },\n } as KeyboardAwareScrollViewRef;\n },\n [synchronize],\n );\n\n useEffect(() => {\n synchronize();\n }, [bottomOffset]);\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 // input has changed layout - let's check if we need to scroll\n // may happen when you paste text, then onSelectionChange will be\n // fired earlier than text actually changes its layout\n scrollFromCurrentPosition();\n }\n },\n [],\n );\n\n const padding = useDerivedValue(\n () => (enabled ? currentKeyboardFrameHeight.value : 0),\n [enabled],\n );\n // layout mode only: a spacer view whose paddingBottom grows with the keyboard.\n // The `+ 1` ensures the scroll view never reaches its absolute end during animation,\n // avoiding the layout recalculation that triggers on every frame at the boundary.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n const layoutSpacerStyle = useAnimatedStyle(\n () =>\n enabled && mode === \"layout\"\n ? { paddingBottom: currentKeyboardFrameHeight.value + 1 }\n : {},\n [enabled, mode],\n );\n\n if (mode === \"layout\") {\n return (\n <ScrollViewComponent\n ref={onRef}\n {...rest}\n scrollEventThrottle={16}\n onLayout={onScrollViewLayout}\n >\n {children}\n {enabled && <Reanimated.View style={layoutSpacerStyle} />}\n </ScrollViewComponent>\n );\n }\n\n return (\n <ScrollViewWithBottomPadding\n ref={onRef}\n {...rest}\n bottomPadding={padding}\n scrollEventThrottle={16}\n ScrollViewComponent={ScrollViewComponent}\n onLayout={onScrollViewLayout}\n >\n {children}\n </ScrollViewWithBottomPadding>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;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;EACA;EACA,MAAMsH,iBAAiB,GAAG,IAAAC,uCAAgB,EACxC,MACEvH,OAAO,IAAIE,IAAI,KAAK,QAAQ,GACxB;IAAEsH,aAAa,EAAE9F,0BAA0B,CAACqB,KAAK,GAAG;EAAE,CAAC,GACvD,CAAC,CAAC,EACR,CAAC/C,OAAO,EAAEE,IAAI,CAChB,CAAC;EAED,IAAIA,IAAI,KAAK,QAAQ,EAAE;IACrB,oBACE9C,MAAA,CAAAe,OAAA,CAAAsJ,aAAA,CAACtH,mBAAmB,EAAAf,QAAA;MAClBoB,GAAG,EAAEM;IAAM,GACPP,IAAI;MACRmH,mBAAmB,EAAE,EAAG;MACxB7H,QAAQ,EAAE6C;IAAmB,IAE5B9C,QAAQ,EACRI,OAAO,iBAAI5C,MAAA,CAAAe,OAAA,CAAAsJ,aAAA,CAAClK,sBAAA,CAAAY,OAAU,CAACwJ,IAAI;MAACC,KAAK,EAAEN;IAAkB,CAAE,CACrC,CAAC;EAE1B;EAEA,oBACElK,MAAA,CAAAe,OAAA,CAAAsJ,aAAA,CAAC3J,4BAAA,CAAAK,OAA2B,EAAAiB,QAAA;IAC1BoB,GAAG,EAAEM;EAAM,GACPP,IAAI;IACRsH,aAAa,EAAET,OAAQ;IACvBM,mBAAmB,EAAE,EAAG;IACxBvH,mBAAmB,EAAEA,mBAAoB;IACzCN,QAAQ,EAAE6C;EAAmB,IAE5B9C,QAC0B,CAAC;AAElC,CACF,CAAC;AAAC,IAAAkI,QAAA,GAAAC,OAAA,CAAA5J,OAAA,GAEauB,uBAAuB","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { AnimatedScrollViewComponent } from \"../ScrollViewWithBottomPadding\";\nimport type { ScrollView, ScrollViewProps } from \"react-native\";\n\nexport type KeyboardAwareScrollViewMode = \"insets\" | \"layout\";\n\nexport type KeyboardAwareScrollViewProps = {\n /** The distance between the keyboard and the caret inside a focused `TextInput` when the 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 /**\n * Controls how keyboard space is created at the bottom of the `ScrollView`.\n *\n * - `\"insets\"` *(default)*: Extends the scrollable area via `contentInset` (iOS) and `ClippingScrollView` (Android). No layout reflow occurs — content positions remain stable during keyboard animation. Recommended for most use cases.\n * - `\"layout\"`: Appends a spacer `View` as the last child of the `ScrollView`. The spacer participates in layout, so flex-based arrangements (e.g. `justifyContent: \"space-between\"`, `gap`) reflow naturally when the keyboard appears. Use this when you need content to physically rearrange around the keyboard space.\n *\n * Default is `\"insets\"`.\n */\n mode?: KeyboardAwareScrollViewMode;\n /** Custom component for `ScrollView`. Default is `ScrollView`. */\n ScrollViewComponent?: AnimatedScrollViewComponent;\n} & ScrollViewProps;\nexport type KeyboardAwareScrollViewRef = {\n assureFocusedInputVisible: () => void;\n} & ScrollView;\n"],"mappings":"","ignoreList":[]}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = exports.TEST_ID_KEYBOARD_TOOLBAR_NEXT = exports.TEST_ID_KEYBOARD_TOOLBAR_DONE = exports.TEST_ID_KEYBOARD_TOOLBAR_CONTENT = exports.TEST_ID_KEYBOARD_TOOLBAR = exports.OPENED_OFFSET = exports.KEYBOARD_TOOLBAR_HEIGHT = exports.KEYBOARD_HAS_ROUNDED_CORNERS = exports.DEFAULT_OPACITY = void 0;
7
- var _reactNative = require("react-native");
7
+ var _constants = require("../../constants");
8
8
  const TEST_ID_KEYBOARD_TOOLBAR = exports.TEST_ID_KEYBOARD_TOOLBAR = "keyboard.toolbar";
9
9
  const TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = exports.TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;
10
10
  const TEST_ID_KEYBOARD_TOOLBAR_NEXT = exports.TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;
@@ -12,6 +12,6 @@ const TEST_ID_KEYBOARD_TOOLBAR_CONTENT = exports.TEST_ID_KEYBOARD_TOOLBAR_CONTEN
12
12
  const TEST_ID_KEYBOARD_TOOLBAR_DONE = exports.TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;
13
13
  const KEYBOARD_TOOLBAR_HEIGHT = exports.KEYBOARD_TOOLBAR_HEIGHT = 42;
14
14
  const DEFAULT_OPACITY = exports.DEFAULT_OPACITY = "FF";
15
- const KEYBOARD_HAS_ROUNDED_CORNERS = exports.KEYBOARD_HAS_ROUNDED_CORNERS = _reactNative.Platform.OS === "ios" && parseInt(_reactNative.Platform.Version, 10) >= 26;
15
+ const KEYBOARD_HAS_ROUNDED_CORNERS = exports.KEYBOARD_HAS_ROUNDED_CORNERS = _constants.KEYBOARD_BORDER_RADIUS > 0;
16
16
  const OPENED_OFFSET = exports.OPENED_OFFSET = KEYBOARD_HAS_ROUNDED_CORNERS ? -11 : 0;
17
17
  //# sourceMappingURL=constants.js.map