@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,216 @@
|
|
|
1
|
+
import React, { forwardRef, useState } from "react";
|
|
2
|
+
import { Platform } from "react-native";
|
|
3
|
+
import Reanimated, {
|
|
4
|
+
runOnJS,
|
|
5
|
+
useAnimatedProps,
|
|
6
|
+
useAnimatedReaction,
|
|
7
|
+
useDerivedValue,
|
|
8
|
+
useSharedValue,
|
|
9
|
+
} from "react-native-reanimated";
|
|
10
|
+
|
|
11
|
+
import { ClippingScrollView } from "../../bindings";
|
|
12
|
+
|
|
13
|
+
import styles from "./styles";
|
|
14
|
+
|
|
15
|
+
import type { ScrollViewProps } from "react-native";
|
|
16
|
+
import type { SharedValue } from "react-native-reanimated";
|
|
17
|
+
|
|
18
|
+
const OS = Platform.OS;
|
|
19
|
+
const ReanimatedClippingScrollView =
|
|
20
|
+
OS === "android" || (OS as string) === "harmony"
|
|
21
|
+
? Reanimated.createAnimatedComponent(ClippingScrollView)
|
|
22
|
+
: ClippingScrollView;
|
|
23
|
+
|
|
24
|
+
type AnimatedScrollViewProps = React.ComponentProps<
|
|
25
|
+
typeof Reanimated.ScrollView
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
export type AnimatedScrollViewComponent = React.ForwardRefExoticComponent<
|
|
29
|
+
AnimatedScrollViewProps & React.RefAttributes<Reanimated.ScrollView>
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
export type ScrollViewContentInsets = {
|
|
33
|
+
top: number;
|
|
34
|
+
bottom: number;
|
|
35
|
+
left: number;
|
|
36
|
+
right: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type ScrollViewWithBottomPaddingProps = {
|
|
40
|
+
ScrollViewComponent: AnimatedScrollViewComponent;
|
|
41
|
+
children?: React.ReactNode;
|
|
42
|
+
inverted?: boolean;
|
|
43
|
+
bottomPadding: SharedValue<number>;
|
|
44
|
+
/** Padding for scroll indicator insets (excludes blankSpace). Falls back to bottomPadding when not provided. */
|
|
45
|
+
scrollIndicatorPadding?: SharedValue<number>;
|
|
46
|
+
/** Absolute Y content offset (iOS only, for KeyboardChatScrollView). */
|
|
47
|
+
contentOffsetY?: SharedValue<number>;
|
|
48
|
+
applyWorkaroundForContentInsetHitTestBug?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Fires whenever the effective content inset changes (combines the static `contentInset`
|
|
51
|
+
* prop with the dynamic keyboard-driven padding). Useful on Android where the synthetic
|
|
52
|
+
* inset is not reflected in `onScroll` events.
|
|
53
|
+
*/
|
|
54
|
+
onContentInsetChange?: (insets: ScrollViewContentInsets) => void;
|
|
55
|
+
} & ScrollViewProps;
|
|
56
|
+
|
|
57
|
+
const ScrollViewWithBottomPadding = forwardRef<
|
|
58
|
+
Reanimated.ScrollView,
|
|
59
|
+
ScrollViewWithBottomPaddingProps
|
|
60
|
+
>(
|
|
61
|
+
(
|
|
62
|
+
{
|
|
63
|
+
ScrollViewComponent,
|
|
64
|
+
bottomPadding,
|
|
65
|
+
scrollIndicatorPadding,
|
|
66
|
+
contentInset,
|
|
67
|
+
scrollIndicatorInsets,
|
|
68
|
+
inverted,
|
|
69
|
+
contentOffsetY,
|
|
70
|
+
applyWorkaroundForContentInsetHitTestBug,
|
|
71
|
+
onContentInsetChange,
|
|
72
|
+
contentContainerStyle,
|
|
73
|
+
children,
|
|
74
|
+
...rest
|
|
75
|
+
},
|
|
76
|
+
ref,
|
|
77
|
+
) => {
|
|
78
|
+
const prevContentOffsetY = useSharedValue<number | null>(null);
|
|
79
|
+
|
|
80
|
+
// HarmonyOS workaround: ArkUI ScrollView's scrollable range only follows
|
|
81
|
+
// contentSize (contentInset prop is dropped, padding/scrollToOverflowEnabled
|
|
82
|
+
// don't extend it). So we mirror the keyboard-driven bottomPadding into the
|
|
83
|
+
// inner ScrollView's contentContainerStyle.paddingBottom to actually expand
|
|
84
|
+
// contentSize, letting the worklet's scrollTo reach the keyboard area.
|
|
85
|
+
const isHarmony = (OS as string) === "harmony";
|
|
86
|
+
const [harmonyKbPad, setHarmonyKbPad] = useState(0);
|
|
87
|
+
useAnimatedReaction(
|
|
88
|
+
() => (isHarmony ? bottomPadding.value : 0),
|
|
89
|
+
(cur, prev) => {
|
|
90
|
+
if (isHarmony && cur !== prev) {
|
|
91
|
+
runOnJS(setHarmonyKbPad)(Math.round(cur));
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
[isHarmony],
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const insets = useDerivedValue(() => {
|
|
98
|
+
const dynamicTop = inverted ? bottomPadding.value : 0;
|
|
99
|
+
const dynamicBottom = !inverted ? bottomPadding.value : 0;
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
dynamic: {
|
|
103
|
+
top: dynamicTop,
|
|
104
|
+
bottom: dynamicBottom,
|
|
105
|
+
},
|
|
106
|
+
effective: {
|
|
107
|
+
top: dynamicTop + (contentInset?.top || 0),
|
|
108
|
+
bottom: dynamicBottom + (contentInset?.bottom || 0),
|
|
109
|
+
left: contentInset?.left || 0,
|
|
110
|
+
right: contentInset?.right || 0,
|
|
111
|
+
} as ScrollViewContentInsets,
|
|
112
|
+
};
|
|
113
|
+
}, [
|
|
114
|
+
inverted,
|
|
115
|
+
contentInset?.top,
|
|
116
|
+
contentInset?.bottom,
|
|
117
|
+
contentInset?.left,
|
|
118
|
+
contentInset?.right,
|
|
119
|
+
]);
|
|
120
|
+
|
|
121
|
+
useAnimatedReaction(
|
|
122
|
+
() => insets.value.effective,
|
|
123
|
+
(current, previous) => {
|
|
124
|
+
if (!onContentInsetChange) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (
|
|
128
|
+
previous &&
|
|
129
|
+
current.top === previous.top &&
|
|
130
|
+
current.bottom === previous.bottom &&
|
|
131
|
+
current.left === previous.left &&
|
|
132
|
+
current.right === previous.right
|
|
133
|
+
) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
runOnJS(onContentInsetChange)(current);
|
|
137
|
+
},
|
|
138
|
+
[onContentInsetChange],
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const animatedProps = useAnimatedProps(() => {
|
|
142
|
+
const { dynamic, effective } = insets.value;
|
|
143
|
+
|
|
144
|
+
const indicatorPadding = scrollIndicatorPadding ?? bottomPadding;
|
|
145
|
+
const indicatorTop =
|
|
146
|
+
(inverted ? indicatorPadding.value : 0) +
|
|
147
|
+
(scrollIndicatorInsets?.top || 0);
|
|
148
|
+
const indicatorBottom =
|
|
149
|
+
(!inverted ? indicatorPadding.value : 0) +
|
|
150
|
+
(scrollIndicatorInsets?.bottom || 0);
|
|
151
|
+
|
|
152
|
+
const result: Record<string, unknown> = {
|
|
153
|
+
// iOS prop
|
|
154
|
+
contentInset: effective,
|
|
155
|
+
scrollIndicatorInsets: {
|
|
156
|
+
bottom: indicatorBottom,
|
|
157
|
+
top: indicatorTop,
|
|
158
|
+
right: scrollIndicatorInsets?.right,
|
|
159
|
+
left: scrollIndicatorInsets?.left,
|
|
160
|
+
},
|
|
161
|
+
// Android prop
|
|
162
|
+
contentInsetBottom: dynamic.bottom,
|
|
163
|
+
contentInsetTop: dynamic.top,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
if (contentOffsetY) {
|
|
167
|
+
const curr = contentOffsetY.value;
|
|
168
|
+
|
|
169
|
+
if (curr !== prevContentOffsetY.value) {
|
|
170
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
171
|
+
prevContentOffsetY.value = curr;
|
|
172
|
+
result.contentOffset = { x: 0, y: curr };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return result;
|
|
177
|
+
}, [
|
|
178
|
+
scrollIndicatorInsets?.bottom,
|
|
179
|
+
scrollIndicatorInsets?.top,
|
|
180
|
+
scrollIndicatorInsets?.right,
|
|
181
|
+
scrollIndicatorInsets?.left,
|
|
182
|
+
inverted,
|
|
183
|
+
contentOffsetY,
|
|
184
|
+
]);
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<ReanimatedClippingScrollView
|
|
188
|
+
animatedProps={animatedProps}
|
|
189
|
+
applyWorkaroundForContentInsetHitTestBug={
|
|
190
|
+
applyWorkaroundForContentInsetHitTestBug
|
|
191
|
+
}
|
|
192
|
+
style={styles.container}
|
|
193
|
+
>
|
|
194
|
+
<ScrollViewComponent
|
|
195
|
+
ref={ref}
|
|
196
|
+
animatedProps={animatedProps}
|
|
197
|
+
{...rest}
|
|
198
|
+
contentContainerStyle={
|
|
199
|
+
isHarmony
|
|
200
|
+
? [
|
|
201
|
+
contentContainerStyle,
|
|
202
|
+
inverted
|
|
203
|
+
? { paddingTop: harmonyKbPad }
|
|
204
|
+
: { paddingBottom: harmonyKbPad },
|
|
205
|
+
]
|
|
206
|
+
: contentContainerStyle
|
|
207
|
+
}
|
|
208
|
+
>
|
|
209
|
+
{children}
|
|
210
|
+
</ScrollViewComponent>
|
|
211
|
+
</ReanimatedClippingScrollView>
|
|
212
|
+
);
|
|
213
|
+
},
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
export default ScrollViewWithBottomPadding;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
|
|
3
|
+
import type { MutableRefObject, Ref, RefCallback } from "react";
|
|
4
|
+
|
|
5
|
+
const useCombinedRef = <T>(...refs: Ref<T>[]): RefCallback<T> => {
|
|
6
|
+
return useCallback((value: T | null) => {
|
|
7
|
+
for (const ref of refs) {
|
|
8
|
+
if (!ref) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (typeof ref === "function") {
|
|
13
|
+
ref(value);
|
|
14
|
+
} else {
|
|
15
|
+
(ref as MutableRefObject<T | null>).current = value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
19
|
+
}, refs);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default useCombinedRef;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useCallback, useEffect } from "react";
|
|
2
|
+
import { useEvent, useSharedValue } from "react-native-reanimated";
|
|
3
|
+
|
|
4
|
+
import { useEventHandlerRegistration } from "../../internal";
|
|
5
|
+
|
|
6
|
+
import type { LayoutChangeEvent } from "react-native";
|
|
7
|
+
import type { AnimatedRef } from "react-native-reanimated";
|
|
8
|
+
import type Reanimated from "react-native-reanimated";
|
|
9
|
+
|
|
10
|
+
const NATIVE_SCROLL_EVENT_NAMES = [
|
|
11
|
+
"onScroll",
|
|
12
|
+
"onScrollBeginDrag",
|
|
13
|
+
"onScrollEndDrag",
|
|
14
|
+
"onMomentumScrollBegin",
|
|
15
|
+
"onMomentumScrollEnd",
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
type ScrollEvent = {
|
|
19
|
+
contentOffset: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
};
|
|
23
|
+
layoutMeasurement: {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
};
|
|
27
|
+
contentSize: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const useScrollState = (ref: AnimatedRef<Reanimated.ScrollView>) => {
|
|
34
|
+
const offset = useSharedValue(0);
|
|
35
|
+
const layout = useSharedValue({ width: 0, height: 0 });
|
|
36
|
+
const size = useSharedValue({ width: 0, height: 0 });
|
|
37
|
+
|
|
38
|
+
const register = useEventHandlerRegistration(ref);
|
|
39
|
+
|
|
40
|
+
const eventHandler = useEvent((event: ScrollEvent) => {
|
|
41
|
+
"worklet";
|
|
42
|
+
|
|
43
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
44
|
+
offset.value = event.contentOffset.y;
|
|
45
|
+
layout.value = event.layoutMeasurement;
|
|
46
|
+
size.value = event.contentSize;
|
|
47
|
+
}, NATIVE_SCROLL_EVENT_NAMES);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const cleanup = register(eventHandler);
|
|
51
|
+
|
|
52
|
+
return () => {
|
|
53
|
+
cleanup();
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
57
|
+
// `onContentSizeChange` is synthesized in JS (from the content container's
|
|
58
|
+
// onLayout) and `onLayout` has a different payload shape than scroll events,
|
|
59
|
+
// so neither can be reliably captured via native event registration.
|
|
60
|
+
// Instead we expose callbacks for the consumer to attach as props.
|
|
61
|
+
const onLayout = useCallback(
|
|
62
|
+
(e: LayoutChangeEvent) => {
|
|
63
|
+
layout.value = {
|
|
64
|
+
width: e.nativeEvent.layout.width,
|
|
65
|
+
height: e.nativeEvent.layout.height,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
[layout],
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const onContentSizeChange = useCallback(
|
|
72
|
+
(w: number, h: number) => {
|
|
73
|
+
size.value = { width: w, height: h };
|
|
74
|
+
},
|
|
75
|
+
[size],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return { offset, layout, size, onLayout, onContentSizeChange };
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default useScrollState;
|
package/src/components/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as KeyboardAvoidingView } from "./KeyboardAvoidingView";
|
|
2
2
|
export { default as KeyboardStickyView } from "./KeyboardStickyView";
|
|
3
3
|
export { default as KeyboardAwareScrollView } from "./KeyboardAwareScrollView";
|
|
4
|
+
export { default as KeyboardChatScrollView } from "./KeyboardChatScrollView";
|
|
4
5
|
export {
|
|
5
6
|
default as KeyboardToolbar,
|
|
6
7
|
DefaultKeyboardToolbarTheme,
|
|
@@ -8,4 +9,6 @@ export {
|
|
|
8
9
|
export type { KeyboardAvoidingViewProps } from "./KeyboardAvoidingView";
|
|
9
10
|
export type { KeyboardStickyViewProps } from "./KeyboardStickyView";
|
|
10
11
|
export type { KeyboardAwareScrollViewProps } from "./KeyboardAwareScrollView";
|
|
12
|
+
export type { KeyboardAwareScrollViewRef } from "./KeyboardAwareScrollView";
|
|
13
|
+
export type { KeyboardChatScrollViewProps } from "./KeyboardChatScrollView/types";
|
|
11
14
|
export type { KeyboardToolbarProps } from "./KeyboardToolbar";
|
package/src/constants.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { KeyboardControllerNative } from "./bindings";
|
|
2
|
+
|
|
1
3
|
// copied from `android.view.WindowManager.LayoutParams`
|
|
2
4
|
export enum AndroidSoftInputModes {
|
|
3
5
|
SOFT_INPUT_ADJUST_NOTHING = 48,
|
|
@@ -17,3 +19,5 @@ export enum AndroidSoftInputModes {
|
|
|
17
19
|
SOFT_INPUT_STATE_UNSPECIFIED = 0,
|
|
18
20
|
SOFT_INPUT_STATE_VISIBLE = 4,
|
|
19
21
|
}
|
|
22
|
+
export const KEYBOARD_BORDER_RADIUS =
|
|
23
|
+
KeyboardControllerNative.getConstants().keyboardBorderRadius;
|
package/src/context.ts
CHANGED
|
@@ -22,6 +22,7 @@ export type KeyboardAnimationContext = {
|
|
|
22
22
|
animated: AnimatedContext;
|
|
23
23
|
reanimated: ReanimatedContext;
|
|
24
24
|
layout: SharedValue<FocusedInputLayoutChangedEvent | null>;
|
|
25
|
+
update: () => Promise<void>;
|
|
25
26
|
setKeyboardHandlers: (handlers: KeyboardHandlers) => void;
|
|
26
27
|
setInputHandlers: (handlers: FocusedInputHandlers) => void;
|
|
27
28
|
setEnabled: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -51,6 +52,7 @@ const defaultContext: KeyboardAnimationContext = {
|
|
|
51
52
|
height: DEFAULT_SHARED_VALUE,
|
|
52
53
|
},
|
|
53
54
|
layout: DEFAULT_LAYOUT,
|
|
55
|
+
update: () => Promise.resolve(),
|
|
54
56
|
setKeyboardHandlers: NESTED_NOOP,
|
|
55
57
|
setInputHandlers: NESTED_NOOP,
|
|
56
58
|
setEnabled: NOOP,
|
package/src/hooks/index.ts
CHANGED
|
@@ -67,7 +67,7 @@ export function useKeyboardController() {
|
|
|
67
67
|
export function useReanimatedFocusedInput() {
|
|
68
68
|
const context = useKeyboardContext();
|
|
69
69
|
|
|
70
|
-
return { input: context.layout };
|
|
70
|
+
return { input: context.layout, update: context.update };
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export function useFocusedInputHandler(
|
|
@@ -88,3 +88,4 @@ export function useFocusedInputHandler(
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export * from "./useWindowDimensions";
|
|
91
|
+
export * from "./useKeyboardState";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { KeyboardEvents } from "../../bindings";
|
|
4
|
+
import { KeyboardController } from "../../module";
|
|
5
|
+
|
|
6
|
+
import type { IKeyboardState } from "../../types";
|
|
7
|
+
|
|
8
|
+
const EVENTS = ["keyboardDidShow", "keyboardDidHide"] as const;
|
|
9
|
+
|
|
10
|
+
const getLatestState = () => ({
|
|
11
|
+
...KeyboardController.state(),
|
|
12
|
+
isVisible: KeyboardController.isVisible(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
type KeyboardStateSelector<T> = (state: IKeyboardState) => T;
|
|
16
|
+
|
|
17
|
+
const defaultSelector: KeyboardStateSelector<IKeyboardState> = (state) => state;
|
|
18
|
+
|
|
19
|
+
export function useKeyboardState<T = IKeyboardState>(
|
|
20
|
+
selector: KeyboardStateSelector<T> = defaultSelector as KeyboardStateSelector<T>,
|
|
21
|
+
): T {
|
|
22
|
+
const [state, setState] = useState<T>(() => selector(getLatestState()));
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const subscriptions = EVENTS.map((event) =>
|
|
26
|
+
KeyboardEvents.addListener(event, () =>
|
|
27
|
+
// state will be updated by global listener first,
|
|
28
|
+
// so we simply read it and don't derive data from the event
|
|
29
|
+
setState(selector(getLatestState())),
|
|
30
|
+
),
|
|
31
|
+
);
|
|
32
|
+
const willShowSubscription = KeyboardEvents.addListener(
|
|
33
|
+
"keyboardWillShow",
|
|
34
|
+
(event) =>
|
|
35
|
+
setState(
|
|
36
|
+
selector({ ...getLatestState(), appearance: event.appearance }),
|
|
37
|
+
),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// we might have missed an update between reading a value in render and
|
|
41
|
+
// `addListener` in this handler, so we set it here. If there was
|
|
42
|
+
// no change, React will filter out this update as a no-op.
|
|
43
|
+
setState(selector(getLatestState()));
|
|
44
|
+
|
|
45
|
+
return () => {
|
|
46
|
+
subscriptions.forEach((subscription) => subscription.remove());
|
|
47
|
+
willShowSubscription.remove();
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
return state;
|
|
52
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,8 +5,10 @@ export * from "./hooks";
|
|
|
5
5
|
export * from "./constants";
|
|
6
6
|
export * from "./module";
|
|
7
7
|
export * from "./types";
|
|
8
|
+
export * from "./compat";
|
|
8
9
|
|
|
9
10
|
export {
|
|
11
|
+
KeyboardChatScrollView,
|
|
10
12
|
KeyboardAvoidingView,
|
|
11
13
|
KeyboardStickyView,
|
|
12
14
|
KeyboardAwareScrollView,
|
|
@@ -15,9 +17,11 @@ export {
|
|
|
15
17
|
DefaultKeyboardToolbarTheme,
|
|
16
18
|
} from "./components";
|
|
17
19
|
export type {
|
|
20
|
+
KeyboardChatScrollViewProps,
|
|
18
21
|
KeyboardAvoidingViewProps,
|
|
19
22
|
KeyboardStickyViewProps,
|
|
20
23
|
KeyboardAwareScrollViewProps,
|
|
24
|
+
KeyboardAwareScrollViewRef,
|
|
21
25
|
KeyboardToolbarProps,
|
|
22
26
|
} from "./components";
|
|
23
|
-
export { OverKeyboardView } from "./views";
|
|
27
|
+
export { OverKeyboardView, KeyboardExtender } from "./views";
|
package/src/internal.ts
CHANGED
|
@@ -2,8 +2,70 @@ import { useCallback, useRef } from "react";
|
|
|
2
2
|
import { Animated } from "react-native";
|
|
3
3
|
import { useSharedValue } from "react-native-reanimated";
|
|
4
4
|
|
|
5
|
+
import { findNodeHandle } from "./utils/findNodeHandle";
|
|
6
|
+
|
|
7
|
+
import type { EventHandlerProcessed } from "react-native-reanimated";
|
|
5
8
|
import type { Handlers } from "./types";
|
|
6
9
|
|
|
10
|
+
type ComponentOrHandle = Parameters<typeof findNodeHandle>[0];
|
|
11
|
+
|
|
12
|
+
type WorkletHandler = {
|
|
13
|
+
registerForEvents: (viewTag: number) => void;
|
|
14
|
+
unregisterFromEvents: (viewTag: number) => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type WorkletHandlerOrWorkletHandlerObject =
|
|
18
|
+
| WorkletHandler
|
|
19
|
+
| {
|
|
20
|
+
workletEventHandler: WorkletHandler;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function useEventHandlerRegistration(
|
|
24
|
+
viewTagRef: React.MutableRefObject<ComponentOrHandle>,
|
|
25
|
+
) {
|
|
26
|
+
const onRegisterHandler = (handler: EventHandlerProcessed<never, never>) => {
|
|
27
|
+
const currentHandler =
|
|
28
|
+
handler as unknown as WorkletHandlerOrWorkletHandlerObject;
|
|
29
|
+
const attachWorkletHandlers = () => {
|
|
30
|
+
const viewTag = findNodeHandle(viewTagRef.current);
|
|
31
|
+
|
|
32
|
+
if (__DEV__ && !viewTag) {
|
|
33
|
+
console.warn(
|
|
34
|
+
"Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.",
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (viewTag) {
|
|
39
|
+
if ("workletEventHandler" in currentHandler) {
|
|
40
|
+
currentHandler.workletEventHandler.registerForEvents(viewTag);
|
|
41
|
+
} else {
|
|
42
|
+
currentHandler.registerForEvents(viewTag);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
if (viewTagRef.current) {
|
|
48
|
+
attachWorkletHandlers();
|
|
49
|
+
} else {
|
|
50
|
+
queueMicrotask(attachWorkletHandlers);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return () => {
|
|
54
|
+
const viewTag = findNodeHandle(viewTagRef.current);
|
|
55
|
+
|
|
56
|
+
if (viewTag) {
|
|
57
|
+
if ("workletEventHandler" in currentHandler) {
|
|
58
|
+
currentHandler.workletEventHandler.unregisterFromEvents(viewTag);
|
|
59
|
+
} else {
|
|
60
|
+
currentHandler.unregisterFromEvents(viewTag);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return onRegisterHandler;
|
|
67
|
+
}
|
|
68
|
+
|
|
7
69
|
type UntypedHandler = Record<string, (event: never) => void>;
|
|
8
70
|
type SharedHandlersReturnType<T extends UntypedHandler> = [
|
|
9
71
|
(handler: Handlers<T>) => void,
|
package/src/module.ts
CHANGED
|
@@ -6,22 +6,31 @@ import type {
|
|
|
6
6
|
KeyboardEventData,
|
|
7
7
|
} from "./types";
|
|
8
8
|
|
|
9
|
-
let isClosed =
|
|
10
|
-
let
|
|
9
|
+
let isClosed = true;
|
|
10
|
+
let lastState: KeyboardEventData = {
|
|
11
|
+
height: 0,
|
|
12
|
+
tag: -1,
|
|
13
|
+
duration: 0,
|
|
14
|
+
timestamp: new Date().getTime(),
|
|
15
|
+
target: -1,
|
|
16
|
+
type: "default",
|
|
17
|
+
appearance: "light",
|
|
18
|
+
};
|
|
11
19
|
|
|
12
20
|
KeyboardEvents.addListener("keyboardDidHide", (e) => {
|
|
13
21
|
isClosed = true;
|
|
14
|
-
|
|
22
|
+
lastState = e;
|
|
15
23
|
});
|
|
16
24
|
|
|
17
25
|
KeyboardEvents.addListener("keyboardDidShow", (e) => {
|
|
18
26
|
isClosed = false;
|
|
19
|
-
|
|
27
|
+
lastState = e;
|
|
20
28
|
});
|
|
21
29
|
|
|
22
|
-
const dismiss = async (
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
const dismiss = async (options?: Partial<DismissOptions>): Promise<void> => {
|
|
31
|
+
const keepFocus = options?.keepFocus ?? false;
|
|
32
|
+
const animated = options?.animated ?? true;
|
|
33
|
+
|
|
25
34
|
return new Promise((resolve) => {
|
|
26
35
|
if (isClosed) {
|
|
27
36
|
resolve();
|
|
@@ -34,19 +43,22 @@ const dismiss = async (
|
|
|
34
43
|
subscription.remove();
|
|
35
44
|
});
|
|
36
45
|
|
|
37
|
-
KeyboardControllerNative.dismiss(keepFocus);
|
|
46
|
+
KeyboardControllerNative.dismiss(keepFocus, animated);
|
|
38
47
|
});
|
|
39
48
|
};
|
|
40
49
|
const isVisible = () => !isClosed;
|
|
41
|
-
const state = () =>
|
|
50
|
+
const state = () => lastState;
|
|
51
|
+
const preload = KeyboardControllerNative.preload ?? (() => {});
|
|
42
52
|
|
|
43
53
|
export const KeyboardController: KeyboardControllerModule = {
|
|
44
54
|
setDefaultMode: KeyboardControllerNative.setDefaultMode,
|
|
45
55
|
setInputMode: KeyboardControllerNative.setInputMode,
|
|
46
56
|
setFocusTo: KeyboardControllerNative.setFocusTo,
|
|
57
|
+
preload,
|
|
47
58
|
dismiss,
|
|
48
59
|
isVisible,
|
|
49
60
|
state,
|
|
50
61
|
addListener: KeyboardControllerNative.addListener,
|
|
51
62
|
removeListeners: KeyboardControllerNative.removeListeners,
|
|
63
|
+
getConstants: KeyboardControllerNative.getConstants,
|
|
52
64
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { codegenNativeComponent } from "react-native";
|
|
2
|
+
|
|
3
|
+
import type { HostComponent } from "react-native";
|
|
4
|
+
import type { ViewProps } from "react-native";
|
|
5
|
+
import type { Double } from "react-native/Libraries/Types/CodegenTypes";
|
|
6
|
+
|
|
7
|
+
export interface NativeProps extends ViewProps {
|
|
8
|
+
contentInsetBottom: Double;
|
|
9
|
+
contentInsetTop: Double;
|
|
10
|
+
applyWorkaroundForContentInsetHitTestBug?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default codegenNativeComponent<NativeProps>(
|
|
14
|
+
"ClippingScrollViewDecoratorView",
|
|
15
|
+
{
|
|
16
|
+
interfaceOnly: true,
|
|
17
|
+
excludedPlatforms: ["iOS"],
|
|
18
|
+
},
|
|
19
|
+
) as HostComponent<NativeProps>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import codegenNativeCommands from "react-native/Libraries/Utilities/codegenNativeCommands";
|
|
1
2
|
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
2
3
|
|
|
3
4
|
import type { HostComponent } from "react-native";
|
|
@@ -66,6 +67,16 @@ export interface NativeProps extends ViewProps {
|
|
|
66
67
|
onFocusedInputSelectionChanged?: DirectEventHandler<FocusedInputSelectionChangedEvent>;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
interface NativeCommands {
|
|
71
|
+
synchronizeFocusedInputLayout: (
|
|
72
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
73
|
+
) => void;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
77
|
+
supportedCommands: ["synchronizeFocusedInputLayout"],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export default codegenNativeComponent<NativeProps>("RNKeyboardControllerView", {
|
|
81
|
+
interfaceOnly: true,
|
|
82
|
+
}) as HostComponent<NativeProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
2
|
+
|
|
3
|
+
import type { HostComponent } from "react-native";
|
|
4
|
+
import type { ViewProps } from "react-native/Libraries/Components/View/ViewPropTypes";
|
|
5
|
+
|
|
6
|
+
export interface NativeProps extends ViewProps {}
|
|
7
|
+
|
|
8
|
+
export default codegenNativeComponent<NativeProps>("KeyboardToolbarGroupView", {
|
|
9
|
+
interfaceOnly: true,
|
|
10
|
+
}) as HostComponent<NativeProps>;
|