@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
@@ -1,10 +1,14 @@
1
1
  import type { TurboModule } from "react-native";
2
2
  export interface Spec extends TurboModule {
3
- readonly getConstants: () => {};
3
+ readonly getConstants: () => {
4
+ keyboardBorderRadius: number;
5
+ };
4
6
  setInputMode(mode: number): void;
5
7
  setDefaultMode(): void;
6
- dismiss(keepFocus: boolean): void;
8
+ preload(): void;
9
+ dismiss(keepFocus: boolean, animated: boolean): void;
7
10
  setFocusTo(direction: string): void;
11
+ viewPositionInWindow(viewTag: number): Promise<object>;
8
12
  addListener: (eventName: string) => void;
9
13
  removeListeners: (count: number) => void;
10
14
  }
@@ -1,5 +1,48 @@
1
1
  import type { PropsWithChildren } from "react";
2
2
  import type { EmitterSubscription, NativeSyntheticEvent, TextInputProps, ViewProps } from "react-native";
3
+ export type KeyboardProviderProps = {
4
+ children: React.ReactNode;
5
+ /**
6
+ * Set the value to `true`, if you use translucent status bar on Android.
7
+ * If you already control status bar translucency via `react-native-screens`
8
+ * or `StatusBar` component from `react-native`, you can ignore it.
9
+ * Defaults to `false`.
10
+ *
11
+ * @platform android
12
+ * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14
13
+ */
14
+ statusBarTranslucent?: boolean;
15
+ /**
16
+ * Set the value to `true`, if you use translucent navigation bar on Android.
17
+ * Defaults to `false`.
18
+ *
19
+ * @platform android
20
+ * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119
21
+ */
22
+ navigationBarTranslucent?: boolean;
23
+ /**
24
+ * A boolean property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).
25
+ * Defaults to `false`.
26
+ *
27
+ * @platform android
28
+ * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592
29
+ */
30
+ preserveEdgeToEdge?: boolean;
31
+ /**
32
+ * A boolean prop indicating whether the module is enabled. It indicate only initial state
33
+ * (if you try to change this prop after component mount it will not have any effect).
34
+ * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.
35
+ * Defaults to `true`.
36
+ */
37
+ enabled?: boolean;
38
+ /**
39
+ * A boolean prop indicating whether to preload the keyboard to reduce time-to-interaction (TTI) on first input focus.
40
+ * Defaults to `true`.
41
+ *
42
+ * @platform ios
43
+ */
44
+ preload?: boolean;
45
+ };
3
46
  export type NativeEvent = {
4
47
  progress: number;
5
48
  height: number;
@@ -81,25 +124,54 @@ export type KeyboardGestureAreaProps = {
81
124
  export type OverKeyboardViewProps = PropsWithChildren<{
82
125
  visible: boolean;
83
126
  }>;
127
+ export type ClippingScrollViewProps = PropsWithChildren<ViewProps & {
128
+ /** An additional space that gets applied to the bottom of the ScrollView content. Default is 0. */
129
+ contentInsetBottom?: number;
130
+ /** An additional space that gets applied to the top of the ScrollView content. Default is 0. */
131
+ contentInsetTop?: number;
132
+ applyWorkaroundForContentInsetHitTestBug?: boolean;
133
+ }>;
134
+ export type KeyboardBackgroundViewProps = PropsWithChildren<ViewProps>;
135
+ export type KeyboardToolbarGroupViewProps = PropsWithChildren<ViewProps>;
136
+ export type KeyboardExtenderProps = PropsWithChildren<{
137
+ /** Controls whether this `KeyboardExtender` instance should take effect. Default is `true`. */
138
+ enabled?: boolean;
139
+ }>;
84
140
  export type Direction = "next" | "prev" | "current";
85
141
  export type DismissOptions = {
86
142
  keepFocus: boolean;
143
+ animated: boolean;
87
144
  };
88
145
  export type KeyboardControllerModule = {
89
146
  setDefaultMode: () => void;
90
147
  setInputMode: (mode: number) => void;
91
- dismiss: (options?: DismissOptions) => Promise<void>;
148
+ preload: () => void;
149
+ dismiss: (options?: Partial<DismissOptions>) => Promise<void>;
92
150
  setFocusTo: (direction: Direction) => void;
93
151
  isVisible: () => boolean;
94
- state: () => KeyboardEventData | null;
152
+ state: () => KeyboardEventData;
95
153
  addListener: (eventName: string) => void;
96
154
  removeListeners: (count: number) => void;
155
+ getConstants: () => {
156
+ keyboardBorderRadius: number;
157
+ };
158
+ };
159
+ export type ViewPositionInWindowResult = {
160
+ x: number;
161
+ y: number;
162
+ width: number;
163
+ height: number;
97
164
  };
98
165
  export type KeyboardControllerNativeModule = {
99
166
  setDefaultMode: () => void;
100
167
  setInputMode: (mode: number) => void;
101
- dismiss: (keepFocus: boolean) => void;
168
+ preload: () => void;
169
+ dismiss: (keepFocus: boolean, animated: boolean) => void;
102
170
  setFocusTo: (direction: Direction) => void;
171
+ viewPositionInWindow: (viewTag: number) => Promise<ViewPositionInWindowResult>;
172
+ getConstants: () => {
173
+ keyboardBorderRadius: number;
174
+ };
103
175
  addListener: (eventName: string) => void;
104
176
  removeListeners: (count: number) => void;
105
177
  };
@@ -111,12 +183,15 @@ export type KeyboardEventData = {
111
183
  timestamp: number;
112
184
  target: number;
113
185
  type: NonNullable<TextInputProps["keyboardType"]>;
114
- appearance: NonNullable<TextInputProps["keyboardAppearance"]>;
186
+ appearance: "dark" | "light";
115
187
  };
188
+ export type IKeyboardState = {
189
+ isVisible: boolean;
190
+ } & KeyboardEventData;
116
191
  export type KeyboardEventsModule = {
117
192
  addListener: (name: KeyboardControllerEvents, cb: (e: KeyboardEventData) => void) => EmitterSubscription;
118
193
  };
119
- export type FocusedInputAvailableEvents = "focusDidSet";
194
+ export type FocusedInputAvailableEvents = "focusDidSet" | "layoutDidSynchronize";
120
195
  export type FocusedInputEventData = {
121
196
  current: number;
122
197
  count: number;
@@ -0,0 +1,4 @@
1
+ import type { findNodeHandle as findNodeHandleRN } from "react-native";
2
+ type FindNodeHandleRN = typeof findNodeHandleRN;
3
+ export declare const findNodeHandle: FindNodeHandleRN;
4
+ export {};
@@ -0,0 +1,2 @@
1
+ import { findNodeHandle } from "react-native";
2
+ export { findNodeHandle };
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import type { KeyboardExtenderProps } from "../../types";
3
+ import type { PropsWithChildren } from "react";
4
+ declare const KeyboardExtender: ({ children, enabled, }: PropsWithChildren<KeyboardExtenderProps>) => React.JSX.Element;
5
+ export default KeyboardExtender;
@@ -1 +1,2 @@
1
1
  export { default as OverKeyboardView } from "./OverKeyboardView";
2
+ export { default as KeyboardExtender } from "./KeyboardExtender";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ohos/react-native-keyboard-controller",
3
- "version": "1.16.8",
3
+ "version": "1.17.0",
4
4
  "description": "Keyboard manager which works in identical way on iOS and Android and harmony",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -17,7 +17,6 @@
17
17
  "react-native-keyboard-controller.podspec",
18
18
  "jest",
19
19
  "!lib/typescript/example",
20
- "!harmony/keyboard_controller/build",
21
20
  "!android/build",
22
21
  "!android/.gradle",
23
22
  "!android/gradle",
@@ -27,7 +26,8 @@
27
26
  "!ios/KeyboardControllerNative",
28
27
  "!**/__tests__",
29
28
  "!**/__fixtures__",
30
- "!**/__mocks__"
29
+ "!**/__mocks__",
30
+ "!build"
31
31
  ],
32
32
  "scripts": {
33
33
  "format": "prettier '**/*' --ignore-unknown --write",
@@ -72,14 +72,14 @@
72
72
  "bugs": {
73
73
  "url": "https://gitcode.com/CPF-RN/rntpc_react-native-keyboard-controller/issues"
74
74
  },
75
- "homepage": "https://gitcode.com/CPF-RN/rntpc_react-native-keyboard-controller/tree/br_rnoh0.77#readme",
75
+ "homepage": "https://gitcode.com/CPF-RN/rntpc_react-native-keyboard-controller/tree/br_rnoh0.82#readme",
76
76
  "publishConfig": {
77
77
  "registry": "https://registry.npmjs.org/"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@commitlint/config-conventional": "^11.0.0",
81
- "@react-native/babel-preset": "0.77.0",
82
- "@react-native/eslint-config": "0.77.0",
81
+ "@react-native/babel-preset": "0.82.0",
82
+ "@react-native/eslint-config": "0.82.0",
83
83
  "@release-it/conventional-changelog": "^2.0.0",
84
84
  "@testing-library/react-hooks": "^8.0.1",
85
85
  "@types/jest": "^29.5.13",
@@ -103,7 +103,7 @@
103
103
  "pod-install": "^0.1.0",
104
104
  "prettier": "^2.8.8",
105
105
  "react": "18.3.1",
106
- "react-native": "0.77.1",
106
+ "react-native": "0.82.1",
107
107
  "react-native-builder-bob": "^0.18.0",
108
108
  "react-native-reanimated": "3.18.0",
109
109
  "react-test-renderer": "18.2.0",
@@ -114,7 +114,7 @@
114
114
  "react": "*",
115
115
  "react-native": "*",
116
116
  "react-native-reanimated": ">=3.0.0",
117
- "react-native-keyboard-controller": "1.16.5"
117
+ "react-native-keyboard-controller": "1.21.8"
118
118
  },
119
119
  "jest": {
120
120
  "preset": "react-native",
@@ -172,6 +172,12 @@
172
172
  }
173
173
  },
174
174
  "harmony": {
175
- "alias": "react-native-keyboard-controller"
175
+ "alias": "react-native-keyboard-controller",
176
+ "autolinking": {
177
+ "etsPackageClassName": "RNKeyboardControllerPackage",
178
+ "cppPackageClassName": "RNKeyboardControllerPackage",
179
+ "cmakeLibraryTargetName": "rnoh_keyboard_controller",
180
+ "ohPackageName": "@react-native-ohos/react-native-keyboard-controller"
181
+ }
176
182
  }
177
183
  }
package/src/animated.tsx CHANGED
@@ -1,11 +1,21 @@
1
- import React, { useEffect, useMemo, useState } from "react";
1
+ import React, {
2
+ useCallback,
3
+ useEffect,
4
+ useMemo,
5
+ useRef,
6
+ useState,
7
+ } from "react";
2
8
  import { Animated, Platform, StyleSheet } from "react-native";
3
9
  import Reanimated, { useSharedValue } from "react-native-reanimated";
4
10
 
5
- import { KeyboardControllerView } from "./bindings";
11
+ import {
12
+ FocusedInputEvents,
13
+ KeyboardControllerView,
14
+ KeyboardControllerViewCommands,
15
+ } from "./bindings";
6
16
  import { KeyboardContext } from "./context";
7
17
  import { useAnimatedValue, useSharedHandlers } from "./internal";
8
- import { applyMonkeyPatch, revertMonkeyPatch } from "./monkey-patch";
18
+ import { KeyboardController } from "./module";
9
19
  import {
10
20
  useAnimatedKeyboardHandler,
11
21
  useFocusedInputLayoutHandler,
@@ -19,6 +29,7 @@ import type {
19
29
  FocusedInputLayoutChangedEvent,
20
30
  KeyboardControllerProps,
21
31
  KeyboardHandler,
32
+ KeyboardProviderProps,
22
33
  NativeEvent,
23
34
  } from "./types";
24
35
  import type { ViewStyle } from "react-native";
@@ -27,7 +38,10 @@ const KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(
27
38
  Animated.createAnimatedComponent(
28
39
  KeyboardControllerView,
29
40
  ) as React.FC<KeyboardControllerProps>,
30
- );
41
+ ) as React.ComponentType<
42
+ KeyboardControllerProps &
43
+ React.RefAttributes<React.Component<KeyboardControllerProps>>
44
+ >;
31
45
 
32
46
  type Styles = {
33
47
  container: ViewStyle;
@@ -44,43 +58,6 @@ const styles = StyleSheet.create<Styles>({
44
58
  },
45
59
  });
46
60
 
47
- type KeyboardProviderProps = {
48
- children: React.ReactNode;
49
- /**
50
- * Set the value to `true`, if you use translucent status bar on Android.
51
- * If you already control status bar translucency via `react-native-screens`
52
- * or `StatusBar` component from `react-native`, you can ignore it.
53
- * Defaults to `false`.
54
- *
55
- * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14
56
- * @platform android
57
- */
58
- statusBarTranslucent?: boolean;
59
- /**
60
- * Set the value to `true`, if you use translucent navigation bar on Android.
61
- * Defaults to `false`.
62
- *
63
- * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119
64
- * @platform android
65
- */
66
- navigationBarTranslucent?: boolean;
67
- /**
68
- * A boolean property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).
69
- * Defaults to `false`.
70
- *
71
- * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592
72
- * @platform android
73
- */
74
- preserveEdgeToEdge?: boolean;
75
- /**
76
- * A boolean prop indicating whether the module is enabled. It indicate only initial state,
77
- * i. e. if you try to change this prop after component mount it will not have any effect.
78
- * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.
79
- * Defaults to `true`.
80
- */
81
- enabled?: boolean;
82
- };
83
-
84
61
  // capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package
85
62
  // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details
86
63
  const OS = Platform.OS;
@@ -91,7 +68,9 @@ export const KeyboardProvider = ({
91
68
  navigationBarTranslucent,
92
69
  preserveEdgeToEdge,
93
70
  enabled: initiallyEnabled = true,
71
+ preload = true,
94
72
  }: KeyboardProviderProps) => {
73
+ const viewRef = useRef<React.Component<KeyboardControllerProps>>(null);
95
74
  // state
96
75
  const [enabled, setEnabled] = useState(initiallyEnabled);
97
76
  // animated values
@@ -105,6 +84,21 @@ export const KeyboardProvider = ({
105
84
  useSharedHandlers<KeyboardHandler>();
106
85
  const [setInputHandlers, broadcastInputEvents] =
107
86
  useSharedHandlers<FocusedInputHandler>();
87
+ const update = useCallback(async () => {
88
+ KeyboardControllerViewCommands.synchronizeFocusedInputLayout(
89
+ viewRef.current,
90
+ );
91
+
92
+ await new Promise((resolve) => {
93
+ const subscription = FocusedInputEvents.addListener(
94
+ "layoutDidSynchronize",
95
+ () => {
96
+ subscription.remove();
97
+ resolve(null);
98
+ },
99
+ );
100
+ });
101
+ }, []);
108
102
  // memo
109
103
  const context = useMemo<KeyboardAnimationContext>(
110
104
  () => ({
@@ -112,11 +106,12 @@ export const KeyboardProvider = ({
112
106
  animated: { progress: progress, height: Animated.multiply(height,-1) },
113
107
  reanimated: { progress: progressSV, height: heightSV },
114
108
  layout,
109
+ update,
115
110
  setKeyboardHandlers,
116
111
  setInputHandlers,
117
112
  setEnabled,
118
113
  }),
119
- [enabled],
114
+ [enabled, update],
120
115
  );
121
116
  const style = useMemo(
122
117
  () => [
@@ -211,18 +206,16 @@ export const KeyboardProvider = ({
211
206
  },
212
207
  [],
213
208
  );
214
- // effects
215
209
  useEffect(() => {
216
- if (enabled) {
217
- applyMonkeyPatch();
218
- } else {
219
- revertMonkeyPatch();
210
+ if (preload) {
211
+ KeyboardController.preload();
220
212
  }
221
- }, [enabled]);
213
+ }, [preload]);
222
214
 
223
215
  return (
224
216
  <KeyboardContext.Provider value={context}>
225
217
  <KeyboardControllerViewAnimated
218
+ ref={viewRef}
226
219
  enabled={enabled}
227
220
  onKeyboardMoveReanimated={keyboardHandler}
228
221
  onKeyboardMoveStart={OS === "ios" ? onKeyboardMove : undefined}
@@ -0,0 +1 @@
1
+ export const IS_FABRIC = "nativeFabricUIManager" in global;
@@ -1,14 +1,25 @@
1
- import { NativeEventEmitter, Platform } from "react-native";
1
+ import React from "react";
2
+ import {
3
+ NativeEventEmitter,
4
+ Platform,
5
+ useColorScheme,
6
+ View,
7
+ } from "react-native";
2
8
 
3
9
  import type {
10
+ ClippingScrollViewProps,
4
11
  FocusedInputEventsModule,
12
+ KeyboardBackgroundViewProps,
5
13
  KeyboardControllerNativeModule,
6
14
  KeyboardControllerProps,
7
15
  KeyboardEventsModule,
16
+ KeyboardExtenderProps,
8
17
  KeyboardGestureAreaProps,
18
+ KeyboardToolbarGroupViewProps,
9
19
  OverKeyboardViewProps,
10
20
  WindowDimensionsEventsModule,
11
21
  } from "./types";
22
+ import type { View as RNView } from "react-native";
12
23
 
13
24
  const LINKING_ERROR =
14
25
  `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` +
@@ -16,6 +27,7 @@ const LINKING_ERROR =
16
27
  "- You rebuilt the app after installing the package\n" +
17
28
  "- You are not using Expo Go\n";
18
29
 
30
+ const KeyboardControllerViewNativeComponentModule = require("./specs/KeyboardControllerViewNativeComponent");
19
31
  const RCTKeyboardController =
20
32
  require("./specs/NativeKeyboardController").default;
21
33
 
@@ -53,10 +65,33 @@ export const WindowDimensionsEvents: WindowDimensionsEventsModule = {
53
65
  eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),
54
66
  };
55
67
  export const KeyboardControllerView: React.FC<KeyboardControllerProps> =
56
- require("./specs/KeyboardControllerViewNativeComponent").default;
68
+ KeyboardControllerViewNativeComponentModule.default;
69
+ export const KeyboardControllerViewCommands =
70
+ KeyboardControllerViewNativeComponentModule.Commands;
57
71
  export const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =
58
72
  (Platform.OS === "android" && Platform.Version >= 30) || Platform.OS === "ios"
59
73
  ? require("./specs/KeyboardGestureAreaNativeComponent").default
60
74
  : ({ children }: KeyboardGestureAreaProps) => children;
61
75
  export const RCTOverKeyboardView: React.FC<OverKeyboardViewProps> =
62
76
  require("./specs/OverKeyboardViewNativeComponent").default;
77
+ export const ClippingScrollView: React.FC<ClippingScrollViewProps> =
78
+ Platform.OS === "android" || (Platform.OS as string) === "harmony"
79
+ ? require("./specs/ClippingScrollViewDecoratorViewNativeComponent").default
80
+ : ({ children }: ClippingScrollViewProps) => children;
81
+ export const KeyboardBackgroundView = React.forwardRef<
82
+ RNView,
83
+ KeyboardBackgroundViewProps
84
+ >(({ style, ...props }, ref) => {
85
+ const colorScheme = useColorScheme();
86
+ const backgroundColor = colorScheme === "dark" ? "#2c2c2e" : "#eceff3";
87
+
88
+ return React.createElement(View, {
89
+ ref,
90
+ style: [{ backgroundColor }, style],
91
+ ...props,
92
+ });
93
+ });
94
+ export const RCTKeyboardExtender =
95
+ View as unknown as React.FC<KeyboardExtenderProps>;
96
+ export const RCTKeyboardToolbarGroupView: React.FC<KeyboardToolbarGroupViewProps> =
97
+ require("./specs/KeyboardToolbarGroupViewNativeComponent").default;
package/src/bindings.ts CHANGED
@@ -1,25 +1,37 @@
1
- import { View } from "react-native";
1
+ import React from "react";
2
+ import { useColorScheme, View } from "react-native";
2
3
 
3
4
  import type {
5
+ ClippingScrollViewProps,
4
6
  FocusedInputEventsModule,
7
+ KeyboardBackgroundViewProps,
5
8
  KeyboardControllerNativeModule,
6
9
  KeyboardControllerProps,
7
10
  KeyboardEventsModule,
11
+ KeyboardExtenderProps,
8
12
  KeyboardGestureAreaProps,
13
+ KeyboardToolbarGroupViewProps,
9
14
  OverKeyboardViewProps,
10
15
  WindowDimensionsEventsModule,
11
16
  } from "./types";
12
17
  import type { EmitterSubscription } from "react-native";
18
+ import type { View as RNView } from "react-native";
13
19
 
14
20
  const NOOP = () => {};
15
21
 
16
22
  export const KeyboardControllerNative: KeyboardControllerNativeModule = {
17
23
  setDefaultMode: NOOP,
18
24
  setInputMode: NOOP,
25
+ preload: NOOP,
19
26
  dismiss: NOOP,
20
27
  setFocusTo: NOOP,
28
+ viewPositionInWindow: () =>
29
+ Promise.resolve({ x: 0, y: 0, width: 0, height: 0 }),
21
30
  addListener: NOOP,
22
31
  removeListeners: NOOP,
32
+ getConstants: () => ({
33
+ keyboardBorderRadius: 0,
34
+ }),
23
35
  };
24
36
  export const KeyboardEvents: KeyboardEventsModule = {
25
37
  addListener: () => ({ remove: NOOP } as EmitterSubscription),
@@ -36,7 +48,34 @@ export const WindowDimensionsEvents: WindowDimensionsEventsModule = {
36
48
  };
37
49
  export const KeyboardControllerView =
38
50
  View as unknown as React.FC<KeyboardControllerProps>;
51
+ export const KeyboardControllerViewCommands = {
52
+ synchronizeFocusedInputLayout: (
53
+ _ref: React.Component<KeyboardControllerProps> | null,
54
+ ) => {},
55
+ };
39
56
  export const KeyboardGestureArea =
40
57
  View as unknown as React.FC<KeyboardGestureAreaProps>;
41
58
  export const RCTOverKeyboardView =
42
59
  View as unknown as React.FC<OverKeyboardViewProps>;
60
+ export const ClippingScrollView =
61
+ View as unknown as React.FC<ClippingScrollViewProps>;
62
+ export const KeyboardBackgroundView = React.forwardRef<
63
+ RNView,
64
+ KeyboardBackgroundViewProps
65
+ >(({ style, ...props }, ref) => {
66
+ const colorScheme = useColorScheme();
67
+ const backgroundColor = colorScheme === "dark" ? "#2c2c2e" : "#eceff3";
68
+
69
+ return React.createElement(View, {
70
+ ref,
71
+ style: [{ backgroundColor }, style],
72
+ ...props,
73
+ });
74
+ });
75
+ export const RCTKeyboardExtender =
76
+ View as unknown as React.FC<KeyboardExtenderProps>;
77
+ /**
78
+ * A View that defines a group of `TextInput`s for toolbar navigation.
79
+ */
80
+ export const RCTKeyboardToolbarGroupView =
81
+ View as unknown as React.FC<KeyboardToolbarGroupViewProps>;
package/src/compat.ts ADDED
@@ -0,0 +1,44 @@
1
+ import { useSharedValue } from "react-native-reanimated";
2
+
3
+ import { useKeyboardHandler } from "./hooks";
4
+
5
+ export const KeyboardState = {
6
+ UNKNOWN: 0,
7
+ OPENING: 1,
8
+ OPEN: 2,
9
+ CLOSING: 3,
10
+ CLOSED: 4,
11
+ };
12
+
13
+ /** Compatibility layer for migrating from Reanimated's useAnimatedKeyboard. */
14
+ export const useAnimatedKeyboard = () => {
15
+ const height = useSharedValue(0);
16
+ const state = useSharedValue(KeyboardState.UNKNOWN);
17
+
18
+ useKeyboardHandler(
19
+ {
20
+ onStart: (event) => {
21
+ "worklet";
22
+ state.value =
23
+ event.height > 0 ? KeyboardState.OPENING : KeyboardState.CLOSING;
24
+ },
25
+ onMove: (event) => {
26
+ "worklet";
27
+ height.value = event.height;
28
+ },
29
+ onInteractive: (event) => {
30
+ "worklet";
31
+ height.value = event.height;
32
+ },
33
+ onEnd: (event) => {
34
+ "worklet";
35
+ state.value =
36
+ event.height > 0 ? KeyboardState.OPEN : KeyboardState.CLOSED;
37
+ height.value = event.height;
38
+ },
39
+ },
40
+ [],
41
+ );
42
+
43
+ return { height, state };
44
+ };
@@ -2,21 +2,28 @@ import { useSharedValue } from "react-native-reanimated";
2
2
 
3
3
  import {useKeyboardHandler} from "../../hooks";
4
4
  import {useKeyboardContext} from "../../context";
5
- import { useState } from "react";
5
+ import { useLayoutEffect } from "react";
6
6
  import { Platform } from "react-native";
7
7
 
8
8
  const OS = Platform.OS;
9
9
 
10
10
  export const useKeyboardAnimation = () => {
11
11
  const { reanimated } = useKeyboardContext();
12
- // calculate it only once on mount, to avoid `SharedValue` reads during a render
13
- const [initialHeight] = useState(() => -reanimated.height.value);
14
- const [initialProgress] = useState(() => reanimated.progress.value);
15
-
16
- const heightWhenOpened = useSharedValue(initialHeight);
17
- const height = useSharedValue(initialHeight);
18
- const progress = useSharedValue(initialProgress);
19
- const isClosed = useSharedValue(initialProgress === 0);
12
+ const heightWhenOpened = useSharedValue(0);
13
+ const height = useSharedValue(0);
14
+ const progress = useSharedValue(0);
15
+ const isClosed = useSharedValue(true);
16
+
17
+ useLayoutEffect(() => {
18
+ const initialHeight = -reanimated.height.value;
19
+ const initialProgress = reanimated.progress.value;
20
+
21
+ // eslint-disable-next-line react-compiler/react-compiler
22
+ heightWhenOpened.value = initialHeight;
23
+ height.value = initialHeight;
24
+ progress.value = initialProgress;
25
+ isClosed.value = initialProgress === 0;
26
+ }, []);
20
27
 
21
28
  useKeyboardHandler(
22
29
  {
@@ -24,7 +31,6 @@ export const useKeyboardAnimation = () => {
24
31
  "worklet";
25
32
 
26
33
  if (e.height > 0) {
27
- // eslint-disable-next-line react-compiler/react-compiler
28
34
  isClosed.value = false;
29
35
  heightWhenOpened.value = e.height;
30
36
  }
@@ -73,19 +79,20 @@ export const useKeyboardAnimation = () => {
73
79
  export const useTranslateAnimation = () => {
74
80
  const { reanimated } = useKeyboardContext();
75
81
 
76
- // calculate it only once on mount, to avoid `SharedValue` reads during a render
77
- const [initialProgress] = useState(() => reanimated.progress.value);
78
-
79
- const padding = useSharedValue(initialProgress);
82
+ const padding = useSharedValue(0);
80
83
  const translate = useSharedValue(0);
81
84
 
85
+ useLayoutEffect(() => {
86
+ // eslint-disable-next-line react-compiler/react-compiler
87
+ padding.value = reanimated.progress.value;
88
+ }, []);
89
+
82
90
  useKeyboardHandler(
83
91
  {
84
92
  onStart: (e) => {
85
93
  "worklet";
86
94
 
87
95
  if (e.height === 0) {
88
- // eslint-disable-next-line react-compiler/react-compiler
89
96
  padding.value = 0;
90
97
  }
91
98
  if (OS === "ios") {
@@ -95,7 +102,7 @@ export const useTranslateAnimation = () => {
95
102
  onMove: (e) => {
96
103
  "worklet";
97
104
 
98
- if (OS === "android") {
105
+ if (OS !== "ios") {
99
106
  translate.value = e.progress;
100
107
  }
101
108
  },
@@ -111,7 +118,7 @@ export const useTranslateAnimation = () => {
111
118
 
112
119
  padding.value = e.progress;
113
120
 
114
- if (OS === "android") {
121
+ if (OS !== "ios") {
115
122
  translate.value = e.progress;
116
123
  }
117
124
  },