@react-native-ohos/react-native-keyboard-controller 1.12.8-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +19 -0
  4. package/harmony/keyboard_controller/BuildProfile.ets +17 -0
  5. package/harmony/keyboard_controller/Index.ets +9 -0
  6. package/harmony/keyboard_controller/ResourceTable.txt +9 -0
  7. package/harmony/keyboard_controller/build-profile.json5 +31 -0
  8. package/harmony/keyboard_controller/consumer-rules.txt +0 -0
  9. package/harmony/keyboard_controller/hvigorfile.ts +6 -0
  10. package/harmony/keyboard_controller/obfuscation-rules.txt +18 -0
  11. package/harmony/keyboard_controller/oh-package.json5 +11 -0
  12. package/harmony/keyboard_controller/src/main/cpp/CMakeLists.txt +7 -0
  13. package/harmony/keyboard_controller/src/main/cpp/EventEmitters.cpp +96 -0
  14. package/harmony/keyboard_controller/src/main/cpp/EventEmitters.h +90 -0
  15. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentDescriptor.h +77 -0
  16. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +158 -0
  17. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.h +74 -0
  18. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewJSIBinder.h +43 -0
  19. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentDescriptor.h +64 -0
  20. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +89 -0
  21. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.h +63 -0
  22. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaJSIBinder.h +39 -0
  23. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.cpp +25 -0
  24. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.h +27 -0
  25. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardControllerPackage.cpp +43 -0
  26. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardControllerPackage.h +56 -0
  27. package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.cpp +24 -0
  28. package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.h +28 -0
  29. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +43 -0
  30. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +56 -0
  31. package/harmony/keyboard_controller/src/main/ets/Logger.ts +46 -0
  32. package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerPackage.ets +46 -0
  33. package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +210 -0
  34. package/harmony/keyboard_controller/src/main/ets/RNStatusBarManagerCompatTurboModule.ts +98 -0
  35. package/harmony/keyboard_controller/src/main/ets/Type.ts +41 -0
  36. package/harmony/keyboard_controller/src/main/module.json +29 -0
  37. package/harmony/keyboard_controller/src/main/module.json5 +11 -0
  38. package/harmony/keyboard_controller/src/main/resources/base/element/string.json +8 -0
  39. package/harmony/keyboard_controller/src/main/resources/en_US/element/string.json +8 -0
  40. package/harmony/keyboard_controller/src/main/resources/zh_CN/element/string.json +8 -0
  41. package/harmony/keyboard_controller/ts.ets +9 -0
  42. package/harmony/keyboard_controller.har +0 -0
  43. package/lib/commonjs/animated.js +174 -0
  44. package/lib/commonjs/animated.js.map +1 -0
  45. package/lib/commonjs/bindings.js +38 -0
  46. package/lib/commonjs/bindings.js.map +1 -0
  47. package/lib/commonjs/bindings.native.js +37 -0
  48. package/lib/commonjs/bindings.native.js.map +1 -0
  49. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +66 -0
  50. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -0
  51. package/lib/commonjs/components/KeyboardAvoidingView/index.js +102 -0
  52. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -0
  53. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +255 -0
  54. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -0
  55. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +110 -0
  56. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  57. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js +37 -0
  58. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -0
  59. package/lib/commonjs/components/KeyboardStickyView/index.js +40 -0
  60. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -0
  61. package/lib/commonjs/components/KeyboardToolbar/Arrow.js +76 -0
  62. package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -0
  63. package/lib/commonjs/components/KeyboardToolbar/Button.js +70 -0
  64. package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -0
  65. package/lib/commonjs/components/KeyboardToolbar/colors.js +21 -0
  66. package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -0
  67. package/lib/commonjs/components/KeyboardToolbar/colors.native.js +40 -0
  68. package/lib/commonjs/components/KeyboardToolbar/colors.native.js.map +1 -0
  69. package/lib/commonjs/components/KeyboardToolbar/index.js +152 -0
  70. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -0
  71. package/lib/commonjs/components/KeyboardToolbar/types.js +6 -0
  72. package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -0
  73. package/lib/commonjs/components/hooks/useColorScheme.js +10 -0
  74. package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -0
  75. package/lib/commonjs/components/index.js +42 -0
  76. package/lib/commonjs/components/index.js.map +1 -0
  77. package/lib/commonjs/constants.js +25 -0
  78. package/lib/commonjs/constants.js.map +1 -0
  79. package/lib/commonjs/context.js +42 -0
  80. package/lib/commonjs/context.js.map +1 -0
  81. package/lib/commonjs/hooks/index.js +104 -0
  82. package/lib/commonjs/hooks/index.js.map +1 -0
  83. package/lib/commonjs/hooks/useWindowDimensions/index.android.js +29 -0
  84. package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -0
  85. package/lib/commonjs/hooks/useWindowDimensions/index.js +13 -0
  86. package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -0
  87. package/lib/commonjs/index.js +116 -0
  88. package/lib/commonjs/index.js.map +1 -0
  89. package/lib/commonjs/internal.js +73 -0
  90. package/lib/commonjs/internal.js.map +1 -0
  91. package/lib/commonjs/monkey-patch.android.js +57 -0
  92. package/lib/commonjs/monkey-patch.android.js.map +1 -0
  93. package/lib/commonjs/monkey-patch.js +11 -0
  94. package/lib/commonjs/monkey-patch.js.map +1 -0
  95. package/lib/commonjs/reanimated.js +12 -0
  96. package/lib/commonjs/reanimated.js.map +1 -0
  97. package/lib/commonjs/reanimated.native.js +88 -0
  98. package/lib/commonjs/reanimated.native.js.map +1 -0
  99. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +10 -0
  100. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
  101. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +12 -0
  102. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
  103. package/lib/commonjs/specs/NativeKeyboardController.js +9 -0
  104. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -0
  105. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +9 -0
  106. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -0
  107. package/lib/commonjs/types.js +6 -0
  108. package/lib/commonjs/types.js.map +1 -0
  109. package/lib/commonjs/utils.js +9 -0
  110. package/lib/commonjs/utils.js.map +1 -0
  111. package/lib/module/animated.js +166 -0
  112. package/lib/module/animated.js.map +1 -0
  113. package/lib/module/bindings.js +32 -0
  114. package/lib/module/bindings.js.map +1 -0
  115. package/lib/module/bindings.native.js +31 -0
  116. package/lib/module/bindings.native.js.map +1 -0
  117. package/lib/module/components/KeyboardAvoidingView/hooks.js +59 -0
  118. package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -0
  119. package/lib/module/components/KeyboardAvoidingView/index.js +95 -0
  120. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -0
  121. package/lib/module/components/KeyboardAwareScrollView/index.js +248 -0
  122. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -0
  123. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +103 -0
  124. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  125. package/lib/module/components/KeyboardAwareScrollView/utils.js +29 -0
  126. package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -0
  127. package/lib/module/components/KeyboardStickyView/index.js +33 -0
  128. package/lib/module/components/KeyboardStickyView/index.js.map +1 -0
  129. package/lib/module/components/KeyboardToolbar/Arrow.js +68 -0
  130. package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -0
  131. package/lib/module/components/KeyboardToolbar/Button.js +62 -0
  132. package/lib/module/components/KeyboardToolbar/Button.js.map +1 -0
  133. package/lib/module/components/KeyboardToolbar/colors.js +15 -0
  134. package/lib/module/components/KeyboardToolbar/colors.js.map +1 -0
  135. package/lib/module/components/KeyboardToolbar/colors.native.js +34 -0
  136. package/lib/module/components/KeyboardToolbar/colors.native.js.map +1 -0
  137. package/lib/module/components/KeyboardToolbar/index.js +140 -0
  138. package/lib/module/components/KeyboardToolbar/index.js.map +1 -0
  139. package/lib/module/components/KeyboardToolbar/types.js +2 -0
  140. package/lib/module/components/KeyboardToolbar/types.js.map +1 -0
  141. package/lib/module/components/hooks/useColorScheme.js +4 -0
  142. package/lib/module/components/hooks/useColorScheme.js.map +1 -0
  143. package/lib/module/components/index.js +5 -0
  144. package/lib/module/components/index.js.map +1 -0
  145. package/lib/module/constants.js +19 -0
  146. package/lib/module/constants.js.map +1 -0
  147. package/lib/module/context.js +35 -0
  148. package/lib/module/context.js.map +1 -0
  149. package/lib/module/hooks/index.js +68 -0
  150. package/lib/module/hooks/index.js.map +1 -0
  151. package/lib/module/hooks/useWindowDimensions/index.android.js +22 -0
  152. package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -0
  153. package/lib/module/hooks/useWindowDimensions/index.js +2 -0
  154. package/lib/module/hooks/useWindowDimensions/index.js.map +1 -0
  155. package/lib/module/index.js +10 -0
  156. package/lib/module/index.js.map +1 -0
  157. package/lib/module/internal.js +66 -0
  158. package/lib/module/internal.js.map +1 -0
  159. package/lib/module/monkey-patch.android.js +47 -0
  160. package/lib/module/monkey-patch.android.js.map +1 -0
  161. package/lib/module/monkey-patch.js +5 -0
  162. package/lib/module/monkey-patch.js.map +1 -0
  163. package/lib/module/reanimated.js +6 -0
  164. package/lib/module/reanimated.js.map +1 -0
  165. package/lib/module/reanimated.native.js +78 -0
  166. package/lib/module/reanimated.native.js.map +1 -0
  167. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +3 -0
  168. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
  169. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +5 -0
  170. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
  171. package/lib/module/specs/NativeKeyboardController.js +3 -0
  172. package/lib/module/specs/NativeKeyboardController.js.map +1 -0
  173. package/lib/module/specs/NativeStatusBarManagerCompat.js +3 -0
  174. package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -0
  175. package/lib/module/types.js +2 -0
  176. package/lib/module/types.js.map +1 -0
  177. package/lib/module/utils.js +2 -0
  178. package/lib/module/utils.js.map +1 -0
  179. package/lib/typescript/animated.d.ts +31 -0
  180. package/lib/typescript/bindings.d.ts +12 -0
  181. package/lib/typescript/bindings.native.d.ts +12 -0
  182. package/lib/typescript/components/KeyboardAvoidingView/hooks.d.ts +6 -0
  183. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +50 -0
  184. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +25 -0
  185. package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +6 -0
  186. package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +2 -0
  187. package/lib/typescript/components/KeyboardStickyView/index.d.ts +35 -0
  188. package/lib/typescript/components/KeyboardToolbar/Arrow.d.ts +9 -0
  189. package/lib/typescript/components/KeyboardToolbar/Button.d.ts +15 -0
  190. package/lib/typescript/components/KeyboardToolbar/colors.d.ts +2 -0
  191. package/lib/typescript/components/KeyboardToolbar/colors.native.d.ts +2 -0
  192. package/lib/typescript/components/KeyboardToolbar/index.d.ts +50 -0
  193. package/lib/typescript/components/KeyboardToolbar/types.d.ts +18 -0
  194. package/lib/typescript/components/hooks/useColorScheme.d.ts +2 -0
  195. package/lib/typescript/components/index.d.ts +8 -0
  196. package/lib/typescript/constants.d.ts +16 -0
  197. package/lib/typescript/context.d.ts +23 -0
  198. package/lib/typescript/hooks/index.d.ts +17 -0
  199. package/lib/typescript/hooks/useWindowDimensions/index.android.d.ts +2 -0
  200. package/lib/typescript/hooks/useWindowDimensions/index.d.ts +1 -0
  201. package/lib/typescript/index.d.ts +8 -0
  202. package/lib/typescript/internal.d.ts +30 -0
  203. package/lib/typescript/monkey-patch.android.d.ts +2 -0
  204. package/lib/typescript/monkey-patch.d.ts +2 -0
  205. package/lib/typescript/reanimated.d.ts +5 -0
  206. package/lib/typescript/reanimated.native.d.ts +7 -0
  207. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +53 -0
  208. package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +10 -0
  209. package/lib/typescript/specs/NativeKeyboardController.d.ts +12 -0
  210. package/lib/typescript/specs/NativeStatusBarManagerCompat.d.ts +10 -0
  211. package/lib/typescript/types.d.ts +133 -0
  212. package/lib/typescript/utils.d.ts +1 -0
  213. package/package.json +177 -0
  214. package/react-native-keyboard-controller.podspec +61 -0
  215. package/src/animated.tsx +246 -0
  216. package/src/bindings.native.ts +57 -0
  217. package/src/bindings.ts +38 -0
  218. package/src/components/KeyboardAvoidingView/hooks.ts +58 -0
  219. package/src/components/KeyboardAvoidingView/index.tsx +156 -0
  220. package/src/components/KeyboardAwareScrollView/index.tsx +373 -0
  221. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +133 -0
  222. package/src/components/KeyboardAwareScrollView/utils.ts +41 -0
  223. package/src/components/KeyboardStickyView/index.tsx +57 -0
  224. package/src/components/KeyboardToolbar/Arrow.tsx +80 -0
  225. package/src/components/KeyboardToolbar/Button.tsx +98 -0
  226. package/src/components/KeyboardToolbar/colors.native.ts +37 -0
  227. package/src/components/KeyboardToolbar/colors.ts +16 -0
  228. package/src/components/KeyboardToolbar/index.tsx +211 -0
  229. package/src/components/KeyboardToolbar/types.ts +40 -0
  230. package/src/components/hooks/useColorScheme.ts +5 -0
  231. package/src/components/index.ts +11 -0
  232. package/src/constants.ts +19 -0
  233. package/src/context.ts +65 -0
  234. package/src/hooks/index.ts +90 -0
  235. package/src/hooks/useWindowDimensions/index.android.ts +33 -0
  236. package/src/hooks/useWindowDimensions/index.ts +1 -0
  237. package/src/index.ts +21 -0
  238. package/src/internal.ts +84 -0
  239. package/src/monkey-patch.android.ts +44 -0
  240. package/src/monkey-patch.ts +4 -0
  241. package/src/reanimated.native.ts +132 -0
  242. package/src/reanimated.ts +29 -0
  243. package/src/specs/KeyboardControllerViewNativeComponent.ts +70 -0
  244. package/src/specs/KeyboardGestureAreaNativeComponent.ts +15 -0
  245. package/src/specs/NativeKeyboardController.ts +19 -0
  246. package/src/specs/NativeStatusBarManagerCompat.ts +14 -0
  247. package/src/types.ts +211 -0
  248. package/src/utils.ts +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_bindings","_context","_internal","_monkeyPatch","_reanimated","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","OS","Platform","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","broadcastKeyboardEvents","useSharedHandlers","setInputHandlers","broadcastInputEvents","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","target","inputTextHandler","useFocusedInputTextHandler","onFocusedInputTextChanged","inputSelectionHandler","useFocusedInputSelectionHandler","onFocusedInputSelectionChanged","useEffect","applyMonkeyPatch","revertMonkeyPatch","createElement","KeyboardContext","Provider","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","onFocusedInputTextChangedReanimated","onFocusedInputSelectionChangedReanimated","View","exports"],"sources":["animated.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from \"react\";\r\nimport { Animated, Platform, StyleSheet } from \"react-native\";\r\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\r\n\r\nimport { KeyboardControllerView } from \"./bindings\";\r\nimport { KeyboardContext } from \"./context\";\r\nimport { useAnimatedValue, useSharedHandlers } from \"./internal\";\r\nimport { applyMonkeyPatch, revertMonkeyPatch } from \"./monkey-patch\";\r\nimport {\r\n useAnimatedKeyboardHandler,\r\n useFocusedInputLayoutHandler,\r\n useFocusedInputSelectionHandler,\r\n useFocusedInputTextHandler,\r\n} from \"./reanimated\";\r\n\r\nimport type { KeyboardAnimationContext } from \"./context\";\r\nimport type {\r\n FocusedInputHandler,\r\n FocusedInputLayoutChangedEvent,\r\n KeyboardControllerProps,\r\n KeyboardHandler,\r\n NativeEvent,\r\n} from \"./types\";\r\nimport type { ViewStyle } from \"react-native\";\r\n\r\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\r\n Animated.createAnimatedComponent(\r\n KeyboardControllerView,\r\n ) as React.FC<KeyboardControllerProps>,\r\n);\r\n\r\ntype Styles = {\r\n container: ViewStyle;\r\n hidden: ViewStyle;\r\n};\r\n\r\nconst styles = StyleSheet.create<Styles>({\r\n container: {\r\n flex: 1,\r\n },\r\n hidden: {\r\n display: \"none\",\r\n position: \"absolute\",\r\n },\r\n});\r\n\r\ntype KeyboardProviderProps = {\r\n children: React.ReactNode;\r\n /**\r\n * Set the value to `true`, if you use translucent status bar on Android.\r\n * If you already control status bar translucency via `react-native-screens`\r\n * or `StatusBar` component from `react-native`, you can ignore it.\r\n * Defaults to `false`.\r\n *\r\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\r\n * @platform android\r\n */\r\n statusBarTranslucent?: boolean;\r\n /**\r\n * Set the value to `true`, if you use translucent navigation bar on Android.\r\n * Defaults to `false`.\r\n *\r\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\r\n * @platform android\r\n */\r\n navigationBarTranslucent?: boolean;\r\n /**\r\n * A boolean prop indicating whether the module is enabled. It indicate only initial state,\r\n * i. e. if you try to change this prop after component mount it will not have any effect.\r\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\r\n * Defaults to `true`.\r\n */\r\n enabled?: boolean;\r\n};\r\n\r\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\r\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\r\nconst OS = Platform.OS;\r\n\r\nexport const KeyboardProvider = ({\r\n children,\r\n statusBarTranslucent,\r\n navigationBarTranslucent,\r\n enabled: initiallyEnabled = true,\r\n}: KeyboardProviderProps) => {\r\n // state\r\n const [enabled, setEnabled] = useState(initiallyEnabled);\r\n // animated values\r\n const progress = useAnimatedValue(0);\r\n const height = useAnimatedValue(0);\r\n // shared values\r\n const progressSV = useSharedValue(0);\r\n const heightSV = useSharedValue(0);\r\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\r\n const [setKeyboardHandlers, broadcastKeyboardEvents] =\r\n useSharedHandlers<KeyboardHandler>();\r\n const [setInputHandlers, broadcastInputEvents] =\r\n useSharedHandlers<FocusedInputHandler>();\r\n // memo\r\n const context = useMemo<KeyboardAnimationContext>(\r\n () => ({\r\n enabled,\r\n animated: { progress: progress, height: Animated.multiply(height,-1) },\r\n reanimated: { progress: progressSV, height: heightSV },\r\n layout,\r\n setKeyboardHandlers,\r\n setInputHandlers,\r\n setEnabled,\r\n }),\r\n [enabled],\r\n );\r\n const style = useMemo(\r\n () => [\r\n styles.hidden,\r\n { transform: [{ translateX: height }, { translateY: progress }] },\r\n ],\r\n [],\r\n );\r\n const onKeyboardMove = useMemo(\r\n () =>\r\n Animated.event(\r\n [\r\n {\r\n nativeEvent: {\r\n progress,\r\n height,\r\n },\r\n },\r\n ],\r\n { useNativeDriver:Platform.OS as string=='harmony'?false:true },\r\n ),\r\n [],\r\n );\r\n // handlers\r\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\r\n \"worklet\";\r\n\r\n if (platforms.includes(OS)) {\r\n // eslint-disable-next-line react-compiler/react-compiler\r\n progressSV.value = event.progress;\r\n heightSV.value = -event.height;\r\n }\r\n };\r\n const keyboardHandler = useAnimatedKeyboardHandler(\r\n {\r\n onKeyboardMoveStart: (event: NativeEvent) => {\r\n \"worklet\";\r\n\r\n broadcastKeyboardEvents(\"onStart\", event);\r\n updateSharedValues(event, [\"ios\"]);\r\n },\r\n onKeyboardMove: (event: NativeEvent) => {\r\n \"worklet\";\r\n\r\n broadcastKeyboardEvents(\"onMove\", event);\r\n updateSharedValues(event, [\"android\"]);\r\n },\r\n onKeyboardMoveEnd: (event: NativeEvent) => {\r\n \"worklet\";\r\n broadcastKeyboardEvents(\"onEnd\", event);\r\n updateSharedValues(event, ['harmony']);\r\n },\r\n onKeyboardMoveInteractive: (event: NativeEvent) => {\r\n \"worklet\";\r\n\r\n updateSharedValues(event, [\"android\", \"ios\"]);\r\n broadcastKeyboardEvents(\"onInteractive\", event);\r\n },\r\n },\r\n [],\r\n );\r\n const inputLayoutHandler = useFocusedInputLayoutHandler(\r\n {\r\n onFocusedInputLayoutChanged: (e) => {\r\n \"worklet\";\r\n\r\n if (e.target !== -1) {\r\n layout.value = e;\r\n } else {\r\n layout.value = null;\r\n }\r\n },\r\n },\r\n [],\r\n );\r\n const inputTextHandler = useFocusedInputTextHandler(\r\n {\r\n onFocusedInputTextChanged: (e) => {\r\n \"worklet\";\r\n\r\n broadcastInputEvents(\"onChangeText\", e);\r\n },\r\n },\r\n [],\r\n );\r\n const inputSelectionHandler = useFocusedInputSelectionHandler(\r\n {\r\n onFocusedInputSelectionChanged: (e) => {\r\n \"worklet\";\r\n broadcastInputEvents(\"onSelectionChange\", e);\r\n },\r\n },\r\n [],\r\n );\r\n // effects\r\n useEffect(() => {\r\n if (enabled) {\r\n applyMonkeyPatch();\r\n } else {\r\n revertMonkeyPatch();\r\n }\r\n }, [enabled]);\r\n\r\n return (\r\n <KeyboardContext.Provider value={context}>\r\n <KeyboardControllerViewAnimated\r\n enabled={enabled}\r\n onKeyboardMoveReanimated={keyboardHandler}\r\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\r\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\r\n onKeyboardMoveInteractive={onKeyboardMove}\r\n onKeyboardMoveEnd={ OS as string === \"harmony\"?onKeyboardMove:undefined}\r\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\r\n onFocusedInputTextChangedReanimated={inputTextHandler}\r\n onFocusedInputSelectionChangedReanimated={inputSelectionHandler}\r\n navigationBarTranslucent={navigationBarTranslucent}\r\n statusBarTranslucent={statusBarTranslucent}\r\n style={styles.container}\r\n >\r\n <Reanimated.View>{children}</Reanimated.View>\r\n {/* {children} */}\r\n </KeyboardControllerViewAnimated>\r\n <Animated.View\r\n // we are using this small hack, because if the component (where\r\n // animated value has been used) is unmounted, then animation will\r\n // stop receiving events (seems like it's react-native optimization).\r\n // So we need to keep a reference to the animated value, to keep it's\r\n // always mounted (keep a reference to an animated value).\r\n //\r\n // To test why it's needed, try to open screen which consumes Animated.Value\r\n // then close it and open it again (for example 'Animated transition').\r\n style={style}\r\n />\r\n </KeyboardContext.Provider>\r\n );\r\n};\r\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAKsB,SAAAD,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,YAAAA,CAAAS,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAA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CAAChG,YAAA,CAAA6B,QAAQ,CAAC2E,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAtC,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAACuC,OAAA,CAAAhE,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WindowDimensionsEvents = exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardController = exports.FocusedInputEvents = void 0;
7
+ var _reactNative = require("react-native");
8
+ const NOOP = () => {};
9
+ const KeyboardController = exports.KeyboardController = {
10
+ setDefaultMode: NOOP,
11
+ setInputMode: NOOP,
12
+ dismiss: NOOP,
13
+ setFocusTo: NOOP,
14
+ addListener: NOOP,
15
+ removeListeners: NOOP
16
+ };
17
+ const KeyboardEvents = exports.KeyboardEvents = {
18
+ addListener: () => ({
19
+ remove: NOOP
20
+ })
21
+ };
22
+ /**
23
+ * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
24
+ * Use it with cautious.
25
+ */
26
+ const FocusedInputEvents = exports.FocusedInputEvents = {
27
+ addListener: () => ({
28
+ remove: NOOP
29
+ })
30
+ };
31
+ const WindowDimensionsEvents = exports.WindowDimensionsEvents = {
32
+ addListener: () => ({
33
+ remove: NOOP
34
+ })
35
+ };
36
+ const KeyboardControllerView = exports.KeyboardControllerView = _reactNative.View;
37
+ const KeyboardGestureArea = exports.KeyboardGestureArea = _reactNative.View;
38
+ //# sourceMappingURL=bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","NOOP","KeyboardController","exports","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","View","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\r\n\r\nimport type {\r\n FocusedInputEventsModule,\r\n KeyboardControllerModule,\r\n KeyboardControllerProps,\r\n KeyboardEventsModule,\r\n KeyboardGestureAreaProps,\r\n WindowDimensionsEventsModule,\r\n} from \"./types\";\r\nimport type { EmitterSubscription } from \"react-native\";\r\n\r\nconst NOOP = () => {};\r\nexport const KeyboardController: KeyboardControllerModule = {\r\n setDefaultMode: NOOP,\r\n setInputMode: NOOP,\r\n dismiss: NOOP,\r\n setFocusTo: NOOP,\r\n addListener: NOOP,\r\n removeListeners: NOOP,\r\n};\r\nexport const KeyboardEvents: KeyboardEventsModule = {\r\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\r\n};\r\n/**\r\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\r\n * Use it with cautious.\r\n */\r\nexport const FocusedInputEvents: FocusedInputEventsModule = {\r\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\r\n};\r\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\r\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\r\n};\r\nexport const KeyboardControllerView =\r\n View as unknown as React.FC<KeyboardControllerProps>;\r\nexport const KeyboardGestureArea =\r\n View as unknown as React.FC<KeyboardGestureAreaProps>;\r\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAYA,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACd,MAAMC,kBAA4C,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAC1DE,cAAc,EAAEH,IAAI;EACpBI,YAAY,EAAEJ,IAAI;EAClBK,OAAO,EAAEL,IAAI;EACbM,UAAU,EAAEN,IAAI;EAChBO,WAAW,EAAEP,IAAI;EACjBQ,eAAe,EAAER;AACnB,CAAC;AACM,MAAMS,cAAoC,GAAAP,OAAA,CAAAO,cAAA,GAAG;EAClDF,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMW,kBAA4C,GAAAT,OAAA,CAAAS,kBAAA,GAAG;EAC1DJ,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACM,MAAMY,sBAAoD,GAAAV,OAAA,CAAAU,sBAAA,GAAG;EAClEL,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACM,MAAMa,sBAAsB,GAAAX,OAAA,CAAAW,sBAAA,GACjCC,iBAAoD;AAC/C,MAAMC,mBAAmB,GAAAb,OAAA,CAAAa,mBAAA,GAC9BD,iBAAqD","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WindowDimensionsEvents = exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardController = exports.FocusedInputEvents = void 0;
7
+ var _reactNative = require("react-native");
8
+ const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
9
+ ios: "- You have run 'pod install'\n",
10
+ default: ""
11
+ }) + "- You rebuilt the app after installing the package\n" + "- You are not using Expo Go\n";
12
+ const RCTKeyboardController = require("./specs/NativeKeyboardController").default;
13
+ const KeyboardController = exports.KeyboardController = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
14
+ get() {
15
+ throw new Error(LINKING_ERROR);
16
+ }
17
+ });
18
+ const KEYBOARD_CONTROLLER_NAMESPACE = "KeyboardController::";
19
+ const eventEmitter = new _reactNative.NativeEventEmitter(KeyboardController);
20
+ const KeyboardEvents = exports.KeyboardEvents = {
21
+ addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
22
+ };
23
+ /**
24
+ * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
25
+ * Use it with cautious.
26
+ */
27
+ const FocusedInputEvents = exports.FocusedInputEvents = {
28
+ addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
29
+ };
30
+ const WindowDimensionsEvents = exports.WindowDimensionsEvents = {
31
+ addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
32
+ };
33
+ const KeyboardControllerView = exports.KeyboardControllerView = require("./specs/KeyboardControllerViewNativeComponent").default;
34
+ const KeyboardGestureArea = exports.KeyboardGestureArea = _reactNative.Platform.OS === "android" && _reactNative.Platform.Version >= 30 ? require("./specs/KeyboardGestureAreaNativeComponent").default : ({
35
+ children
36
+ }) => children;
37
+ //# sourceMappingURL=bindings.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","RCTKeyboardController","KeyboardController","exports","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","NativeEventEmitter","KeyboardEvents","addListener","name","cb","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","OS","Version","children"],"sources":["bindings.native.ts"],"sourcesContent":["import { NativeEventEmitter, Platform } from \"react-native\";\r\n\r\nimport type {\r\n FocusedInputEventsModule,\r\n KeyboardControllerModule,\r\n KeyboardControllerProps,\r\n KeyboardEventsModule,\r\n KeyboardGestureAreaProps,\r\n WindowDimensionsEventsModule,\r\n} from \"./types\";\r\n\r\nconst LINKING_ERROR =\r\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\r\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: \"\" }) +\r\n \"- You rebuilt the app after installing the package\\n\" +\r\n \"- You are not using Expo Go\\n\";\r\n\r\nconst RCTKeyboardController =\r\n require(\"./specs/NativeKeyboardController\").default;\r\nexport const KeyboardController = (\r\n RCTKeyboardController\r\n ? RCTKeyboardController\r\n : new Proxy(\r\n {},\r\n {\r\n get() {\r\n throw new Error(LINKING_ERROR);\r\n },\r\n },\r\n )\r\n) as KeyboardControllerModule;\r\n\r\nconst KEYBOARD_CONTROLLER_NAMESPACE = \"KeyboardController::\";\r\nconst eventEmitter = new NativeEventEmitter(KeyboardController);\r\n\r\nexport const KeyboardEvents: KeyboardEventsModule = {\r\n addListener: (name, cb) =>\r\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\r\n};\r\n/**\r\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\r\n * Use it with cautious.\r\n */\r\nexport const FocusedInputEvents: FocusedInputEventsModule = {\r\n addListener: (name, cb) =>\r\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\r\n};\r\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\r\n addListener: (name, cb) =>\r\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\r\n};\r\nexport const KeyboardControllerView: React.FC<KeyboardControllerProps> =\r\n require(\"./specs/KeyboardControllerViewNativeComponent\").default;\r\nexport const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =\r\n Platform.OS === \"android\" && Platform.Version >= 30\r\n ? require(\"./specs/KeyboardGestureAreaNativeComponent\").default\r\n : ({ children }: KeyboardGestureAreaProps) => children;\r\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAWA,MAAMC,aAAa,GACjB,2FAA2F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,qBAAqB,GACzBN,OAAO,CAAC,kCAAkC,CAAC,CAACK,OAAO;AAC9C,MAAME,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAC7BD,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CACF,CACuB;AAE7B,MAAMW,6BAA6B,GAAG,sBAAsB;AAC5D,MAAMC,YAAY,GAAG,IAAIC,+BAAkB,CAACP,kBAAkB,CAAC;AAExD,MAAMQ,cAAoC,GAAAP,OAAA,CAAAO,cAAA,GAAG;EAClDC,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAACJ,6BAA6B,GAAGK,IAAI,EAAEC,EAAE;AACrE,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMC,kBAA4C,GAAAX,OAAA,CAAAW,kBAAA,GAAG;EAC1DH,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAACJ,6BAA6B,GAAGK,IAAI,EAAEC,EAAE;AACrE,CAAC;AACM,MAAME,sBAAoD,GAAAZ,OAAA,CAAAY,sBAAA,GAAG;EAClEJ,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAACJ,6BAA6B,GAAGK,IAAI,EAAEC,EAAE;AACrE,CAAC;AACM,MAAMG,sBAAyD,GAAAb,OAAA,CAAAa,sBAAA,GACpErB,OAAO,CAAC,+CAA+C,CAAC,CAACK,OAAO;AAC3D,MAAMiB,mBAAuD,GAAAd,OAAA,CAAAc,mBAAA,GAClEpB,qBAAQ,CAACqB,EAAE,KAAK,SAAS,IAAIrB,qBAAQ,CAACsB,OAAO,IAAI,EAAE,GAC/CxB,OAAO,CAAC,4CAA4C,CAAC,CAACK,OAAO,GAC7D,CAAC;EAAEoB;AAAmC,CAAC,KAAKA,QAAQ","ignoreList":[]}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useKeyboardAnimation = void 0;
7
+ var _reactNativeReanimated = require("react-native-reanimated");
8
+ var _hooks = require("../../hooks");
9
+ var _context = require("../../context");
10
+ var _reactNative = require("react-native");
11
+ const useKeyboardAnimation = () => {
12
+ const {
13
+ reanimated
14
+ } = (0, _context.useKeyboardContext)();
15
+ const heightWhenOpened = (0, _reactNativeReanimated.useSharedValue)(-reanimated.height.value);
16
+ const height = (0, _reactNativeReanimated.useSharedValue)(-reanimated.height.value);
17
+ const progress = (0, _reactNativeReanimated.useSharedValue)(reanimated.progress.value);
18
+ const isClosed = (0, _reactNativeReanimated.useSharedValue)(reanimated.progress.value === 0);
19
+ (0, _hooks.useKeyboardHandler)({
20
+ onStart: e => {
21
+ "worklet";
22
+
23
+ if (e.height > 0) {
24
+ // eslint-disable-next-line react-compiler/react-compiler
25
+ isClosed.value = false;
26
+ heightWhenOpened.value = e.height;
27
+ }
28
+ },
29
+ onMove: e => {
30
+ "worklet";
31
+
32
+ progress.value = e.progress;
33
+ height.value = e.height;
34
+ },
35
+ onEnd: e => {
36
+ "worklet";
37
+
38
+ if (_reactNative.Platform.OS === 'harmony') {
39
+ heightWhenOpened.value = e.height;
40
+ }
41
+ isClosed.value = e.height === 0;
42
+
43
+ // `height` update happens in `onMove` handler
44
+ // in `onEnd` we need to update only if `onMove`
45
+ // wasn't called (i. e. duration === 0)
46
+ //
47
+ // we can not call this code without condition below
48
+ // because in some corner cases (iOS with `secureTextEntry`)
49
+ // `onEnd` can be emitted before `onMove` and in this case
50
+ // it may lead to choppy/glitchy/jumpy UI
51
+ // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327
52
+ if (e.duration === 0) {
53
+ progress.value = e.progress;
54
+ height.value = e.height;
55
+ }
56
+ }
57
+ }, []);
58
+ return {
59
+ height,
60
+ progress,
61
+ heightWhenOpened,
62
+ isClosed
63
+ };
64
+ };
65
+ exports.useKeyboardAnimation = useKeyboardAnimation;
66
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNativeReanimated","require","_hooks","_context","_reactNative","useKeyboardAnimation","reanimated","useKeyboardContext","heightWhenOpened","useSharedValue","height","value","progress","isClosed","useKeyboardHandler","onStart","e","onMove","onEnd","Platform","OS","duration","exports"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\r\n\r\nimport {useKeyboardHandler} from \"../../hooks\";\r\nimport {useKeyboardContext} from \"../../context\";\r\nimport { Platform } from \"react-native\";\r\n\r\nexport const useKeyboardAnimation = () => {\r\n const { reanimated } = useKeyboardContext();\r\n const heightWhenOpened = useSharedValue(-reanimated.height.value);\r\n const height = useSharedValue(-reanimated.height.value);\r\n const progress = useSharedValue(reanimated.progress.value);\r\n const isClosed = useSharedValue(reanimated.progress.value === 0);\r\n\r\n useKeyboardHandler(\r\n {\r\n onStart: (e) => {\r\n \"worklet\";\r\n\r\n if (e.height > 0) {\r\n // eslint-disable-next-line react-compiler/react-compiler\r\n isClosed.value = false;\r\n heightWhenOpened.value = e.height;\r\n }\r\n },\r\n onMove: (e) => {\r\n \"worklet\";\r\n \r\n progress.value = e.progress;\r\n height.value = e.height;\r\n },\r\n onEnd: (e) => {\r\n \"worklet\";\r\n if(Platform.OS as string === 'harmony'){\r\n heightWhenOpened.value = e.height;\r\n }\r\n \r\n isClosed.value = e.height === 0;\r\n\r\n // `height` update happens in `onMove` handler\r\n // in `onEnd` we need to update only if `onMove`\r\n // wasn't called (i. e. duration === 0)\r\n //\r\n // we can not call this code without condition below\r\n // because in some corner cases (iOS with `secureTextEntry`)\r\n // `onEnd` can be emitted before `onMove` and in this case\r\n // it may lead to choppy/glitchy/jumpy UI\r\n // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327\r\n if (e.duration === 0) {\r\n progress.value = e.progress;\r\n height.value = e.height;\r\n }\r\n },\r\n },\r\n [],\r\n );\r\n\r\n return { height, progress, heightWhenOpened, isClosed };\r\n};\r\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAA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AAK,GAAGK,CAAC,CAACJ,QAAQ;QAC3BF,MAAM,CAACC,KAAK,GAAGK,CAAC,CAACN,MAAM;MACzB;IACF;EACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEA,MAAM;IAAEE,QAAQ;IAAEJ,gBAAgB;IAAEK;EAAS,CAAC;AACzD,CAAC;AAACS,OAAA,CAAAjB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _hooks = require("../../hooks");
11
+ var _hooks2 = require("./hooks");
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
+ 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); }
14
+ const defaultLayout = {
15
+ x: 0,
16
+ y: 0,
17
+ width: 0,
18
+ height: 0
19
+ };
20
+
21
+ /**
22
+ * View that moves out of the way when the keyboard appears by automatically
23
+ * adjusting its height, position, or bottom padding.
24
+ */
25
+ const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)(({
26
+ behavior,
27
+ children,
28
+ contentContainerStyle,
29
+ enabled = true,
30
+ keyboardVerticalOffset = 0,
31
+ style,
32
+ onLayout: onLayoutProps,
33
+ ...props
34
+ }, ref) => {
35
+ const initialFrame = (0, _reactNativeReanimated.useSharedValue)(null);
36
+ const frame = (0, _reactNativeReanimated.useDerivedValue)(() => initialFrame.value || defaultLayout);
37
+ const keyboard = (0, _hooks2.useKeyboardAnimation)();
38
+ const {
39
+ height: screenHeight
40
+ } = (0, _hooks.useWindowDimensions)();
41
+ const relativeKeyboardHeight = (0, _react.useCallback)(() => {
42
+ "worklet";
43
+
44
+ const keyboardY = screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;
45
+ return Math.max(frame.value.y + frame.value.height - keyboardY, 0);
46
+ }, [screenHeight, keyboardVerticalOffset]);
47
+ const onLayoutWorklet = (0, _react.useCallback)(layout => {
48
+ "worklet";
49
+
50
+ if (keyboard.isClosed.value || initialFrame.value === null) {
51
+ // eslint-disable-next-line react-compiler/react-compiler
52
+ initialFrame.value = layout;
53
+ }
54
+ }, []);
55
+ const onLayout = (0, _react.useCallback)(e => {
56
+ (0, _reactNativeReanimated.runOnUI)(onLayoutWorklet)(e.nativeEvent.layout);
57
+ onLayoutProps === null || onLayoutProps === void 0 || onLayoutProps(e);
58
+ }, [onLayoutProps]);
59
+ const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
60
+ const bottom = (0, _reactNativeReanimated.interpolate)(keyboard.progress.value, [0, 1], [0, relativeKeyboardHeight()]);
61
+ const bottomHeight = enabled ? bottom : 0;
62
+ switch (behavior) {
63
+ case "height":
64
+ if (!keyboard.isClosed.value) {
65
+ return {
66
+ height: frame.value.height - bottomHeight,
67
+ flex: 0
68
+ };
69
+ }
70
+ return {};
71
+ case "position":
72
+ return {
73
+ bottom: bottomHeight
74
+ };
75
+ case "padding":
76
+ return {
77
+ paddingBottom: bottomHeight
78
+ };
79
+ default:
80
+ return {};
81
+ }
82
+ }, [behavior, enabled, relativeKeyboardHeight]);
83
+ const isPositionBehavior = behavior === "position";
84
+ const containerStyle = isPositionBehavior ? contentContainerStyle : style;
85
+ const combinedStyles = (0, _react.useMemo)(() => [containerStyle, animatedStyle], [containerStyle, animatedStyle]);
86
+ if (isPositionBehavior) {
87
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({
88
+ ref: ref,
89
+ style: style,
90
+ onLayout: onLayout
91
+ }, props), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
92
+ style: combinedStyles
93
+ }, children));
94
+ }
95
+ return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, _extends({
96
+ ref: ref,
97
+ onLayout: onLayout,
98
+ style: combinedStyles
99
+ }, props), children);
100
+ });
101
+ var _default = exports.default = KeyboardAvoidingView;
102
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_hooks","_hooks2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_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","keyboard","useKeyboardAnimation","screenHeight","useWindowDimensions","relativeKeyboardHeight","useCallback","keyboardY","heightWhenOpened","Math","max","onLayoutWorklet","layout","isClosed","runOnUI","nativeEvent","animatedStyle","useAnimatedStyle","bottom","interpolate","progress","bottomHeight","flex","paddingBottom","isPositionBehavior","containerStyle","combinedStyles","useMemo","createElement","View","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\r\nimport { View } from \"react-native\";\r\nimport Reanimated, {\r\n interpolate,\r\n runOnUI,\r\n useAnimatedStyle,\r\n useDerivedValue,\r\n useSharedValue,\r\n} from \"react-native-reanimated\";\r\n\r\nimport { useWindowDimensions } from \"../../hooks\";\r\n\r\nimport { useKeyboardAnimation } from \"./hooks\";\r\n\r\nimport type { LayoutRectangle, ViewProps } from \"react-native\";\r\n\r\nexport type KeyboardAvoidingViewProps = {\r\n /**\r\n * Specify how to react to the presence of the keyboard.\r\n */\r\n behavior?: \"height\" | \"position\" | \"padding\";\r\n\r\n /**\r\n * Style of the content container when `behavior` is 'position'.\r\n */\r\n contentContainerStyle?: ViewProps[\"style\"];\r\n\r\n /**\r\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\r\n * This is useful when more than one is on the screen. Defaults to true.\r\n */\r\n enabled?: boolean;\r\n\r\n /**\r\n * Distance between the top of the user screen and the React Native view. This\r\n * may be non-zero in some cases. Defaults to 0.\r\n */\r\n keyboardVerticalOffset?: number;\r\n} & ViewProps;\r\n\r\nconst defaultLayout: LayoutRectangle = {\r\n x: 0,\r\n y: 0,\r\n width: 0,\r\n height: 0,\r\n};\r\n\r\n/**\r\n * View that moves out of the way when the keyboard appears by automatically\r\n * adjusting its height, position, or bottom padding.\r\n */\r\nconst KeyboardAvoidingView = forwardRef<\r\n View,\r\n React.PropsWithChildren<KeyboardAvoidingViewProps>\r\n>(\r\n (\r\n {\r\n behavior,\r\n children,\r\n contentContainerStyle,\r\n enabled = true,\r\n keyboardVerticalOffset = 0,\r\n style,\r\n onLayout: onLayoutProps,\r\n ...props\r\n },\r\n ref,\r\n ) => {\r\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\r\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\r\n\r\n const keyboard = useKeyboardAnimation();\r\n const { height: screenHeight } = useWindowDimensions();\r\n\r\n const relativeKeyboardHeight = useCallback(() => {\r\n \"worklet\";\r\n\r\n const keyboardY =\r\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\r\n\r\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\r\n }, [screenHeight, keyboardVerticalOffset]);\r\n\r\n const onLayoutWorklet = useCallback((layout: LayoutRectangle) => {\r\n \"worklet\";\r\n\r\n if (keyboard.isClosed.value || initialFrame.value === null) {\r\n // eslint-disable-next-line react-compiler/react-compiler\r\n initialFrame.value = layout;\r\n }\r\n }, []);\r\n const onLayout = useCallback<NonNullable<ViewProps[\"onLayout\"]>>(\r\n (e) => {\r\n runOnUI(onLayoutWorklet)(e.nativeEvent.layout);\r\n onLayoutProps?.(e);\r\n },\r\n [onLayoutProps],\r\n );\r\n\r\n const animatedStyle = useAnimatedStyle(() => {\r\n const bottom = interpolate(\r\n keyboard.progress.value,\r\n [0, 1],\r\n [0, relativeKeyboardHeight()],\r\n );\r\n const bottomHeight = enabled ? bottom : 0;\r\n\r\n switch (behavior) {\r\n case \"height\":\r\n if (!keyboard.isClosed.value) {\r\n return {\r\n height: frame.value.height - bottomHeight,\r\n flex: 0,\r\n };\r\n }\r\n\r\n return {};\r\n\r\n case \"position\":\r\n return { bottom: bottomHeight };\r\n\r\n case \"padding\":\r\n return { paddingBottom: bottomHeight };\r\n default:\r\n return {};\r\n }\r\n }, [behavior, enabled, relativeKeyboardHeight]);\r\n const isPositionBehavior = behavior === \"position\";\r\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\r\n const combinedStyles = useMemo(\r\n () => [containerStyle, animatedStyle],\r\n [containerStyle, animatedStyle],\r\n );\r\n\r\n if (isPositionBehavior) {\r\n return (\r\n <View ref={ref} style={style} onLayout={onLayout} {...props}>\r\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\r\n </View>\r\n );\r\n }\r\n\r\n return (\r\n <Reanimated.View\r\n ref={ref}\r\n onLayout={onLayout}\r\n style={combinedStyles}\r\n {...props}\r\n >\r\n {children}\r\n </Reanimated.View>\r\n );\r\n },\r\n);\r\n\r\nexport default KeyboardAvoidingView;\r\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA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Q,EAAEG,OAAO,EAAEgB,sBAAsB,CAAC,CAAC;EAC/C,MAAMmB,kBAAkB,GAAGtC,QAAQ,KAAK,UAAU;EAClD,MAAMuC,cAAc,GAAGD,kBAAkB,GAAGpC,qBAAqB,GAAGG,KAAK;EACzE,MAAMmC,cAAc,GAAG,IAAAC,cAAO,EAC5B,MAAM,CAACF,cAAc,EAAET,aAAa,CAAC,EACrC,CAACS,cAAc,EAAET,aAAa,CAChC,CAAC;EAED,IAAIQ,kBAAkB,EAAE;IACtB,oBACE7E,MAAA,CAAAiB,OAAA,CAAAgE,aAAA,CAAC9E,YAAA,CAAA+E,IAAI,EAAAxD,QAAA;MAACsB,GAAG,EAAEA,GAAI;MAACJ,KAAK,EAAEA,KAAM;MAACC,QAAQ,EAAEA;IAAS,GAAKE,KAAK,gBACzD/C,MAAA,CAAAiB,OAAA,CAAAgE,aAAA,CAAC7E,sBAAA,CAAAa,OAAU,CAACiE,IAAI;MAACtC,KAAK,EAAEmC;IAAe,GAAEvC,QAA0B,CAC/D,CAAC;EAEX;EAEA,oBACExC,MAAA,CAAAiB,OAAA,CAAAgE,aAAA,CAAC7E,sBAAA,CAAAa,OAAU,CAACiE,IAAI,EAAAxD,QAAA;IACdsB,GAAG,EAAEA,GAAI;IACTH,QAAQ,EAAEA,QAAS;IACnBD,KAAK,EAAEmC;EAAe,GAClBhC,KAAK,GAERP,QACc,CAAC;AAEtB,CACF,CAAC;AAAC,IAAA2C,QAAA,GAAAC,OAAA,CAAAnE,OAAA,GAEaoB,oBAAoB","ignoreList":[]}
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _hooks = require("../../hooks");
11
+ var _useSmoothKeyboardHandler = require("./useSmoothKeyboardHandler");
12
+ var _utils = require("./utils");
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
+ 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); }
15
+ /*
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
+ * +============================+ +============================+ +=====================================+
48
+ * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +
49
+ * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +
50
+ * +============================+ +============================+ +=====================================+
51
+ *
52
+ */
53
+ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
54
+ children,
55
+ onLayout,
56
+ bottomOffset = 0,
57
+ disableScrollOnKeyboardHide = false,
58
+ enabled = true,
59
+ extraKeyboardSpace = 0,
60
+ ...rest
61
+ }, ref) => {
62
+ const scrollViewAnimatedRef = (0, _reactNativeReanimated.useAnimatedRef)();
63
+ const scrollViewTarget = (0, _reactNativeReanimated.useSharedValue)(null);
64
+ const scrollPosition = (0, _reactNativeReanimated.useSharedValue)(0);
65
+ const position = (0, _reactNativeReanimated.useScrollViewOffset)(scrollViewAnimatedRef);
66
+ const currentKeyboardFrameHeight = (0, _reactNativeReanimated.useSharedValue)(0);
67
+ const keyboardHeight = (0, _reactNativeReanimated.useSharedValue)(0);
68
+ const keyboardWillAppear = (0, _reactNativeReanimated.useSharedValue)(false);
69
+ const tag = (0, _reactNativeReanimated.useSharedValue)(-1);
70
+ const initialKeyboardSize = (0, _reactNativeReanimated.useSharedValue)(0);
71
+ const scrollBeforeKeyboardMovement = (0, _reactNativeReanimated.useSharedValue)(0);
72
+ const {
73
+ input
74
+ } = (0, _hooks.useReanimatedFocusedInput)();
75
+ const layout = (0, _reactNativeReanimated.useSharedValue)(null);
76
+ const {
77
+ height
78
+ } = (0, _hooks.useWindowDimensions)();
79
+ const onRef = (0, _react.useCallback)(assignedRef => {
80
+ if (typeof ref === "function") {
81
+ ref(assignedRef);
82
+ } else if (ref) {
83
+ ref.current = assignedRef;
84
+ }
85
+ scrollViewAnimatedRef(assignedRef);
86
+ }, []);
87
+ const onScrollViewLayout = (0, _react.useCallback)(e => {
88
+ scrollViewTarget.value = (0, _reactNative.findNodeHandle)(scrollViewAnimatedRef.current);
89
+ onLayout === null || onLayout === void 0 || onLayout(e);
90
+ }, [onLayout]);
91
+
92
+ /**
93
+ * Function that will scroll a ScrollView as keyboard gets moving
94
+ */
95
+ const maybeScroll = (0, _react.useCallback)((e, animated = false) => {
96
+ "worklet";
97
+
98
+ var _layout$value, _layout$value2, _layout$value3;
99
+ if (!enabled) {
100
+ return 0;
101
+ }
102
+
103
+ // input belongs to ScrollView
104
+ if (((_layout$value = layout.value) === null || _layout$value === void 0 ? void 0 : _layout$value.parentScrollViewTarget) !== scrollViewTarget.value) {
105
+ return 0;
106
+ }
107
+ const visibleRect = height - keyboardHeight.value;
108
+ const absoluteY = ((_layout$value2 = layout.value) === null || _layout$value2 === void 0 ? void 0 : _layout$value2.layout.absoluteY) || 0;
109
+ const inputHeight = ((_layout$value3 = layout.value) === null || _layout$value3 === void 0 ? void 0 : _layout$value3.layout.height) || 0;
110
+ const point = absoluteY + inputHeight;
111
+ if (visibleRect - point <= bottomOffset) {
112
+ const relativeScrollTo = keyboardHeight.value - (height - point) + bottomOffset;
113
+ const interpolatedScrollTo = (0, _reactNativeReanimated.interpolate)(e, [initialKeyboardSize.value, keyboardHeight.value], [0, (0, _utils.scrollDistanceWithRespectToSnapPoints)(relativeScrollTo + scrollPosition.value, rest.snapToOffsets) - scrollPosition.value]);
114
+ const targetScrollY = Math.max(interpolatedScrollTo, 0) + scrollPosition.value;
115
+ (0, _reactNativeReanimated.scrollTo)(scrollViewAnimatedRef, 0, targetScrollY, animated);
116
+ return interpolatedScrollTo;
117
+ }
118
+ if (absoluteY < 0) {
119
+ const positionOnScreen = visibleRect - inputHeight - bottomOffset;
120
+ const topOfScreen = scrollPosition.value + absoluteY;
121
+ (0, _reactNativeReanimated.scrollTo)(scrollViewAnimatedRef, 0, topOfScreen - positionOnScreen, animated);
122
+ }
123
+ return 0;
124
+ }, [bottomOffset, enabled, height, rest.snapToOffsets]);
125
+ const scrollFromCurrentPosition = (0, _react.useCallback)(customHeight => {
126
+ "worklet";
127
+
128
+ var _input$value;
129
+ const prevScrollPosition = scrollPosition.value;
130
+ const prevLayout = layout.value;
131
+ if (!((_input$value = input.value) !== null && _input$value !== void 0 && _input$value.layout)) {
132
+ return;
133
+ }
134
+
135
+ // eslint-disable-next-line react-compiler/react-compiler
136
+ layout.value = {
137
+ ...input.value,
138
+ layout: {
139
+ ...input.value.layout,
140
+ height: customHeight ?? input.value.layout.height
141
+ }
142
+ };
143
+ scrollPosition.value = position.value;
144
+ maybeScroll(keyboardHeight.value, true);
145
+ scrollPosition.value = prevScrollPosition;
146
+ layout.value = prevLayout;
147
+ }, [maybeScroll]);
148
+ const onChangeText = (0, _react.useCallback)(() => {
149
+ "worklet";
150
+
151
+ // if typing a text caused layout shift, then we need to ignore this handler
152
+ // because this event will be handled in `useAnimatedReaction` below
153
+ var _layout$value4, _input$value2;
154
+ if (((_layout$value4 = layout.value) === null || _layout$value4 === void 0 ? void 0 : _layout$value4.layout.height) !== ((_input$value2 = input.value) === null || _input$value2 === void 0 ? void 0 : _input$value2.layout.height)) {
155
+ return;
156
+ }
157
+ scrollFromCurrentPosition();
158
+ }, [scrollFromCurrentPosition]);
159
+ const onSelectionChange = (0, _react.useCallback)(e => {
160
+ "worklet";
161
+
162
+ if (e.selection.start.position !== e.selection.end.position) {
163
+ scrollFromCurrentPosition(e.selection.end.y);
164
+ }
165
+ }, [scrollFromCurrentPosition]);
166
+ const onChangeTextHandler = (0, _react.useMemo)(() => (0, _utils.debounce)(onChangeText, 200), [onChangeText]);
167
+ (0, _hooks.useFocusedInputHandler)({
168
+ onChangeText: onChangeTextHandler,
169
+ onSelectionChange: onSelectionChange
170
+ }, [onChangeTextHandler, onSelectionChange]);
171
+ (0, _useSmoothKeyboardHandler.useSmoothKeyboardHandler)({
172
+ onStart: e => {
173
+ "worklet";
174
+
175
+ const keyboardWillChangeSize = keyboardHeight.value !== e.height && e.height > 0;
176
+ keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;
177
+ const keyboardWillHide = e.height === 0;
178
+ const focusWasChanged = tag.value !== e.target && e.target !== -1 || keyboardWillChangeSize;
179
+ if (keyboardWillChangeSize) {
180
+ initialKeyboardSize.value = keyboardHeight.value;
181
+ }
182
+ if (keyboardWillHide) {
183
+ // on back transition need to interpolate as [0, keyboardHeight]
184
+ initialKeyboardSize.value = 0;
185
+ scrollPosition.value = scrollBeforeKeyboardMovement.value;
186
+ }
187
+ if (keyboardWillAppear.value || keyboardWillChangeSize || focusWasChanged) {
188
+ // persist scroll value
189
+ scrollPosition.value = position.value;
190
+ // just persist height - later will be used in interpolation
191
+ keyboardHeight.value = e.height;
192
+ }
193
+
194
+ // focus was changed
195
+ if (focusWasChanged) {
196
+ tag.value = e.target;
197
+
198
+ // save position of focused text input when keyboard starts to move
199
+ layout.value = input.value;
200
+ // save current scroll position - when keyboard will hide we'll reuse
201
+ // this value to achieve smooth hide effect
202
+ scrollBeforeKeyboardMovement.value = position.value;
203
+ }
204
+ if (focusWasChanged && !keyboardWillAppear.value) {
205
+ // update position on scroll value, so `onEnd` handler
206
+ // will pick up correct values
207
+ position.value += maybeScroll(e.height, true);
208
+ }
209
+ },
210
+ onMove: e => {
211
+ "worklet";
212
+
213
+ const keyboardFrame = (0, _reactNativeReanimated.interpolate)(e.height, [0, keyboardHeight.value], [0, keyboardHeight.value + extraKeyboardSpace]);
214
+ currentKeyboardFrameHeight.value = keyboardFrame;
215
+
216
+ // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens
217
+ if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {
218
+ maybeScroll(e.height);
219
+ }
220
+ },
221
+ onEnd: e => {
222
+ "worklet";
223
+
224
+ keyboardHeight.value = e.height;
225
+ scrollPosition.value = position.value;
226
+ }
227
+ }, [maybeScroll, disableScrollOnKeyboardHide, extraKeyboardSpace]);
228
+ (0, _reactNativeReanimated.useAnimatedReaction)(() => input.value, (current, previous) => {
229
+ if ((current === null || current === void 0 ? void 0 : current.target) === (previous === null || previous === void 0 ? void 0 : previous.target) && (current === null || current === void 0 ? void 0 : current.layout.height) !== (previous === null || previous === void 0 ? void 0 : previous.layout.height)) {
230
+ const prevLayout = layout.value;
231
+ layout.value = input.value;
232
+ scrollPosition.value += maybeScroll(keyboardHeight.value, true);
233
+ layout.value = prevLayout;
234
+ }
235
+ }, []);
236
+ const view = (0, _reactNativeReanimated.useAnimatedStyle)(() => enabled ? {
237
+ // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)
238
+ // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding
239
+ // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation
240
+ // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout
241
+ // re-calculation on every animation frame and it helps to achieve smooth animation.
242
+ // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342
243
+ paddingBottom: currentKeyboardFrameHeight.value + 1
244
+ } : {}, [enabled]);
245
+ return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.ScrollView, _extends({
246
+ ref: onRef
247
+ }, rest, {
248
+ onLayout: onScrollViewLayout,
249
+ scrollEventThrottle: 16
250
+ }), children, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
251
+ style: view
252
+ }));
253
+ });
254
+ var _default = exports.default = KeyboardAwareScrollView;
255
+ //# sourceMappingURL=index.js.map