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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/LICENSE +21 -21
  2. package/README.OpenSource +11 -11
  3. package/README.md +686 -19
  4. package/harmony/keyboard_controller/BuildProfile.ets +16 -16
  5. package/harmony/keyboard_controller/Index.ets +29 -28
  6. package/harmony/keyboard_controller/build-profile.json5 +31 -31
  7. package/harmony/keyboard_controller/hvigorfile.ts +6 -6
  8. package/harmony/keyboard_controller/obfuscation-rules.txt +17 -17
  9. package/harmony/keyboard_controller/oh-package-lock.json5 +28 -18
  10. package/harmony/keyboard_controller/oh-package.json5 +10 -10
  11. package/harmony/keyboard_controller/src/main/cpp/CMakeLists.txt +7 -7
  12. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentDescriptor.h +86 -0
  13. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.cpp +104 -0
  14. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.h +64 -0
  15. package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewJSIBinder.h +60 -0
  16. package/harmony/keyboard_controller/src/main/cpp/EventEmitters.cpp +119 -96
  17. package/harmony/keyboard_controller/src/main/cpp/EventEmitters.h +111 -111
  18. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentDescriptor.h +94 -94
  19. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +840 -288
  20. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.h +169 -103
  21. package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewJSIBinder.h +65 -65
  22. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentDescriptor.h +79 -79
  23. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +108 -108
  24. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.h +83 -83
  25. package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaJSIBinder.h +60 -60
  26. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentDescriptor.h +46 -0
  27. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.cpp +37 -0
  28. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.h +32 -0
  29. package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewJSIBinder.h +23 -0
  30. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.cpp +103 -46
  31. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.h +48 -48
  32. package/harmony/keyboard_controller/src/main/cpp/RNKeyboardControllerPackage.h +20 -0
  33. package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.cpp +45 -45
  34. package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.h +49 -49
  35. package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.cpp +207 -186
  36. package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.h +131 -112
  37. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +77 -64
  38. package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +85 -77
  39. package/harmony/keyboard_controller/src/main/ets/Logger.ts +66 -66
  40. package/harmony/keyboard_controller/src/main/ets/{RNKeyboardControllerPackage.ts → RNKeyboardControllerPackage.ets} +70 -66
  41. package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +465 -273
  42. package/harmony/keyboard_controller/src/main/ets/RNStatusBarManagerCompatTurboModule.ts +128 -119
  43. package/harmony/keyboard_controller/src/main/ets/Type.ts +63 -62
  44. package/harmony/keyboard_controller/src/main/module.json5 +11 -11
  45. package/harmony/keyboard_controller/src/main/resources/base/element/string.json +8 -8
  46. package/harmony/keyboard_controller/src/main/resources/en_US/element/string.json +8 -8
  47. package/harmony/keyboard_controller/src/main/resources/zh_CN/element/string.json +8 -8
  48. package/harmony/keyboard_controller/{ts.ts → ts.ets} +29 -29
  49. package/harmony/keyboard_controller.har +0 -0
  50. package/lib/commonjs/animated.js +22 -11
  51. package/lib/commonjs/animated.js.map +1 -1
  52. package/lib/commonjs/architecture.js +8 -0
  53. package/lib/commonjs/architecture.js.map +1 -0
  54. package/lib/commonjs/bindings.js +40 -5
  55. package/lib/commonjs/bindings.js.map +1 -1
  56. package/lib/commonjs/bindings.native.js +28 -5
  57. package/lib/commonjs/bindings.native.js.map +1 -1
  58. package/lib/commonjs/compat.js +50 -0
  59. package/lib/commonjs/compat.js.map +1 -0
  60. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +21 -15
  61. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
  62. package/lib/commonjs/components/KeyboardAvoidingView/index.js +39 -14
  63. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  64. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +94 -57
  65. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  66. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +5 -5
  67. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  68. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -1
  69. package/lib/commonjs/components/KeyboardChatScrollView/hooks.js +13 -0
  70. package/lib/commonjs/components/KeyboardChatScrollView/hooks.js.map +1 -0
  71. package/lib/commonjs/components/KeyboardChatScrollView/index.js +122 -0
  72. package/lib/commonjs/components/KeyboardChatScrollView/index.js.map +1 -0
  73. package/lib/commonjs/components/KeyboardChatScrollView/types.js +6 -0
  74. package/lib/commonjs/components/KeyboardChatScrollView/types.js.map +1 -0
  75. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +221 -0
  76. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
  77. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +149 -0
  78. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
  79. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js +240 -0
  80. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
  81. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js +6 -0
  82. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
  83. package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js +40 -0
  84. package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
  85. package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js +92 -0
  86. package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
  87. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  88. package/lib/commonjs/components/KeyboardToolbar/Arrow.js +2 -3
  89. package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
  90. package/lib/commonjs/components/KeyboardToolbar/Button.js +2 -3
  91. package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
  92. package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -1
  93. package/lib/commonjs/components/KeyboardToolbar/colors.native.js.map +1 -1
  94. package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js +13 -0
  95. package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
  96. package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js +25 -0
  97. package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
  98. package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js +58 -0
  99. package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
  100. package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js +49 -0
  101. package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
  102. package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js +49 -0
  103. package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
  104. package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js +42 -0
  105. package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js.map +1 -0
  106. package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js +6 -0
  107. package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js.map +1 -0
  108. package/lib/commonjs/components/KeyboardToolbar/compound/context.js +17 -0
  109. package/lib/commonjs/components/KeyboardToolbar/compound/context.js.map +1 -0
  110. package/lib/commonjs/components/KeyboardToolbar/constants.js +17 -0
  111. package/lib/commonjs/components/KeyboardToolbar/constants.js.map +1 -0
  112. package/lib/commonjs/components/KeyboardToolbar/index.js +98 -87
  113. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  114. package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -1
  115. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js +120 -0
  116. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js.map +1 -0
  117. package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js +15 -0
  118. package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
  119. package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -1
  120. package/lib/commonjs/components/hooks/useCombinedRef.js +24 -0
  121. package/lib/commonjs/components/hooks/useCombinedRef.js.map +1 -0
  122. package/lib/commonjs/components/hooks/useScrollState.js +62 -0
  123. package/lib/commonjs/components/hooks/useScrollState.js.map +1 -0
  124. package/lib/commonjs/components/index.js +7 -0
  125. package/lib/commonjs/components/index.js.map +1 -1
  126. package/lib/commonjs/constants.js +3 -1
  127. package/lib/commonjs/constants.js.map +1 -1
  128. package/lib/commonjs/context.js +1 -0
  129. package/lib/commonjs/context.js.map +1 -1
  130. package/lib/commonjs/hooks/index.js +14 -1
  131. package/lib/commonjs/hooks/index.js.map +1 -1
  132. package/lib/commonjs/hooks/useKeyboardState/index.js +39 -0
  133. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -0
  134. package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -1
  135. package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -1
  136. package/lib/commonjs/index.js +27 -1
  137. package/lib/commonjs/index.js.map +1 -1
  138. package/lib/commonjs/internal.js +54 -18
  139. package/lib/commonjs/internal.js.map +1 -1
  140. package/lib/commonjs/module.js +21 -12
  141. package/lib/commonjs/module.js.map +1 -1
  142. package/lib/commonjs/reanimated.js.map +1 -1
  143. package/lib/commonjs/reanimated.native.js.map +1 -1
  144. package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js +12 -0
  145. package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
  146. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +8 -2
  147. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  148. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +2 -1
  149. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  150. package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js +12 -0
  151. package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
  152. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
  153. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -1
  154. package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -1
  155. package/lib/commonjs/types.js.map +1 -1
  156. package/lib/commonjs/utils/findNodeHandle/index.js +9 -0
  157. package/lib/commonjs/utils/findNodeHandle/index.js.map +1 -0
  158. package/lib/commonjs/utils/findNodeHandle/index.native.js +13 -0
  159. package/lib/commonjs/utils/findNodeHandle/index.native.js.map +1 -0
  160. package/lib/commonjs/utils.js.map +1 -1
  161. package/lib/commonjs/views/KeyboardExtender/index.js +30 -0
  162. package/lib/commonjs/views/KeyboardExtender/index.js.map +1 -0
  163. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
  164. package/lib/commonjs/views/index.js +7 -0
  165. package/lib/commonjs/views/index.js.map +1 -1
  166. package/lib/module/animated.js +24 -13
  167. package/lib/module/animated.js.map +1 -1
  168. package/lib/module/architecture.js +2 -0
  169. package/lib/module/architecture.js.map +1 -0
  170. package/lib/module/bindings.js +39 -5
  171. package/lib/module/bindings.js.map +1 -1
  172. package/lib/module/bindings.native.js +27 -5
  173. package/lib/module/bindings.native.js.map +1 -1
  174. package/lib/module/compat.js +43 -0
  175. package/lib/module/compat.js.map +1 -0
  176. package/lib/module/components/KeyboardAvoidingView/hooks.js +22 -16
  177. package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
  178. package/lib/module/components/KeyboardAvoidingView/index.js +38 -14
  179. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  180. package/lib/module/components/KeyboardAwareScrollView/index.js +97 -60
  181. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  182. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +5 -5
  183. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  184. package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -1
  185. package/lib/module/components/KeyboardChatScrollView/hooks.js +2 -0
  186. package/lib/module/components/KeyboardChatScrollView/hooks.js.map +1 -0
  187. package/lib/module/components/KeyboardChatScrollView/index.js +115 -0
  188. package/lib/module/components/KeyboardChatScrollView/index.js.map +1 -0
  189. package/lib/module/components/KeyboardChatScrollView/types.js +2 -0
  190. package/lib/module/components/KeyboardChatScrollView/types.js.map +1 -0
  191. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +207 -0
  192. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
  193. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +143 -0
  194. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
  195. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js +234 -0
  196. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
  197. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js +2 -0
  198. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
  199. package/lib/module/components/KeyboardChatScrollView/useEndVisible.js +33 -0
  200. package/lib/module/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
  201. package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js +87 -0
  202. package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
  203. package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
  204. package/lib/module/components/KeyboardToolbar/Arrow.js +2 -2
  205. package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -1
  206. package/lib/module/components/KeyboardToolbar/Button.js +2 -2
  207. package/lib/module/components/KeyboardToolbar/Button.js.map +1 -1
  208. package/lib/module/components/KeyboardToolbar/colors.js.map +1 -1
  209. package/lib/module/components/KeyboardToolbar/colors.native.js.map +1 -1
  210. package/lib/module/components/KeyboardToolbar/compound/components/Background.js +6 -0
  211. package/lib/module/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
  212. package/lib/module/components/KeyboardToolbar/compound/components/Content.js +18 -0
  213. package/lib/module/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
  214. package/lib/module/components/KeyboardToolbar/compound/components/Done.js +50 -0
  215. package/lib/module/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
  216. package/lib/module/components/KeyboardToolbar/compound/components/Next.js +41 -0
  217. package/lib/module/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
  218. package/lib/module/components/KeyboardToolbar/compound/components/Prev.js +41 -0
  219. package/lib/module/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
  220. package/lib/module/components/KeyboardToolbar/compound/components/index.js +6 -0
  221. package/lib/module/components/KeyboardToolbar/compound/components/index.js.map +1 -0
  222. package/lib/module/components/KeyboardToolbar/compound/components/types.js +2 -0
  223. package/lib/module/components/KeyboardToolbar/compound/components/types.js.map +1 -0
  224. package/lib/module/components/KeyboardToolbar/compound/context.js +10 -0
  225. package/lib/module/components/KeyboardToolbar/compound/context.js.map +1 -0
  226. package/lib/module/components/KeyboardToolbar/constants.js +11 -0
  227. package/lib/module/components/KeyboardToolbar/constants.js.map +1 -0
  228. package/lib/module/components/KeyboardToolbar/index.js +98 -88
  229. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  230. package/lib/module/components/KeyboardToolbar/types.js.map +1 -1
  231. package/lib/module/components/ScrollViewWithBottomPadding/index.js +112 -0
  232. package/lib/module/components/ScrollViewWithBottomPadding/index.js.map +1 -0
  233. package/lib/module/components/ScrollViewWithBottomPadding/styles.js +9 -0
  234. package/lib/module/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
  235. package/lib/module/components/hooks/useColorScheme.js.map +1 -1
  236. package/lib/module/components/hooks/useCombinedRef.js +18 -0
  237. package/lib/module/components/hooks/useCombinedRef.js.map +1 -0
  238. package/lib/module/components/hooks/useScrollState.js +56 -0
  239. package/lib/module/components/hooks/useScrollState.js.map +1 -0
  240. package/lib/module/components/index.js +1 -0
  241. package/lib/module/components/index.js.map +1 -1
  242. package/lib/module/constants.js +3 -0
  243. package/lib/module/constants.js.map +1 -1
  244. package/lib/module/context.js +1 -0
  245. package/lib/module/context.js.map +1 -1
  246. package/lib/module/hooks/index.js +3 -1
  247. package/lib/module/hooks/index.js.map +1 -1
  248. package/lib/module/hooks/useKeyboardState/index.js +33 -0
  249. package/lib/module/hooks/useKeyboardState/index.js.map +1 -0
  250. package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -1
  251. package/lib/module/hooks/useWindowDimensions/index.js.map +1 -1
  252. package/lib/module/index.js +3 -2
  253. package/lib/module/index.js.map +1 -1
  254. package/lib/module/internal.js +53 -18
  255. package/lib/module/internal.js.map +1 -1
  256. package/lib/module/module.js +21 -12
  257. package/lib/module/module.js.map +1 -1
  258. package/lib/module/reanimated.js.map +1 -1
  259. package/lib/module/reanimated.native.js.map +1 -1
  260. package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js +6 -0
  261. package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
  262. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +7 -1
  263. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  264. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +2 -1
  265. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  266. package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js +5 -0
  267. package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
  268. package/lib/module/specs/NativeKeyboardController.js.map +1 -1
  269. package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -1
  270. package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -1
  271. package/lib/module/types.js.map +1 -1
  272. package/lib/module/utils/findNodeHandle/index.js +2 -0
  273. package/lib/module/utils/findNodeHandle/index.js.map +1 -0
  274. package/lib/module/utils/findNodeHandle/index.native.js +3 -0
  275. package/lib/module/utils/findNodeHandle/index.native.js.map +1 -0
  276. package/lib/module/utils.js.map +1 -1
  277. package/lib/module/views/KeyboardExtender/index.js +23 -0
  278. package/lib/module/views/KeyboardExtender/index.js.map +1 -0
  279. package/lib/module/views/OverKeyboardView/index.js.map +1 -1
  280. package/lib/module/views/index.js +1 -0
  281. package/lib/module/views/index.js.map +1 -1
  282. package/lib/typescript/animated.d.ts +2 -38
  283. package/lib/typescript/architecture.d.ts +1 -0
  284. package/lib/typescript/bindings.d.ts +15 -1
  285. package/lib/typescript/bindings.native.d.ts +10 -1
  286. package/lib/typescript/compat.d.ts +12 -0
  287. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +5 -0
  288. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -1
  289. package/lib/typescript/components/KeyboardChatScrollView/hooks.d.ts +2 -0
  290. package/lib/typescript/components/KeyboardChatScrollView/index.d.ts +17 -0
  291. package/lib/typescript/components/KeyboardChatScrollView/types.d.ts +113 -0
  292. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts +132 -0
  293. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.d.ts +18 -0
  294. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.ios.d.ts +21 -0
  295. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts +37 -0
  296. package/lib/typescript/components/KeyboardChatScrollView/useEndVisible.d.ts +17 -0
  297. package/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts +45 -0
  298. package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -2
  299. package/lib/typescript/components/KeyboardToolbar/compound/components/Background.d.ts +6 -0
  300. package/lib/typescript/components/KeyboardToolbar/compound/components/Content.d.ts +7 -0
  301. package/lib/typescript/components/KeyboardToolbar/compound/components/Done.d.ts +7 -0
  302. package/lib/typescript/components/KeyboardToolbar/compound/components/Next.d.ts +4 -0
  303. package/lib/typescript/components/KeyboardToolbar/compound/components/Prev.d.ts +4 -0
  304. package/lib/typescript/components/KeyboardToolbar/compound/components/index.d.ts +5 -0
  305. package/lib/typescript/components/KeyboardToolbar/compound/components/types.d.ts +14 -0
  306. package/lib/typescript/components/KeyboardToolbar/compound/context.d.ts +9 -0
  307. package/lib/typescript/components/KeyboardToolbar/constants.d.ts +10 -0
  308. package/lib/typescript/components/KeyboardToolbar/index.d.ts +12 -45
  309. package/lib/typescript/components/KeyboardToolbar/types.d.ts +24 -1
  310. package/lib/typescript/components/ScrollViewWithBottomPadding/index.d.ts +30 -0
  311. package/lib/typescript/components/ScrollViewWithBottomPadding/styles.d.ts +7 -0
  312. package/lib/typescript/components/hooks/useCombinedRef.d.ts +3 -0
  313. package/lib/typescript/components/hooks/useScrollState.d.ts +17 -0
  314. package/lib/typescript/components/index.d.ts +3 -0
  315. package/lib/typescript/constants.d.ts +1 -0
  316. package/lib/typescript/context.d.ts +1 -0
  317. package/lib/typescript/hooks/index.d.ts +2 -0
  318. package/lib/typescript/hooks/useKeyboardState/index.d.ts +4 -0
  319. package/lib/typescript/index.d.ts +4 -3
  320. package/lib/typescript/internal.d.ts +4 -0
  321. package/lib/typescript/specs/ClippingScrollViewDecoratorViewNativeComponent.d.ts +10 -0
  322. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
  323. package/lib/typescript/specs/KeyboardToolbarGroupViewNativeComponent.d.ts +6 -0
  324. package/lib/typescript/specs/NativeKeyboardController.d.ts +6 -2
  325. package/lib/typescript/types.d.ts +81 -5
  326. package/lib/typescript/utils/findNodeHandle/index.d.ts +4 -0
  327. package/lib/typescript/utils/findNodeHandle/index.native.d.ts +2 -0
  328. package/lib/typescript/views/KeyboardExtender/index.d.ts +5 -0
  329. package/lib/typescript/views/index.d.ts +1 -0
  330. package/package.json +183 -174
  331. package/src/animated.tsx +248 -255
  332. package/src/architecture.ts +1 -0
  333. package/src/bindings.native.ts +97 -62
  334. package/src/bindings.ts +81 -42
  335. package/src/compat.ts +44 -0
  336. package/src/components/KeyboardAvoidingView/hooks.ts +130 -123
  337. package/src/components/KeyboardAvoidingView/index.tsx +232 -188
  338. package/src/components/KeyboardAwareScrollView/index.tsx +452 -389
  339. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +133 -133
  340. package/src/components/KeyboardAwareScrollView/utils.ts +41 -41
  341. package/src/components/KeyboardChatScrollView/hooks.ts +2 -0
  342. package/src/components/KeyboardChatScrollView/index.tsx +164 -0
  343. package/src/components/KeyboardChatScrollView/types.ts +117 -0
  344. package/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts +268 -0
  345. package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts +260 -0
  346. package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts +374 -0
  347. package/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts +39 -0
  348. package/src/components/KeyboardChatScrollView/useEndVisible.ts +66 -0
  349. package/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts +149 -0
  350. package/src/components/KeyboardStickyView/index.tsx +66 -66
  351. package/src/components/KeyboardToolbar/Arrow.tsx +80 -80
  352. package/src/components/KeyboardToolbar/Button.tsx +98 -98
  353. package/src/components/KeyboardToolbar/colors.native.ts +37 -37
  354. package/src/components/KeyboardToolbar/colors.ts +16 -16
  355. package/src/components/KeyboardToolbar/compound/components/Background.tsx +9 -0
  356. package/src/components/KeyboardToolbar/compound/components/Content.tsx +25 -0
  357. package/src/components/KeyboardToolbar/compound/components/Done.tsx +57 -0
  358. package/src/components/KeyboardToolbar/compound/components/Next.tsx +49 -0
  359. package/src/components/KeyboardToolbar/compound/components/Prev.tsx +49 -0
  360. package/src/components/KeyboardToolbar/compound/components/index.ts +5 -0
  361. package/src/components/KeyboardToolbar/compound/components/types.ts +15 -0
  362. package/src/components/KeyboardToolbar/compound/context.ts +25 -0
  363. package/src/components/KeyboardToolbar/constants.ts +14 -0
  364. package/src/components/KeyboardToolbar/index.tsx +220 -223
  365. package/src/components/KeyboardToolbar/types.ts +72 -40
  366. package/src/components/ScrollViewWithBottomPadding/index.tsx +216 -0
  367. package/src/components/ScrollViewWithBottomPadding/styles.ts +10 -0
  368. package/src/components/hooks/useColorScheme.ts +6 -6
  369. package/src/components/hooks/useCombinedRef.ts +22 -0
  370. package/src/components/hooks/useScrollState.ts +81 -0
  371. package/src/components/index.ts +14 -11
  372. package/src/constants.ts +23 -19
  373. package/src/context.ts +70 -68
  374. package/src/hooks/index.ts +91 -90
  375. package/src/hooks/useKeyboardState/index.ts +52 -0
  376. package/src/hooks/useWindowDimensions/index.android.ts +38 -38
  377. package/src/hooks/useWindowDimensions/index.ts +1 -1
  378. package/src/index.ts +27 -23
  379. package/src/internal.ts +146 -84
  380. package/src/module.ts +64 -52
  381. package/src/reanimated.native.ts +132 -132
  382. package/src/reanimated.ts +29 -29
  383. package/src/specs/ClippingScrollViewDecoratorViewNativeComponent.ts +19 -0
  384. package/src/specs/KeyboardControllerViewNativeComponent.ts +82 -71
  385. package/src/specs/KeyboardGestureAreaNativeComponent.ts +21 -20
  386. package/src/specs/KeyboardToolbarGroupViewNativeComponent.ts +10 -0
  387. package/src/specs/NativeKeyboardController.ts +23 -19
  388. package/src/specs/NativeStatusBarManagerCompat.ts +14 -14
  389. package/src/specs/OverKeyboardViewNativeComponent.ts +12 -12
  390. package/src/types.ts +330 -243
  391. package/src/utils/findNodeHandle/index.native.ts +3 -0
  392. package/src/utils/findNodeHandle/index.ts +6 -0
  393. package/src/utils.ts +1 -1
  394. package/src/views/KeyboardExtender/index.tsx +30 -0
  395. package/src/views/OverKeyboardView/index.tsx +43 -43
  396. package/src/views/index.ts +2 -1
  397. package/lib/commonjs/monkey-patch.android.js +0 -57
  398. package/lib/commonjs/monkey-patch.android.js.map +0 -1
  399. package/lib/commonjs/monkey-patch.js +0 -11
  400. package/lib/commonjs/monkey-patch.js.map +0 -1
  401. package/lib/module/monkey-patch.android.js +0 -47
  402. package/lib/module/monkey-patch.android.js.map +0 -1
  403. package/lib/module/monkey-patch.js +0 -5
  404. package/lib/module/monkey-patch.js.map +0 -1
  405. package/lib/typescript/monkey-patch.android.d.ts +0 -2
  406. package/lib/typescript/monkey-patch.d.ts +0 -2
  407. package/src/monkey-patch.android.ts +0 -44
  408. package/src/monkey-patch.ts +0 -4
@@ -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,
@@ -11,9 +14,9 @@ const defaultLayout = {
11
14
  height: 0
12
15
  };
13
16
 
14
- /**
15
- * View that moves out of the way when the keyboard appears by automatically
16
- * adjusting its height, position, or bottom padding.
17
+ /**
18
+ * View that moves out of the way when the keyboard appears by automatically
19
+ * adjusting its height, position, or bottom padding.
17
20
  */
18
21
  const KeyboardAvoidingView = /*#__PURE__*/forwardRef(({
19
22
  behavior,
@@ -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\";\r\nimport { View } from \"react-native\";\r\nimport Reanimated, {\r\n interpolate,\r\n runOnUI,\r\n useAnimatedStyle,\r\n useDerivedValue,\r\n useSharedValue,\r\n} from \"react-native-reanimated\";\r\n\r\nimport { useWindowDimensions } from \"../../hooks\";\r\n\r\nimport { useKeyboardAnimation, useTranslateAnimation } from \"./hooks\";\r\n\r\nimport type { LayoutRectangle, ViewProps } from \"react-native\";\r\n\r\nexport type KeyboardAvoidingViewBaseProps = {\r\n /**\r\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\r\n * This is useful when more than one is on the screen. Defaults to true.\r\n */\r\n enabled?: boolean;\r\n\r\n /**\r\n * Distance between the top of the user screen and the React Native view. This\r\n * may be non-zero in some cases. Defaults to 0.\r\n */\r\n keyboardVerticalOffset?: number;\r\n} & ViewProps;\r\n\r\nexport type KeyboardAvoidingViewProps = KeyboardAvoidingViewBaseProps &\r\n (\r\n | {\r\n /**\r\n * Specify how to react to the presence of the keyboard.\r\n */\r\n behavior?: \"position\";\r\n\r\n /**\r\n * Style of the content container when `behavior` is 'position'.\r\n */\r\n contentContainerStyle?: ViewProps[\"style\"];\r\n }\r\n | {\r\n /**\r\n * Specify how to react to the presence of the keyboard.\r\n */\r\n behavior?: \"height\" | \"padding\" | \"translate-with-padding\";\r\n\r\n /**\r\n * `contentContainerStyle` is not allowed for these behaviors.\r\n */\r\n contentContainerStyle?: never;\r\n }\r\n );\r\n\r\nconst defaultLayout: LayoutRectangle = {\r\n x: 0,\r\n y: 0,\r\n width: 0,\r\n height: 0,\r\n};\r\n\r\n/**\r\n * View that moves out of the way when the keyboard appears by automatically\r\n * adjusting its height, position, or bottom padding.\r\n */\r\nconst KeyboardAvoidingView = forwardRef<\r\n View,\r\n React.PropsWithChildren<KeyboardAvoidingViewProps>\r\n>(\r\n (\r\n {\r\n behavior,\r\n children,\r\n contentContainerStyle,\r\n enabled = true,\r\n keyboardVerticalOffset = 0,\r\n style,\r\n onLayout: onLayoutProps,\r\n ...props\r\n },\r\n ref,\r\n ) => {\r\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\r\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\r\n\r\n const { translate, padding } = useTranslateAnimation();\r\n const keyboard = useKeyboardAnimation();\r\n const { height: screenHeight } = useWindowDimensions();\r\n\r\n const relativeKeyboardHeight = useCallback(() => {\r\n \"worklet\";\r\n\r\n const keyboardY =\r\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\r\n\r\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\r\n }, [screenHeight, keyboardVerticalOffset]);\r\n const interpolateToRelativeKeyboardHeight = useCallback(\r\n (value: number) => {\r\n \"worklet\";\r\n\r\n return interpolate(value, [0, 1], [0, relativeKeyboardHeight()]);\r\n },\r\n [relativeKeyboardHeight],\r\n );\r\n\r\n const onLayoutWorklet = useCallback((layout: LayoutRectangle) => {\r\n \"worklet\";\r\n\r\n if (keyboard.isClosed.value || initialFrame.value === null) {\r\n // eslint-disable-next-line react-compiler/react-compiler\r\n initialFrame.value = layout;\r\n }\r\n }, []);\r\n const onLayout = useCallback<NonNullable<ViewProps[\"onLayout\"]>>(\r\n (e) => {\r\n runOnUI(onLayoutWorklet)(e.nativeEvent.layout);\r\n onLayoutProps?.(e);\r\n },\r\n [onLayoutProps],\r\n );\r\n\r\n const animatedStyle = useAnimatedStyle(() => {\r\n const bottom = interpolateToRelativeKeyboardHeight(\r\n keyboard.progress.value,\r\n );\r\n const translateY = interpolateToRelativeKeyboardHeight(translate.value);\r\n const paddingBottom = interpolateToRelativeKeyboardHeight(padding.value);\r\n const bottomHeight = enabled ? bottom : 0;\r\n\r\n switch (behavior) {\r\n case \"height\":\r\n if (!keyboard.isClosed.value) {\r\n return {\r\n height: frame.value.height - bottomHeight,\r\n flex: 0,\r\n };\r\n }\r\n\r\n return {};\r\n\r\n case \"position\":\r\n return { bottom: bottomHeight };\r\n\r\n case \"padding\":\r\n return { paddingBottom: bottomHeight };\r\n\r\n case \"translate-with-padding\":\r\n return {\r\n paddingBottom: paddingBottom,\r\n transform: [{ translateY: -translateY}],\r\n };\r\n\r\n default:\r\n return {};\r\n }\r\n }, [behavior, enabled, interpolateToRelativeKeyboardHeight]);\r\n const isPositionBehavior = behavior === \"position\";\r\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\r\n const combinedStyles = useMemo(\r\n () => [containerStyle, animatedStyle],\r\n [containerStyle, animatedStyle],\r\n );\r\n\r\n if (isPositionBehavior) {\r\n return (\r\n <View ref={ref} style={style} onLayout={onLayout} {...props}>\r\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\r\n </View>\r\n );\r\n }\r\n\r\n return (\r\n <Reanimated.View\r\n ref={ref}\r\n onLayout={onLayout}\r\n style={combinedStyles}\r\n {...props}\r\n >\r\n {children}\r\n </Reanimated.View>\r\n );\r\n },\r\n);\r\n\r\nexport default KeyboardAvoidingView;\r\n"],"mappings":";AAAA,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,eAAe,EACfC,cAAc,QACT,yBAAyB;AAEhC,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,SAASC,oBAAoB,EAAEC,qBAAqB,QAAQ,SAAS;AA4CrE,MAAMC,aAA8B,GAAG;EACrCC,CAAC,EAAE,CAAC;EACJC,CAAC,EAAE,CAAC;EACJC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,gBAAGlB,UAAU,CAIrC,CACE;EACEmB,QAAQ;EACRC,QAAQ;EACRC,qBAAqB;EACrBC,OAAO,GAAG,IAAI;EACdC,sBAAsB,GAAG,CAAC;EAC1BC,KAAK;EACLC,QAAQ,EAAEC,aAAa;EACvB,GAAGC;AACL,CAAC,EACDC,GAAG,KACA;EACH,MAAMC,YAAY,GAAGpB,cAAc,CAAyB,IAAI,CAAC;EACjE,MAAMqB,KAAK,GAAGtB,eAAe,CAAC,MAAMqB,YAAY,CAACE,KAAK,IAAIlB,aAAa,CAAC;EAExE,MAAM;IAAEmB,SAAS;IAAEC;EAAQ,CAAC,GAAGrB,qBAAqB,CAAC,CAAC;EACtD,MAAMsB,QAAQ,GAAGvB,oBAAoB,CAAC,CAAC;EACvC,MAAM;IAAEM,MAAM,EAAEkB;EAAa,CAAC,GAAGzB,mBAAmB,CAAC,CAAC;EAEtD,MAAM0B,sBAAsB,GAAGnC,WAAW,CAAC,MAAM;IAC/C,SAAS;;IAET,MAAMoC,SAAS,GACbF,YAAY,GAAG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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,IACfC,WAAW,EACXC,OAAO,EACPC,gBAAgB,EAChBC,eAAe,EACfC,cAAc,QACT,yBAAyB;AAEhC,SAASC,wBAAwB,QAAQ,gBAAgB;AACzD,SAASC,mBAAmB,QAAQ,aAAa;AACjD,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,OAAOC,cAAc,MAAM,yBAAyB;AAEpD,SAASC,oBAAoB,EAAEC,qBAAqB,QAAQ,SAAS;AAkDrE,MAAMC,aAA8B,GAAG;EACrCC,CAAC,EAAE,CAAC;EACJC,CAAC,EAAE,CAAC;EACJC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,gBAAGrB,UAAU,CAIrC,CACE;EACEsB,QAAQ;EACRC,QAAQ;EACRC,qBAAqB;EACrBC,OAAO,GAAG,IAAI;EACdC,sBAAsB,GAAG,CAAC;EAC1BC,eAAe,GAAG,KAAK;EACvBC,KAAK;EACLC,QAAQ,EAAEC,aAAa;EACvB,GAAGC;AACL,CAAC,EACDC,GAAG,KACA;EACH,MAAMC,YAAY,GAAGxB,cAAc,CAAyB,IAAI,CAAC;EACjE,MAAMyB,WAAW,GAAGnC,KAAK,CAACoC,MAAM,CAAc,IAAI,CAAC;EACnD,MAAMC,KAAK,GAAG5B,eAAe,CAAC,MAAMyB,YAAY,CAACI,KAAK,IAAIrB,aAAa,CAAC;EAExE,MAAM;IAAEsB,SAAS;IAAEC;EAAQ,CAAC,GAAGxB,qBAA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AK,SAAS;QACZ,OAAO;UAAEG,aAAa,EAAEH;QAAO,CAAC;MAElC,KAAK,wBAAwB;QAC3B,OAAO;UACLG,aAAa,EAAEA,aAAa;UAC5BE,SAAS,EAAE,CAAC;YAAEH,UAAU,EAAE,CAACA;UAAW,CAAC;QACzC,CAAC;MAEH;QACE,OAAO,CAAC,CAAC;IACb;EACF,CAAC,EAAE,CAACxC,QAAQ,EAAEG,OAAO,EAAEsB,mCAAmC,CAAC,CAAC;EAC5D,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,47 +1,50 @@
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 } 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
- /*
9
- * Everything begins from `onStart` handler. This handler is called every time,
10
- * when keyboard changes its size or when focused `TextInput` was changed. In
11
- * this handler we are calculating/memoizing values which later will be used
12
- * during layout movement. For that we calculate:
13
- * - layout of focused field (`layout`) - to understand whether there will be overlap
14
- * - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation
15
- * - future keyboard height (`keyboardHeight`) - used in scroll interpolation
16
- * - current scroll position (`scrollPosition`) - used to scroll from this point
17
- *
18
- * Once we've calculated all necessary variables - we can actually start to use them.
19
- * It happens in `onMove` handler - this function simply calls `maybeScroll` with
20
- * current keyboard frame height. This functions makes the smooth transition.
21
- *
22
- * When the transition has finished we go to `onEnd` handler. In this handler
23
- * we verify, that the current field is not overlapped within a keyboard frame.
24
- * For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,
25
- * however there could be some cases, when `onMove` is not called:
26
- * - on iOS when TextInput was changed - keyboard transition is instant
27
- * - on Android when TextInput was changed and keyboard size wasn't changed
28
- * So `onEnd` handler handle the case, when `onMove` wasn't triggered.
29
- *
30
- * ====================================================================================================================+
31
- * -----------------------------------------------------Flow chart-----------------------------------------------------+
32
- * ====================================================================================================================+
33
- *
34
- * +============================+ +============================+ +==================================+
35
- * + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>
36
- * + + + (run `onStart`) + + `onMove` is getting called +
37
- * +============================+ +============================+ +==================================+
38
- *
39
- *
40
- * +============================+ +============================+ +=====================================+
41
- * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +
42
- * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +
43
- * +============================+ +============================+ +=====================================+
44
- *
10
+ const IS_HARMONY = Platform.OS === "harmony";
11
+ /*
12
+ * Everything begins from `onStart` handler. This handler is called every time,
13
+ * when keyboard changes its size or when focused `TextInput` was changed. In
14
+ * this handler we are calculating/memoizing values which later will be used
15
+ * during layout movement. For that we calculate:
16
+ * - layout of focused field (`layout`) - to understand whether there will be overlap
17
+ * - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation
18
+ * - future keyboard height (`keyboardHeight`) - used in scroll interpolation
19
+ * - current scroll position (`scrollPosition`) - used to scroll from this point
20
+ *
21
+ * Once we've calculated all necessary variables - we can actually start to use them.
22
+ * It happens in `onMove` handler - this function simply calls `maybeScroll` with
23
+ * current keyboard frame height. This functions makes the smooth transition.
24
+ *
25
+ * When the transition has finished we go to `onEnd` handler. In this handler
26
+ * we verify, that the current field is not overlapped within a keyboard frame.
27
+ * For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,
28
+ * however there could be some cases, when `onMove` is not called:
29
+ * - on iOS when TextInput was changed - keyboard transition is instant
30
+ * - on Android when TextInput was changed and keyboard size wasn't changed
31
+ * So `onEnd` handler handle the case, when `onMove` wasn't triggered.
32
+ *
33
+ * ====================================================================================================================+
34
+ * -----------------------------------------------------Flow chart-----------------------------------------------------+
35
+ * ====================================================================================================================+
36
+ *
37
+ * +============================+ +============================+ +==================================+
38
+ * + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>
39
+ * + + + (run `onStart`) + + `onMove` is getting called +
40
+ * +============================+ +============================+ +==================================+
41
+ *
42
+ *
43
+ * +============================+ +============================+ +=====================================+
44
+ * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +
45
+ * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +
46
+ * +============================+ +============================+ +=====================================+
47
+ *
45
48
  */
46
49
  const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
47
50
  children,
@@ -67,24 +70,31 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
67
70
  input
68
71
  } = useReanimatedFocusedInput();
69
72
  const layout = useSharedValue(null);
73
+ const scrollViewPageY = useSharedValue(0);
70
74
  const {
71
75
  height
72
76
  } = useWindowDimensions();
73
77
  const onRef = useCallback(assignedRef => {
74
- if (typeof ref === "function") {
75
- ref(assignedRef);
76
- } else if (ref) {
77
- ref.current = assignedRef;
78
- }
79
78
  scrollViewAnimatedRef(assignedRef);
80
79
  }, []);
81
- const onScrollViewLayout = useCallback(e => {
82
- scrollViewTarget.value = findNodeHandle(scrollViewAnimatedRef.current);
80
+ const onScrollViewLayout = useCallback(async e => {
81
+ const handle = findNodeHandle(scrollViewAnimatedRef.current);
82
+ scrollViewTarget.value = handle;
83
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
+ }
84
94
  }, [onLayout]);
85
95
 
86
- /**
87
- * Function that will scroll a ScrollView as keyboard gets moving
96
+ /**
97
+ * Function that will scroll a ScrollView as keyboard gets moving
88
98
  */
89
99
  const maybeScroll = useCallback((e, animated = false) => {
90
100
  "worklet";
@@ -109,13 +119,27 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
109
119
  scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);
110
120
  return interpolatedScrollTo;
111
121
  }
112
- if (absoluteY < 0) {
113
- const positionOnScreen = visibleRect - inputHeight - bottomOffset;
114
- const topOfScreen = scrollPosition.value + absoluteY;
122
+ if (point < scrollViewPageY.value) {
123
+ const positionOnScreen = visibleRect - bottomOffset;
124
+ const topOfScreen = scrollPosition.value + point;
115
125
  scrollTo(scrollViewAnimatedRef, 0, topOfScreen - positionOnScreen, animated);
116
126
  }
117
127
  return 0;
118
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]);
119
143
  const syncKeyboardFrame = useCallback(e => {
120
144
  "worklet";
121
145
 
@@ -126,7 +150,6 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
126
150
  "worklet";
127
151
 
128
152
  var _input$value;
129
- const prevScrollPosition = scrollPosition.value;
130
153
  const prevLayout = layout.value;
131
154
  if (!((_input$value = input.value) !== null && _input$value !== void 0 && _input$value.layout)) {
132
155
  return;
@@ -140,11 +163,24 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
140
163
  height: customHeight ?? input.value.layout.height
141
164
  }
142
165
  };
143
- scrollPosition.value = position.value;
144
- maybeScroll(keyboardHeight.value, true);
145
- scrollPosition.value = prevScrollPosition;
166
+ performScrollWithPositionRestoration(position.value);
146
167
  layout.value = prevLayout;
147
- }, [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]);
148
184
  const onChangeText = useCallback(() => {
149
185
  "worklet";
150
186
 
@@ -201,7 +237,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
201
237
  // this value to achieve smooth hide effect
202
238
  scrollBeforeKeyboardMovement.value = position.value;
203
239
  }
204
- if (focusWasChanged && !keyboardWillAppear.value) {
240
+ if (focusWasChanged && (IS_HARMONY || !keyboardWillAppear.value)) {
205
241
  // update position on scroll value, so `onEnd` handler
206
242
  // will pick up correct values
207
243
  position.value += maybeScroll(e.height, true);
@@ -213,7 +249,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
213
249
  syncKeyboardFrame(e);
214
250
 
215
251
  // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens
216
- if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {
252
+ if ((!IS_HARMONY || !keyboardWillAppear.value) && (!disableScrollOnKeyboardHide || keyboardWillAppear.value)) {
217
253
  maybeScroll(e.height);
218
254
  }
219
255
  },
@@ -246,8 +282,9 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
246
282
  ref: onRef
247
283
  }, rest, {
248
284
  onLayout: onScrollViewLayout,
285
+ scrollToOverflowEnabled: IS_HARMONY ? true : rest.scrollToOverflowEnabled,
249
286
  scrollEventThrottle: 16
250
- }), children, /*#__PURE__*/React.createElement(Reanimated.View, {
287
+ }), children, enabled && /*#__PURE__*/React.createElement(Reanimated.View, {
251
288
  style: view
252
289
  }));
253
290
  });
@@ -1 +1 @@
1
- {"version":3,"names":["React","forwardRef","useCallback","useMemo","findNodeHandle","Reanimated","interpolate","scrollTo","useAnimatedReaction","useAnimatedRef","useAnimatedStyle","useScrollViewOffset","useSharedValue","useFocusedInputHandler","useReanimatedFocusedInput","useWindowDimensions","useSmoothKeyboardHandler","debounce","scrollDistanceWithRespectToSnapPoints","KeyboardAwareScrollView","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","ScrollView","rest","ref","scrollViewAnimatedRef","scrollViewTarget","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","layout","height","onRef","assignedRef","current","onScrollViewLayout","e","value","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","snapToOffsets","targetScrollY","Math","max","positionOnScreen","topOfScreen","syncKeyboardFrame","keyboardFrame","scrollFromCurrentPosition","customHeight","_input$value","prevScrollPosition","prevLayout","onChangeText","_layout$value4","_input$value2","onSelectionChange","selection","start","end","y","onChangeTextHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","target","onMove","onEnd","previous","view","paddingBottom","createElement","_extends","scrollEventThrottle","View","style"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\r\nimport { findNodeHandle } from \"react-native\";\r\nimport Reanimated, {\r\n interpolate,\r\n scrollTo,\r\n useAnimatedReaction,\r\n useAnimatedRef,\r\n useAnimatedStyle,\r\n useScrollViewOffset,\r\n useSharedValue,\r\n} from \"react-native-reanimated\";\r\n\r\nimport {\r\n useFocusedInputHandler,\r\n useReanimatedFocusedInput,\r\n useWindowDimensions,\r\n} from \"../../hooks\";\r\n\r\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\r\nimport { debounce, scrollDistanceWithRespectToSnapPoints } from \"./utils\";\r\n\r\nimport type {\r\n LayoutChangeEvent,\r\n ScrollView,\r\n ScrollViewProps,\r\n} from \"react-native\";\r\nimport type {\r\n FocusedInputLayoutChangedEvent,\r\n FocusedInputSelectionChangedEvent,\r\n NativeEvent,\r\n} from \"..//../types\";\r\n\r\nexport type KeyboardAwareScrollViewProps = {\r\n /** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */\r\n bottomOffset?: number;\r\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\r\n disableScrollOnKeyboardHide?: boolean;\r\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */\r\n enabled?: boolean;\r\n /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */\r\n extraKeyboardSpace?: number;\r\n /** Custom component for `ScrollView`. Default is `ScrollView` */\r\n ScrollViewComponent?: React.ComponentType<ScrollViewProps>;\r\n} & ScrollViewProps;\r\n\r\n/*\r\n * Everything begins from `onStart` handler. This handler is called every time,\r\n * when keyboard changes its size or when focused `TextInput` was changed. In\r\n * this handler we are calculating/memoizing values which later will be used\r\n * during layout movement. For that we calculate:\r\n * - layout of focused field (`layout`) - to understand whether there will be overlap\r\n * - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\r\n * - future keyboard height (`keyboardHeight`) - used in scroll interpolation\r\n * - current scroll position (`scrollPosition`) - used to scroll from this point\r\n *\r\n * Once we've calculated all necessary variables - we can actually start to use them.\r\n * It happens in `onMove` handler - this function simply calls `maybeScroll` with\r\n * current keyboard frame height. This functions makes the smooth transition.\r\n *\r\n * When the transition has finished we go to `onEnd` handler. In this handler\r\n * we verify, that the current field is not overlapped within a keyboard frame.\r\n * For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\r\n * however there could be some cases, when `onMove` is not called:\r\n * - on iOS when TextInput was changed - keyboard transition is instant\r\n * - on Android when TextInput was changed and keyboard size wasn't changed\r\n * So `onEnd` handler handle the case, when `onMove` wasn't triggered.\r\n *\r\n * ====================================================================================================================+\r\n * -----------------------------------------------------Flow chart-----------------------------------------------------+\r\n * ====================================================================================================================+\r\n *\r\n * +============================+ +============================+ +==================================+\r\n * + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\r\n * + + + (run `onStart`) + + `onMove` is getting called +\r\n * +============================+ +============================+ +==================================+\r\n *\r\n *\r\n * +============================+ +============================+ +=====================================+\r\n * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\r\n * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\r\n * +============================+ +============================+ +=====================================+\r\n *\r\n */\r\nconst KeyboardAwareScrollView = forwardRef<\r\n ScrollView,\r\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\r\n>(\r\n (\r\n {\r\n children,\r\n onLayout,\r\n bottomOffset = 0,\r\n disableScrollOnKeyboardHide = false,\r\n enabled = true,\r\n extraKeyboardSpace = 0,\r\n ScrollViewComponent = Reanimated.ScrollView,\r\n ...rest\r\n },\r\n ref,\r\n ) => {\r\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\r\n const scrollViewTarget = useSharedValue<number | null>(null);\r\n const scrollPosition = useSharedValue(0);\r\n const position = useScrollViewOffset(scrollViewAnimatedRef);\r\n const currentKeyboardFrameHeight = useSharedValue(0);\r\n const keyboardHeight = useSharedValue(0);\r\n const keyboardWillAppear = useSharedValue(false);\r\n const tag = useSharedValue(-1);\r\n const initialKeyboardSize = useSharedValue(0);\r\n const scrollBeforeKeyboardMovement = useSharedValue(0);\r\n const { input } = useReanimatedFocusedInput();\r\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\r\n\r\n const { height } = useWindowDimensions();\r\n\r\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\r\n if (typeof ref === \"function\") {\r\n ref(assignedRef);\r\n } else if (ref) {\r\n ref.current = assignedRef;\r\n }\r\n\r\n scrollViewAnimatedRef(assignedRef);\r\n }, []);\r\n const onScrollViewLayout = useCallback(\r\n (e: LayoutChangeEvent) => {\r\n scrollViewTarget.value = findNodeHandle(scrollViewAnimatedRef.current);\r\n\r\n onLayout?.(e);\r\n },\r\n [onLayout],\r\n );\r\n\r\n /**\r\n * Function that will scroll a ScrollView as keyboard gets moving\r\n */\r\n const maybeScroll = useCallback(\r\n (e: number, animated: boolean = false) => {\r\n \"worklet\";\r\n\r\n if (!enabled) {\r\n return 0;\r\n }\r\n\r\n // input belongs to ScrollView\r\n if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {\r\n return 0;\r\n }\r\n\r\n const visibleRect = height - keyboardHeight.value;\r\n const absoluteY = layout.value?.layout.absoluteY || 0;\r\n const inputHeight = layout.value?.layout.height || 0;\r\n const point = absoluteY + inputHeight;\r\n\r\n if (visibleRect - point <= bottomOffset) {\r\n const relativeScrollTo =\r\n keyboardHeight.value - (height - point) + bottomOffset;\r\n const interpolatedScrollTo = interpolate(\r\n e,\r\n [initialKeyboardSize.value, keyboardHeight.value],\r\n [\r\n 0,\r\n scrollDistanceWithRespectToSnapPoints(\r\n relativeScrollTo + scrollPosition.value,\r\n rest.snapToOffsets,\r\n ) - scrollPosition.value,\r\n ],\r\n );\r\n const targetScrollY =\r\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\r\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\r\n\r\n return interpolatedScrollTo;\r\n }\r\n\r\n if (absoluteY < 0) {\r\n const positionOnScreen = visibleRect - inputHeight - bottomOffset;\r\n const topOfScreen = scrollPosition.value + absoluteY;\r\n\r\n scrollTo(\r\n scrollViewAnimatedRef,\r\n 0,\r\n topOfScreen - positionOnScreen,\r\n animated,\r\n );\r\n }\r\n\r\n return 0;\r\n },\r\n [bottomOffset, enabled, height, rest.snapToOffsets],\r\n );\r\n\r\n const syncKeyboardFrame = useCallback(\r\n (e: NativeEvent) => {\r\n \"worklet\";\r\n\r\n const keyboardFrame = interpolate(\r\n e.height,\r\n [0, keyboardHeight.value],\r\n [0, keyboardHeight.value + extraKeyboardSpace],\r\n );\r\n\r\n currentKeyboardFrameHeight.value = keyboardFrame;\r\n },\r\n [extraKeyboardSpace],\r\n );\r\n\r\n const scrollFromCurrentPosition = useCallback(\r\n (customHeight?: number) => {\r\n \"worklet\";\r\n\r\n const prevScrollPosition = scrollPosition.value;\r\n const prevLayout = layout.value;\r\n\r\n if (!input.value?.layout) {\r\n return;\r\n }\r\n\r\n // eslint-disable-next-line react-compiler/react-compiler\r\n layout.value = {\r\n ...input.value,\r\n layout: {\r\n ...input.value.layout,\r\n height: customHeight ?? input.value.layout.height,\r\n },\r\n };\r\n scrollPosition.value = position.value;\r\n maybeScroll(keyboardHeight.value, true);\r\n scrollPosition.value = prevScrollPosition;\r\n layout.value = prevLayout;\r\n },\r\n [maybeScroll],\r\n );\r\n const onChangeText = useCallback(() => {\r\n \"worklet\";\r\n\r\n // if typing a text caused layout shift, then we need to ignore this handler\r\n // because this event will be handled in `useAnimatedReaction` below\r\n if (layout.value?.layout.height !== input.value?.layout.height) {\r\n return;\r\n }\r\n\r\n scrollFromCurrentPosition();\r\n }, [scrollFromCurrentPosition]);\r\n const onSelectionChange = useCallback(\r\n (e: FocusedInputSelectionChangedEvent) => {\r\n \"worklet\";\r\n\r\n if (e.selection.start.position !== e.selection.end.position) {\r\n scrollFromCurrentPosition(e.selection.end.y);\r\n }\r\n },\r\n [scrollFromCurrentPosition],\r\n );\r\n\r\n const onChangeTextHandler = useMemo(\r\n () => debounce(onChangeText, 200),\r\n [onChangeText],\r\n );\r\n\r\n useFocusedInputHandler(\r\n {\r\n onChangeText: onChangeTextHandler,\r\n onSelectionChange: onSelectionChange,\r\n },\r\n [onChangeTextHandler, onSelectionChange],\r\n );\r\n\r\n useSmoothKeyboardHandler(\r\n {\r\n onStart: (e) => {\r\n \"worklet\";\r\n\r\n const keyboardWillChangeSize =\r\n keyboardHeight.value !== e.height && e.height > 0;\r\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\r\n const keyboardWillHide = e.height === 0;\r\n const focusWasChanged =\r\n (tag.value !== e.target && e.target !== -1) ||\r\n keyboardWillChangeSize;\r\n\r\n if (keyboardWillChangeSize) {\r\n initialKeyboardSize.value = keyboardHeight.value;\r\n }\r\n\r\n if (keyboardWillHide) {\r\n // on back transition need to interpolate as [0, keyboardHeight]\r\n initialKeyboardSize.value = 0;\r\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\r\n }\r\n\r\n if (\r\n keyboardWillAppear.value ||\r\n keyboardWillChangeSize ||\r\n focusWasChanged\r\n ) {\r\n // persist scroll value\r\n scrollPosition.value = position.value;\r\n // just persist height - later will be used in interpolation\r\n keyboardHeight.value = e.height;\r\n }\r\n\r\n // focus was changed\r\n if (focusWasChanged) {\r\n tag.value = e.target;\r\n\r\n // save position of focused text input when keyboard starts to move\r\n layout.value = input.value;\r\n // save current scroll position - when keyboard will hide we'll reuse\r\n // this value to achieve smooth hide effect\r\n scrollBeforeKeyboardMovement.value = position.value;\r\n }\r\n\r\n if (focusWasChanged && !keyboardWillAppear.value) {\r\n // update position on scroll value, so `onEnd` handler\r\n // will pick up correct values\r\n position.value += maybeScroll(e.height, true);\r\n }\r\n },\r\n onMove: (e) => {\r\n \"worklet\";\r\n\r\n syncKeyboardFrame(e);\r\n\r\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\r\n if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\r\n maybeScroll(e.height);\r\n }\r\n },\r\n onEnd: (e) => {\r\n \"worklet\";\r\n\r\n keyboardHeight.value = e.height;\r\n scrollPosition.value = position.value;\r\n\r\n syncKeyboardFrame(e);\r\n },\r\n },\r\n [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame],\r\n );\r\n\r\n useAnimatedReaction(\r\n () => input.value,\r\n (current, previous) => {\r\n if (\r\n current?.target === previous?.target &&\r\n current?.layout.height !== previous?.layout.height\r\n ) {\r\n const prevLayout = layout.value;\r\n\r\n layout.value = input.value;\r\n scrollPosition.value += maybeScroll(keyboardHeight.value, true);\r\n layout.value = prevLayout;\r\n }\r\n },\r\n [],\r\n );\r\n\r\n const view = useAnimatedStyle(\r\n () =>\r\n enabled\r\n ? {\r\n // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)\r\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\r\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\r\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\r\n // re-calculation on every animation frame and it helps to achieve smooth animation.\r\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\r\n paddingBottom: currentKeyboardFrameHeight.value + 1,\r\n }\r\n : {},\r\n [enabled],\r\n );\r\n\r\n return (\r\n <ScrollViewComponent\r\n ref={onRef}\r\n {...rest}\r\n onLayout={onScrollViewLayout}\r\n scrollEventThrottle={16}\r\n >\r\n {children}\r\n <Reanimated.View style={view} />\r\n </ScrollViewComponent>\r\n );\r\n },\r\n);\r\n\r\nexport default KeyboardAwareScrollView;\r\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,cAAc,QAAQ,cAAc;AAC7C,OAAOC,UAAU,IACfC,WAAW,EACXC,QAAQ,EACRC,mBAAmB,EACnBC,cAAc,EACdC,gBAAgB,EAChBC,mBAAmB,EACnBC,cAAc,QACT,yBAAyB;AAEhC,SACEC,sBAAsB,EACtBC,yBAAyB,EACzBC,mBAAmB,QACd,aAAa;AAEpB,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,QAAQ,EAAEC,qCAAqC,QAAQ,SAAS;AA0BzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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C,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEJ,MAAM,CAACC,MAAM,OAAKgD,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEjD,MAAM,CAACC,MAAM,GAClD;MACA,MAAM+B,UAAU,GAAGhC,MAAM,CAACO,KAAK;MAE/BP,MAAM,CAACO,KAAK,GAAGR,KAAK,CAACQ,KAAK;MAC1BhB,cAAc,CAACgB,KAAK,IAAIC,WAAW,CAACd,cAAc,CAACa,KAAK,EAAE,IAAI,CAAC;MAC/DP,MAAM,CAACO,KAAK,GAAGyB,UAAU;IAC3B;EACF,CAAC,EACD,EACF,CAAC;EAED,MAAMkB,IAAI,GAAGjF,gBAAgB,CAC3B,MACEc,OAAO,GACH;IACA;IACA;IACA;IACA;IACA;IACA;IACAoE,aAAa,EAAE1D,0BAA0B,CAACc,KAAK,GAAG;EACpD,CAAC,GACC,CAAC,CAAC,EACR,CAACxB,OAAO,CACV,CAAC;EAED,oBACExB,KAAA,CAAA6F,aAAA,CAACnE,mBAAmB,EAAAoE,QAAA;IAClBjE,GAAG,EAAEc;EAAM,GACPf,IAAI;IACRP,QAAQ,EAAEyB,kBAAmB;IAC7BiD,mBAAmB,EAAE;EAAG,IAEvB3E,QAAQ,eACTpB,KAAA,CAAA6F,aAAA,CAACxF,UAAU,CAAC2F,IAAI;IAACC,KAAK,EAAEN;EAAK,CAAE,CACZ,CAAC;AAE1B,CACF,CAAC;AAED,eAAexE,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","Platform","Reanimated","interpolate","runOnUI","scrollTo","useAnimatedReaction","useAnimatedRef","useAnimatedStyle","useScrollViewOffset","useSharedValue","KeyboardControllerNative","useFocusedInputHandler","useReanimatedFocusedInput","useWindowDimensions","findNodeHandle","useSmoothKeyboardHandler","debounce","scrollDistanceWithRespectToSnapPoints","IS_HARMONY","OS","KeyboardAwareScrollView","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","ScrollView","rest","ref","scrollViewAnimatedRef","scrollViewTarget","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","layout","scrollViewPageY","height","onRef","assignedRef","onScrollViewLayout","e","handle","current","value","y","viewPositionInWindow","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","snapToOffsets","targetScrollY","Math","max","positionOnScreen","topOfScreen","performScrollWithPositionRestoration","newPosition","prevScrollPosition","syncKeyboardFrame","keyboardFrame","scrollFromCurrentPosition","customHeight","_input$value","prevLayout","assureFocusedInputVisible","Object","assign","onChangeText","_layout$value4","_input$value2","onSelectionChange","selection","start","end","onChangeTextHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","target","onMove","onEnd","previous","view","paddingBottom","createElement","_extends","scrollToOverflowEnabled","scrollEventThrottle","View","style"],"sources":["index.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n} from \"react\";\nimport { Platform } from \"react-native\";\nimport Reanimated, {\n interpolate,\n runOnUI,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedStyle,\n useScrollViewOffset,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { KeyboardControllerNative } from \"../../bindings\";\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n useWindowDimensions,\n} from \"../../hooks\";\nimport { findNodeHandle } from \"../../utils/findNodeHandle\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce, scrollDistanceWithRespectToSnapPoints } from \"./utils\";\n\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type {\n FocusedInputLayoutChangedEvent,\n FocusedInputSelectionChangedEvent,\n NativeEvent,\n} from \"..//../types\";\n\nconst IS_HARMONY = (Platform.OS as string) === \"harmony\";\n\nexport type KeyboardAwareScrollViewProps = {\n /** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */\n bottomOffset?: number;\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\n disableScrollOnKeyboardHide?: boolean;\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */\n enabled?: boolean;\n /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */\n extraKeyboardSpace?: number;\n /** Custom component for `ScrollView`. Default is `ScrollView` */\n ScrollViewComponent?: React.ComponentType<ScrollViewProps>;\n} & ScrollViewProps;\n\nexport type KeyboardAwareScrollViewRef = ScrollView & {\n assureFocusedInputVisible: () => void;\n};\n\n/*\n * Everything begins from `onStart` handler. This handler is called every time,\n * when keyboard changes its size or when focused `TextInput` was changed. In\n * this handler we are calculating/memoizing values which later will be used\n * during layout movement. For that we calculate:\n * - layout of focused field (`layout`) - to understand whether there will be overlap\n * - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n * - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n * - current scroll position (`scrollPosition`) - used to scroll from this point\n *\n * Once we've calculated all necessary variables - we can actually start to use them.\n * It happens in `onMove` handler - this function simply calls `maybeScroll` with\n * current keyboard frame height. This functions makes the smooth transition.\n *\n * When the transition has finished we go to `onEnd` handler. In this handler\n * we verify, that the current field is not overlapped within a keyboard frame.\n * For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n * however there could be some cases, when `onMove` is not called:\n * - on iOS when TextInput was changed - keyboard transition is instant\n * - on Android when TextInput was changed and keyboard size wasn't changed\n * So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n *\n * ====================================================================================================================+\n * -----------------------------------------------------Flow chart-----------------------------------------------------+\n * ====================================================================================================================+\n *\n * +============================+ +============================+ +==================================+\n * + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n * + + + (run `onStart`) + + `onMove` is getting called +\n * +============================+ +============================+ +==================================+\n *\n *\n * +============================+ +============================+ +=====================================+\n * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n * +============================+ +============================+ +=====================================+\n *\n */\nconst KeyboardAwareScrollView = forwardRef<\n KeyboardAwareScrollViewRef,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n extraKeyboardSpace = 0,\n ScrollViewComponent = Reanimated.ScrollView,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const position = useScrollViewOffset(scrollViewAnimatedRef);\n const currentKeyboardFrameHeight = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const keyboardWillAppear = useSharedValue(false);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const scrollViewPageY = useSharedValue(0);\n\n const { height } = useWindowDimensions();\n\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\n scrollViewAnimatedRef(assignedRef);\n }, []);\n const onScrollViewLayout = useCallback(\n async (e: LayoutChangeEvent) => {\n const handle = findNodeHandle(scrollViewAnimatedRef.current);\n\n scrollViewTarget.value = handle;\n\n onLayout?.(e);\n\n if (handle !== null) {\n try {\n const { y } =\n await KeyboardControllerNative.viewPositionInWindow(handle);\n\n scrollViewPageY.value = y;\n } catch {\n // Keep the previous top boundary when the view is not mounted yet.\n }\n }\n },\n [onLayout],\n );\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n \"worklet\";\n\n if (!enabled) {\n return 0;\n }\n\n // input belongs to ScrollView\n if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {\n return 0;\n }\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const relativeScrollTo =\n keyboardHeight.value - (height - point) + bottomOffset;\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [\n 0,\n scrollDistanceWithRespectToSnapPoints(\n relativeScrollTo + scrollPosition.value,\n rest.snapToOffsets,\n ) - scrollPosition.value,\n ],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (point < scrollViewPageY.value) {\n const positionOnScreen = visibleRect - bottomOffset;\n const topOfScreen = scrollPosition.value + point;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled, height, rest.snapToOffsets],\n );\n const performScrollWithPositionRestoration = useCallback(\n (newPosition: number) => {\n \"worklet\";\n\n const prevScrollPosition = scrollPosition.value;\n\n // eslint-disable-next-line react-compiler/react-compiler\n scrollPosition.value = newPosition;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScrollPosition;\n },\n [maybeScroll],\n );\n\n useEffect(() => {\n // Recalculate from the pre-keyboard position to avoid accumulating an already applied offset.\n runOnUI(performScrollWithPositionRestoration)(\n scrollBeforeKeyboardMovement.value,\n );\n }, [bottomOffset]);\n\n const syncKeyboardFrame = useCallback(\n (e: NativeEvent) => {\n \"worklet\";\n\n const keyboardFrame = interpolate(\n e.height,\n [0, keyboardHeight.value],\n [0, keyboardHeight.value + extraKeyboardSpace],\n );\n\n currentKeyboardFrameHeight.value = keyboardFrame;\n },\n [extraKeyboardSpace],\n );\n\n const scrollFromCurrentPosition = useCallback(\n (customHeight?: number) => {\n \"worklet\";\n\n const prevLayout = layout.value;\n\n if (!input.value?.layout) {\n return;\n }\n\n // eslint-disable-next-line react-compiler/react-compiler\n layout.value = {\n ...input.value,\n layout: {\n ...input.value.layout,\n height: customHeight ?? input.value.layout.height,\n },\n };\n performScrollWithPositionRestoration(position.value);\n layout.value = prevLayout;\n },\n [performScrollWithPositionRestoration],\n );\n const assureFocusedInputVisible = useCallback(() => {\n runOnUI(scrollFromCurrentPosition)();\n }, [scrollFromCurrentPosition]);\n\n useImperativeHandle(\n ref,\n () => {\n const current = scrollViewAnimatedRef.current;\n if (current) {\n Object.assign(current, { assureFocusedInputVisible });\n return current as unknown as KeyboardAwareScrollViewRef;\n }\n\n return { assureFocusedInputVisible } as KeyboardAwareScrollViewRef;\n },\n [assureFocusedInputVisible],\n );\n const onChangeText = useCallback(() => {\n \"worklet\";\n\n // if typing a text caused layout shift, then we need to ignore this handler\n // because this event will be handled in `useAnimatedReaction` below\n if (layout.value?.layout.height !== input.value?.layout.height) {\n return;\n }\n\n scrollFromCurrentPosition();\n }, [scrollFromCurrentPosition]);\n const onSelectionChange = useCallback(\n (e: FocusedInputSelectionChangedEvent) => {\n \"worklet\";\n\n if (e.selection.start.position !== e.selection.end.position) {\n scrollFromCurrentPosition(e.selection.end.y);\n }\n },\n [scrollFromCurrentPosition],\n );\n\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n\n useFocusedInputHandler(\n {\n onChangeText: onChangeTextHandler,\n onSelectionChange: onSelectionChange,\n },\n [onChangeTextHandler, onSelectionChange],\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) ||\n keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n }\n\n if (\n keyboardWillAppear.value ||\n keyboardWillChangeSize ||\n focusWasChanged\n ) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n\n // save position of focused text input when keyboard starts to move\n layout.value = input.value;\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && (IS_HARMONY || !keyboardWillAppear.value)) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n syncKeyboardFrame(e);\n\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\n if (\n (!IS_HARMONY || !keyboardWillAppear.value) &&\n (!disableScrollOnKeyboardHide || keyboardWillAppear.value)\n ) {\n maybeScroll(e.height);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n\n syncKeyboardFrame(e);\n },\n },\n [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame],\n );\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n const prevLayout = layout.value;\n\n layout.value = input.value;\n scrollPosition.value += maybeScroll(keyboardHeight.value, true);\n layout.value = prevLayout;\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () =>\n enabled\n ? {\n // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\n // re-calculation on every animation frame and it helps to achieve smooth animation.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n paddingBottom: currentKeyboardFrameHeight.value + 1,\n }\n : {},\n [enabled],\n );\n\n return (\n <ScrollViewComponent\n ref={onRef}\n {...rest}\n onLayout={onScrollViewLayout}\n scrollToOverflowEnabled={\n IS_HARMONY ? true : rest.scrollToOverflowEnabled\n }\n scrollEventThrottle={16}\n >\n {children}\n {enabled && <Reanimated.View style={view} />}\n </ScrollViewComponent>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";AAAA,OAAOA,KAAK,IACVC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,QACF,OAAO;AACd,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,UAAU,IACfC,WAAW,EACXC,OAAO,EACPC,QAAQ,EACRC,mBAAmB,EACnBC,cAAc,EACdC,gBAAgB,EAChBC,mBAAmB,EACnBC,cAAc,QACT,yBAAyB;AAEhC,SAASC,wBAAwB,QAAQ,gBAAgB;AACzD,SACEC,sBAAsB,EACtBC,yBAAyB,EACzBC,mBAAmB,QACd,aAAa;AACpB,SAASC,cAAc,QAAQ,4BAA4B;AAE3D,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,QAAQ,EAAEC,qCAAqC,QAAQ,SAAS;AAazE,MAAMC,UAAU,GAAIlB,QAAQ,CAACmB,EAAE,KAAgB,SAAS;AAmBxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AK,IAAIG,WAAW,CAAClB,cAAc,CAACe,KAAK,EAAE,IAAI,CAAC;MAC/DT,MAAM,CAACS,KAAK,GAAG6B,UAAU;IAC3B;EACF,CAAC,EACD,EACF,CAAC;EAED,MAAMoB,IAAI,GAAG7F,gBAAgB,CAC3B,MACEkB,OAAO,GACH;IACA;IACA;IACA;IACA;IACA;IACA;IACA4E,aAAa,EAAElE,0BAA0B,CAACgB,KAAK,GAAG;EACpD,CAAC,GACC,CAAC,CAAC,EACR,CAAC1B,OAAO,CACV,CAAC;EAED,oBACE/B,KAAA,CAAA4G,aAAA,CAAC3E,mBAAmB,EAAA4E,QAAA;IAClBzE,GAAG,EAAEe;EAAM,GACPhB,IAAI;IACRP,QAAQ,EAAEyB,kBAAmB;IAC7ByD,uBAAuB,EACrBtF,UAAU,GAAG,IAAI,GAAGW,IAAI,CAAC2E,uBAC1B;IACDC,mBAAmB,EAAE;EAAG,IAEvBpF,QAAQ,EACRI,OAAO,iBAAI/B,KAAA,CAAA4G,aAAA,CAACrG,UAAU,CAACyG,IAAI;IAACC,KAAK,EAAEP;EAAK,CAAE,CACxB,CAAC;AAE1B,CACF,CAAC;AAED,eAAehF,uBAAuB","ignoreList":[]}
@@ -12,9 +12,9 @@ const TELEGRAM_ANDROID_TIMING_CONFIG = {
12
12
  easing: Easing.bezier(0.19919472913616398, 0.010644531250000006, 0.27920937042459737, 0.91025390625)
13
13
  };
14
14
 
15
- /**
16
- * Hook that uses default transitions for iOS and Android > 11, and uses
17
- * custom interpolation on Android < 11 to achieve more smooth animation
15
+ /**
16
+ * Hook that uses default transitions for iOS and Android > 11, and uses
17
+ * custom interpolation on Android < 11 to achieve more smooth animation
18
18
  */
19
19
  export const useSmoothKeyboardHandler = (handler, deps) => {
20
20
  const target = useSharedValue(-1);
@@ -51,8 +51,8 @@ export const useSmoothKeyboardHandler = (handler, deps) => {
51
51
  persistedHeight.value = height.value;
52
52
  }
53
53
  },
54
- // REA uses own version of `DependencyList` and it's not compatible with the same type from React
55
- deps);
54
+ // create shallow copy (if deps specified) since `useAnimatedReaction` modifies them
55
+ deps ? [...deps] : deps);
56
56
  useKeyboardHandler({
57
57
  onStart: e => {
58
58
  "worklet";
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","Easing","useAnimatedReaction","useSharedValue","withTiming","useKeyboardHandler","IS_ANDROID_ELEVEN_OR_HIGHER","OS","Version","IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS","TELEGRAM_ANDROID_TIMING_CONFIG","duration","easing","bezier","useSmoothKeyboardHandler","handler","deps","target","height","persistedHeight","animatedKeyboardHeight","value","event","progress","evt","_handler$onMove","onMove","call","_handler$onEnd","onEnd","onStart","e","_handler$onStart2","_handler$onStart","_handler$onEnd2","_handler$onMove2","_handler$onEnd3"],"sources":["useSmoothKeyboardHandler.ts"],"sourcesContent":["import { Platform } from \"react-native\";\r\nimport {\r\n Easing,\r\n useAnimatedReaction,\r\n useSharedValue,\r\n withTiming,\r\n} from \"react-native-reanimated\";\r\n\r\nimport { useKeyboardHandler } from \"../../hooks\";\r\n\r\nconst IS_ANDROID_ELEVEN_OR_HIGHER =\r\n Platform.OS === \"android\" && Platform.Version >= 30;\r\n// on these platforms keyboard transitions will be smooth\r\nconst IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS =\r\n IS_ANDROID_ELEVEN_OR_HIGHER || Platform.OS === \"ios\" || Platform.OS as string === 'harmony';\r\n// on Android Telegram is not using androidx.core values and uses custom interpolation\r\n// duration is taken from here: https://github.com/DrKLO/Telegram/blob/e9a35cea54c06277c69d41b8e25d94b5d7ede065/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AdjustPanLayoutHelper.java#L39\r\n// and bezier is taken from: https://github.com/DrKLO/Telegram/blob/e9a35cea54c06277c69d41b8e25d94b5d7ede065/TMessagesProj/src/main/java/androidx/recyclerview/widget/ChatListItemAnimator.java#L40\r\nconst TELEGRAM_ANDROID_TIMING_CONFIG = {\r\n duration: 250,\r\n easing: Easing.bezier(\r\n 0.19919472913616398,\r\n 0.010644531250000006,\r\n 0.27920937042459737,\r\n 0.91025390625,\r\n ),\r\n};\r\n\r\n/**\r\n * Hook that uses default transitions for iOS and Android > 11, and uses\r\n * custom interpolation on Android < 11 to achieve more smooth animation\r\n */\r\nexport const useSmoothKeyboardHandler: typeof useKeyboardHandler = (\r\n handler,\r\n deps,\r\n) => {\r\n const target = useSharedValue(-1);\r\n const height = useSharedValue(0);\r\n const persistedHeight = useSharedValue(0);\r\n const animatedKeyboardHeight = useSharedValue(0);\r\n\r\n useAnimatedReaction(\r\n () => {\r\n if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\r\n return;\r\n }\r\n if (persistedHeight.value === 0) {\r\n return;\r\n }\r\n const event = {\r\n // it'll be always `TELEGRAM_ANDROID_TIMING_CONFIG.duration`, since we're running animation via `withTiming`\r\n duration: TELEGRAM_ANDROID_TIMING_CONFIG.duration,\r\n target: target.value,\r\n height: animatedKeyboardHeight.value,\r\n progress: animatedKeyboardHeight.value / persistedHeight.value,\r\n };\r\n return event;\r\n },\r\n (evt) => {\r\n if (!evt) {\r\n return;\r\n }\r\n handler.onMove?.(evt);\r\n\r\n // dispatch `onEnd`\r\n if (evt.height === height.value) {\r\n handler.onEnd?.(evt);\r\n // eslint-disable-next-line react-compiler/react-compiler\r\n persistedHeight.value = height.value;\r\n }\r\n },\r\n // REA uses own version of `DependencyList` and it's not compatible with the same type from React\r\n deps as unknown[],\r\n );\r\n\r\n useKeyboardHandler(\r\n {\r\n onStart: (e) => {\r\n \"worklet\";\r\n\r\n // immediately dispatch onStart/onEnd events if onStart dispatched with the same height\r\n // and don't wait for animation 250ms\r\n if (\r\n !IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS &&\r\n e.height === persistedHeight.value\r\n ) {\r\n handler.onStart?.(e);\r\n handler.onEnd?.(e);\r\n\r\n return;\r\n }\r\n\r\n target.value = e.target;\r\n height.value = e.height;\r\n\r\n if (e.height > 0) {\r\n persistedHeight.value = e.height;\r\n }\r\n // if we are running on Android < 9, then we are using custom interpolation\r\n // to achieve smoother animation and use `animatedKeyboardHeight` as animation\r\n // driver\r\n if (!IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\r\n animatedKeyboardHeight.value = withTiming(\r\n e.height,\r\n TELEGRAM_ANDROID_TIMING_CONFIG,\r\n );\r\n }\r\n\r\n handler.onStart?.({\r\n ...e,\r\n duration: IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS\r\n ? e.duration\r\n : TELEGRAM_ANDROID_TIMING_CONFIG.duration,\r\n });\r\n },\r\n onMove: (e) => {\r\n \"worklet\";\r\n\r\n if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\r\n handler.onMove?.(e);\r\n }\r\n },\r\n onEnd: (e) => {\r\n \"worklet\";\r\n\r\n if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\r\n handler.onEnd?.(e);\r\n }\r\n },\r\n },\r\n deps,\r\n );\r\n};\r\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SACEC,MAAM,EACNC,mBAAmB,EACnBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAEhC,SAASC,kBAAkB,QAAQ,aAAa;AAEhD,MAAMC,2BAA2B,GAC/BN,QAAQ,CAACO,EAAE,KAAK,SAAS,IAAIP,QAAQ,CAACQ,OAAO,IAAI,EAAE;AACrD;AACA,MAAMC,kCAAkC,GACtCH,2BAA2B,IAAIN,QAAQ,CAACO,EAAE,KAAK,KAAK,IAAIP,QAAQ,CAACO,EAAE,KAAe,SAAS;AAC7F;AACA;AACA;AACA,MAAMG,8BAA8B,GAAG;EACrCC,QAAQ,EAAE,GAAG;EACbC,MAAM,EAAEX,MAAM,CAACY,MAAM,CACnB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,aACF;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAmD,GAAGA,CACjEC,OAAO,EACPC,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B,eAAA;QACtC,CAAAA,eAAA,GAAArB,OAAO,CAACc,KAAK,cAAAO,eAAA,eAAbA,eAAA,CAAAT,IAAA,CAAAZ,OAAO,EAASgB,CAAC,CAAC;MACpB;IACF;EACF,CAAC,EACDf,IACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Platform","Easing","useAnimatedReaction","useSharedValue","withTiming","useKeyboardHandler","IS_ANDROID_ELEVEN_OR_HIGHER","OS","Version","IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS","TELEGRAM_ANDROID_TIMING_CONFIG","duration","easing","bezier","useSmoothKeyboardHandler","handler","deps","target","height","persistedHeight","animatedKeyboardHeight","value","event","progress","evt","_handler$onMove","onMove","call","_handler$onEnd","onEnd","onStart","e","_handler$onStart2","_handler$onStart","_handler$onEnd2","_handler$onMove2","_handler$onEnd3"],"sources":["useSmoothKeyboardHandler.ts"],"sourcesContent":["import { Platform } from \"react-native\";\nimport {\n Easing,\n useAnimatedReaction,\n useSharedValue,\n withTiming,\n} from \"react-native-reanimated\";\n\nimport { useKeyboardHandler } from \"../../hooks\";\n\nconst IS_ANDROID_ELEVEN_OR_HIGHER =\n Platform.OS === \"android\" && Platform.Version >= 30;\n// on these platforms keyboard transitions will be smooth\nconst IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS =\n IS_ANDROID_ELEVEN_OR_HIGHER || Platform.OS === \"ios\" || Platform.OS as string === 'harmony';\n// on Android Telegram is not using androidx.core values and uses custom interpolation\n// duration is taken from here: https://github.com/DrKLO/Telegram/blob/e9a35cea54c06277c69d41b8e25d94b5d7ede065/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AdjustPanLayoutHelper.java#L39\n// and bezier is taken from: https://github.com/DrKLO/Telegram/blob/e9a35cea54c06277c69d41b8e25d94b5d7ede065/TMessagesProj/src/main/java/androidx/recyclerview/widget/ChatListItemAnimator.java#L40\nconst TELEGRAM_ANDROID_TIMING_CONFIG = {\n duration: 250,\n easing: Easing.bezier(\n 0.19919472913616398,\n 0.010644531250000006,\n 0.27920937042459737,\n 0.91025390625,\n ),\n};\n\n/**\n * Hook that uses default transitions for iOS and Android > 11, and uses\n * custom interpolation on Android < 11 to achieve more smooth animation\n */\nexport const useSmoothKeyboardHandler: typeof useKeyboardHandler = (\n handler,\n deps,\n) => {\n const target = useSharedValue(-1);\n const height = useSharedValue(0);\n const persistedHeight = useSharedValue(0);\n const animatedKeyboardHeight = useSharedValue(0);\n\n useAnimatedReaction(\n () => {\n if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\n return;\n }\n if (persistedHeight.value === 0) {\n return;\n }\n const event = {\n // it'll be always `TELEGRAM_ANDROID_TIMING_CONFIG.duration`, since we're running animation via `withTiming`\n duration: TELEGRAM_ANDROID_TIMING_CONFIG.duration,\n target: target.value,\n height: animatedKeyboardHeight.value,\n progress: animatedKeyboardHeight.value / persistedHeight.value,\n };\n return event;\n },\n (evt) => {\n if (!evt) {\n return;\n }\n handler.onMove?.(evt);\n\n // dispatch `onEnd`\n if (evt.height === height.value) {\n handler.onEnd?.(evt);\n // eslint-disable-next-line react-compiler/react-compiler\n persistedHeight.value = height.value;\n }\n },\n // create shallow copy (if deps specified) since `useAnimatedReaction` modifies them\n deps ? [...deps] : deps,\n );\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n // immediately dispatch onStart/onEnd events if onStart dispatched with the same height\n // and don't wait for animation 250ms\n if (\n !IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS &&\n e.height === persistedHeight.value\n ) {\n handler.onStart?.(e);\n handler.onEnd?.(e);\n\n return;\n }\n\n target.value = e.target;\n height.value = e.height;\n\n if (e.height > 0) {\n persistedHeight.value = e.height;\n }\n // if we are running on Android < 9, then we are using custom interpolation\n // to achieve smoother animation and use `animatedKeyboardHeight` as animation\n // driver\n if (!IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\n animatedKeyboardHeight.value = withTiming(\n e.height,\n TELEGRAM_ANDROID_TIMING_CONFIG,\n );\n }\n\n handler.onStart?.({\n ...e,\n duration: IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS\n ? e.duration\n : TELEGRAM_ANDROID_TIMING_CONFIG.duration,\n });\n },\n onMove: (e) => {\n \"worklet\";\n\n if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\n handler.onMove?.(e);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\n handler.onEnd?.(e);\n }\n },\n },\n deps,\n );\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SACEC,MAAM,EACNC,mBAAmB,EACnBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAEhC,SAASC,kBAAkB,QAAQ,aAAa;AAEhD,MAAMC,2BAA2B,GAC/BN,QAAQ,CAACO,EAAE,KAAK,SAAS,IAAIP,QAAQ,CAACQ,OAAO,IAAI,EAAE;AACrD;AACA,MAAMC,kCAAkC,GACtCH,2BAA2B,IAAIN,QAAQ,CAACO,EAAE,KAAK,KAAK,IAAIP,QAAQ,CAACO,EAAE,KAAe,SAAS;AAC7F;AACA;AACA;AACA,MAAMG,8BAA8B,GAAG;EACrCC,QAAQ,EAAE,GAAG;EACbC,MAAM,EAAEX,MAAM,CAACY,MAAM,CACnB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,aACF;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAmD,GAAGA,CACjEC,OAAO,EACPC,IAAI,KACD;EACH,MAAMC,MAAM,GAAGd,cAAc,CAAC,CAAC,CAAC,CAAC;EACjC,MAAMe,MAAM,GAAGf,cAAc,CAAC,CAAC,CAAC;EAChC,MAAMgB,eAAe,GAAGhB,cAAc,CAAC,CAAC,CAAC;EACzC,MAAMiB,sBAAsB,GAAGjB,cAAc,CAAC,CAAC,CAAC;EAEhDD,mBAAmB,CACjB,MAAM;IACJ,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names":["debounce","worklet","wait","value","time","args","t","Date","now","scrollDistanceWithRespectToSnapPoints","defaultScrollValue","snapPoints","snapPoint","find","offset"],"sources":["utils.ts"],"sourcesContent":["export const debounce = <F extends (...args: Parameters<F>) => ReturnType<F>>(\r\n worklet: F,\r\n wait = 0,\r\n) => {\r\n \"worklet\";\r\n\r\n const value = {\r\n time: 0,\r\n };\r\n\r\n return (...args: Parameters<F>): ReturnType<F> | void => {\r\n \"worklet\";\r\n\r\n const t = Date.now();\r\n const now = t - value.time;\r\n\r\n if (now < wait) {\r\n value.time = t;\r\n return;\r\n }\r\n\r\n value.time = t;\r\n\r\n return worklet(...args);\r\n };\r\n};\r\n\r\nexport const scrollDistanceWithRespectToSnapPoints = (\r\n defaultScrollValue: number,\r\n snapPoints?: number[],\r\n) => {\r\n \"worklet\";\r\n\r\n let snapPoint: number | undefined;\r\n\r\n if (snapPoints) {\r\n snapPoint = snapPoints.find((offset) => offset >= defaultScrollValue);\r\n }\r\n\r\n return snapPoint ?? defaultScrollValue;\r\n};\r\n"],"mappings":"AAAA,OAAO,MAAMA,QAAQ,GAAGA,CACtBC,OAAU,EACVC,IAAI,GAAG,CAAC,KACL;EACH,SAAS;;EAET,MAAMC,KAAK,GAAG;IACZC,IAAI,EAAE;EACR,CAAC;EAED,OAAO,CAAC,GAAGC,IAAmB,KAA2B;IACvD,SAAS;;IAET,MAAMC,CAAC,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;IACpB,MAAMA,GAAG,GAAGF,CAAC,GAAGH,KAAK,CAACC,IAAI;IAE1B,IAAII,GAAG,GAAGN,IAAI,EAAE;MACdC,KAAK,CAACC,IAAI,GAAGE,CAAC;MACd;IACF;IAEAH,KAAK,CAACC,IAAI,GAAGE,CAAC;IAEd,OAAOL,OAAO,CAAC,GAAGI,IAAI,CAAC;EACzB,CAAC;AACH,CAAC;AAED,OAAO,MAAMI,qCAAqC,GAAGA,CACnDC,kBAA0B,EAC1BC,UAAqB,KAClB;EACH,SAAS;;EAET,IAAIC,SAA6B;EAEjC,IAAID,UAAU,EAAE;IACdC,SAAS,GAAGD,UAAU,CAACE,IAAI,CAAEC,MAAM,IAAKA,MAAM,IAAIJ,kBAAkB,CAAC;EACvE;EAEA,OAAOE,SAAS,IAAIF,kBAAkB;AACxC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["debounce","worklet","wait","value","time","args","t","Date","now","scrollDistanceWithRespectToSnapPoints","defaultScrollValue","snapPoints","snapPoint","find","offset"],"sources":["utils.ts"],"sourcesContent":["export const debounce = <F extends (...args: Parameters<F>) => ReturnType<F>>(\n worklet: F,\n wait = 0,\n) => {\n \"worklet\";\n\n const value = {\n time: 0,\n };\n\n return (...args: Parameters<F>): ReturnType<F> | void => {\n \"worklet\";\n\n const t = Date.now();\n const now = t - value.time;\n\n if (now < wait) {\n value.time = t;\n return;\n }\n\n value.time = t;\n\n return worklet(...args);\n };\n};\n\nexport const scrollDistanceWithRespectToSnapPoints = (\n defaultScrollValue: number,\n snapPoints?: number[],\n) => {\n \"worklet\";\n\n let snapPoint: number | undefined;\n\n if (snapPoints) {\n snapPoint = snapPoints.find((offset) => offset >= defaultScrollValue);\n }\n\n return snapPoint ?? defaultScrollValue;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,QAAQ,GAAGA,CACtBC,OAAU,EACVC,IAAI,GAAG,CAAC,KACL;EACH,SAAS;;EAET,MAAMC,KAAK,GAAG;IACZC,IAAI,EAAE;EACR,CAAC;EAED,OAAO,CAAC,GAAGC,IAAmB,KAA2B;IACvD,SAAS;;IAET,MAAMC,CAAC,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;IACpB,MAAMA,GAAG,GAAGF,CAAC,GAAGH,KAAK,CAACC,IAAI;IAE1B,IAAII,GAAG,GAAGN,IAAI,EAAE;MACdC,KAAK,CAACC,IAAI,GAAGE,CAAC;MACd;IACF;IAEAH,KAAK,CAACC,IAAI,GAAGE,CAAC;IAEd,OAAOL,OAAO,CAAC,GAAGI,IAAI,CAAC;EACzB,CAAC;AACH,CAAC;AAED,OAAO,MAAMI,qCAAqC,GAAGA,CACnDC,kBAA0B,EAC1BC,UAAqB,KAClB;EACH,SAAS;;EAET,IAAIC,SAA6B;EAEjC,IAAID,UAAU,EAAE;IACdC,SAAS,GAAGD,UAAU,CAACE,IAAI,CAAEC,MAAM,IAAKA,MAAM,IAAIJ,kBAAkB,CAAC;EACvE;EAEA,OAAOE,SAAS,IAAIF,kBAAkB;AACxC,CAAC","ignoreList":[]}