@react-native-ohos/react-native-keyboard-controller 1.16.8 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.OpenSource +2 -2
- package/README.md +105 -29
- package/harmony/keyboard_controller/BuildProfile.ets +1 -1
- package/harmony/keyboard_controller/Index.ets +1 -0
- package/harmony/keyboard_controller/oh-package-lock.json5 +7 -7
- package/harmony/keyboard_controller/oh-package.json5 +1 -1
- 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/KeyboardControllerViewComponentInstance.cpp +8 -1
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +2 -2
- 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 +58 -1
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardControllerPackage.h +20 -0
- package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.cpp +65 -44
- package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.h +22 -3
- package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +17 -4
- package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +9 -1
- package/harmony/keyboard_controller/src/main/ets/{RNKeyboardControllerPackage.ts → RNKeyboardControllerPackage.ets} +9 -5
- package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +29 -5
- package/harmony/keyboard_controller/src/main/ets/Type.ts +2 -1
- package/harmony/keyboard_controller.har +0 -0
- package/lib/commonjs/animated.js +20 -9
- 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 +37 -2
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +25 -2
- 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 +36 -11
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +51 -16
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.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/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/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 +95 -84
- 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 +1 -1
- 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/index.js +27 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +36 -0
- 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/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/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/views/KeyboardExtender/index.js +30 -0
- package/lib/commonjs/views/KeyboardExtender/index.js.map +1 -0
- package/lib/commonjs/views/index.js +7 -0
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/module/animated.js +22 -11
- 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 +36 -2
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +24 -2
- 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 +35 -11
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +54 -19
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.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/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/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 +95 -85
- 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 +1 -1
- 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/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +35 -0
- 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/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/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/views/KeyboardExtender/index.js +23 -0
- package/lib/module/views/KeyboardExtender/index.js.map +1 -0
- 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 +80 -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 +15 -9
- package/src/animated.tsx +41 -48
- package/src/architecture.ts +1 -0
- package/src/bindings.native.ts +37 -2
- package/src/bindings.ts +40 -1
- package/src/compat.ts +44 -0
- package/src/components/KeyboardAvoidingView/hooks.ts +24 -17
- package/src/components/KeyboardAvoidingView/index.tsx +62 -18
- package/src/components/KeyboardAwareScrollView/index.tsx +75 -20
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +2 -2
- 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/KeyboardToolbar/Arrow.tsx +2 -2
- package/src/components/KeyboardToolbar/Button.tsx +4 -4
- 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 +143 -146
- package/src/components/KeyboardToolbar/types.ts +33 -1
- package/src/components/ScrollViewWithBottomPadding/index.tsx +216 -0
- package/src/components/ScrollViewWithBottomPadding/styles.ts +10 -0
- package/src/components/hooks/useColorScheme.ts +2 -1
- package/src/components/hooks/useCombinedRef.ts +22 -0
- package/src/components/hooks/useScrollState.ts +81 -0
- package/src/components/index.ts +3 -0
- package/src/constants.ts +4 -0
- package/src/context.ts +2 -0
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useKeyboardState/index.ts +52 -0
- package/src/index.ts +5 -1
- package/src/internal.ts +62 -0
- package/src/module.ts +21 -9
- package/src/specs/ClippingScrollViewDecoratorViewNativeComponent.ts +19 -0
- package/src/specs/KeyboardControllerViewNativeComponent.ts +14 -3
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +1 -0
- package/src/specs/KeyboardToolbarGroupViewNativeComponent.ts +10 -0
- package/src/specs/NativeKeyboardController.ts +6 -2
- package/src/types.ts +91 -5
- package/src/utils/findNodeHandle/index.native.ts +3 -0
- package/src/utils/findNodeHandle/index.ts +6 -0
- package/src/views/KeyboardExtender/index.tsx +30 -0
- package/src/views/index.ts +1 -0
- 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
- /package/harmony/keyboard_controller/{ts.ts → ts.ets} +0 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { interpolate } from "react-native-reanimated";
|
|
2
|
+
|
|
3
|
+
import type { KeyboardLiftBehavior } from "./types";
|
|
4
|
+
|
|
5
|
+
const AT_END_THRESHOLD = 20;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Map the current keyboard height to an effective height that accounts for a
|
|
9
|
+
* fixed offset (e.g. Bottom safe-area or tab-bar height)..
|
|
10
|
+
*
|
|
11
|
+
* @param height - Current keyboard height.
|
|
12
|
+
* @param targetKeyboardHeight - Full target keyboard height (captured on keyboard open).
|
|
13
|
+
* @param offset - Fixed distance between the scroll-view bottom and the screen bottom.
|
|
14
|
+
* @returns Effective height after subtracting the offset proportionally.
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* getEffectiveHeight(300, 300, 50); // 250
|
|
18
|
+
* getEffectiveHeight(150, 300, 50); // 125
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export const getEffectiveHeight = (
|
|
22
|
+
height: number,
|
|
23
|
+
targetKeyboardHeight: number,
|
|
24
|
+
offset: number,
|
|
25
|
+
): number => {
|
|
26
|
+
"worklet";
|
|
27
|
+
|
|
28
|
+
if (offset === 0 || targetKeyboardHeight === 0) {
|
|
29
|
+
return height;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return interpolate(
|
|
33
|
+
height,
|
|
34
|
+
[0, targetKeyboardHeight],
|
|
35
|
+
[0, Math.max(targetKeyboardHeight - offset, 0)],
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Check whether the scroll view is at the end of its content.
|
|
41
|
+
*
|
|
42
|
+
* For non-inverted lists the "end" is the bottom of the content.
|
|
43
|
+
* For inverted lists the "end" is the top (scroll offset near 0),
|
|
44
|
+
* because that is where the latest messages are displayed.
|
|
45
|
+
*
|
|
46
|
+
* @param scrollOffset - Current vertical scroll offset.
|
|
47
|
+
* @param layoutHeight - Visible height of the scroll view.
|
|
48
|
+
* @param contentHeight - Total height of the scrollable content.
|
|
49
|
+
* @param inverted - Whether the list is inverted.
|
|
50
|
+
* @returns `true` if the scroll position is within the threshold of the content end.
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const atEnd = isScrollAtEnd(100, 800, 920); // true (100 + 800 >= 920 - 20)
|
|
54
|
+
* const atEndInverted = isScrollAtEnd(5, 800, 2000, true); // true (5 <= 20)
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export const isScrollAtEnd = (
|
|
58
|
+
scrollOffset: number,
|
|
59
|
+
layoutHeight: number,
|
|
60
|
+
contentHeight: number,
|
|
61
|
+
inverted: boolean = false,
|
|
62
|
+
): boolean => {
|
|
63
|
+
"worklet";
|
|
64
|
+
|
|
65
|
+
if (inverted) {
|
|
66
|
+
return scrollOffset <= AT_END_THRESHOLD;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return scrollOffset + layoutHeight >= contentHeight - AT_END_THRESHOLD;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Decide whether content should be shifted based on the keyboard lift behavior.
|
|
74
|
+
*
|
|
75
|
+
* @param behavior - The configured keyboard lift behavior.
|
|
76
|
+
* @param isAtEnd - Whether the scroll view is currently at the end.
|
|
77
|
+
* @returns `true` if content should be shifted.
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* shouldShiftContent("always", false); // true
|
|
81
|
+
* shouldShiftContent("whenAtEnd", false); // false
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export const shouldShiftContent = (
|
|
85
|
+
behavior: KeyboardLiftBehavior,
|
|
86
|
+
isAtEnd: boolean,
|
|
87
|
+
): boolean => {
|
|
88
|
+
"worklet";
|
|
89
|
+
|
|
90
|
+
switch (behavior) {
|
|
91
|
+
case "always":
|
|
92
|
+
return true;
|
|
93
|
+
case "never":
|
|
94
|
+
return false;
|
|
95
|
+
case "whenAtEnd":
|
|
96
|
+
return isAtEnd;
|
|
97
|
+
case "persistent":
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Compute the fraction of minimum padding space currently visible in the viewport (0–1).
|
|
104
|
+
*
|
|
105
|
+
* The minimum padding space lives in the scroll view's contentInset, NOT in the
|
|
106
|
+
* content itself. So `contentHeight` (from onContentSizeChange / scroll
|
|
107
|
+
* events) does **not** include it. The visible portion is how far the
|
|
108
|
+
* viewport extends past the content boundary into the inset area.
|
|
109
|
+
*
|
|
110
|
+
* For non-inverted lists the padding is in contentInset.bottom.
|
|
111
|
+
* For inverted lists the padding is in contentInset.top (negative scroll).
|
|
112
|
+
*
|
|
113
|
+
* @param scrollOffset - Current vertical scroll offset.
|
|
114
|
+
* @param layoutHeight - Visible height of the scroll view.
|
|
115
|
+
* @param contentHeight - Height of the scroll content (excludes insets).
|
|
116
|
+
* @param blankSpace - Size of the minimum padding inset area.
|
|
117
|
+
* @param inverted - Whether the list is inverted.
|
|
118
|
+
* @returns A value between 0 (padding fully off-screen) and 1 (padding fully visible).
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* // Non-inverted: contentHeight=1500, layout=800, blankSpace=300
|
|
122
|
+
* getVisibleMinimumPaddingFraction(1500, 800, 1500, 300, false); // 1 (at end, viewport past content)
|
|
123
|
+
* getVisibleMinimumPaddingFraction(850, 800, 1500, 300, false); // 0.5 (half padding visible)
|
|
124
|
+
* getVisibleMinimumPaddingFraction(700, 800, 1500, 300, false); // 0 (padding off-screen)
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export const getVisibleMinimumPaddingFraction = (
|
|
128
|
+
scrollOffset: number,
|
|
129
|
+
layoutHeight: number,
|
|
130
|
+
contentHeight: number,
|
|
131
|
+
blankSpace: number,
|
|
132
|
+
inverted: boolean,
|
|
133
|
+
): number => {
|
|
134
|
+
"worklet";
|
|
135
|
+
|
|
136
|
+
if (blankSpace <= 0) {
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (inverted) {
|
|
141
|
+
// Minimum padding is in contentInset.top; visible when scroll < 0
|
|
142
|
+
return Math.max(0, Math.min(1, -scrollOffset / blankSpace));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Minimum padding is in contentInset.bottom; visible when viewport extends past content
|
|
146
|
+
const pastContentEnd = scrollOffset + layoutHeight - contentHeight;
|
|
147
|
+
|
|
148
|
+
return Math.max(0, Math.min(1, pastContentEnd / blankSpace));
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Compute how much of the minimum content padding absorbs the keyboard + extraContentPadding.
|
|
153
|
+
*
|
|
154
|
+
* @param blankSpace - Minimum inset floor.
|
|
155
|
+
* @param extraContentPadding - Extra content padding from external elements.
|
|
156
|
+
* @returns The portion of blankSpace that absorbs keyboard displacement.
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* getMinimumPaddingAbsorbed(500, 20); // 480
|
|
160
|
+
* getMinimumPaddingAbsorbed(0, 20); // 0
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export const getMinimumPaddingAbsorbed = (
|
|
164
|
+
blankSpace: number,
|
|
165
|
+
extraContentPadding: number,
|
|
166
|
+
): number => {
|
|
167
|
+
"worklet";
|
|
168
|
+
|
|
169
|
+
return Math.max(0, blankSpace - extraContentPadding);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Compute the effective scroll displacement after minimum padding absorption.
|
|
174
|
+
*
|
|
175
|
+
* @param rawEffective - Raw effective keyboard height.
|
|
176
|
+
* @param minimumPaddingAbsorbed - Amount absorbed by minimum content padding.
|
|
177
|
+
* @returns The scroll displacement after subtracting the absorbed portion.
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* getScrollEffective(300, 200); // 100
|
|
181
|
+
* getScrollEffective(300, 400); // 0
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export const getScrollEffective = (
|
|
185
|
+
rawEffective: number,
|
|
186
|
+
minimumPaddingAbsorbed: number,
|
|
187
|
+
): number => {
|
|
188
|
+
"worklet";
|
|
189
|
+
|
|
190
|
+
return Math.max(0, rawEffective - minimumPaddingAbsorbed);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Compute the clamped scroll target for non-inverted lists.
|
|
195
|
+
*
|
|
196
|
+
* @param offsetBeforeScroll - Scroll position before keyboard appeared.
|
|
197
|
+
* @param keyboardHeight - Current keyboard height (used for scroll displacement).
|
|
198
|
+
* @param contentHeight - Total height of the scrollable content.
|
|
199
|
+
* @param layoutHeight - Visible height of the scroll view.
|
|
200
|
+
* @param totalPaddingForMaxScroll - Total padding to use for maxScroll calculation. When provided, used instead of keyboardHeight for the scrollable range. Defaults to keyboardHeight.
|
|
201
|
+
* @returns Clamped scroll target between 0 and maxScroll.
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* clampedScrollTarget(100, 300, 1000, 800); // 400
|
|
205
|
+
* clampedScrollTarget(100, 100, 1000, 800, 500); // 200, maxScroll uses 500
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
export const clampedScrollTarget = (
|
|
209
|
+
offsetBeforeScroll: number,
|
|
210
|
+
keyboardHeight: number,
|
|
211
|
+
contentHeight: number,
|
|
212
|
+
layoutHeight: number,
|
|
213
|
+
totalPaddingForMaxScroll?: number,
|
|
214
|
+
): number => {
|
|
215
|
+
"worklet";
|
|
216
|
+
|
|
217
|
+
const paddingForMax =
|
|
218
|
+
totalPaddingForMaxScroll !== undefined
|
|
219
|
+
? totalPaddingForMaxScroll
|
|
220
|
+
: keyboardHeight;
|
|
221
|
+
const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
|
|
222
|
+
|
|
223
|
+
return Math.min(Math.max(offsetBeforeScroll + keyboardHeight, 0), maxScroll);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Compute contentOffset.y for iOS lists.
|
|
228
|
+
*
|
|
229
|
+
* @param relativeScroll - Scroll position relative to current inset.
|
|
230
|
+
* @param keyboardHeight - Target keyboard height (used for scroll displacement).
|
|
231
|
+
* @param contentHeight - Total height of the scrollable content.
|
|
232
|
+
* @param layoutHeight - Visible height of the scroll view.
|
|
233
|
+
* @param inverted - Whether the list is inverted.
|
|
234
|
+
* @param totalPaddingForMaxScroll - Total padding to use for maxScroll calculation. When provided, used instead of keyboardHeight for the scrollable range. Defaults to keyboardHeight.
|
|
235
|
+
* @returns The absolute contentOffset.y to set.
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* computeIOSContentOffset(100, 300, 1000, 800, false); // 400
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
export const computeIOSContentOffset = (
|
|
242
|
+
relativeScroll: number,
|
|
243
|
+
keyboardHeight: number,
|
|
244
|
+
contentHeight: number,
|
|
245
|
+
layoutHeight: number,
|
|
246
|
+
inverted: boolean,
|
|
247
|
+
totalPaddingForMaxScroll?: number,
|
|
248
|
+
): number => {
|
|
249
|
+
"worklet";
|
|
250
|
+
|
|
251
|
+
const paddingForMax =
|
|
252
|
+
totalPaddingForMaxScroll !== undefined
|
|
253
|
+
? totalPaddingForMaxScroll
|
|
254
|
+
: keyboardHeight;
|
|
255
|
+
|
|
256
|
+
if (inverted) {
|
|
257
|
+
const maxScroll = Math.max(contentHeight - layoutHeight, 0);
|
|
258
|
+
|
|
259
|
+
return Math.max(
|
|
260
|
+
Math.min(relativeScroll - keyboardHeight, maxScroll),
|
|
261
|
+
-paddingForMax,
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
|
|
266
|
+
|
|
267
|
+
return Math.min(Math.max(keyboardHeight + relativeScroll, 0), maxScroll);
|
|
268
|
+
};
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { useSharedValue } from "react-native-reanimated";
|
|
2
|
+
|
|
3
|
+
import { useKeyboardHandler } from "../../../hooks";
|
|
4
|
+
import useScrollState from "../../hooks/useScrollState";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
computeIOSContentOffset,
|
|
8
|
+
getEffectiveHeight,
|
|
9
|
+
getScrollEffective,
|
|
10
|
+
getVisibleMinimumPaddingFraction,
|
|
11
|
+
isScrollAtEnd,
|
|
12
|
+
shouldShiftContent,
|
|
13
|
+
} from "./helpers";
|
|
14
|
+
|
|
15
|
+
import type { UseChatKeyboardOptions, UseChatKeyboardReturn } from "./types";
|
|
16
|
+
import type { AnimatedRef } from "react-native-reanimated";
|
|
17
|
+
import type Reanimated from "react-native-reanimated";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Hook that manages keyboard-driven scrolling for chat-style scroll views.
|
|
21
|
+
* Calculates padding (extra scrollable space) and content shift values,
|
|
22
|
+
* using iOS-specific strategy (contentOffset set once in onStart).
|
|
23
|
+
*
|
|
24
|
+
* @param scrollViewRef - Animated ref to the scroll view.
|
|
25
|
+
* @param options - Configuration for inverted and keyboardLiftBehavior.
|
|
26
|
+
* @returns Shared values for padding and contentOffsetY.
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* const { padding, contentOffsetY } = useChatKeyboard(ref, {
|
|
30
|
+
* inverted: false,
|
|
31
|
+
* keyboardLiftBehavior: "always",
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function useChatKeyboard(
|
|
36
|
+
scrollViewRef: AnimatedRef<Reanimated.ScrollView>,
|
|
37
|
+
options: UseChatKeyboardOptions,
|
|
38
|
+
): UseChatKeyboardReturn {
|
|
39
|
+
const {
|
|
40
|
+
inverted,
|
|
41
|
+
keyboardLiftBehavior,
|
|
42
|
+
freeze,
|
|
43
|
+
offset,
|
|
44
|
+
blankSpace,
|
|
45
|
+
extraContentPadding,
|
|
46
|
+
} = options;
|
|
47
|
+
|
|
48
|
+
const padding = useSharedValue(0);
|
|
49
|
+
const currentHeight = useSharedValue(0);
|
|
50
|
+
const contentOffsetY = useSharedValue(0);
|
|
51
|
+
const targetKeyboardHeight = useSharedValue(0);
|
|
52
|
+
const prevAbsorption = useSharedValue(0);
|
|
53
|
+
|
|
54
|
+
const {
|
|
55
|
+
layout,
|
|
56
|
+
size,
|
|
57
|
+
offset: scroll,
|
|
58
|
+
onLayout,
|
|
59
|
+
onContentSizeChange,
|
|
60
|
+
} = useScrollState(scrollViewRef);
|
|
61
|
+
|
|
62
|
+
useKeyboardHandler(
|
|
63
|
+
{
|
|
64
|
+
onStart: (e) => {
|
|
65
|
+
"worklet";
|
|
66
|
+
|
|
67
|
+
if (freeze.value) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (e.height > 0) {
|
|
72
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
73
|
+
targetKeyboardHeight.value = e.height;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const effective = getEffectiveHeight(
|
|
77
|
+
e.height,
|
|
78
|
+
targetKeyboardHeight.value,
|
|
79
|
+
offset,
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const atEnd = isScrollAtEnd(
|
|
83
|
+
scroll.value,
|
|
84
|
+
layout.value.height,
|
|
85
|
+
size.value.height,
|
|
86
|
+
inverted,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// Scale minimum padding absorption by how much of it is visible.
|
|
90
|
+
// Fully visible → full absorption; fully off-screen → no absorption.
|
|
91
|
+
const visibleFraction = getVisibleMinimumPaddingFraction(
|
|
92
|
+
scroll.value,
|
|
93
|
+
layout.value.height,
|
|
94
|
+
size.value.height,
|
|
95
|
+
blankSpace.value,
|
|
96
|
+
inverted,
|
|
97
|
+
);
|
|
98
|
+
const visiblePadding = visibleFraction * blankSpace.value;
|
|
99
|
+
const minimumPaddingAbsorbed = Math.max(
|
|
100
|
+
0,
|
|
101
|
+
visiblePadding - extraContentPadding.value,
|
|
102
|
+
);
|
|
103
|
+
const scrollEffective = getScrollEffective(
|
|
104
|
+
effective,
|
|
105
|
+
minimumPaddingAbsorbed,
|
|
106
|
+
);
|
|
107
|
+
const actualTotalPadding = Math.max(
|
|
108
|
+
blankSpace.value,
|
|
109
|
+
effective + extraContentPadding.value,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// persistent mode: when keyboard shrinks, clamp to valid range
|
|
113
|
+
if (
|
|
114
|
+
keyboardLiftBehavior === "persistent" &&
|
|
115
|
+
effective < padding.value
|
|
116
|
+
) {
|
|
117
|
+
padding.value = effective;
|
|
118
|
+
prevAbsorption.value = minimumPaddingAbsorbed;
|
|
119
|
+
|
|
120
|
+
if (inverted) {
|
|
121
|
+
const maxScroll = Math.max(
|
|
122
|
+
size.value.height - layout.value.height,
|
|
123
|
+
0,
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
contentOffsetY.value = Math.max(
|
|
127
|
+
-actualTotalPadding,
|
|
128
|
+
Math.min(scroll.value, maxScroll),
|
|
129
|
+
);
|
|
130
|
+
} else {
|
|
131
|
+
const maxScroll = Math.max(
|
|
132
|
+
size.value.height - layout.value.height + actualTotalPadding,
|
|
133
|
+
0,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
contentOffsetY.value = Math.max(
|
|
137
|
+
0,
|
|
138
|
+
Math.min(scroll.value, maxScroll),
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// never mode: when keyboard shrinks, clamp to valid range
|
|
146
|
+
// to avoid ghost padding
|
|
147
|
+
if (
|
|
148
|
+
keyboardLiftBehavior === "never" &&
|
|
149
|
+
effective < padding.value &&
|
|
150
|
+
atEnd
|
|
151
|
+
) {
|
|
152
|
+
padding.value = effective;
|
|
153
|
+
prevAbsorption.value = minimumPaddingAbsorbed;
|
|
154
|
+
|
|
155
|
+
if (inverted) {
|
|
156
|
+
const maxScroll = Math.max(
|
|
157
|
+
size.value.height - layout.value.height,
|
|
158
|
+
0,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
contentOffsetY.value = Math.max(
|
|
162
|
+
-actualTotalPadding,
|
|
163
|
+
Math.min(scroll.value, maxScroll),
|
|
164
|
+
);
|
|
165
|
+
} else {
|
|
166
|
+
const maxScroll = Math.max(
|
|
167
|
+
size.value.height - layout.value.height + actualTotalPadding,
|
|
168
|
+
0,
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
contentOffsetY.value = Math.max(
|
|
172
|
+
0,
|
|
173
|
+
Math.min(scroll.value, maxScroll),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Undo only the scroll displacement that was actually applied
|
|
181
|
+
// (not the full padding, which includes the absorbed portion).
|
|
182
|
+
// Use the stored absorption from the previous event so that
|
|
183
|
+
// the unwind matches the shift that was originally applied.
|
|
184
|
+
const prevScrollEffective = getScrollEffective(
|
|
185
|
+
padding.value,
|
|
186
|
+
prevAbsorption.value,
|
|
187
|
+
);
|
|
188
|
+
const relativeScroll = inverted
|
|
189
|
+
? scroll.value + prevScrollEffective
|
|
190
|
+
: scroll.value - prevScrollEffective;
|
|
191
|
+
|
|
192
|
+
padding.value = effective;
|
|
193
|
+
prevAbsorption.value = minimumPaddingAbsorbed;
|
|
194
|
+
|
|
195
|
+
if (!shouldShiftContent(keyboardLiftBehavior, atEnd)) {
|
|
196
|
+
// Preserve current scroll position so animated props
|
|
197
|
+
// don't re-apply a stale contentOffset when padding changes
|
|
198
|
+
contentOffsetY.value = scroll.value;
|
|
199
|
+
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// When blankSpace fully absorbs the keyboard opening, preserve current scroll position
|
|
204
|
+
// (only when keyboard is open — effective > 0 — not when closing)
|
|
205
|
+
if (
|
|
206
|
+
scrollEffective === 0 &&
|
|
207
|
+
minimumPaddingAbsorbed > 0 &&
|
|
208
|
+
effective > 0
|
|
209
|
+
) {
|
|
210
|
+
contentOffsetY.value = scroll.value;
|
|
211
|
+
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
contentOffsetY.value = computeIOSContentOffset(
|
|
216
|
+
relativeScroll,
|
|
217
|
+
scrollEffective,
|
|
218
|
+
size.value.height,
|
|
219
|
+
layout.value.height,
|
|
220
|
+
inverted,
|
|
221
|
+
actualTotalPadding,
|
|
222
|
+
);
|
|
223
|
+
},
|
|
224
|
+
onMove: () => {
|
|
225
|
+
"worklet";
|
|
226
|
+
|
|
227
|
+
// iOS doesn't need per-frame updates (contentOffset handles it)
|
|
228
|
+
},
|
|
229
|
+
onEnd: (e) => {
|
|
230
|
+
"worklet";
|
|
231
|
+
|
|
232
|
+
if (freeze.value) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const effective = getEffectiveHeight(
|
|
237
|
+
e.height,
|
|
238
|
+
targetKeyboardHeight.value,
|
|
239
|
+
offset,
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
padding.value = effective;
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
[inverted, keyboardLiftBehavior, offset, extraContentPadding],
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
padding,
|
|
250
|
+
currentHeight,
|
|
251
|
+
contentOffsetY,
|
|
252
|
+
scroll,
|
|
253
|
+
layout,
|
|
254
|
+
size,
|
|
255
|
+
onLayout,
|
|
256
|
+
onContentSizeChange,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export { useChatKeyboard };
|