react-native-keyboard-controller 1.17.4 → 1.18.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.md +4 -1
- package/android/src/base/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +6 -5
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardBackgroundViewManager.kt +19 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +4 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +3 -5
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +3 -5
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt +3 -5
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +3 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/Context.kt +20 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +2 -12
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardBackgroundViewManagerImpl.kt +13 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +2 -6
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +1 -5
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/OverKeyboardViewManagerImpl.kt +1 -5
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +4 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/{StatusBarManagerCompatModuleImpl.kt → statusbar/StatusBarManagerCompatModuleImpl.kt} +31 -5
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/statusbar/StatusBarModuleProxy.kt +86 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +9 -11
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/background/KeyboardBackgroundViewGroup.kt +35 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/background/Skins.kt +91 -0
- package/android/src/main/jni/reactnativekeyboardcontroller.h +1 -0
- package/android/src/main/res/values/attrs.xml +7 -0
- package/android/src/main/res/values/colors.xml +35 -0
- package/android/src/main/res/values-v29/colors.xml +5 -0
- package/android/src/main/res/values-v30/colors.xml +17 -0
- package/android/src/main/res/values-v33/colors.xml +16 -0
- package/android/src/main/res/values-v34/colors.xml +18 -0
- package/android/src/main/res/values-v35/colors.xml +10 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardBackgroundViewManager.kt +15 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +2 -5
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +2 -5
- package/android/src/paper/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt +2 -5
- package/android/src/paper/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +3 -1
- package/android/src/turbo/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +5 -5
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardBackgroundViewComponentDescriptor.h +27 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardBackgroundViewShadowNode.cpp +14 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardBackgroundViewShadowNode.h +30 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardBackgroundViewState.h +28 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardExtenderComponentDescriptor.h +27 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardExtenderShadowNode.cpp +14 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardExtenderShadowNode.h +30 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardExtenderState.h +28 -0
- package/ios/KeyboardControllerModule.mm +9 -0
- package/ios/delegates/KCTextInputCompositeDelegate.swift +5 -5
- package/ios/events/KeyboardEventEmitterPayload.swift +1 -1
- package/ios/extensions/String.swift +12 -0
- package/ios/extensions/UIResponder.swift +27 -0
- package/ios/interactive/KeyboardAreaExtender.swift +5 -5
- package/ios/observers/FocusedInputObserver.swift +14 -5
- package/ios/observers/KeyboardMovementObserver.swift +24 -9
- package/ios/protocols/TextInput.swift +22 -0
- package/ios/swizzling/UIResponderSwizzle.swift +3 -0
- package/ios/traversal/KeyboardView.swift +6 -3
- package/ios/views/KeyboardBackgroundViewManager.h +29 -0
- package/ios/views/KeyboardBackgroundViewManager.mm +168 -0
- package/ios/views/KeyboardExtenderContainerView.swift +59 -0
- package/ios/views/KeyboardExtenderManager.h +29 -0
- package/ios/views/KeyboardExtenderManager.mm +287 -0
- package/jest/index.js +6 -1
- package/lib/commonjs/animated.js +7 -10
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js +15 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +5 -1
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +49 -29
- package/lib/commonjs/components/KeyboardAwareScrollView/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/constants.js +17 -0
- package/lib/commonjs/components/KeyboardToolbar/constants.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js +25 -22
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/hooks/useKeyboardState/index.js +18 -8
- package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
- package/lib/commonjs/index.js +8 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/module.js +2 -1
- package/lib/commonjs/module.js.map +1 -1
- package/lib/commonjs/specs/KeyboardBackgroundViewNativeComponent.js +12 -0
- package/lib/commonjs/specs/KeyboardBackgroundViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/KeyboardExtenderNativeComponent.js +13 -0
- package/lib/commonjs/specs/KeyboardExtenderNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/types/module.js.map +1 -1
- package/lib/commonjs/types/views.js.map +1 -1
- package/lib/commonjs/views/KeyboardExtender/index.ios.js +43 -0
- package/lib/commonjs/views/KeyboardExtender/index.ios.js.map +1 -0
- package/lib/commonjs/views/KeyboardExtender/index.js +46 -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 +8 -11
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js +14 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +4 -0
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +50 -30
- package/lib/module/components/KeyboardAwareScrollView/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/constants.js +11 -0
- package/lib/module/components/KeyboardToolbar/constants.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/index.js +17 -14
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/hooks/useKeyboardState/index.js +18 -6
- package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/module.js +2 -1
- package/lib/module/module.js.map +1 -1
- package/lib/module/specs/KeyboardBackgroundViewNativeComponent.js +5 -0
- package/lib/module/specs/KeyboardBackgroundViewNativeComponent.js.map +1 -0
- package/lib/module/specs/KeyboardExtenderNativeComponent.js +6 -0
- package/lib/module/specs/KeyboardExtenderNativeComponent.js.map +1 -0
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/types/module.js.map +1 -1
- package/lib/module/types/views.js.map +1 -1
- package/lib/module/views/KeyboardExtender/index.ios.js +36 -0
- package/lib/module/views/KeyboardExtender/index.ios.js.map +1 -0
- package/lib/module/views/KeyboardExtender/index.js +39 -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 +7 -0
- package/lib/typescript/bindings.d.ts +14 -1
- package/lib/typescript/bindings.native.d.ts +3 -1
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +2 -2
- package/lib/typescript/components/KeyboardToolbar/constants.d.ts +10 -0
- package/lib/typescript/hooks/useKeyboardState/index.d.ts +8 -2
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/specs/KeyboardBackgroundViewNativeComponent.d.ts +6 -0
- package/lib/typescript/specs/KeyboardExtenderNativeComponent.d.ts +7 -0
- package/lib/typescript/specs/NativeKeyboardController.d.ts +1 -0
- package/lib/typescript/types/module.d.ts +15 -3
- package/lib/typescript/types/views.d.ts +5 -0
- package/lib/typescript/views/KeyboardExtender/index.d.ts +19 -0
- package/lib/typescript/views/KeyboardExtender/index.ios.d.ts +19 -0
- package/lib/typescript/views/index.d.ts +1 -0
- package/package.json +7 -3
- package/react-native.config.js +1 -0
- package/src/animated.tsx +14 -9
- package/src/bindings.native.ts +8 -0
- package/src/bindings.ts +18 -0
- package/src/components/KeyboardAwareScrollView/index.tsx +72 -47
- package/src/components/KeyboardToolbar/Arrow.tsx +2 -2
- package/src/components/KeyboardToolbar/Button.tsx +2 -2
- package/src/components/KeyboardToolbar/constants.ts +15 -0
- package/src/components/KeyboardToolbar/index.tsx +45 -17
- package/src/hooks/useKeyboardState/index.ts +25 -6
- package/src/index.ts +1 -1
- package/src/module.ts +2 -1
- package/src/specs/KeyboardBackgroundViewNativeComponent.ts +10 -0
- package/src/specs/KeyboardExtenderNativeComponent.ts +13 -0
- package/src/specs/NativeKeyboardController.ts +1 -0
- package/src/types/module.ts +17 -3
- package/src/types/views.ts +5 -0
- package/src/views/KeyboardExtender/index.ios.tsx +35 -0
- package/src/views/KeyboardExtender/index.tsx +42 -0
- package/src/views/index.ts +1 -0
- package/ios/extensions/UIKeyboardAppearance.swift +0 -21
- package/lib/commonjs/components/hooks/useColorScheme.js +0 -10
- package/lib/commonjs/components/hooks/useColorScheme.js.map +0 -1
- package/lib/commonjs/monkey-patch.android.js +0 -53
- 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/components/hooks/useColorScheme.js +0 -4
- package/lib/module/components/hooks/useColorScheme.js.map +0 -1
- package/lib/module/monkey-patch.android.js +0 -42
- 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/components/hooks/useColorScheme.d.ts +0 -2
- package/lib/typescript/monkey-patch.android.d.ts +0 -2
- package/lib/typescript/monkey-patch.d.ts +0 -2
- package/src/components/hooks/useColorScheme.ts +0 -5
- package/src/monkey-patch.android.ts +0 -41
- package/src/monkey-patch.ts +0 -5
package/lib/module/bindings.js
CHANGED
|
@@ -3,6 +3,7 @@ const NOOP = () => {};
|
|
|
3
3
|
export const KeyboardControllerNative = {
|
|
4
4
|
setDefaultMode: NOOP,
|
|
5
5
|
setInputMode: NOOP,
|
|
6
|
+
preload: NOOP,
|
|
6
7
|
dismiss: NOOP,
|
|
7
8
|
setFocusTo: NOOP,
|
|
8
9
|
addListener: NOOP,
|
|
@@ -49,4 +50,17 @@ export const KeyboardControllerView = View;
|
|
|
49
50
|
*/
|
|
50
51
|
export const KeyboardGestureArea = View;
|
|
51
52
|
export const RCTOverKeyboardView = View;
|
|
53
|
+
/**
|
|
54
|
+
* A view that matches keyboard background.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-background-view|Documentation} page for more details.
|
|
57
|
+
*/
|
|
58
|
+
export const KeyboardBackgroundView = View;
|
|
59
|
+
/**
|
|
60
|
+
* A container that will embed its children into the keyboard
|
|
61
|
+
* and will always show them above the keyboard.
|
|
62
|
+
*
|
|
63
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-extender|Documentation} page for more details.
|
|
64
|
+
*/
|
|
65
|
+
export const RCTKeyboardExtender = View;
|
|
52
66
|
//# sourceMappingURL=bindings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","NOOP","KeyboardControllerNative","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","RCTOverKeyboardView"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\nimport type { EmitterSubscription } from \"react-native\";\n\nconst NOOP = () => {};\n\nexport const KeyboardControllerNative: KeyboardControllerNativeModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n dismiss: NOOP,\n setFocusTo: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\n/**\n * An event emitter that provides a way to subscribe to next keyboard events:\n * - `keyboardWillShow`;\n * - `keyboardDidShow`;\n * - `keyboardWillHide`;\n * - `keyboardDidHide`.\n *\n * Use `addListener` function to add your event listener for a specific keyboard event.\n */\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * A view that sends events whenever keyboard or focused events are happening.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|Documentation} page for more details.\n */\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\n/**\n * A view that defines a region on the screen, where gestures will control the keyboard position.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-gesture-area|Documentation} page for more details.\n */\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\nexport const RCTOverKeyboardView =\n View as unknown as React.FC<OverKeyboardViewProps>;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["View","NOOP","KeyboardControllerNative","setDefaultMode","setInputMode","preload","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","RCTOverKeyboardView","KeyboardBackgroundView","RCTKeyboardExtender"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardBackgroundViewProps,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardExtenderProps,\n KeyboardGestureAreaProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\nimport type { EmitterSubscription } from \"react-native\";\n\nconst NOOP = () => {};\n\nexport const KeyboardControllerNative: KeyboardControllerNativeModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n preload: NOOP,\n dismiss: NOOP,\n setFocusTo: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\n/**\n * An event emitter that provides a way to subscribe to next keyboard events:\n * - `keyboardWillShow`;\n * - `keyboardDidShow`;\n * - `keyboardWillHide`;\n * - `keyboardDidHide`.\n *\n * Use `addListener` function to add your event listener for a specific keyboard event.\n */\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * A view that sends events whenever keyboard or focused events are happening.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|Documentation} page for more details.\n */\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\n/**\n * A view that defines a region on the screen, where gestures will control the keyboard position.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-gesture-area|Documentation} page for more details.\n */\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\nexport const RCTOverKeyboardView =\n View as unknown as React.FC<OverKeyboardViewProps>;\n/**\n * A view that matches keyboard background.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-background-view|Documentation} page for more details.\n */\nexport const KeyboardBackgroundView =\n View as unknown as React.FC<KeyboardBackgroundViewProps>;\n/**\n * A container that will embed its children into the keyboard\n * and will always show them above the keyboard.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-extender|Documentation} page for more details.\n */\nexport const RCTKeyboardExtender =\n View as unknown as React.FC<KeyboardExtenderProps>;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,cAAc;AAenC,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,OAAO,MAAMC,wBAAwD,GAAG;EACtEC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,OAAO,EAAEJ,IAAI;EACbK,OAAO,EAAEL,IAAI;EACbM,UAAU,EAAEN,IAAI;EAChBO,WAAW,EAAEP,IAAI;EACjBQ,eAAe,EAAER;AACnB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMS,cAAoC,GAAG;EAClDF,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACA,OAAO,MAAMW,kBAA4C,GAAG;EAC1DJ,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMY,sBAAoD,GAAG;EAClEL,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEV;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMa,sBAAsB,GACjCd,IAAoD;AACtD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMe,mBAAmB,GAC9Bf,IAAqD;AACvD,OAAO,MAAMgB,mBAAmB,GAC9BhB,IAAkD;AACpD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMiB,sBAAsB,GACjCjB,IAAwD;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMkB,mBAAmB,GAC9BlB,IAAkD","ignoreList":[]}
|
|
@@ -30,4 +30,8 @@ export const KeyboardGestureArea = Platform.OS === "android" && Platform.Version
|
|
|
30
30
|
children
|
|
31
31
|
}) => children;
|
|
32
32
|
export const RCTOverKeyboardView = require("./specs/OverKeyboardViewNativeComponent").default;
|
|
33
|
+
export const KeyboardBackgroundView = require("./specs/KeyboardBackgroundViewNativeComponent").default;
|
|
34
|
+
export const RCTKeyboardExtender = Platform.OS === "ios" ? require("./specs/KeyboardExtenderNativeComponent").default : ({
|
|
35
|
+
children
|
|
36
|
+
}) => children;
|
|
33
37
|
//# sourceMappingURL=bindings.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","RCTKeyboardController","require","KeyboardControllerNative","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","KeyboardEvents","addListener","name","cb","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","OS","Version","children","RCTOverKeyboardView"],"sources":["bindings.native.ts"],"sourcesContent":["import { NativeEventEmitter, Platform } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\n\nconst LINKING_ERROR =\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: \"\" }) +\n \"- You rebuilt the app after installing the package\\n\" +\n \"- You are not using Expo Go\\n\";\n\nconst RCTKeyboardController =\n require(\"./specs/NativeKeyboardController\").default;\n\nexport const KeyboardControllerNative = (\n RCTKeyboardController\n ? RCTKeyboardController\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n },\n )\n) as KeyboardControllerNativeModule;\n\nconst KEYBOARD_CONTROLLER_NAMESPACE = \"KeyboardController::\";\nconst eventEmitter = new NativeEventEmitter(KeyboardControllerNative);\n\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\n\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\nexport const KeyboardControllerView: React.FC<KeyboardControllerProps> =\n require(\"./specs/KeyboardControllerViewNativeComponent\").default;\nexport const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =\n (Platform.OS === \"android\" && Platform.Version >= 30) || Platform.OS === \"ios\"\n ? require(\"./specs/KeyboardGestureAreaNativeComponent\").default\n : ({ children }: KeyboardGestureAreaProps) => children;\nexport const RCTOverKeyboardView: React.FC<OverKeyboardViewProps> =\n require(\"./specs/OverKeyboardViewNativeComponent\").default;\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","RCTKeyboardController","require","KeyboardControllerNative","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","KeyboardEvents","addListener","name","cb","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","OS","Version","children","RCTOverKeyboardView","KeyboardBackgroundView","RCTKeyboardExtender"],"sources":["bindings.native.ts"],"sourcesContent":["import { NativeEventEmitter, Platform } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardBackgroundViewProps,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardExtenderProps,\n KeyboardGestureAreaProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\n\nconst LINKING_ERROR =\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: \"\" }) +\n \"- You rebuilt the app after installing the package\\n\" +\n \"- You are not using Expo Go\\n\";\n\nconst RCTKeyboardController =\n require(\"./specs/NativeKeyboardController\").default;\n\nexport const KeyboardControllerNative = (\n RCTKeyboardController\n ? RCTKeyboardController\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n },\n )\n) as KeyboardControllerNativeModule;\n\nconst KEYBOARD_CONTROLLER_NAMESPACE = \"KeyboardController::\";\nconst eventEmitter = new NativeEventEmitter(KeyboardControllerNative);\n\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\n\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\nexport const KeyboardControllerView: React.FC<KeyboardControllerProps> =\n require(\"./specs/KeyboardControllerViewNativeComponent\").default;\nexport const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =\n (Platform.OS === \"android\" && Platform.Version >= 30) || Platform.OS === \"ios\"\n ? require(\"./specs/KeyboardGestureAreaNativeComponent\").default\n : ({ children }: KeyboardGestureAreaProps) => children;\nexport const RCTOverKeyboardView: React.FC<OverKeyboardViewProps> =\n require(\"./specs/OverKeyboardViewNativeComponent\").default;\nexport const KeyboardBackgroundView: React.FC<KeyboardBackgroundViewProps> =\n require(\"./specs/KeyboardBackgroundViewNativeComponent\").default;\nexport const RCTKeyboardExtender: React.FC<KeyboardExtenderProps> =\n Platform.OS === \"ios\"\n ? require(\"./specs/KeyboardExtenderNativeComponent\").default\n : ({ children }: KeyboardExtenderProps) => children;\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAc3D,MAAMC,aAAa,GACjB,2FAA2F,GAC3FD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,qBAAqB,GACzBC,OAAO,CAAC,kCAAkC,CAAC,CAACF,OAAO;AAErD,OAAO,MAAMG,wBAAwB,GACnCF,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAC6B;AAEnC,MAAMU,6BAA6B,GAAG,sBAAsB;AAC5D,MAAMC,YAAY,GAAG,IAAIb,kBAAkB,CAACQ,wBAAwB,CAAC;AAErE,OAAO,MAAMM,cAAoC,GAAG;EAClDC,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBJ,YAAY,CAACE,WAAW,CAACH,6BAA6B,GAAGI,IAAI,EAAEC,EAAE;AACrE,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAA4C,GAAG;EAC1DH,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBJ,YAAY,CAACE,WAAW,CAACH,6BAA6B,GAAGI,IAAI,EAAEC,EAAE;AACrE,CAAC;AACD,OAAO,MAAME,sBAAoD,GAAG;EAClEJ,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBJ,YAAY,CAACE,WAAW,CAACH,6BAA6B,GAAGI,IAAI,EAAEC,EAAE;AACrE,CAAC;AACD,OAAO,MAAMG,sBAAyD,GACpEb,OAAO,CAAC,+CAA+C,CAAC,CAACF,OAAO;AAClE,OAAO,MAAMgB,mBAAuD,GACjEpB,QAAQ,CAACqB,EAAE,KAAK,SAAS,IAAIrB,QAAQ,CAACsB,OAAO,IAAI,EAAE,IAAKtB,QAAQ,CAACqB,EAAE,KAAK,KAAK,GAC1Ef,OAAO,CAAC,4CAA4C,CAAC,CAACF,OAAO,GAC7D,CAAC;EAAEmB;AAAmC,CAAC,KAAKA,QAAQ;AAC1D,OAAO,MAAMC,mBAAoD,GAC/DlB,OAAO,CAAC,yCAAyC,CAAC,CAACF,OAAO;AAC5D,OAAO,MAAMqB,sBAA6D,GACxEnB,OAAO,CAAC,+CAA+C,CAAC,CAACF,OAAO;AAClE,OAAO,MAAMsB,mBAAoD,GAC/D1B,QAAQ,CAACqB,EAAE,KAAK,KAAK,GACjBf,OAAO,CAAC,yCAAyC,CAAC,CAACF,OAAO,GAC1D,CAAC;EAAEmB;AAAgC,CAAC,KAAKA,QAAQ","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
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
2
|
import React, { forwardRef, useCallback, useEffect, useMemo } from "react";
|
|
3
|
-
import Reanimated, { interpolate, runOnUI, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedStyle, useScrollViewOffset, useSharedValue } from "react-native-reanimated";
|
|
3
|
+
import Reanimated, { clamp, interpolate, runOnUI, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedStyle, useScrollViewOffset, useSharedValue } from "react-native-reanimated";
|
|
4
4
|
import { useFocusedInputHandler, useReanimatedFocusedInput, useWindowDimensions } from "../../hooks";
|
|
5
5
|
import { findNodeHandle } from "../../utils/findNodeHandle";
|
|
6
6
|
import { useSmoothKeyboardHandler } from "./useSmoothKeyboardHandler";
|
|
@@ -83,6 +83,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
|
|
|
83
83
|
input
|
|
84
84
|
} = useReanimatedFocusedInput();
|
|
85
85
|
const layout = useSharedValue(null);
|
|
86
|
+
const lastSelection = useSharedValue(null);
|
|
86
87
|
const {
|
|
87
88
|
height
|
|
88
89
|
} = useWindowDimensions();
|
|
@@ -125,9 +126,9 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
|
|
|
125
126
|
scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);
|
|
126
127
|
return interpolatedScrollTo;
|
|
127
128
|
}
|
|
128
|
-
if (
|
|
129
|
-
const positionOnScreen = visibleRect -
|
|
130
|
-
const topOfScreen = scrollPosition.value +
|
|
129
|
+
if (point < 0) {
|
|
130
|
+
const positionOnScreen = visibleRect - bottomOffset;
|
|
131
|
+
const topOfScreen = scrollPosition.value + point;
|
|
131
132
|
scrollTo(scrollViewAnimatedRef, 0, topOfScreen - positionOnScreen, animated);
|
|
132
133
|
}
|
|
133
134
|
return 0;
|
|
@@ -138,24 +139,35 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
|
|
|
138
139
|
const keyboardFrame = interpolate(e.height, [0, keyboardHeight.value], [0, keyboardHeight.value + extraKeyboardSpace]);
|
|
139
140
|
currentKeyboardFrameHeight.value = keyboardFrame;
|
|
140
141
|
}, [extraKeyboardSpace]);
|
|
141
|
-
const
|
|
142
|
+
const updateLayoutFromSelection = useCallback(() => {
|
|
142
143
|
"worklet";
|
|
143
144
|
|
|
144
|
-
var _input$value;
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return;
|
|
145
|
+
var _lastSelection$value, _input$value;
|
|
146
|
+
const customHeight = (_lastSelection$value = lastSelection.value) === null || _lastSelection$value === void 0 ? void 0 : _lastSelection$value.selection.end.y;
|
|
147
|
+
if (!((_input$value = input.value) !== null && _input$value !== void 0 && _input$value.layout) || !customHeight) {
|
|
148
|
+
return false;
|
|
149
149
|
}
|
|
150
|
-
|
|
151
|
-
// eslint-disable-next-line react-compiler/react-compiler
|
|
152
150
|
layout.value = {
|
|
153
151
|
...input.value,
|
|
154
152
|
layout: {
|
|
155
153
|
...input.value.layout,
|
|
156
|
-
|
|
154
|
+
// when we have multiline input with limited amount of lines, then custom height can be very big
|
|
155
|
+
// so we clamp it to max input height
|
|
156
|
+
height: clamp(customHeight, 0, input.value.layout.height)
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
|
+
return true;
|
|
160
|
+
}, [input, lastSelection, layout]);
|
|
161
|
+
const scrollFromCurrentPosition = useCallback(() => {
|
|
162
|
+
"worklet";
|
|
163
|
+
|
|
164
|
+
const prevScrollPosition = scrollPosition.value;
|
|
165
|
+
const prevLayout = layout.value;
|
|
166
|
+
if (!updateLayoutFromSelection()) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
159
171
|
scrollPosition.value = position.value;
|
|
160
172
|
maybeScroll(keyboardHeight.value, true);
|
|
161
173
|
scrollPosition.value = prevScrollPosition;
|
|
@@ -164,26 +176,35 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
|
|
|
164
176
|
const onChangeText = useCallback(() => {
|
|
165
177
|
"worklet";
|
|
166
178
|
|
|
167
|
-
|
|
168
|
-
// because this event will be handled in `useAnimatedReaction` below
|
|
169
|
-
var _layout$value4, _input$value2;
|
|
170
|
-
if (((_layout$value4 = layout.value) === null || _layout$value4 === void 0 ? void 0 : _layout$value4.layout.height) !== ((_input$value2 = input.value) === null || _input$value2 === void 0 ? void 0 : _input$value2.layout.height)) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
179
|
+
console.debug("maybeScroll - onChangeText");
|
|
173
180
|
scrollFromCurrentPosition();
|
|
174
181
|
}, [scrollFromCurrentPosition]);
|
|
182
|
+
const onChangeTextHandler = useMemo(() => debounce(onChangeText, 200), [onChangeText]);
|
|
175
183
|
const onSelectionChange = useCallback(e => {
|
|
176
184
|
"worklet";
|
|
177
185
|
|
|
186
|
+
var _lastSelection$value2, _lastSelection$value3;
|
|
187
|
+
const lastTarget = (_lastSelection$value2 = lastSelection.value) === null || _lastSelection$value2 === void 0 ? void 0 : _lastSelection$value2.target;
|
|
188
|
+
const latestSelection = (_lastSelection$value3 = lastSelection.value) === null || _lastSelection$value3 === void 0 ? void 0 : _lastSelection$value3.selection;
|
|
189
|
+
lastSelection.value = e;
|
|
190
|
+
if (e.target !== lastTarget) {
|
|
191
|
+
// ignore this event, because "focus changed" event handled in `useSmoothKeyboardHandler`
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
// caret in the end + end coordinates has been changed -> we moved to a new line
|
|
195
|
+
// so input may grow
|
|
196
|
+
if (e.selection.end.position === e.selection.start.position && (latestSelection === null || latestSelection === void 0 ? void 0 : latestSelection.end.y) !== e.selection.end.y) {
|
|
197
|
+
return scrollFromCurrentPosition();
|
|
198
|
+
}
|
|
199
|
+
// selection has been changed
|
|
178
200
|
if (e.selection.start.position !== e.selection.end.position) {
|
|
179
|
-
scrollFromCurrentPosition(
|
|
201
|
+
return scrollFromCurrentPosition();
|
|
180
202
|
}
|
|
181
|
-
|
|
182
|
-
|
|
203
|
+
onChangeTextHandler();
|
|
204
|
+
}, [scrollFromCurrentPosition, onChangeTextHandler]);
|
|
183
205
|
useFocusedInputHandler({
|
|
184
|
-
onChangeText: onChangeTextHandler,
|
|
185
206
|
onSelectionChange: onSelectionChange
|
|
186
|
-
}, [
|
|
207
|
+
}, [onSelectionChange]);
|
|
187
208
|
useSmoothKeyboardHandler({
|
|
188
209
|
onStart: e => {
|
|
189
210
|
"worklet";
|
|
@@ -210,9 +231,8 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
|
|
|
210
231
|
// focus was changed
|
|
211
232
|
if (focusWasChanged) {
|
|
212
233
|
tag.value = e.target;
|
|
213
|
-
|
|
214
234
|
// save position of focused text input when keyboard starts to move
|
|
215
|
-
|
|
235
|
+
updateLayoutFromSelection();
|
|
216
236
|
// save current scroll position - when keyboard will hide we'll reuse
|
|
217
237
|
// this value to achieve smooth hide effect
|
|
218
238
|
scrollBeforeKeyboardMovement.value = position.value;
|
|
@@ -246,10 +266,10 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
|
|
|
246
266
|
}, [bottomOffset]);
|
|
247
267
|
useAnimatedReaction(() => input.value, (current, previous) => {
|
|
248
268
|
if ((current === null || current === void 0 ? void 0 : current.target) === (previous === null || previous === void 0 ? void 0 : previous.target) && (current === null || current === void 0 ? void 0 : current.layout.height) !== (previous === null || previous === void 0 ? void 0 : previous.layout.height)) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
269
|
+
// input has changed layout - let's check if we need to scroll
|
|
270
|
+
// may happen when you paste text, then onSelectionChange will be
|
|
271
|
+
// fired earlier than text actually changes its layout
|
|
272
|
+
scrollFromCurrentPosition();
|
|
253
273
|
}
|
|
254
274
|
}, []);
|
|
255
275
|
const view = useAnimatedStyle(() => enabled ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","forwardRef","useCallback","useEffect","useMemo","Reanimated","interpolate","runOnUI","scrollTo","useAnimatedReaction","useAnimatedRef","useAnimatedStyle","useScrollViewOffset","useSharedValue","useFocusedInputHandler","useReanimatedFocusedInput","useWindowDimensions","findNodeHandle","useSmoothKeyboardHandler","debounce","scrollDistanceWithRespectToSnapPoints","KeyboardAwareScrollView","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","ScrollView","snapToOffsets","rest","ref","scrollViewAnimatedRef","scrollViewTarget","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","layout","height","onRef","assignedRef","current","onScrollViewLayout","e","value","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","targetScrollY","Math","max","positionOnScreen","topOfScreen","syncKeyboardFrame","keyboardFrame","scrollFromCurrentPosition","customHeight","_input$value","prevScrollPosition","prevLayout","onChangeText","_layout$value4","_input$value2","onSelectionChange","selection","start","end","y","onChangeTextHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","target","onMove","onEnd","previous","view","paddingBottom","createElement","_extends","scrollEventThrottle","View","style"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useMemo } from \"react\";\nimport Reanimated, {\n interpolate,\n runOnUI,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedStyle,\n useScrollViewOffset,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n useWindowDimensions,\n} from \"../../hooks\";\nimport { findNodeHandle } from \"../../utils/findNodeHandle\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce, scrollDistanceWithRespectToSnapPoints } from \"./utils\";\n\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type {\n FocusedInputLayoutChangedEvent,\n FocusedInputSelectionChangedEvent,\n NativeEvent,\n} from \"react-native-keyboard-controller\";\n\nexport type KeyboardAwareScrollViewProps = {\n /** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */\n bottomOffset?: number;\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\n disableScrollOnKeyboardHide?: boolean;\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true`. */\n enabled?: boolean;\n /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0`. */\n extraKeyboardSpace?: number;\n /** Custom component for `ScrollView`. Default is `ScrollView`. */\n ScrollViewComponent?: React.ComponentType<ScrollViewProps>;\n} & ScrollViewProps;\n\n// Everything begins from `onStart` handler. This handler is called every time,\n// when keyboard changes its size or when focused `TextInput` was changed. In\n// this handler we are calculating/memoizing values which later will be used\n// during layout movement. For that we calculate:\n// - layout of focused field (`layout`) - to understand whether there will be overlap\n// - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n// - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n// - current scroll position (`scrollPosition`) - used to scroll from this point\n//\n// Once we've calculated all necessary variables - we can actually start to use them.\n// It happens in `onMove` handler - this function simply calls `maybeScroll` with\n// current keyboard frame height. This functions makes the smooth transition.\n//\n// When the transition has finished we go to `onEnd` handler. In this handler\n// we verify, that the current field is not overlapped within a keyboard frame.\n// For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n// however there could be some cases, when `onMove` is not called:\n// - on iOS when TextInput was changed - keyboard transition is instant\n// - on Android when TextInput was changed and keyboard size wasn't changed\n// So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n//\n// ====================================================================================================================+\n// -----------------------------------------------------Flow chart-----------------------------------------------------+\n// ====================================================================================================================+\n//\n// +============================+ +============================+ +==================================+\n// + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n// + + + (run `onStart`) + + `onMove` is getting called +\n// +============================+ +============================+ +==================================+\n//\n// +============================+ +============================+ +=====================================+\n// + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n// + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n// +============================+ +============================+ +=====================================+\n//\n\n/**\n * A ScrollView component that automatically handles keyboard appearance and disappearance\n * by adjusting its content position to ensure the focused input remains visible.\n *\n * The component uses a sophisticated animation system to smoothly handle keyboard transitions\n * and maintain proper scroll position during keyboard interactions.\n *\n * @returns A ScrollView component that handles keyboard interactions.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-aware-scroll-view|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardAwareScrollView bottomOffset={20}>\n * <TextInput placeholder=\"Enter text\" />\n * <TextInput placeholder=\"Another input\" />\n * </KeyboardAwareScrollView>\n * ```\n */\nconst KeyboardAwareScrollView = forwardRef<\n ScrollView,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n extraKeyboardSpace = 0,\n ScrollViewComponent = Reanimated.ScrollView,\n snapToOffsets,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const position = useScrollViewOffset(scrollViewAnimatedRef);\n const currentKeyboardFrameHeight = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const keyboardWillAppear = useSharedValue(false);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\n if (typeof ref === \"function\") {\n ref(assignedRef);\n } else if (ref) {\n ref.current = assignedRef;\n }\n\n scrollViewAnimatedRef(assignedRef);\n }, []);\n const onScrollViewLayout = useCallback(\n (e: LayoutChangeEvent) => {\n scrollViewTarget.value = findNodeHandle(scrollViewAnimatedRef.current);\n\n onLayout?.(e);\n },\n [onLayout],\n );\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving.\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n \"worklet\";\n\n if (!enabled) {\n return 0;\n }\n\n // input belongs to ScrollView\n if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {\n return 0;\n }\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const relativeScrollTo =\n keyboardHeight.value - (height - point) + bottomOffset;\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [\n 0,\n scrollDistanceWithRespectToSnapPoints(\n relativeScrollTo + scrollPosition.value,\n snapToOffsets,\n ) - scrollPosition.value,\n ],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (absoluteY < 0) {\n const positionOnScreen = visibleRect - inputHeight - bottomOffset;\n const topOfScreen = scrollPosition.value + absoluteY;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled, height, snapToOffsets],\n );\n const syncKeyboardFrame = useCallback(\n (e: NativeEvent) => {\n \"worklet\";\n\n const keyboardFrame = interpolate(\n e.height,\n [0, keyboardHeight.value],\n [0, keyboardHeight.value + extraKeyboardSpace],\n );\n\n currentKeyboardFrameHeight.value = keyboardFrame;\n },\n [extraKeyboardSpace],\n );\n\n const scrollFromCurrentPosition = useCallback(\n (customHeight?: number) => {\n \"worklet\";\n\n const prevScrollPosition = scrollPosition.value;\n const prevLayout = layout.value;\n\n if (!input.value?.layout) {\n return;\n }\n\n // eslint-disable-next-line react-compiler/react-compiler\n layout.value = {\n ...input.value,\n layout: {\n ...input.value.layout,\n height: customHeight ?? input.value.layout.height,\n },\n };\n scrollPosition.value = position.value;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScrollPosition;\n layout.value = prevLayout;\n },\n [maybeScroll],\n );\n const onChangeText = useCallback(() => {\n \"worklet\";\n\n // if typing a text caused layout shift, then we need to ignore this handler\n // because this event will be handled in `useAnimatedReaction` below\n if (layout.value?.layout.height !== input.value?.layout.height) {\n return;\n }\n\n scrollFromCurrentPosition();\n }, [scrollFromCurrentPosition]);\n const onSelectionChange = useCallback(\n (e: FocusedInputSelectionChangedEvent) => {\n \"worklet\";\n\n if (e.selection.start.position !== e.selection.end.position) {\n scrollFromCurrentPosition(e.selection.end.y);\n }\n },\n [scrollFromCurrentPosition],\n );\n\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n\n useFocusedInputHandler(\n {\n onChangeText: onChangeTextHandler,\n onSelectionChange: onSelectionChange,\n },\n [onChangeTextHandler, onSelectionChange],\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\n\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) ||\n keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n }\n\n if (\n keyboardWillAppear.value ||\n keyboardWillChangeSize ||\n focusWasChanged\n ) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n\n // save position of focused text input when keyboard starts to move\n layout.value = input.value;\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && !keyboardWillAppear.value) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n syncKeyboardFrame(e);\n\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\n if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\n maybeScroll(e.height);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n\n syncKeyboardFrame(e);\n },\n },\n [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame],\n );\n\n useEffect(() => {\n runOnUI(maybeScroll)(keyboardHeight.value, true);\n }, [bottomOffset]);\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n const prevLayout = layout.value;\n\n layout.value = input.value;\n scrollPosition.value += maybeScroll(keyboardHeight.value, true);\n layout.value = prevLayout;\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () =>\n enabled\n ? {\n // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\n // re-calculation on every animation frame and it helps to achieve smooth animation.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n paddingBottom: currentKeyboardFrameHeight.value + 1,\n }\n : {},\n [enabled],\n );\n\n return (\n <ScrollViewComponent\n ref={onRef}\n {...rest}\n scrollEventThrottle={16}\n onLayout={onScrollViewLayout}\n >\n {children}\n {enabled && <Reanimated.View style={view} />}\n </ScrollViewComponent>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAC1E,OAAOC,UAAU,IACfC,WAAW,EACXC,OAAO,EACPC,QAAQ,EACRC,mBAAmB,EACnBC,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Ec;EAAM,GACPf,IAAI;IACRkE,mBAAmB,EAAE,EAAG;IACxB1E,QAAQ,EAAE0B;EAAmB,IAE5B3B,QAAQ,EACRI,OAAO,iBAAI1B,KAAA,CAAA+F,aAAA,CAAC1F,UAAU,CAAC6F,IAAI;IAACC,KAAK,EAAEN;EAAK,CAAE,CACxB,CAAC;AAE1B,CACF,CAAC;AAED,eAAexE,uBAAuB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useCallback","useEffect","useMemo","Reanimated","clamp","interpolate","runOnUI","scrollTo","useAnimatedReaction","useAnimatedRef","useAnimatedStyle","useScrollViewOffset","useSharedValue","useFocusedInputHandler","useReanimatedFocusedInput","useWindowDimensions","findNodeHandle","useSmoothKeyboardHandler","debounce","scrollDistanceWithRespectToSnapPoints","KeyboardAwareScrollView","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","ScrollView","snapToOffsets","rest","ref","scrollViewAnimatedRef","scrollViewTarget","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","layout","lastSelection","height","onRef","assignedRef","current","onScrollViewLayout","e","value","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","targetScrollY","Math","max","positionOnScreen","topOfScreen","syncKeyboardFrame","keyboardFrame","updateLayoutFromSelection","_lastSelection$value","_input$value","customHeight","selection","end","y","scrollFromCurrentPosition","prevScrollPosition","prevLayout","onChangeText","console","debug","onChangeTextHandler","onSelectionChange","_lastSelection$value2","_lastSelection$value3","lastTarget","target","latestSelection","start","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","onMove","onEnd","previous","view","paddingBottom","createElement","_extends","scrollEventThrottle","View","style"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useMemo } from \"react\";\nimport Reanimated, {\n clamp,\n interpolate,\n runOnUI,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedStyle,\n useScrollViewOffset,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n useWindowDimensions,\n} from \"../../hooks\";\nimport { findNodeHandle } from \"../../utils/findNodeHandle\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce, scrollDistanceWithRespectToSnapPoints } from \"./utils\";\n\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type {\n FocusedInputLayoutChangedEvent,\n FocusedInputSelectionChangedEvent,\n NativeEvent,\n} from \"react-native-keyboard-controller\";\n\nexport type KeyboardAwareScrollViewProps = {\n /** The distance between the keyboard and the caret inside a focused `TextInput` when the keyboard is shown. Default is `0`. */\n bottomOffset?: number;\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\n disableScrollOnKeyboardHide?: boolean;\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true`. */\n enabled?: boolean;\n /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0`. */\n extraKeyboardSpace?: number;\n /** Custom component for `ScrollView`. Default is `ScrollView`. */\n ScrollViewComponent?: React.ComponentType<ScrollViewProps>;\n} & ScrollViewProps;\n\n// Everything begins from `onStart` handler. This handler is called every time,\n// when keyboard changes its size or when focused `TextInput` was changed. In\n// this handler we are calculating/memoizing values which later will be used\n// during layout movement. For that we calculate:\n// - layout of focused field (`layout`) - to understand whether there will be overlap\n// - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n// - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n// - current scroll position (`scrollPosition`) - used to scroll from this point\n//\n// Once we've calculated all necessary variables - we can actually start to use them.\n// It happens in `onMove` handler - this function simply calls `maybeScroll` with\n// current keyboard frame height. This functions makes the smooth transition.\n//\n// When the transition has finished we go to `onEnd` handler. In this handler\n// we verify, that the current field is not overlapped within a keyboard frame.\n// For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n// however there could be some cases, when `onMove` is not called:\n// - on iOS when TextInput was changed - keyboard transition is instant\n// - on Android when TextInput was changed and keyboard size wasn't changed\n// So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n//\n// ====================================================================================================================+\n// -----------------------------------------------------Flow chart-----------------------------------------------------+\n// ====================================================================================================================+\n//\n// +============================+ +============================+ +==================================+\n// + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n// + + + (run `onStart`) + + `onMove` is getting called +\n// +============================+ +============================+ +==================================+\n//\n// +============================+ +============================+ +=====================================+\n// + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n// + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n// +============================+ +============================+ +=====================================+\n//\n\n/**\n * A ScrollView component that automatically handles keyboard appearance and disappearance\n * by adjusting its content position to ensure the focused input remains visible.\n *\n * The component uses a sophisticated animation system to smoothly handle keyboard transitions\n * and maintain proper scroll position during keyboard interactions.\n *\n * @returns A ScrollView component that handles keyboard interactions.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-aware-scroll-view|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardAwareScrollView bottomOffset={20}>\n * <TextInput placeholder=\"Enter text\" />\n * <TextInput placeholder=\"Another input\" />\n * </KeyboardAwareScrollView>\n * ```\n */\nconst KeyboardAwareScrollView = forwardRef<\n ScrollView,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n extraKeyboardSpace = 0,\n ScrollViewComponent = Reanimated.ScrollView,\n snapToOffsets,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const position = useScrollViewOffset(scrollViewAnimatedRef);\n const currentKeyboardFrameHeight = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const keyboardWillAppear = useSharedValue(false);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const lastSelection =\n useSharedValue<FocusedInputSelectionChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\n if (typeof ref === \"function\") {\n ref(assignedRef);\n } else if (ref) {\n ref.current = assignedRef;\n }\n\n scrollViewAnimatedRef(assignedRef);\n }, []);\n const onScrollViewLayout = useCallback(\n (e: LayoutChangeEvent) => {\n scrollViewTarget.value = findNodeHandle(scrollViewAnimatedRef.current);\n\n onLayout?.(e);\n },\n [onLayout],\n );\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving.\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n \"worklet\";\n\n if (!enabled) {\n return 0;\n }\n\n // input belongs to ScrollView\n if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {\n return 0;\n }\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const relativeScrollTo =\n keyboardHeight.value - (height - point) + bottomOffset;\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [\n 0,\n scrollDistanceWithRespectToSnapPoints(\n relativeScrollTo + scrollPosition.value,\n snapToOffsets,\n ) - scrollPosition.value,\n ],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (point < 0) {\n const positionOnScreen = visibleRect - bottomOffset;\n const topOfScreen = scrollPosition.value + point;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled, height, snapToOffsets],\n );\n const syncKeyboardFrame = useCallback(\n (e: NativeEvent) => {\n \"worklet\";\n\n const keyboardFrame = interpolate(\n e.height,\n [0, keyboardHeight.value],\n [0, keyboardHeight.value + extraKeyboardSpace],\n );\n\n currentKeyboardFrameHeight.value = keyboardFrame;\n },\n [extraKeyboardSpace],\n );\n\n const updateLayoutFromSelection = useCallback(() => {\n \"worklet\";\n\n const customHeight = lastSelection.value?.selection.end.y;\n\n if (!input.value?.layout || !customHeight) {\n return false;\n }\n\n layout.value = {\n ...input.value,\n layout: {\n ...input.value.layout,\n // when we have multiline input with limited amount of lines, then custom height can be very big\n // so we clamp it to max input height\n height: clamp(customHeight, 0, input.value.layout.height),\n },\n };\n\n return true;\n }, [input, lastSelection, layout]);\n const scrollFromCurrentPosition = useCallback(() => {\n \"worklet\";\n\n const prevScrollPosition = scrollPosition.value;\n const prevLayout = layout.value;\n\n if (!updateLayoutFromSelection()) {\n return;\n }\n\n // eslint-disable-next-line react-compiler/react-compiler\n scrollPosition.value = position.value;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScrollPosition;\n layout.value = prevLayout;\n }, [maybeScroll]);\n const onChangeText = useCallback(() => {\n \"worklet\";\n\n console.debug(\"maybeScroll - onChangeText\");\n scrollFromCurrentPosition();\n }, [scrollFromCurrentPosition]);\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n const onSelectionChange = useCallback(\n (e: FocusedInputSelectionChangedEvent) => {\n \"worklet\";\n\n const lastTarget = lastSelection.value?.target;\n const latestSelection = lastSelection.value?.selection;\n\n lastSelection.value = e;\n\n if (e.target !== lastTarget) {\n // ignore this event, because \"focus changed\" event handled in `useSmoothKeyboardHandler`\n return;\n }\n // caret in the end + end coordinates has been changed -> we moved to a new line\n // so input may grow\n if (\n e.selection.end.position === e.selection.start.position &&\n latestSelection?.end.y !== e.selection.end.y\n ) {\n return scrollFromCurrentPosition();\n }\n // selection has been changed\n if (e.selection.start.position !== e.selection.end.position) {\n return scrollFromCurrentPosition();\n }\n\n onChangeTextHandler();\n },\n [scrollFromCurrentPosition, onChangeTextHandler],\n );\n\n useFocusedInputHandler(\n {\n onSelectionChange: onSelectionChange,\n },\n [onSelectionChange],\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\n\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) ||\n keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n }\n\n if (\n keyboardWillAppear.value ||\n keyboardWillChangeSize ||\n focusWasChanged\n ) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n // save position of focused text input when keyboard starts to move\n updateLayoutFromSelection();\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && !keyboardWillAppear.value) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n syncKeyboardFrame(e);\n\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\n if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\n maybeScroll(e.height);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n\n syncKeyboardFrame(e);\n },\n },\n [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame],\n );\n\n useEffect(() => {\n runOnUI(maybeScroll)(keyboardHeight.value, true);\n }, [bottomOffset]);\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n // input has changed layout - let's check if we need to scroll\n // may happen when you paste text, then onSelectionChange will be\n // fired earlier than text actually changes its layout\n scrollFromCurrentPosition();\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () =>\n enabled\n ? {\n // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\n // re-calculation on every animation frame and it helps to achieve smooth animation.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n paddingBottom: currentKeyboardFrameHeight.value + 1,\n }\n : {},\n [enabled],\n );\n\n return (\n <ScrollViewComponent\n ref={onRef}\n {...rest}\n scrollEventThrottle={16}\n onLayout={onScrollViewLayout}\n >\n {children}\n {enabled && <Reanimated.View style={view} />}\n </ScrollViewComponent>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAC1E,OAAOC,UAAU,IACfC,KAAK,EACLC,WAAW,EACXC,OAAO,EACPC,QAAQ,EACRC,mBAAmB,EACnBC,cAAc,EACdC,gBAAgB,EAChBC,mBAAmB,EACn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AK;IACrB,IACE,CAAAlD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEyC,MAAM,OAAKS,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAET,MAAM,KACpC,CAAAzC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEL,MAAM,CAACE,MAAM,OAAKqD,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEvD,MAAM,CAACE,MAAM,GAClD;MACA;MACA;MACA;MACAiC,yBAAyB,CAAC,CAAC;IAC7B;EACF,CAAC,EACD,EACF,CAAC;EAED,MAAMqB,IAAI,GAAGzF,gBAAgB,CAC3B,MACEe,OAAO,GACH;IACE;IACA;IACA;IACA;IACA;IACA;IACA2E,aAAa,EAAEhE,0BAA0B,CAACe,KAAK,GAAG;EACpD,CAAC,GACD,CAAC,CAAC,EACR,CAAC1B,OAAO,CACV,CAAC;EAED,oBACE3B,KAAA,CAAAuG,aAAA,CAAC1E,mBAAmB,EAAA2E,QAAA;IAClBvE,GAAG,EAAEe;EAAM,GACPhB,IAAI;IACRyE,mBAAmB,EAAE,EAAG;IACxBjF,QAAQ,EAAE2B;EAAmB,IAE5B5B,QAAQ,EACRI,OAAO,iBAAI3B,KAAA,CAAAuG,aAAA,CAAClG,UAAU,CAACqG,IAAI;IAACC,KAAK,EAAEN;EAAK,CAAE,CACxB,CAAC;AAE1B,CACF,CAAC;AAED,eAAe/E,uBAAuB","ignoreList":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
import { Animated, StyleSheet, View } from "react-native";
|
|
3
|
-
import
|
|
3
|
+
import { useKeyboardState } from "../../hooks";
|
|
4
4
|
const ArrowComponent = ({
|
|
5
5
|
type,
|
|
6
6
|
disabled,
|
|
7
7
|
theme
|
|
8
8
|
}) => {
|
|
9
|
-
const colorScheme =
|
|
9
|
+
const colorScheme = useKeyboardState(state => state.appearance);
|
|
10
10
|
const color = useMemo(() => ({
|
|
11
11
|
backgroundColor: disabled ? theme[colorScheme].disabled : theme[colorScheme].primary
|
|
12
12
|
}), [disabled, theme, colorScheme]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","Animated","StyleSheet","View","
|
|
1
|
+
{"version":3,"names":["React","useMemo","Animated","StyleSheet","View","useKeyboardState","ArrowComponent","type","disabled","theme","colorScheme","state","appearance","color","backgroundColor","primary","left","styles","arrowLeftLine","right","arrowRightLine","createElement","style","arrowDownContainer","arrowUpContainer","arrow","arrowLine","width","height","borderRadius","marginHorizontal","justifyContent","alignItems","create","transform","rotate","flexDirection"],"sources":["Arrow.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Animated, StyleSheet, View } from \"react-native\";\n\nimport { useKeyboardState } from \"../../hooks\";\n\nimport type { KeyboardToolbarTheme } from \"./types\";\nimport type { ViewStyle } from \"react-native\";\n\ntype ArrowProps = {\n type: \"prev\" | \"next\";\n disabled?: boolean;\n theme: KeyboardToolbarTheme;\n};\n\nconst ArrowComponent: React.FC<ArrowProps> = ({ type, disabled, theme }) => {\n const colorScheme = useKeyboardState((state) => state.appearance);\n\n const color = useMemo(\n () => ({\n backgroundColor: disabled\n ? theme[colorScheme].disabled\n : theme[colorScheme].primary,\n }),\n [disabled, theme, colorScheme],\n );\n const left = useMemo(() => [styles.arrowLeftLine, color], [color]);\n const right = useMemo(() => [styles.arrowRightLine, color], [color]);\n\n return (\n <View\n style={\n type === \"next\" ? styles.arrowDownContainer : styles.arrowUpContainer\n }\n >\n <View style={styles.arrow}>\n <Animated.View style={left} />\n <Animated.View style={right} />\n </View>\n </View>\n );\n};\n\nconst arrowLine: ViewStyle = {\n width: 13,\n height: 2,\n borderRadius: 1,\n};\nconst arrowUpContainer: ViewStyle = {\n marginHorizontal: 5,\n width: 30,\n height: 30,\n justifyContent: \"center\",\n alignItems: \"center\",\n};\nconst styles = StyleSheet.create({\n arrowUpContainer: arrowUpContainer,\n arrowDownContainer: {\n ...arrowUpContainer,\n transform: [{ rotate: \"180deg\" }],\n },\n arrow: {\n width: 20,\n height: 20,\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n },\n arrowLeftLine: {\n ...arrowLine,\n transform: [{ rotate: \"-45deg\" }],\n left: -0.5,\n },\n arrowRightLine: {\n ...arrowLine,\n transform: [{ rotate: \"45deg\" }],\n left: -5.5,\n },\n});\n\nexport default ArrowComponent;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAEzD,SAASC,gBAAgB,QAAQ,aAAa;AAW9C,MAAMC,cAAoC,GAAGA,CAAC;EAAEC,IAAI;EAAEC,QAAQ;EAAEC;AAAM,CAAC,KAAK;EAC1E,MAAMC,WAAW,GAAGL,gBAAgB,CAAEM,KAAK,IAAKA,KAAK,CAACC,UAAU,CAAC;EAEjE,MAAMC,KAAK,GAAGZ,OAAO,CACnB,OAAO;IACLa,eAAe,EAAEN,QAAQ,GACrBC,KAAK,CAACC,WAAW,CAAC,CAACF,QAAQ,GAC3BC,KAAK,CAACC,WAAW,CAAC,CAACK;EACzB,CAAC,CAAC,EACF,CAACP,QAAQ,EAAEC,KAAK,EAAEC,WAAW,CAC/B,CAAC;EACD,MAAMM,IAAI,GAAGf,OAAO,CAAC,MAAM,CAACgB,MAAM,CAACC,aAAa,EAAEL,KAAK,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAClE,MAAMM,KAAK,GAAGlB,OAAO,CAAC,MAAM,CAACgB,MAAM,CAACG,cAAc,EAAEP,KAAK,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEpE,oBACEb,KAAA,CAAAqB,aAAA,CAACjB,IAAI;IACHkB,KAAK,EACHf,IAAI,KAAK,MAAM,GAAGU,MAAM,CAACM,kBAAkB,GAAGN,MAAM,CAACO;EACtD,gBAEDxB,KAAA,CAAAqB,aAAA,CAACjB,IAAI;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react";
|
|
2
2
|
import { Platform, TouchableNativeFeedback, TouchableOpacity, View } from "react-native";
|
|
3
|
-
import
|
|
3
|
+
import { useKeyboardState } from "../../hooks";
|
|
4
4
|
const ButtonIOS = ({
|
|
5
5
|
children,
|
|
6
6
|
onPress,
|
|
@@ -37,7 +37,7 @@ const ButtonAndroid = ({
|
|
|
37
37
|
style,
|
|
38
38
|
theme
|
|
39
39
|
}) => {
|
|
40
|
-
const colorScheme =
|
|
40
|
+
const colorScheme = useKeyboardState(state => state.appearance);
|
|
41
41
|
const accessibilityState = useMemo(() => ({
|
|
42
42
|
disabled
|
|
43
43
|
}), [disabled]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","Platform","TouchableNativeFeedback","TouchableOpacity","View","
|
|
1
|
+
{"version":3,"names":["React","useMemo","Platform","TouchableNativeFeedback","TouchableOpacity","View","useKeyboardState","ButtonIOS","children","onPress","disabled","accessibilityLabel","accessibilityHint","testID","style","Container","accessibilityState","createElement","accessibilityRole","ButtonAndroid","rippleRadius","theme","colorScheme","state","appearance","ripple","Ripple","background","select","android","default"],"sources":["Button.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport {\n Platform,\n TouchableNativeFeedback,\n TouchableOpacity,\n View,\n} from \"react-native\";\n\nimport { useKeyboardState } from \"../../hooks\";\n\nimport type { KeyboardToolbarTheme } from \"./types\";\nimport type { PropsWithChildren } from \"react\";\nimport type { GestureResponderEvent, ViewStyle } from \"react-native\";\n\ntype ButtonProps = {\n disabled?: boolean;\n onPress: (event: GestureResponderEvent) => void;\n accessibilityLabel: string;\n accessibilityHint: string;\n testID: string;\n rippleRadius?: number;\n style?: ViewStyle;\n theme: KeyboardToolbarTheme;\n};\n\nconst ButtonIOS = ({\n children,\n onPress,\n disabled,\n accessibilityLabel,\n accessibilityHint,\n testID,\n style,\n}: PropsWithChildren<ButtonProps>) => {\n // immediately switch to plain view to avoid animation flickering\n // when fade out animation happens and view becomes disabled\n const Container = disabled\n ? (View as unknown as typeof TouchableOpacity)\n : TouchableOpacity;\n const accessibilityState = useMemo(() => ({ disabled }), [disabled]);\n\n return (\n <Container\n accessibilityHint={accessibilityHint}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole=\"button\"\n accessibilityState={accessibilityState}\n style={style}\n testID={testID}\n onPress={onPress}\n >\n {children}\n </Container>\n );\n};\nconst ButtonAndroid = ({\n children,\n onPress,\n disabled,\n accessibilityLabel,\n accessibilityHint,\n testID,\n rippleRadius = 18,\n style,\n theme,\n}: PropsWithChildren<ButtonProps>) => {\n const colorScheme = useKeyboardState((state) => state.appearance);\n const accessibilityState = useMemo(() => ({ disabled }), [disabled]);\n const ripple = useMemo(\n () =>\n TouchableNativeFeedback.Ripple(\n theme[colorScheme].ripple,\n true,\n rippleRadius,\n ),\n [colorScheme, rippleRadius, theme],\n );\n\n return (\n <TouchableNativeFeedback\n accessibilityHint={accessibilityHint}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole=\"button\"\n accessibilityState={accessibilityState}\n background={ripple}\n style={style}\n testID={testID}\n onPress={onPress}\n >\n <View style={style}>{children}</View>\n </TouchableNativeFeedback>\n );\n};\n\nexport default Platform.select({\n android: ButtonAndroid,\n default: ButtonIOS,\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SACEC,QAAQ,EACRC,uBAAuB,EACvBC,gBAAgB,EAChBC,IAAI,QACC,cAAc;AAErB,SAASC,gBAAgB,QAAQ,aAAa;AAiB9C,MAAMC,SAAS,GAAGA,CAAC;EACjBC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,kBAAkB;EAClBC,iBAAiB;EACjBC,MAAM;EACNC;AAC8B,CAAC,KAAK;EACpC;EACA;EACA,MAAMC,SAAS,GAAGL,QAAQ,GACrBL,IAAI,GACLD,gBAAgB;EACpB,MAAMY,kBAAkB,GAAGf,OAAO,CAAC,OAAO;IAAES;EAAS,CAAC,CAAC,EAAE,CAACA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E9B,CAAC;AAED,eAAeN,QAAQ,CAAC0B,MAAM,CAAC;EAC7BC,OAAO,EAAEV,aAAa;EACtBW,OAAO,EAAEvB;AACX,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
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 = Platform.OS === "ios" && parseInt(Platform.Version, 10) >= 26;
|
|
10
|
+
export const OPENED_OFFSET = KEYBOARD_HAS_ROUNDED_CORNERS ? -11 : 0;
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Platform","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","OS","parseInt","Version","OPENED_OFFSET"],"sources":["constants.ts"],"sourcesContent":["import { Platform } from \"react-native\";\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 =\n Platform.OS === \"ios\" && parseInt(Platform.Version, 10) >= 26;\nexport const OPENED_OFFSET = KEYBOARD_HAS_ROUNDED_CORNERS ? -11 : 0;\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAIvC,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,GACvCR,QAAQ,CAACS,EAAE,KAAK,KAAK,IAAIC,QAAQ,CAACV,QAAQ,CAACW,OAAO,EAAE,EAAE,CAAC,IAAI,EAAE;AAC/D,OAAO,MAAMC,aAAa,GAAGJ,4BAA4B,GAAG,CAAC,EAAE,GAAG,CAAC","ignoreList":[]}
|
|
@@ -2,20 +2,13 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { StyleSheet, Text, View } from "react-native";
|
|
4
4
|
import { FocusedInputEvents } from "../../bindings";
|
|
5
|
+
import { useKeyboardState } from "../../hooks";
|
|
5
6
|
import { KeyboardController } from "../../module";
|
|
6
|
-
import useColorScheme from "../hooks/useColorScheme";
|
|
7
7
|
import KeyboardStickyView from "../KeyboardStickyView";
|
|
8
8
|
import Arrow from "./Arrow";
|
|
9
9
|
import Button from "./Button";
|
|
10
10
|
import { colors } from "./colors";
|
|
11
|
-
|
|
12
|
-
const TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;
|
|
13
|
-
const TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;
|
|
14
|
-
const TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;
|
|
15
|
-
const TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;
|
|
16
|
-
const KEYBOARD_TOOLBAR_HEIGHT = 42;
|
|
17
|
-
const DEFAULT_OPACITY = "FF";
|
|
18
|
-
|
|
11
|
+
import { DEFAULT_OPACITY, KEYBOARD_HAS_ROUNDED_CORNERS, KEYBOARD_TOOLBAR_HEIGHT, OPENED_OFFSET, TEST_ID_KEYBOARD_TOOLBAR, TEST_ID_KEYBOARD_TOOLBAR_CONTENT, TEST_ID_KEYBOARD_TOOLBAR_DONE, TEST_ID_KEYBOARD_TOOLBAR_NEXT, TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS } from "./constants";
|
|
19
12
|
/**
|
|
20
13
|
* `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` buttons from left and
|
|
21
14
|
* `Done` button from the right (to dismiss the keyboard). Allows to add customizable content (yours UI elements) in the middle.
|
|
@@ -49,7 +42,7 @@ const KeyboardToolbar = props => {
|
|
|
49
42
|
insets,
|
|
50
43
|
...rest
|
|
51
44
|
} = props;
|
|
52
|
-
const colorScheme =
|
|
45
|
+
const colorScheme = useKeyboardState(state => state.appearance);
|
|
53
46
|
const [inputs, setInputs] = useState({
|
|
54
47
|
current: 0,
|
|
55
48
|
count: 0
|
|
@@ -67,13 +60,17 @@ const KeyboardToolbar = props => {
|
|
|
67
60
|
}], [colorScheme, theme]);
|
|
68
61
|
const toolbarStyle = useMemo(() => [styles.toolbar, {
|
|
69
62
|
backgroundColor: `${theme[colorScheme].background}${opacity}`
|
|
70
|
-
}, {
|
|
63
|
+
}, !KEYBOARD_HAS_ROUNDED_CORNERS ? {
|
|
71
64
|
paddingLeft: insets === null || insets === void 0 ? void 0 : insets.left,
|
|
72
65
|
paddingRight: insets === null || insets === void 0 ? void 0 : insets.right
|
|
73
|
-
}], [colorScheme, opacity, theme, insets]);
|
|
66
|
+
} : null, KEYBOARD_HAS_ROUNDED_CORNERS ? styles.floating : null], [colorScheme, opacity, theme, insets]);
|
|
67
|
+
const containerStyle = useMemo(() => [KEYBOARD_HAS_ROUNDED_CORNERS ? {
|
|
68
|
+
marginLeft: ((insets === null || insets === void 0 ? void 0 : insets.left) ?? 0) + 16,
|
|
69
|
+
marginRight: ((insets === null || insets === void 0 ? void 0 : insets.right) ?? 0) + 16
|
|
70
|
+
} : null], [insets]);
|
|
74
71
|
const offset = useMemo(() => ({
|
|
75
72
|
closed: closed + KEYBOARD_TOOLBAR_HEIGHT,
|
|
76
|
-
opened
|
|
73
|
+
opened: opened + OPENED_OFFSET
|
|
77
74
|
}), [closed, opened]);
|
|
78
75
|
const ButtonContainer = button || Button;
|
|
79
76
|
const IconContainer = icon || Arrow;
|
|
@@ -97,7 +94,8 @@ const KeyboardToolbar = props => {
|
|
|
97
94
|
}, [onDoneCallback]);
|
|
98
95
|
return /*#__PURE__*/React.createElement(KeyboardStickyView, {
|
|
99
96
|
enabled: enabled,
|
|
100
|
-
offset: offset
|
|
97
|
+
offset: offset,
|
|
98
|
+
style: containerStyle
|
|
101
99
|
}, /*#__PURE__*/React.createElement(View, _extends({}, rest, {
|
|
102
100
|
style: toolbarStyle,
|
|
103
101
|
testID: TEST_ID_KEYBOARD_TOOLBAR
|
|
@@ -164,6 +162,11 @@ const styles = StyleSheet.create({
|
|
|
164
162
|
doneButtonContainer: {
|
|
165
163
|
marginRight: 16,
|
|
166
164
|
marginLeft: 8
|
|
165
|
+
},
|
|
166
|
+
floating: {
|
|
167
|
+
alignSelf: "center",
|
|
168
|
+
borderRadius: 20,
|
|
169
|
+
overflow: "hidden"
|
|
167
170
|
}
|
|
168
171
|
});
|
|
169
172
|
export { colors as DefaultKeyboardToolbarTheme };
|