@react-native-ohos/react-native-keyboard-controller 1.16.8 → 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 (352) hide show
  1. package/README.OpenSource +2 -2
  2. package/README.md +105 -29
  3. package/harmony/keyboard_controller/BuildProfile.ets +1 -1
  4. package/harmony/keyboard_controller/Index.ets +1 -0
  5. package/harmony/keyboard_controller/oh-package-lock.json5 +7 -7
  6. package/harmony/keyboard_controller/oh-package.json5 +1 -1
  7. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentDescriptor.h +86 -0
  8. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.cpp +104 -0
  9. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.h +64 -0
  10. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewJSIBinder.h +60 -0
  11. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +8 -1
  12. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +2 -2
  13. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentDescriptor.h +46 -0
  14. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.cpp +37 -0
  15. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.h +32 -0
  16. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewJSIBinder.h +23 -0
  17. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.cpp +58 -1
  18. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardControllerPackage.h +20 -0
  19. package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.cpp +65 -44
  20. package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.h +22 -3
  21. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +17 -4
  22. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +9 -1
  23. package/harmony/keyboard_controller/src/main/ets/{RNKeyboardControllerPackage.ts → RNKeyboardControllerPackage.ets} +9 -5
  24. package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +29 -5
  25. package/harmony/keyboard_controller/src/main/ets/Type.ts +2 -1
  26. package/harmony/keyboard_controller.har +0 -0
  27. package/lib/commonjs/animated.js +20 -9
  28. package/lib/commonjs/animated.js.map +1 -1
  29. package/lib/commonjs/architecture.js +8 -0
  30. package/lib/commonjs/architecture.js.map +1 -0
  31. package/lib/commonjs/bindings.js +37 -2
  32. package/lib/commonjs/bindings.js.map +1 -1
  33. package/lib/commonjs/bindings.native.js +25 -2
  34. package/lib/commonjs/bindings.native.js.map +1 -1
  35. package/lib/commonjs/compat.js +50 -0
  36. package/lib/commonjs/compat.js.map +1 -0
  37. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +21 -15
  38. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
  39. package/lib/commonjs/components/KeyboardAvoidingView/index.js +36 -11
  40. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  41. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +51 -16
  42. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  43. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
  44. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  45. package/lib/commonjs/components/KeyboardChatScrollView/hooks.js +13 -0
  46. package/lib/commonjs/components/KeyboardChatScrollView/hooks.js.map +1 -0
  47. package/lib/commonjs/components/KeyboardChatScrollView/index.js +122 -0
  48. package/lib/commonjs/components/KeyboardChatScrollView/index.js.map +1 -0
  49. package/lib/commonjs/components/KeyboardChatScrollView/types.js +6 -0
  50. package/lib/commonjs/components/KeyboardChatScrollView/types.js.map +1 -0
  51. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +221 -0
  52. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
  53. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +149 -0
  54. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
  55. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js +240 -0
  56. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
  57. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js +6 -0
  58. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
  59. package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js +40 -0
  60. package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
  61. package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js +92 -0
  62. package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
  63. package/lib/commonjs/components/KeyboardToolbar/Arrow.js +2 -3
  64. package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
  65. package/lib/commonjs/components/KeyboardToolbar/Button.js +2 -3
  66. package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
  67. package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js +13 -0
  68. package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
  69. package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js +25 -0
  70. package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
  71. package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js +58 -0
  72. package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
  73. package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js +49 -0
  74. package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
  75. package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js +49 -0
  76. package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
  77. package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js +42 -0
  78. package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js.map +1 -0
  79. package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js +6 -0
  80. package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js.map +1 -0
  81. package/lib/commonjs/components/KeyboardToolbar/compound/context.js +17 -0
  82. package/lib/commonjs/components/KeyboardToolbar/compound/context.js.map +1 -0
  83. package/lib/commonjs/components/KeyboardToolbar/constants.js +17 -0
  84. package/lib/commonjs/components/KeyboardToolbar/constants.js.map +1 -0
  85. package/lib/commonjs/components/KeyboardToolbar/index.js +95 -84
  86. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  87. package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -1
  88. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js +120 -0
  89. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js.map +1 -0
  90. package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js +15 -0
  91. package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
  92. package/lib/commonjs/components/hooks/useColorScheme.js +1 -1
  93. package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -1
  94. package/lib/commonjs/components/hooks/useCombinedRef.js +24 -0
  95. package/lib/commonjs/components/hooks/useCombinedRef.js.map +1 -0
  96. package/lib/commonjs/components/hooks/useScrollState.js +62 -0
  97. package/lib/commonjs/components/hooks/useScrollState.js.map +1 -0
  98. package/lib/commonjs/components/index.js +7 -0
  99. package/lib/commonjs/components/index.js.map +1 -1
  100. package/lib/commonjs/constants.js +3 -1
  101. package/lib/commonjs/constants.js.map +1 -1
  102. package/lib/commonjs/context.js +1 -0
  103. package/lib/commonjs/context.js.map +1 -1
  104. package/lib/commonjs/hooks/index.js +14 -1
  105. package/lib/commonjs/hooks/index.js.map +1 -1
  106. package/lib/commonjs/hooks/useKeyboardState/index.js +39 -0
  107. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -0
  108. package/lib/commonjs/index.js +27 -1
  109. package/lib/commonjs/index.js.map +1 -1
  110. package/lib/commonjs/internal.js +36 -0
  111. package/lib/commonjs/internal.js.map +1 -1
  112. package/lib/commonjs/module.js +21 -12
  113. package/lib/commonjs/module.js.map +1 -1
  114. package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js +12 -0
  115. package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
  116. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +8 -2
  117. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  118. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +2 -1
  119. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  120. package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js +12 -0
  121. package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
  122. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
  123. package/lib/commonjs/types.js.map +1 -1
  124. package/lib/commonjs/utils/findNodeHandle/index.js +9 -0
  125. package/lib/commonjs/utils/findNodeHandle/index.js.map +1 -0
  126. package/lib/commonjs/utils/findNodeHandle/index.native.js +13 -0
  127. package/lib/commonjs/utils/findNodeHandle/index.native.js.map +1 -0
  128. package/lib/commonjs/views/KeyboardExtender/index.js +30 -0
  129. package/lib/commonjs/views/KeyboardExtender/index.js.map +1 -0
  130. package/lib/commonjs/views/index.js +7 -0
  131. package/lib/commonjs/views/index.js.map +1 -1
  132. package/lib/module/animated.js +22 -11
  133. package/lib/module/animated.js.map +1 -1
  134. package/lib/module/architecture.js +2 -0
  135. package/lib/module/architecture.js.map +1 -0
  136. package/lib/module/bindings.js +36 -2
  137. package/lib/module/bindings.js.map +1 -1
  138. package/lib/module/bindings.native.js +24 -2
  139. package/lib/module/bindings.native.js.map +1 -1
  140. package/lib/module/compat.js +43 -0
  141. package/lib/module/compat.js.map +1 -0
  142. package/lib/module/components/KeyboardAvoidingView/hooks.js +22 -16
  143. package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
  144. package/lib/module/components/KeyboardAvoidingView/index.js +35 -11
  145. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  146. package/lib/module/components/KeyboardAwareScrollView/index.js +54 -19
  147. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  148. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
  149. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  150. package/lib/module/components/KeyboardChatScrollView/hooks.js +2 -0
  151. package/lib/module/components/KeyboardChatScrollView/hooks.js.map +1 -0
  152. package/lib/module/components/KeyboardChatScrollView/index.js +115 -0
  153. package/lib/module/components/KeyboardChatScrollView/index.js.map +1 -0
  154. package/lib/module/components/KeyboardChatScrollView/types.js +2 -0
  155. package/lib/module/components/KeyboardChatScrollView/types.js.map +1 -0
  156. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +207 -0
  157. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
  158. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +143 -0
  159. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
  160. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js +234 -0
  161. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
  162. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js +2 -0
  163. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
  164. package/lib/module/components/KeyboardChatScrollView/useEndVisible.js +33 -0
  165. package/lib/module/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
  166. package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js +87 -0
  167. package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
  168. package/lib/module/components/KeyboardToolbar/Arrow.js +2 -2
  169. package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -1
  170. package/lib/module/components/KeyboardToolbar/Button.js +2 -2
  171. package/lib/module/components/KeyboardToolbar/Button.js.map +1 -1
  172. package/lib/module/components/KeyboardToolbar/compound/components/Background.js +6 -0
  173. package/lib/module/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
  174. package/lib/module/components/KeyboardToolbar/compound/components/Content.js +18 -0
  175. package/lib/module/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
  176. package/lib/module/components/KeyboardToolbar/compound/components/Done.js +50 -0
  177. package/lib/module/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
  178. package/lib/module/components/KeyboardToolbar/compound/components/Next.js +41 -0
  179. package/lib/module/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
  180. package/lib/module/components/KeyboardToolbar/compound/components/Prev.js +41 -0
  181. package/lib/module/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
  182. package/lib/module/components/KeyboardToolbar/compound/components/index.js +6 -0
  183. package/lib/module/components/KeyboardToolbar/compound/components/index.js.map +1 -0
  184. package/lib/module/components/KeyboardToolbar/compound/components/types.js +2 -0
  185. package/lib/module/components/KeyboardToolbar/compound/components/types.js.map +1 -0
  186. package/lib/module/components/KeyboardToolbar/compound/context.js +10 -0
  187. package/lib/module/components/KeyboardToolbar/compound/context.js.map +1 -0
  188. package/lib/module/components/KeyboardToolbar/constants.js +11 -0
  189. package/lib/module/components/KeyboardToolbar/constants.js.map +1 -0
  190. package/lib/module/components/KeyboardToolbar/index.js +95 -85
  191. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  192. package/lib/module/components/KeyboardToolbar/types.js.map +1 -1
  193. package/lib/module/components/ScrollViewWithBottomPadding/index.js +112 -0
  194. package/lib/module/components/ScrollViewWithBottomPadding/index.js.map +1 -0
  195. package/lib/module/components/ScrollViewWithBottomPadding/styles.js +9 -0
  196. package/lib/module/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
  197. package/lib/module/components/hooks/useColorScheme.js +1 -1
  198. package/lib/module/components/hooks/useColorScheme.js.map +1 -1
  199. package/lib/module/components/hooks/useCombinedRef.js +18 -0
  200. package/lib/module/components/hooks/useCombinedRef.js.map +1 -0
  201. package/lib/module/components/hooks/useScrollState.js +56 -0
  202. package/lib/module/components/hooks/useScrollState.js.map +1 -0
  203. package/lib/module/components/index.js +1 -0
  204. package/lib/module/components/index.js.map +1 -1
  205. package/lib/module/constants.js +3 -0
  206. package/lib/module/constants.js.map +1 -1
  207. package/lib/module/context.js +1 -0
  208. package/lib/module/context.js.map +1 -1
  209. package/lib/module/hooks/index.js +3 -1
  210. package/lib/module/hooks/index.js.map +1 -1
  211. package/lib/module/hooks/useKeyboardState/index.js +33 -0
  212. package/lib/module/hooks/useKeyboardState/index.js.map +1 -0
  213. package/lib/module/index.js +3 -2
  214. package/lib/module/index.js.map +1 -1
  215. package/lib/module/internal.js +35 -0
  216. package/lib/module/internal.js.map +1 -1
  217. package/lib/module/module.js +21 -12
  218. package/lib/module/module.js.map +1 -1
  219. package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js +6 -0
  220. package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
  221. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +7 -1
  222. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  223. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +2 -1
  224. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  225. package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js +5 -0
  226. package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
  227. package/lib/module/specs/NativeKeyboardController.js.map +1 -1
  228. package/lib/module/types.js.map +1 -1
  229. package/lib/module/utils/findNodeHandle/index.js +2 -0
  230. package/lib/module/utils/findNodeHandle/index.js.map +1 -0
  231. package/lib/module/utils/findNodeHandle/index.native.js +3 -0
  232. package/lib/module/utils/findNodeHandle/index.native.js.map +1 -0
  233. package/lib/module/views/KeyboardExtender/index.js +23 -0
  234. package/lib/module/views/KeyboardExtender/index.js.map +1 -0
  235. package/lib/module/views/index.js +1 -0
  236. package/lib/module/views/index.js.map +1 -1
  237. package/lib/typescript/animated.d.ts +2 -38
  238. package/lib/typescript/architecture.d.ts +1 -0
  239. package/lib/typescript/bindings.d.ts +15 -1
  240. package/lib/typescript/bindings.native.d.ts +10 -1
  241. package/lib/typescript/compat.d.ts +12 -0
  242. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +5 -0
  243. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -1
  244. package/lib/typescript/components/KeyboardChatScrollView/hooks.d.ts +2 -0
  245. package/lib/typescript/components/KeyboardChatScrollView/index.d.ts +17 -0
  246. package/lib/typescript/components/KeyboardChatScrollView/types.d.ts +113 -0
  247. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts +132 -0
  248. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.d.ts +18 -0
  249. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.ios.d.ts +21 -0
  250. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts +37 -0
  251. package/lib/typescript/components/KeyboardChatScrollView/useEndVisible.d.ts +17 -0
  252. package/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts +45 -0
  253. package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -2
  254. package/lib/typescript/components/KeyboardToolbar/compound/components/Background.d.ts +6 -0
  255. package/lib/typescript/components/KeyboardToolbar/compound/components/Content.d.ts +7 -0
  256. package/lib/typescript/components/KeyboardToolbar/compound/components/Done.d.ts +7 -0
  257. package/lib/typescript/components/KeyboardToolbar/compound/components/Next.d.ts +4 -0
  258. package/lib/typescript/components/KeyboardToolbar/compound/components/Prev.d.ts +4 -0
  259. package/lib/typescript/components/KeyboardToolbar/compound/components/index.d.ts +5 -0
  260. package/lib/typescript/components/KeyboardToolbar/compound/components/types.d.ts +14 -0
  261. package/lib/typescript/components/KeyboardToolbar/compound/context.d.ts +9 -0
  262. package/lib/typescript/components/KeyboardToolbar/constants.d.ts +10 -0
  263. package/lib/typescript/components/KeyboardToolbar/index.d.ts +12 -45
  264. package/lib/typescript/components/KeyboardToolbar/types.d.ts +24 -1
  265. package/lib/typescript/components/ScrollViewWithBottomPadding/index.d.ts +30 -0
  266. package/lib/typescript/components/ScrollViewWithBottomPadding/styles.d.ts +7 -0
  267. package/lib/typescript/components/hooks/useCombinedRef.d.ts +3 -0
  268. package/lib/typescript/components/hooks/useScrollState.d.ts +17 -0
  269. package/lib/typescript/components/index.d.ts +3 -0
  270. package/lib/typescript/constants.d.ts +1 -0
  271. package/lib/typescript/context.d.ts +1 -0
  272. package/lib/typescript/hooks/index.d.ts +2 -0
  273. package/lib/typescript/hooks/useKeyboardState/index.d.ts +4 -0
  274. package/lib/typescript/index.d.ts +4 -3
  275. package/lib/typescript/internal.d.ts +4 -0
  276. package/lib/typescript/specs/ClippingScrollViewDecoratorViewNativeComponent.d.ts +10 -0
  277. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
  278. package/lib/typescript/specs/KeyboardToolbarGroupViewNativeComponent.d.ts +6 -0
  279. package/lib/typescript/specs/NativeKeyboardController.d.ts +6 -2
  280. package/lib/typescript/types.d.ts +80 -5
  281. package/lib/typescript/utils/findNodeHandle/index.d.ts +4 -0
  282. package/lib/typescript/utils/findNodeHandle/index.native.d.ts +2 -0
  283. package/lib/typescript/views/KeyboardExtender/index.d.ts +5 -0
  284. package/lib/typescript/views/index.d.ts +1 -0
  285. package/package.json +15 -9
  286. package/src/animated.tsx +41 -48
  287. package/src/architecture.ts +1 -0
  288. package/src/bindings.native.ts +37 -2
  289. package/src/bindings.ts +40 -1
  290. package/src/compat.ts +44 -0
  291. package/src/components/KeyboardAvoidingView/hooks.ts +24 -17
  292. package/src/components/KeyboardAvoidingView/index.tsx +62 -18
  293. package/src/components/KeyboardAwareScrollView/index.tsx +75 -20
  294. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +2 -2
  295. package/src/components/KeyboardChatScrollView/hooks.ts +2 -0
  296. package/src/components/KeyboardChatScrollView/index.tsx +164 -0
  297. package/src/components/KeyboardChatScrollView/types.ts +117 -0
  298. package/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts +268 -0
  299. package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts +260 -0
  300. package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts +374 -0
  301. package/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts +39 -0
  302. package/src/components/KeyboardChatScrollView/useEndVisible.ts +66 -0
  303. package/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts +149 -0
  304. package/src/components/KeyboardToolbar/Arrow.tsx +2 -2
  305. package/src/components/KeyboardToolbar/Button.tsx +4 -4
  306. package/src/components/KeyboardToolbar/compound/components/Background.tsx +9 -0
  307. package/src/components/KeyboardToolbar/compound/components/Content.tsx +25 -0
  308. package/src/components/KeyboardToolbar/compound/components/Done.tsx +57 -0
  309. package/src/components/KeyboardToolbar/compound/components/Next.tsx +49 -0
  310. package/src/components/KeyboardToolbar/compound/components/Prev.tsx +49 -0
  311. package/src/components/KeyboardToolbar/compound/components/index.ts +5 -0
  312. package/src/components/KeyboardToolbar/compound/components/types.ts +15 -0
  313. package/src/components/KeyboardToolbar/compound/context.ts +25 -0
  314. package/src/components/KeyboardToolbar/constants.ts +14 -0
  315. package/src/components/KeyboardToolbar/index.tsx +143 -146
  316. package/src/components/KeyboardToolbar/types.ts +33 -1
  317. package/src/components/ScrollViewWithBottomPadding/index.tsx +216 -0
  318. package/src/components/ScrollViewWithBottomPadding/styles.ts +10 -0
  319. package/src/components/hooks/useColorScheme.ts +2 -1
  320. package/src/components/hooks/useCombinedRef.ts +22 -0
  321. package/src/components/hooks/useScrollState.ts +81 -0
  322. package/src/components/index.ts +3 -0
  323. package/src/constants.ts +4 -0
  324. package/src/context.ts +2 -0
  325. package/src/hooks/index.ts +2 -1
  326. package/src/hooks/useKeyboardState/index.ts +52 -0
  327. package/src/index.ts +5 -1
  328. package/src/internal.ts +62 -0
  329. package/src/module.ts +21 -9
  330. package/src/specs/ClippingScrollViewDecoratorViewNativeComponent.ts +19 -0
  331. package/src/specs/KeyboardControllerViewNativeComponent.ts +14 -3
  332. package/src/specs/KeyboardGestureAreaNativeComponent.ts +1 -0
  333. package/src/specs/KeyboardToolbarGroupViewNativeComponent.ts +10 -0
  334. package/src/specs/NativeKeyboardController.ts +6 -2
  335. package/src/types.ts +91 -5
  336. package/src/utils/findNodeHandle/index.native.ts +3 -0
  337. package/src/utils/findNodeHandle/index.ts +6 -0
  338. package/src/views/KeyboardExtender/index.tsx +30 -0
  339. package/src/views/index.ts +1 -0
  340. package/lib/commonjs/monkey-patch.android.js +0 -57
  341. package/lib/commonjs/monkey-patch.android.js.map +0 -1
  342. package/lib/commonjs/monkey-patch.js +0 -11
  343. package/lib/commonjs/monkey-patch.js.map +0 -1
  344. package/lib/module/monkey-patch.android.js +0 -47
  345. package/lib/module/monkey-patch.android.js.map +0 -1
  346. package/lib/module/monkey-patch.js +0 -5
  347. package/lib/module/monkey-patch.js.map +0 -1
  348. package/lib/typescript/monkey-patch.android.d.ts +0 -2
  349. package/lib/typescript/monkey-patch.d.ts +0 -2
  350. package/src/monkey-patch.android.ts +0 -44
  351. package/src/monkey-patch.ts +0 -4
  352. /package/harmony/keyboard_controller/{ts.ts → ts.ets} +0 -0
@@ -0,0 +1,374 @@
1
+ import { scrollTo, useSharedValue } from "react-native-reanimated";
2
+
3
+ import { useKeyboardHandler } from "../../../hooks";
4
+ import useScrollState from "../../hooks/useScrollState";
5
+
6
+ import {
7
+ clampedScrollTarget,
8
+ getEffectiveHeight,
9
+ getMinimumPaddingAbsorbed,
10
+ getScrollEffective,
11
+ getVisibleMinimumPaddingFraction,
12
+ isScrollAtEnd,
13
+ shouldShiftContent,
14
+ } from "./helpers";
15
+
16
+ import type { UseChatKeyboardOptions, UseChatKeyboardReturn } from "./types";
17
+ import type { AnimatedRef } from "react-native-reanimated";
18
+ import type Reanimated from "react-native-reanimated";
19
+
20
+ /**
21
+ * Hook that manages keyboard-driven scrolling for chat-style scroll views.
22
+ * Calculates padding (extra scrollable space) and content shift values,
23
+ * using per-frame scrollTo updates (Android and other platforms).
24
+ *
25
+ * @param scrollViewRef - Animated ref to the scroll view.
26
+ * @param options - Configuration for inverted and keyboardLiftBehavior.
27
+ * @returns Shared values for padding and contentOffsetY (always `undefined`).
28
+ * @example
29
+ * ```tsx
30
+ * const { padding } = useChatKeyboard(ref, { inverted: false, keyboardLiftBehavior: "always" });
31
+ * ```
32
+ */
33
+ function useChatKeyboard(
34
+ scrollViewRef: AnimatedRef<Reanimated.ScrollView>,
35
+ options: UseChatKeyboardOptions,
36
+ ): UseChatKeyboardReturn {
37
+ const {
38
+ inverted,
39
+ keyboardLiftBehavior,
40
+ freeze,
41
+ offset,
42
+ blankSpace,
43
+ extraContentPadding,
44
+ } = options;
45
+
46
+ const padding = useSharedValue(0);
47
+ const currentHeight = useSharedValue(0);
48
+ const offsetBeforeScroll = useSharedValue(0);
49
+ const targetKeyboardHeight = useSharedValue(0);
50
+ const closing = useSharedValue(false);
51
+ const minimumPaddingFractionOnOpen = useSharedValue(0);
52
+ const actualOpenShift = useSharedValue(0);
53
+ const {
54
+ layout,
55
+ size,
56
+ offset: scroll,
57
+ onLayout,
58
+ onContentSizeChange,
59
+ } = useScrollState(scrollViewRef);
60
+ const clampScrollIfNeeded = (
61
+ effective: number,
62
+ totalPaddingForMaxScroll?: number,
63
+ ) => {
64
+ "worklet";
65
+
66
+ const paddingForMax =
67
+ totalPaddingForMaxScroll !== undefined
68
+ ? totalPaddingForMaxScroll
69
+ : effective;
70
+ const maxScroll = Math.max(
71
+ size.value.height - layout.value.height + paddingForMax,
72
+ 0,
73
+ );
74
+
75
+ if (scroll.value > maxScroll) {
76
+ scrollTo(scrollViewRef, 0, maxScroll, false);
77
+ }
78
+ };
79
+
80
+ useKeyboardHandler(
81
+ {
82
+ onStart: (e) => {
83
+ "worklet";
84
+
85
+ if (freeze.value) {
86
+ return;
87
+ }
88
+
89
+ if (e.height > 0) {
90
+ // eslint-disable-next-line react-compiler/react-compiler
91
+ targetKeyboardHeight.value = e.height;
92
+ closing.value = false;
93
+ } else {
94
+ closing.value = true;
95
+ }
96
+
97
+ const effective = getEffectiveHeight(
98
+ e.height,
99
+ targetKeyboardHeight.value,
100
+ offset,
101
+ );
102
+
103
+ const atEnd = isScrollAtEnd(
104
+ scroll.value,
105
+ layout.value.height,
106
+ size.value.height,
107
+ inverted,
108
+ );
109
+
110
+ // Scale minimum padding absorption by how much of it is visible.
111
+ // Fully visible → full absorption; fully off-screen → no absorption.
112
+ const visibleFraction = getVisibleMinimumPaddingFraction(
113
+ scroll.value,
114
+ layout.value.height,
115
+ size.value.height,
116
+ blankSpace.value,
117
+ inverted,
118
+ );
119
+ const minimumPaddingAbsorbed =
120
+ visibleFraction >= 1
121
+ ? getMinimumPaddingAbsorbed(
122
+ blankSpace.value,
123
+ extraContentPadding.value,
124
+ )
125
+ : 0;
126
+ const scrollEffective = getScrollEffective(
127
+ effective,
128
+ minimumPaddingAbsorbed,
129
+ );
130
+
131
+ if (inverted && e.duration === -1) {
132
+ // Android inverted: skip post-interactive snap-back events
133
+ // (duration === -1 means the keyboard is re-establishing its
134
+ // position after an interactive gesture, not a real animation)
135
+ return;
136
+ } else if (e.height > 0) {
137
+ // Android: keyboard opening — set padding + capture scroll position
138
+ minimumPaddingFractionOnOpen.value = visibleFraction >= 1 ? 1 : 0;
139
+ padding.value = effective;
140
+ offsetBeforeScroll.value = scroll.value;
141
+
142
+ if (!inverted && keyboardLiftBehavior === "whenAtEnd" && !atEnd) {
143
+ // Sentinel: don't scroll in onMove (non-inverted only)
144
+ offsetBeforeScroll.value = -1;
145
+ } else if (!inverted && scrollEffective === 0) {
146
+ // blankSpace fully absorbs the keyboard — prevent scroll
147
+ offsetBeforeScroll.value = -1;
148
+ } else if (inverted && scrollEffective === 0) {
149
+ // blankSpace fully absorbs the keyboard — guard for inverted
150
+ offsetBeforeScroll.value = scroll.value;
151
+ }
152
+ } else {
153
+ // Android: keyboard closing — re-capture scroll position
154
+ if (inverted) {
155
+ offsetBeforeScroll.value = scroll.value;
156
+ } else {
157
+ // Preserve "whenAtEnd" sentinel: if open didn't shift, close shouldn't either
158
+ if (offsetBeforeScroll.value !== -1) {
159
+ // Use the actual displacement recorded at end of open animation
160
+ // (not the theoretical value) so close is symmetric with open
161
+ offsetBeforeScroll.value = scroll.value - actualOpenShift.value;
162
+ }
163
+ }
164
+ }
165
+ },
166
+ onMove: (e) => {
167
+ "worklet";
168
+
169
+ if (freeze.value) {
170
+ return;
171
+ }
172
+
173
+ currentHeight.value = e.height;
174
+
175
+ if (inverted) {
176
+ // Skip post-interactive snap-back (duration === -1)
177
+ if (e.duration === -1) {
178
+ return;
179
+ }
180
+
181
+ const effective = getEffectiveHeight(
182
+ e.height,
183
+ targetKeyboardHeight.value,
184
+ offset,
185
+ );
186
+
187
+ const minimumPaddingAbsorbed =
188
+ getMinimumPaddingAbsorbed(
189
+ blankSpace.value,
190
+ extraContentPadding.value,
191
+ ) * minimumPaddingFractionOnOpen.value;
192
+ const scrollEffective = getScrollEffective(
193
+ effective,
194
+ minimumPaddingAbsorbed,
195
+ );
196
+ const actualTotalPadding = Math.max(
197
+ blankSpace.value,
198
+ effective + extraContentPadding.value,
199
+ );
200
+
201
+ // Check if we should shift content based on position when keyboard started
202
+ const wasAtEnd = isScrollAtEnd(
203
+ offsetBeforeScroll.value,
204
+ layout.value.height,
205
+ size.value.height,
206
+ inverted,
207
+ );
208
+
209
+ // "never" at end: scroll along when keyboard closes to avoid jump
210
+ if (
211
+ keyboardLiftBehavior === "never" &&
212
+ wasAtEnd &&
213
+ effective < padding.value
214
+ ) {
215
+ padding.value = effective;
216
+
217
+ if (scrollEffective === 0 && minimumPaddingAbsorbed > 0) {
218
+ return;
219
+ }
220
+
221
+ scrollTo(scrollViewRef, 0, 0, false);
222
+
223
+ return;
224
+ }
225
+
226
+ if (!shouldShiftContent(keyboardLiftBehavior, wasAtEnd)) {
227
+ // Closing, not shifting: reduce padding to avoid gap
228
+ if (closing.value && effective < padding.value) {
229
+ padding.value = effective;
230
+ clampScrollIfNeeded(effective, actualTotalPadding);
231
+ }
232
+
233
+ return;
234
+ }
235
+
236
+ // When blankSpace fully absorbs the keyboard, skip scroll
237
+ if (scrollEffective === 0 && minimumPaddingAbsorbed > 0) {
238
+ return;
239
+ }
240
+
241
+ // Persistent: don't let shift decrease
242
+ if (keyboardLiftBehavior === "persistent") {
243
+ const currentShift =
244
+ offsetBeforeScroll.value + padding.value - scroll.value;
245
+
246
+ if (effective < currentShift) {
247
+ // When at end, allow scrolling back (snap to end + reduce padding)
248
+ if (wasAtEnd) {
249
+ padding.value = effective;
250
+ scrollTo(scrollViewRef, 0, 0, false);
251
+ } else if (closing.value) {
252
+ // Not at end: reduce padding to avoid gap
253
+ padding.value = effective;
254
+ clampScrollIfNeeded(effective, actualTotalPadding);
255
+ }
256
+
257
+ return;
258
+ }
259
+ }
260
+
261
+ const target =
262
+ offsetBeforeScroll.value + padding.value - scrollEffective;
263
+
264
+ scrollTo(scrollViewRef, 0, target, false);
265
+ } else {
266
+ const effective = getEffectiveHeight(
267
+ e.height,
268
+ targetKeyboardHeight.value,
269
+ offset,
270
+ );
271
+
272
+ const minimumPaddingAbsorbed =
273
+ getMinimumPaddingAbsorbed(
274
+ blankSpace.value,
275
+ extraContentPadding.value,
276
+ ) * minimumPaddingFractionOnOpen.value;
277
+ const scrollEffective = getScrollEffective(
278
+ effective,
279
+ minimumPaddingAbsorbed,
280
+ );
281
+ const actualTotalPadding = Math.max(
282
+ blankSpace.value,
283
+ effective + extraContentPadding.value,
284
+ );
285
+
286
+ // "never" closing: clamp scroll to valid range as inset shrinks
287
+ if (
288
+ keyboardLiftBehavior === "never" &&
289
+ closing.value &&
290
+ effective < padding.value
291
+ ) {
292
+ clampScrollIfNeeded(effective, actualTotalPadding);
293
+
294
+ return;
295
+ }
296
+
297
+ if (!shouldShiftContent(keyboardLiftBehavior, true)) {
298
+ return;
299
+ }
300
+
301
+ // "whenAtEnd" sentinel check (also used for blankSpace full absorption)
302
+ if (offsetBeforeScroll.value === -1) {
303
+ if (closing.value) {
304
+ // Keyboard didn't shift on open; ensure valid position on close
305
+ clampScrollIfNeeded(effective, actualTotalPadding);
306
+ }
307
+ return;
308
+ }
309
+
310
+ // "persistent" closing: maintain position, clamped to valid range
311
+ if (keyboardLiftBehavior === "persistent" && closing.value) {
312
+ const keepAt = offsetBeforeScroll.value + padding.value;
313
+ const maxScroll = Math.max(
314
+ size.value.height - layout.value.height + actualTotalPadding,
315
+ 0,
316
+ );
317
+
318
+ scrollTo(scrollViewRef, 0, Math.min(keepAt, maxScroll), false);
319
+ return;
320
+ }
321
+
322
+ const target = clampedScrollTarget(
323
+ offsetBeforeScroll.value,
324
+ scrollEffective,
325
+ size.value.height,
326
+ layout.value.height,
327
+ actualTotalPadding,
328
+ );
329
+
330
+ scrollTo(scrollViewRef, 0, target, false);
331
+
332
+ // Track actual (clamped) displacement during open for symmetric close
333
+ if (!closing.value) {
334
+ actualOpenShift.value = target - offsetBeforeScroll.value;
335
+ }
336
+ }
337
+ },
338
+ onEnd: (e) => {
339
+ "worklet";
340
+
341
+ if (freeze.value) {
342
+ return;
343
+ }
344
+
345
+ const effective = getEffectiveHeight(
346
+ e.height,
347
+ targetKeyboardHeight.value,
348
+ offset,
349
+ );
350
+
351
+ padding.value = effective;
352
+
353
+ // Record actual scroll displacement so close can be symmetric
354
+ if (effective > 0 && offsetBeforeScroll.value !== -1) {
355
+ actualOpenShift.value = scroll.value - offsetBeforeScroll.value;
356
+ }
357
+ },
358
+ },
359
+ [inverted, keyboardLiftBehavior, offset],
360
+ );
361
+
362
+ return {
363
+ padding,
364
+ currentHeight,
365
+ contentOffsetY: undefined,
366
+ scroll,
367
+ layout,
368
+ size,
369
+ onLayout,
370
+ onContentSizeChange,
371
+ };
372
+ }
373
+
374
+ export { useChatKeyboard };
@@ -0,0 +1,39 @@
1
+ import type { LayoutChangeEvent } from "react-native";
2
+ import type { SharedValue } from "react-native-reanimated";
3
+
4
+ type KeyboardLiftBehavior = "always" | "whenAtEnd" | "persistent" | "never";
5
+
6
+ type UseChatKeyboardOptions = {
7
+ inverted: boolean;
8
+ keyboardLiftBehavior: KeyboardLiftBehavior;
9
+ freeze: SharedValue<boolean>;
10
+ offset: number;
11
+ blankSpace: SharedValue<number>;
12
+ /** Extra content padding shared value — needed on iOS to correctly clamp contentOffset. */
13
+ extraContentPadding: SharedValue<number>;
14
+ };
15
+
16
+ type UseChatKeyboardReturn = {
17
+ /** Extra scrollable space (= keyboard height). Used as contentInset on iOS, contentInsetBottom/contentInsetTop on Android. */
18
+ padding: SharedValue<number>;
19
+ /** Raw keyboard height updated every frame in onMove. Used to force Reanimated commits on Fabric. */
20
+ currentHeight: SharedValue<number>;
21
+ /** Absolute Y content offset for iOS (set once in onStart). `undefined` on Android. */
22
+ contentOffsetY: SharedValue<number> | undefined;
23
+ /** Current vertical scroll offset. */
24
+ scroll: SharedValue<number>;
25
+ /** Visible viewport dimensions. */
26
+ layout: SharedValue<{ width: number; height: number }>;
27
+ /** Total content dimensions. */
28
+ size: SharedValue<{ width: number; height: number }>;
29
+ /** Callback to attach to ScrollView's onLayout prop to capture initial viewport dimensions. */
30
+ onLayout: (e: LayoutChangeEvent) => void;
31
+ /** Callback to attach to ScrollView's onContentSizeChange prop to capture initial content dimensions. */
32
+ onContentSizeChange: (w: number, h: number) => void;
33
+ };
34
+
35
+ export type {
36
+ KeyboardLiftBehavior,
37
+ UseChatKeyboardOptions,
38
+ UseChatKeyboardReturn,
39
+ };
@@ -0,0 +1,66 @@
1
+ import { useMemo } from "react";
2
+ import {
3
+ runOnJS,
4
+ useAnimatedReaction,
5
+ useDerivedValue,
6
+ } from "react-native-reanimated";
7
+
8
+ import { isScrollAtEnd } from "./useChatKeyboard/helpers";
9
+
10
+ import type { SharedValue } from "react-native-reanimated";
11
+
12
+ type EndVisibleCallback = (visible: boolean) => void;
13
+
14
+ type Options = {
15
+ scroll: SharedValue<number>;
16
+ layout: SharedValue<{ width: number; height: number }>;
17
+ size: SharedValue<{ width: number; height: number }>;
18
+ inverted: boolean;
19
+ onEndVisible?: EndVisibleCallback;
20
+ };
21
+
22
+ const hasWorkletHash = (value: unknown): boolean =>
23
+ typeof value === "function" &&
24
+ !!(value as unknown as Record<string, unknown>).__workletHash;
25
+
26
+ export const useEndVisible = ({
27
+ scroll,
28
+ layout,
29
+ size,
30
+ inverted,
31
+ onEndVisible,
32
+ }: Options) => {
33
+ const isWorklet = useMemo(() => hasWorkletHash(onEndVisible), [onEndVisible]);
34
+
35
+ const isAtEnd = useDerivedValue(() => {
36
+ // Wait until the scroll view has been measured to avoid a spurious initial
37
+ // `true` on a (0,0,0) layout (the helper would otherwise treat unmeasured
38
+ // state as "at end" because 0 + 0 >= 0 - threshold).
39
+ if (layout.value.height === 0 || size.value.height === 0) {
40
+ return null;
41
+ }
42
+
43
+ return isScrollAtEnd(
44
+ scroll.value,
45
+ layout.value.height,
46
+ size.value.height,
47
+ inverted,
48
+ );
49
+ });
50
+
51
+ useAnimatedReaction(
52
+ () => isAtEnd.value,
53
+ (current, previous) => {
54
+ if (current === null || current === previous || !onEndVisible) {
55
+ return;
56
+ }
57
+
58
+ if (isWorklet) {
59
+ onEndVisible(current);
60
+ } else {
61
+ runOnJS(onEndVisible)(current);
62
+ }
63
+ },
64
+ [onEndVisible, isWorklet, inverted],
65
+ );
66
+ };
@@ -0,0 +1,149 @@
1
+ import { useCallback } from "react";
2
+ import { Platform } from "react-native";
3
+ import { scrollTo, useAnimatedReaction } from "react-native-reanimated";
4
+
5
+ import { IS_FABRIC } from "../../../architecture";
6
+ import { isScrollAtEnd, shouldShiftContent } from "../useChatKeyboard/helpers";
7
+
8
+ import type { KeyboardLiftBehavior } from "../useChatKeyboard/types";
9
+ import type { AnimatedRef, SharedValue } from "react-native-reanimated";
10
+ import type Reanimated from "react-native-reanimated";
11
+
12
+ type UseExtraContentPaddingOptions = {
13
+ scrollViewRef: AnimatedRef<Reanimated.ScrollView>;
14
+ extraContentPadding: SharedValue<number>;
15
+ /** Keyboard-only padding from useChatKeyboard — used to compute total padding for clamping. */
16
+ keyboardPadding: SharedValue<number>;
17
+ /** Minimum inset floor — used to absorb keyboard and extraContentPadding changes. */
18
+ blankSpace: SharedValue<number>;
19
+ /** Current vertical scroll offset. */
20
+ scroll: SharedValue<number>;
21
+ /** Visible viewport dimensions. */
22
+ layout: SharedValue<{ width: number; height: number }>;
23
+ /** Total content dimensions. */
24
+ size: SharedValue<{ width: number; height: number }>;
25
+ /** IOS only — when provided, sets contentOffset atomically with contentInset. */
26
+ contentOffsetY?: SharedValue<number>;
27
+ inverted: boolean;
28
+ keyboardLiftBehavior: KeyboardLiftBehavior;
29
+ freeze: SharedValue<boolean>;
30
+ };
31
+
32
+ /**
33
+ * Hook that reacts to `extraContentPadding` changes and conditionally
34
+ * adjusts the scroll position using `scrollTo` on both iOS and Android.
35
+ *
36
+ * Padding extension (scrollable range) is handled externally via a
37
+ * `useDerivedValue` that sums keyboard padding + extra content padding.
38
+ * This hook only handles the scroll correction.
39
+ *
40
+ * @param options - Configuration and shared values.
41
+ * @example
42
+ * ```tsx
43
+ * useExtraContentPadding({ scrollViewRef, extraContentPadding, ... });
44
+ * ```
45
+ */
46
+ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
47
+ const {
48
+ scrollViewRef,
49
+ extraContentPadding,
50
+ keyboardPadding,
51
+ blankSpace,
52
+ scroll,
53
+ layout,
54
+ size,
55
+ contentOffsetY,
56
+ inverted,
57
+ keyboardLiftBehavior,
58
+ freeze,
59
+ } = options;
60
+
61
+ const scrollToTarget = useCallback(
62
+ (target: number) => {
63
+ "worklet";
64
+
65
+ if (contentOffsetY && IS_FABRIC) {
66
+ // eslint-disable-next-line react-compiler/react-compiler
67
+ contentOffsetY.value = target;
68
+ } else if (Platform.OS === "android" || (Platform.OS as string) === "harmony") {
69
+ // Defer scrollTo so the animatedProps inset commit lands first;
70
+ // otherwise the native ScrollView clamps to the old range.
71
+ requestAnimationFrame(() => {
72
+ scrollTo(scrollViewRef, 0, target, false);
73
+ });
74
+ } else {
75
+ scrollTo(scrollViewRef, 0, target, false);
76
+ }
77
+ },
78
+ [scrollViewRef, contentOffsetY],
79
+ );
80
+
81
+ useAnimatedReaction(
82
+ () => extraContentPadding.value,
83
+ (current, previous) => {
84
+ if (freeze.value || previous === null) {
85
+ return;
86
+ }
87
+
88
+ const rawDelta = current - previous;
89
+
90
+ if (rawDelta === 0) {
91
+ return;
92
+ }
93
+
94
+ // Compute effective delta considering blankSpace floor
95
+ const previousTotal = Math.max(
96
+ blankSpace.value,
97
+ keyboardPadding.value + previous,
98
+ );
99
+ const currentTotal = Math.max(
100
+ blankSpace.value,
101
+ keyboardPadding.value + current,
102
+ );
103
+ const effectiveDelta = currentTotal - previousTotal;
104
+
105
+ if (effectiveDelta === 0) {
106
+ // blankSpace absorbed the change
107
+ return;
108
+ }
109
+
110
+ const atEnd = isScrollAtEnd(
111
+ scroll.value,
112
+ layout.value.height,
113
+ size.value.height,
114
+ inverted,
115
+ );
116
+
117
+ // "persistent": scroll on grow, hold position on shrink (unless at end)
118
+ if (
119
+ keyboardLiftBehavior === "persistent" &&
120
+ effectiveDelta < 0 &&
121
+ !atEnd
122
+ ) {
123
+ return;
124
+ }
125
+
126
+ if (!shouldShiftContent(keyboardLiftBehavior, atEnd)) {
127
+ return;
128
+ }
129
+
130
+ if (inverted) {
131
+ const target = Math.max(scroll.value - effectiveDelta, -currentTotal);
132
+
133
+ scrollToTarget(target);
134
+ } else {
135
+ const maxScroll = Math.max(
136
+ size.value.height - layout.value.height + currentTotal,
137
+ 0,
138
+ );
139
+ const target = Math.min(scroll.value + effectiveDelta, maxScroll);
140
+
141
+ scrollToTarget(target);
142
+ }
143
+ },
144
+ [inverted, keyboardLiftBehavior],
145
+ );
146
+ }
147
+
148
+ export { useExtraContentPadding };
149
+ export type { UseExtraContentPaddingOptions };
@@ -1,7 +1,7 @@
1
1
  import React, { useMemo } from "react";
2
2
  import { Animated, StyleSheet, View } from "react-native";
3
3
 
4
- import useColorScheme from "../hooks/useColorScheme";
4
+ import { useKeyboardState } from "../../hooks";
5
5
 
6
6
  import type { KeyboardToolbarTheme } from "./types";
7
7
  import type { ViewStyle } from "react-native";
@@ -13,7 +13,7 @@ type ArrowProps = {
13
13
  };
14
14
 
15
15
  const ArrowComponent: React.FC<ArrowProps> = ({ type, disabled, theme }) => {
16
- const colorScheme = useColorScheme();
16
+ const colorScheme = useKeyboardState((state) => state.appearance);
17
17
 
18
18
  const color = useMemo(
19
19
  () => ({
@@ -6,15 +6,15 @@ import {
6
6
  View,
7
7
  } from "react-native";
8
8
 
9
- import useColorScheme from "../hooks/useColorScheme";
9
+ import { useKeyboardState } from "../../hooks";
10
10
 
11
11
  import type { KeyboardToolbarTheme } from "./types";
12
12
  import type { PropsWithChildren } from "react";
13
- import type { ViewStyle } from "react-native";
13
+ import type { GestureResponderEvent, ViewStyle } from "react-native";
14
14
 
15
15
  type ButtonProps = {
16
16
  disabled?: boolean;
17
- onPress: () => void;
17
+ onPress: (event: GestureResponderEvent) => void;
18
18
  accessibilityLabel: string;
19
19
  accessibilityHint: string;
20
20
  testID: string;
@@ -64,7 +64,7 @@ const ButtonAndroid = ({
64
64
  style,
65
65
  theme,
66
66
  }: PropsWithChildren<ButtonProps>) => {
67
- const colorScheme = useColorScheme();
67
+ const colorScheme = useKeyboardState((state) => state.appearance);
68
68
  const accessibilityState = useMemo(() => ({ disabled }), [disabled]);
69
69
  const ripple = useMemo(
70
70
  () =>
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+
3
+ import type { ReactNode } from "react";
4
+
5
+ const Background: React.FC<{ children: ReactNode }> = ({ children }) => (
6
+ <>{children}</>
7
+ );
8
+
9
+ export default Background;