@react-native-ohos/react-native-keyboard-controller 1.17.0-beta.2 → 1.17.1-rc.1
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.
- package/LICENSE +21 -21
- package/README.OpenSource +11 -11
- package/README.md +686 -19
- package/harmony/keyboard_controller/BuildProfile.ets +16 -16
- package/harmony/keyboard_controller/Index.ets +29 -28
- package/harmony/keyboard_controller/build-profile.json5 +31 -31
- package/harmony/keyboard_controller/hvigorfile.ts +6 -6
- package/harmony/keyboard_controller/obfuscation-rules.txt +17 -17
- package/harmony/keyboard_controller/oh-package-lock.json5 +28 -18
- package/harmony/keyboard_controller/oh-package.json5 +10 -10
- package/harmony/keyboard_controller/src/main/cpp/CMakeLists.txt +7 -7
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentDescriptor.h +86 -0
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.cpp +104 -0
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.h +64 -0
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewJSIBinder.h +60 -0
- package/harmony/keyboard_controller/src/main/cpp/EventEmitters.cpp +119 -96
- package/harmony/keyboard_controller/src/main/cpp/EventEmitters.h +111 -111
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentDescriptor.h +94 -94
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +852 -288
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.h +170 -103
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewJSIBinder.h +65 -65
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentDescriptor.h +79 -79
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +108 -108
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.h +83 -83
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaJSIBinder.h +60 -60
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentDescriptor.h +46 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.cpp +37 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.h +32 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewJSIBinder.h +23 -0
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.cpp +103 -46
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.h +48 -48
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardControllerPackage.h +20 -0
- package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.cpp +45 -45
- package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.h +49 -49
- package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.cpp +207 -186
- package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.h +131 -112
- package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +77 -64
- package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +85 -77
- package/harmony/keyboard_controller/src/main/ets/Logger.ts +66 -66
- package/harmony/keyboard_controller/src/main/ets/{RNKeyboardControllerPackage.ts → RNKeyboardControllerPackage.ets} +70 -66
- package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +465 -273
- package/harmony/keyboard_controller/src/main/ets/RNStatusBarManagerCompatTurboModule.ts +128 -119
- package/harmony/keyboard_controller/src/main/ets/Type.ts +63 -62
- package/harmony/keyboard_controller/src/main/module.json5 +11 -11
- package/harmony/keyboard_controller/src/main/resources/base/element/string.json +8 -8
- package/harmony/keyboard_controller/src/main/resources/en_US/element/string.json +8 -8
- package/harmony/keyboard_controller/src/main/resources/zh_CN/element/string.json +8 -8
- package/harmony/keyboard_controller/{ts.ts → ts.ets} +29 -29
- package/harmony/keyboard_controller.har +0 -0
- package/lib/commonjs/animated.js +22 -11
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/architecture.js +8 -0
- package/lib/commonjs/architecture.js.map +1 -0
- package/lib/commonjs/bindings.js +40 -5
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +28 -5
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/compat.js +50 -0
- package/lib/commonjs/compat.js.map +1 -0
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +21 -15
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +39 -14
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +90 -56
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +5 -5
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/commonjs/components/KeyboardChatScrollView/hooks.js +13 -0
- package/lib/commonjs/components/KeyboardChatScrollView/hooks.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/index.js +122 -0
- package/lib/commonjs/components/KeyboardChatScrollView/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/types.js +6 -0
- package/lib/commonjs/components/KeyboardChatScrollView/types.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +221 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +149 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js +240 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js +6 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js +40 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js +92 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js +2 -3
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Button.js +2 -3
- package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/colors.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js +13 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js +25 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js +58 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js +49 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js +49 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js +42 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js +6 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/context.js +17 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/context.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/constants.js +17 -0
- package/lib/commonjs/components/KeyboardToolbar/constants.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js +98 -87
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -1
- package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js +120 -0
- package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js.map +1 -0
- package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js +15 -0
- package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
- package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -1
- package/lib/commonjs/components/hooks/useCombinedRef.js +24 -0
- package/lib/commonjs/components/hooks/useCombinedRef.js.map +1 -0
- package/lib/commonjs/components/hooks/useScrollState.js +62 -0
- package/lib/commonjs/components/hooks/useScrollState.js.map +1 -0
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/constants.js +3 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/context.js +1 -0
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks/index.js +14 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useKeyboardState/index.js +39 -0
- package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -0
- package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -1
- package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -1
- package/lib/commonjs/index.js +27 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +54 -18
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/module.js +21 -12
- package/lib/commonjs/module.js.map +1 -1
- package/lib/commonjs/reanimated.js.map +1 -1
- package/lib/commonjs/reanimated.native.js.map +1 -1
- package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js +12 -0
- package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +8 -2
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +2 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js +12 -0
- package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/findNodeHandle/index.js +9 -0
- package/lib/commonjs/utils/findNodeHandle/index.js.map +1 -0
- package/lib/commonjs/utils/findNodeHandle/index.native.js +13 -0
- package/lib/commonjs/utils/findNodeHandle/index.native.js.map +1 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/views/KeyboardExtender/index.js +30 -0
- package/lib/commonjs/views/KeyboardExtender/index.js.map +1 -0
- package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
- package/lib/commonjs/views/index.js +7 -0
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/module/animated.js +24 -13
- package/lib/module/animated.js.map +1 -1
- package/lib/module/architecture.js +2 -0
- package/lib/module/architecture.js.map +1 -0
- package/lib/module/bindings.js +39 -5
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +27 -5
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/compat.js +43 -0
- package/lib/module/compat.js.map +1 -0
- package/lib/module/components/KeyboardAvoidingView/hooks.js +22 -16
- package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +38 -14
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +92 -58
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +5 -5
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/module/components/KeyboardChatScrollView/hooks.js +2 -0
- package/lib/module/components/KeyboardChatScrollView/hooks.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/index.js +115 -0
- package/lib/module/components/KeyboardChatScrollView/index.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/types.js +2 -0
- package/lib/module/components/KeyboardChatScrollView/types.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +207 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +143 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js +234 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js +2 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useEndVisible.js +33 -0
- package/lib/module/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js +87 -0
- package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/Arrow.js +2 -2
- package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/Button.js +2 -2
- package/lib/module/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/colors.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/colors.native.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/compound/components/Background.js +6 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Content.js +18 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Done.js +50 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Next.js +41 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Prev.js +41 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/index.js +6 -0
- package/lib/module/components/KeyboardToolbar/compound/components/index.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/types.js +2 -0
- package/lib/module/components/KeyboardToolbar/compound/components/types.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/context.js +10 -0
- package/lib/module/components/KeyboardToolbar/compound/context.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/constants.js +11 -0
- package/lib/module/components/KeyboardToolbar/constants.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/index.js +98 -88
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/types.js.map +1 -1
- package/lib/module/components/ScrollViewWithBottomPadding/index.js +112 -0
- package/lib/module/components/ScrollViewWithBottomPadding/index.js.map +1 -0
- package/lib/module/components/ScrollViewWithBottomPadding/styles.js +9 -0
- package/lib/module/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
- package/lib/module/components/hooks/useColorScheme.js.map +1 -1
- package/lib/module/components/hooks/useCombinedRef.js +18 -0
- package/lib/module/components/hooks/useCombinedRef.js.map +1 -0
- package/lib/module/components/hooks/useScrollState.js +56 -0
- package/lib/module/components/hooks/useScrollState.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/constants.js +3 -0
- package/lib/module/constants.js.map +1 -1
- package/lib/module/context.js +1 -0
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks/index.js +3 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useKeyboardState/index.js +33 -0
- package/lib/module/hooks/useKeyboardState/index.js.map +1 -0
- package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -1
- package/lib/module/hooks/useWindowDimensions/index.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +53 -18
- package/lib/module/internal.js.map +1 -1
- package/lib/module/module.js +21 -12
- package/lib/module/module.js.map +1 -1
- package/lib/module/reanimated.js.map +1 -1
- package/lib/module/reanimated.native.js.map +1 -1
- package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js +6 -0
- package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js +7 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +2 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js +5 -0
- package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/findNodeHandle/index.js +2 -0
- package/lib/module/utils/findNodeHandle/index.js.map +1 -0
- package/lib/module/utils/findNodeHandle/index.native.js +3 -0
- package/lib/module/utils/findNodeHandle/index.native.js.map +1 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/views/KeyboardExtender/index.js +23 -0
- package/lib/module/views/KeyboardExtender/index.js.map +1 -0
- package/lib/module/views/OverKeyboardView/index.js.map +1 -1
- package/lib/module/views/index.js +1 -0
- package/lib/module/views/index.js.map +1 -1
- package/lib/typescript/animated.d.ts +2 -38
- package/lib/typescript/architecture.d.ts +1 -0
- package/lib/typescript/bindings.d.ts +15 -1
- package/lib/typescript/bindings.native.d.ts +10 -1
- package/lib/typescript/compat.d.ts +12 -0
- package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +5 -0
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -1
- package/lib/typescript/components/KeyboardChatScrollView/hooks.d.ts +2 -0
- package/lib/typescript/components/KeyboardChatScrollView/index.d.ts +17 -0
- package/lib/typescript/components/KeyboardChatScrollView/types.d.ts +113 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts +132 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.d.ts +18 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.ios.d.ts +21 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts +37 -0
- package/lib/typescript/components/KeyboardChatScrollView/useEndVisible.d.ts +17 -0
- package/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts +45 -0
- package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -2
- package/lib/typescript/components/KeyboardToolbar/compound/components/Background.d.ts +6 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Content.d.ts +7 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Done.d.ts +7 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Next.d.ts +4 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Prev.d.ts +4 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/index.d.ts +5 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/types.d.ts +14 -0
- package/lib/typescript/components/KeyboardToolbar/compound/context.d.ts +9 -0
- package/lib/typescript/components/KeyboardToolbar/constants.d.ts +10 -0
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +12 -45
- package/lib/typescript/components/KeyboardToolbar/types.d.ts +24 -1
- package/lib/typescript/components/ScrollViewWithBottomPadding/index.d.ts +30 -0
- package/lib/typescript/components/ScrollViewWithBottomPadding/styles.d.ts +7 -0
- package/lib/typescript/components/hooks/useCombinedRef.d.ts +3 -0
- package/lib/typescript/components/hooks/useScrollState.d.ts +17 -0
- package/lib/typescript/components/index.d.ts +3 -0
- package/lib/typescript/constants.d.ts +1 -0
- package/lib/typescript/context.d.ts +1 -0
- package/lib/typescript/hooks/index.d.ts +2 -0
- package/lib/typescript/hooks/useKeyboardState/index.d.ts +4 -0
- package/lib/typescript/index.d.ts +4 -3
- package/lib/typescript/internal.d.ts +4 -0
- package/lib/typescript/specs/ClippingScrollViewDecoratorViewNativeComponent.d.ts +10 -0
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
- package/lib/typescript/specs/KeyboardToolbarGroupViewNativeComponent.d.ts +6 -0
- package/lib/typescript/specs/NativeKeyboardController.d.ts +6 -2
- package/lib/typescript/types.d.ts +81 -5
- package/lib/typescript/utils/findNodeHandle/index.d.ts +4 -0
- package/lib/typescript/utils/findNodeHandle/index.native.d.ts +2 -0
- package/lib/typescript/views/KeyboardExtender/index.d.ts +5 -0
- package/lib/typescript/views/index.d.ts +1 -0
- package/package.json +183 -174
- package/src/animated.tsx +248 -255
- package/src/architecture.ts +1 -0
- package/src/bindings.native.ts +97 -62
- package/src/bindings.ts +81 -42
- package/src/compat.ts +44 -0
- package/src/components/KeyboardAvoidingView/hooks.ts +130 -123
- package/src/components/KeyboardAvoidingView/index.tsx +232 -188
- package/src/components/KeyboardAwareScrollView/index.tsx +443 -389
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +133 -133
- package/src/components/KeyboardAwareScrollView/utils.ts +41 -41
- package/src/components/KeyboardChatScrollView/hooks.ts +2 -0
- package/src/components/KeyboardChatScrollView/index.tsx +164 -0
- package/src/components/KeyboardChatScrollView/types.ts +117 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts +268 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts +260 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts +374 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts +39 -0
- package/src/components/KeyboardChatScrollView/useEndVisible.ts +66 -0
- package/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts +149 -0
- package/src/components/KeyboardStickyView/index.tsx +66 -66
- package/src/components/KeyboardToolbar/Arrow.tsx +80 -80
- package/src/components/KeyboardToolbar/Button.tsx +98 -98
- package/src/components/KeyboardToolbar/colors.native.ts +37 -37
- package/src/components/KeyboardToolbar/colors.ts +16 -16
- package/src/components/KeyboardToolbar/compound/components/Background.tsx +9 -0
- package/src/components/KeyboardToolbar/compound/components/Content.tsx +25 -0
- package/src/components/KeyboardToolbar/compound/components/Done.tsx +57 -0
- package/src/components/KeyboardToolbar/compound/components/Next.tsx +49 -0
- package/src/components/KeyboardToolbar/compound/components/Prev.tsx +49 -0
- package/src/components/KeyboardToolbar/compound/components/index.ts +5 -0
- package/src/components/KeyboardToolbar/compound/components/types.ts +15 -0
- package/src/components/KeyboardToolbar/compound/context.ts +25 -0
- package/src/components/KeyboardToolbar/constants.ts +14 -0
- package/src/components/KeyboardToolbar/index.tsx +220 -223
- package/src/components/KeyboardToolbar/types.ts +72 -40
- package/src/components/ScrollViewWithBottomPadding/index.tsx +216 -0
- package/src/components/ScrollViewWithBottomPadding/styles.ts +10 -0
- package/src/components/hooks/useColorScheme.ts +6 -6
- package/src/components/hooks/useCombinedRef.ts +22 -0
- package/src/components/hooks/useScrollState.ts +81 -0
- package/src/components/index.ts +14 -11
- package/src/constants.ts +23 -19
- package/src/context.ts +70 -68
- package/src/hooks/index.ts +91 -90
- package/src/hooks/useKeyboardState/index.ts +52 -0
- package/src/hooks/useWindowDimensions/index.android.ts +38 -38
- package/src/hooks/useWindowDimensions/index.ts +1 -1
- package/src/index.ts +27 -23
- package/src/internal.ts +146 -84
- package/src/module.ts +64 -52
- package/src/reanimated.native.ts +132 -132
- package/src/reanimated.ts +29 -29
- package/src/specs/ClippingScrollViewDecoratorViewNativeComponent.ts +19 -0
- package/src/specs/KeyboardControllerViewNativeComponent.ts +82 -71
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +21 -20
- package/src/specs/KeyboardToolbarGroupViewNativeComponent.ts +10 -0
- package/src/specs/NativeKeyboardController.ts +23 -19
- package/src/specs/NativeStatusBarManagerCompat.ts +14 -14
- package/src/specs/OverKeyboardViewNativeComponent.ts +12 -12
- package/src/types.ts +330 -243
- package/src/utils/findNodeHandle/index.native.ts +3 -0
- package/src/utils/findNodeHandle/index.ts +6 -0
- package/src/utils.ts +1 -1
- package/src/views/KeyboardExtender/index.tsx +30 -0
- package/src/views/OverKeyboardView/index.tsx +43 -43
- package/src/views/index.ts +2 -1
- package/lib/commonjs/monkey-patch.android.js +0 -57
- package/lib/commonjs/monkey-patch.android.js.map +0 -1
- package/lib/commonjs/monkey-patch.js +0 -11
- package/lib/commonjs/monkey-patch.js.map +0 -1
- package/lib/module/monkey-patch.android.js +0 -47
- package/lib/module/monkey-patch.android.js.map +0 -1
- package/lib/module/monkey-patch.js +0 -5
- package/lib/module/monkey-patch.js.map +0 -1
- package/lib/typescript/monkey-patch.android.d.ts +0 -2
- package/lib/typescript/monkey-patch.d.ts +0 -2
- package/src/monkey-patch.android.ts +0 -44
- package/src/monkey-patch.ts +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_hooks","_hooks2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","defaultLayout","x","y","width","height","KeyboardAvoidingView","forwardRef","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","ref","initialFrame","useSharedValue","frame","useDerivedValue","value","translate","padding","useTranslateAnimation","keyboard","useKeyboardAnimation","screenHeight","useWindowDimensions","relativeKeyboardHeight","useCallback","keyboardY","heightWhenOpened","Math","max","interpolateToRelativeKeyboardHeight","interpolate","onLayoutWorklet","layout","isClosed","runOnUI","nativeEvent","animatedStyle","useAnimatedStyle","bottom","progress","translateY","paddingBottom","bottomHeight","flex","transform","isPositionBehavior","containerStyle","combinedStyles","useMemo","createElement","View","_default","exports"],"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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zD/C,MAAA,CAAAiB,OAAA,CAAAsE,aAAA,CAACnF,sBAAA,CAAAa,OAAU,CAACuE,IAAI;MAAC5C,KAAK,EAAEyC;IAAe,GAAE7C,QAA0B,CAC/D,CAAC;EAEX;EAEA,oBACExC,MAAA,CAAAiB,OAAA,CAAAsE,aAAA,CAACnF,sBAAA,CAAAa,OAAU,CAACuE,IAAI,EAAA9D,QAAA;IACdsB,GAAG,EAAEA,GAAI;IACTH,QAAQ,EAAEA,QAAS;IACnBD,KAAK,EAAEyC;EAAe,GAClBtC,KAAK,GAERP,QACc,CAAC;AAEtB,CACF,CAAC;AAAC,IAAAiD,QAAA,GAAAC,OAAA,CAAAzE,OAAA,GAEaoB,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_bindings","_hooks","_findNodeHandle","_useCombinedRef","_interopRequireDefault","_hooks2","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","defaultLayout","x","y","width","height","KeyboardAvoidingView","forwardRef","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","automaticOffset","style","onLayout","onLayoutProps","props","ref","initialFrame","useSharedValue","internalRef","React","useRef","frame","useDerivedValue","value","translate","padding","useTranslateAnimation","keyboard","useKeyboardAnimation","screenHeight","useWindowDimensions","relativeKeyboardHeight","useCallback","keyboardY","heightWhenOpened","Math","max","interpolateToRelativeKeyboardHeight","interpolate","onLayoutWorklet","layout","isClosed","nativeEvent","tag","findNodeHandle","current","KeyboardControllerNative","viewPositionInWindow","then","position","runOnUI","catch","animatedStyle","useAnimatedStyle","bottom","progress","translateY","paddingBottom","flex","transform","combinedRef","useCombinedRef","isPositionBehavior","containerStyle","combinedStyles","useMemo","createElement","View","_default","exports"],"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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAQA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAC,sBAAA,CAAAP,OAAA;AAEA,IAAAQ,OAAA,GAAAR,OAAA;AAAsE,SAAAO,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAd,uBAAA,YAAAA,CAAAU,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IA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O,EAC5B,MAAM,CAACF,cAAc,EAAEX,aAAa,CAAC,EACrC,CAACW,cAAc,EAAEX,aAAa,CAChC,CAAC;EAED,IAAIU,kBAAkB,EAAE;IACtB,oBACEpG,MAAA,CAAAa,OAAA,CAAA2F,aAAA,CAACrG,YAAA,CAAAsG,IAAI,EAAA3E,QAAA;MAACuB,GAAG,EAAE6C,WAAY;MAACjD,KAAK,EAAEA,KAAM;MAACC,QAAQ,EAAEA;IAAS,GAAKE,KAAK,gBACjEpD,MAAA,CAAAa,OAAA,CAAA2F,aAAA,CAACpG,sBAAA,CAAAS,OAAU,CAAC4F,IAAI;MAACxD,KAAK,EAAEqD;IAAe,GAAE1D,QAA0B,CAC/D,CAAC;EAEX;EAEA,oBACE5C,MAAA,CAAAa,OAAA,CAAA2F,aAAA,CAACpG,sBAAA,CAAAS,OAAU,CAAC4F,IAAI,EAAA3E,QAAA;IACduB,GAAG,EAAE6C,WAAY;IACjBhD,QAAQ,EAAEA,QAAS;IACnBD,KAAK,EAAEqD;EAAe,GAClBlD,KAAK,GAERR,QACc,CAAC;AAEtB,CACF,CAAC;AAAC,IAAA8D,QAAA,GAAAC,OAAA,CAAA9F,OAAA,GAEa4B,oBAAoB","ignoreList":[]}
|
|
@@ -5,50 +5,51 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
8
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
9
|
+
var _bindings = require("../../bindings");
|
|
10
10
|
var _hooks = require("../../hooks");
|
|
11
|
+
var _findNodeHandle = require("../../utils/findNodeHandle");
|
|
11
12
|
var _useSmoothKeyboardHandler = require("./useSmoothKeyboardHandler");
|
|
12
13
|
var _utils = require("./utils");
|
|
13
14
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
15
|
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); }
|
|
15
|
-
/*
|
|
16
|
-
* Everything begins from `onStart` handler. This handler is called every time,
|
|
17
|
-
* when keyboard changes its size or when focused `TextInput` was changed. In
|
|
18
|
-
* this handler we are calculating/memoizing values which later will be used
|
|
19
|
-
* during layout movement. For that we calculate:
|
|
20
|
-
* - layout of focused field (`layout`) - to understand whether there will be overlap
|
|
21
|
-
* - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation
|
|
22
|
-
* - future keyboard height (`keyboardHeight`) - used in scroll interpolation
|
|
23
|
-
* - current scroll position (`scrollPosition`) - used to scroll from this point
|
|
24
|
-
*
|
|
25
|
-
* Once we've calculated all necessary variables - we can actually start to use them.
|
|
26
|
-
* It happens in `onMove` handler - this function simply calls `maybeScroll` with
|
|
27
|
-
* current keyboard frame height. This functions makes the smooth transition.
|
|
28
|
-
*
|
|
29
|
-
* When the transition has finished we go to `onEnd` handler. In this handler
|
|
30
|
-
* we verify, that the current field is not overlapped within a keyboard frame.
|
|
31
|
-
* For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,
|
|
32
|
-
* however there could be some cases, when `onMove` is not called:
|
|
33
|
-
* - on iOS when TextInput was changed - keyboard transition is instant
|
|
34
|
-
* - on Android when TextInput was changed and keyboard size wasn't changed
|
|
35
|
-
* So `onEnd` handler handle the case, when `onMove` wasn't triggered.
|
|
36
|
-
*
|
|
37
|
-
* ====================================================================================================================+
|
|
38
|
-
* -----------------------------------------------------Flow chart-----------------------------------------------------+
|
|
39
|
-
* ====================================================================================================================+
|
|
40
|
-
*
|
|
41
|
-
* +============================+ +============================+ +==================================+
|
|
42
|
-
* + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>
|
|
43
|
-
* + + + (run `onStart`) + + `onMove` is getting called +
|
|
44
|
-
* +============================+ +============================+ +==================================+
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* +============================+ +============================+ +=====================================+
|
|
48
|
-
* + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +
|
|
49
|
-
* + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +
|
|
50
|
-
* +============================+ +============================+ +=====================================+
|
|
51
|
-
*
|
|
16
|
+
/*
|
|
17
|
+
* Everything begins from `onStart` handler. This handler is called every time,
|
|
18
|
+
* when keyboard changes its size or when focused `TextInput` was changed. In
|
|
19
|
+
* this handler we are calculating/memoizing values which later will be used
|
|
20
|
+
* during layout movement. For that we calculate:
|
|
21
|
+
* - layout of focused field (`layout`) - to understand whether there will be overlap
|
|
22
|
+
* - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation
|
|
23
|
+
* - future keyboard height (`keyboardHeight`) - used in scroll interpolation
|
|
24
|
+
* - current scroll position (`scrollPosition`) - used to scroll from this point
|
|
25
|
+
*
|
|
26
|
+
* Once we've calculated all necessary variables - we can actually start to use them.
|
|
27
|
+
* It happens in `onMove` handler - this function simply calls `maybeScroll` with
|
|
28
|
+
* current keyboard frame height. This functions makes the smooth transition.
|
|
29
|
+
*
|
|
30
|
+
* When the transition has finished we go to `onEnd` handler. In this handler
|
|
31
|
+
* we verify, that the current field is not overlapped within a keyboard frame.
|
|
32
|
+
* For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,
|
|
33
|
+
* however there could be some cases, when `onMove` is not called:
|
|
34
|
+
* - on iOS when TextInput was changed - keyboard transition is instant
|
|
35
|
+
* - on Android when TextInput was changed and keyboard size wasn't changed
|
|
36
|
+
* So `onEnd` handler handle the case, when `onMove` wasn't triggered.
|
|
37
|
+
*
|
|
38
|
+
* ====================================================================================================================+
|
|
39
|
+
* -----------------------------------------------------Flow chart-----------------------------------------------------+
|
|
40
|
+
* ====================================================================================================================+
|
|
41
|
+
*
|
|
42
|
+
* +============================+ +============================+ +==================================+
|
|
43
|
+
* + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>
|
|
44
|
+
* + + + (run `onStart`) + + `onMove` is getting called +
|
|
45
|
+
* +============================+ +============================+ +==================================+
|
|
46
|
+
*
|
|
47
|
+
*
|
|
48
|
+
* +============================+ +============================+ +=====================================+
|
|
49
|
+
* + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +
|
|
50
|
+
* + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +
|
|
51
|
+
* +============================+ +============================+ +=====================================+
|
|
52
|
+
*
|
|
52
53
|
*/
|
|
53
54
|
const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
54
55
|
children,
|
|
@@ -74,24 +75,31 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
74
75
|
input
|
|
75
76
|
} = (0, _hooks.useReanimatedFocusedInput)();
|
|
76
77
|
const layout = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
78
|
+
const scrollViewPageY = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
77
79
|
const {
|
|
78
80
|
height
|
|
79
81
|
} = (0, _hooks.useWindowDimensions)();
|
|
80
82
|
const onRef = (0, _react.useCallback)(assignedRef => {
|
|
81
|
-
if (typeof ref === "function") {
|
|
82
|
-
ref(assignedRef);
|
|
83
|
-
} else if (ref) {
|
|
84
|
-
ref.current = assignedRef;
|
|
85
|
-
}
|
|
86
83
|
scrollViewAnimatedRef(assignedRef);
|
|
87
84
|
}, []);
|
|
88
|
-
const onScrollViewLayout = (0, _react.useCallback)(e => {
|
|
89
|
-
|
|
85
|
+
const onScrollViewLayout = (0, _react.useCallback)(async e => {
|
|
86
|
+
const handle = (0, _findNodeHandle.findNodeHandle)(scrollViewAnimatedRef.current);
|
|
87
|
+
scrollViewTarget.value = handle;
|
|
90
88
|
onLayout === null || onLayout === void 0 || onLayout(e);
|
|
89
|
+
if (handle !== null) {
|
|
90
|
+
try {
|
|
91
|
+
const {
|
|
92
|
+
y
|
|
93
|
+
} = await _bindings.KeyboardControllerNative.viewPositionInWindow(handle);
|
|
94
|
+
scrollViewPageY.value = y;
|
|
95
|
+
} catch {
|
|
96
|
+
// Keep the previous top boundary when the view is not mounted yet.
|
|
97
|
+
}
|
|
98
|
+
}
|
|
91
99
|
}, [onLayout]);
|
|
92
100
|
|
|
93
|
-
/**
|
|
94
|
-
* Function that will scroll a ScrollView as keyboard gets moving
|
|
101
|
+
/**
|
|
102
|
+
* Function that will scroll a ScrollView as keyboard gets moving
|
|
95
103
|
*/
|
|
96
104
|
const maybeScroll = (0, _react.useCallback)((e, animated = false) => {
|
|
97
105
|
"worklet";
|
|
@@ -116,13 +124,27 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
116
124
|
(0, _reactNativeReanimated.scrollTo)(scrollViewAnimatedRef, 0, targetScrollY, animated);
|
|
117
125
|
return interpolatedScrollTo;
|
|
118
126
|
}
|
|
119
|
-
if (
|
|
120
|
-
const positionOnScreen = visibleRect -
|
|
121
|
-
const topOfScreen = scrollPosition.value +
|
|
127
|
+
if (point < scrollViewPageY.value) {
|
|
128
|
+
const positionOnScreen = visibleRect - bottomOffset;
|
|
129
|
+
const topOfScreen = scrollPosition.value + point;
|
|
122
130
|
(0, _reactNativeReanimated.scrollTo)(scrollViewAnimatedRef, 0, topOfScreen - positionOnScreen, animated);
|
|
123
131
|
}
|
|
124
132
|
return 0;
|
|
125
133
|
}, [bottomOffset, enabled, height, rest.snapToOffsets]);
|
|
134
|
+
const performScrollWithPositionRestoration = (0, _react.useCallback)(newPosition => {
|
|
135
|
+
"worklet";
|
|
136
|
+
|
|
137
|
+
const prevScrollPosition = scrollPosition.value;
|
|
138
|
+
|
|
139
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
140
|
+
scrollPosition.value = newPosition;
|
|
141
|
+
maybeScroll(keyboardHeight.value, true);
|
|
142
|
+
scrollPosition.value = prevScrollPosition;
|
|
143
|
+
}, [maybeScroll]);
|
|
144
|
+
(0, _react.useEffect)(() => {
|
|
145
|
+
// Recalculate from the pre-keyboard position to avoid accumulating an already applied offset.
|
|
146
|
+
(0, _reactNativeReanimated.runOnUI)(performScrollWithPositionRestoration)(scrollBeforeKeyboardMovement.value);
|
|
147
|
+
}, [bottomOffset]);
|
|
126
148
|
const syncKeyboardFrame = (0, _react.useCallback)(e => {
|
|
127
149
|
"worklet";
|
|
128
150
|
|
|
@@ -133,7 +155,6 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
133
155
|
"worklet";
|
|
134
156
|
|
|
135
157
|
var _input$value;
|
|
136
|
-
const prevScrollPosition = scrollPosition.value;
|
|
137
158
|
const prevLayout = layout.value;
|
|
138
159
|
if (!((_input$value = input.value) !== null && _input$value !== void 0 && _input$value.layout)) {
|
|
139
160
|
return;
|
|
@@ -147,11 +168,24 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
147
168
|
height: customHeight ?? input.value.layout.height
|
|
148
169
|
}
|
|
149
170
|
};
|
|
150
|
-
|
|
151
|
-
maybeScroll(keyboardHeight.value, true);
|
|
152
|
-
scrollPosition.value = prevScrollPosition;
|
|
171
|
+
performScrollWithPositionRestoration(position.value);
|
|
153
172
|
layout.value = prevLayout;
|
|
154
|
-
}, [
|
|
173
|
+
}, [performScrollWithPositionRestoration]);
|
|
174
|
+
const assureFocusedInputVisible = (0, _react.useCallback)(() => {
|
|
175
|
+
(0, _reactNativeReanimated.runOnUI)(scrollFromCurrentPosition)();
|
|
176
|
+
}, [scrollFromCurrentPosition]);
|
|
177
|
+
(0, _react.useImperativeHandle)(ref, () => {
|
|
178
|
+
const current = scrollViewAnimatedRef.current;
|
|
179
|
+
if (current) {
|
|
180
|
+
Object.assign(current, {
|
|
181
|
+
assureFocusedInputVisible
|
|
182
|
+
});
|
|
183
|
+
return current;
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
assureFocusedInputVisible
|
|
187
|
+
};
|
|
188
|
+
}, [assureFocusedInputVisible]);
|
|
155
189
|
const onChangeText = (0, _react.useCallback)(() => {
|
|
156
190
|
"worklet";
|
|
157
191
|
|
|
@@ -254,7 +288,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
254
288
|
}, rest, {
|
|
255
289
|
onLayout: onScrollViewLayout,
|
|
256
290
|
scrollEventThrottle: 16
|
|
257
|
-
}), children, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
291
|
+
}), children, enabled && /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
258
292
|
style: view
|
|
259
293
|
}));
|
|
260
294
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_hooks","_useSmoothKeyboardHandler","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","KeyboardAwareScrollView","forwardRef","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","Reanimated","ScrollView","rest","ref","scrollViewAnimatedRef","useAnimatedRef","scrollViewTarget","useSharedValue","scrollPosition","position","useScrollViewOffset","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","useReanimatedFocusedInput","layout","height","useWindowDimensions","onRef","useCallback","assignedRef","current","onScrollViewLayout","value","findNodeHandle","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","interpolate","scrollDistanceWithRespectToSnapPoints","snapToOffsets","targetScrollY","Math","max","scrollTo","positionOnScreen","topOfScreen","syncKeyboardFrame","keyboardFrame","scrollFromCurrentPosition","customHeight","_input$value","prevScrollPosition","prevLayout","onChangeText","_layout$value4","_input$value2","onSelectionChange","selection","start","end","y","onChangeTextHandler","useMemo","debounce","useFocusedInputHandler","useSmoothKeyboardHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","target","onMove","onEnd","useAnimatedReaction","previous","view","useAnimatedStyle","paddingBottom","createElement","scrollEventThrottle","View","style","_default","exports"],"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,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAUA,IAAAG,MAAA,GAAAH,OAAA;AAMA,IAAAI,yBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAA0E,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAA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uBAARA,QAAQ,CAAE3D,MAAM,CAACC,MAAM,GAClD;MACA,MAAMoC,UAAU,GAAGrC,MAAM,CAACQ,KAAK;MAE/BR,MAAM,CAACQ,KAAK,GAAGV,KAAK,CAACU,KAAK;MAC1BnB,cAAc,CAACmB,KAAK,IAAIE,WAAW,CAACjB,cAAc,CAACe,KAAK,EAAE,IAAI,CAAC;MAC/DR,MAAM,CAACQ,KAAK,GAAG6B,UAAU;IAC3B;EACF,CAAC,EACD,EACF,CAAC;EAED,MAAMuB,IAAI,GAAG,IAAAC,uCAAgB,EAC3B,MACEnF,OAAO,GACH;IACA;IACA;IACA;IACA;IACA;IACA;IACAoF,aAAa,EAAEtE,0BAA0B,CAACgB,KAAK,GAAG;EACpD,CAAC,GACC,CAAC,CAAC,EACR,CAAC9B,OAAO,CACV,CAAC;EAED,oBACEvC,MAAA,CAAAkB,OAAA,CAAA0G,aAAA,CAACnF,mBAAmB,EAAAd,QAAA;IAClBkB,GAAG,EAAEmB;EAAM,GACPpB,IAAI;IACRR,QAAQ,EAAEgC,kBAAmB;IAC7ByD,mBAAmB,EAAE;EAAG,IAEvB1F,QAAQ,eACTnC,MAAA,CAAAkB,OAAA,CAAA0G,aAAA,CAACxH,sBAAA,CAAAc,OAAU,CAAC4G,IAAI;IAACC,KAAK,EAAEN;EAAK,CAAE,CACZ,CAAC;AAE1B,CACF,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAA/G,OAAA,GAEae,uBAAuB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_bindings","_hooks","_findNodeHandle","_useSmoothKeyboardHandler","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","KeyboardAwareScrollView","forwardRef","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","Reanimated","ScrollView","rest","ref","scrollViewAnimatedRef","useAnimatedRef","scrollViewTarget","useSharedValue","scrollPosition","position","useScrollViewOffset","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","useReanimatedFocusedInput","layout","scrollViewPageY","height","useWindowDimensions","onRef","useCallback","assignedRef","onScrollViewLayout","handle","findNodeHandle","current","value","y","KeyboardControllerNative","viewPositionInWindow","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","interpolate","scrollDistanceWithRespectToSnapPoints","snapToOffsets","targetScrollY","Math","max","scrollTo","positionOnScreen","topOfScreen","performScrollWithPositionRestoration","newPosition","prevScrollPosition","useEffect","runOnUI","syncKeyboardFrame","keyboardFrame","scrollFromCurrentPosition","customHeight","_input$value","prevLayout","assureFocusedInputVisible","useImperativeHandle","onChangeText","_layout$value4","_input$value2","onSelectionChange","selection","start","end","onChangeTextHandler","useMemo","debounce","useFocusedInputHandler","useSmoothKeyboardHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","target","onMove","onEnd","useAnimatedReaction","previous","view","useAnimatedStyle","paddingBottom","createElement","scrollEventThrottle","View","style","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n} from \"react\";\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\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 && !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 (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\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 scrollEventThrottle={16}\n >\n {children}\n {enabled && <Reanimated.View style={view} />}\n </ScrollViewComponent>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,sBAAA,GAAAF,uBAAA,CAAAC,OAAA;AAWA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAKA,IAAAI,eAAA,GAAAJ,OAAA;AAEA,IAAAK,yBAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAA0E,SAAAD,wBAAAQ,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAQ,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,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AACsB,KAAK,IAAII,WAAW,CAACtB,cAAc,CAACkB,KAAK,EAAE,IAAI,CAAC;MAC/DX,MAAM,CAACW,KAAK,GAAGmC,UAAU;IAC3B;EACF,CAAC,EACD,EACF,CAAC;EAED,MAAMwB,IAAI,GAAG,IAAAC,uCAAgB,EAC3B,MACE7F,OAAO,GACH;IACA;IACA;IACA;IACA;IACA;IACA;IACA8F,aAAa,EAAEhF,0BAA0B,CAACmB,KAAK,GAAG;EACpD,CAAC,GACC,CAAC,CAAC,EACR,CAACjC,OAAO,CACV,CAAC;EAED,oBACExC,MAAA,CAAAmB,OAAA,CAAAoH,aAAA,CAAC7F,mBAAmB,EAAAd,QAAA;IAClBkB,GAAG,EAAEoB;EAAM,GACPrB,IAAI;IACRR,QAAQ,EAAEgC,kBAAmB;IAC7BmE,mBAAmB,EAAE;EAAG,IAEvBpG,QAAQ,EACRI,OAAO,iBAAIxC,MAAA,CAAAmB,OAAA,CAAAoH,aAAA,CAACpI,sBAAA,CAAAgB,OAAU,CAACsH,IAAI;IAACC,KAAK,EAAEN;EAAK,CAAE,CACxB,CAAC;AAE1B,CACF,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAAzH,OAAA,GAEae,uBAAuB","ignoreList":[]}
|
|
@@ -18,9 +18,9 @@ const TELEGRAM_ANDROID_TIMING_CONFIG = {
|
|
|
18
18
|
easing: _reactNativeReanimated.Easing.bezier(0.19919472913616398, 0.010644531250000006, 0.27920937042459737, 0.91025390625)
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Hook that uses default transitions for iOS and Android > 11, and uses
|
|
23
|
-
* custom interpolation on Android < 11 to achieve more smooth animation
|
|
21
|
+
/**
|
|
22
|
+
* Hook that uses default transitions for iOS and Android > 11, and uses
|
|
23
|
+
* custom interpolation on Android < 11 to achieve more smooth animation
|
|
24
24
|
*/
|
|
25
25
|
const useSmoothKeyboardHandler = (handler, deps) => {
|
|
26
26
|
const target = (0, _reactNativeReanimated.useSharedValue)(-1);
|
|
@@ -57,8 +57,8 @@ const useSmoothKeyboardHandler = (handler, deps) => {
|
|
|
57
57
|
persistedHeight.value = height.value;
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
-
//
|
|
61
|
-
deps);
|
|
60
|
+
// create shallow copy (if deps specified) since `useAnimatedReaction` modifies them
|
|
61
|
+
deps ? [...deps] : deps);
|
|
62
62
|
(0, _hooks.useKeyboardHandler)({
|
|
63
63
|
onStart: e => {
|
|
64
64
|
"worklet";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_reactNativeReanimated","_hooks","IS_ANDROID_ELEVEN_OR_HIGHER","Platform","OS","Version","IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS","TELEGRAM_ANDROID_TIMING_CONFIG","duration","easing","Easing","bezier","useSmoothKeyboardHandler","handler","deps","target","useSharedValue","height","persistedHeight","animatedKeyboardHeight","useAnimatedReaction","value","event","progress","evt","_handler$onMove","onMove","call","_handler$onEnd","onEnd","useKeyboardHandler","onStart","e","_handler$onStart2","_handler$onStart","_handler$onEnd2","withTiming","_handler$onMove2","_handler$onEnd3","exports"],"sources":["useSmoothKeyboardHandler.ts"],"sourcesContent":["import { Platform } from \"react-native\";\
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_reactNativeReanimated","_hooks","IS_ANDROID_ELEVEN_OR_HIGHER","Platform","OS","Version","IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS","TELEGRAM_ANDROID_TIMING_CONFIG","duration","easing","Easing","bezier","useSmoothKeyboardHandler","handler","deps","target","useSharedValue","height","persistedHeight","animatedKeyboardHeight","useAnimatedReaction","value","event","progress","evt","_handler$onMove","onMove","call","_handler$onEnd","onEnd","useKeyboardHandler","onStart","e","_handler$onStart2","_handler$onStart","_handler$onEnd2","withTiming","_handler$onMove2","_handler$onEnd3","exports"],"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,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AAOA,IAAAE,MAAA,GAAAF,OAAA;AAEA,MAAMG,2BAA2B,GAC/BC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAID,qBAAQ,CAACE,OAAO,IAAI,EAAE;AACrD;AACA,MAAMC,kCAAk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AC;QACJxB,QAAQ,EAAEF,kCAAkC,GACxC0B,CAAC,CAACxB,QAAQ,GACVD,8BAA8B,CAACC;MACrC,CAAC,CAAC;IACJ,CAAC;IACDkB,MAAM,EAAGM,CAAC,IAAK;MACb,SAAS;;MAET,IAAI1B,kCAAkC,EAAE;QAAA,IAAA+B,gBAAA;QACtC,CAAAA,gBAAA,GAAAxB,OAAO,CAACa,MAAM,cAAAW,gBAAA,eAAdA,gBAAA,CAAAV,IAAA,CAAAd,OAAO,EAAUmB,CAAC,CAAC;MACrB;IACF,CAAC;IACDH,KAAK,EAAGG,CAAC,IAAK;MACZ,SAAS;;MAET,IAAI1B,kCAAkC,EAAE;QAAA,IAAAgC,eAAA;QACtC,CAAAA,eAAA,GAAAzB,OAAO,CAACgB,KAAK,cAAAS,eAAA,eAAbA,eAAA,CAAAX,IAAA,CAAAd,OAAO,EAASmB,CAAC,CAAC;MACpB;IACF;EACF,CAAC,EACDlB,IACF,CAAC;AACH,CAAC;AAACyB,OAAA,CAAA3B,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["debounce","worklet","wait","value","time","args","t","Date","now","exports","scrollDistanceWithRespectToSnapPoints","defaultScrollValue","snapPoints","snapPoint","find","offset"],"sources":["utils.ts"],"sourcesContent":["export const debounce = <F extends (...args: Parameters<F>) => ReturnType<F>>(\
|
|
1
|
+
{"version":3,"names":["debounce","worklet","wait","value","time","args","t","Date","now","exports","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":";;;;;;AAAO,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;AAACI,OAAA,CAAAT,QAAA,GAAAA,QAAA;AAEK,MAAMU,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;AAACF,OAAA,CAAAC,qCAAA,GAAAA,qCAAA","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "useChatKeyboard", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useChatKeyboard.useChatKeyboard;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _useChatKeyboard = require("./useChatKeyboard");
|
|
13
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_useChatKeyboard","require"],"sources":["hooks.ts"],"sourcesContent":["export { useChatKeyboard } from \"./useChatKeyboard\";\nexport type { KeyboardLiftBehavior } from \"./useChatKeyboard/types\";\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA","ignoreList":[]}
|