react-native-keyboard-controller 1.17.0 → 1.17.2

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 (133) hide show
  1. package/README.md +24 -23
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardViewGroup.kt +49 -15
  3. package/ios/delegates/KCTextInputCompositeDelegate.swift +16 -1
  4. package/ios/observers/FocusedInputObserver.swift +3 -1
  5. package/lib/commonjs/animated.js +23 -7
  6. package/lib/commonjs/animated.js.map +1 -1
  7. package/lib/commonjs/bindings.js +19 -0
  8. package/lib/commonjs/bindings.js.map +1 -1
  9. package/lib/commonjs/components/KeyboardAvoidingView/index.js +11 -2
  10. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  11. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +54 -39
  12. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  13. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +17 -1
  14. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  15. package/lib/commonjs/components/KeyboardStickyView/index.js +13 -0
  16. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  17. package/lib/commonjs/components/KeyboardToolbar/index.js +31 -22
  18. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  19. package/lib/commonjs/context.js +16 -0
  20. package/lib/commonjs/context.js.map +1 -1
  21. package/lib/commonjs/hooks/index.js +164 -0
  22. package/lib/commonjs/hooks/index.js.map +1 -1
  23. package/lib/commonjs/hooks/useKeyboardState/index.js +21 -0
  24. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
  25. package/lib/commonjs/internal.js +23 -1
  26. package/lib/commonjs/internal.js.map +1 -1
  27. package/lib/commonjs/module.js +4 -0
  28. package/lib/commonjs/module.js.map +1 -1
  29. package/lib/commonjs/monkey-patch.android.js +0 -5
  30. package/lib/commonjs/monkey-patch.android.js.map +1 -1
  31. package/lib/commonjs/{types.js → types/hooks.js} +1 -1
  32. package/lib/commonjs/types/hooks.js.map +1 -0
  33. package/lib/commonjs/types/index.js +50 -0
  34. package/lib/commonjs/types/index.js.map +1 -0
  35. package/lib/commonjs/types/internal.js +6 -0
  36. package/lib/commonjs/types/internal.js.map +1 -0
  37. package/lib/commonjs/types/module.js +6 -0
  38. package/lib/commonjs/types/module.js.map +1 -0
  39. package/lib/commonjs/types/views.js +6 -0
  40. package/lib/commonjs/types/views.js.map +1 -0
  41. package/lib/commonjs/utils/findNodeHandle/index.js +9 -0
  42. package/lib/commonjs/utils/findNodeHandle/index.js.map +1 -0
  43. package/lib/commonjs/utils/findNodeHandle/index.native.js +13 -0
  44. package/lib/commonjs/utils/findNodeHandle/index.native.js.map +1 -0
  45. package/lib/commonjs/views/OverKeyboardView/index.js +18 -4
  46. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
  47. package/lib/module/animated.js +23 -7
  48. package/lib/module/animated.js.map +1 -1
  49. package/lib/module/bindings.js +19 -0
  50. package/lib/module/bindings.js.map +1 -1
  51. package/lib/module/components/KeyboardAvoidingView/index.js +11 -2
  52. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  53. package/lib/module/components/KeyboardAwareScrollView/index.js +53 -38
  54. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  55. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +17 -1
  56. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  57. package/lib/module/components/KeyboardStickyView/index.js +13 -0
  58. package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
  59. package/lib/module/components/KeyboardToolbar/index.js +31 -22
  60. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  61. package/lib/module/context.js +16 -0
  62. package/lib/module/context.js.map +1 -1
  63. package/lib/module/hooks/index.js +164 -0
  64. package/lib/module/hooks/index.js.map +1 -1
  65. package/lib/module/hooks/useKeyboardState/index.js +21 -0
  66. package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
  67. package/lib/module/internal.js +23 -1
  68. package/lib/module/internal.js.map +1 -1
  69. package/lib/module/module.js +4 -0
  70. package/lib/module/module.js.map +1 -1
  71. package/lib/module/monkey-patch.android.js +0 -5
  72. package/lib/module/monkey-patch.android.js.map +1 -1
  73. package/lib/module/types/hooks.js +2 -0
  74. package/lib/module/types/hooks.js.map +1 -0
  75. package/lib/module/types/index.js +5 -0
  76. package/lib/module/types/index.js.map +1 -0
  77. package/lib/module/types/internal.js +2 -0
  78. package/lib/module/types/internal.js.map +1 -0
  79. package/lib/module/types/module.js +2 -0
  80. package/lib/module/types/module.js.map +1 -0
  81. package/lib/module/types/views.js +2 -0
  82. package/lib/module/types/views.js.map +1 -0
  83. package/lib/module/utils/findNodeHandle/index.js +2 -0
  84. package/lib/module/utils/findNodeHandle/index.js.map +1 -0
  85. package/lib/module/utils/findNodeHandle/index.native.js +3 -0
  86. package/lib/module/utils/findNodeHandle/index.native.js.map +1 -0
  87. package/lib/module/views/OverKeyboardView/index.js +18 -4
  88. package/lib/module/views/OverKeyboardView/index.js.map +1 -1
  89. package/lib/typescript/animated.d.ts +20 -6
  90. package/lib/typescript/bindings.d.ts +19 -0
  91. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +11 -2
  92. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +23 -6
  93. package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +17 -1
  94. package/lib/typescript/components/KeyboardStickyView/index.d.ts +15 -2
  95. package/lib/typescript/components/KeyboardToolbar/index.d.ts +13 -2
  96. package/lib/typescript/context.d.ts +32 -0
  97. package/lib/typescript/hooks/index.d.ts +157 -0
  98. package/lib/typescript/hooks/useKeyboardState/index.d.ts +20 -0
  99. package/lib/typescript/internal.d.ts +23 -1
  100. package/lib/typescript/module.d.ts +3 -0
  101. package/lib/typescript/{types.d.ts → types/hooks.d.ts} +72 -78
  102. package/lib/typescript/types/index.d.ts +4 -0
  103. package/lib/typescript/types/internal.d.ts +17 -0
  104. package/lib/typescript/types/module.d.ts +91 -0
  105. package/lib/typescript/types/views.d.ts +45 -0
  106. package/lib/typescript/utils/findNodeHandle/index.d.ts +4 -0
  107. package/lib/typescript/utils/findNodeHandle/index.native.d.ts +2 -0
  108. package/lib/typescript/views/OverKeyboardView/index.d.ts +14 -1
  109. package/package.json +2 -1
  110. package/src/animated.tsx +27 -12
  111. package/src/bindings.ts +19 -0
  112. package/src/components/KeyboardAvoidingView/index.tsx +11 -2
  113. package/src/components/KeyboardAwareScrollView/index.tsx +56 -41
  114. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +17 -1
  115. package/src/components/KeyboardStickyView/index.tsx +14 -1
  116. package/src/components/KeyboardToolbar/index.tsx +31 -19
  117. package/src/context.ts +33 -0
  118. package/src/hooks/index.ts +157 -0
  119. package/src/hooks/useKeyboardState/index.ts +20 -0
  120. package/src/internal.ts +23 -1
  121. package/src/module.ts +3 -0
  122. package/src/monkey-patch.android.ts +3 -6
  123. package/src/{types.ts → types/hooks.ts} +72 -105
  124. package/src/types/index.ts +4 -0
  125. package/src/types/internal.ts +24 -0
  126. package/src/types/module.ts +105 -0
  127. package/src/types/views.ts +46 -0
  128. package/src/utils/findNodeHandle/index.native.ts +3 -0
  129. package/src/utils/findNodeHandle/index.ts +6 -0
  130. package/src/views/OverKeyboardView/index.tsx +15 -4
  131. package/lib/commonjs/types.js.map +0 -1
  132. package/lib/module/types.js +0 -2
  133. package/lib/module/types.js.map +0 -1
package/README.md CHANGED
@@ -1,37 +1,38 @@
1
1
  # react-native-keyboard-controller
2
2
 
3
- Keyboard manager which works in identical way on both iOS and Android.
3
+ A universal keyboard handling solution for React Native — lightweight, fully customizable, and built for real-world apps. Smooth animations, consistent behavior on both iOS and Android, with a developer-oriented design.
4
4
 
5
- ## Demonstration
5
+ <div>
6
+ <img align="right" width="32%" src="./gifs/demo.png?raw=true">
7
+ </div>
6
8
 
7
- <img src="./gifs/demo.gif?raw=true" width="60%">
9
+ ### Key features
8
10
 
9
- ## Key features
11
+ - 🧬 Map keyboard movement to animated values
12
+ - 🧪 `keyboardWillShow` / `keyboardWillHide` events now available on Android
13
+ - ⚡ Change soft input mode on Android
14
+ - 🚀 Reanimated support
15
+ - 📱 Interactive keyboard dismissing 👆📱
16
+ - 📚 Prebuilt components (`KeyboardStickyView`, `KeyboardAwareScrollView`, reworked `KeyboardAvoidingView`)
17
+ - 📐 `KeyboardToolbar` with customizable _**previous**_, _**next**_, and _**done**_ buttons
18
+ - 🌐 Display anything over the keyboard (without dismissing it) using `OverKeyboardView`
19
+ - 📝 Easy retrieval of focused input info
20
+ - 🧭 Compatible with any navigation library
21
+ - ✨ More coming soon... stay tuned! 😊
10
22
 
11
- - mapping keyboard movement to animated values 😎
12
- - missing `keyboardWillShow` / `keyboardWillHide` events are available on Android 😍
13
- - module for changing soft input mode on Android 🤔
14
- - reanimated support 🚀
15
- - interactive keyboard dismissing 👆📱
16
- - prebuilt components (`KeyboardStickyView`, `KeyboardAwareScrollView`, re-worked `KeyboardAvoidingView`) 📚
17
- - `KeyboardToolbar` with easy behavior customization of _**previous**_, _**next**_ and _**done**_ buttons in the keyboard toolbar 📐
18
- - show anything over the keyboard (without dismissing it) using `OverKeyboardView` 🌐
19
- - easy focused input information retrieval 📝 🔮
20
- - works with any navigation library 🧭
21
- - and more is coming... Stay tuned! 😊
23
+ ### Installation
22
24
 
23
- ## Installation
25
+ Check out the [installation](https://kirillzyusko.github.io/react-native-keyboard-controller/docs/installation) section of the docs for detailed setup instructions.
24
26
 
25
- Check out the [installation](https://kirillzyusko.github.io/react-native-keyboard-controller/docs/installation) section of docs for the detailed installation instructions.
27
+ ### Documentation
26
28
 
27
- ## Documentation
29
+ Full API reference and guides available at:
30
+ [https://kirillzyusko.github.io/react-native-keyboard-controller/](https://kirillzyusko.github.io/react-native-keyboard-controller/)
28
31
 
29
- Check out the dedicated documentation page for information about this library, API reference and more: [https://kirillzyusko.github.io/react-native-keyboard-controller/](https://kirillzyusko.github.io/react-native-keyboard-controller/)
32
+ ### Contributing
30
33
 
31
- ## Contributing
34
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repo and development workflow.
32
35
 
33
- See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
34
-
35
- ## License
36
+ ### License
36
37
 
37
38
  MIT
@@ -18,6 +18,9 @@ import com.facebook.react.uimanager.events.EventDispatcher
18
18
  import com.facebook.react.views.view.ReactViewGroup
19
19
  import com.reactnativekeyboardcontroller.extensions.dp
20
20
  import com.reactnativekeyboardcontroller.extensions.getDisplaySize
21
+ import com.reactnativekeyboardcontroller.log.Logger
22
+
23
+ private val TAG = OverKeyboardHostView::class.qualifiedName
21
24
 
22
25
  @SuppressLint("ViewConstructor")
23
26
  class OverKeyboardHostView(
@@ -27,7 +30,11 @@ class OverKeyboardHostView(
27
30
  private var windowManager: WindowManager = reactContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager
28
31
  private var hostView: OverKeyboardRootViewGroup = OverKeyboardRootViewGroup(reactContext)
29
32
 
30
- internal var stateWrapper: StateWrapper? = null
33
+ var stateWrapper: StateWrapper?
34
+ get() = hostView.stateWrapper
35
+ set(stateWrapper) {
36
+ hostView.stateWrapper = stateWrapper
37
+ }
31
38
 
32
39
  init {
33
40
  hostView.eventDispatcher = dispatcher
@@ -89,24 +96,14 @@ class OverKeyboardHostView(
89
96
  PixelFormat.TRANSLUCENT,
90
97
  )
91
98
 
92
- stretchTo(fullScreen = true)
93
99
  windowManager.addView(hostView, layoutParams)
94
100
  }
95
101
 
96
102
  fun hide() {
97
103
  if (hostView.isAttached) {
98
104
  windowManager.removeView(hostView)
99
- stretchTo(fullScreen = false)
100
105
  }
101
106
  }
102
-
103
- private fun stretchTo(fullScreen: Boolean) {
104
- val displaySize = reactContext.getDisplaySize()
105
- val newStateData: WritableMap = WritableNativeMap()
106
- newStateData.putDouble("screenWidth", if (fullScreen) displaySize.x.toFloat().dp else 0.0)
107
- newStateData.putDouble("screenHeight", if (fullScreen) displaySize.y.toFloat().dp else 0.0)
108
- stateWrapper?.updateState(newStateData)
109
- }
110
107
  }
111
108
 
112
109
  @SuppressLint("ViewConstructor")
@@ -117,6 +114,7 @@ class OverKeyboardRootViewGroup(
117
114
  private val jsTouchDispatcher: JSTouchDispatcher = JSTouchDispatcher(this)
118
115
  private var jsPointerDispatcher: JSPointerDispatcherCompat? = null
119
116
  internal var eventDispatcher: EventDispatcher? = null
117
+ internal var stateWrapper: StateWrapper? = null
120
118
  internal var isAttached = false
121
119
 
122
120
  init {
@@ -128,20 +126,40 @@ class OverKeyboardRootViewGroup(
128
126
  // region life cycles
129
127
  override fun onAttachedToWindow() {
130
128
  super.onAttachedToWindow()
129
+ val displaySize = reactContext.getDisplaySize()
130
+ stretchTo(width = displaySize.x, height = displaySize.y)
131
131
  isAttached = true
132
132
  }
133
133
 
134
134
  override fun onDetachedFromWindow() {
135
135
  super.onDetachedFromWindow()
136
+ stretchTo(width = 0, height = 0)
136
137
  isAttached = false
137
138
  }
139
+
140
+ override fun onSizeChanged(
141
+ width: Int,
142
+ height: Int,
143
+ oldWidth: Int,
144
+ oldHeight: Int,
145
+ ) {
146
+ super.onSizeChanged(width, height, oldWidth, oldHeight)
147
+ stretchTo(width, height)
148
+ }
149
+
138
150
  // endregion
139
151
 
140
152
  // region Touch events handling
141
153
  override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
142
154
  eventDispatcher?.let { eventDispatcher ->
143
- jsTouchDispatcher.handleTouchEvent(event, eventDispatcher)
144
- jsPointerDispatcher?.handleMotionEventCompat(event, eventDispatcher, true)
155
+ try {
156
+ jsTouchDispatcher.handleTouchEvent(event, eventDispatcher)
157
+ jsPointerDispatcher?.handleMotionEventCompat(event, eventDispatcher, true)
158
+ } catch (
159
+ @Suppress("detekt:TooGenericExceptionCaught") e: RuntimeException,
160
+ ) {
161
+ Logger.w(TAG, "Can not handle touch event", e)
162
+ }
145
163
  }
146
164
  return super.onInterceptTouchEvent(event)
147
165
  }
@@ -149,8 +167,14 @@ class OverKeyboardRootViewGroup(
149
167
  @SuppressLint("ClickableViewAccessibility")
150
168
  override fun onTouchEvent(event: MotionEvent): Boolean {
151
169
  eventDispatcher?.let { eventDispatcher ->
152
- jsTouchDispatcher.handleTouchEvent(event, eventDispatcher)
153
- jsPointerDispatcher?.handleMotionEventCompat(event, eventDispatcher, false)
170
+ try {
171
+ jsTouchDispatcher.handleTouchEvent(event, eventDispatcher)
172
+ jsPointerDispatcher?.handleMotionEventCompat(event, eventDispatcher, false)
173
+ } catch (
174
+ @Suppress("detekt:TooGenericExceptionCaught") e: RuntimeException,
175
+ ) {
176
+ Logger.w(TAG, "Can not handle touch event", e)
177
+ }
154
178
  }
155
179
  super.onTouchEvent(event)
156
180
  // In case when there is no children interested in handling touch event, we return true from
@@ -201,4 +225,14 @@ class OverKeyboardRootViewGroup(
201
225
  reactContext.reactApplicationContext.handleException(RuntimeException(t))
202
226
  }
203
227
  // endregion
228
+
229
+ private fun stretchTo(
230
+ width: Int,
231
+ height: Int,
232
+ ) {
233
+ val newStateData: WritableMap = WritableNativeMap()
234
+ newStateData.putDouble("screenWidth", width.toFloat().dp)
235
+ newStateData.putDouble("screenHeight", height.toFloat().dp)
236
+ stateWrapper?.updateState(newStateData)
237
+ }
204
238
  }
@@ -65,7 +65,7 @@ class KCTextInputCompositeDelegate: NSObject, UITextViewDelegate, UITextFieldDel
65
65
  // MARK: setters/getters
66
66
 
67
67
  public func setTextViewDelegate(delegate: UITextViewDelegate?) {
68
- // remove KVO from any old textField
68
+ // remove KVO from any old textView
69
69
  if let oldTextField = observedTextFieldForSelection {
70
70
  removeSelectionRangeObserver(from: oldTextField)
71
71
  }
@@ -96,6 +96,21 @@ class KCTextInputCompositeDelegate: NSObject, UITextViewDelegate, UITextFieldDel
96
96
  }
97
97
  }
98
98
 
99
+ public func canSubstituteTextFieldDelegate(delegate: UITextFieldDelegate?) -> Bool {
100
+ let type = String(describing: delegate)
101
+ if type.range(of: "SQIPTextFieldInputModifier") != nil {
102
+ // SQIPTextFieldInputModifier is a private class used internally by Square.
103
+ // It forwards input events to the keyboard-controller delegate.
104
+ // To prevent an infinite loop, we avoid setting our delegate in this case.
105
+ // Since Square's SDK is used imperatively and doesn't allow adding custom components,
106
+ // keyboard-controller components cannot be used in this context,
107
+ // so it's safe to skip replacing the delegate.
108
+ return false
109
+ }
110
+
111
+ return true
112
+ }
113
+
99
114
  // Getter for the active delegate
100
115
  public var activeDelegate: AnyObject? {
101
116
  return textViewDelegate ?? textFieldDelegate
@@ -228,7 +228,9 @@ public class FocusedInputObserver: NSObject {
228
228
 
229
229
  private func substituteDelegate(_ input: UIResponder?) {
230
230
  if let textField = input as? UITextField {
231
- if !(textField.delegate is KCTextInputCompositeDelegate) {
231
+ if !(textField.delegate is KCTextInputCompositeDelegate),
232
+ delegate.canSubstituteTextFieldDelegate(delegate: textField.delegate)
233
+ {
232
234
  delegate.setTextFieldDelegate(delegate: textField.delegate, textField: textField)
233
235
  textField.delegate = delegate
234
236
  }
@@ -32,13 +32,29 @@ const styles = _reactNative.StyleSheet.create({
32
32
  // capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package
33
33
  // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details
34
34
  const OS = _reactNative.Platform.OS;
35
- const KeyboardProvider = ({
36
- children,
37
- statusBarTranslucent,
38
- navigationBarTranslucent,
39
- preserveEdgeToEdge,
40
- enabled: initiallyEnabled = true
41
- }) => {
35
+
36
+ /**
37
+ * A component that wrap your app. Under the hood it works with {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|KeyboardControllerView} to receive events during keyboard movements,
38
+ * maps these events to `Animated`/`Reanimated` values and store them in context.
39
+ *
40
+ * @param props - Provider props, such as `statusBarTranslucent`, `navigationBarTranslucent`, etc.
41
+ * @returns A component that should be mounted in root of your App layout.
42
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-provider|Documentation} page for more details.
43
+ * @example
44
+ * ```tsx
45
+ * <KeyboardProvider>
46
+ * <NavigationContainer />
47
+ * </KeyboardProvider>
48
+ * ```
49
+ */
50
+ const KeyboardProvider = props => {
51
+ const {
52
+ children,
53
+ statusBarTranslucent,
54
+ navigationBarTranslucent,
55
+ preserveEdgeToEdge,
56
+ enabled: initiallyEnabled = true
57
+ } = props;
42
58
  // ref
43
59
  const viewTagRef = (0, _react.useRef)(null);
44
60
  // state
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeIsEdgeToEdge","_reactNativeReanimated","_bindings","_context","_eventMappings","_internal","_monkeyPatch","_reanimated","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","IS_EDGE_TO_EDGE","isEdgeToEdge","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","OS","Platform","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","preserveEdgeToEdge","enabled","initiallyEnabled","viewTagRef","useRef","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","useEventHandlerRegistration","keyboardEventsMap","setInputHandlers","focusedInputEventsMap","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","onKeyboardMoveEnd","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","target","useLayoutEffect","applyMonkeyPatch","revertMonkeyPatch","__DEV__","controlEdgeToEdgeValues","createElement","KeyboardContext","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View","exports"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { Animated, Platform, StyleSheet } from \"react-native\";\nimport {\n controlEdgeToEdgeValues,\n isEdgeToEdge,\n} from \"react-native-is-edge-to-edge\";\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\n\nimport { KeyboardControllerView } from \"./bindings\";\nimport { KeyboardContext } from \"./context\";\nimport { focusedInputEventsMap, keyboardEventsMap } from \"./event-mappings\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { applyMonkeyPatch, revertMonkeyPatch } from \"./monkey-patch\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\n} from \"./reanimated\";\n\nimport type { KeyboardAnimationContext } from \"./context\";\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from \"./types\";\nimport type { ViewStyle } from \"react-native\";\n\nconst IS_EDGE_TO_EDGE = isEdgeToEdge();\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(KeyboardControllerView),\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: \"none\",\n position: \"absolute\",\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n * @platform android\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592\n * @platform android\n */\n preserveEdgeToEdge?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state,\n * i. e. if you try to change this prop after component mount it will not have any effect.\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n};\n\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(\n keyboardEventsMap,\n viewTagRef,\n );\n const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(\n focusedInputEventsMap,\n viewTagRef,\n );\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled],\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n [],\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n // Setting useNativeDriver to true on web triggers a warning due to the absence of a native driver for web. Therefore, it is set to false.\n { useNativeDriver: Platform.OS !== \"web\" },\n ),\n [],\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n \"worklet\";\n\n if (platforms.includes(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n },\n [],\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n \"worklet\";\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n [],\n );\n\n // layout effects\n useLayoutEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n if (__DEV__) {\n controlEdgeToEdgeValues({\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n });\n }\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}\n statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}\n preserveEdgeToEdge={IS_EDGE_TO_EDGE || preserveEdgeToEdge}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onKeyboardMoveEnd={OS === \"android\" ? onKeyboardMove : undefined}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AAIA,IAAAG,sBAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAEA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AAGsB,SAAAU,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,SAAAZ,wBAAAY,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,E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,CAAAqF,aAAA,CAACpG,YAAA,CAAAkC,QAAQ,CAACyE,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAjC,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAACkC,OAAA,CAAA9D,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeIsEdgeToEdge","_reactNativeReanimated","_bindings","_context","_eventMappings","_internal","_monkeyPatch","_reanimated","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","IS_EDGE_TO_EDGE","isEdgeToEdge","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","OS","Platform","KeyboardProvider","props","children","statusBarTranslucent","navigationBarTranslucent","preserveEdgeToEdge","enabled","initiallyEnabled","viewTagRef","useRef","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","useEventHandlerRegistration","keyboardEventsMap","setInputHandlers","focusedInputEventsMap","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","onKeyboardMoveEnd","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","target","useLayoutEffect","applyMonkeyPatch","revertMonkeyPatch","__DEV__","controlEdgeToEdgeValues","createElement","KeyboardContext","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View","exports"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { Animated, Platform, StyleSheet } from \"react-native\";\nimport {\n controlEdgeToEdgeValues,\n isEdgeToEdge,\n} from \"react-native-is-edge-to-edge\";\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\n\nimport { KeyboardControllerView } from \"./bindings\";\nimport { KeyboardContext } from \"./context\";\nimport { focusedInputEventsMap, keyboardEventsMap } from \"./event-mappings\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { applyMonkeyPatch, revertMonkeyPatch } from \"./monkey-patch\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\n} from \"./reanimated\";\n\nimport type { KeyboardAnimationContext } from \"./context\";\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from \"./types\";\nimport type { ViewStyle } from \"react-native\";\n\nconst IS_EDGE_TO_EDGE = isEdgeToEdge();\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(KeyboardControllerView),\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: \"none\",\n position: \"absolute\",\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592\n */\n preserveEdgeToEdge?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state\n * (if you try to change this prop after component mount it will not have any effect).\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n};\n\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\n/**\n * A component that wrap your app. Under the hood it works with {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|KeyboardControllerView} to receive events during keyboard movements,\n * maps these events to `Animated`/`Reanimated` values and store them in context.\n *\n * @param props - Provider props, such as `statusBarTranslucent`, `navigationBarTranslucent`, etc.\n * @returns A component that should be mounted in root of your App layout.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-provider|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardProvider>\n * <NavigationContainer />\n * </KeyboardProvider>\n * ```\n */\nexport const KeyboardProvider = (props: KeyboardProviderProps) => {\n const {\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n enabled: initiallyEnabled = true,\n } = props;\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(\n keyboardEventsMap,\n viewTagRef,\n );\n const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(\n focusedInputEventsMap,\n viewTagRef,\n );\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled],\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n [],\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n // Setting useNativeDriver to true on web triggers a warning due to the absence of a native driver for web. Therefore, it is set to false.\n { useNativeDriver: Platform.OS !== \"web\" },\n ),\n [],\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n \"worklet\";\n\n if (platforms.includes(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n },\n [],\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n \"worklet\";\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n [],\n );\n\n // layout effects\n useLayoutEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n if (__DEV__) {\n controlEdgeToEdgeValues({\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n });\n }\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}\n statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}\n preserveEdgeToEdge={IS_EDGE_TO_EDGE || preserveEdgeToEdge}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onKeyboardMoveEnd={OS === \"android\" ? onKeyboardMove : undefined}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AAIA,IAAAG,sBAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAEA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AAGsB,SAAAU,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,SAA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C/D3B,cAAc,EAAEnC,EAAE,KAAK,SAAS,GAAGmC,cAAc,GAAG2B,SAAU;IAC9DhB,yBAAyB,EAAEX,cAAe;IAC1CY,iBAAiB,EAAE/C,EAAE,KAAK,SAAS,GAAGmC,cAAc,GAAG2B,SAAU;IACjEC,qCAAqC,EAAEf;EAAmB,GAEzD5C,QAC6B,CAAC,eACjCnD,MAAA,CAAAkB,OAAA,CAAAsF,aAAA,CAACrG,YAAA,CAAAkC,QAAQ,CAAC0E,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAjC,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAACkC,OAAA,CAAA/D,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -14,6 +14,15 @@ const KeyboardControllerNative = exports.KeyboardControllerNative = {
14
14
  addListener: NOOP,
15
15
  removeListeners: NOOP
16
16
  };
17
+ /**
18
+ * An event emitter that provides a way to subscribe to next keyboard events:
19
+ * - `keyboardWillShow`;
20
+ * - `keyboardDidShow`;
21
+ * - `keyboardWillHide`;
22
+ * - `keyboardDidHide`.
23
+ *
24
+ * Use `addListener` function to add your event listener for a specific keyboard event.
25
+ */
17
26
  const KeyboardEvents = exports.KeyboardEvents = {
18
27
  addListener: () => ({
19
28
  remove: NOOP
@@ -33,7 +42,17 @@ const WindowDimensionsEvents = exports.WindowDimensionsEvents = {
33
42
  remove: NOOP
34
43
  })
35
44
  };
45
+ /**
46
+ * A view that sends events whenever keyboard or focused events are happening.
47
+ *
48
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|Documentation} page for more details.
49
+ */
36
50
  const KeyboardControllerView = exports.KeyboardControllerView = _reactNative.View;
51
+ /**
52
+ * A view that defines a region on the screen, where gestures will control the keyboard position.
53
+ *
54
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-gesture-area|Documentation} page for more details.
55
+ */
37
56
  const KeyboardGestureArea = exports.KeyboardGestureArea = _reactNative.View;
38
57
  const RCTOverKeyboardView = exports.RCTOverKeyboardView = _reactNative.View;
39
58
  //# sourceMappingURL=bindings.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","NOOP","KeyboardControllerNative","exports","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","View","KeyboardGestureArea","RCTOverKeyboardView"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\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 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>;\nexport const RCTOverKeyboardView =\n View as unknown as React.FC<OverKeyboardViewProps>;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAaA,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,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;AAChD,MAAME,mBAAmB,GAAAd,OAAA,CAAAc,mBAAA,GAC9BF,iBAAkD","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","NOOP","KeyboardControllerNative","exports","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","View","KeyboardGestureArea","RCTOverKeyboardView"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\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 dismiss: NOOP,\n setFocusTo: NOOP,\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>;\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"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAaA,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,UAAU,EAAEN,IAAI;EAChBO,WAAW,EAAEP,IAAI;EACjBQ,eAAe,EAAER;AACnB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,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;AACD;AACA;AACA;AACA;AACA;AACO,MAAMa,sBAAsB,GAAAX,OAAA,CAAAW,sBAAA,GACjCC,iBAAoD;AACtD;AACA;AACA;AACA;AACA;AACO,MAAMC,mBAAmB,GAAAb,OAAA,CAAAa,mBAAA,GAC9BD,iBAAqD;AAChD,MAAME,mBAAmB,GAAAd,OAAA,CAAAc,mBAAA,GAC9BF,iBAAkD","ignoreList":[]}
@@ -20,8 +20,17 @@ const defaultLayout = {
20
20
  };
21
21
 
22
22
  /**
23
- * View that moves out of the way when the keyboard appears by automatically
24
- * adjusting its height, position, or bottom padding.
23
+ * A View component that automatically adjusts its height, position, or bottom padding
24
+ * when the keyboard appears to ensure that the content remains visible.
25
+ *
26
+ * @returns A View component that adjusts to keyboard visibility.
27
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-avoiding-view|Documentation} page for more details.
28
+ * @example
29
+ * ```tsx
30
+ * <KeyboardAvoidingView behavior="padding">
31
+ * <TextInput />
32
+ * </KeyboardAvoidingView>
33
+ * ```
25
34
  */
26
35
  const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)(({
27
36
  behavior,
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_hooks","_hooks2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","defaultLayout","x","y","width","height","KeyboardAvoidingView","forwardRef","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","ref","initialFrame","useSharedValue","frame","useDerivedValue","value","translate","padding","useTranslateAnimation","keyboard","useKeyboardAnimation","screenHeight","useWindowDimensions","relativeKeyboardHeight","useCallback","keyboardY","heightWhenOpened","Math","max","interpolateToRelativeKeyboardHeight","interpolate","onLayoutWorklet","layout","isClosed","runOnUI","nativeEvent","animatedStyle","useAnimatedStyle","bottom","progress","translateY","paddingBottom","bottomHeight","flex","paddingTop","transform","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 \"../../hooks\";\n\nimport { useKeyboardAnimation, useTranslateAnimation } from \"./hooks\";\n\nimport type { LayoutRectangle, ViewProps } from \"react-native\";\n\nexport type KeyboardAvoidingViewBaseProps = {\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\nexport type KeyboardAvoidingViewProps = KeyboardAvoidingViewBaseProps &\n (\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"position\";\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps[\"style\"];\n }\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"height\" | \"padding\" | \"translate-with-padding\";\n\n /**\n * `contentContainerStyle` is not allowed for these behaviors.\n */\n contentContainerStyle?: never;\n }\n );\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 { translate, padding } = useTranslateAnimation();\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 const interpolateToRelativeKeyboardHeight = useCallback(\n (value: number) => {\n \"worklet\";\n\n return interpolate(value, [0, 1], [0, relativeKeyboardHeight()]);\n },\n [relativeKeyboardHeight],\n );\n\n const onLayoutWorklet = useCallback(\n (layout: LayoutRectangle) => {\n \"worklet\";\n\n if (\n keyboard.isClosed.value ||\n initialFrame.value === null ||\n behavior !== \"height\"\n ) {\n // eslint-disable-next-line react-compiler/react-compiler\n initialFrame.value = layout;\n }\n },\n [behavior],\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 = interpolateToRelativeKeyboardHeight(\n keyboard.progress.value,\n );\n const translateY = interpolateToRelativeKeyboardHeight(translate.value);\n const paddingBottom = interpolateToRelativeKeyboardHeight(padding.value);\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 case \"translate-with-padding\":\n return {\n paddingTop: paddingBottom,\n transform: [{ translateY: -translateY }],\n };\n\n default:\n return {};\n }\n }, [behavior, enabled, interpolateToRelativeKeyboardHeight]);\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 style={combinedStyles}\n onLayout={onLayout}\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;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAAsE,SAAAK,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,SAAAP,wBAAAO,CAAA,EAAAE,C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;AAAC,IAAAkD,QAAA,GAAAC,OAAA,CAAA/E,OAAA,GAEayB,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_hooks","_hooks2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","defaultLayout","x","y","width","height","KeyboardAvoidingView","forwardRef","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","ref","initialFrame","useSharedValue","frame","useDerivedValue","value","translate","padding","useTranslateAnimation","keyboard","useKeyboardAnimation","screenHeight","useWindowDimensions","relativeKeyboardHeight","useCallback","keyboardY","heightWhenOpened","Math","max","interpolateToRelativeKeyboardHeight","interpolate","onLayoutWorklet","layout","isClosed","runOnUI","nativeEvent","animatedStyle","useAnimatedStyle","bottom","progress","translateY","paddingBottom","bottomHeight","flex","paddingTop","transform","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 \"../../hooks\";\n\nimport { useKeyboardAnimation, useTranslateAnimation } from \"./hooks\";\n\nimport type { LayoutRectangle, ViewProps } from \"react-native\";\n\nexport type KeyboardAvoidingViewBaseProps = {\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\nexport type KeyboardAvoidingViewProps = KeyboardAvoidingViewBaseProps &\n (\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"position\";\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps[\"style\"];\n }\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"height\" | \"padding\" | \"translate-with-padding\";\n\n /**\n * `contentContainerStyle` is not allowed for these behaviors.\n */\n contentContainerStyle?: never;\n }\n );\n\nconst defaultLayout: LayoutRectangle = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n};\n\n/**\n * A View component that automatically adjusts its height, position, or bottom padding\n * when the keyboard appears to ensure that the content remains visible.\n *\n * @returns A View component that adjusts to keyboard visibility.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-avoiding-view|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardAvoidingView behavior=\"padding\">\n * <TextInput />\n * </KeyboardAvoidingView>\n * ```\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 { translate, padding } = useTranslateAnimation();\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 const interpolateToRelativeKeyboardHeight = useCallback(\n (value: number) => {\n \"worklet\";\n\n return interpolate(value, [0, 1], [0, relativeKeyboardHeight()]);\n },\n [relativeKeyboardHeight],\n );\n\n const onLayoutWorklet = useCallback(\n (layout: LayoutRectangle) => {\n \"worklet\";\n\n if (\n keyboard.isClosed.value ||\n initialFrame.value === null ||\n behavior !== \"height\"\n ) {\n // eslint-disable-next-line react-compiler/react-compiler\n initialFrame.value = layout;\n }\n },\n [behavior],\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 = interpolateToRelativeKeyboardHeight(\n keyboard.progress.value,\n );\n const translateY = interpolateToRelativeKeyboardHeight(translate.value);\n const paddingBottom = interpolateToRelativeKeyboardHeight(padding.value);\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 case \"translate-with-padding\":\n return {\n paddingTop: paddingBottom,\n transform: [{ translateY: -translateY }],\n };\n\n default:\n return {};\n }\n }, [behavior, enabled, interpolateToRelativeKeyboardHeight]);\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 style={combinedStyles}\n onLayout={onLayout}\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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,CAAAS,OAAU,CAAC6E,IAAI;MAAC7C,KAAK,EAAE0C;IAAe,GAAE9C,QAA0B,CAC/D,CAAC;EAEX;EAEA,oBACEzC,MAAA,CAAAa,OAAA,CAAA4E,aAAA,CAACrF,sBAAA,CAAAS,OAAU,CAAC6E,IAAI,EAAA/D,QAAA;IACdsB,GAAG,EAAEA,GAAI;IACTJ,KAAK,EAAE0C,cAAe;IACtBzC,QAAQ,EAAEA;EAAS,GACfE,KAAK,GAERP,QACc,CAAC;AAEtB,CACF,CAAC;AAAC,IAAAkD,QAAA,GAAAC,OAAA,CAAA/E,OAAA,GAEayB,oBAAoB","ignoreList":[]}
@@ -5,51 +5,66 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
8
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
9
  var _hooks = require("../../hooks");
10
+ var _findNodeHandle = require("../../utils/findNodeHandle");
11
11
  var _useSmoothKeyboardHandler = require("./useSmoothKeyboardHandler");
12
12
  var _utils = require("./utils");
13
13
  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); }
14
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
15
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
16
- /*
17
- * Everything begins from `onStart` handler. This handler is called every time,
18
- * when keyboard changes its size or when focused `TextInput` was changed. In
19
- * this handler we are calculating/memoizing values which later will be used
20
- * during layout movement. For that we calculate:
21
- * - layout of focused field (`layout`) - to understand whether there will be overlap
22
- * - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation
23
- * - future keyboard height (`keyboardHeight`) - used in scroll interpolation
24
- * - current scroll position (`scrollPosition`) - used to scroll from this point
25
- *
26
- * Once we've calculated all necessary variables - we can actually start to use them.
27
- * It happens in `onMove` handler - this function simply calls `maybeScroll` with
28
- * current keyboard frame height. This functions makes the smooth transition.
29
- *
30
- * When the transition has finished we go to `onEnd` handler. In this handler
31
- * we verify, that the current field is not overlapped within a keyboard frame.
32
- * For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,
33
- * however there could be some cases, when `onMove` is not called:
34
- * - on iOS when TextInput was changed - keyboard transition is instant
35
- * - on Android when TextInput was changed and keyboard size wasn't changed
36
- * So `onEnd` handler handle the case, when `onMove` wasn't triggered.
37
- *
38
- * ====================================================================================================================+
39
- * -----------------------------------------------------Flow chart-----------------------------------------------------+
40
- * ====================================================================================================================+
41
- *
42
- * +============================+ +============================+ +==================================+
43
- * + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>
44
- * + + + (run `onStart`) + + `onMove` is getting called +
45
- * +============================+ +============================+ +==================================+
46
- *
16
+ // Everything begins from `onStart` handler. This handler is called every time,
17
+ // when keyboard changes its size or when focused `TextInput` was changed. In
18
+ // this handler we are calculating/memoizing values which later will be used
19
+ // during layout movement. For that we calculate:
20
+ // - layout of focused field (`layout`) - to understand whether there will be overlap
21
+ // - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation
22
+ // - future keyboard height (`keyboardHeight`) - used in scroll interpolation
23
+ // - current scroll position (`scrollPosition`) - used to scroll from this point
24
+ //
25
+ // Once we've calculated all necessary variables - we can actually start to use them.
26
+ // It happens in `onMove` handler - this function simply calls `maybeScroll` with
27
+ // current keyboard frame height. This functions makes the smooth transition.
28
+ //
29
+ // When the transition has finished we go to `onEnd` handler. In this handler
30
+ // we verify, that the current field is not overlapped within a keyboard frame.
31
+ // For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,
32
+ // however there could be some cases, when `onMove` is not called:
33
+ // - on iOS when TextInput was changed - keyboard transition is instant
34
+ // - on Android when TextInput was changed and keyboard size wasn't changed
35
+ // So `onEnd` handler handle the case, when `onMove` wasn't triggered.
36
+ //
37
+ // ====================================================================================================================+
38
+ // -----------------------------------------------------Flow chart-----------------------------------------------------+
39
+ // ====================================================================================================================+
40
+ //
41
+ // +============================+ +============================+ +==================================+
42
+ // + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>
43
+ // + + + (run `onStart`) + + `onMove` is getting called +
44
+ // +============================+ +============================+ +==================================+
45
+ //
46
+ // +============================+ +============================+ +=====================================+
47
+ // + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +
48
+ // + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +
49
+ // +============================+ +============================+ +=====================================+
50
+ //
51
+
52
+ /**
53
+ * A ScrollView component that automatically handles keyboard appearance and disappearance
54
+ * by adjusting its content position to ensure the focused input remains visible.
47
55
  *
48
- * +============================+ +============================+ +=====================================+
49
- * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +
50
- * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +
51
- * +============================+ +============================+ +=====================================+
56
+ * The component uses a sophisticated animation system to smoothly handle keyboard transitions
57
+ * and maintain proper scroll position during keyboard interactions.
52
58
  *
59
+ * @returns A ScrollView component that handles keyboard interactions.
60
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-aware-scroll-view|Documentation} page for more details.
61
+ * @example
62
+ * ```tsx
63
+ * <KeyboardAwareScrollView bottomOffset={20}>
64
+ * <TextInput placeholder="Enter text" />
65
+ * <TextInput placeholder="Another input" />
66
+ * </KeyboardAwareScrollView>
67
+ * ```
53
68
  */
54
69
  const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
55
70
  children,
@@ -88,12 +103,12 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
88
103
  scrollViewAnimatedRef(assignedRef);
89
104
  }, []);
90
105
  const onScrollViewLayout = (0, _react.useCallback)(e => {
91
- scrollViewTarget.value = (0, _reactNative.findNodeHandle)(scrollViewAnimatedRef.current);
106
+ scrollViewTarget.value = (0, _findNodeHandle.findNodeHandle)(scrollViewAnimatedRef.current);
92
107
  onLayout === null || onLayout === void 0 || onLayout(e);
93
108
  }, [onLayout]);
94
109
 
95
110
  /**
96
- * Function that will scroll a ScrollView as keyboard gets moving
111
+ * Function that will scroll a ScrollView as keyboard gets moving.
97
112
  */
98
113
  const maybeScroll = (0, _react.useCallback)((e, animated = false) => {
99
114
  "worklet";
@@ -256,7 +271,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
256
271
  }, rest, {
257
272
  scrollEventThrottle: 16,
258
273
  onLayout: onScrollViewLayout
259
- }), children, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
274
+ }), children, enabled && /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
260
275
  style: view
261
276
  }));
262
277
  });