@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,12 +1,23 @@
1
- import { View } from "react-native";
1
+ import React from "react";
2
+ import { useColorScheme, View } from "react-native";
2
3
  const NOOP = () => {};
3
4
  export const KeyboardControllerNative = {
4
5
  setDefaultMode: NOOP,
5
6
  setInputMode: NOOP,
7
+ preload: NOOP,
6
8
  dismiss: NOOP,
7
9
  setFocusTo: NOOP,
10
+ viewPositionInWindow: () => Promise.resolve({
11
+ x: 0,
12
+ y: 0,
13
+ width: 0,
14
+ height: 0
15
+ }),
8
16
  addListener: NOOP,
9
- removeListeners: NOOP
17
+ removeListeners: NOOP,
18
+ getConstants: () => ({
19
+ keyboardBorderRadius: 0
20
+ })
10
21
  };
11
22
  export const KeyboardEvents = {
12
23
  addListener: () => ({
@@ -28,6 +39,29 @@ export const WindowDimensionsEvents = {
28
39
  })
29
40
  };
30
41
  export const KeyboardControllerView = View;
42
+ export const KeyboardControllerViewCommands = {
43
+ synchronizeFocusedInputLayout: _ref => {}
44
+ };
31
45
  export const KeyboardGestureArea = View;
32
46
  export const RCTOverKeyboardView = View;
47
+ export const ClippingScrollView = View;
48
+ export const KeyboardBackgroundView = /*#__PURE__*/React.forwardRef(({
49
+ style,
50
+ ...props
51
+ }, ref) => {
52
+ const colorScheme = useColorScheme();
53
+ const backgroundColor = colorScheme === "dark" ? "#2c2c2e" : "#eceff3";
54
+ return /*#__PURE__*/React.createElement(View, {
55
+ ref,
56
+ style: [{
57
+ backgroundColor
58
+ }, style],
59
+ ...props
60
+ });
61
+ });
62
+ export const RCTKeyboardExtender = View;
63
+ /**
64
+ * A View that defines a group of `TextInput`s for toolbar navigation.
65
+ */
66
+ export const RCTKeyboardToolbarGroupView = View;
33
67
  //# sourceMappingURL=bindings.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["View","NOOP","KeyboardControllerNative","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","RCTOverKeyboardView"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\nimport type { EmitterSubscription } from \"react-native\";\n\nconst NOOP = () => {};\n\nexport const KeyboardControllerNative: KeyboardControllerNativeModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n dismiss: NOOP,\n setFocusTo: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\nexport const RCTOverKeyboardView =\n View as unknown as React.FC<OverKeyboardViewProps>;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,cAAc;AAanC,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,OAAO,MAAMC,wBAAwD,GAAG;EACtEC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,OAAO,EAAEJ,IAAI;EACbK,UAAU,EAAEL,IAAI;EAChBM,WAAW,EAAEN,IAAI;EACjBO,eAAe,EAAEP;AACnB,CAAC;AACD,OAAO,MAAMQ,cAAoC,GAAG;EAClDF,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACA,OAAO,MAAMU,kBAA4C,GAAG;EAC1DJ,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMW,sBAAoD,GAAG;EAClEL,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMY,sBAAsB,GACjCb,IAAoD;AACtD,OAAO,MAAMc,mBAAmB,GAC9Bd,IAAqD;AACvD,OAAO,MAAMe,mBAAmB,GAC9Bf,IAAkD","ignoreList":[]}
1
+ {"version":3,"names":["React","useColorScheme","View","NOOP","KeyboardControllerNative","setDefaultMode","setInputMode","preload","dismiss","setFocusTo","viewPositionInWindow","Promise","resolve","x","y","width","height","addListener","removeListeners","getConstants","keyboardBorderRadius","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardControllerViewCommands","synchronizeFocusedInputLayout","_ref","KeyboardGestureArea","RCTOverKeyboardView","ClippingScrollView","KeyboardBackgroundView","forwardRef","style","props","ref","colorScheme","backgroundColor","createElement","RCTKeyboardExtender","RCTKeyboardToolbarGroupView"],"sources":["bindings.ts"],"sourcesContent":["import React from \"react\";\nimport { useColorScheme, View } from \"react-native\";\n\nimport type {\n ClippingScrollViewProps,\n FocusedInputEventsModule,\n KeyboardBackgroundViewProps,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardExtenderProps,\n KeyboardGestureAreaProps,\n KeyboardToolbarGroupViewProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\nimport type { EmitterSubscription } from \"react-native\";\nimport type { View as RNView } from \"react-native\";\n\nconst NOOP = () => {};\n\nexport const KeyboardControllerNative: KeyboardControllerNativeModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n preload: NOOP,\n dismiss: NOOP,\n setFocusTo: NOOP,\n viewPositionInWindow: () =>\n Promise.resolve({ x: 0, y: 0, width: 0, height: 0 }),\n addListener: NOOP,\n removeListeners: NOOP,\n getConstants: () => ({\n keyboardBorderRadius: 0,\n }),\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardControllerViewCommands = {\n synchronizeFocusedInputLayout: (\n _ref: React.Component<KeyboardControllerProps> | null,\n ) => {},\n};\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\nexport const RCTOverKeyboardView =\n View as unknown as React.FC<OverKeyboardViewProps>;\nexport const ClippingScrollView =\n View as unknown as React.FC<ClippingScrollViewProps>;\nexport const KeyboardBackgroundView = React.forwardRef<\n RNView,\n KeyboardBackgroundViewProps\n>(({ style, ...props }, ref) => {\n const colorScheme = useColorScheme();\n const backgroundColor = colorScheme === \"dark\" ? \"#2c2c2e\" : \"#eceff3\";\n\n return React.createElement(View, {\n ref,\n style: [{ backgroundColor }, style],\n ...props,\n });\n});\nexport const RCTKeyboardExtender =\n View as unknown as React.FC<KeyboardExtenderProps>;\n/**\n * A View that defines a group of `TextInput`s for toolbar navigation.\n */\nexport const RCTKeyboardToolbarGroupView =\n View as unknown as React.FC<KeyboardToolbarGroupViewProps>;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,EAAEC,IAAI,QAAQ,cAAc;AAkBnD,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,OAAO,MAAMC,wBAAwD,GAAG;EACtEC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,OAAO,EAAEJ,IAAI;EACbK,OAAO,EAAEL,IAAI;EACbM,UAA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IAAI,EAAE;IAC/BkC,GAAG;IACHF,KAAK,EAAE,CAAC;MAAEI;IAAgB,CAAC,EAAEJ,KAAK,CAAC;IACnC,GAAGC;EACL,CAAC,CAAC;AACJ,CAAC,CAAC;AACF,OAAO,MAAMK,mBAAmB,GAC9BtC,IAAkD;AACpD;AACA;AACA;AACA,OAAO,MAAMuC,2BAA2B,GACtCvC,IAA0D","ignoreList":[]}
@@ -1,8 +1,10 @@
1
- import { NativeEventEmitter, Platform } from "react-native";
1
+ import React from "react";
2
+ import { NativeEventEmitter, Platform, useColorScheme, View } from "react-native";
2
3
  const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
3
4
  ios: "- You have run 'pod install'\n",
4
5
  default: ""
5
6
  }) + "- You rebuilt the app after installing the package\n" + "- You are not using Expo Go\n";
7
+ const KeyboardControllerViewNativeComponentModule = require("./specs/KeyboardControllerViewNativeComponent");
6
8
  const RCTKeyboardController = require("./specs/NativeKeyboardController").default;
7
9
  export const KeyboardControllerNative = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
8
10
  get() {
@@ -25,9 +27,29 @@ export const FocusedInputEvents = {
25
27
  export const WindowDimensionsEvents = {
26
28
  addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
27
29
  };
28
- export const KeyboardControllerView = require("./specs/KeyboardControllerViewNativeComponent").default;
30
+ export const KeyboardControllerView = KeyboardControllerViewNativeComponentModule.default;
31
+ export const KeyboardControllerViewCommands = KeyboardControllerViewNativeComponentModule.Commands;
29
32
  export const KeyboardGestureArea = Platform.OS === "android" && Platform.Version >= 30 || Platform.OS === "ios" ? require("./specs/KeyboardGestureAreaNativeComponent").default : ({
30
33
  children
31
34
  }) => children;
32
35
  export const RCTOverKeyboardView = require("./specs/OverKeyboardViewNativeComponent").default;
36
+ export const ClippingScrollView = Platform.OS === "android" || Platform.OS === "harmony" ? require("./specs/ClippingScrollViewDecoratorViewNativeComponent").default : ({
37
+ children
38
+ }) => children;
39
+ export const KeyboardBackgroundView = /*#__PURE__*/React.forwardRef(({
40
+ style,
41
+ ...props
42
+ }, ref) => {
43
+ const colorScheme = useColorScheme();
44
+ const backgroundColor = colorScheme === "dark" ? "#2c2c2e" : "#eceff3";
45
+ return /*#__PURE__*/React.createElement(View, {
46
+ ref,
47
+ style: [{
48
+ backgroundColor
49
+ }, style],
50
+ ...props
51
+ });
52
+ });
53
+ export const RCTKeyboardExtender = View;
54
+ export const RCTKeyboardToolbarGroupView = require("./specs/KeyboardToolbarGroupViewNativeComponent").default;
33
55
  //# sourceMappingURL=bindings.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","RCTKeyboardController","require","KeyboardControllerNative","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","KeyboardEvents","addListener","name","cb","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","OS","Version","children","RCTOverKeyboardView"],"sources":["bindings.native.ts"],"sourcesContent":["import { NativeEventEmitter, Platform } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\n\nconst LINKING_ERROR =\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: \"\" }) +\n \"- You rebuilt the app after installing the package\\n\" +\n \"- You are not using Expo Go\\n\";\n\nconst RCTKeyboardController =\n require(\"./specs/NativeKeyboardController\").default;\n\nexport const KeyboardControllerNative = (\n RCTKeyboardController\n ? RCTKeyboardController\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n },\n )\n) as KeyboardControllerNativeModule;\n\nconst KEYBOARD_CONTROLLER_NAMESPACE = \"KeyboardController::\";\nconst eventEmitter = new NativeEventEmitter(KeyboardControllerNative);\n\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\n\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\nexport const KeyboardControllerView: React.FC<KeyboardControllerProps> =\n require(\"./specs/KeyboardControllerViewNativeComponent\").default;\nexport const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =\n (Platform.OS === \"android\" && Platform.Version >= 30) || Platform.OS === \"ios\"\n ? require(\"./specs/KeyboardGestureAreaNativeComponent\").default\n : ({ children }: KeyboardGestureAreaProps) => children;\nexport const RCTOverKeyboardView: React.FC<OverKeyboardViewProps> =\n require(\"./specs/OverKeyboardViewNativeComponent\").default;\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAY3D,MAAMC,aAAa,GACjB,2FAA2F,GAC3FD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,qBAAqB,GACzBC,OAAO,CAAC,kCAAkC,CAAC,CAACF,OAAO;AAErD,OAAO,MAAMG,wBAAwB,GACnCF,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAC6B;AAEnC,MAAMU,6BAA6B,GAAG,sBAAsB;AAC5D,MAAMC,YAAY,GAAG,IAAIb,kBAAkB,CAACQ,wBAAwB,CAAC;AAErE,OAAO,MAAMM,cAAoC,GAAG;EAClDC,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBJ,YAAY,CAACE,WAAW,CAACH,6BAA6B,GAAGI,IAAI,EAAEC,EAAE;AACrE,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAA4C,GAAG;EAC1DH,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBJ,YAAY,CAACE,WAAW,CAACH,6BAA6B,GAAGI,IAAI,EAAEC,EAAE;AACrE,CAAC;AACD,OAAO,MAAME,sBAAoD,GAAG;EAClEJ,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBJ,YAAY,CAACE,WAAW,CAACH,6BAA6B,GAAGI,IAAI,EAAEC,EAAE;AACrE,CAAC;AACD,OAAO,MAAMG,sBAAyD,GACpEb,OAAO,CAAC,+CAA+C,CAAC,CAACF,OAAO;AAClE,OAAO,MAAMgB,mBAAuD,GACjEpB,QAAQ,CAACqB,EAAE,KAAK,SAAS,IAAIrB,QAAQ,CAACsB,OAAO,IAAI,EAAE,IAAKtB,QAAQ,CAACqB,EAAE,KAAK,KAAK,GAC1Ef,OAAO,CAAC,4CAA4C,CAAC,CAACF,OAAO,GAC7D,CAAC;EAAEmB;AAAmC,CAAC,KAAKA,QAAQ;AAC1D,OAAO,MAAMC,mBAAoD,GAC/DlB,OAAO,CAAC,yCAAyC,CAAC,CAACF,OAAO","ignoreList":[]}
1
+ {"version":3,"names":["React","NativeEventEmitter","Platform","useColorScheme","View","LINKING_ERROR","select","ios","default","KeyboardControllerViewNativeComponentModule","require","RCTKeyboardController","KeyboardControllerNative","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","KeyboardEvents","addListener","name","cb","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardControllerViewCommands","Commands","KeyboardGestureArea","OS","Version","children","RCTOverKeyboardView","ClippingScrollView","KeyboardBackgroundView","forwardRef","style","props","ref","colorScheme","backgroundColor","createElement","RCTKeyboardExtender","RCTKeyboardToolbarGroupView"],"sources":["bindings.native.ts"],"sourcesContent":["import React from \"react\";\nimport {\n NativeEventEmitter,\n Platform,\n useColorScheme,\n View,\n} from \"react-native\";\n\nimport type {\n ClippingScrollViewProps,\n FocusedInputEventsModule,\n KeyboardBackgroundViewProps,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardExtenderProps,\n KeyboardGestureAreaProps,\n KeyboardToolbarGroupViewProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\nimport type { View as RNView } from \"react-native\";\n\nconst LINKING_ERROR =\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: \"\" }) +\n \"- You rebuilt the app after installing the package\\n\" +\n \"- You are not using Expo Go\\n\";\n\nconst KeyboardControllerViewNativeComponentModule = require(\"./specs/KeyboardControllerViewNativeComponent\");\nconst RCTKeyboardController =\n require(\"./specs/NativeKeyboardController\").default;\n\nexport const KeyboardControllerNative = (\n RCTKeyboardController\n ? RCTKeyboardController\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n },\n )\n) as KeyboardControllerNativeModule;\n\nconst KEYBOARD_CONTROLLER_NAMESPACE = \"KeyboardController::\";\nconst eventEmitter = new NativeEventEmitter(KeyboardControllerNative);\n\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\n\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\nexport const KeyboardControllerView: React.FC<KeyboardControllerProps> =\n KeyboardControllerViewNativeComponentModule.default;\nexport const KeyboardControllerViewCommands =\n KeyboardControllerViewNativeComponentModule.Commands;\nexport const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =\n (Platform.OS === \"android\" && Platform.Version >= 30) || Platform.OS === \"ios\"\n ? require(\"./specs/KeyboardGestureAreaNativeComponent\").default\n : ({ children }: KeyboardGestureAreaProps) => children;\nexport const RCTOverKeyboardView: React.FC<OverKeyboardViewProps> =\n require(\"./specs/OverKeyboardViewNativeComponent\").default;\nexport const ClippingScrollView: React.FC<ClippingScrollViewProps> =\n Platform.OS === \"android\" || (Platform.OS as string) === \"harmony\"\n ? require(\"./specs/ClippingScrollViewDecoratorViewNativeComponent\").default\n : ({ children }: ClippingScrollViewProps) => children;\nexport const KeyboardBackgroundView = React.forwardRef<\n RNView,\n KeyboardBackgroundViewProps\n>(({ style, ...props }, ref) => {\n const colorScheme = useColorScheme();\n const backgroundColor = colorScheme === \"dark\" ? \"#2c2c2e\" : \"#eceff3\";\n\n return React.createElement(View, {\n ref,\n style: [{ backgroundColor }, style],\n ...props,\n });\n});\nexport const RCTKeyboardExtender =\n View as unknown as React.FC<KeyboardExtenderProps>;\nexport const RCTKeyboardToolbarGroupView: React.FC<KeyboardToolbarGroupViewProps> =\n require(\"./specs/KeyboardToolbarGroupViewNativeComponent\").default;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACEC,kBAAkB,EAClBC,QAAQ,EACRC,cAAc,EACdC,IAAI,QACC,cAAc;AAiBrB,MAAMC,aAAa,GACjB,2FAA2F,GAC3FH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;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,KAAK,KAAK,GAC1ElB,OAAO,CAAC,4CAA4C,CAAC,CAACF,OAAO,GAC7D,CAAC;EAAEsB;AAAmC,CAAC,KAAKA,QAAQ;AAC1D,OAAO,MAAMC,mBAAoD,GAC/DrB,OAAO,CAAC,yCAAyC,CAAC,CAACF,OAAO;AAC5D,OAAO,MAAMwB,kBAAqD,GAChE9B,QAAQ,CAAC0B,EAAE,KAAK,SAAS,IAAK1B,QAAQ,CAAC0B,EAAE,KAAgB,SAAS,GAC9DlB,OAAO,CAAC,wDAAwD,CAAC,CAACF,OAAO,GACzE,CAAC;EAAEsB;AAAkC,CAAC,KAAKA,QAAQ;AACzD,OAAO,MAAMG,sBAAsB,gBAAGjC,KAAK,CAACkC,UAAU,CAGpD,CAAC;EAAEC,KAAK;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EAC9B,MAAMC,WAAW,GAAGnC,cAAc,CAAC,CAAC;EACpC,MAAMoC,eAAe,GAAGD,WAAW,KAAK,MAAM,GAAG,SAAS,GAAG,SAAS;EAEtE,oBAAOtC,KAAK,CAACwC,aAAa,CAACpC,IAAI,EAAE;IAC/BiC,GAAG;IACHF,KAAK,EAAE,CAAC;MAAEI;IAAgB,CAAC,EAAEJ,KAAK,CAAC;IACnC,GAAGC;EACL,CAAC,CAAC;AACJ,CAAC,CAAC;AACF,OAAO,MAAMK,mBAAmB,GAC9BrC,IAAkD;AACpD,OAAO,MAAMsC,2BAAoE,GAC/EhC,OAAO,CAAC,iDAAiD,CAAC,CAACF,OAAO","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ import { useSharedValue } from "react-native-reanimated";
2
+ import { useKeyboardHandler } from "./hooks";
3
+ export const KeyboardState = {
4
+ UNKNOWN: 0,
5
+ OPENING: 1,
6
+ OPEN: 2,
7
+ CLOSING: 3,
8
+ CLOSED: 4
9
+ };
10
+
11
+ /** Compatibility layer for migrating from Reanimated's useAnimatedKeyboard. */
12
+ export const useAnimatedKeyboard = () => {
13
+ const height = useSharedValue(0);
14
+ const state = useSharedValue(KeyboardState.UNKNOWN);
15
+ useKeyboardHandler({
16
+ onStart: event => {
17
+ "worklet";
18
+
19
+ state.value = event.height > 0 ? KeyboardState.OPENING : KeyboardState.CLOSING;
20
+ },
21
+ onMove: event => {
22
+ "worklet";
23
+
24
+ height.value = event.height;
25
+ },
26
+ onInteractive: event => {
27
+ "worklet";
28
+
29
+ height.value = event.height;
30
+ },
31
+ onEnd: event => {
32
+ "worklet";
33
+
34
+ state.value = event.height > 0 ? KeyboardState.OPEN : KeyboardState.CLOSED;
35
+ height.value = event.height;
36
+ }
37
+ }, []);
38
+ return {
39
+ height,
40
+ state
41
+ };
42
+ };
43
+ //# sourceMappingURL=compat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSharedValue","useKeyboardHandler","KeyboardState","UNKNOWN","OPENING","OPEN","CLOSING","CLOSED","useAnimatedKeyboard","height","state","onStart","event","value","onMove","onInteractive","onEnd"],"sources":["compat.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport { useKeyboardHandler } from \"./hooks\";\n\nexport const KeyboardState = {\n UNKNOWN: 0,\n OPENING: 1,\n OPEN: 2,\n CLOSING: 3,\n CLOSED: 4,\n};\n\n/** Compatibility layer for migrating from Reanimated's useAnimatedKeyboard. */\nexport const useAnimatedKeyboard = () => {\n const height = useSharedValue(0);\n const state = useSharedValue(KeyboardState.UNKNOWN);\n\n useKeyboardHandler(\n {\n onStart: (event) => {\n \"worklet\";\n state.value =\n event.height > 0 ? KeyboardState.OPENING : KeyboardState.CLOSING;\n },\n onMove: (event) => {\n \"worklet\";\n height.value = event.height;\n },\n onInteractive: (event) => {\n \"worklet\";\n height.value = event.height;\n },\n onEnd: (event) => {\n \"worklet\";\n state.value =\n event.height > 0 ? KeyboardState.OPEN : KeyboardState.CLOSED;\n height.value = event.height;\n },\n },\n [],\n );\n\n return { height, state };\n};\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,yBAAyB;AAExD,SAASC,kBAAkB,QAAQ,SAAS;AAE5C,OAAO,MAAMC,aAAa,GAAG;EAC3BC,OAAO,EAAE,CAAC;EACVC,OAAO,EAAE,CAAC;EACVC,IAAI,EAAE,CAAC;EACPC,OAAO,EAAE,CAAC;EACVC,MAAM,EAAE;AACV,CAAC;;AAED;AACA,OAAO,MAAMC,mBAAmB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAGT,cAAc,CAAC,CAAC,CAAC;EAChC,MAAMU,KAAK,GAAGV,cAAc,CAACE,aAAa,CAACC,OAAO,CAAC;EAEnDF,kBAAkB,CAChB;IACEU,OAAO,EAAGC,KAAK,IAAK;MAClB,SAAS;;MACTF,KAAK,CAACG,KAAK,GACTD,KAAK,CAACH,MAAM,GAAG,CAAC,GAAGP,aAAa,CAACE,OAAO,GAAGF,aAAa,CAACI,OAAO;IACpE,CAAC;IACDQ,MAAM,EAAGF,KAAK,IAAK;MACjB,SAAS;;MACTH,MAAM,CAACI,KAAK,GAAGD,KAAK,CAACH,MAAM;IAC7B,CAAC;IACDM,aAAa,EAAGH,KAAK,IAAK;MACxB,SAAS;;MACTH,MAAM,CAACI,KAAK,GAAGD,KAAK,CAACH,MAAM;IAC7B,CAAC;IACDO,KAAK,EAAGJ,KAAK,IAAK;MAChB,SAAS;;MACTF,KAAK,CAACG,KAAK,GACTD,KAAK,CAACH,MAAM,GAAG,CAAC,GAAGP,aAAa,CAACG,IAAI,GAAGH,aAAa,CAACK,MAAM;MAC9DE,MAAM,CAACI,KAAK,GAAGD,KAAK,CAACH,MAAM;IAC7B;EACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEA,MAAM;IAAEC;EAAM,CAAC;AAC1B,CAAC","ignoreList":[]}
@@ -1,26 +1,32 @@
1
1
  import { useSharedValue } from "react-native-reanimated";
2
2
  import { useKeyboardHandler } from "../../hooks";
3
3
  import { useKeyboardContext } from "../../context";
4
- import { useState } from "react";
4
+ import { useLayoutEffect } from "react";
5
5
  import { Platform } from "react-native";
6
6
  const OS = Platform.OS;
7
7
  export const useKeyboardAnimation = () => {
8
8
  const {
9
9
  reanimated
10
10
  } = useKeyboardContext();
11
- // calculate it only once on mount, to avoid `SharedValue` reads during a render
12
- const [initialHeight] = useState(() => -reanimated.height.value);
13
- const [initialProgress] = useState(() => reanimated.progress.value);
14
- const heightWhenOpened = useSharedValue(initialHeight);
15
- const height = useSharedValue(initialHeight);
16
- const progress = useSharedValue(initialProgress);
17
- const isClosed = useSharedValue(initialProgress === 0);
11
+ const heightWhenOpened = useSharedValue(0);
12
+ const height = useSharedValue(0);
13
+ const progress = useSharedValue(0);
14
+ const isClosed = useSharedValue(true);
15
+ useLayoutEffect(() => {
16
+ const initialHeight = -reanimated.height.value;
17
+ const initialProgress = reanimated.progress.value;
18
+
19
+ // eslint-disable-next-line react-compiler/react-compiler
20
+ heightWhenOpened.value = initialHeight;
21
+ height.value = initialHeight;
22
+ progress.value = initialProgress;
23
+ isClosed.value = initialProgress === 0;
24
+ }, []);
18
25
  useKeyboardHandler({
19
26
  onStart: e => {
20
27
  "worklet";
21
28
 
22
29
  if (e.height > 0) {
23
- // eslint-disable-next-line react-compiler/react-compiler
24
30
  isClosed.value = false;
25
31
  heightWhenOpened.value = e.height;
26
32
  }
@@ -71,17 +77,17 @@ export const useTranslateAnimation = () => {
71
77
  const {
72
78
  reanimated
73
79
  } = useKeyboardContext();
74
-
75
- // calculate it only once on mount, to avoid `SharedValue` reads during a render
76
- const [initialProgress] = useState(() => reanimated.progress.value);
77
- const padding = useSharedValue(initialProgress);
80
+ const padding = useSharedValue(0);
78
81
  const translate = useSharedValue(0);
82
+ useLayoutEffect(() => {
83
+ // eslint-disable-next-line react-compiler/react-compiler
84
+ padding.value = reanimated.progress.value;
85
+ }, []);
79
86
  useKeyboardHandler({
80
87
  onStart: e => {
81
88
  "worklet";
82
89
 
83
90
  if (e.height === 0) {
84
- // eslint-disable-next-line react-compiler/react-compiler
85
91
  padding.value = 0;
86
92
  }
87
93
  if (OS === "ios") {
@@ -91,7 +97,7 @@ export const useTranslateAnimation = () => {
91
97
  onMove: e => {
92
98
  "worklet";
93
99
 
94
- if (OS === "android") {
100
+ if (OS !== "ios") {
95
101
  translate.value = e.progress;
96
102
  }
97
103
  },
@@ -105,7 +111,7 @@ export const useTranslateAnimation = () => {
105
111
  "worklet";
106
112
 
107
113
  padding.value = e.progress;
108
- if (OS === "android") {
114
+ if (OS !== "ios") {
109
115
  translate.value = e.progress;
110
116
  }
111
117
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useSharedValue","useKeyboardHandler","useKeyboardContext","useState","Platform","OS","useKeyboardAnimation","reanimated","initialHeight","height","value","initialProgress","progress","heightWhenOpened","isClosed","onStart","e","onMove","onInteractive","onEnd","duration","useTranslateAnimation","padding","translate"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport {useKeyboardHandler} from \"../../hooks\";\nimport {useKeyboardContext} from \"../../context\";\nimport { useState } from \"react\";\nimport { Platform } from \"react-native\";\n\nconst OS = Platform.OS;\n\nexport const useKeyboardAnimation = () => {\n const { reanimated } = useKeyboardContext();\n // calculate it only once on mount, to avoid `SharedValue` reads during a render\n const [initialHeight] = useState(() => -reanimated.height.value);\n const [initialProgress] = useState(() => reanimated.progress.value);\n\n const heightWhenOpened = useSharedValue(initialHeight);\n const height = useSharedValue(initialHeight);\n const progress = useSharedValue(initialProgress);\n const isClosed = useSharedValue(initialProgress === 0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height > 0) {\n // eslint-disable-next-line react-compiler/react-compiler\n isClosed.value = false;\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n \"worklet\";\n \n progress.value = e.progress;\n height.value = e.height;\n },\n onInteractive: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n \"worklet\";\n if(Platform.OS as string === 'harmony'){\n heightWhenOpened.value = e.height;\n }\n \n isClosed.value = e.height === 0;\n\n // `height` update happens in `onMove` handler\n // in `onEnd` we need to update only if `onMove`\n // wasn't called (i. e. duration === 0)\n //\n // we can not call this code without condition below\n // because in some corner cases (iOS with `secureTextEntry`)\n // `onEnd` can be emitted before `onMove` and in this case\n // it may lead to choppy/glitchy/jumpy UI\n // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327\n if (e.duration === 0) {\n progress.value = e.progress;\n height.value = e.height;\n }\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n\nexport const useTranslateAnimation = () => {\n const { reanimated } = useKeyboardContext();\n\n // calculate it only once on mount, to avoid `SharedValue` reads during a render\n const [initialProgress] = useState(() => reanimated.progress.value);\n\n const padding = useSharedValue(initialProgress);\n const translate = useSharedValue(0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height === 0) {\n // eslint-disable-next-line react-compiler/react-compiler\n padding.value = 0;\n }\n if (OS === \"ios\") {\n translate.value = e.progress;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n if (OS === \"android\") {\n translate.value = e.progress;\n }\n },\n onInteractive: (e) => {\n \"worklet\";\n\n padding.value = 0;\n\n translate.value = e.progress;\n },\n onEnd: (e) => {\n \"worklet\";\n\n padding.value = e.progress;\n\n if (OS === \"android\") {\n translate.value = e.progress;\n }\n },\n },\n [],\n );\n\n return { translate, padding };\n};\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,yBAAyB;AAExD,SAAQC,kBAAkB,QAAO,aAAa;AAC9C,SAAQC,kBAAkB,QAAO,eAAe;AAChD,SAASC,QAAQ,QAAQ,OAAO;AAChC,SAASC,QAAQ,QAAQ,cAAc;AAEvC,MAAMC,EAAE,GAAGD,QAAQ,CAACC,EAAE;AAEtB,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAW,CAAC,GAAGL,kBAAkB,CAAC,CAAC;EAC3C;EACA,MAAM,CAACM,a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,CAACJ,QAAQ;MAE1B,IAAIP,EAAE,KAAK,SAAS,EAAE;QACpBkB,SAAS,CAACb,KAAK,GAAGM,CAAC,CAACJ,QAAQ;MAC9B;IACF;EACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEW,SAAS;IAAED;EAAQ,CAAC;AAC/B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useSharedValue","useKeyboardHandler","useKeyboardContext","useLayoutEffect","Platform","OS","useKeyboardAnimation","reanimated","heightWhenOpened","height","progress","isClosed","initialHeight","value","initialProgress","onStart","e","onMove","onInteractive","onEnd","duration","useTranslateAnimation","padding","translate"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport {useKeyboardHandler} from \"../../hooks\";\nimport {useKeyboardContext} from \"../../context\";\nimport { useLayoutEffect } from \"react\";\nimport { Platform } from \"react-native\";\n\nconst OS = Platform.OS;\n\nexport const useKeyboardAnimation = () => {\n const { reanimated } = useKeyboardContext();\n const heightWhenOpened = useSharedValue(0);\n const height = useSharedValue(0);\n const progress = useSharedValue(0);\n const isClosed = useSharedValue(true);\n\n useLayoutEffect(() => {\n const initialHeight = -reanimated.height.value;\n const initialProgress = reanimated.progress.value;\n\n // eslint-disable-next-line react-compiler/react-compiler\n heightWhenOpened.value = initialHeight;\n height.value = initialHeight;\n progress.value = initialProgress;\n isClosed.value = initialProgress === 0;\n }, []);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height > 0) {\n isClosed.value = false;\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n \"worklet\";\n \n progress.value = e.progress;\n height.value = e.height;\n },\n onInteractive: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n \"worklet\";\n if(Platform.OS as string === 'harmony'){\n heightWhenOpened.value = e.height;\n }\n \n isClosed.value = e.height === 0;\n\n // `height` update happens in `onMove` handler\n // in `onEnd` we need to update only if `onMove`\n // wasn't called (i. e. duration === 0)\n //\n // we can not call this code without condition below\n // because in some corner cases (iOS with `secureTextEntry`)\n // `onEnd` can be emitted before `onMove` and in this case\n // it may lead to choppy/glitchy/jumpy UI\n // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327\n if (e.duration === 0) {\n progress.value = e.progress;\n height.value = e.height;\n }\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n\nexport const useTranslateAnimation = () => {\n const { reanimated } = useKeyboardContext();\n\n const padding = useSharedValue(0);\n const translate = useSharedValue(0);\n\n useLayoutEffect(() => {\n // eslint-disable-next-line react-compiler/react-compiler\n padding.value = reanimated.progress.value;\n }, []);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height === 0) {\n padding.value = 0;\n }\n if (OS === \"ios\") {\n translate.value = e.progress;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n if (OS !== \"ios\") {\n translate.value = e.progress;\n }\n },\n onInteractive: (e) => {\n \"worklet\";\n\n padding.value = 0;\n\n translate.value = e.progress;\n },\n onEnd: (e) => {\n \"worklet\";\n\n padding.value = e.progress;\n\n if (OS !== \"ios\") {\n translate.value = e.progress;\n }\n },\n },\n [],\n );\n\n return { translate, padding };\n};\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,yBAAyB;AAExD,SAAQC,kBAAkB,QAAO,aAAa;AAC9C,SAAQC,kBAAkB,QAAO,eAAe;AAChD,SAASC,eAAe,QAAQ,OAAO;AACvC,SAASC,QAAQ,QAAQ,cAAc;AAEvC,MAAMC,EAAE,GAAGD,QAAQ,CAACC,EAAE;AAEtB,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAW,CAAC,GAAGL,kBAAkB,CAAC,CAAC;EAC3C,MAAMM,gBAAgB,GAAGR,cAAc,CAAC,CAAC,CAAC;EAC1C,MAAMS,MAAM,GAAGT,cAAc,CAAC,CAAC,CAAC;EAChC,MA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ACZ,SAAS;;MAETM,OAAO,CAACT,KAAK,GAAGG,CAAC,CAACN,QAAQ;MAE1B,IAAIL,EAAE,KAAK,KAAK,EAAE;QAChBkB,SAAS,CAACV,KAAK,GAAGG,CAAC,CAACN,QAAQ;MAC9B;IACF;EACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEa,SAAS;IAAED;EAAQ,CAAC;AAC/B,CAAC","ignoreList":[]}
@@ -2,7 +2,10 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
2
2
  import React, { forwardRef, useCallback, useMemo } from "react";
3
3
  import { View } from "react-native";
4
4
  import Reanimated, { interpolate, runOnUI, useAnimatedStyle, useDerivedValue, useSharedValue } from "react-native-reanimated";
5
+ import { KeyboardControllerNative } from "../../bindings";
5
6
  import { useWindowDimensions } from "../../hooks";
7
+ import { findNodeHandle } from "../../utils/findNodeHandle";
8
+ import useCombinedRef from "../hooks/useCombinedRef";
6
9
  import { useKeyboardAnimation, useTranslateAnimation } from "./hooks";
7
10
  const defaultLayout = {
8
11
  x: 0,
@@ -21,11 +24,13 @@ const KeyboardAvoidingView = /*#__PURE__*/forwardRef(({
21
24
  contentContainerStyle,
22
25
  enabled = true,
23
26
  keyboardVerticalOffset = 0,
27
+ automaticOffset = false,
24
28
  style,
25
29
  onLayout: onLayoutProps,
26
30
  ...props
27
31
  }, ref) => {
28
32
  const initialFrame = useSharedValue(null);
33
+ const internalRef = React.useRef(null);
29
34
  const frame = useDerivedValue(() => initialFrame.value || defaultLayout);
30
35
  const {
31
36
  translate,
@@ -49,36 +54,54 @@ const KeyboardAvoidingView = /*#__PURE__*/forwardRef(({
49
54
  const onLayoutWorklet = useCallback(layout => {
50
55
  "worklet";
51
56
 
52
- if (keyboard.isClosed.value || initialFrame.value === null) {
57
+ if (keyboard.isClosed.value || initialFrame.value === null || behavior !== "height") {
53
58
  // eslint-disable-next-line react-compiler/react-compiler
54
59
  initialFrame.value = layout;
55
60
  }
56
- }, []);
61
+ }, [behavior]);
57
62
  const onLayout = useCallback(e => {
58
- runOnUI(onLayoutWorklet)(e.nativeEvent.layout);
59
63
  onLayoutProps === null || onLayoutProps === void 0 || onLayoutProps(e);
60
- }, [onLayoutProps]);
64
+ const layout = e.nativeEvent.layout;
65
+ if (automaticOffset) {
66
+ const tag = findNodeHandle(internalRef.current);
67
+ if (tag !== null) {
68
+ return KeyboardControllerNative.viewPositionInWindow(tag).then(position => {
69
+ runOnUI(onLayoutWorklet)({
70
+ ...layout,
71
+ x: position.x,
72
+ y: position.y
73
+ });
74
+ }).catch(() => {
75
+ runOnUI(onLayoutWorklet)(layout);
76
+ });
77
+ }
78
+ }
79
+ return runOnUI(onLayoutWorklet)(layout);
80
+ }, [onLayoutProps, automaticOffset]);
61
81
  const animatedStyle = useAnimatedStyle(() => {
82
+ if (!enabled) {
83
+ return {};
84
+ }
62
85
  const bottom = interpolateToRelativeKeyboardHeight(keyboard.progress.value);
63
86
  const translateY = interpolateToRelativeKeyboardHeight(translate.value);
64
87
  const paddingBottom = interpolateToRelativeKeyboardHeight(padding.value);
65
- const bottomHeight = enabled ? bottom : 0;
88
+ const height = frame.value.height - bottom;
66
89
  switch (behavior) {
67
90
  case "height":
68
- if (!keyboard.isClosed.value) {
91
+ if (!keyboard.isClosed.value && height > 0) {
69
92
  return {
70
- height: frame.value.height - bottomHeight,
93
+ height,
71
94
  flex: 0
72
95
  };
73
96
  }
74
97
  return {};
75
98
  case "position":
76
99
  return {
77
- bottom: bottomHeight
100
+ bottom
78
101
  };
79
102
  case "padding":
80
103
  return {
81
- paddingBottom: bottomHeight
104
+ paddingBottom: bottom
82
105
  };
83
106
  case "translate-with-padding":
84
107
  return {
@@ -91,12 +114,13 @@ const KeyboardAvoidingView = /*#__PURE__*/forwardRef(({
91
114
  return {};
92
115
  }
93
116
  }, [behavior, enabled, interpolateToRelativeKeyboardHeight]);
117
+ const combinedRef = useCombinedRef(internalRef, ref);
94
118
  const isPositionBehavior = behavior === "position";
95
119
  const containerStyle = isPositionBehavior ? contentContainerStyle : style;
96
120
  const combinedStyles = useMemo(() => [containerStyle, animatedStyle], [containerStyle, animatedStyle]);
97
121
  if (isPositionBehavior) {
98
122
  return /*#__PURE__*/React.createElement(View, _extends({
99
- ref: ref,
123
+ ref: combinedRef,
100
124
  style: style,
101
125
  onLayout: onLayout
102
126
  }, props), /*#__PURE__*/React.createElement(Reanimated.View, {
@@ -104,7 +128,7 @@ const KeyboardAvoidingView = /*#__PURE__*/forwardRef(({
104
128
  }, children));
105
129
  }
106
130
  return /*#__PURE__*/React.createElement(Reanimated.View, _extends({
107
- ref: ref,
131
+ ref: combinedRef,
108
132
  onLayout: onLayout,
109
133
  style: combinedStyles
110
134
  }, props), children);
@@ -1 +1 @@
1
- {"version":3,"names":["React","forwardRef","useCallback","useMemo","View","Reanimated","interpolate","runOnUI","useAnimatedStyle","useDerivedValue","useSharedValue","useWindowDimensions","useKeyboardAnimation","useTranslateAnimation","defaultLayout","x","y","width","height","KeyboardAvoidingView","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","ref","initialFrame","frame","value","translate","padding","keyboard","screenHeight","relativeKeyboardHeight","keyboardY","heightWhenOpened","Math","max","interpolateToRelativeKeyboardHeight","onLayoutWorklet","layout","isClosed","e","nativeEvent","animatedStyle","bottom","progress","translateY","paddingBottom","bottomHeight","flex","transform","isPositionBehavior","containerStyle","combinedStyles","createElement","_extends"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { View } from \"react-native\";\nimport Reanimated, {\n interpolate,\n runOnUI,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { useWindowDimensions } from \"../../hooks\";\n\nimport { useKeyboardAnimation, useTranslateAnimation } from \"./hooks\";\n\nimport type { LayoutRectangle, ViewProps } from \"react-native\";\n\nexport type KeyboardAvoidingViewBaseProps = {\n /**\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\n * This is useful when more than one is on the screen. Defaults to true.\n */\n enabled?: boolean;\n\n /**\n * Distance between the top of the user screen and the React Native view. This\n * may be non-zero in some cases. Defaults to 0.\n */\n keyboardVerticalOffset?: number;\n} & ViewProps;\n\nexport type KeyboardAvoidingViewProps = KeyboardAvoidingViewBaseProps &\n (\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"position\";\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps[\"style\"];\n }\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"height\" | \"padding\" | \"translate-with-padding\";\n\n /**\n * `contentContainerStyle` is not allowed for these behaviors.\n */\n contentContainerStyle?: never;\n }\n );\n\nconst defaultLayout: LayoutRectangle = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n};\n\n/**\n * View that moves out of the way when the keyboard appears by automatically\n * adjusting its height, position, or bottom padding.\n */\nconst KeyboardAvoidingView = forwardRef<\n View,\n React.PropsWithChildren<KeyboardAvoidingViewProps>\n>(\n (\n {\n behavior,\n children,\n contentContainerStyle,\n enabled = true,\n keyboardVerticalOffset = 0,\n style,\n onLayout: onLayoutProps,\n ...props\n },\n ref,\n ) => {\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\n\n const { translate, padding } = useTranslateAnimation();\n const keyboard = useKeyboardAnimation();\n const { height: screenHeight } = useWindowDimensions();\n\n const relativeKeyboardHeight = useCallback(() => {\n \"worklet\";\n\n const keyboardY =\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\n\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\n }, [screenHeight, keyboardVerticalOffset]);\n const interpolateToRelativeKeyboardHeight = useCallback(\n (value: number) => {\n \"worklet\";\n\n return interpolate(value, [0, 1], [0, relativeKeyboardHeight()]);\n },\n [relativeKeyboardHeight],\n );\n\n const onLayoutWorklet = useCallback((layout: LayoutRectangle) => {\n \"worklet\";\n\n if (keyboard.isClosed.value || initialFrame.value === null) {\n // eslint-disable-next-line react-compiler/react-compiler\n initialFrame.value = layout;\n }\n }, []);\n const onLayout = useCallback<NonNullable<ViewProps[\"onLayout\"]>>(\n (e) => {\n runOnUI(onLayoutWorklet)(e.nativeEvent.layout);\n onLayoutProps?.(e);\n },\n [onLayoutProps],\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n const bottom = interpolateToRelativeKeyboardHeight(\n keyboard.progress.value,\n );\n const translateY = interpolateToRelativeKeyboardHeight(translate.value);\n const paddingBottom = interpolateToRelativeKeyboardHeight(padding.value);\n const bottomHeight = enabled ? bottom : 0;\n\n switch (behavior) {\n case \"height\":\n if (!keyboard.isClosed.value) {\n return {\n height: frame.value.height - bottomHeight,\n flex: 0,\n };\n }\n\n return {};\n\n case \"position\":\n return { bottom: bottomHeight };\n\n case \"padding\":\n return { paddingBottom: bottomHeight };\n\n case \"translate-with-padding\":\n return {\n paddingBottom: paddingBottom,\n transform: [{ translateY: -translateY}],\n };\n\n default:\n return {};\n }\n }, [behavior, enabled, interpolateToRelativeKeyboardHeight]);\n const isPositionBehavior = behavior === \"position\";\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\n const combinedStyles = useMemo(\n () => [containerStyle, animatedStyle],\n [containerStyle, animatedStyle],\n );\n\n if (isPositionBehavior) {\n return (\n <View ref={ref} style={style} onLayout={onLayout} {...props}>\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\n </View>\n );\n }\n\n return (\n <Reanimated.View\n ref={ref}\n onLayout={onLayout}\n style={combinedStyles}\n {...props}\n >\n {children}\n </Reanimated.View>\n );\n },\n);\n\nexport default KeyboardAvoidingView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,IAAI,QAAQ,cAAc;AACnC,OAAOC,UAAU,IACfC,WAAW,EACXC,OAAO,EACPC,gBAAgB,EAChBC,eAA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K,UAAU;QACb,OAAO;UAAEL,MAAM,EAAEI;QAAa,CAAC;MAEjC,KAAK,SAAS;QACZ,OAAO;UAAED,aAAa,EAAEC;QAAa,CAAC;MAExC,KAAK,wBAAwB;QAC3B,OAAO;UACLD,aAAa,EAAEA,aAAa;UAC5BG,SAAS,EAAE,CAAC;YAAEJ,UAAU,EAAE,CAACA;UAAU,CAAC;QACxC,CAAC;MAEH;QACE,OAAO,CAAC,CAAC;IACb;EACF,CAAC,EAAE,CAAC/B,QAAQ,EAAEG,OAAO,EAAEmB,mCAAmC,CAAC,CAAC;EAC5D,MAAMc,kBAAkB,GAAGpC,QAAQ,KAAK,UAAU;EAClD,MAAMqC,cAAc,GAAGD,kBAAkB,GAAGlC,qBAAqB,GAAGG,KAAK;EACzE,MAAMiC,cAAc,GAAGvD,OAAO,CAC5B,MAAM,CAACsD,cAAc,EAAET,aAAa,CAAC,EACrC,CAACS,cAAc,EAAET,aAAa,CAChC,CAAC;EAED,IAAIQ,kBAAkB,EAAE;IACtB,oBACExD,KAAA,CAAA2D,aAAA,CAACvD,IAAI,EAAAwD,QAAA;MAAC/B,GAAG,EAAEA,GAAI;MAACJ,KAAK,EAAEA,KAAM;MAACC,QAAQ,EAAEA;IAAS,GAAKE,KAAK,gBACzD5B,KAAA,CAAA2D,aAAA,CAACtD,UAAU,CAACD,IAAI;MAACqB,KAAK,EAAEiC;IAAe,GAAErC,QAA0B,CAC/D,CAAC;EAEX;EAEA,oBACErB,KAAA,CAAA2D,aAAA,CAACtD,UAAU,CAACD,IAAI,EAAAwD,QAAA;IACd/B,GAAG,EAAEA,GAAI;IACTH,QAAQ,EAAEA,QAAS;IACnBD,KAAK,EAAEiC;EAAe,GAClB9B,KAAK,GAERP,QACc,CAAC;AAEtB,CACF,CAAC;AAED,eAAeF,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["React","forwardRef","useCallback","useMemo","View","Reanimated","interpolate","runOnUI","useAnimatedStyle","useDerivedValue","useSharedValue","KeyboardControllerNative","useWindowDimensions","findNodeHandle","useCombinedRef","useKeyboardAnimation","useTranslateAnimation","defaultLayout","x","y","width","height","KeyboardAvoidingView","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","automaticOffset","style","onLayout","onLayoutProps","props","ref","initialFrame","internalRef","useRef","frame","value","translate","padding","keyboard","screenHeight","relativeKeyboardHeight","keyboardY","heightWhenOpened","Math","max","interpolateToRelativeKeyboardHeight","onLayoutWorklet","layout","isClosed","e","nativeEvent","tag","current","viewPositionInWindow","then","position","catch","animatedStyle","bottom","progress","translateY","paddingBottom","flex","transform","combinedRef","isPositionBehavior","containerStyle","combinedStyles","createElement","_extends"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { View } from \"react-native\";\nimport Reanimated, {\n interpolate,\n runOnUI,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { KeyboardControllerNative } from \"../../bindings\";\nimport { useWindowDimensions } from \"../../hooks\";\nimport { findNodeHandle } from \"../../utils/findNodeHandle\";\nimport useCombinedRef from \"../hooks/useCombinedRef\";\n\nimport { useKeyboardAnimation, useTranslateAnimation } from \"./hooks\";\n\nimport type { LayoutRectangle, ViewProps } from \"react-native\";\n\nexport type KeyboardAvoidingViewBaseProps = {\n /**\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\n * This is useful when more than one is on the screen. Defaults to true.\n */\n enabled?: boolean;\n\n /**\n * Distance between the top of the user screen and the React Native view. This\n * may be non-zero in some cases. Defaults to 0.\n */\n keyboardVerticalOffset?: number;\n\n /**\n * When true, detect the view position in the window automatically.\n * keyboardVerticalOffset remains an additive offset.\n */\n automaticOffset?: boolean;\n} & ViewProps;\n\nexport type KeyboardAvoidingViewProps = KeyboardAvoidingViewBaseProps &\n (\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"position\";\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps[\"style\"];\n }\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"height\" | \"padding\" | \"translate-with-padding\";\n\n /**\n * `contentContainerStyle` is not allowed for these behaviors.\n */\n contentContainerStyle?: never;\n }\n );\n\nconst defaultLayout: LayoutRectangle = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n};\n\n/**\n * View that moves out of the way when the keyboard appears by automatically\n * adjusting its height, position, or bottom padding.\n */\nconst KeyboardAvoidingView = forwardRef<\n View,\n React.PropsWithChildren<KeyboardAvoidingViewProps>\n>(\n (\n {\n behavior,\n children,\n contentContainerStyle,\n enabled = true,\n keyboardVerticalOffset = 0,\n automaticOffset = false,\n style,\n onLayout: onLayoutProps,\n ...props\n },\n ref,\n ) => {\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\n const internalRef = React.useRef<View | null>(null);\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\n\n const { translate, padding } = useTranslateAnimation();\n const keyboard = useKeyboardAnimation();\n const { height: screenHeight } = useWindowDimensions();\n\n const relativeKeyboardHeight = useCallback(() => {\n \"worklet\";\n\n const keyboardY =\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\n\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\n }, [screenHeight, keyboardVerticalOffset]);\n const interpolateToRelativeKeyboardHeight = useCallback(\n (value: number) => {\n \"worklet\";\n\n return interpolate(value, [0, 1], [0, relativeKeyboardHeight()]);\n },\n [relativeKeyboardHeight],\n );\n\n const onLayoutWorklet = useCallback(\n (layout: LayoutRectangle) => {\n \"worklet\";\n\n if (\n keyboard.isClosed.value ||\n initialFrame.value === null ||\n behavior !== \"height\"\n ) {\n // eslint-disable-next-line react-compiler/react-compiler\n initialFrame.value = layout;\n }\n },\n [behavior],\n );\n const onLayout = useCallback<NonNullable<ViewProps[\"onLayout\"]>>(\n (e) => {\n onLayoutProps?.(e);\n\n const layout = e.nativeEvent.layout;\n\n if (automaticOffset) {\n const tag = findNodeHandle(internalRef.current);\n\n if (tag !== null) {\n return KeyboardControllerNative.viewPositionInWindow(tag)\n .then((position) => {\n runOnUI(onLayoutWorklet)({\n ...layout,\n x: position.x,\n y: position.y,\n });\n })\n .catch(() => {\n runOnUI(onLayoutWorklet)(layout);\n });\n }\n }\n\n return runOnUI(onLayoutWorklet)(layout);\n },\n [onLayoutProps, automaticOffset],\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n if (!enabled) {\n return {};\n }\n\n const bottom = interpolateToRelativeKeyboardHeight(\n keyboard.progress.value,\n );\n const translateY = interpolateToRelativeKeyboardHeight(translate.value);\n const paddingBottom = interpolateToRelativeKeyboardHeight(padding.value);\n const height = frame.value.height - bottom;\n\n switch (behavior) {\n case \"height\":\n if (!keyboard.isClosed.value && height > 0) {\n return {\n height,\n flex: 0,\n };\n }\n\n return {};\n\n case \"position\":\n return { bottom };\n\n case \"padding\":\n return { paddingBottom: bottom };\n\n case \"translate-with-padding\":\n return {\n paddingBottom: paddingBottom,\n transform: [{ translateY: -translateY }],\n };\n\n default:\n return {};\n }\n }, [behavior, enabled, interpolateToRelativeKeyboardHeight]);\n const combinedRef = useCombinedRef(internalRef, ref);\n const isPositionBehavior = behavior === \"position\";\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\n const combinedStyles = useMemo(\n () => [containerStyle, animatedStyle],\n [containerStyle, animatedStyle],\n );\n\n if (isPositionBehavior) {\n return (\n <View ref={combinedRef} style={style} onLayout={onLayout} {...props}>\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\n </View>\n );\n }\n\n return (\n <Reanimated.View\n ref={combinedRef}\n onLayout={onLayout}\n style={combinedStyles}\n {...props}\n >\n {children}\n </Reanimated.View>\n );\n },\n);\n\nexport default KeyboardAvoidingView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,IAAI,QAAQ,cAAc;AACnC,OAAOC,UAAU,IAC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,MAAMmB,WAAW,GAAGrD,cAAc,CAACqB,WAAW,EAAEF,GAAG,CAAC;EACpD,MAAMmC,kBAAkB,GAAG7C,QAAQ,KAAK,UAAU;EAClD,MAAM8C,cAAc,GAAGD,kBAAkB,GAAG3C,qBAAqB,GAAGI,KAAK;EACzE,MAAMyC,cAAc,GAAGnE,OAAO,CAC5B,MAAM,CAACkE,cAAc,EAAET,aAAa,CAAC,EACrC,CAACS,cAAc,EAAET,aAAa,CAChC,CAAC;EAED,IAAIQ,kBAAkB,EAAE;IACtB,oBACEpE,KAAA,CAAAuE,aAAA,CAACnE,IAAI,EAAAoE,QAAA;MAACvC,GAAG,EAAEkC,WAAY;MAACtC,KAAK,EAAEA,KAAM;MAACC,QAAQ,EAAEA;IAAS,GAAKE,KAAK,gBACjEhC,KAAA,CAAAuE,aAAA,CAAClE,UAAU,CAACD,IAAI;MAACyB,KAAK,EAAEyC;IAAe,GAAE9C,QAA0B,CAC/D,CAAC;EAEX;EAEA,oBACExB,KAAA,CAAAuE,aAAA,CAAClE,UAAU,CAACD,IAAI,EAAAoE,QAAA;IACdvC,GAAG,EAAEkC,WAAY;IACjBrC,QAAQ,EAAEA,QAAS;IACnBD,KAAK,EAAEyC;EAAe,GAClBtC,KAAK,GAERR,QACc,CAAC;AAEtB,CACF,CAAC;AAED,eAAeF,oBAAoB","ignoreList":[]}
@@ -1,8 +1,10 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { forwardRef, useCallback, useMemo } from "react";
3
- import { findNodeHandle, Platform } from "react-native";
4
- import Reanimated, { interpolate, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedStyle, useScrollViewOffset, useSharedValue } from "react-native-reanimated";
2
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo } from "react";
3
+ import { Platform } from "react-native";
4
+ import Reanimated, { interpolate, runOnUI, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedStyle, useScrollViewOffset, useSharedValue } from "react-native-reanimated";
5
+ import { KeyboardControllerNative } from "../../bindings";
5
6
  import { useFocusedInputHandler, useReanimatedFocusedInput, useWindowDimensions } from "../../hooks";
7
+ import { findNodeHandle } from "../../utils/findNodeHandle";
6
8
  import { useSmoothKeyboardHandler } from "./useSmoothKeyboardHandler";
7
9
  import { debounce, scrollDistanceWithRespectToSnapPoints } from "./utils";
8
10
  const IS_HARMONY = Platform.OS === "harmony";
@@ -68,20 +70,27 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
68
70
  input
69
71
  } = useReanimatedFocusedInput();
70
72
  const layout = useSharedValue(null);
73
+ const scrollViewPageY = useSharedValue(0);
71
74
  const {
72
75
  height
73
76
  } = useWindowDimensions();
74
77
  const onRef = useCallback(assignedRef => {
75
- if (typeof ref === "function") {
76
- ref(assignedRef);
77
- } else if (ref) {
78
- ref.current = assignedRef;
79
- }
80
78
  scrollViewAnimatedRef(assignedRef);
81
79
  }, []);
82
- const onScrollViewLayout = useCallback(e => {
83
- scrollViewTarget.value = findNodeHandle(scrollViewAnimatedRef.current);
80
+ const onScrollViewLayout = useCallback(async e => {
81
+ const handle = findNodeHandle(scrollViewAnimatedRef.current);
82
+ scrollViewTarget.value = handle;
84
83
  onLayout === null || onLayout === void 0 || onLayout(e);
84
+ if (handle !== null) {
85
+ try {
86
+ const {
87
+ y
88
+ } = await KeyboardControllerNative.viewPositionInWindow(handle);
89
+ scrollViewPageY.value = y;
90
+ } catch {
91
+ // Keep the previous top boundary when the view is not mounted yet.
92
+ }
93
+ }
85
94
  }, [onLayout]);
86
95
 
87
96
  /**
@@ -110,13 +119,27 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
110
119
  scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);
111
120
  return interpolatedScrollTo;
112
121
  }
113
- if (absoluteY < 0) {
114
- const positionOnScreen = visibleRect - inputHeight - bottomOffset;
115
- const topOfScreen = scrollPosition.value + absoluteY;
122
+ if (point < scrollViewPageY.value) {
123
+ const positionOnScreen = visibleRect - bottomOffset;
124
+ const topOfScreen = scrollPosition.value + point;
116
125
  scrollTo(scrollViewAnimatedRef, 0, topOfScreen - positionOnScreen, animated);
117
126
  }
118
127
  return 0;
119
128
  }, [bottomOffset, enabled, height, rest.snapToOffsets]);
129
+ const performScrollWithPositionRestoration = useCallback(newPosition => {
130
+ "worklet";
131
+
132
+ const prevScrollPosition = scrollPosition.value;
133
+
134
+ // eslint-disable-next-line react-compiler/react-compiler
135
+ scrollPosition.value = newPosition;
136
+ maybeScroll(keyboardHeight.value, true);
137
+ scrollPosition.value = prevScrollPosition;
138
+ }, [maybeScroll]);
139
+ useEffect(() => {
140
+ // Recalculate from the pre-keyboard position to avoid accumulating an already applied offset.
141
+ runOnUI(performScrollWithPositionRestoration)(scrollBeforeKeyboardMovement.value);
142
+ }, [bottomOffset]);
120
143
  const syncKeyboardFrame = useCallback(e => {
121
144
  "worklet";
122
145
 
@@ -127,7 +150,6 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
127
150
  "worklet";
128
151
 
129
152
  var _input$value;
130
- const prevScrollPosition = scrollPosition.value;
131
153
  const prevLayout = layout.value;
132
154
  if (!((_input$value = input.value) !== null && _input$value !== void 0 && _input$value.layout)) {
133
155
  return;
@@ -141,11 +163,24 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
141
163
  height: customHeight ?? input.value.layout.height
142
164
  }
143
165
  };
144
- scrollPosition.value = position.value;
145
- maybeScroll(keyboardHeight.value, true);
146
- scrollPosition.value = prevScrollPosition;
166
+ performScrollWithPositionRestoration(position.value);
147
167
  layout.value = prevLayout;
148
- }, [maybeScroll]);
168
+ }, [performScrollWithPositionRestoration]);
169
+ const assureFocusedInputVisible = useCallback(() => {
170
+ runOnUI(scrollFromCurrentPosition)();
171
+ }, [scrollFromCurrentPosition]);
172
+ useImperativeHandle(ref, () => {
173
+ const current = scrollViewAnimatedRef.current;
174
+ if (current) {
175
+ Object.assign(current, {
176
+ assureFocusedInputVisible
177
+ });
178
+ return current;
179
+ }
180
+ return {
181
+ assureFocusedInputVisible
182
+ };
183
+ }, [assureFocusedInputVisible]);
149
184
  const onChangeText = useCallback(() => {
150
185
  "worklet";
151
186
 
@@ -249,7 +284,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
249
284
  onLayout: onScrollViewLayout,
250
285
  scrollToOverflowEnabled: IS_HARMONY ? true : rest.scrollToOverflowEnabled,
251
286
  scrollEventThrottle: 16
252
- }), children, /*#__PURE__*/React.createElement(Reanimated.View, {
287
+ }), children, enabled && /*#__PURE__*/React.createElement(Reanimated.View, {
253
288
  style: view
254
289
  }));
255
290
  });