@react-native-ohos/react-native-keyboard-controller 1.17.0-beta.2 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.OpenSource +11 -11
- package/README.md +686 -19
- package/harmony/keyboard_controller/BuildProfile.ets +16 -16
- package/harmony/keyboard_controller/Index.ets +29 -28
- package/harmony/keyboard_controller/build-profile.json5 +31 -31
- package/harmony/keyboard_controller/hvigorfile.ts +6 -6
- package/harmony/keyboard_controller/obfuscation-rules.txt +17 -17
- package/harmony/keyboard_controller/oh-package-lock.json5 +28 -18
- package/harmony/keyboard_controller/oh-package.json5 +10 -10
- package/harmony/keyboard_controller/src/main/cpp/CMakeLists.txt +7 -7
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentDescriptor.h +86 -0
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.cpp +104 -0
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewComponentInstance.h +64 -0
- package/harmony/keyboard_controller/src/main/cpp/ClippingScrollViewJSIBinder.h +60 -0
- package/harmony/keyboard_controller/src/main/cpp/EventEmitters.cpp +119 -96
- package/harmony/keyboard_controller/src/main/cpp/EventEmitters.h +111 -111
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentDescriptor.h +94 -94
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +840 -288
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.h +169 -103
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewJSIBinder.h +65 -65
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentDescriptor.h +79 -79
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +108 -108
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.h +83 -83
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaJSIBinder.h +60 -60
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentDescriptor.h +46 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.cpp +37 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewComponentInstance.h +32 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardToolbarGroupViewJSIBinder.h +23 -0
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.cpp +103 -46
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.h +48 -48
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardControllerPackage.h +20 -0
- package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.cpp +45 -45
- package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.h +49 -49
- package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.cpp +207 -186
- package/harmony/keyboard_controller/src/main/cpp/ViewHierarchyNavigator.h +131 -112
- package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +77 -64
- package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +85 -77
- package/harmony/keyboard_controller/src/main/ets/Logger.ts +66 -66
- package/harmony/keyboard_controller/src/main/ets/{RNKeyboardControllerPackage.ts → RNKeyboardControllerPackage.ets} +70 -66
- package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +465 -273
- package/harmony/keyboard_controller/src/main/ets/RNStatusBarManagerCompatTurboModule.ts +128 -119
- package/harmony/keyboard_controller/src/main/ets/Type.ts +63 -62
- package/harmony/keyboard_controller/src/main/module.json5 +11 -11
- package/harmony/keyboard_controller/src/main/resources/base/element/string.json +8 -8
- package/harmony/keyboard_controller/src/main/resources/en_US/element/string.json +8 -8
- package/harmony/keyboard_controller/src/main/resources/zh_CN/element/string.json +8 -8
- package/harmony/keyboard_controller/{ts.ts → ts.ets} +29 -29
- package/harmony/keyboard_controller.har +0 -0
- package/lib/commonjs/animated.js +22 -11
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/architecture.js +8 -0
- package/lib/commonjs/architecture.js.map +1 -0
- package/lib/commonjs/bindings.js +40 -5
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +28 -5
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/compat.js +50 -0
- package/lib/commonjs/compat.js.map +1 -0
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +21 -15
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +39 -14
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +94 -57
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +5 -5
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/commonjs/components/KeyboardChatScrollView/hooks.js +13 -0
- package/lib/commonjs/components/KeyboardChatScrollView/hooks.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/index.js +122 -0
- package/lib/commonjs/components/KeyboardChatScrollView/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/types.js +6 -0
- package/lib/commonjs/components/KeyboardChatScrollView/types.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +221 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +149 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js +240 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js +6 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js +40 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js +92 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js +2 -3
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Button.js +2 -3
- package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/colors.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js +13 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js +25 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js +58 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js +49 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js +49 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js +42 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js +6 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/context.js +17 -0
- package/lib/commonjs/components/KeyboardToolbar/compound/context.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/constants.js +17 -0
- package/lib/commonjs/components/KeyboardToolbar/constants.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js +98 -87
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -1
- package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js +120 -0
- package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js.map +1 -0
- package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js +15 -0
- package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
- package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -1
- package/lib/commonjs/components/hooks/useCombinedRef.js +24 -0
- package/lib/commonjs/components/hooks/useCombinedRef.js.map +1 -0
- package/lib/commonjs/components/hooks/useScrollState.js +62 -0
- package/lib/commonjs/components/hooks/useScrollState.js.map +1 -0
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/constants.js +3 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/context.js +1 -0
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks/index.js +14 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useKeyboardState/index.js +39 -0
- package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -0
- package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -1
- package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -1
- package/lib/commonjs/index.js +27 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +54 -18
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/module.js +21 -12
- package/lib/commonjs/module.js.map +1 -1
- package/lib/commonjs/reanimated.js.map +1 -1
- package/lib/commonjs/reanimated.native.js.map +1 -1
- package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js +12 -0
- package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +8 -2
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +2 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js +12 -0
- package/lib/commonjs/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/findNodeHandle/index.js +9 -0
- package/lib/commonjs/utils/findNodeHandle/index.js.map +1 -0
- package/lib/commonjs/utils/findNodeHandle/index.native.js +13 -0
- package/lib/commonjs/utils/findNodeHandle/index.native.js.map +1 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/views/KeyboardExtender/index.js +30 -0
- package/lib/commonjs/views/KeyboardExtender/index.js.map +1 -0
- package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
- package/lib/commonjs/views/index.js +7 -0
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/module/animated.js +24 -13
- package/lib/module/animated.js.map +1 -1
- package/lib/module/architecture.js +2 -0
- package/lib/module/architecture.js.map +1 -0
- package/lib/module/bindings.js +39 -5
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +27 -5
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/compat.js +43 -0
- package/lib/module/compat.js.map +1 -0
- package/lib/module/components/KeyboardAvoidingView/hooks.js +22 -16
- package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +38 -14
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +97 -60
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +5 -5
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/module/components/KeyboardChatScrollView/hooks.js +2 -0
- package/lib/module/components/KeyboardChatScrollView/hooks.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/index.js +115 -0
- package/lib/module/components/KeyboardChatScrollView/index.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/types.js +2 -0
- package/lib/module/components/KeyboardChatScrollView/types.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js +207 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +143 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js +234 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js +2 -0
- package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useEndVisible.js +33 -0
- package/lib/module/components/KeyboardChatScrollView/useEndVisible.js.map +1 -0
- package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js +87 -0
- package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -0
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/Arrow.js +2 -2
- package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/Button.js +2 -2
- package/lib/module/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/colors.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/colors.native.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/compound/components/Background.js +6 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Content.js +18 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Done.js +50 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Next.js +41 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Prev.js +41 -0
- package/lib/module/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/index.js +6 -0
- package/lib/module/components/KeyboardToolbar/compound/components/index.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/components/types.js +2 -0
- package/lib/module/components/KeyboardToolbar/compound/components/types.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/compound/context.js +10 -0
- package/lib/module/components/KeyboardToolbar/compound/context.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/constants.js +11 -0
- package/lib/module/components/KeyboardToolbar/constants.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/index.js +98 -88
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/types.js.map +1 -1
- package/lib/module/components/ScrollViewWithBottomPadding/index.js +112 -0
- package/lib/module/components/ScrollViewWithBottomPadding/index.js.map +1 -0
- package/lib/module/components/ScrollViewWithBottomPadding/styles.js +9 -0
- package/lib/module/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
- package/lib/module/components/hooks/useColorScheme.js.map +1 -1
- package/lib/module/components/hooks/useCombinedRef.js +18 -0
- package/lib/module/components/hooks/useCombinedRef.js.map +1 -0
- package/lib/module/components/hooks/useScrollState.js +56 -0
- package/lib/module/components/hooks/useScrollState.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/constants.js +3 -0
- package/lib/module/constants.js.map +1 -1
- package/lib/module/context.js +1 -0
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks/index.js +3 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useKeyboardState/index.js +33 -0
- package/lib/module/hooks/useKeyboardState/index.js.map +1 -0
- package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -1
- package/lib/module/hooks/useWindowDimensions/index.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +53 -18
- package/lib/module/internal.js.map +1 -1
- package/lib/module/module.js +21 -12
- package/lib/module/module.js.map +1 -1
- package/lib/module/reanimated.js.map +1 -1
- package/lib/module/reanimated.native.js.map +1 -1
- package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js +6 -0
- package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js +7 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +2 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js +5 -0
- package/lib/module/specs/KeyboardToolbarGroupViewNativeComponent.js.map +1 -0
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/findNodeHandle/index.js +2 -0
- package/lib/module/utils/findNodeHandle/index.js.map +1 -0
- package/lib/module/utils/findNodeHandle/index.native.js +3 -0
- package/lib/module/utils/findNodeHandle/index.native.js.map +1 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/views/KeyboardExtender/index.js +23 -0
- package/lib/module/views/KeyboardExtender/index.js.map +1 -0
- package/lib/module/views/OverKeyboardView/index.js.map +1 -1
- package/lib/module/views/index.js +1 -0
- package/lib/module/views/index.js.map +1 -1
- package/lib/typescript/animated.d.ts +2 -38
- package/lib/typescript/architecture.d.ts +1 -0
- package/lib/typescript/bindings.d.ts +15 -1
- package/lib/typescript/bindings.native.d.ts +10 -1
- package/lib/typescript/compat.d.ts +12 -0
- package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +5 -0
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -1
- package/lib/typescript/components/KeyboardChatScrollView/hooks.d.ts +2 -0
- package/lib/typescript/components/KeyboardChatScrollView/index.d.ts +17 -0
- package/lib/typescript/components/KeyboardChatScrollView/types.d.ts +113 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts +132 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.d.ts +18 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/index.ios.d.ts +21 -0
- package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts +37 -0
- package/lib/typescript/components/KeyboardChatScrollView/useEndVisible.d.ts +17 -0
- package/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts +45 -0
- package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -2
- package/lib/typescript/components/KeyboardToolbar/compound/components/Background.d.ts +6 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Content.d.ts +7 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Done.d.ts +7 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Next.d.ts +4 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/Prev.d.ts +4 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/index.d.ts +5 -0
- package/lib/typescript/components/KeyboardToolbar/compound/components/types.d.ts +14 -0
- package/lib/typescript/components/KeyboardToolbar/compound/context.d.ts +9 -0
- package/lib/typescript/components/KeyboardToolbar/constants.d.ts +10 -0
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +12 -45
- package/lib/typescript/components/KeyboardToolbar/types.d.ts +24 -1
- package/lib/typescript/components/ScrollViewWithBottomPadding/index.d.ts +30 -0
- package/lib/typescript/components/ScrollViewWithBottomPadding/styles.d.ts +7 -0
- package/lib/typescript/components/hooks/useCombinedRef.d.ts +3 -0
- package/lib/typescript/components/hooks/useScrollState.d.ts +17 -0
- package/lib/typescript/components/index.d.ts +3 -0
- package/lib/typescript/constants.d.ts +1 -0
- package/lib/typescript/context.d.ts +1 -0
- package/lib/typescript/hooks/index.d.ts +2 -0
- package/lib/typescript/hooks/useKeyboardState/index.d.ts +4 -0
- package/lib/typescript/index.d.ts +4 -3
- package/lib/typescript/internal.d.ts +4 -0
- package/lib/typescript/specs/ClippingScrollViewDecoratorViewNativeComponent.d.ts +10 -0
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
- package/lib/typescript/specs/KeyboardToolbarGroupViewNativeComponent.d.ts +6 -0
- package/lib/typescript/specs/NativeKeyboardController.d.ts +6 -2
- package/lib/typescript/types.d.ts +81 -5
- package/lib/typescript/utils/findNodeHandle/index.d.ts +4 -0
- package/lib/typescript/utils/findNodeHandle/index.native.d.ts +2 -0
- package/lib/typescript/views/KeyboardExtender/index.d.ts +5 -0
- package/lib/typescript/views/index.d.ts +1 -0
- package/package.json +183 -174
- package/src/animated.tsx +248 -255
- package/src/architecture.ts +1 -0
- package/src/bindings.native.ts +97 -62
- package/src/bindings.ts +81 -42
- package/src/compat.ts +44 -0
- package/src/components/KeyboardAvoidingView/hooks.ts +130 -123
- package/src/components/KeyboardAvoidingView/index.tsx +232 -188
- package/src/components/KeyboardAwareScrollView/index.tsx +452 -389
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +133 -133
- package/src/components/KeyboardAwareScrollView/utils.ts +41 -41
- package/src/components/KeyboardChatScrollView/hooks.ts +2 -0
- package/src/components/KeyboardChatScrollView/index.tsx +164 -0
- package/src/components/KeyboardChatScrollView/types.ts +117 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts +268 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts +260 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts +374 -0
- package/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts +39 -0
- package/src/components/KeyboardChatScrollView/useEndVisible.ts +66 -0
- package/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts +149 -0
- package/src/components/KeyboardStickyView/index.tsx +66 -66
- package/src/components/KeyboardToolbar/Arrow.tsx +80 -80
- package/src/components/KeyboardToolbar/Button.tsx +98 -98
- package/src/components/KeyboardToolbar/colors.native.ts +37 -37
- package/src/components/KeyboardToolbar/colors.ts +16 -16
- package/src/components/KeyboardToolbar/compound/components/Background.tsx +9 -0
- package/src/components/KeyboardToolbar/compound/components/Content.tsx +25 -0
- package/src/components/KeyboardToolbar/compound/components/Done.tsx +57 -0
- package/src/components/KeyboardToolbar/compound/components/Next.tsx +49 -0
- package/src/components/KeyboardToolbar/compound/components/Prev.tsx +49 -0
- package/src/components/KeyboardToolbar/compound/components/index.ts +5 -0
- package/src/components/KeyboardToolbar/compound/components/types.ts +15 -0
- package/src/components/KeyboardToolbar/compound/context.ts +25 -0
- package/src/components/KeyboardToolbar/constants.ts +14 -0
- package/src/components/KeyboardToolbar/index.tsx +220 -223
- package/src/components/KeyboardToolbar/types.ts +72 -40
- package/src/components/ScrollViewWithBottomPadding/index.tsx +216 -0
- package/src/components/ScrollViewWithBottomPadding/styles.ts +10 -0
- package/src/components/hooks/useColorScheme.ts +6 -6
- package/src/components/hooks/useCombinedRef.ts +22 -0
- package/src/components/hooks/useScrollState.ts +81 -0
- package/src/components/index.ts +14 -11
- package/src/constants.ts +23 -19
- package/src/context.ts +70 -68
- package/src/hooks/index.ts +91 -90
- package/src/hooks/useKeyboardState/index.ts +52 -0
- package/src/hooks/useWindowDimensions/index.android.ts +38 -38
- package/src/hooks/useWindowDimensions/index.ts +1 -1
- package/src/index.ts +27 -23
- package/src/internal.ts +146 -84
- package/src/module.ts +64 -52
- package/src/reanimated.native.ts +132 -132
- package/src/reanimated.ts +29 -29
- package/src/specs/ClippingScrollViewDecoratorViewNativeComponent.ts +19 -0
- package/src/specs/KeyboardControllerViewNativeComponent.ts +82 -71
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +21 -20
- package/src/specs/KeyboardToolbarGroupViewNativeComponent.ts +10 -0
- package/src/specs/NativeKeyboardController.ts +23 -19
- package/src/specs/NativeStatusBarManagerCompat.ts +14 -14
- package/src/specs/OverKeyboardViewNativeComponent.ts +12 -12
- package/src/types.ts +330 -243
- package/src/utils/findNodeHandle/index.native.ts +3 -0
- package/src/utils/findNodeHandle/index.ts +6 -0
- package/src/utils.ts +1 -1
- package/src/views/KeyboardExtender/index.tsx +30 -0
- package/src/views/OverKeyboardView/index.tsx +43 -43
- package/src/views/index.ts +2 -1
- package/lib/commonjs/monkey-patch.android.js +0 -57
- package/lib/commonjs/monkey-patch.android.js.map +0 -1
- package/lib/commonjs/monkey-patch.js +0 -11
- package/lib/commonjs/monkey-patch.js.map +0 -1
- package/lib/module/monkey-patch.android.js +0 -47
- package/lib/module/monkey-patch.android.js.map +0 -1
- package/lib/module/monkey-patch.js +0 -5
- package/lib/module/monkey-patch.js.map +0 -1
- package/lib/typescript/monkey-patch.android.d.ts +0 -2
- package/lib/typescript/monkey-patch.d.ts +0 -2
- package/src/monkey-patch.android.ts +0 -44
- package/src/monkey-patch.ts +0 -4
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from "react";
|
|
2
|
+
import { StyleSheet, Text } from "react-native";
|
|
3
|
+
import { useKeyboardState } from "../../../../hooks";
|
|
4
|
+
import { KeyboardController } from "../../../../module";
|
|
5
|
+
import Button from "../../Button";
|
|
6
|
+
import { TEST_ID_KEYBOARD_TOOLBAR_DONE } from "../../constants";
|
|
7
|
+
import { useToolbarContext } from "../context";
|
|
8
|
+
const Done = ({
|
|
9
|
+
children,
|
|
10
|
+
onPress,
|
|
11
|
+
rippleRadius = 28,
|
|
12
|
+
text,
|
|
13
|
+
button: ButtonContainer = Button
|
|
14
|
+
}) => {
|
|
15
|
+
const colorScheme = useKeyboardState(state => state.appearance);
|
|
16
|
+
const {
|
|
17
|
+
theme
|
|
18
|
+
} = useToolbarContext();
|
|
19
|
+
const doneStyle = useMemo(() => [styles.doneButton, {
|
|
20
|
+
color: theme[colorScheme].primary
|
|
21
|
+
}], [colorScheme, theme]);
|
|
22
|
+
const onPressDone = useCallback(event => {
|
|
23
|
+
onPress === null || onPress === void 0 || onPress(event);
|
|
24
|
+
if (!event.isDefaultPrevented()) KeyboardController.dismiss();
|
|
25
|
+
}, [onPress]);
|
|
26
|
+
return /*#__PURE__*/React.createElement(ButtonContainer, {
|
|
27
|
+
accessibilityHint: "Closes the keyboard",
|
|
28
|
+
accessibilityLabel: "Done",
|
|
29
|
+
rippleRadius: rippleRadius,
|
|
30
|
+
style: styles.doneButtonContainer,
|
|
31
|
+
testID: TEST_ID_KEYBOARD_TOOLBAR_DONE,
|
|
32
|
+
theme: theme,
|
|
33
|
+
onPress: onPressDone
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
35
|
+
maxFontSizeMultiplier: 1.3,
|
|
36
|
+
style: doneStyle
|
|
37
|
+
}, children ?? text ?? "Done"));
|
|
38
|
+
};
|
|
39
|
+
const styles = StyleSheet.create({
|
|
40
|
+
doneButton: {
|
|
41
|
+
fontWeight: "600",
|
|
42
|
+
fontSize: 15
|
|
43
|
+
},
|
|
44
|
+
doneButtonContainer: {
|
|
45
|
+
marginRight: 16,
|
|
46
|
+
marginLeft: 8
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
export default Done;
|
|
50
|
+
//# sourceMappingURL=Done.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","useMemo","StyleSheet","Text","useKeyboardState","KeyboardController","Button","TEST_ID_KEYBOARD_TOOLBAR_DONE","useToolbarContext","Done","children","onPress","rippleRadius","text","button","ButtonContainer","colorScheme","state","appearance","theme","doneStyle","styles","doneButton","color","primary","onPressDone","event","isDefaultPrevented","dismiss","createElement","accessibilityHint","accessibilityLabel","style","doneButtonContainer","testID","maxFontSizeMultiplier","create","fontWeight","fontSize","marginRight","marginLeft"],"sources":["Done.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from \"react\";\nimport { StyleSheet, Text } from \"react-native\";\n\nimport { useKeyboardState } from \"../../../../hooks\";\nimport { KeyboardController } from \"../../../../module\";\nimport Button from \"../../Button\";\nimport { TEST_ID_KEYBOARD_TOOLBAR_DONE } from \"../../constants\";\nimport { useToolbarContext } from \"../context\";\n\nimport type { ButtonSubProps } from \"./types\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent } from \"react-native\";\n\nconst Done: React.FC<Omit<ButtonSubProps, \"icon\"> & { text?: ReactNode }> = ({\n children,\n onPress,\n rippleRadius = 28,\n text,\n button: ButtonContainer = Button,\n}) => {\n const colorScheme = useKeyboardState((state) => state.appearance);\n const { theme } = useToolbarContext();\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onPress?.(event);\n if (!event.isDefaultPrevented()) KeyboardController.dismiss();\n },\n [onPress],\n );\n\n return (\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={rippleRadius}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\n {children ?? text ?? \"Done\"}\n </Text>\n </ButtonContainer>\n );\n};\n\nconst styles = StyleSheet.create({\n doneButton: { fontWeight: \"600\", fontSize: 15 },\n doneButtonContainer: { marginRight: 16, marginLeft: 8 },\n});\n\nexport default Done;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACnD,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAE/C,SAASC,gBAAgB,QAAQ,mBAAmB;AACpD,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,OAAOC,MAAM,MAAM,cAAc;AACjC,SAASC,6BAA6B,QAAQ,iBAAiB;AAC/D,SAASC,iBAAiB,QAAQ,YAAY;AAM9C,MAAMC,IAAmE,GAAGA,CAAC;EAC3EC,QAAQ;EACRC,OAAO;EACPC,YAAY,GAAG,EAAE;EACjBC,IAAI;EACJC,MAAM,EAAEC,eAAe,GAAGT;AAC5B,CAAC,KAAK;EACJ,MAAMU,WAAW,GAAGZ,gBAAgB,CAAEa,KAAK,IAAKA,KAAK,CAACC,UAAU,CAAC;EACjE,MAAM;IAAEC;EAAM,CAAC,GAAGX,iBAAiB,CAAC,CAAC;EACrC,MAAMY,SAAS,GAAGnB,OAAO,CACvB,MAAM,CAACoB,MAAM,CAACC,UAAU,EAAE;IAAEC,KAAK,EAAEJ,KAAK,CAACH,WAAW,CAAC,CAACQ;EAAQ,CAAC,CAAC,EAChE,CAACR,WAAW,EAAEG,KAAK,CACrB,CAAC;EACD,MAAMM,WAAW,GAAGzB,WAAW,CAC5B0B,KAA4B,IAAK;IAChCf,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAGe,KAAK,CAAC;IAChB,IAAI,CAACA,KAAK,CAACC,kBAAkB,CAAC,CAAC,EAAEtB,kBAAkB,CAACuB,OAAO,CAAC,CAAC;EAC/D,CAAC,EACD,CAACjB,OAAO,CACV,CAAC;EAED,oBACEZ,KAAA,CAAA8B,aAAA,CAACd,eAAe;IACde,iBAAiB,EAAC,qBAAqB;IACvCC,kBAAkB,EAAC,MAAM;IACzBnB,YAAY,EAAEA,YAAa;IAC3BoB,KAAK,EAAEX,MAAM,CAACY,mBAAoB;IAClCC,MAAM,EAAE3B,6BAA8B;IACtCY,KAAK,EAAEA,KAAM;IACbR,OAAO,EAAEc;EAAY,gBAErB1B,KAAA,CAAA8B,aAAA,CAAC1B,IAAI;IAACgC,qBAAqB,EAAE,GAAI;IAACH,KAAK,EAAEZ;EAAU,GAChDV,QAAQ,IAAIG,IAAI,IAAI,MACjB,CACS,CAAC;AAEtB,CAAC;AAED,MAAMQ,MAAM,GAAGnB,UAAU,CAACkC,MAAM,CAAC;EAC/Bd,UAAU,EAAE;IAAEe,UAAU,EAAE,KAAK;IAAEC,QAAQ,EAAE;EAAG,CAAC;EAC/CL,mBAAmB,EAAE;IAAEM,WAAW,EAAE,EAAE;IAAEC,UAAU,EAAE;EAAE;AACxD,CAAC,CAAC;AAEF,eAAe/B,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { KeyboardController } from "../../../../module";
|
|
3
|
+
import Arrow from "../../Arrow";
|
|
4
|
+
import Button from "../../Button";
|
|
5
|
+
import { TEST_ID_KEYBOARD_TOOLBAR_NEXT } from "../../constants";
|
|
6
|
+
import { useToolbarContext } from "../context";
|
|
7
|
+
const Next = ({
|
|
8
|
+
children,
|
|
9
|
+
onPress,
|
|
10
|
+
disabled,
|
|
11
|
+
rippleRadius,
|
|
12
|
+
style,
|
|
13
|
+
button: ButtonContainer = Button,
|
|
14
|
+
icon: IconContainer = Arrow
|
|
15
|
+
}) => {
|
|
16
|
+
const {
|
|
17
|
+
theme,
|
|
18
|
+
isNextDisabled
|
|
19
|
+
} = useToolbarContext();
|
|
20
|
+
const isDisabled = disabled ?? isNextDisabled;
|
|
21
|
+
const onPressNext = useCallback(event => {
|
|
22
|
+
onPress === null || onPress === void 0 || onPress(event);
|
|
23
|
+
if (!event.isDefaultPrevented()) KeyboardController.setFocusTo("next");
|
|
24
|
+
}, [onPress]);
|
|
25
|
+
return /*#__PURE__*/React.createElement(ButtonContainer, {
|
|
26
|
+
accessibilityHint: "Moves focus to the next field",
|
|
27
|
+
accessibilityLabel: "Next",
|
|
28
|
+
disabled: isDisabled,
|
|
29
|
+
rippleRadius: rippleRadius,
|
|
30
|
+
style: style,
|
|
31
|
+
testID: TEST_ID_KEYBOARD_TOOLBAR_NEXT,
|
|
32
|
+
theme: theme,
|
|
33
|
+
onPress: onPressNext
|
|
34
|
+
}, children ?? /*#__PURE__*/React.createElement(IconContainer, {
|
|
35
|
+
disabled: isDisabled,
|
|
36
|
+
theme: theme,
|
|
37
|
+
type: "next"
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
export default Next;
|
|
41
|
+
//# sourceMappingURL=Next.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","KeyboardController","Arrow","Button","TEST_ID_KEYBOARD_TOOLBAR_NEXT","useToolbarContext","Next","children","onPress","disabled","rippleRadius","style","button","ButtonContainer","icon","IconContainer","theme","isNextDisabled","isDisabled","onPressNext","event","isDefaultPrevented","setFocusTo","createElement","accessibilityHint","accessibilityLabel","testID","type"],"sources":["Next.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\n\nimport { KeyboardController } from \"../../../../module\";\nimport Arrow from \"../../Arrow\";\nimport Button from \"../../Button\";\nimport { TEST_ID_KEYBOARD_TOOLBAR_NEXT } from \"../../constants\";\nimport { useToolbarContext } from \"../context\";\n\nimport type { ButtonSubProps } from \"./types\";\nimport type { GestureResponderEvent } from \"react-native\";\n\nconst Next: React.FC<ButtonSubProps> = ({\n children,\n onPress,\n disabled,\n rippleRadius,\n style,\n button: ButtonContainer = Button,\n icon: IconContainer = Arrow,\n}) => {\n const { theme, isNextDisabled } = useToolbarContext();\n const isDisabled = disabled ?? isNextDisabled;\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onPress?.(event);\n if (!event.isDefaultPrevented()) KeyboardController.setFocusTo(\"next\");\n },\n [onPress],\n );\n\n return (\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isDisabled}\n rippleRadius={rippleRadius}\n style={style}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n {children ?? (\n <IconContainer disabled={isDisabled} theme={theme} type=\"next\" />\n )}\n </ButtonContainer>\n );\n};\n\nexport default Next;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAE1C,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,OAAOC,KAAK,MAAM,aAAa;AAC/B,OAAOC,MAAM,MAAM,cAAc;AACjC,SAASC,6BAA6B,QAAQ,iBAAiB;AAC/D,SAASC,iBAAiB,QAAQ,YAAY;AAK9C,MAAMC,IAA8B,GAAGA,CAAC;EACtCC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,YAAY;EACZC,KAAK;EACLC,MAAM,EAAEC,eAAe,GAAGV,MAAM;EAChCW,IAAI,EAAEC,aAAa,GAAGb;AACxB,CAAC,KAAK;EACJ,MAAM;IAAEc,KAAK;IAAEC;EAAe,CAAC,GAAGZ,iBAAiB,CAAC,CAAC;EACrD,MAAMa,UAAU,GAAGT,QAAQ,IAAIQ,cAAc;EAC7C,MAAME,WAAW,GAAGnB,WAAW,CAC5BoB,KAA4B,IAAK;IAChCZ,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAGY,KAAK,CAAC;IAChB,IAAI,CAACA,KAAK,CAACC,kBAAkB,CAAC,CAAC,EAAEpB,kBAAkB,CAACqB,UAAU,CAAC,MAAM,CAAC;EACxE,CAAC,EACD,CAACd,OAAO,CACV,CAAC;EAED,oBACET,KAAA,CAAAwB,aAAA,CAACV,eAAe;IACdW,iBAAiB,EAAC,+BAA+B;IACjDC,kBAAkB,EAAC,MAAM;IACzBhB,QAAQ,EAAES,UAAW;IACrBR,YAAY,EAAEA,YAAa;IAC3BC,KAAK,EAAEA,KAAM;IACbe,MAAM,EAAEtB,6BAA8B;IACtCY,KAAK,EAAEA,KAAM;IACbR,OAAO,EAAEW;EAAY,GAEpBZ,QAAQ,iBACPR,KAAA,CAAAwB,aAAA,CAACR,aAAa;IAACN,QAAQ,EAAES,UAAW;IAACF,KAAK,EAAEA,KAAM;IAACW,IAAI,EAAC;EAAM,CAAE,CAEnD,CAAC;AAEtB,CAAC;AAED,eAAerB,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { KeyboardController } from "../../../../module";
|
|
3
|
+
import Arrow from "../../Arrow";
|
|
4
|
+
import Button from "../../Button";
|
|
5
|
+
import { TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS } from "../../constants";
|
|
6
|
+
import { useToolbarContext } from "../context";
|
|
7
|
+
const Prev = ({
|
|
8
|
+
children,
|
|
9
|
+
onPress,
|
|
10
|
+
disabled,
|
|
11
|
+
rippleRadius,
|
|
12
|
+
style,
|
|
13
|
+
button: ButtonContainer = Button,
|
|
14
|
+
icon: IconContainer = Arrow
|
|
15
|
+
}) => {
|
|
16
|
+
const {
|
|
17
|
+
theme,
|
|
18
|
+
isPrevDisabled
|
|
19
|
+
} = useToolbarContext();
|
|
20
|
+
const isDisabled = disabled ?? isPrevDisabled;
|
|
21
|
+
const onPressPrev = useCallback(event => {
|
|
22
|
+
onPress === null || onPress === void 0 || onPress(event);
|
|
23
|
+
if (!event.isDefaultPrevented()) KeyboardController.setFocusTo("prev");
|
|
24
|
+
}, [onPress]);
|
|
25
|
+
return /*#__PURE__*/React.createElement(ButtonContainer, {
|
|
26
|
+
accessibilityHint: "Moves focus to the previous field",
|
|
27
|
+
accessibilityLabel: "Previous",
|
|
28
|
+
disabled: isDisabled,
|
|
29
|
+
rippleRadius: rippleRadius,
|
|
30
|
+
style: style,
|
|
31
|
+
testID: TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS,
|
|
32
|
+
theme: theme,
|
|
33
|
+
onPress: onPressPrev
|
|
34
|
+
}, children ?? /*#__PURE__*/React.createElement(IconContainer, {
|
|
35
|
+
disabled: isDisabled,
|
|
36
|
+
theme: theme,
|
|
37
|
+
type: "prev"
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
export default Prev;
|
|
41
|
+
//# sourceMappingURL=Prev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","KeyboardController","Arrow","Button","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","useToolbarContext","Prev","children","onPress","disabled","rippleRadius","style","button","ButtonContainer","icon","IconContainer","theme","isPrevDisabled","isDisabled","onPressPrev","event","isDefaultPrevented","setFocusTo","createElement","accessibilityHint","accessibilityLabel","testID","type"],"sources":["Prev.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\n\nimport { KeyboardController } from \"../../../../module\";\nimport Arrow from \"../../Arrow\";\nimport Button from \"../../Button\";\nimport { TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS } from \"../../constants\";\nimport { useToolbarContext } from \"../context\";\n\nimport type { ButtonSubProps } from \"./types\";\nimport type { GestureResponderEvent } from \"react-native\";\n\nconst Prev: React.FC<ButtonSubProps> = ({\n children,\n onPress,\n disabled,\n rippleRadius,\n style,\n button: ButtonContainer = Button,\n icon: IconContainer = Arrow,\n}) => {\n const { theme, isPrevDisabled } = useToolbarContext();\n const isDisabled = disabled ?? isPrevDisabled;\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPress?.(event);\n if (!event.isDefaultPrevented()) KeyboardController.setFocusTo(\"prev\");\n },\n [onPress],\n );\n\n return (\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isDisabled}\n rippleRadius={rippleRadius}\n style={style}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n {children ?? (\n <IconContainer disabled={isDisabled} theme={theme} type=\"prev\" />\n )}\n </ButtonContainer>\n );\n};\n\nexport default Prev;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAE1C,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,OAAOC,KAAK,MAAM,aAAa;AAC/B,OAAOC,MAAM,MAAM,cAAc;AACjC,SAASC,iCAAiC,QAAQ,iBAAiB;AACnE,SAASC,iBAAiB,QAAQ,YAAY;AAK9C,MAAMC,IAA8B,GAAGA,CAAC;EACtCC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,YAAY;EACZC,KAAK;EACLC,MAAM,EAAEC,eAAe,GAAGV,MAAM;EAChCW,IAAI,EAAEC,aAAa,GAAGb;AACxB,CAAC,KAAK;EACJ,MAAM;IAAEc,KAAK;IAAEC;EAAe,CAAC,GAAGZ,iBAAiB,CAAC,CAAC;EACrD,MAAMa,UAAU,GAAGT,QAAQ,IAAIQ,cAAc;EAC7C,MAAME,WAAW,GAAGnB,WAAW,CAC5BoB,KAA4B,IAAK;IAChCZ,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAGY,KAAK,CAAC;IAChB,IAAI,CAACA,KAAK,CAACC,kBAAkB,CAAC,CAAC,EAAEpB,kBAAkB,CAACqB,UAAU,CAAC,MAAM,CAAC;EACxE,CAAC,EACD,CAACd,OAAO,CACV,CAAC;EAED,oBACET,KAAA,CAAAwB,aAAA,CAACV,eAAe;IACdW,iBAAiB,EAAC,mCAAmC;IACrDC,kBAAkB,EAAC,UAAU;IAC7BhB,QAAQ,EAAES,UAAW;IACrBR,YAAY,EAAEA,YAAa;IAC3BC,KAAK,EAAEA,KAAM;IACbe,MAAM,EAAEtB,iCAAkC;IAC1CY,KAAK,EAAEA,KAAM;IACbR,OAAO,EAAEW;EAAY,GAEpBZ,QAAQ,iBACPR,KAAA,CAAAwB,aAAA,CAACR,aAAa;IAACN,QAAQ,EAAES,UAAW;IAACF,KAAK,EAAEA,KAAM;IAACW,IAAI,EAAC;EAAM,CAAE,CAEnD,CAAC;AAEtB,CAAC;AAED,eAAerB,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Background } from "./Background";
|
|
2
|
+
export { default as Content } from "./Content";
|
|
3
|
+
export { default as Done } from "./Done";
|
|
4
|
+
export { default as Next } from "./Next";
|
|
5
|
+
export { default as Prev } from "./Prev";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default","Background","Content","Done","Next","Prev"],"sources":["index.ts"],"sourcesContent":["export { default as Background } from \"./Background\";\nexport { default as Content } from \"./Content\";\nexport { default as Done } from \"./Done\";\nexport { default as Next } from \"./Next\";\nexport { default as Prev } from \"./Prev\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAAU,QAAQ,cAAc;AACpD,SAASD,OAAO,IAAIE,OAAO,QAAQ,WAAW;AAC9C,SAASF,OAAO,IAAIG,IAAI,QAAQ,QAAQ;AACxC,SAASH,OAAO,IAAII,IAAI,QAAQ,QAAQ;AACxC,SAASJ,OAAO,IAAIK,IAAI,QAAQ,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type Arrow from \"../../Arrow\";\nimport type Button from \"../../Button\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewStyle } from \"react-native\";\n\nexport type ButtonSubProps = {\n children?: ReactNode;\n onPress?: (event: GestureResponderEvent) => void;\n disabled?: boolean;\n testID?: string;\n rippleRadius?: number;\n style?: ViewStyle;\n button?: typeof Button;\n icon?: typeof Arrow;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
export const ToolbarContext = /*#__PURE__*/createContext(undefined);
|
|
3
|
+
export const useToolbarContext = () => {
|
|
4
|
+
const context = useContext(ToolbarContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error("KeyboardToolbar.* component must be used inside <KeyboardToolbar>");
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","useContext","ToolbarContext","undefined","useToolbarContext","context","Error"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nimport type { KeyboardToolbarTheme } from \"../types\";\n\ntype ToolbarContextType = {\n theme: KeyboardToolbarTheme;\n isPrevDisabled: boolean;\n isNextDisabled: boolean;\n};\n\nexport const ToolbarContext = createContext<ToolbarContextType | undefined>(\n undefined,\n);\n\nexport const useToolbarContext = () => {\n const context = useContext(ToolbarContext);\n\n if (!context) {\n throw new Error(\n \"KeyboardToolbar.* component must be used inside <KeyboardToolbar>\",\n );\n }\n\n return context;\n};\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAUjD,OAAO,MAAMC,cAAc,gBAAGF,aAAa,CACzCG,SACF,CAAC;AAED,OAAO,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EACrC,MAAMC,OAAO,GAAGJ,UAAU,CAACC,cAAc,CAAC;EAE1C,IAAI,CAACG,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CACb,mEACF,CAAC;EACH;EAEA,OAAOD,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { KEYBOARD_BORDER_RADIUS } from "../../constants";
|
|
2
|
+
export const TEST_ID_KEYBOARD_TOOLBAR = "keyboard.toolbar";
|
|
3
|
+
export const TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;
|
|
4
|
+
export const TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;
|
|
5
|
+
export const TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;
|
|
6
|
+
export const TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;
|
|
7
|
+
export const KEYBOARD_TOOLBAR_HEIGHT = 42;
|
|
8
|
+
export const DEFAULT_OPACITY = "FF";
|
|
9
|
+
export const KEYBOARD_HAS_ROUNDED_CORNERS = KEYBOARD_BORDER_RADIUS > 0;
|
|
10
|
+
export const OPENED_OFFSET = KEYBOARD_HAS_ROUNDED_CORNERS ? -11 : 0;
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["KEYBOARD_BORDER_RADIUS","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","KEYBOARD_HAS_ROUNDED_CORNERS","OPENED_OFFSET"],"sources":["constants.ts"],"sourcesContent":["import { KEYBOARD_BORDER_RADIUS } from \"../../constants\";\n\nimport type { HEX } from \"./types\";\n\nexport const TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nexport const TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nexport const TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nexport const TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nexport const TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nexport const KEYBOARD_TOOLBAR_HEIGHT = 42;\nexport const DEFAULT_OPACITY: HEX = \"FF\";\nexport const KEYBOARD_HAS_ROUNDED_CORNERS = KEYBOARD_BORDER_RADIUS > 0;\nexport const OPENED_OFFSET = KEYBOARD_HAS_ROUNDED_CORNERS ? -11 : 0;\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,iBAAiB;AAIxD,OAAO,MAAMC,wBAAwB,GAAG,kBAAkB;AAC1D,OAAO,MAAMC,iCAAiC,GAAG,GAAGD,wBAAwB,WAAW;AACvF,OAAO,MAAME,6BAA6B,GAAG,GAAGF,wBAAwB,OAAO;AAC/E,OAAO,MAAMG,gCAAgC,GAAG,GAAGH,wBAAwB,UAAU;AACrF,OAAO,MAAMI,6BAA6B,GAAG,GAAGJ,wBAAwB,OAAO;AAE/E,OAAO,MAAMK,uBAAuB,GAAG,EAAE;AACzC,OAAO,MAAMC,eAAoB,GAAG,IAAI;AACxC,OAAO,MAAMC,4BAA4B,GAAGR,sBAAsB,GAAG,CAAC;AACtE,OAAO,MAAMS,aAAa,GAAGD,4BAA4B,GAAG,CAAC,EAAE,GAAG,CAAC","ignoreList":[]}
|
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, {
|
|
3
|
-
import { StyleSheet,
|
|
4
|
-
import { FocusedInputEvents } from "../../bindings";
|
|
2
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { StyleSheet, View } from "react-native";
|
|
4
|
+
import { FocusedInputEvents, RCTKeyboardToolbarGroupView } from "../../bindings";
|
|
5
|
+
import { useKeyboardState } from "../../hooks";
|
|
5
6
|
import KeyboardStickyView from "../KeyboardStickyView";
|
|
6
|
-
import { KeyboardControllerNative } from "../../bindings";
|
|
7
|
-
import useColorScheme from "../hooks/useColorScheme";
|
|
8
7
|
import Arrow from "./Arrow";
|
|
9
8
|
import Button from "./Button";
|
|
10
9
|
import { colors } from "./colors";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const DEFAULT_OPACITY = "FF";
|
|
18
|
-
const dismissKeyboard = () => KeyboardControllerNative.dismiss(false);
|
|
19
|
-
const goToNextField = () => KeyboardControllerNative.setFocusTo("next");
|
|
20
|
-
const goToPrevField = () => KeyboardControllerNative.setFocusTo("prev");
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and
|
|
24
|
-
* `Done` buttons.
|
|
10
|
+
import { Background, Content, Done, Next, Prev } from "./compound/components";
|
|
11
|
+
import { ToolbarContext } from "./compound/context";
|
|
12
|
+
import { DEFAULT_OPACITY, KEYBOARD_HAS_ROUNDED_CORNERS, KEYBOARD_TOOLBAR_HEIGHT, OPENED_OFFSET, TEST_ID_KEYBOARD_TOOLBAR } from "./constants";
|
|
13
|
+
/**
|
|
14
|
+
* `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and
|
|
15
|
+
* `Done` buttons.
|
|
25
16
|
*/
|
|
26
17
|
const KeyboardToolbar = ({
|
|
18
|
+
children,
|
|
27
19
|
content,
|
|
28
20
|
theme = colors,
|
|
29
|
-
doneText,
|
|
21
|
+
doneText = "Done",
|
|
30
22
|
button,
|
|
31
23
|
icon,
|
|
32
24
|
showArrows = true,
|
|
@@ -40,92 +32,103 @@ const KeyboardToolbar = ({
|
|
|
40
32
|
opened = 0
|
|
41
33
|
} = {},
|
|
42
34
|
enabled = true,
|
|
35
|
+
insets,
|
|
43
36
|
...rest
|
|
44
37
|
}) => {
|
|
45
|
-
const colorScheme =
|
|
38
|
+
const colorScheme = useKeyboardState(state => state.appearance);
|
|
46
39
|
const [inputs, setInputs] = useState({
|
|
47
40
|
current: 0,
|
|
48
41
|
count: 0
|
|
49
42
|
});
|
|
50
43
|
const isPrevDisabled = inputs.current === 0;
|
|
51
44
|
const isNextDisabled = inputs.current === inputs.count - 1;
|
|
45
|
+
const buttonContainer = button ?? Button;
|
|
46
|
+
const iconContainer = icon ?? Arrow;
|
|
52
47
|
useEffect(() => {
|
|
53
48
|
const subscription = FocusedInputEvents.addListener("focusDidSet", e => {
|
|
54
49
|
setInputs(e);
|
|
55
50
|
});
|
|
56
51
|
return subscription.remove;
|
|
57
52
|
}, []);
|
|
58
|
-
const doneStyle = useMemo(() => [styles.doneButton, {
|
|
59
|
-
color: theme[colorScheme].primary
|
|
60
|
-
}], [colorScheme, theme]);
|
|
61
53
|
const toolbarStyle = useMemo(() => [styles.toolbar, {
|
|
62
54
|
backgroundColor: `${theme[colorScheme].background}${opacity}`
|
|
63
|
-
}
|
|
55
|
+
}, !KEYBOARD_HAS_ROUNDED_CORNERS ? {
|
|
56
|
+
paddingLeft: insets === null || insets === void 0 ? void 0 : insets.left,
|
|
57
|
+
paddingRight: insets === null || insets === void 0 ? void 0 : insets.right
|
|
58
|
+
} : null, KEYBOARD_HAS_ROUNDED_CORNERS ? styles.floating : null], [colorScheme, opacity, theme, insets]);
|
|
59
|
+
const containerStyle = useMemo(() => [
|
|
60
|
+
// CRUCIAL: gives the native view real bounds
|
|
61
|
+
styles.sticky, KEYBOARD_HAS_ROUNDED_CORNERS ? {
|
|
62
|
+
left: ((insets === null || insets === void 0 ? void 0 : insets.left) ?? 0) + 16,
|
|
63
|
+
right: ((insets === null || insets === void 0 ? void 0 : insets.right) ?? 0) + 16
|
|
64
|
+
} : null], [insets]);
|
|
64
65
|
const offset = useMemo(() => ({
|
|
65
66
|
closed: closed + KEYBOARD_TOOLBAR_HEIGHT,
|
|
66
|
-
opened
|
|
67
|
+
opened: opened + OPENED_OFFSET
|
|
67
68
|
}), [closed, opened]);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
let backgroundElement = null;
|
|
70
|
+
let arrowsElement = null;
|
|
71
|
+
let contentContainer = null;
|
|
72
|
+
let doneElement = null;
|
|
73
|
+
if (children) {
|
|
74
|
+
let prevChild = null;
|
|
75
|
+
let nextChild = null;
|
|
76
|
+
let contentChild = null;
|
|
77
|
+
let doneChild = null;
|
|
78
|
+
let backgroundChild = null;
|
|
79
|
+
React.Children.forEach(children, child => {
|
|
80
|
+
if (! /*#__PURE__*/React.isValidElement(child)) return;
|
|
81
|
+
if (child.type === Background) backgroundChild = child;else if (child.type === Content) contentChild = child;else if (child.type === Prev) prevChild = child;else if (child.type === Next) nextChild = child;else if (child.type === Done) doneChild = child;
|
|
82
|
+
});
|
|
83
|
+
backgroundElement = backgroundChild;
|
|
84
|
+
doneElement = doneChild;
|
|
85
|
+
arrowsElement = prevChild || nextChild ? /*#__PURE__*/React.createElement(View, {
|
|
86
|
+
style: styles.arrows
|
|
87
|
+
}, prevChild, nextChild) : null;
|
|
88
|
+
contentContainer = contentChild ?? /*#__PURE__*/React.createElement(Content, null, contentChild);
|
|
89
|
+
} else {
|
|
90
|
+
backgroundElement = blur;
|
|
91
|
+
arrowsElement = showArrows ? /*#__PURE__*/React.createElement(View, {
|
|
92
|
+
style: styles.arrows
|
|
93
|
+
}, /*#__PURE__*/React.createElement(Prev, {
|
|
94
|
+
button: buttonContainer,
|
|
95
|
+
icon: iconContainer,
|
|
96
|
+
onPress: onPrevCallback
|
|
97
|
+
}), /*#__PURE__*/React.createElement(Next, {
|
|
98
|
+
button: buttonContainer,
|
|
99
|
+
icon: iconContainer,
|
|
100
|
+
onPress: onNextCallback
|
|
101
|
+
})) : null;
|
|
102
|
+
contentContainer = /*#__PURE__*/React.createElement(Content, null, content);
|
|
103
|
+
doneElement = doneText ? /*#__PURE__*/React.createElement(Done, {
|
|
104
|
+
button: buttonContainer,
|
|
105
|
+
text: doneText,
|
|
106
|
+
onPress: onDoneCallback
|
|
107
|
+
}) : null;
|
|
108
|
+
}
|
|
109
|
+
const contextValue = useMemo(() => ({
|
|
110
|
+
theme,
|
|
111
|
+
isPrevDisabled,
|
|
112
|
+
isNextDisabled
|
|
113
|
+
}), [theme, isPrevDisabled, isNextDisabled]);
|
|
114
|
+
return /*#__PURE__*/React.createElement(ToolbarContext.Provider, {
|
|
115
|
+
value: contextValue
|
|
116
|
+
}, /*#__PURE__*/React.createElement(KeyboardStickyView, {
|
|
83
117
|
enabled: enabled,
|
|
84
|
-
offset: offset
|
|
118
|
+
offset: offset,
|
|
119
|
+
style: containerStyle
|
|
85
120
|
}, /*#__PURE__*/React.createElement(View, _extends({}, rest, {
|
|
86
121
|
style: toolbarStyle,
|
|
87
122
|
testID: TEST_ID_KEYBOARD_TOOLBAR
|
|
88
|
-
}),
|
|
89
|
-
accessibilityLabel: "Previous",
|
|
90
|
-
accessibilityHint: "Will move focus to previous field",
|
|
91
|
-
disabled: isPrevDisabled,
|
|
92
|
-
onPress: onPressPrev,
|
|
93
|
-
testID: TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS,
|
|
94
|
-
theme: theme
|
|
95
|
-
}, /*#__PURE__*/React.createElement(IconContainer, {
|
|
96
|
-
disabled: isPrevDisabled,
|
|
97
|
-
type: "prev",
|
|
98
|
-
theme: theme
|
|
99
|
-
})), /*#__PURE__*/React.createElement(ButtonContainer, {
|
|
100
|
-
accessibilityLabel: "Next",
|
|
101
|
-
accessibilityHint: "Will move focus to next field",
|
|
102
|
-
disabled: isNextDisabled,
|
|
103
|
-
onPress: onPressNext,
|
|
104
|
-
testID: TEST_ID_KEYBOARD_TOOLBAR_NEXT,
|
|
105
|
-
theme: theme
|
|
106
|
-
}, /*#__PURE__*/React.createElement(IconContainer, {
|
|
107
|
-
disabled: isNextDisabled,
|
|
108
|
-
type: "next",
|
|
109
|
-
theme: theme
|
|
110
|
-
}))), /*#__PURE__*/React.createElement(View, {
|
|
111
|
-
style: styles.flex,
|
|
112
|
-
testID: TEST_ID_KEYBOARD_TOOLBAR_CONTENT
|
|
113
|
-
}, content), /*#__PURE__*/React.createElement(ButtonContainer, {
|
|
114
|
-
accessibilityLabel: "Done",
|
|
115
|
-
accessibilityHint: "Will close the keyboard",
|
|
116
|
-
onPress: onPressDone,
|
|
117
|
-
testID: TEST_ID_KEYBOARD_TOOLBAR_DONE,
|
|
118
|
-
rippleRadius: 28,
|
|
119
|
-
style: styles.doneButtonContainer,
|
|
120
|
-
theme: theme
|
|
121
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
122
|
-
style: doneStyle,
|
|
123
|
-
maxFontSizeMultiplier: 1.3
|
|
124
|
-
}, doneText || "Done"))));
|
|
123
|
+
}), backgroundElement, arrowsElement, contentContainer, doneElement)));
|
|
125
124
|
};
|
|
126
125
|
const styles = StyleSheet.create({
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
sticky: {
|
|
127
|
+
position: "absolute",
|
|
128
|
+
left: 0,
|
|
129
|
+
right: 0,
|
|
130
|
+
bottom: 0,
|
|
131
|
+
height: KEYBOARD_TOOLBAR_HEIGHT
|
|
129
132
|
},
|
|
130
133
|
toolbar: {
|
|
131
134
|
position: "absolute",
|
|
@@ -133,17 +136,24 @@ const styles = StyleSheet.create({
|
|
|
133
136
|
alignItems: "center",
|
|
134
137
|
width: "100%",
|
|
135
138
|
flexDirection: "row",
|
|
136
|
-
height: KEYBOARD_TOOLBAR_HEIGHT
|
|
137
|
-
paddingHorizontal: 8
|
|
139
|
+
height: KEYBOARD_TOOLBAR_HEIGHT
|
|
138
140
|
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
arrows: {
|
|
142
|
+
flexDirection: "row",
|
|
143
|
+
paddingLeft: 8
|
|
142
144
|
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
floating: {
|
|
146
|
+
alignSelf: "center",
|
|
147
|
+
borderRadius: 20,
|
|
148
|
+
overflow: "hidden"
|
|
145
149
|
}
|
|
146
150
|
});
|
|
151
|
+
KeyboardToolbar.Background = Background;
|
|
152
|
+
KeyboardToolbar.Content = Content;
|
|
153
|
+
KeyboardToolbar.Prev = Prev;
|
|
154
|
+
KeyboardToolbar.Next = Next;
|
|
155
|
+
KeyboardToolbar.Done = Done;
|
|
156
|
+
KeyboardToolbar.Group = RCTKeyboardToolbarGroupView;
|
|
147
157
|
export { colors as DefaultKeyboardToolbarTheme };
|
|
148
158
|
export default KeyboardToolbar;
|
|
149
159
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useMemo","useState","StyleSheet","Text","View","FocusedInputEvents","KeyboardStickyView","KeyboardControllerNative","useColorScheme","Arrow","Button","colors","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","dismissKeyboard","dismiss","goToNextField","setFocusTo","goToPrevField","KeyboardToolbar","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","offset","closed","opened","enabled","rest","colorScheme","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","subscription","addListener","e","remove","doneStyle","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","IconContainer","onPressNext","onPressPrev","onPressDone","createElement","_extends","style","testID","Fragment","accessibilityLabel","accessibilityHint","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","maxFontSizeMultiplier","create","position","bottom","alignItems","width","flexDirection","height","paddingHorizontal","fontWeight","fontSize","marginRight","DefaultKeyboardToolbarTheme"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\r\nimport { StyleSheet, Text, View } from \"react-native\";\r\n\r\nimport {\r\n FocusedInputEvents,\r\n} from \"../../bindings\";\r\nimport KeyboardStickyView from \"../KeyboardStickyView\"\r\nimport { KeyboardControllerNative } from \"../../bindings\";\r\nimport useColorScheme from \"../hooks/useColorScheme\";\r\n\r\nimport Arrow from \"./Arrow\";\r\nimport Button from \"./Button\";\r\nimport { colors } from \"./colors\";\r\n\r\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\r\nimport type { KeyboardStickyViewProps } from \"../KeyboardStickyView\";\r\nimport type { ReactNode } from \"react\";\r\nimport type { ViewProps } from \"react-native\";\r\n\r\nexport type KeyboardToolbarProps = Omit<\r\n ViewProps,\r\n \"style\" | \"testID\" | \"children\"\r\n> & {\r\n /** An element that is shown in the middle of the toolbar. */\r\n content?: JSX.Element | null;\r\n /** A set of dark/light colors consumed by toolbar component. */\r\n theme?: KeyboardToolbarTheme;\r\n /** Custom text for done button. */\r\n doneText?: ReactNode;\r\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\r\n button?: typeof Button;\r\n /** Custom icon component used to display next/prev buttons. */\r\n icon?: typeof Arrow;\r\n /**\r\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\r\n * and want to show only `Done` button. Default to `true`.\r\n */\r\n showArrows?: boolean;\r\n /**\r\n * A callback that is called when the user presses the next button along with the default action.\r\n */\r\n onNextCallback?: () => void;\r\n /**\r\n * A callback that is called when the user presses the previous button along with the default action.\r\n */\r\n onPrevCallback?: () => void;\r\n /**\r\n * A callback that is called when the user presses the done button along with the default action.\r\n */\r\n onDoneCallback?: () => void;\r\n /**\r\n * A component that applies blur effect to the toolbar.\r\n */\r\n blur?: JSX.Element | null;\r\n /**\r\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\r\n */\r\n opacity?: HEX;\r\n} & Pick<KeyboardStickyViewProps, \"offset\" | \"enabled\">;\r\n\r\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\r\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\r\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\r\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\r\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\r\n\r\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\r\nconst DEFAULT_OPACITY: HEX = \"FF\";\r\n\r\nconst dismissKeyboard = () => KeyboardControllerNative.dismiss(false);\r\nconst goToNextField = () => KeyboardControllerNative.setFocusTo(\"next\");\r\nconst goToPrevField = () => KeyboardControllerNative.setFocusTo(\"prev\");\r\n\r\n/**\r\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\r\n * `Done` buttons.\r\n */\r\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({\r\n content,\r\n theme = colors,\r\n doneText,\r\n button,\r\n icon,\r\n showArrows = true,\r\n onNextCallback,\r\n onPrevCallback,\r\n onDoneCallback,\r\n blur = null,\r\n opacity = DEFAULT_OPACITY,\r\n offset: { closed = 0, opened = 0 } = {},\r\n enabled = true,\r\n ...rest\r\n}) => {\r\n const colorScheme = useColorScheme();\r\n const [inputs, setInputs] = useState({\r\n current: 0,\r\n count: 0,\r\n });\r\n const isPrevDisabled = inputs.current === 0;\r\n const isNextDisabled = inputs.current === inputs.count - 1;\r\n\r\n useEffect(() => {\r\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\r\n setInputs(e);\r\n });\r\n\r\n return subscription.remove;\r\n }, []);\r\n const doneStyle = useMemo(\r\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\r\n [colorScheme, theme],\r\n );\r\n const toolbarStyle = useMemo(\r\n () => [\r\n styles.toolbar,\r\n {\r\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\r\n },\r\n ],\r\n [colorScheme, opacity, theme],\r\n );\r\n const offset = useMemo(\r\n () => ({ closed: closed + KEYBOARD_TOOLBAR_HEIGHT, opened }),\r\n [closed, opened],\r\n );\r\n const ButtonContainer = button || Button;\r\n const IconContainer = icon || Arrow;\r\n\r\n const onPressNext = useCallback(() => {\r\n goToNextField();\r\n onNextCallback?.();\r\n }, [onNextCallback]);\r\n const onPressPrev = useCallback(() => {\r\n goToPrevField();\r\n onPrevCallback?.();\r\n }, [onPrevCallback]);\r\n const onPressDone = useCallback(() => {\r\n dismissKeyboard();\r\n onDoneCallback?.();\r\n }, [onDoneCallback]);\r\n\r\n return (\r\n <KeyboardStickyView enabled={enabled} offset={offset}>\r\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\r\n {blur}\r\n {showArrows && (\r\n <>\r\n <ButtonContainer\r\n accessibilityLabel=\"Previous\"\r\n accessibilityHint=\"Will move focus to previous field\"\r\n disabled={isPrevDisabled}\r\n onPress={onPressPrev}\r\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\r\n theme={theme}\r\n >\r\n <IconContainer\r\n disabled={isPrevDisabled}\r\n type=\"prev\"\r\n theme={theme}\r\n />\r\n </ButtonContainer>\r\n <ButtonContainer\r\n accessibilityLabel=\"Next\"\r\n accessibilityHint=\"Will move focus to next field\"\r\n disabled={isNextDisabled}\r\n onPress={onPressNext}\r\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\r\n theme={theme}\r\n >\r\n <IconContainer\r\n disabled={isNextDisabled}\r\n type=\"next\"\r\n theme={theme}\r\n />\r\n </ButtonContainer>\r\n </>\r\n )}\r\n\r\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\r\n {content}\r\n </View>\r\n <ButtonContainer\r\n accessibilityLabel=\"Done\"\r\n accessibilityHint=\"Will close the keyboard\"\r\n onPress={onPressDone}\r\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\r\n rippleRadius={28}\r\n style={styles.doneButtonContainer}\r\n theme={theme}\r\n >\r\n <Text style={doneStyle} maxFontSizeMultiplier={1.3}>\r\n {doneText || \"Done\"}\r\n </Text>\r\n </ButtonContainer>\r\n </View>\r\n </KeyboardStickyView>\r\n );\r\n};\r\n\r\nconst styles = StyleSheet.create({\r\n flex: {\r\n flex: 1,\r\n },\r\n toolbar: {\r\n position: \"absolute\",\r\n bottom: 0,\r\n alignItems: \"center\",\r\n width: \"100%\",\r\n flexDirection: \"row\",\r\n height: KEYBOARD_TOOLBAR_HEIGHT,\r\n paddingHorizontal: 8,\r\n },\r\n doneButton: {\r\n fontWeight: \"600\",\r\n fontSize: 15,\r\n },\r\n doneButtonContainer: {\r\n marginRight: 8,\r\n },\r\n});\r\n\r\nexport { colors as DefaultKeyboardToolbarTheme };\r\nexport default KeyboardToolbar;\r\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACxE,SAASC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAErD,SACEC,kBAAkB,QACb,gBAAgB;AACvB,OAAOC,kBAAkB,MAAM,uBAAuB;AACtD,SAASC,wBAAwB,QAAQ,gBAAgB;AACzD,OAAOC,cAAc,MAAM,yBAAyB;AAEpD,OAAOC,KAAK,MAAM,SAAS;AA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K,EAAEA;EAAM,CACd,CACc,CACjB,CACH,eAED7B,KAAA,CAAAqE,aAAA,CAAC9D,IAAI;IAACgE,KAAK,EAAEf,MAAM,CAACuB,IAAK;IAACP,MAAM,EAAEtD;EAAiC,GAChEU,OACG,CAAC,eACP5B,KAAA,CAAAqE,aAAA,CAACL,eAAe;IACdU,kBAAkB,EAAC,MAAM;IACzBC,iBAAiB,EAAC,yBAAyB;IAC3CE,OAAO,EAAET,WAAY;IACrBI,MAAM,EAAErD,6BAA8B;IACtC6D,YAAY,EAAE,EAAG;IACjBT,KAAK,EAAEf,MAAM,CAACyB,mBAAoB;IAClCpD,KAAK,EAAEA;EAAM,gBAEb7B,KAAA,CAAAqE,aAAA,CAAC/D,IAAI;IAACiE,KAAK,EAAEhB,SAAU;IAAC2B,qBAAqB,EAAE;EAAI,GAChDpD,QAAQ,IAAI,MACT,CACS,CACb,CACY,CAAC;AAEzB,CAAC;AAED,MAAM0B,MAAM,GAAGnD,UAAU,CAAC8E,MAAM,CAAC;EAC/BJ,IAAI,EAAE;IACJA,IAAI,EAAE;EACR,CAAC;EACDlB,OAAO,EAAE;IACPuB,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,aAAa,EAAE,KAAK;IACpBC,MAAM,EAAErE,uBAAuB;IAC/BsE,iBAAiB,EAAE;EACrB,CAAC;EACDjC,UAAU,EAAE;IACVkC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDX,mBAAmB,EAAE;IACnBY,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,SAAS/E,MAAM,IAAIgF,2BAA2B;AAC9C,eAAenE,eAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useEffect","useMemo","useState","StyleSheet","View","FocusedInputEvents","RCTKeyboardToolbarGroupView","useKeyboardState","KeyboardStickyView","Arrow","Button","colors","Background","Content","Done","Next","Prev","ToolbarContext","DEFAULT_OPACITY","KEYBOARD_HAS_ROUNDED_CORNERS","KEYBOARD_TOOLBAR_HEIGHT","OPENED_OFFSET","TEST_ID_KEYBOARD_TOOLBAR","KeyboardToolbar","children","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","offset","closed","opened","enabled","insets","rest","colorScheme","state","appearance","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","buttonContainer","iconContainer","subscription","addListener","e","remove","toolbarStyle","styles","toolbar","backgroundColor","background","paddingLeft","left","paddingRight","right","floating","containerStyle","sticky","backgroundElement","arrowsElement","contentContainer","doneElement","prevChild","nextChild","contentChild","doneChild","backgroundChild","Children","forEach","child","isValidElement","type","createElement","style","arrows","onPress","text","contextValue","Provider","value","_extends","testID","create","position","bottom","height","alignItems","width","flexDirection","alignSelf","borderRadius","overflow","Group","DefaultKeyboardToolbarTheme"],"sources":["index.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, View } from \"react-native\";\n\nimport {\n FocusedInputEvents,\n RCTKeyboardToolbarGroupView,\n} from \"../../bindings\";\nimport { useKeyboardState } from \"../../hooks\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\nimport { Background, Content, Done, Next, Prev } from \"./compound/components\";\nimport { ToolbarContext } from \"./compound/context\";\nimport {\n DEFAULT_OPACITY,\n KEYBOARD_HAS_ROUNDED_CORNERS,\n KEYBOARD_TOOLBAR_HEIGHT,\n OPENED_OFFSET,\n TEST_ID_KEYBOARD_TOOLBAR,\n} from \"./constants\";\n\nimport type { KeyboardToolbarProps } from \"./types\";\nimport type { ReactNode } from \"react\";\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\n * `Done` buttons.\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> & {\n Background: typeof Background;\n Content: typeof Content;\n Prev: typeof Prev;\n Next: typeof Next;\n Done: typeof Done;\n Group: typeof RCTKeyboardToolbarGroupView;\n} = ({\n children,\n content,\n theme = colors,\n doneText = \"Done\",\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n offset: { closed = 0, opened = 0 } = {},\n enabled = true,\n insets,\n ...rest\n}) => {\n const colorScheme = useKeyboardState((state) => state.appearance);\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n const buttonContainer = button ?? Button;\n const iconContainer = icon ?? Arrow;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n !KEYBOARD_HAS_ROUNDED_CORNERS\n ? {\n paddingLeft: insets?.left,\n paddingRight: insets?.right,\n }\n : null,\n KEYBOARD_HAS_ROUNDED_CORNERS ? styles.floating : null,\n ],\n [colorScheme, opacity, theme, insets],\n );\n const containerStyle = useMemo(\n () => [\n // CRUCIAL: gives the native view real bounds\n styles.sticky,\n KEYBOARD_HAS_ROUNDED_CORNERS\n ? ({\n left: (insets?.left ?? 0) + 16,\n right: (insets?.right ?? 0) + 16,\n } as const)\n : null,\n ],\n [insets],\n );\n const offset = useMemo(\n () => ({\n closed: closed + KEYBOARD_TOOLBAR_HEIGHT,\n opened: opened + OPENED_OFFSET,\n }),\n [closed, opened],\n );\n let backgroundElement: ReactNode = null;\n let arrowsElement: ReactNode = null;\n let contentContainer: ReactNode = null;\n let doneElement: ReactNode = null;\n\n if (children) {\n let prevChild: ReactNode = null;\n let nextChild: ReactNode = null;\n let contentChild: ReactNode = null;\n let doneChild: ReactNode = null;\n let backgroundChild: ReactNode = null;\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) return;\n if (child.type === Background) backgroundChild = child;\n else if (child.type === Content) contentChild = child;\n else if (child.type === Prev) prevChild = child;\n else if (child.type === Next) nextChild = child;\n else if (child.type === Done) doneChild = child;\n });\n\n backgroundElement = backgroundChild;\n doneElement = doneChild;\n arrowsElement =\n prevChild || nextChild ? (\n <View style={styles.arrows}>\n {prevChild}\n {nextChild}\n </View>\n ) : null;\n contentContainer = contentChild ?? <Content>{contentChild}</Content>;\n } else {\n backgroundElement = blur;\n arrowsElement = showArrows ? (\n <View style={styles.arrows}>\n <Prev\n button={buttonContainer}\n icon={iconContainer}\n onPress={onPrevCallback}\n />\n <Next\n button={buttonContainer}\n icon={iconContainer}\n onPress={onNextCallback}\n />\n </View>\n ) : null;\n contentContainer = <Content>{content}</Content>;\n doneElement = doneText ? (\n <Done button={buttonContainer} text={doneText} onPress={onDoneCallback} />\n ) : null;\n }\n\n const contextValue = useMemo(\n () => ({ theme, isPrevDisabled, isNextDisabled }),\n [theme, isPrevDisabled, isNextDisabled],\n );\n\n return (\n <ToolbarContext.Provider value={contextValue}>\n <KeyboardStickyView\n enabled={enabled}\n offset={offset}\n style={containerStyle}\n >\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {backgroundElement}\n {arrowsElement}\n {contentContainer}\n {doneElement}\n </View>\n </KeyboardStickyView>\n </ToolbarContext.Provider>\n );\n};\n\nconst styles = StyleSheet.create({\n sticky: {\n position: \"absolute\",\n left: 0,\n right: 0,\n bottom: 0,\n height: KEYBOARD_TOOLBAR_HEIGHT,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n },\n arrows: {\n flexDirection: \"row\",\n paddingLeft: 8,\n },\n floating: {\n alignSelf: \"center\",\n borderRadius: 20,\n overflow: \"hidden\",\n },\n});\n\nKeyboardToolbar.Background = Background;\nKeyboardToolbar.Content = Content;\nKeyboardToolbar.Prev = Prev;\nKeyboardToolbar.Next = Next;\nKeyboardToolbar.Done = Done;\nKeyboardToolbar.Group = RCTKeyboardToolbarGroupView;\n\nexport { colors as DefaultKeyboardToolbarTheme, KeyboardToolbarProps };\nexport default KeyboardToolbar;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC3D,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAE/C,SACEC,kBAAkB,EAClBC,2BAA2B,QACtB,gBAAgB;AACvB,SAASC,gBAAgB,QAAQ,aAAa;AAC9C,OAAOC,kBAAkB,MAAM,uBAAuB;AAEtD,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,UAAU,EAAEC,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAEC,IAAI,QAAQ,uBAAuB;AAC7E,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SACEC,eAAe,EACfC,4BAA4B,EAC5BC,uBAAuB,EACvBC,aAAa,EACbC,wBAAwB,QACnB,aAAa;AAKpB;AACA;AACA;AACA;AACA,MAAMC,eAOL,GAAGA,CAAC;EACHC,QAAQ;EACRC,OAAO;EACPC,KAAK,GAAGf,MAAM;EACdgB,QAAQ,GAAG,MAAM;EACjBC,MAAM;EACNC,IAAI;EACJC,UAAU,GAAG,IAAI;EACjBC,cAAc;EACdC,cAAc;EACdC,cAAc;EACdC,IAAI,GAAG,IAAI;EACXC,OAAO,GAAGjB,eAAe;EACzBkB,MAAM,EAAE;IAAEC,MAAM,GAAG,CAAC;IAAEC,MAAM,GAAG;EAAE,CAAC,GAAG,CAAC,CAAC;EACvCC,OAAO,GAAG,IAAI;EACdC,MAAM;EACN,GAAGC;AACL,CAAC,KAAK;EACJ,MAAMC,WAAW,GAAGnC,gBAAgB,CAAEoC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I;AAC3BS,eAAe,CAACgF,KAAK,GAAGjG,2BAA2B;AAEnD,SAASK,MAAM,IAAI6F,2BAA2B;AAC9C,eAAejF,eAAe","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type Arrow from \"./Arrow\";\nimport type Button from \"./Button\";\nimport type { KeyboardStickyViewProps } from \"../KeyboardStickyView\";\nimport type { ReactNode } from \"react\";\nimport type {\n ColorValue,\n GestureResponderEvent,\n ViewProps,\n} from \"react-native\";\n\ntype Theme = {\n /** Color for arrow when it's enabled */\n primary: ColorValue;\n /** Color for arrow when it's disabled */\n disabled: ColorValue;\n /** Keyboard toolbar background color */\n background: string;\n /** Color for ripple effect (on button touch) on Android */\n ripple: ColorValue;\n};\nexport type KeyboardToolbarTheme = {\n light: Theme;\n dark: Theme;\n};\ntype HexSymbol =\n | \"0\"\n | \"1\"\n | \"2\"\n | \"3\"\n | \"4\"\n | \"5\"\n | \"6\"\n | \"7\"\n | \"8\"\n | \"9\"\n | \"A\"\n | \"B\"\n | \"C\"\n | \"D\"\n | \"E\"\n | \"F\"\n | \"a\"\n | \"b\"\n | \"c\"\n | \"d\"\n | \"e\"\n | \"f\";\nexport type HEX = `${HexSymbol}${HexSymbol}`;\n\ntype SafeAreaInsets = {\n left: number;\n right: number;\n};\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n content?: React.JSX.Element | null;\n theme?: KeyboardToolbarTheme;\n doneText?: ReactNode;\n button?: typeof Button;\n icon?: typeof Arrow;\n showArrows?: boolean;\n onNextCallback?: (event: GestureResponderEvent) => void;\n onPrevCallback?: (event: GestureResponderEvent) => void;\n onDoneCallback?: (event: GestureResponderEvent) => void;\n blur?: React.JSX.Element | null;\n opacity?: HEX;\n insets?: SafeAreaInsets;\n children?: ReactNode;\n} & Pick<KeyboardStickyViewProps, \"offset\" | \"enabled\">;\n"],"mappings":"","ignoreList":[]}
|