@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,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { TEST_ID_KEYBOARD_TOOLBAR_CONTENT } from "../../constants";
|
|
5
|
+
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
import type { ViewProps } from "react-native";
|
|
8
|
+
|
|
9
|
+
const Content: React.FC<ViewProps & { children?: ReactNode }> = ({
|
|
10
|
+
children,
|
|
11
|
+
}) => {
|
|
12
|
+
return (
|
|
13
|
+
<View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>
|
|
14
|
+
{children}
|
|
15
|
+
</View>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const styles = StyleSheet.create({
|
|
20
|
+
flex: {
|
|
21
|
+
flex: 1,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export default Content;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from "react";
|
|
2
|
+
import { StyleSheet, Text } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { useKeyboardState } from "../../../../hooks";
|
|
5
|
+
import { KeyboardController } from "../../../../module";
|
|
6
|
+
import Button from "../../Button";
|
|
7
|
+
import { TEST_ID_KEYBOARD_TOOLBAR_DONE } from "../../constants";
|
|
8
|
+
import { useToolbarContext } from "../context";
|
|
9
|
+
|
|
10
|
+
import type { ButtonSubProps } from "./types";
|
|
11
|
+
import type { ReactNode } from "react";
|
|
12
|
+
import type { GestureResponderEvent } from "react-native";
|
|
13
|
+
|
|
14
|
+
const Done: React.FC<Omit<ButtonSubProps, "icon"> & { text?: ReactNode }> = ({
|
|
15
|
+
children,
|
|
16
|
+
onPress,
|
|
17
|
+
rippleRadius = 28,
|
|
18
|
+
text,
|
|
19
|
+
button: ButtonContainer = Button,
|
|
20
|
+
}) => {
|
|
21
|
+
const colorScheme = useKeyboardState((state) => state.appearance);
|
|
22
|
+
const { theme } = useToolbarContext();
|
|
23
|
+
const doneStyle = useMemo(
|
|
24
|
+
() => [styles.doneButton, { color: theme[colorScheme].primary }],
|
|
25
|
+
[colorScheme, theme],
|
|
26
|
+
);
|
|
27
|
+
const onPressDone = useCallback(
|
|
28
|
+
(event: GestureResponderEvent) => {
|
|
29
|
+
onPress?.(event);
|
|
30
|
+
if (!event.isDefaultPrevented()) KeyboardController.dismiss();
|
|
31
|
+
},
|
|
32
|
+
[onPress],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ButtonContainer
|
|
37
|
+
accessibilityHint="Closes the keyboard"
|
|
38
|
+
accessibilityLabel="Done"
|
|
39
|
+
rippleRadius={rippleRadius}
|
|
40
|
+
style={styles.doneButtonContainer}
|
|
41
|
+
testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}
|
|
42
|
+
theme={theme}
|
|
43
|
+
onPress={onPressDone}
|
|
44
|
+
>
|
|
45
|
+
<Text maxFontSizeMultiplier={1.3} style={doneStyle}>
|
|
46
|
+
{children ?? text ?? "Done"}
|
|
47
|
+
</Text>
|
|
48
|
+
</ButtonContainer>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const styles = StyleSheet.create({
|
|
53
|
+
doneButton: { fontWeight: "600", fontSize: 15 },
|
|
54
|
+
doneButtonContainer: { marginRight: 16, marginLeft: 8 },
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export default Done;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
|
|
3
|
+
import { KeyboardController } from "../../../../module";
|
|
4
|
+
import Arrow from "../../Arrow";
|
|
5
|
+
import Button from "../../Button";
|
|
6
|
+
import { TEST_ID_KEYBOARD_TOOLBAR_NEXT } from "../../constants";
|
|
7
|
+
import { useToolbarContext } from "../context";
|
|
8
|
+
|
|
9
|
+
import type { ButtonSubProps } from "./types";
|
|
10
|
+
import type { GestureResponderEvent } from "react-native";
|
|
11
|
+
|
|
12
|
+
const Next: React.FC<ButtonSubProps> = ({
|
|
13
|
+
children,
|
|
14
|
+
onPress,
|
|
15
|
+
disabled,
|
|
16
|
+
rippleRadius,
|
|
17
|
+
style,
|
|
18
|
+
button: ButtonContainer = Button,
|
|
19
|
+
icon: IconContainer = Arrow,
|
|
20
|
+
}) => {
|
|
21
|
+
const { theme, isNextDisabled } = useToolbarContext();
|
|
22
|
+
const isDisabled = disabled ?? isNextDisabled;
|
|
23
|
+
const onPressNext = useCallback(
|
|
24
|
+
(event: GestureResponderEvent) => {
|
|
25
|
+
onPress?.(event);
|
|
26
|
+
if (!event.isDefaultPrevented()) KeyboardController.setFocusTo("next");
|
|
27
|
+
},
|
|
28
|
+
[onPress],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<ButtonContainer
|
|
33
|
+
accessibilityHint="Moves focus to the next field"
|
|
34
|
+
accessibilityLabel="Next"
|
|
35
|
+
disabled={isDisabled}
|
|
36
|
+
rippleRadius={rippleRadius}
|
|
37
|
+
style={style}
|
|
38
|
+
testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}
|
|
39
|
+
theme={theme}
|
|
40
|
+
onPress={onPressNext}
|
|
41
|
+
>
|
|
42
|
+
{children ?? (
|
|
43
|
+
<IconContainer disabled={isDisabled} theme={theme} type="next" />
|
|
44
|
+
)}
|
|
45
|
+
</ButtonContainer>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default Next;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
|
|
3
|
+
import { KeyboardController } from "../../../../module";
|
|
4
|
+
import Arrow from "../../Arrow";
|
|
5
|
+
import Button from "../../Button";
|
|
6
|
+
import { TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS } from "../../constants";
|
|
7
|
+
import { useToolbarContext } from "../context";
|
|
8
|
+
|
|
9
|
+
import type { ButtonSubProps } from "./types";
|
|
10
|
+
import type { GestureResponderEvent } from "react-native";
|
|
11
|
+
|
|
12
|
+
const Prev: React.FC<ButtonSubProps> = ({
|
|
13
|
+
children,
|
|
14
|
+
onPress,
|
|
15
|
+
disabled,
|
|
16
|
+
rippleRadius,
|
|
17
|
+
style,
|
|
18
|
+
button: ButtonContainer = Button,
|
|
19
|
+
icon: IconContainer = Arrow,
|
|
20
|
+
}) => {
|
|
21
|
+
const { theme, isPrevDisabled } = useToolbarContext();
|
|
22
|
+
const isDisabled = disabled ?? isPrevDisabled;
|
|
23
|
+
const onPressPrev = useCallback(
|
|
24
|
+
(event: GestureResponderEvent) => {
|
|
25
|
+
onPress?.(event);
|
|
26
|
+
if (!event.isDefaultPrevented()) KeyboardController.setFocusTo("prev");
|
|
27
|
+
},
|
|
28
|
+
[onPress],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<ButtonContainer
|
|
33
|
+
accessibilityHint="Moves focus to the previous field"
|
|
34
|
+
accessibilityLabel="Previous"
|
|
35
|
+
disabled={isDisabled}
|
|
36
|
+
rippleRadius={rippleRadius}
|
|
37
|
+
style={style}
|
|
38
|
+
testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}
|
|
39
|
+
theme={theme}
|
|
40
|
+
onPress={onPressPrev}
|
|
41
|
+
>
|
|
42
|
+
{children ?? (
|
|
43
|
+
<IconContainer disabled={isDisabled} theme={theme} type="prev" />
|
|
44
|
+
)}
|
|
45
|
+
</ButtonContainer>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default Prev;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type Arrow from "../../Arrow";
|
|
2
|
+
import type Button from "../../Button";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import type { GestureResponderEvent, ViewStyle } from "react-native";
|
|
5
|
+
|
|
6
|
+
export type ButtonSubProps = {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
onPress?: (event: GestureResponderEvent) => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
testID?: string;
|
|
11
|
+
rippleRadius?: number;
|
|
12
|
+
style?: ViewStyle;
|
|
13
|
+
button?: typeof Button;
|
|
14
|
+
icon?: typeof Arrow;
|
|
15
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
|
|
3
|
+
import type { KeyboardToolbarTheme } from "../types";
|
|
4
|
+
|
|
5
|
+
type ToolbarContextType = {
|
|
6
|
+
theme: KeyboardToolbarTheme;
|
|
7
|
+
isPrevDisabled: boolean;
|
|
8
|
+
isNextDisabled: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const ToolbarContext = createContext<ToolbarContextType | undefined>(
|
|
12
|
+
undefined,
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const useToolbarContext = () => {
|
|
16
|
+
const context = useContext(ToolbarContext);
|
|
17
|
+
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"KeyboardToolbar.* component must be used inside <KeyboardToolbar>",
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return context;
|
|
25
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { KEYBOARD_BORDER_RADIUS } from "../../constants";
|
|
2
|
+
|
|
3
|
+
import type { HEX } from "./types";
|
|
4
|
+
|
|
5
|
+
export const TEST_ID_KEYBOARD_TOOLBAR = "keyboard.toolbar";
|
|
6
|
+
export const TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;
|
|
7
|
+
export const TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;
|
|
8
|
+
export const TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;
|
|
9
|
+
export const TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;
|
|
10
|
+
|
|
11
|
+
export const KEYBOARD_TOOLBAR_HEIGHT = 42;
|
|
12
|
+
export const DEFAULT_OPACITY: HEX = "FF";
|
|
13
|
+
export const KEYBOARD_HAS_ROUNDED_CORNERS = KEYBOARD_BORDER_RADIUS > 0;
|
|
14
|
+
export const OPENED_OFFSET = KEYBOARD_HAS_ROUNDED_CORNERS ? -11 : 0;
|
|
@@ -1,84 +1,45 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { StyleSheet,
|
|
1
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
FocusedInputEvents,
|
|
6
|
+
RCTKeyboardToolbarGroupView,
|
|
6
7
|
} from "../../bindings";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import useColorScheme from "../hooks/useColorScheme";
|
|
8
|
+
import { useKeyboardState } from "../../hooks";
|
|
9
|
+
import KeyboardStickyView from "../KeyboardStickyView";
|
|
10
10
|
|
|
11
11
|
import Arrow from "./Arrow";
|
|
12
12
|
import Button from "./Button";
|
|
13
13
|
import { colors } from "./colors";
|
|
14
|
+
import { Background, Content, Done, Next, Prev } from "./compound/components";
|
|
15
|
+
import { ToolbarContext } from "./compound/context";
|
|
16
|
+
import {
|
|
17
|
+
DEFAULT_OPACITY,
|
|
18
|
+
KEYBOARD_HAS_ROUNDED_CORNERS,
|
|
19
|
+
KEYBOARD_TOOLBAR_HEIGHT,
|
|
20
|
+
OPENED_OFFSET,
|
|
21
|
+
TEST_ID_KEYBOARD_TOOLBAR,
|
|
22
|
+
} from "./constants";
|
|
14
23
|
|
|
15
|
-
import type {
|
|
16
|
-
import type { KeyboardStickyViewProps } from "../KeyboardStickyView";
|
|
24
|
+
import type { KeyboardToolbarProps } from "./types";
|
|
17
25
|
import type { ReactNode } from "react";
|
|
18
|
-
import type { ViewProps } from "react-native";
|
|
19
|
-
|
|
20
|
-
export type KeyboardToolbarProps = Omit<
|
|
21
|
-
ViewProps,
|
|
22
|
-
"style" | "testID" | "children"
|
|
23
|
-
> & {
|
|
24
|
-
/** An element that is shown in the middle of the toolbar. */
|
|
25
|
-
content?: JSX.Element | null;
|
|
26
|
-
/** A set of dark/light colors consumed by toolbar component. */
|
|
27
|
-
theme?: KeyboardToolbarTheme;
|
|
28
|
-
/** Custom text for done button. */
|
|
29
|
-
doneText?: ReactNode;
|
|
30
|
-
/** Custom touchable component for toolbar (used for prev/next/done buttons). */
|
|
31
|
-
button?: typeof Button;
|
|
32
|
-
/** Custom icon component used to display next/prev buttons. */
|
|
33
|
-
icon?: typeof Arrow;
|
|
34
|
-
/**
|
|
35
|
-
* Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input
|
|
36
|
-
* and want to show only `Done` button. Default to `true`.
|
|
37
|
-
*/
|
|
38
|
-
showArrows?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* A callback that is called when the user presses the next button along with the default action.
|
|
41
|
-
*/
|
|
42
|
-
onNextCallback?: () => void;
|
|
43
|
-
/**
|
|
44
|
-
* A callback that is called when the user presses the previous button along with the default action.
|
|
45
|
-
*/
|
|
46
|
-
onPrevCallback?: () => void;
|
|
47
|
-
/**
|
|
48
|
-
* A callback that is called when the user presses the done button along with the default action.
|
|
49
|
-
*/
|
|
50
|
-
onDoneCallback?: () => void;
|
|
51
|
-
/**
|
|
52
|
-
* A component that applies blur effect to the toolbar.
|
|
53
|
-
*/
|
|
54
|
-
blur?: JSX.Element | null;
|
|
55
|
-
/**
|
|
56
|
-
* A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.
|
|
57
|
-
*/
|
|
58
|
-
opacity?: HEX;
|
|
59
|
-
} & Pick<KeyboardStickyViewProps, "offset" | "enabled">;
|
|
60
|
-
|
|
61
|
-
const TEST_ID_KEYBOARD_TOOLBAR = "keyboard.toolbar";
|
|
62
|
-
const TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;
|
|
63
|
-
const TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;
|
|
64
|
-
const TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;
|
|
65
|
-
const TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;
|
|
66
|
-
|
|
67
|
-
const KEYBOARD_TOOLBAR_HEIGHT = 42;
|
|
68
|
-
const DEFAULT_OPACITY: HEX = "FF";
|
|
69
|
-
|
|
70
|
-
const dismissKeyboard = () => KeyboardControllerNative.dismiss(false);
|
|
71
|
-
const goToNextField = () => KeyboardControllerNative.setFocusTo("next");
|
|
72
|
-
const goToPrevField = () => KeyboardControllerNative.setFocusTo("prev");
|
|
73
26
|
|
|
74
27
|
/**
|
|
75
28
|
* `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and
|
|
76
29
|
* `Done` buttons.
|
|
77
30
|
*/
|
|
78
|
-
const KeyboardToolbar: React.FC<KeyboardToolbarProps>
|
|
31
|
+
const KeyboardToolbar: React.FC<KeyboardToolbarProps> & {
|
|
32
|
+
Background: typeof Background;
|
|
33
|
+
Content: typeof Content;
|
|
34
|
+
Prev: typeof Prev;
|
|
35
|
+
Next: typeof Next;
|
|
36
|
+
Done: typeof Done;
|
|
37
|
+
Group: typeof RCTKeyboardToolbarGroupView;
|
|
38
|
+
} = ({
|
|
39
|
+
children,
|
|
79
40
|
content,
|
|
80
41
|
theme = colors,
|
|
81
|
-
doneText,
|
|
42
|
+
doneText = "Done",
|
|
82
43
|
button,
|
|
83
44
|
icon,
|
|
84
45
|
showArrows = true,
|
|
@@ -89,15 +50,18 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
89
50
|
opacity = DEFAULT_OPACITY,
|
|
90
51
|
offset: { closed = 0, opened = 0 } = {},
|
|
91
52
|
enabled = true,
|
|
53
|
+
insets,
|
|
92
54
|
...rest
|
|
93
55
|
}) => {
|
|
94
|
-
const colorScheme =
|
|
56
|
+
const colorScheme = useKeyboardState((state) => state.appearance);
|
|
95
57
|
const [inputs, setInputs] = useState({
|
|
96
58
|
current: 0,
|
|
97
59
|
count: 0,
|
|
98
60
|
});
|
|
99
61
|
const isPrevDisabled = inputs.current === 0;
|
|
100
62
|
const isNextDisabled = inputs.current === inputs.count - 1;
|
|
63
|
+
const buttonContainer = button ?? Button;
|
|
64
|
+
const iconContainer = icon ?? Arrow;
|
|
101
65
|
|
|
102
66
|
useEffect(() => {
|
|
103
67
|
const subscription = FocusedInputEvents.addListener("focusDidSet", (e) => {
|
|
@@ -106,100 +70,125 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
106
70
|
|
|
107
71
|
return subscription.remove;
|
|
108
72
|
}, []);
|
|
109
|
-
const doneStyle = useMemo(
|
|
110
|
-
() => [styles.doneButton, { color: theme[colorScheme].primary }],
|
|
111
|
-
[colorScheme, theme],
|
|
112
|
-
);
|
|
113
73
|
const toolbarStyle = useMemo(
|
|
114
74
|
() => [
|
|
115
75
|
styles.toolbar,
|
|
116
76
|
{
|
|
117
77
|
backgroundColor: `${theme[colorScheme].background}${opacity}`,
|
|
118
78
|
},
|
|
79
|
+
!KEYBOARD_HAS_ROUNDED_CORNERS
|
|
80
|
+
? {
|
|
81
|
+
paddingLeft: insets?.left,
|
|
82
|
+
paddingRight: insets?.right,
|
|
83
|
+
}
|
|
84
|
+
: null,
|
|
85
|
+
KEYBOARD_HAS_ROUNDED_CORNERS ? styles.floating : null,
|
|
119
86
|
],
|
|
120
|
-
[colorScheme, opacity, theme],
|
|
87
|
+
[colorScheme, opacity, theme, insets],
|
|
88
|
+
);
|
|
89
|
+
const containerStyle = useMemo(
|
|
90
|
+
() => [
|
|
91
|
+
// CRUCIAL: gives the native view real bounds
|
|
92
|
+
styles.sticky,
|
|
93
|
+
KEYBOARD_HAS_ROUNDED_CORNERS
|
|
94
|
+
? ({
|
|
95
|
+
left: (insets?.left ?? 0) + 16,
|
|
96
|
+
right: (insets?.right ?? 0) + 16,
|
|
97
|
+
} as const)
|
|
98
|
+
: null,
|
|
99
|
+
],
|
|
100
|
+
[insets],
|
|
121
101
|
);
|
|
122
102
|
const offset = useMemo(
|
|
123
|
-
() => ({
|
|
103
|
+
() => ({
|
|
104
|
+
closed: closed + KEYBOARD_TOOLBAR_HEIGHT,
|
|
105
|
+
opened: opened + OPENED_OFFSET,
|
|
106
|
+
}),
|
|
124
107
|
[closed, opened],
|
|
125
108
|
);
|
|
126
|
-
|
|
127
|
-
|
|
109
|
+
let backgroundElement: ReactNode = null;
|
|
110
|
+
let arrowsElement: ReactNode = null;
|
|
111
|
+
let contentContainer: ReactNode = null;
|
|
112
|
+
let doneElement: ReactNode = null;
|
|
128
113
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
onPrevCallback?.();
|
|
136
|
-
}, [onPrevCallback]);
|
|
137
|
-
const onPressDone = useCallback(() => {
|
|
138
|
-
dismissKeyboard();
|
|
139
|
-
onDoneCallback?.();
|
|
140
|
-
}, [onDoneCallback]);
|
|
114
|
+
if (children) {
|
|
115
|
+
let prevChild: ReactNode = null;
|
|
116
|
+
let nextChild: ReactNode = null;
|
|
117
|
+
let contentChild: ReactNode = null;
|
|
118
|
+
let doneChild: ReactNode = null;
|
|
119
|
+
let backgroundChild: ReactNode = null;
|
|
141
120
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
accessibilityHint="Will move focus to previous field"
|
|
151
|
-
disabled={isPrevDisabled}
|
|
152
|
-
onPress={onPressPrev}
|
|
153
|
-
testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}
|
|
154
|
-
theme={theme}
|
|
155
|
-
>
|
|
156
|
-
<IconContainer
|
|
157
|
-
disabled={isPrevDisabled}
|
|
158
|
-
type="prev"
|
|
159
|
-
theme={theme}
|
|
160
|
-
/>
|
|
161
|
-
</ButtonContainer>
|
|
162
|
-
<ButtonContainer
|
|
163
|
-
accessibilityLabel="Next"
|
|
164
|
-
accessibilityHint="Will move focus to next field"
|
|
165
|
-
disabled={isNextDisabled}
|
|
166
|
-
onPress={onPressNext}
|
|
167
|
-
testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}
|
|
168
|
-
theme={theme}
|
|
169
|
-
>
|
|
170
|
-
<IconContainer
|
|
171
|
-
disabled={isNextDisabled}
|
|
172
|
-
type="next"
|
|
173
|
-
theme={theme}
|
|
174
|
-
/>
|
|
175
|
-
</ButtonContainer>
|
|
176
|
-
</>
|
|
177
|
-
)}
|
|
121
|
+
React.Children.forEach(children, (child) => {
|
|
122
|
+
if (!React.isValidElement(child)) return;
|
|
123
|
+
if (child.type === Background) backgroundChild = child;
|
|
124
|
+
else if (child.type === Content) contentChild = child;
|
|
125
|
+
else if (child.type === Prev) prevChild = child;
|
|
126
|
+
else if (child.type === Next) nextChild = child;
|
|
127
|
+
else if (child.type === Done) doneChild = child;
|
|
128
|
+
});
|
|
178
129
|
|
|
179
|
-
|
|
180
|
-
|
|
130
|
+
backgroundElement = backgroundChild;
|
|
131
|
+
doneElement = doneChild;
|
|
132
|
+
arrowsElement =
|
|
133
|
+
prevChild || nextChild ? (
|
|
134
|
+
<View style={styles.arrows}>
|
|
135
|
+
{prevChild}
|
|
136
|
+
{nextChild}
|
|
181
137
|
</View>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
138
|
+
) : null;
|
|
139
|
+
contentContainer = contentChild ?? <Content>{contentChild}</Content>;
|
|
140
|
+
} else {
|
|
141
|
+
backgroundElement = blur;
|
|
142
|
+
arrowsElement = showArrows ? (
|
|
143
|
+
<View style={styles.arrows}>
|
|
144
|
+
<Prev
|
|
145
|
+
button={buttonContainer}
|
|
146
|
+
icon={iconContainer}
|
|
147
|
+
onPress={onPrevCallback}
|
|
148
|
+
/>
|
|
149
|
+
<Next
|
|
150
|
+
button={buttonContainer}
|
|
151
|
+
icon={iconContainer}
|
|
152
|
+
onPress={onNextCallback}
|
|
153
|
+
/>
|
|
195
154
|
</View>
|
|
196
|
-
|
|
155
|
+
) : null;
|
|
156
|
+
contentContainer = <Content>{content}</Content>;
|
|
157
|
+
doneElement = doneText ? (
|
|
158
|
+
<Done button={buttonContainer} text={doneText} onPress={onDoneCallback} />
|
|
159
|
+
) : null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const contextValue = useMemo(
|
|
163
|
+
() => ({ theme, isPrevDisabled, isNextDisabled }),
|
|
164
|
+
[theme, isPrevDisabled, isNextDisabled],
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<ToolbarContext.Provider value={contextValue}>
|
|
169
|
+
<KeyboardStickyView
|
|
170
|
+
enabled={enabled}
|
|
171
|
+
offset={offset}
|
|
172
|
+
style={containerStyle}
|
|
173
|
+
>
|
|
174
|
+
<View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>
|
|
175
|
+
{backgroundElement}
|
|
176
|
+
{arrowsElement}
|
|
177
|
+
{contentContainer}
|
|
178
|
+
{doneElement}
|
|
179
|
+
</View>
|
|
180
|
+
</KeyboardStickyView>
|
|
181
|
+
</ToolbarContext.Provider>
|
|
197
182
|
);
|
|
198
183
|
};
|
|
199
184
|
|
|
200
185
|
const styles = StyleSheet.create({
|
|
201
|
-
|
|
202
|
-
|
|
186
|
+
sticky: {
|
|
187
|
+
position: "absolute",
|
|
188
|
+
left: 0,
|
|
189
|
+
right: 0,
|
|
190
|
+
bottom: 0,
|
|
191
|
+
height: KEYBOARD_TOOLBAR_HEIGHT,
|
|
203
192
|
},
|
|
204
193
|
toolbar: {
|
|
205
194
|
position: "absolute",
|
|
@@ -208,16 +197,24 @@ const styles = StyleSheet.create({
|
|
|
208
197
|
width: "100%",
|
|
209
198
|
flexDirection: "row",
|
|
210
199
|
height: KEYBOARD_TOOLBAR_HEIGHT,
|
|
211
|
-
paddingHorizontal: 8,
|
|
212
200
|
},
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
201
|
+
arrows: {
|
|
202
|
+
flexDirection: "row",
|
|
203
|
+
paddingLeft: 8,
|
|
216
204
|
},
|
|
217
|
-
|
|
218
|
-
|
|
205
|
+
floating: {
|
|
206
|
+
alignSelf: "center",
|
|
207
|
+
borderRadius: 20,
|
|
208
|
+
overflow: "hidden",
|
|
219
209
|
},
|
|
220
210
|
});
|
|
221
211
|
|
|
222
|
-
|
|
212
|
+
KeyboardToolbar.Background = Background;
|
|
213
|
+
KeyboardToolbar.Content = Content;
|
|
214
|
+
KeyboardToolbar.Prev = Prev;
|
|
215
|
+
KeyboardToolbar.Next = Next;
|
|
216
|
+
KeyboardToolbar.Done = Done;
|
|
217
|
+
KeyboardToolbar.Group = RCTKeyboardToolbarGroupView;
|
|
218
|
+
|
|
219
|
+
export { colors as DefaultKeyboardToolbarTheme, KeyboardToolbarProps };
|
|
223
220
|
export default KeyboardToolbar;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type Arrow from "./Arrow";
|
|
2
|
+
import type Button from "./Button";
|
|
3
|
+
import type { KeyboardStickyViewProps } from "../KeyboardStickyView";
|
|
4
|
+
import type { ReactNode } from "react";
|
|
5
|
+
import type {
|
|
6
|
+
ColorValue,
|
|
7
|
+
GestureResponderEvent,
|
|
8
|
+
ViewProps,
|
|
9
|
+
} from "react-native";
|
|
2
10
|
|
|
3
11
|
type Theme = {
|
|
4
12
|
/** Color for arrow when it's enabled */
|
|
@@ -38,3 +46,27 @@ type HexSymbol =
|
|
|
38
46
|
| "e"
|
|
39
47
|
| "f";
|
|
40
48
|
export type HEX = `${HexSymbol}${HexSymbol}`;
|
|
49
|
+
|
|
50
|
+
type SafeAreaInsets = {
|
|
51
|
+
left: number;
|
|
52
|
+
right: number;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type KeyboardToolbarProps = Omit<
|
|
56
|
+
ViewProps,
|
|
57
|
+
"style" | "testID" | "children"
|
|
58
|
+
> & {
|
|
59
|
+
content?: React.JSX.Element | null;
|
|
60
|
+
theme?: KeyboardToolbarTheme;
|
|
61
|
+
doneText?: ReactNode;
|
|
62
|
+
button?: typeof Button;
|
|
63
|
+
icon?: typeof Arrow;
|
|
64
|
+
showArrows?: boolean;
|
|
65
|
+
onNextCallback?: (event: GestureResponderEvent) => void;
|
|
66
|
+
onPrevCallback?: (event: GestureResponderEvent) => void;
|
|
67
|
+
onDoneCallback?: (event: GestureResponderEvent) => void;
|
|
68
|
+
blur?: React.JSX.Element | null;
|
|
69
|
+
opacity?: HEX;
|
|
70
|
+
insets?: SafeAreaInsets;
|
|
71
|
+
children?: ReactNode;
|
|
72
|
+
} & Pick<KeyboardStickyViewProps, "offset" | "enabled">;
|