@react-native-ohos/react-native-keyboard-controller 1.17.0-beta.2 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/LICENSE +21 -21
  2. package/README.OpenSource +11 -11
  3. package/README.md +686 -19
  4. package/harmony/keyboard_controller/BuildProfile.ets +16 -16
  5. package/harmony/keyboard_controller/Index.ets +29 -28
  6. package/harmony/keyboard_controller/build-profile.json5 +31 -31
  7. package/harmony/keyboard_controller/hvigorfile.ts +6 -6
  8. package/harmony/keyboard_controller/obfuscation-rules.txt +17 -17
  9. package/harmony/keyboard_controller/oh-package-lock.json5 +28 -18
  10. package/harmony/keyboard_controller/oh-package.json5 +10 -10
  11. package/harmony/keyboard_controller/src/main/cpp/CMakeLists.txt +7 -7
  12. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentDescriptor.h +86 -0
  13. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.cpp +104 -0
  14. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.h +64 -0
  15. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewJSIBinder.h +60 -0
  16. package/harmony/keyboard_controller/src/main/cpp/EventEmitters.cpp +119 -96
  17. package/harmony/keyboard_controller/src/main/cpp/EventEmitters.h +111 -111
  18. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentDescriptor.h +94 -94
  19. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +840 -288
  20. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.h +169 -103
  21. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewJSIBinder.h +65 -65
  22. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentDescriptor.h +79 -79
  23. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +108 -108
  24. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.h +83 -83
  25. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaJSIBinder.h +60 -60
  26. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentDescriptor.h +46 -0
  27. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.cpp +37 -0
  28. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.h +32 -0
  29. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewJSIBinder.h +23 -0
  30. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.cpp +103 -46
  31. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.h +48 -48
  32. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardControllerPackage.h +20 -0
  33. package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.cpp +45 -45
  34. package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.h +49 -49
  35. package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.cpp +207 -186
  36. package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.h +131 -112
  37. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +77 -64
  38. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +85 -77
  39. package/harmony/keyboard_controller/src/main/ets/Logger.ts +66 -66
  40. package/harmony/keyboard_controller/src/main/ets/{RNKeyboardControllerPackage.ts → RNKeyboardControllerPackage.ets} +70 -66
  41. package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +465 -273
  42. package/harmony/keyboard_controller/src/main/ets/RNStatusBarManagerCompatTurboModule.ts +128 -119
  43. package/harmony/keyboard_controller/src/main/ets/Type.ts +63 -62
  44. package/harmony/keyboard_controller/src/main/module.json5 +11 -11
  45. package/harmony/keyboard_controller/src/main/resources/base/element/string.json +8 -8
  46. package/harmony/keyboard_controller/src/main/resources/en_US/element/string.json +8 -8
  47. package/harmony/keyboard_controller/src/main/resources/zh_CN/element/string.json +8 -8
  48. package/harmony/keyboard_controller/{ts.ts → ts.ets} +29 -29
  49. package/harmony/keyboard_controller.har +0 -0
  50. package/lib/commonjs/animated.js +22 -11
  51. package/lib/commonjs/animated.js.map +1 -1
  52. package/lib/commonjs/architecture.js +8 -0
  53. package/lib/commonjs/architecture.js.map +1 -0
  54. package/lib/commonjs/bindings.js +40 -5
  55. package/lib/commonjs/bindings.js.map +1 -1
  56. package/lib/commonjs/bindings.native.js +28 -5
  57. package/lib/commonjs/bindings.native.js.map +1 -1
  58. package/lib/commonjs/compat.js +50 -0
  59. package/lib/commonjs/compat.js.map +1 -0
  60. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +21 -15
  61. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
  62. package/lib/commonjs/components/KeyboardAvoidingView/index.js +39 -14
  63. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  64. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +94 -57
  65. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  66. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +5 -5
  67. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  68. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -1
  69. package/lib/commonjs/components/KeyboardChatScrollView/hooks.js +13 -0
  70. package/lib/commonjs/components/KeyboardChatScrollView/hooks.js.map +1 -0
  71. package/lib/commonjs/components/KeyboardChatScrollView/index.js +122 -0
  72. package/lib/commonjs/components/KeyboardChatScrollView/index.js.map +1 -0
  73. package/lib/commonjs/components/KeyboardChatScrollView/types.js +6 -0
  74. package/lib/commonjs/components/KeyboardChatScrollView/types.js.map +1 -0
  75. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +221 -0
  76. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
  77. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +149 -0
  78. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
  79. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js +240 -0
  80. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
  81. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js +6 -0
  82. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
  83. package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js +40 -0
  84. package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
  85. package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js +92 -0
  86. package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
  87. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  88. package/lib/commonjs/components/KeyboardToolbar/Arrow.js +2 -3
  89. package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
  90. package/lib/commonjs/components/KeyboardToolbar/Button.js +2 -3
  91. package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
  92. package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -1
  93. package/lib/commonjs/components/KeyboardToolbar/colors.native.js.map +1 -1
  94. package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js +13 -0
  95. package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
  96. package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js +25 -0
  97. package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
  98. package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js +58 -0
  99. package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
  100. package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js +49 -0
  101. package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
  102. package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js +49 -0
  103. package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
  104. package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js +42 -0
  105. package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js.map +1 -0
  106. package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js +6 -0
  107. package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js.map +1 -0
  108. package/lib/commonjs/components/KeyboardToolbar/compound/context.js +17 -0
  109. package/lib/commonjs/components/KeyboardToolbar/compound/context.js.map +1 -0
  110. package/lib/commonjs/components/KeyboardToolbar/constants.js +17 -0
  111. package/lib/commonjs/components/KeyboardToolbar/constants.js.map +1 -0
  112. package/lib/commonjs/components/KeyboardToolbar/index.js +98 -87
  113. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  114. package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -1
  115. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js +120 -0
  116. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js.map +1 -0
  117. package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js +15 -0
  118. package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
  119. package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -1
  120. package/lib/commonjs/components/hooks/useCombinedRef.js +24 -0
  121. package/lib/commonjs/components/hooks/useCombinedRef.js.map +1 -0
  122. package/lib/commonjs/components/hooks/useScrollState.js +62 -0
  123. package/lib/commonjs/components/hooks/useScrollState.js.map +1 -0
  124. package/lib/commonjs/components/index.js +7 -0
  125. package/lib/commonjs/components/index.js.map +1 -1
  126. package/lib/commonjs/constants.js +3 -1
  127. package/lib/commonjs/constants.js.map +1 -1
  128. package/lib/commonjs/context.js +1 -0
  129. package/lib/commonjs/context.js.map +1 -1
  130. package/lib/commonjs/hooks/index.js +14 -1
  131. package/lib/commonjs/hooks/index.js.map +1 -1
  132. package/lib/commonjs/hooks/useKeyboardState/index.js +39 -0
  133. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -0
  134. package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -1
  135. package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -1
  136. package/lib/commonjs/index.js +27 -1
  137. package/lib/commonjs/index.js.map +1 -1
  138. package/lib/commonjs/internal.js +54 -18
  139. package/lib/commonjs/internal.js.map +1 -1
  140. package/lib/commonjs/module.js +21 -12
  141. package/lib/commonjs/module.js.map +1 -1
  142. package/lib/commonjs/reanimated.js.map +1 -1
  143. package/lib/commonjs/reanimated.native.js.map +1 -1
  144. package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js +12 -0
  145. package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
  146. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +8 -2
  147. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  148. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +2 -1
  149. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  150. package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js +12 -0
  151. package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
  152. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
  153. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -1
  154. package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -1
  155. package/lib/commonjs/types.js.map +1 -1
  156. package/lib/commonjs/utils/findNodeHandle/index.js +9 -0
  157. package/lib/commonjs/utils/findNodeHandle/index.js.map +1 -0
  158. package/lib/commonjs/utils/findNodeHandle/index.native.js +13 -0
  159. package/lib/commonjs/utils/findNodeHandle/index.native.js.map +1 -0
  160. package/lib/commonjs/utils.js.map +1 -1
  161. package/lib/commonjs/views/KeyboardExtender/index.js +30 -0
  162. package/lib/commonjs/views/KeyboardExtender/index.js.map +1 -0
  163. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
  164. package/lib/commonjs/views/index.js +7 -0
  165. package/lib/commonjs/views/index.js.map +1 -1
  166. package/lib/module/animated.js +24 -13
  167. package/lib/module/animated.js.map +1 -1
  168. package/lib/module/architecture.js +2 -0
  169. package/lib/module/architecture.js.map +1 -0
  170. package/lib/module/bindings.js +39 -5
  171. package/lib/module/bindings.js.map +1 -1
  172. package/lib/module/bindings.native.js +27 -5
  173. package/lib/module/bindings.native.js.map +1 -1
  174. package/lib/module/compat.js +43 -0
  175. package/lib/module/compat.js.map +1 -0
  176. package/lib/module/components/KeyboardAvoidingView/hooks.js +22 -16
  177. package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
  178. package/lib/module/components/KeyboardAvoidingView/index.js +38 -14
  179. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  180. package/lib/module/components/KeyboardAwareScrollView/index.js +97 -60
  181. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  182. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +5 -5
  183. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  184. package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -1
  185. package/lib/module/components/KeyboardChatScrollView/hooks.js +2 -0
  186. package/lib/module/components/KeyboardChatScrollView/hooks.js.map +1 -0
  187. package/lib/module/components/KeyboardChatScrollView/index.js +115 -0
  188. package/lib/module/components/KeyboardChatScrollView/index.js.map +1 -0
  189. package/lib/module/components/KeyboardChatScrollView/types.js +2 -0
  190. package/lib/module/components/KeyboardChatScrollView/types.js.map +1 -0
  191. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +207 -0
  192. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
  193. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +143 -0
  194. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
  195. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js +234 -0
  196. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
  197. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js +2 -0
  198. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
  199. package/lib/module/components/KeyboardChatScrollView/useEndVisible.js +33 -0
  200. package/lib/module/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
  201. package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js +87 -0
  202. package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
  203. package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
  204. package/lib/module/components/KeyboardToolbar/Arrow.js +2 -2
  205. package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -1
  206. package/lib/module/components/KeyboardToolbar/Button.js +2 -2
  207. package/lib/module/components/KeyboardToolbar/Button.js.map +1 -1
  208. package/lib/module/components/KeyboardToolbar/colors.js.map +1 -1
  209. package/lib/module/components/KeyboardToolbar/colors.native.js.map +1 -1
  210. package/lib/module/components/KeyboardToolbar/compound/components/Background.js +6 -0
  211. package/lib/module/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
  212. package/lib/module/components/KeyboardToolbar/compound/components/Content.js +18 -0
  213. package/lib/module/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
  214. package/lib/module/components/KeyboardToolbar/compound/components/Done.js +50 -0
  215. package/lib/module/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
  216. package/lib/module/components/KeyboardToolbar/compound/components/Next.js +41 -0
  217. package/lib/module/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
  218. package/lib/module/components/KeyboardToolbar/compound/components/Prev.js +41 -0
  219. package/lib/module/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
  220. package/lib/module/components/KeyboardToolbar/compound/components/index.js +6 -0
  221. package/lib/module/components/KeyboardToolbar/compound/components/index.js.map +1 -0
  222. package/lib/module/components/KeyboardToolbar/compound/components/types.js +2 -0
  223. package/lib/module/components/KeyboardToolbar/compound/components/types.js.map +1 -0
  224. package/lib/module/components/KeyboardToolbar/compound/context.js +10 -0
  225. package/lib/module/components/KeyboardToolbar/compound/context.js.map +1 -0
  226. package/lib/module/components/KeyboardToolbar/constants.js +11 -0
  227. package/lib/module/components/KeyboardToolbar/constants.js.map +1 -0
  228. package/lib/module/components/KeyboardToolbar/index.js +98 -88
  229. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  230. package/lib/module/components/KeyboardToolbar/types.js.map +1 -1
  231. package/lib/module/components/ScrollViewWithBottomPadding/index.js +112 -0
  232. package/lib/module/components/ScrollViewWithBottomPadding/index.js.map +1 -0
  233. package/lib/module/components/ScrollViewWithBottomPadding/styles.js +9 -0
  234. package/lib/module/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
  235. package/lib/module/components/hooks/useColorScheme.js.map +1 -1
  236. package/lib/module/components/hooks/useCombinedRef.js +18 -0
  237. package/lib/module/components/hooks/useCombinedRef.js.map +1 -0
  238. package/lib/module/components/hooks/useScrollState.js +56 -0
  239. package/lib/module/components/hooks/useScrollState.js.map +1 -0
  240. package/lib/module/components/index.js +1 -0
  241. package/lib/module/components/index.js.map +1 -1
  242. package/lib/module/constants.js +3 -0
  243. package/lib/module/constants.js.map +1 -1
  244. package/lib/module/context.js +1 -0
  245. package/lib/module/context.js.map +1 -1
  246. package/lib/module/hooks/index.js +3 -1
  247. package/lib/module/hooks/index.js.map +1 -1
  248. package/lib/module/hooks/useKeyboardState/index.js +33 -0
  249. package/lib/module/hooks/useKeyboardState/index.js.map +1 -0
  250. package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -1
  251. package/lib/module/hooks/useWindowDimensions/index.js.map +1 -1
  252. package/lib/module/index.js +3 -2
  253. package/lib/module/index.js.map +1 -1
  254. package/lib/module/internal.js +53 -18
  255. package/lib/module/internal.js.map +1 -1
  256. package/lib/module/module.js +21 -12
  257. package/lib/module/module.js.map +1 -1
  258. package/lib/module/reanimated.js.map +1 -1
  259. package/lib/module/reanimated.native.js.map +1 -1
  260. package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js +6 -0
  261. package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
  262. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +7 -1
  263. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  264. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +2 -1
  265. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  266. package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js +5 -0
  267. package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
  268. package/lib/module/specs/NativeKeyboardController.js.map +1 -1
  269. package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -1
  270. package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -1
  271. package/lib/module/types.js.map +1 -1
  272. package/lib/module/utils/findNodeHandle/index.js +2 -0
  273. package/lib/module/utils/findNodeHandle/index.js.map +1 -0
  274. package/lib/module/utils/findNodeHandle/index.native.js +3 -0
  275. package/lib/module/utils/findNodeHandle/index.native.js.map +1 -0
  276. package/lib/module/utils.js.map +1 -1
  277. package/lib/module/views/KeyboardExtender/index.js +23 -0
  278. package/lib/module/views/KeyboardExtender/index.js.map +1 -0
  279. package/lib/module/views/OverKeyboardView/index.js.map +1 -1
  280. package/lib/module/views/index.js +1 -0
  281. package/lib/module/views/index.js.map +1 -1
  282. package/lib/typescript/animated.d.ts +2 -38
  283. package/lib/typescript/architecture.d.ts +1 -0
  284. package/lib/typescript/bindings.d.ts +15 -1
  285. package/lib/typescript/bindings.native.d.ts +10 -1
  286. package/lib/typescript/compat.d.ts +12 -0
  287. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +5 -0
  288. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -1
  289. package/lib/typescript/components/KeyboardChatScrollView/hooks.d.ts +2 -0
  290. package/lib/typescript/components/KeyboardChatScrollView/index.d.ts +17 -0
  291. package/lib/typescript/components/KeyboardChatScrollView/types.d.ts +113 -0
  292. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts +132 -0
  293. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.d.ts +18 -0
  294. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.ios.d.ts +21 -0
  295. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts +37 -0
  296. package/lib/typescript/components/KeyboardChatScrollView/useEndVisible.d.ts +17 -0
  297. package/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts +45 -0
  298. package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -2
  299. package/lib/typescript/components/KeyboardToolbar/compound/components/Background.d.ts +6 -0
  300. package/lib/typescript/components/KeyboardToolbar/compound/components/Content.d.ts +7 -0
  301. package/lib/typescript/components/KeyboardToolbar/compound/components/Done.d.ts +7 -0
  302. package/lib/typescript/components/KeyboardToolbar/compound/components/Next.d.ts +4 -0
  303. package/lib/typescript/components/KeyboardToolbar/compound/components/Prev.d.ts +4 -0
  304. package/lib/typescript/components/KeyboardToolbar/compound/components/index.d.ts +5 -0
  305. package/lib/typescript/components/KeyboardToolbar/compound/components/types.d.ts +14 -0
  306. package/lib/typescript/components/KeyboardToolbar/compound/context.d.ts +9 -0
  307. package/lib/typescript/components/KeyboardToolbar/constants.d.ts +10 -0
  308. package/lib/typescript/components/KeyboardToolbar/index.d.ts +12 -45
  309. package/lib/typescript/components/KeyboardToolbar/types.d.ts +24 -1
  310. package/lib/typescript/components/ScrollViewWithBottomPadding/index.d.ts +30 -0
  311. package/lib/typescript/components/ScrollViewWithBottomPadding/styles.d.ts +7 -0
  312. package/lib/typescript/components/hooks/useCombinedRef.d.ts +3 -0
  313. package/lib/typescript/components/hooks/useScrollState.d.ts +17 -0
  314. package/lib/typescript/components/index.d.ts +3 -0
  315. package/lib/typescript/constants.d.ts +1 -0
  316. package/lib/typescript/context.d.ts +1 -0
  317. package/lib/typescript/hooks/index.d.ts +2 -0
  318. package/lib/typescript/hooks/useKeyboardState/index.d.ts +4 -0
  319. package/lib/typescript/index.d.ts +4 -3
  320. package/lib/typescript/internal.d.ts +4 -0
  321. package/lib/typescript/specs/ClippingScrollViewDecoratorViewNativeComponent.d.ts +10 -0
  322. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
  323. package/lib/typescript/specs/KeyboardToolbarGroupViewNativeComponent.d.ts +6 -0
  324. package/lib/typescript/specs/NativeKeyboardController.d.ts +6 -2
  325. package/lib/typescript/types.d.ts +81 -5
  326. package/lib/typescript/utils/findNodeHandle/index.d.ts +4 -0
  327. package/lib/typescript/utils/findNodeHandle/index.native.d.ts +2 -0
  328. package/lib/typescript/views/KeyboardExtender/index.d.ts +5 -0
  329. package/lib/typescript/views/index.d.ts +1 -0
  330. package/package.json +183 -174
  331. package/src/animated.tsx +248 -255
  332. package/src/architecture.ts +1 -0
  333. package/src/bindings.native.ts +97 -62
  334. package/src/bindings.ts +81 -42
  335. package/src/compat.ts +44 -0
  336. package/src/components/KeyboardAvoidingView/hooks.ts +130 -123
  337. package/src/components/KeyboardAvoidingView/index.tsx +232 -188
  338. package/src/components/KeyboardAwareScrollView/index.tsx +452 -389
  339. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +133 -133
  340. package/src/components/KeyboardAwareScrollView/utils.ts +41 -41
  341. package/src/components/KeyboardChatScrollView/hooks.ts +2 -0
  342. package/src/components/KeyboardChatScrollView/index.tsx +164 -0
  343. package/src/components/KeyboardChatScrollView/types.ts +117 -0
  344. package/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts +268 -0
  345. package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts +260 -0
  346. package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts +374 -0
  347. package/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts +39 -0
  348. package/src/components/KeyboardChatScrollView/useEndVisible.ts +66 -0
  349. package/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts +149 -0
  350. package/src/components/KeyboardStickyView/index.tsx +66 -66
  351. package/src/components/KeyboardToolbar/Arrow.tsx +80 -80
  352. package/src/components/KeyboardToolbar/Button.tsx +98 -98
  353. package/src/components/KeyboardToolbar/colors.native.ts +37 -37
  354. package/src/components/KeyboardToolbar/colors.ts +16 -16
  355. package/src/components/KeyboardToolbar/compound/components/Background.tsx +9 -0
  356. package/src/components/KeyboardToolbar/compound/components/Content.tsx +25 -0
  357. package/src/components/KeyboardToolbar/compound/components/Done.tsx +57 -0
  358. package/src/components/KeyboardToolbar/compound/components/Next.tsx +49 -0
  359. package/src/components/KeyboardToolbar/compound/components/Prev.tsx +49 -0
  360. package/src/components/KeyboardToolbar/compound/components/index.ts +5 -0
  361. package/src/components/KeyboardToolbar/compound/components/types.ts +15 -0
  362. package/src/components/KeyboardToolbar/compound/context.ts +25 -0
  363. package/src/components/KeyboardToolbar/constants.ts +14 -0
  364. package/src/components/KeyboardToolbar/index.tsx +220 -223
  365. package/src/components/KeyboardToolbar/types.ts +72 -40
  366. package/src/components/ScrollViewWithBottomPadding/index.tsx +216 -0
  367. package/src/components/ScrollViewWithBottomPadding/styles.ts +10 -0
  368. package/src/components/hooks/useColorScheme.ts +6 -6
  369. package/src/components/hooks/useCombinedRef.ts +22 -0
  370. package/src/components/hooks/useScrollState.ts +81 -0
  371. package/src/components/index.ts +14 -11
  372. package/src/constants.ts +23 -19
  373. package/src/context.ts +70 -68
  374. package/src/hooks/index.ts +91 -90
  375. package/src/hooks/useKeyboardState/index.ts +52 -0
  376. package/src/hooks/useWindowDimensions/index.android.ts +38 -38
  377. package/src/hooks/useWindowDimensions/index.ts +1 -1
  378. package/src/index.ts +27 -23
  379. package/src/internal.ts +146 -84
  380. package/src/module.ts +64 -52
  381. package/src/reanimated.native.ts +132 -132
  382. package/src/reanimated.ts +29 -29
  383. package/src/specs/ClippingScrollViewDecoratorViewNativeComponent.ts +19 -0
  384. package/src/specs/KeyboardControllerViewNativeComponent.ts +82 -71
  385. package/src/specs/KeyboardGestureAreaNativeComponent.ts +21 -20
  386. package/src/specs/KeyboardToolbarGroupViewNativeComponent.ts +10 -0
  387. package/src/specs/NativeKeyboardController.ts +23 -19
  388. package/src/specs/NativeStatusBarManagerCompat.ts +14 -14
  389. package/src/specs/OverKeyboardViewNativeComponent.ts +12 -12
  390. package/src/types.ts +330 -243
  391. package/src/utils/findNodeHandle/index.native.ts +3 -0
  392. package/src/utils/findNodeHandle/index.ts +6 -0
  393. package/src/utils.ts +1 -1
  394. package/src/views/KeyboardExtender/index.tsx +30 -0
  395. package/src/views/OverKeyboardView/index.tsx +43 -43
  396. package/src/views/index.ts +2 -1
  397. package/lib/commonjs/monkey-patch.android.js +0 -57
  398. package/lib/commonjs/monkey-patch.android.js.map +0 -1
  399. package/lib/commonjs/monkey-patch.js +0 -11
  400. package/lib/commonjs/monkey-patch.js.map +0 -1
  401. package/lib/module/monkey-patch.android.js +0 -47
  402. package/lib/module/monkey-patch.android.js.map +0 -1
  403. package/lib/module/monkey-patch.js +0 -5
  404. package/lib/module/monkey-patch.js.map +0 -1
  405. package/lib/typescript/monkey-patch.android.d.ts +0 -2
  406. package/lib/typescript/monkey-patch.d.ts +0 -2
  407. package/src/monkey-patch.android.ts +0 -44
  408. package/src/monkey-patch.ts +0 -4
@@ -0,0 +1,2 @@
1
+ export { useChatKeyboard } from "./useChatKeyboard";
2
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useChatKeyboard"],"sources":["hooks.ts"],"sourcesContent":["export { useChatKeyboard } from \"./useChatKeyboard\";\nexport type { KeyboardLiftBehavior } from \"./useChatKeyboard/types\";\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB","ignoreList":[]}
@@ -0,0 +1,115 @@
1
+ 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); }
2
+ import React, { forwardRef, useCallback, useMemo } from "react";
3
+ import { StyleSheet } from "react-native";
4
+ import { makeMutable, useAnimatedRef, useAnimatedStyle, useDerivedValue } from "react-native-reanimated";
5
+ import Reanimated from "react-native-reanimated";
6
+ import useCombinedRef from "../hooks/useCombinedRef";
7
+ import ScrollViewWithBottomPadding from "../ScrollViewWithBottomPadding";
8
+ import { useChatKeyboard } from "./useChatKeyboard";
9
+ import { useEndVisible } from "./useEndVisible";
10
+ import { useExtraContentPadding } from "./useExtraContentPadding";
11
+ const ZERO_CONTENT_PADDING = makeMutable(0);
12
+ const ZERO_BLANK_SPACE = makeMutable(0);
13
+ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
14
+ children,
15
+ ScrollViewComponent = Reanimated.ScrollView,
16
+ inverted = false,
17
+ keyboardLiftBehavior = "always",
18
+ freeze = false,
19
+ offset = 0,
20
+ extraContentPadding = ZERO_CONTENT_PADDING,
21
+ blankSpace = ZERO_BLANK_SPACE,
22
+ applyWorkaroundForContentInsetHitTestBug = false,
23
+ onLayout: onLayoutProp,
24
+ onContentSizeChange: onContentSizeChangeProp,
25
+ onEndVisible,
26
+ ...rest
27
+ }, ref) => {
28
+ const scrollViewRef = useAnimatedRef();
29
+ const onRef = useCombinedRef(ref, scrollViewRef);
30
+ const freezeSV = useDerivedValue(() => typeof freeze === "boolean" ? freeze : freeze.value);
31
+ const {
32
+ padding,
33
+ currentHeight,
34
+ contentOffsetY,
35
+ scroll,
36
+ layout,
37
+ size,
38
+ onLayout: onLayoutInternal,
39
+ onContentSizeChange: onContentSizeChangeInternal
40
+ } = useChatKeyboard(scrollViewRef, {
41
+ inverted,
42
+ keyboardLiftBehavior,
43
+ freeze: freezeSV,
44
+ offset,
45
+ blankSpace,
46
+ extraContentPadding
47
+ });
48
+ useExtraContentPadding({
49
+ scrollViewRef,
50
+ extraContentPadding,
51
+ keyboardPadding: padding,
52
+ blankSpace,
53
+ scroll,
54
+ layout,
55
+ size,
56
+ contentOffsetY,
57
+ inverted,
58
+ keyboardLiftBehavior,
59
+ freeze: freezeSV
60
+ });
61
+ useEndVisible({
62
+ scroll,
63
+ layout,
64
+ size,
65
+ inverted,
66
+ onEndVisible
67
+ });
68
+ const totalPadding = useDerivedValue(() => Math.max(blankSpace.value, padding.value + extraContentPadding.value));
69
+
70
+ // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).
71
+ // Apps that render into the unsafe area can supply a negative
72
+ // scrollIndicatorInsets adjustment at the application layer.
73
+ const indicatorPadding = useDerivedValue(() => padding.value + extraContentPadding.value);
74
+ const onLayout = useCallback(e => {
75
+ onLayoutInternal(e);
76
+ onLayoutProp === null || onLayoutProp === void 0 || onLayoutProp(e);
77
+ }, [onLayoutInternal, onLayoutProp]);
78
+ const onContentSizeChange = useCallback((w, h) => {
79
+ onContentSizeChangeInternal(w, h);
80
+ onContentSizeChangeProp === null || onContentSizeChangeProp === void 0 || onContentSizeChangeProp(w, h);
81
+ }, [onContentSizeChangeInternal, onContentSizeChangeProp]);
82
+
83
+ // Invisible view whose animated style changes every frame during keyboard
84
+ // animation. On Fabric, this forces Reanimated to schedule a commit,
85
+ // which flushes the scrollTo call in the same frame (fixing de-synchronization).
86
+ // see https://github.com/software-mansion/react-native-reanimated/issues/9000
87
+ const commitStyle = useAnimatedStyle(() => ({
88
+ transform: [{
89
+ translateY: -currentHeight.value
90
+ }]
91
+ }), []);
92
+ const commit = useMemo(() => [styles.commitView, commitStyle], [commitStyle]);
93
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ScrollViewWithBottomPadding, _extends({
94
+ ref: onRef
95
+ }, rest, {
96
+ applyWorkaroundForContentInsetHitTestBug: applyWorkaroundForContentInsetHitTestBug,
97
+ bottomPadding: totalPadding,
98
+ contentOffsetY: contentOffsetY,
99
+ inverted: inverted,
100
+ scrollIndicatorPadding: indicatorPadding,
101
+ ScrollViewComponent: ScrollViewComponent,
102
+ onContentSizeChange: onContentSizeChange,
103
+ onLayout: onLayout
104
+ }), children), /*#__PURE__*/React.createElement(Reanimated.View, {
105
+ style: commit
106
+ }));
107
+ });
108
+ const styles = StyleSheet.create({
109
+ commitView: {
110
+ display: "none",
111
+ position: "absolute"
112
+ }
113
+ });
114
+ export default KeyboardChatScrollView;
115
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","forwardRef","useCallback","useMemo","StyleSheet","makeMutable","useAnimatedRef","useAnimatedStyle","useDerivedValue","Reanimated","useCombinedRef","ScrollViewWithBottomPadding","useChatKeyboard","useEndVisible","useExtraContentPadding","ZERO_CONTENT_PADDING","ZERO_BLANK_SPACE","KeyboardChatScrollView","children","ScrollViewComponent","ScrollView","inverted","keyboardLiftBehavior","freeze","offset","extraContentPadding","blankSpace","applyWorkaroundForContentInsetHitTestBug","onLayout","onLayoutProp","onContentSizeChange","onContentSizeChangeProp","onEndVisible","rest","ref","scrollViewRef","onRef","freezeSV","value","padding","currentHeight","contentOffsetY","scroll","layout","size","onLayoutInternal","onContentSizeChangeInternal","keyboardPadding","totalPadding","Math","max","indicatorPadding","e","w","h","commitStyle","transform","translateY","commit","styles","commitView","createElement","Fragment","_extends","bottomPadding","scrollIndicatorPadding","View","style","create","display","position"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport {\n makeMutable,\n useAnimatedRef,\n useAnimatedStyle,\n useDerivedValue,\n} from \"react-native-reanimated\";\nimport Reanimated from \"react-native-reanimated\";\n\nimport useCombinedRef from \"../hooks/useCombinedRef\";\nimport ScrollViewWithBottomPadding from \"../ScrollViewWithBottomPadding\";\n\nimport { useChatKeyboard } from \"./useChatKeyboard\";\nimport { useEndVisible } from \"./useEndVisible\";\nimport { useExtraContentPadding } from \"./useExtraContentPadding\";\n\nimport type { KeyboardChatScrollViewProps } from \"./types\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nconst ZERO_CONTENT_PADDING = makeMutable(0);\nconst ZERO_BLANK_SPACE = makeMutable(0);\n\nconst KeyboardChatScrollView = forwardRef<\n Reanimated.ScrollView,\n React.PropsWithChildren<KeyboardChatScrollViewProps>\n>(\n (\n {\n children,\n ScrollViewComponent = Reanimated.ScrollView,\n inverted = false,\n keyboardLiftBehavior = \"always\",\n freeze = false,\n offset = 0,\n extraContentPadding = ZERO_CONTENT_PADDING,\n blankSpace = ZERO_BLANK_SPACE,\n applyWorkaroundForContentInsetHitTestBug = false,\n onLayout: onLayoutProp,\n onContentSizeChange: onContentSizeChangeProp,\n onEndVisible,\n ...rest\n },\n ref,\n ) => {\n const scrollViewRef = useAnimatedRef<Reanimated.ScrollView>();\n const onRef = useCombinedRef(ref, scrollViewRef);\n const freezeSV = useDerivedValue(() =>\n typeof freeze === \"boolean\" ? freeze : freeze.value,\n );\n const {\n padding,\n currentHeight,\n contentOffsetY,\n scroll,\n layout,\n size,\n onLayout: onLayoutInternal,\n onContentSizeChange: onContentSizeChangeInternal,\n } = useChatKeyboard(scrollViewRef, {\n inverted,\n keyboardLiftBehavior,\n freeze: freezeSV,\n offset,\n blankSpace,\n extraContentPadding,\n });\n\n useExtraContentPadding({\n scrollViewRef,\n extraContentPadding,\n keyboardPadding: padding,\n blankSpace,\n scroll,\n layout,\n size,\n contentOffsetY,\n inverted,\n keyboardLiftBehavior,\n freeze: freezeSV,\n });\n\n useEndVisible({\n scroll,\n layout,\n size,\n inverted,\n onEndVisible,\n });\n\n const totalPadding = useDerivedValue(() =>\n Math.max(blankSpace.value, padding.value + extraContentPadding.value),\n );\n\n // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).\n // Apps that render into the unsafe area can supply a negative\n // scrollIndicatorInsets adjustment at the application layer.\n const indicatorPadding = useDerivedValue(\n () => padding.value + extraContentPadding.value,\n );\n\n const onLayout = useCallback(\n (e: LayoutChangeEvent) => {\n onLayoutInternal(e);\n onLayoutProp?.(e);\n },\n [onLayoutInternal, onLayoutProp],\n );\n\n const onContentSizeChange = useCallback(\n (w: number, h: number) => {\n onContentSizeChangeInternal(w, h);\n onContentSizeChangeProp?.(w, h);\n },\n [onContentSizeChangeInternal, onContentSizeChangeProp],\n );\n\n // Invisible view whose animated style changes every frame during keyboard\n // animation. On Fabric, this forces Reanimated to schedule a commit,\n // which flushes the scrollTo call in the same frame (fixing de-synchronization).\n // see https://github.com/software-mansion/react-native-reanimated/issues/9000\n const commitStyle = useAnimatedStyle(\n () => ({\n transform: [{ translateY: -currentHeight.value }],\n }),\n [],\n );\n const commit = useMemo(\n () => [styles.commitView, commitStyle],\n [commitStyle],\n );\n\n return (\n <>\n <ScrollViewWithBottomPadding\n ref={onRef}\n {...rest}\n applyWorkaroundForContentInsetHitTestBug={\n applyWorkaroundForContentInsetHitTestBug\n }\n bottomPadding={totalPadding}\n contentOffsetY={contentOffsetY}\n inverted={inverted}\n scrollIndicatorPadding={indicatorPadding}\n ScrollViewComponent={ScrollViewComponent}\n onContentSizeChange={onContentSizeChange}\n onLayout={onLayout}\n >\n {children}\n </ScrollViewWithBottomPadding>\n <Reanimated.View style={commit} />\n </>\n );\n },\n);\n\nconst styles = StyleSheet.create({\n commitView: {\n display: \"none\",\n position: \"absolute\",\n },\n});\n\nexport default KeyboardChatScrollView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,UAAU,QAAQ,cAAc;AACzC,SACEC,WAAW,EACXC,cAAc,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,aAAa,CAACF;IAAM,CAAC;EAClD,CAAC,CAAC,EACF,EACF,CAAC;EACD,MAAMoB,MAAM,GAAGvD,OAAO,CACpB,MAAM,CAACwD,MAAM,CAACC,UAAU,EAAEL,WAAW,CAAC,EACtC,CAACA,WAAW,CACd,CAAC;EAED,oBACEvD,KAAA,CAAA6D,aAAA,CAAA7D,KAAA,CAAA8D,QAAA,qBACE9D,KAAA,CAAA6D,aAAA,CAAClD,2BAA2B,EAAAoD,QAAA;IAC1B7B,GAAG,EAAEE;EAAM,GACPH,IAAI;IACRN,wCAAwC,EACtCA,wCACD;IACDqC,aAAa,EAAEhB,YAAa;IAC5BP,cAAc,EAAEA,cAAe;IAC/BpB,QAAQ,EAAEA,QAAS;IACnB4C,sBAAsB,EAAEd,gBAAiB;IACzChC,mBAAmB,EAAEA,mBAAoB;IACzCW,mBAAmB,EAAEA,mBAAoB;IACzCF,QAAQ,EAAEA;EAAS,IAElBV,QAC0B,CAAC,eAC9BlB,KAAA,CAAA6D,aAAA,CAACpD,UAAU,CAACyD,IAAI;IAACC,KAAK,EAAET;EAAO,CAAE,CACjC,CAAC;AAEP,CACF,CAAC;AAED,MAAMC,MAAM,GAAGvD,UAAU,CAACgE,MAAM,CAAC;EAC/BR,UAAU,EAAE;IACVS,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAEF,eAAerD,sBAAsB","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n AnimatedScrollViewComponent,\n ScrollViewContentInsets,\n} from \"../ScrollViewWithBottomPadding\";\nimport type { KeyboardLiftBehavior } from \"./useChatKeyboard/types\";\nimport type { ScrollViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nexport type KeyboardChatScrollViewProps = {\n /** Custom component for `ScrollView`. Default is `ScrollView`. */\n ScrollViewComponent?: AnimatedScrollViewComponent;\n /** Whether list are using `inverted` prop. Default is `false`. */\n inverted?: boolean;\n /**\n * The distance between the bottom of the screen and the `ScrollView`.\n * When the keyboard appears, the `ScrollView` will only push content by the effective\n * distance (`keyboardHeight - offset`) instead of the full keyboard height.\n *\n * Useful when the input is not at the very bottom of the screen (e.g., above safe area, above\n * bottom tabs, etc. - in this case offset should be equal to the height of the elements between\n * `ScrollView` and bottom of the screen).\n *\n * Default is `0`.\n */\n offset?: number;\n /**\n * Determines how the chat content should behave when the keyboard appears, specifically whether\n * the scroll view should automatically lift its content to keep it visible above the keyboard.\n *\n * Possible values:\n * - `'always'`: The content always lifts along with the keyboard, ensuring the messages from the bottom part of screen\n * remain visible regardless of the current scroll position. This is the default behavior for most chat applications (used in Telegram).\n * - `'whenAtEnd'`: The content lifts only if the scroll view is at the end (i.e., the last message\n * is visible or near the bottom). This prevents unnecessary adjustments when the user is scrolling\n * through older messages (ChatGPT mobile app behavior).\n * - `'persistent'`: The content always lifts when the keyboard appears (similar to `'always'`), but\n * does not reset (lower) when the keyboard hides. This mimics behaviors where the view remains adjusted\n * after keyboard dismissal to maintain focus on the latest content without shifting back (Claude mobile app behavior).\n * - `'never'`: The content does not lift at all when the keyboard appears. Use this for scenarios\n * when you don't want to disturb user attention with animations (Perplexity mobile app behavior).\n *\n * Default is `'always'`.\n */\n keyboardLiftBehavior?: KeyboardLiftBehavior;\n /**\n * When `true`, freezes all keyboard-driven layout changes (padding, content offset, scroll position).\n * Useful when dismissing the keyboard to open a bottom sheet — prevents visual disruption\n * while the sheet is visible.\n *\n * Default is `false`.\n */\n freeze?: boolean | SharedValue<boolean>;\n /**\n * A shared value representing additional padding from external elements\n * (e.g., a growing multiline `TextInput` in a `KeyboardStickyView`).\n *\n * When this value changes:\n * - The scrollable range is always extended/contracted (via `contentInset`).\n * - The scroll position is conditionally adjusted based on `keyboardLiftBehavior`.\n *\n * Default is `undefined` (no extra padding).\n */\n extraContentPadding?: SharedValue<number>;\n /**\n * When `true`, applies a runtime workaround for a React Native 0.81+ bug\n * where the ScrollView's `contentInset` area does not respond to touch/scroll\n * gestures (facebook/react-native#54123).\n *\n * This uses Objective-C runtime method swizzling on the ScrollView's container\n * view, which is inherently fragile. Only enable if you are affected by the\n * upstream bug and understand the risks.\n *\n * iOS only. Default is `false`.\n */\n applyWorkaroundForContentInsetHitTestBug?: boolean;\n /**\n * A shared value representing a minimum inset floor (in pixels).\n *\n * When set, the total bottom padding is computed as:\n * `max(blankSpace, keyboardPadding + extraContentPadding)`\n *\n * This means the keyboard \"absorbs\" into the minimum padding rather than adding to it:\n * - When `blankSpace >= keyboard + extraContentPadding`: content does NOT move on keyboard open/close.\n * - When `blankSpace < keyboard + extraContentPadding`: content moves, but only by the excess amount.\n *\n * Useful in AI chat apps where a sent message needs space below it (to push it to the top\n * of the viewport) while the AI response streams in, without that space causing extra movement\n * when the keyboard opens.\n *\n * Default is `undefined` (equivalent to `0` — no minimum floor).\n */\n blankSpace?: SharedValue<number>;\n /**\n * Fires whenever the effective content inset changes — the static `contentInset`\n * prop combined with the dynamic keyboard-driven padding.\n *\n * Useful on Android, where the synthetic content inset is not reflected in the native\n * `onScroll` event payload. Consumers such as virtualized lists computing their own\n * `scrollToEnd` target can use this to track the current inset alongside scroll offsets.\n */\n onContentInsetChange?: (insets: ScrollViewContentInsets) => void;\n /**\n * Fires whenever the visibility of the content \"end\" changes — both when the user\n * arrives at the end and when they leave it. The boolean parameter reflects the new state.\n *\n * For non-inverted lists, the \"end\" is the bottom of the content. For inverted lists\n * (`inverted={true}`), the \"end\" is the top of the scroll view, where the latest messages\n * are rendered. The same internal detection drives `keyboardLiftBehavior=\"whenAtEnd\"`.\n *\n * The callback can be either a plain JS function or a Reanimated worklet — the type is\n * detected automatically. Worklets run on the UI thread; plain functions are dispatched\n * via `runOnJS`.\n *\n * Fires once on mount with the initial state (after the scroll view has been measured).\n */\n onEndVisible?: (visible: boolean) => void;\n} & ScrollViewProps;\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,207 @@
1
+ import { interpolate } from "react-native-reanimated";
2
+ const AT_END_THRESHOLD = 20;
3
+
4
+ /**
5
+ * Map the current keyboard height to an effective height that accounts for a
6
+ * fixed offset (e.g. Bottom safe-area or tab-bar height)..
7
+ *
8
+ * @param height - Current keyboard height.
9
+ * @param targetKeyboardHeight - Full target keyboard height (captured on keyboard open).
10
+ * @param offset - Fixed distance between the scroll-view bottom and the screen bottom.
11
+ * @returns Effective height after subtracting the offset proportionally.
12
+ * @example
13
+ * ```ts
14
+ * getEffectiveHeight(300, 300, 50); // 250
15
+ * getEffectiveHeight(150, 300, 50); // 125
16
+ * ```
17
+ */
18
+ export const getEffectiveHeight = (height, targetKeyboardHeight, offset) => {
19
+ "worklet";
20
+
21
+ if (offset === 0 || targetKeyboardHeight === 0) {
22
+ return height;
23
+ }
24
+ return interpolate(height, [0, targetKeyboardHeight], [0, Math.max(targetKeyboardHeight - offset, 0)]);
25
+ };
26
+
27
+ /**
28
+ * Check whether the scroll view is at the end of its content.
29
+ *
30
+ * For non-inverted lists the "end" is the bottom of the content.
31
+ * For inverted lists the "end" is the top (scroll offset near 0),
32
+ * because that is where the latest messages are displayed.
33
+ *
34
+ * @param scrollOffset - Current vertical scroll offset.
35
+ * @param layoutHeight - Visible height of the scroll view.
36
+ * @param contentHeight - Total height of the scrollable content.
37
+ * @param inverted - Whether the list is inverted.
38
+ * @returns `true` if the scroll position is within the threshold of the content end.
39
+ * @example
40
+ * ```ts
41
+ * const atEnd = isScrollAtEnd(100, 800, 920); // true (100 + 800 >= 920 - 20)
42
+ * const atEndInverted = isScrollAtEnd(5, 800, 2000, true); // true (5 <= 20)
43
+ * ```
44
+ */
45
+ export const isScrollAtEnd = (scrollOffset, layoutHeight, contentHeight, inverted = false) => {
46
+ "worklet";
47
+
48
+ if (inverted) {
49
+ return scrollOffset <= AT_END_THRESHOLD;
50
+ }
51
+ return scrollOffset + layoutHeight >= contentHeight - AT_END_THRESHOLD;
52
+ };
53
+
54
+ /**
55
+ * Decide whether content should be shifted based on the keyboard lift behavior.
56
+ *
57
+ * @param behavior - The configured keyboard lift behavior.
58
+ * @param isAtEnd - Whether the scroll view is currently at the end.
59
+ * @returns `true` if content should be shifted.
60
+ * @example
61
+ * ```ts
62
+ * shouldShiftContent("always", false); // true
63
+ * shouldShiftContent("whenAtEnd", false); // false
64
+ * ```
65
+ */
66
+ export const shouldShiftContent = (behavior, isAtEnd) => {
67
+ "worklet";
68
+
69
+ switch (behavior) {
70
+ case "always":
71
+ return true;
72
+ case "never":
73
+ return false;
74
+ case "whenAtEnd":
75
+ return isAtEnd;
76
+ case "persistent":
77
+ return true;
78
+ }
79
+ };
80
+
81
+ /**
82
+ * Compute the fraction of minimum padding space currently visible in the viewport (0–1).
83
+ *
84
+ * The minimum padding space lives in the scroll view's contentInset, NOT in the
85
+ * content itself. So `contentHeight` (from onContentSizeChange / scroll
86
+ * events) does **not** include it. The visible portion is how far the
87
+ * viewport extends past the content boundary into the inset area.
88
+ *
89
+ * For non-inverted lists the padding is in contentInset.bottom.
90
+ * For inverted lists the padding is in contentInset.top (negative scroll).
91
+ *
92
+ * @param scrollOffset - Current vertical scroll offset.
93
+ * @param layoutHeight - Visible height of the scroll view.
94
+ * @param contentHeight - Height of the scroll content (excludes insets).
95
+ * @param blankSpace - Size of the minimum padding inset area.
96
+ * @param inverted - Whether the list is inverted.
97
+ * @returns A value between 0 (padding fully off-screen) and 1 (padding fully visible).
98
+ * @example
99
+ * ```ts
100
+ * // Non-inverted: contentHeight=1500, layout=800, blankSpace=300
101
+ * getVisibleMinimumPaddingFraction(1500, 800, 1500, 300, false); // 1 (at end, viewport past content)
102
+ * getVisibleMinimumPaddingFraction(850, 800, 1500, 300, false); // 0.5 (half padding visible)
103
+ * getVisibleMinimumPaddingFraction(700, 800, 1500, 300, false); // 0 (padding off-screen)
104
+ * ```
105
+ */
106
+ export const getVisibleMinimumPaddingFraction = (scrollOffset, layoutHeight, contentHeight, blankSpace, inverted) => {
107
+ "worklet";
108
+
109
+ if (blankSpace <= 0) {
110
+ return 0;
111
+ }
112
+ if (inverted) {
113
+ // Minimum padding is in contentInset.top; visible when scroll < 0
114
+ return Math.max(0, Math.min(1, -scrollOffset / blankSpace));
115
+ }
116
+
117
+ // Minimum padding is in contentInset.bottom; visible when viewport extends past content
118
+ const pastContentEnd = scrollOffset + layoutHeight - contentHeight;
119
+ return Math.max(0, Math.min(1, pastContentEnd / blankSpace));
120
+ };
121
+
122
+ /**
123
+ * Compute how much of the minimum content padding absorbs the keyboard + extraContentPadding.
124
+ *
125
+ * @param blankSpace - Minimum inset floor.
126
+ * @param extraContentPadding - Extra content padding from external elements.
127
+ * @returns The portion of blankSpace that absorbs keyboard displacement.
128
+ * @example
129
+ * ```ts
130
+ * getMinimumPaddingAbsorbed(500, 20); // 480
131
+ * getMinimumPaddingAbsorbed(0, 20); // 0
132
+ * ```
133
+ */
134
+ export const getMinimumPaddingAbsorbed = (blankSpace, extraContentPadding) => {
135
+ "worklet";
136
+
137
+ return Math.max(0, blankSpace - extraContentPadding);
138
+ };
139
+
140
+ /**
141
+ * Compute the effective scroll displacement after minimum padding absorption.
142
+ *
143
+ * @param rawEffective - Raw effective keyboard height.
144
+ * @param minimumPaddingAbsorbed - Amount absorbed by minimum content padding.
145
+ * @returns The scroll displacement after subtracting the absorbed portion.
146
+ * @example
147
+ * ```ts
148
+ * getScrollEffective(300, 200); // 100
149
+ * getScrollEffective(300, 400); // 0
150
+ * ```
151
+ */
152
+ export const getScrollEffective = (rawEffective, minimumPaddingAbsorbed) => {
153
+ "worklet";
154
+
155
+ return Math.max(0, rawEffective - minimumPaddingAbsorbed);
156
+ };
157
+
158
+ /**
159
+ * Compute the clamped scroll target for non-inverted lists.
160
+ *
161
+ * @param offsetBeforeScroll - Scroll position before keyboard appeared.
162
+ * @param keyboardHeight - Current keyboard height (used for scroll displacement).
163
+ * @param contentHeight - Total height of the scrollable content.
164
+ * @param layoutHeight - Visible height of the scroll view.
165
+ * @param totalPaddingForMaxScroll - Total padding to use for maxScroll calculation. When provided, used instead of keyboardHeight for the scrollable range. Defaults to keyboardHeight.
166
+ * @returns Clamped scroll target between 0 and maxScroll.
167
+ * @example
168
+ * ```ts
169
+ * clampedScrollTarget(100, 300, 1000, 800); // 400
170
+ * clampedScrollTarget(100, 100, 1000, 800, 500); // 200, maxScroll uses 500
171
+ * ```
172
+ */
173
+ export const clampedScrollTarget = (offsetBeforeScroll, keyboardHeight, contentHeight, layoutHeight, totalPaddingForMaxScroll) => {
174
+ "worklet";
175
+
176
+ const paddingForMax = totalPaddingForMaxScroll !== undefined ? totalPaddingForMaxScroll : keyboardHeight;
177
+ const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
178
+ return Math.min(Math.max(offsetBeforeScroll + keyboardHeight, 0), maxScroll);
179
+ };
180
+
181
+ /**
182
+ * Compute contentOffset.y for iOS lists.
183
+ *
184
+ * @param relativeScroll - Scroll position relative to current inset.
185
+ * @param keyboardHeight - Target keyboard height (used for scroll displacement).
186
+ * @param contentHeight - Total height of the scrollable content.
187
+ * @param layoutHeight - Visible height of the scroll view.
188
+ * @param inverted - Whether the list is inverted.
189
+ * @param totalPaddingForMaxScroll - Total padding to use for maxScroll calculation. When provided, used instead of keyboardHeight for the scrollable range. Defaults to keyboardHeight.
190
+ * @returns The absolute contentOffset.y to set.
191
+ * @example
192
+ * ```ts
193
+ * computeIOSContentOffset(100, 300, 1000, 800, false); // 400
194
+ * ```
195
+ */
196
+ export const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight, layoutHeight, inverted, totalPaddingForMaxScroll) => {
197
+ "worklet";
198
+
199
+ const paddingForMax = totalPaddingForMaxScroll !== undefined ? totalPaddingForMaxScroll : keyboardHeight;
200
+ if (inverted) {
201
+ const maxScroll = Math.max(contentHeight - layoutHeight, 0);
202
+ return Math.max(Math.min(relativeScroll - keyboardHeight, maxScroll), -paddingForMax);
203
+ }
204
+ const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
205
+ return Math.min(Math.max(keyboardHeight + relativeScroll, 0), maxScroll);
206
+ };
207
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["interpolate","AT_END_THRESHOLD","getEffectiveHeight","height","targetKeyboardHeight","offset","Math","max","isScrollAtEnd","scrollOffset","layoutHeight","contentHeight","inverted","shouldShiftContent","behavior","isAtEnd","getVisibleMinimumPaddingFraction","blankSpace","min","pastContentEnd","getMinimumPaddingAbsorbed","extraContentPadding","getScrollEffective","rawEffective","minimumPaddingAbsorbed","clampedScrollTarget","offsetBeforeScroll","keyboardHeight","totalPaddingForMaxScroll","paddingForMax","undefined","maxScroll","computeIOSContentOffset","relativeScroll"],"sources":["helpers.ts"],"sourcesContent":["import { interpolate } from \"react-native-reanimated\";\n\nimport type { KeyboardLiftBehavior } from \"./types\";\n\nconst AT_END_THRESHOLD = 20;\n\n/**\n * Map the current keyboard height to an effective height that accounts for a\n * fixed offset (e.g. Bottom safe-area or tab-bar height)..\n *\n * @param height - Current keyboard height.\n * @param targetKeyboardHeight - Full target keyboard height (captured on keyboard open).\n * @param offset - Fixed distance between the scroll-view bottom and the screen bottom.\n * @returns Effective height after subtracting the offset proportionally.\n * @example\n * ```ts\n * getEffectiveHeight(300, 300, 50); // 250\n * getEffectiveHeight(150, 300, 50); // 125\n * ```\n */\nexport const getEffectiveHeight = (\n height: number,\n targetKeyboardHeight: number,\n offset: number,\n): number => {\n \"worklet\";\n\n if (offset === 0 || targetKeyboardHeight === 0) {\n return height;\n }\n\n return interpolate(\n height,\n [0, targetKeyboardHeight],\n [0, Math.max(targetKeyboardHeight - offset, 0)],\n );\n};\n\n/**\n * Check whether the scroll view is at the end of its content.\n *\n * For non-inverted lists the \"end\" is the bottom of the content.\n * For inverted lists the \"end\" is the top (scroll offset near 0),\n * because that is where the latest messages are displayed.\n *\n * @param scrollOffset - Current vertical scroll offset.\n * @param layoutHeight - Visible height of the scroll view.\n * @param contentHeight - Total height of the scrollable content.\n * @param inverted - Whether the list is inverted.\n * @returns `true` if the scroll position is within the threshold of the content end.\n * @example\n * ```ts\n * const atEnd = isScrollAtEnd(100, 800, 920); // true (100 + 800 >= 920 - 20)\n * const atEndInverted = isScrollAtEnd(5, 800, 2000, true); // true (5 <= 20)\n * ```\n */\nexport const isScrollAtEnd = (\n scrollOffset: number,\n layoutHeight: number,\n contentHeight: number,\n inverted: boolean = false,\n): boolean => {\n \"worklet\";\n\n if (inverted) {\n return scrollOffset <= AT_END_THRESHOLD;\n }\n\n return scrollOffset + layoutHeight >= contentHeight - AT_END_THRESHOLD;\n};\n\n/**\n * Decide whether content should be shifted based on the keyboard lift behavior.\n *\n * @param behavior - The configured keyboard lift behavior.\n * @param isAtEnd - Whether the scroll view is currently at the end.\n * @returns `true` if content should be shifted.\n * @example\n * ```ts\n * shouldShiftContent(\"always\", false); // true\n * shouldShiftContent(\"whenAtEnd\", false); // false\n * ```\n */\nexport const shouldShiftContent = (\n behavior: KeyboardLiftBehavior,\n isAtEnd: boolean,\n): boolean => {\n \"worklet\";\n\n switch (behavior) {\n case \"always\":\n return true;\n case \"never\":\n return false;\n case \"whenAtEnd\":\n return isAtEnd;\n case \"persistent\":\n return true;\n }\n};\n\n/**\n * Compute the fraction of minimum padding space currently visible in the viewport (0–1).\n *\n * The minimum padding space lives in the scroll view's contentInset, NOT in the\n * content itself. So `contentHeight` (from onContentSizeChange / scroll\n * events) does **not** include it. The visible portion is how far the\n * viewport extends past the content boundary into the inset area.\n *\n * For non-inverted lists the padding is in contentInset.bottom.\n * For inverted lists the padding is in contentInset.top (negative scroll).\n *\n * @param scrollOffset - Current vertical scroll offset.\n * @param layoutHeight - Visible height of the scroll view.\n * @param contentHeight - Height of the scroll content (excludes insets).\n * @param blankSpace - Size of the minimum padding inset area.\n * @param inverted - Whether the list is inverted.\n * @returns A value between 0 (padding fully off-screen) and 1 (padding fully visible).\n * @example\n * ```ts\n * // Non-inverted: contentHeight=1500, layout=800, blankSpace=300\n * getVisibleMinimumPaddingFraction(1500, 800, 1500, 300, false); // 1 (at end, viewport past content)\n * getVisibleMinimumPaddingFraction(850, 800, 1500, 300, false); // 0.5 (half padding visible)\n * getVisibleMinimumPaddingFraction(700, 800, 1500, 300, false); // 0 (padding off-screen)\n * ```\n */\nexport const getVisibleMinimumPaddingFraction = (\n scrollOffset: number,\n layoutHeight: number,\n contentHeight: number,\n blankSpace: number,\n inverted: boolean,\n): number => {\n \"worklet\";\n\n if (blankSpace <= 0) {\n return 0;\n }\n\n if (inverted) {\n // Minimum padding is in contentInset.top; visible when scroll < 0\n return Math.max(0, Math.min(1, -scrollOffset / blankSpace));\n }\n\n // Minimum padding is in contentInset.bottom; visible when viewport extends past content\n const pastContentEnd = scrollOffset + layoutHeight - contentHeight;\n\n return Math.max(0, Math.min(1, pastContentEnd / blankSpace));\n};\n\n/**\n * Compute how much of the minimum content padding absorbs the keyboard + extraContentPadding.\n *\n * @param blankSpace - Minimum inset floor.\n * @param extraContentPadding - Extra content padding from external elements.\n * @returns The portion of blankSpace that absorbs keyboard displacement.\n * @example\n * ```ts\n * getMinimumPaddingAbsorbed(500, 20); // 480\n * getMinimumPaddingAbsorbed(0, 20); // 0\n * ```\n */\nexport const getMinimumPaddingAbsorbed = (\n blankSpace: number,\n extraContentPadding: number,\n): number => {\n \"worklet\";\n\n return Math.max(0, blankSpace - extraContentPadding);\n};\n\n/**\n * Compute the effective scroll displacement after minimum padding absorption.\n *\n * @param rawEffective - Raw effective keyboard height.\n * @param minimumPaddingAbsorbed - Amount absorbed by minimum content padding.\n * @returns The scroll displacement after subtracting the absorbed portion.\n * @example\n * ```ts\n * getScrollEffective(300, 200); // 100\n * getScrollEffective(300, 400); // 0\n * ```\n */\nexport const getScrollEffective = (\n rawEffective: number,\n minimumPaddingAbsorbed: number,\n): number => {\n \"worklet\";\n\n return Math.max(0, rawEffective - minimumPaddingAbsorbed);\n};\n\n/**\n * Compute the clamped scroll target for non-inverted lists.\n *\n * @param offsetBeforeScroll - Scroll position before keyboard appeared.\n * @param keyboardHeight - Current keyboard height (used for scroll displacement).\n * @param contentHeight - Total height of the scrollable content.\n * @param layoutHeight - Visible height of the scroll view.\n * @param totalPaddingForMaxScroll - Total padding to use for maxScroll calculation. When provided, used instead of keyboardHeight for the scrollable range. Defaults to keyboardHeight.\n * @returns Clamped scroll target between 0 and maxScroll.\n * @example\n * ```ts\n * clampedScrollTarget(100, 300, 1000, 800); // 400\n * clampedScrollTarget(100, 100, 1000, 800, 500); // 200, maxScroll uses 500\n * ```\n */\nexport const clampedScrollTarget = (\n offsetBeforeScroll: number,\n keyboardHeight: number,\n contentHeight: number,\n layoutHeight: number,\n totalPaddingForMaxScroll?: number,\n): number => {\n \"worklet\";\n\n const paddingForMax =\n totalPaddingForMaxScroll !== undefined\n ? totalPaddingForMaxScroll\n : keyboardHeight;\n const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);\n\n return Math.min(Math.max(offsetBeforeScroll + keyboardHeight, 0), maxScroll);\n};\n\n/**\n * Compute contentOffset.y for iOS lists.\n *\n * @param relativeScroll - Scroll position relative to current inset.\n * @param keyboardHeight - Target keyboard height (used for scroll displacement).\n * @param contentHeight - Total height of the scrollable content.\n * @param layoutHeight - Visible height of the scroll view.\n * @param inverted - Whether the list is inverted.\n * @param totalPaddingForMaxScroll - Total padding to use for maxScroll calculation. When provided, used instead of keyboardHeight for the scrollable range. Defaults to keyboardHeight.\n * @returns The absolute contentOffset.y to set.\n * @example\n * ```ts\n * computeIOSContentOffset(100, 300, 1000, 800, false); // 400\n * ```\n */\nexport const computeIOSContentOffset = (\n relativeScroll: number,\n keyboardHeight: number,\n contentHeight: number,\n layoutHeight: number,\n inverted: boolean,\n totalPaddingForMaxScroll?: number,\n): number => {\n \"worklet\";\n\n const paddingForMax =\n totalPaddingForMaxScroll !== undefined\n ? totalPaddingForMaxScroll\n : keyboardHeight;\n\n if (inverted) {\n const maxScroll = Math.max(contentHeight - layoutHeight, 0);\n\n return Math.max(\n Math.min(relativeScroll - keyboardHeight, maxScroll),\n -paddingForMax,\n );\n }\n\n const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);\n\n return Math.min(Math.max(keyboardHeight + relativeScroll, 0), maxScroll);\n};\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,yBAAyB;AAIrD,MAAMC,gBAAgB,GAAG,EAAE;;AAE3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAGA,CAChCC,MAAc,EACdC,oBAA4B,EAC5BC,MAAc,KACH;EACX,SAAS;;EAET,IAAIA,MAAM,KAAK,CAAC,IAAID,oBAAoB,KAAK,CAAC,EAAE;IAC9C,OAAOD,MAAM;EACf;EAEA,OAAOH,WAAW,CAChBG,MAAM,EACN,CAAC,CAAC,EAAEC,oBAAoB,CAAC,EACzB,CAAC,CAAC,EAAEE,IAAI,CAACC,GAAG,CAACH,oBAAoB,GAAGC,MAAM,EAAE,CAAC,CAAC,CAChD,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,aAAa,GAAGA,CAC3BC,YAAoB,EACpBC,YAAoB,EACpBC,aAAqB,EACrBC,QAAiB,GAAG,KAAK,KACb;EACZ,SAAS;;EAET,IAAIA,QAAQ,EAAE;IACZ,OAAOH,YAAY,IAAIR,gBAAgB;EACzC;EAEA,OAAOQ,YAAY,GAAGC,YAAY,IAAIC,aAAa,GAAGV,gBAAgB;AACxE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMY,kBAAkB,GAAGA,CAChCC,QAA8B,EAC9BC,OAAgB,KACJ;EACZ,SAAS;;EAET,QAAQD,QAAQ;IACd,KAAK,QAAQ;MACX,OAAO,IAAI;IACb,KAAK,OA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GAAGM,cAAc,EAAE,CAAC,CAAC,EAAEF,SAAS,CAAC;AAC1E,CAAC","ignoreList":[]}
@@ -0,0 +1,143 @@
1
+ import { useSharedValue } from "react-native-reanimated";
2
+ import { useKeyboardHandler } from "../../../hooks";
3
+ import useScrollState from "../../hooks/useScrollState";
4
+ import { computeIOSContentOffset, getEffectiveHeight, getScrollEffective, getVisibleMinimumPaddingFraction, isScrollAtEnd, shouldShiftContent } from "./helpers";
5
+ /**
6
+ * Hook that manages keyboard-driven scrolling for chat-style scroll views.
7
+ * Calculates padding (extra scrollable space) and content shift values,
8
+ * using iOS-specific strategy (contentOffset set once in onStart).
9
+ *
10
+ * @param scrollViewRef - Animated ref to the scroll view.
11
+ * @param options - Configuration for inverted and keyboardLiftBehavior.
12
+ * @returns Shared values for padding and contentOffsetY.
13
+ * @example
14
+ * ```tsx
15
+ * const { padding, contentOffsetY } = useChatKeyboard(ref, {
16
+ * inverted: false,
17
+ * keyboardLiftBehavior: "always",
18
+ * });
19
+ * ```
20
+ */
21
+ function useChatKeyboard(scrollViewRef, options) {
22
+ const {
23
+ inverted,
24
+ keyboardLiftBehavior,
25
+ freeze,
26
+ offset,
27
+ blankSpace,
28
+ extraContentPadding
29
+ } = options;
30
+ const padding = useSharedValue(0);
31
+ const currentHeight = useSharedValue(0);
32
+ const contentOffsetY = useSharedValue(0);
33
+ const targetKeyboardHeight = useSharedValue(0);
34
+ const prevAbsorption = useSharedValue(0);
35
+ const {
36
+ layout,
37
+ size,
38
+ offset: scroll,
39
+ onLayout,
40
+ onContentSizeChange
41
+ } = useScrollState(scrollViewRef);
42
+ useKeyboardHandler({
43
+ onStart: e => {
44
+ "worklet";
45
+
46
+ if (freeze.value) {
47
+ return;
48
+ }
49
+ if (e.height > 0) {
50
+ // eslint-disable-next-line react-compiler/react-compiler
51
+ targetKeyboardHeight.value = e.height;
52
+ }
53
+ const effective = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
54
+ const atEnd = isScrollAtEnd(scroll.value, layout.value.height, size.value.height, inverted);
55
+
56
+ // Scale minimum padding absorption by how much of it is visible.
57
+ // Fully visible → full absorption; fully off-screen → no absorption.
58
+ const visibleFraction = getVisibleMinimumPaddingFraction(scroll.value, layout.value.height, size.value.height, blankSpace.value, inverted);
59
+ const visiblePadding = visibleFraction * blankSpace.value;
60
+ const minimumPaddingAbsorbed = Math.max(0, visiblePadding - extraContentPadding.value);
61
+ const scrollEffective = getScrollEffective(effective, minimumPaddingAbsorbed);
62
+ const actualTotalPadding = Math.max(blankSpace.value, effective + extraContentPadding.value);
63
+
64
+ // persistent mode: when keyboard shrinks, clamp to valid range
65
+ if (keyboardLiftBehavior === "persistent" && effective < padding.value) {
66
+ padding.value = effective;
67
+ prevAbsorption.value = minimumPaddingAbsorbed;
68
+ if (inverted) {
69
+ const maxScroll = Math.max(size.value.height - layout.value.height, 0);
70
+ contentOffsetY.value = Math.max(-actualTotalPadding, Math.min(scroll.value, maxScroll));
71
+ } else {
72
+ const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, 0);
73
+ contentOffsetY.value = Math.max(0, Math.min(scroll.value, maxScroll));
74
+ }
75
+ return;
76
+ }
77
+
78
+ // never mode: when keyboard shrinks, clamp to valid range
79
+ // to avoid ghost padding
80
+ if (keyboardLiftBehavior === "never" && effective < padding.value && atEnd) {
81
+ padding.value = effective;
82
+ prevAbsorption.value = minimumPaddingAbsorbed;
83
+ if (inverted) {
84
+ const maxScroll = Math.max(size.value.height - layout.value.height, 0);
85
+ contentOffsetY.value = Math.max(-actualTotalPadding, Math.min(scroll.value, maxScroll));
86
+ } else {
87
+ const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, 0);
88
+ contentOffsetY.value = Math.max(0, Math.min(scroll.value, maxScroll));
89
+ }
90
+ return;
91
+ }
92
+
93
+ // Undo only the scroll displacement that was actually applied
94
+ // (not the full padding, which includes the absorbed portion).
95
+ // Use the stored absorption from the previous event so that
96
+ // the unwind matches the shift that was originally applied.
97
+ const prevScrollEffective = getScrollEffective(padding.value, prevAbsorption.value);
98
+ const relativeScroll = inverted ? scroll.value + prevScrollEffective : scroll.value - prevScrollEffective;
99
+ padding.value = effective;
100
+ prevAbsorption.value = minimumPaddingAbsorbed;
101
+ if (!shouldShiftContent(keyboardLiftBehavior, atEnd)) {
102
+ // Preserve current scroll position so animated props
103
+ // don't re-apply a stale contentOffset when padding changes
104
+ contentOffsetY.value = scroll.value;
105
+ return;
106
+ }
107
+
108
+ // When blankSpace fully absorbs the keyboard opening, preserve current scroll position
109
+ // (only when keyboard is open — effective > 0 — not when closing)
110
+ if (scrollEffective === 0 && minimumPaddingAbsorbed > 0 && effective > 0) {
111
+ contentOffsetY.value = scroll.value;
112
+ return;
113
+ }
114
+ contentOffsetY.value = computeIOSContentOffset(relativeScroll, scrollEffective, size.value.height, layout.value.height, inverted, actualTotalPadding);
115
+ },
116
+ onMove: () => {
117
+ "worklet";
118
+
119
+ // iOS doesn't need per-frame updates (contentOffset handles it)
120
+ },
121
+ onEnd: e => {
122
+ "worklet";
123
+
124
+ if (freeze.value) {
125
+ return;
126
+ }
127
+ const effective = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
128
+ padding.value = effective;
129
+ }
130
+ }, [inverted, keyboardLiftBehavior, offset, extraContentPadding]);
131
+ return {
132
+ padding,
133
+ currentHeight,
134
+ contentOffsetY,
135
+ scroll,
136
+ layout,
137
+ size,
138
+ onLayout,
139
+ onContentSizeChange
140
+ };
141
+ }
142
+ export { useChatKeyboard };
143
+ //# sourceMappingURL=index.ios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSharedValue","useKeyboardHandler","useScrollState","computeIOSContentOffset","getEffectiveHeight","getScrollEffective","getVisibleMinimumPaddingFraction","isScrollAtEnd","shouldShiftContent","useChatKeyboard","scrollViewRef","options","inverted","keyboardLiftBehavior","freeze","offset","blankSpace","extraContentPadding","padding","currentHeight","contentOffsetY","targetKeyboardHeight","prevAbsorption","layout","size","scroll","onLayout","onContentSizeChange","onStart","e","value","height","effective","atEnd","visibleFraction","visiblePadding","minimumPaddingAbsorbed","Math","max","scrollEffective","actualTotalPadding","maxScroll","min","prevScrollEffective","relativeScroll","onMove","onEnd"],"sources":["index.ios.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport { useKeyboardHandler } from \"../../../hooks\";\nimport useScrollState from \"../../hooks/useScrollState\";\n\nimport {\n computeIOSContentOffset,\n getEffectiveHeight,\n getScrollEffective,\n getVisibleMinimumPaddingFraction,\n isScrollAtEnd,\n shouldShiftContent,\n} from \"./helpers\";\n\nimport type { UseChatKeyboardOptions, UseChatKeyboardReturn } from \"./types\";\nimport type { AnimatedRef } from \"react-native-reanimated\";\nimport type Reanimated from \"react-native-reanimated\";\n\n/**\n * Hook that manages keyboard-driven scrolling for chat-style scroll views.\n * Calculates padding (extra scrollable space) and content shift values,\n * using iOS-specific strategy (contentOffset set once in onStart).\n *\n * @param scrollViewRef - Animated ref to the scroll view.\n * @param options - Configuration for inverted and keyboardLiftBehavior.\n * @returns Shared values for padding and contentOffsetY.\n * @example\n * ```tsx\n * const { padding, contentOffsetY } = useChatKeyboard(ref, {\n * inverted: false,\n * keyboardLiftBehavior: \"always\",\n * });\n * ```\n */\nfunction useChatKeyboard(\n scrollViewRef: AnimatedRef<Reanimated.ScrollView>,\n options: UseChatKeyboardOptions,\n): UseChatKeyboardReturn {\n const {\n inverted,\n keyboardLiftBehavior,\n freeze,\n offset,\n blankSpace,\n extraContentPadding,\n } = options;\n\n const padding = useSharedValue(0);\n const currentHeight = useSharedValue(0);\n const contentOffsetY = useSharedValue(0);\n const targetKeyboardHeight = useSharedValue(0);\n const prevAbsorption = useSharedValue(0);\n\n const {\n layout,\n size,\n offset: scroll,\n onLayout,\n onContentSizeChange,\n } = useScrollState(scrollViewRef);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (freeze.value) {\n return;\n }\n\n if (e.height > 0) {\n // eslint-disable-next-line react-compiler/react-compiler\n targetKeyboardHeight.value = e.height;\n }\n\n const effective = getEffectiveHeight(\n e.height,\n targetKeyboardHeight.value,\n offset,\n );\n\n const atEnd = isScrollAtEnd(\n scroll.value,\n layout.value.height,\n size.value.height,\n inverted,\n );\n\n // Scale minimum padding absorption by how much of it is visible.\n // Fully visible → full absorption; fully off-screen → no absorption.\n const visibleFraction = getVisibleMinimumPaddingFraction(\n scroll.value,\n layout.value.height,\n size.value.height,\n blankSpace.value,\n inverted,\n );\n const visiblePadding = visibleFraction * blankSpace.value;\n const minimumPaddingAbsorbed = Math.max(\n 0,\n visiblePadding - extraContentPadding.value,\n );\n const scrollEffective = getScrollEffective(\n effective,\n minimumPaddingAbsorbed,\n );\n const actualTotalPadding = Math.max(\n blankSpace.value,\n effective + extraContentPadding.value,\n );\n\n // persistent mode: when keyboard shrinks, clamp to valid range\n if (\n keyboardLiftBehavior === \"persistent\" &&\n effective < padding.value\n ) {\n padding.value = effective;\n prevAbsorption.value = minimumPaddingAbsorbed;\n\n if (inverted) {\n const maxScroll = Math.max(\n size.value.height - layout.value.height,\n 0,\n );\n\n contentOffsetY.value = Math.max(\n -actualTotalPadding,\n Math.min(scroll.value, maxScroll),\n );\n } else {\n const maxScroll = Math.max(\n size.value.height - layout.value.height + actualTotalPadding,\n 0,\n );\n\n contentOffsetY.value = Math.max(\n 0,\n Math.min(scroll.value, maxScroll),\n );\n }\n\n return;\n }\n\n // never mode: when keyboard shrinks, clamp to valid range\n // to avoid ghost padding\n if (\n keyboardLiftBehavior === \"never\" &&\n effective < padding.value &&\n atEnd\n ) {\n padding.value = effective;\n prevAbsorption.value = minimumPaddingAbsorbed;\n\n if (inverted) {\n const maxScroll = Math.max(\n size.value.height - layout.value.height,\n 0,\n );\n\n contentOffsetY.value = Math.max(\n -actualTotalPadding,\n Math.min(scroll.value, maxScroll),\n );\n } else {\n const maxScroll = Math.max(\n size.value.height - layout.value.height + actualTotalPadding,\n 0,\n );\n\n contentOffsetY.value = Math.max(\n 0,\n Math.min(scroll.value, maxScroll),\n );\n }\n\n return;\n }\n\n // Undo only the scroll displacement that was actually applied\n // (not the full padding, which includes the absorbed portion).\n // Use the stored absorption from the previous event so that\n // the unwind matches the shift that was originally applied.\n const prevScrollEffective = getScrollEffective(\n padding.value,\n prevAbsorption.value,\n );\n const relativeScroll = inverted\n ? scroll.value + prevScrollEffective\n : scroll.value - prevScrollEffective;\n\n padding.value = effective;\n prevAbsorption.value = minimumPaddingAbsorbed;\n\n if (!shouldShiftContent(keyboardLiftBehavior, atEnd)) {\n // Preserve current scroll position so animated props\n // don't re-apply a stale contentOffset when padding changes\n contentOffsetY.value = scroll.value;\n\n return;\n }\n\n // When blankSpace fully absorbs the keyboard opening, preserve current scroll position\n // (only when keyboard is open — effective > 0 — not when closing)\n if (\n scrollEffective === 0 &&\n minimumPaddingAbsorbed > 0 &&\n effective > 0\n ) {\n contentOffsetY.value = scroll.value;\n\n return;\n }\n\n contentOffsetY.value = computeIOSContentOffset(\n relativeScroll,\n scrollEffective,\n size.value.height,\n layout.value.height,\n inverted,\n actualTotalPadding,\n );\n },\n onMove: () => {\n \"worklet\";\n\n // iOS doesn't need per-frame updates (contentOffset handles it)\n },\n onEnd: (e) => {\n \"worklet\";\n\n if (freeze.value) {\n return;\n }\n\n const effective = getEffectiveHeight(\n e.height,\n targetKeyboardHeight.value,\n offset,\n );\n\n padding.value = effective;\n },\n },\n [inverted, keyboardLiftBehavior, offset, extraContentPadding],\n );\n\n return {\n padding,\n currentHeight,\n contentOffsetY,\n scroll,\n layout,\n size,\n onLayout,\n onContentSizeChange,\n };\n}\n\nexport { useChatKeyboard };\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,yBAAyB;AAExD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,OAAOC,cAAc,MAAM,4BAA4B;AAEvD,SACEC,uBAAuB,EACvBC,kBAAkB,EAClBC,kBAAkB,EAClBC,gCAAgC,EAChCC,aAAa,EACbC,kBAAkB,QACb,WAAW;AAM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