react-native-keyboard-controller 1.20.0-beta.0 → 1.20.1
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/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +18 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +1 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +7 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +2 -2
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +16 -0
- package/ios/KeyboardControllerModule.mm +1 -0
- package/ios/observers/FocusedInputObserver.swift +1 -1
- package/ios/views/KeyboardControllerView.mm +11 -0
- package/ios/views/KeyboardControllerViewManager.mm +3 -0
- package/ios/views/KeyboardControllerViewManager.swift +13 -1
- package/lib/commonjs/animated.js +14 -4
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js +4 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +4 -2
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/compat.js +65 -0
- package/lib/commonjs/compat.js.map +1 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +25 -7
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/commonjs/components/index.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 +2 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +5 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/types/internal.js.map +1 -1
- package/lib/commonjs/types/module.js.map +1 -1
- package/lib/module/animated.js +16 -6
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js +3 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +3 -1
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/compat.js +58 -0
- package/lib/module/compat.js.map +1 -0
- package/lib/module/components/KeyboardAwareScrollView/index.js +26 -8
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/module/components/index.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 +2 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js +4 -0
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/types/internal.js.map +1 -1
- package/lib/module/types/module.js.map +1 -1
- package/lib/typescript/bindings.d.ts +3 -0
- package/lib/typescript/bindings.native.d.ts +1 -0
- package/lib/typescript/compat.d.ts +27 -0
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -1
- package/lib/typescript/components/index.d.ts +1 -1
- package/lib/typescript/context.d.ts +2 -0
- package/lib/typescript/hooks/index.d.ts +1 -0
- package/lib/typescript/hooks/useKeyboardState/index.d.ts +3 -3
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
- package/lib/typescript/types/internal.d.ts +1 -1
- package/lib/typescript/types/module.d.ts +3 -2
- package/package.json +1 -1
- package/src/animated.tsx +32 -6
- package/src/bindings.native.ts +4 -1
- package/src/bindings.ts +5 -0
- package/src/compat.ts +61 -0
- package/src/components/KeyboardAwareScrollView/index.tsx +43 -11
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +2 -2
- package/src/components/index.ts +4 -1
- package/src/context.ts +3 -0
- package/src/hooks/index.ts +4 -1
- package/src/hooks/useKeyboardState/index.ts +4 -4
- package/src/index.ts +2 -0
- package/src/specs/KeyboardControllerViewNativeComponent.ts +11 -0
- package/src/types/internal.ts +3 -1
- package/src/types/module.ts +3 -2
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -2
- package/ios/KeyboardController.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/Tests/Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcuserdata/kirylziusko.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Tests/Tests.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +0 -32
package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.reactnativekeyboardcontroller
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.ReadableArray
|
|
3
4
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
4
5
|
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
5
6
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
@@ -56,6 +57,23 @@ class KeyboardControllerViewManager :
|
|
|
56
57
|
) = manager.setEnabled(view as EdgeToEdgeReactViewGroup, value)
|
|
57
58
|
// endregion
|
|
58
59
|
|
|
60
|
+
// region Commands
|
|
61
|
+
override fun receiveCommand(
|
|
62
|
+
root: ReactViewGroup,
|
|
63
|
+
commandId: String,
|
|
64
|
+
args: ReadableArray?,
|
|
65
|
+
) {
|
|
66
|
+
when (commandId) {
|
|
67
|
+
"synchronizeFocusedInputLayout" -> synchronizeFocusedInputLayout(root)
|
|
68
|
+
else -> super.receiveCommand(root, commandId, args)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
override fun synchronizeFocusedInputLayout(view: ReactViewGroup) {
|
|
73
|
+
manager.synchronizeFocusedInputLayout(view as EdgeToEdgeReactViewGroup)
|
|
74
|
+
}
|
|
75
|
+
// endregion
|
|
76
|
+
|
|
59
77
|
// region Getters
|
|
60
78
|
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> =
|
|
61
79
|
manager.getExportedCustomDirectEventTypeConstants()
|
|
@@ -109,7 +109,7 @@ class KeyboardAnimationCallback(
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
internal var layoutObserver: FocusedInputObserver? = null
|
|
113
113
|
|
|
114
114
|
init {
|
|
115
115
|
require(config.persistentInsetTypes and config.deferredInsetTypes == 0) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
package com.reactnativekeyboardcontroller.managers
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
3
4
|
import com.facebook.react.common.MapBuilder
|
|
4
5
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
6
|
import com.reactnativekeyboardcontroller.events.FocusedInputLayoutChangedEvent
|
|
6
7
|
import com.reactnativekeyboardcontroller.events.FocusedInputSelectionChangedEvent
|
|
7
8
|
import com.reactnativekeyboardcontroller.events.FocusedInputTextChangedEvent
|
|
8
9
|
import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent
|
|
10
|
+
import com.reactnativekeyboardcontroller.extensions.emitEvent
|
|
9
11
|
import com.reactnativekeyboardcontroller.listeners.WindowDimensionListener
|
|
10
12
|
import com.reactnativekeyboardcontroller.views.EdgeToEdgeReactViewGroup
|
|
11
13
|
|
|
@@ -25,6 +27,11 @@ class KeyboardControllerViewManagerImpl {
|
|
|
25
27
|
listener = null
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
fun synchronizeFocusedInputLayout(view: EdgeToEdgeReactViewGroup) {
|
|
31
|
+
view.callback?.layoutObserver?.syncUpLayout()
|
|
32
|
+
view.reactContext.emitEvent("KeyboardController::layoutDidSynchronize", Arguments.createMap())
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
fun setEnabled(
|
|
29
36
|
view: EdgeToEdgeReactViewGroup,
|
|
30
37
|
enabled: Boolean,
|
package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt
CHANGED
|
@@ -38,7 +38,7 @@ object EdgeToEdgeViewRegistry {
|
|
|
38
38
|
@Suppress("detekt:TooManyFunctions")
|
|
39
39
|
@SuppressLint("ViewConstructor")
|
|
40
40
|
class EdgeToEdgeReactViewGroup(
|
|
41
|
-
|
|
41
|
+
val reactContext: ThemedReactContext,
|
|
42
42
|
) : ReactViewGroup(reactContext) {
|
|
43
43
|
// props
|
|
44
44
|
private var isStatusBarTranslucent = false
|
|
@@ -58,7 +58,7 @@ class EdgeToEdgeReactViewGroup(
|
|
|
58
58
|
// internal class members
|
|
59
59
|
private var eventView: ReactViewGroup? = null
|
|
60
60
|
private var wasMounted = false
|
|
61
|
-
|
|
61
|
+
internal var callback: KeyboardAnimationCallback? = null
|
|
62
62
|
private val config =
|
|
63
63
|
KeyboardAnimationCallbackConfig(
|
|
64
64
|
persistentInsetTypes = WindowInsetsCompat.Type.systemBars(),
|
package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.reactnativekeyboardcontroller
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.ReadableArray
|
|
3
4
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
4
5
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
5
6
|
import com.facebook.react.views.view.ReactViewGroup
|
|
@@ -58,6 +59,21 @@ class KeyboardControllerViewManager : ReactViewManager() {
|
|
|
58
59
|
}
|
|
59
60
|
// endregion
|
|
60
61
|
|
|
62
|
+
// region Commands
|
|
63
|
+
override fun receiveCommand(
|
|
64
|
+
root: ReactViewGroup,
|
|
65
|
+
commandId: String,
|
|
66
|
+
args: ReadableArray?,
|
|
67
|
+
) {
|
|
68
|
+
when (commandId) {
|
|
69
|
+
"synchronizeFocusedInputLayout" -> {
|
|
70
|
+
manager.synchronizeFocusedInputLayout(root as EdgeToEdgeReactViewGroup)
|
|
71
|
+
}
|
|
72
|
+
else -> super.receiveCommand(root, commandId, args)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//endregion
|
|
76
|
+
|
|
61
77
|
// region Getters
|
|
62
78
|
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> =
|
|
63
79
|
manager.getExportedCustomDirectEventTypeConstants()
|
|
@@ -127,6 +127,7 @@ RCT_EXPORT_METHOD(setFocusTo : (nonnull NSString *)direction)
|
|
|
127
127
|
@"KeyboardController::keyboardDidHide",
|
|
128
128
|
// focused input
|
|
129
129
|
@"KeyboardController::focusDidSet",
|
|
130
|
+
@"KeyboardController::layoutDidSynchronize",
|
|
130
131
|
// window dimensions
|
|
131
132
|
@"KeyboardController::windowDidResize",
|
|
132
133
|
];
|
|
@@ -165,7 +165,7 @@ public class FocusedInputObserver: NSObject {
|
|
|
165
165
|
dispatchEventToJS(data: noFocusedInputEvent)
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
@objc func syncUpLayout() {
|
|
168
|
+
@objc public func syncUpLayout() {
|
|
169
169
|
let responder = currentResponder as UIResponder?
|
|
170
170
|
let focusedInput = currentInput
|
|
171
171
|
let globalFrame = focusedInput?.globalFrame
|
|
@@ -41,6 +41,17 @@ using namespace facebook::react;
|
|
|
41
41
|
CGSize _lastScreenSize;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
45
|
+
{
|
|
46
|
+
RCTKeyboardControllerViewHandleCommand(self, commandName, args);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (void)synchronizeFocusedInputLayout
|
|
50
|
+
{
|
|
51
|
+
[inputObserver syncUpLayout];
|
|
52
|
+
[KeyboardController.shared sendEvent:@"KeyboardController::layoutDidSynchronize" body:nil];
|
|
53
|
+
}
|
|
54
|
+
|
|
44
55
|
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
45
56
|
{
|
|
46
57
|
return concreteComponentDescriptorProvider<KeyboardControllerViewComponentDescriptor>();
|
|
@@ -16,4 +16,7 @@ RCT_EXPORT_VIEW_PROPERTY(onFocusedInputLayoutChanged, RCTDirectEventBlock);
|
|
|
16
16
|
RCT_EXPORT_VIEW_PROPERTY(onFocusedInputTextChanged, RCTDirectEventBlock);
|
|
17
17
|
RCT_EXPORT_VIEW_PROPERTY(onFocusedInputSelectionChanged, RCTDirectEventBlock);
|
|
18
18
|
|
|
19
|
+
// commands
|
|
20
|
+
RCT_EXTERN_METHOD(synchronizeFocusedInputLayout : (nonnull NSNumber *)reactTag);
|
|
21
|
+
|
|
19
22
|
@end
|
|
@@ -7,12 +7,24 @@ class KeyboardControllerViewManager: RCTViewManager {
|
|
|
7
7
|
override func view() -> (KeyboardControllerView) {
|
|
8
8
|
return KeyboardControllerView(frame: CGRect.zero, bridge: bridge)
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
@objc(synchronizeFocusedInputLayout:)
|
|
12
|
+
func synchronizeFocusedInputLayout(_ reactTag: NSNumber) {
|
|
13
|
+
bridge.uiManager.addUIBlock { _, viewRegistry in
|
|
14
|
+
guard let view = viewRegistry?[reactTag] as? KeyboardControllerView else {
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
view.inputObserver?.syncUpLayout()
|
|
19
|
+
KeyboardController.shared()?.sendEvent("KeyboardController::layoutDidSynchronize", body: nil)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
10
22
|
}
|
|
11
23
|
|
|
12
24
|
class KeyboardControllerView: UIView {
|
|
13
25
|
// internal variables
|
|
14
26
|
private var keyboardObserver: KeyboardMovementObserver?
|
|
15
|
-
|
|
27
|
+
var inputObserver: FocusedInputObserver?
|
|
16
28
|
private var eventDispatcher: RCTEventDispatcherProtocol
|
|
17
29
|
private var bridge: RCTBridge
|
|
18
30
|
// internal state
|
package/lib/commonjs/animated.js
CHANGED
|
@@ -55,7 +55,7 @@ const KeyboardProvider = props => {
|
|
|
55
55
|
preload = true
|
|
56
56
|
} = props;
|
|
57
57
|
// ref
|
|
58
|
-
const
|
|
58
|
+
const viewRef = (0, _react.useRef)(null);
|
|
59
59
|
// state
|
|
60
60
|
const [enabled, setEnabled] = (0, _react.useState)(initiallyEnabled);
|
|
61
61
|
// animated values
|
|
@@ -65,8 +65,17 @@ const KeyboardProvider = props => {
|
|
|
65
65
|
const progressSV = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
66
66
|
const heightSV = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
67
67
|
const layout = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
68
|
-
const setKeyboardHandlers = (0, _internal.useEventHandlerRegistration)(
|
|
69
|
-
const setInputHandlers = (0, _internal.useEventHandlerRegistration)(
|
|
68
|
+
const setKeyboardHandlers = (0, _internal.useEventHandlerRegistration)(viewRef);
|
|
69
|
+
const setInputHandlers = (0, _internal.useEventHandlerRegistration)(viewRef);
|
|
70
|
+
const update = (0, _react.useCallback)(async () => {
|
|
71
|
+
_bindings.KeyboardControllerViewCommands.synchronizeFocusedInputLayout(viewRef.current);
|
|
72
|
+
await new Promise(resolve => {
|
|
73
|
+
const subscription = _bindings.FocusedInputEvents.addListener("layoutDidSynchronize", () => {
|
|
74
|
+
subscription.remove();
|
|
75
|
+
resolve(null);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}, []);
|
|
70
79
|
// memo
|
|
71
80
|
const context = (0, _react.useMemo)(() => ({
|
|
72
81
|
enabled,
|
|
@@ -79,6 +88,7 @@ const KeyboardProvider = props => {
|
|
|
79
88
|
height: heightSV
|
|
80
89
|
},
|
|
81
90
|
layout,
|
|
91
|
+
update,
|
|
82
92
|
setKeyboardHandlers,
|
|
83
93
|
setInputHandlers,
|
|
84
94
|
setEnabled
|
|
@@ -158,7 +168,7 @@ const KeyboardProvider = props => {
|
|
|
158
168
|
return /*#__PURE__*/_react.default.createElement(_context.KeyboardContext.Provider, {
|
|
159
169
|
value: context
|
|
160
170
|
}, /*#__PURE__*/_react.default.createElement(KeyboardControllerViewAnimated, {
|
|
161
|
-
ref:
|
|
171
|
+
ref: viewRef,
|
|
162
172
|
enabled: enabled,
|
|
163
173
|
navigationBarTranslucent: IS_EDGE_TO_EDGE || navigationBarTranslucent,
|
|
164
174
|
statusBarTranslucent: IS_EDGE_TO_EDGE || statusBarTranslucent,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeIsEdgeToEdge","_reactNativeReanimated","_bindings","_context","_internal","_module","_reanimated","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","IS_EDGE_TO_EDGE","isEdgeToEdge","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","OS","Platform","KeyboardProvider","props","children","statusBarTranslucent","navigationBarTranslucent","preserveEdgeToEdge","enabled","initiallyEnabled","preload","viewTagRef","useRef","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","useEventHandlerRegistration","setInputHandlers","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","onKeyboardMoveEnd","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","target","useEffect","KeyboardController","__DEV__","controlEdgeToEdgeValues","createElement","KeyboardContext","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View","exports"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Animated, Platform, StyleSheet } from \"react-native\";\nimport {\n controlEdgeToEdgeValues,\n isEdgeToEdge,\n} from \"react-native-is-edge-to-edge\";\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\n\nimport { KeyboardControllerView } from \"./bindings\";\nimport { KeyboardContext } from \"./context\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { KeyboardController } from \"./module\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\n} from \"./reanimated\";\n\nimport type { KeyboardAnimationContext } from \"./context\";\nimport type {\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n NativeEvent,\n} from \"./types\";\nimport type { ViewStyle } from \"react-native\";\n\nconst IS_EDGE_TO_EDGE = isEdgeToEdge();\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(KeyboardControllerView),\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: \"none\",\n position: \"absolute\",\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592\n */\n preserveEdgeToEdge?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state\n * (if you try to change this prop after component mount it will not have any effect).\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n /**\n * A boolean prop indicating whether to preload the keyboard to reduce time-to-interaction (TTI) on first input focus.\n * Defaults to `true`.\n *\n * @platform ios\n */\n preload?: boolean;\n};\n\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\n/**\n * A component that wrap your app. Under the hood it works with {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|KeyboardControllerView} to receive events during keyboard movements,\n * maps these events to `Animated`/`Reanimated` values and store them in context.\n *\n * @param props - Provider props, such as `statusBarTranslucent`, `navigationBarTranslucent`, etc.\n * @returns A component that should be mounted in root of your App layout.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-provider|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardProvider>\n * <NavigationContainer />\n * </KeyboardProvider>\n * ```\n */\nexport const KeyboardProvider = (props: KeyboardProviderProps) => {\n const {\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n enabled: initiallyEnabled = true,\n preload = true,\n } = props;\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const setKeyboardHandlers = useEventHandlerRegistration(viewTagRef);\n const setInputHandlers = useEventHandlerRegistration(viewTagRef);\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled],\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n [],\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n // Setting useNativeDriver to true on web triggers a warning due to the absence of a native driver for web. Therefore, it is set to false.\n { useNativeDriver: Platform.OS !== \"web\" },\n ),\n [],\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n \"worklet\";\n\n if (platforms.includes(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n },\n [],\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n \"worklet\";\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n [],\n );\n\n useEffect(() => {\n if (preload) {\n KeyboardController.preload();\n }\n }, [preload]);\n\n if (__DEV__) {\n controlEdgeToEdgeValues({\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n });\n }\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}\n statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}\n preserveEdgeToEdge={IS_EDGE_TO_EDGE || preserveEdgeToEdge}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onKeyboardMoveEnd={OS === \"android\" ? onKeyboardMove : undefined}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AAIA,IAAAG,sBAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAEA,IAAAI,S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sB,kBAAmB;IAC1DuB,KAAK,EAAEtC,MAAM,CAACG;IACd;IAAA;IACAgE,wBAAwB,EAAEjB,eAAgB;IAC1CE,mBAAmB,EAAE5C,EAAE,KAAK,KAAK,GAAGkC,cAAc,GAAG0B,SAAU;IAC/D1B,cAAc,EAAElC,EAAE,KAAK,SAAS,GAAGkC,cAAc,GAAG0B,SAAU;IAC9Df,yBAAyB,EAAEX,cAAe;IAC1CY,iBAAiB,EAAE9C,EAAE,KAAK,SAAS,GAAGkC,cAAc,GAAG0B,SAAU;IACjEC,qCAAqC,EAAEd;EAAmB,GAEzD3C,QAC6B,CAAC,eACjCjD,MAAA,CAAAqB,OAAA,CAAA+E,aAAA,CAACjG,YAAA,CAAAgC,QAAQ,CAACwE,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAhC,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAACiC,OAAA,CAAA7D,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeIsEdgeToEdge","_reactNativeReanimated","_bindings","_context","_internal","_module","_reanimated","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","IS_EDGE_TO_EDGE","isEdgeToEdge","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","OS","Platform","KeyboardProvider","props","children","statusBarTranslucent","navigationBarTranslucent","preserveEdgeToEdge","enabled","initiallyEnabled","preload","viewRef","useRef","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","useEventHandlerRegistration","setInputHandlers","update","useCallback","KeyboardControllerViewCommands","synchronizeFocusedInputLayout","current","Promise","resolve","subscription","FocusedInputEvents","addListener","remove","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","onKeyboardMoveEnd","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","target","useEffect","KeyboardController","__DEV__","controlEdgeToEdgeValues","createElement","KeyboardContext","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View","exports"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Animated, Platform, StyleSheet } from \"react-native\";\nimport {\n controlEdgeToEdgeValues,\n isEdgeToEdge,\n} from \"react-native-is-edge-to-edge\";\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\n\nimport {\n FocusedInputEvents,\n KeyboardControllerView,\n KeyboardControllerViewCommands,\n} from \"./bindings\";\nimport { KeyboardContext } from \"./context\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { KeyboardController } from \"./module\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\n} from \"./reanimated\";\n\nimport type { KeyboardAnimationContext } from \"./context\";\nimport type {\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n NativeEvent,\n} from \"./types\";\nimport type { ViewStyle } from \"react-native\";\n\nconst IS_EDGE_TO_EDGE = isEdgeToEdge();\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(KeyboardControllerView),\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: \"none\",\n position: \"absolute\",\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592\n */\n preserveEdgeToEdge?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state\n * (if you try to change this prop after component mount it will not have any effect).\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n /**\n * A boolean prop indicating whether to preload the keyboard to reduce time-to-interaction (TTI) on first input focus.\n * Defaults to `true`.\n *\n * @platform ios\n */\n preload?: boolean;\n};\n\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\n/**\n * A component that wrap your app. Under the hood it works with {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|KeyboardControllerView} to receive events during keyboard movements,\n * maps these events to `Animated`/`Reanimated` values and store them in context.\n *\n * @param props - Provider props, such as `statusBarTranslucent`, `navigationBarTranslucent`, etc.\n * @returns A component that should be mounted in root of your App layout.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-provider|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardProvider>\n * <NavigationContainer />\n * </KeyboardProvider>\n * ```\n */\nexport const KeyboardProvider = (props: KeyboardProviderProps) => {\n const {\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n enabled: initiallyEnabled = true,\n preload = true,\n } = props;\n // ref\n const viewRef = useRef<React.Component<KeyboardControllerProps>>(null);\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const setKeyboardHandlers = useEventHandlerRegistration(viewRef);\n const setInputHandlers = useEventHandlerRegistration(viewRef);\n const update = useCallback(async () => {\n KeyboardControllerViewCommands.synchronizeFocusedInputLayout(\n viewRef.current,\n );\n\n await new Promise((resolve) => {\n const subscription = FocusedInputEvents.addListener(\n \"layoutDidSynchronize\",\n () => {\n subscription.remove();\n resolve(null);\n },\n );\n });\n }, []);\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n update,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled],\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n [],\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n // Setting useNativeDriver to true on web triggers a warning due to the absence of a native driver for web. Therefore, it is set to false.\n { useNativeDriver: Platform.OS !== \"web\" },\n ),\n [],\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n \"worklet\";\n\n if (platforms.includes(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n },\n [],\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n \"worklet\";\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n [],\n );\n\n useEffect(() => {\n if (preload) {\n KeyboardController.preload();\n }\n }, [preload]);\n\n if (__DEV__) {\n controlEdgeToEdgeValues({\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n });\n }\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n ref={viewRef}\n enabled={enabled}\n navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}\n statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}\n preserveEdgeToEdge={IS_EDGE_TO_EDGE || preserveEdgeToEdge}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onKeyboardMoveEnd={OS === \"android\" ? onKeyboardMove : undefined}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\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GED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WindowDimensionsEvents = exports.RCTOverKeyboardView = exports.RCTKeyboardExtender = exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardControllerNative = exports.KeyboardBackgroundView = exports.FocusedInputEvents = void 0;
|
|
6
|
+
exports.WindowDimensionsEvents = exports.RCTOverKeyboardView = exports.RCTKeyboardExtender = exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerViewCommands = exports.KeyboardControllerView = exports.KeyboardControllerNative = exports.KeyboardBackgroundView = exports.FocusedInputEvents = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
const NOOP = () => {};
|
|
9
9
|
const KeyboardControllerNative = exports.KeyboardControllerNative = {
|
|
@@ -49,6 +49,9 @@ const WindowDimensionsEvents = exports.WindowDimensionsEvents = {
|
|
|
49
49
|
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|Documentation} page for more details.
|
|
50
50
|
*/
|
|
51
51
|
const KeyboardControllerView = exports.KeyboardControllerView = _reactNative.View;
|
|
52
|
+
const KeyboardControllerViewCommands = exports.KeyboardControllerViewCommands = {
|
|
53
|
+
synchronizeFocusedInputLayout: _ref => {}
|
|
54
|
+
};
|
|
52
55
|
/**
|
|
53
56
|
* A view that defines a region on the screen, where gestures will control the keyboard position.
|
|
54
57
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","NOOP","KeyboardControllerNative","exports","setDefaultMode","setInputMode","preload","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","View","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,IAAAA,YAAA,GAAAC,OAAA;AAeA,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAEd,MAAMC,wBAAwD,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACtEE,cAAc,EAAEH,IAAI;EACpBI,YAAY,EAAEJ,IAAI;EAClBK,OAAO,EAAEL,IAAI;EACbM,OAAO,EAAEN,IAAI;EACbO,UAAU,EAAEP,IAAI;EAChBQ,WAAW,EAAER,IAAI;EACjBS,eAAe,EAAET;AACnB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMU,cAAoC,GAAAR,OAAA,CAAAQ,cAAA,GAAG;EAClDF,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEX;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMY,kBAA4C,GAAAV,OAAA,CAAAU,kBAAA,GAAG;EAC1DJ,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEX;EAAK,CAAC;AACtC,CAAC;AACM,MAAMa,sBAAoD,GAAAX,OAAA,CAAAW,sBAAA,GAAG;EAClEL,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEX;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,MAAMc,sBAAsB,GAAAZ,OAAA,CAAAY,sBAAA,GACjCC,iBAAoD;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","NOOP","KeyboardControllerNative","exports","setDefaultMode","setInputMode","preload","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","View","KeyboardControllerViewCommands","synchronizeFocusedInputLayout","_ref","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>;\nexport const KeyboardControllerViewCommands = {\n synchronizeFocusedInputLayout: (\n _ref: React.Component<KeyboardControllerProps> | null,\n ) => {},\n};\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,IAAAA,YAAA,GAAAC,OAAA;AAeA,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAEd,MAAMC,wBAAwD,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACtEE,cAAc,EAAEH,IAAI;EACpBI,YAAY,EAAEJ,IAAI;EAClBK,OAAO,EAAEL,IAAI;EACbM,OAAO,EAAEN,IAAI;EACbO,UAAU,EAAEP,IAAI;EAChBQ,WAAW,EAAER,IAAI;EACjBS,eAAe,EAAET;AACnB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMU,cAAoC,GAAAR,OAAA,CAAAQ,cAAA,GAAG;EAClDF,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEX;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMY,kBAA4C,GAAAV,OAAA,CAAAU,kBAAA,GAAG;EAC1DJ,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEX;EAAK,CAAC;AACtC,CAAC;AACM,MAAMa,sBAAoD,GAAAX,OAAA,CAAAW,sBAAA,GAAG;EAClEL,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAEX;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,MAAMc,sBAAsB,GAAAZ,OAAA,CAAAY,sBAAA,GACjCC,iBAAoD;AAC/C,MAAMC,8BAA8B,GAAAd,OAAA,CAAAc,8BAAA,GAAG;EAC5CC,6BAA6B,EAC3BC,IAAqD,IAClD,CAAC;AACR,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,MAAMC,mBAAmB,GAAAjB,OAAA,CAAAiB,mBAAA,GAC9BJ,iBAAqD;AAChD,MAAMK,mBAAmB,GAAAlB,OAAA,CAAAkB,mBAAA,GAC9BL,iBAAkD;AACpD;AACA;AACA;AACA;AACA;AACO,MAAMM,sBAAsB,GAAAnB,OAAA,CAAAmB,sBAAA,GACjCN,iBAAwD;AAC1D;AACA;AACA;AACA;AACA;AACA;AACO,MAAMO,mBAAmB,GAAApB,OAAA,CAAAoB,mBAAA,GAC9BP,iBAAkD","ignoreList":[]}
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WindowDimensionsEvents = exports.RCTOverKeyboardView = exports.RCTKeyboardExtender = exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardControllerNative = exports.KeyboardBackgroundView = exports.FocusedInputEvents = void 0;
|
|
6
|
+
exports.WindowDimensionsEvents = exports.RCTOverKeyboardView = exports.RCTKeyboardExtender = exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerViewCommands = exports.KeyboardControllerView = exports.KeyboardControllerNative = exports.KeyboardBackgroundView = exports.FocusedInputEvents = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
9
9
|
ios: "- You have run 'pod install'\n",
|
|
10
10
|
default: ""
|
|
11
11
|
}) + "- You rebuilt the app after installing the package\n" + "- You are not using Expo Go\n";
|
|
12
|
+
const KeyboardControllerViewNativeComponentModule = require("./specs/KeyboardControllerViewNativeComponent");
|
|
12
13
|
const RCTKeyboardController = require("./specs/NativeKeyboardController").default;
|
|
13
14
|
const KeyboardControllerNative = exports.KeyboardControllerNative = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
14
15
|
get() {
|
|
@@ -31,7 +32,8 @@ const FocusedInputEvents = exports.FocusedInputEvents = {
|
|
|
31
32
|
const WindowDimensionsEvents = exports.WindowDimensionsEvents = {
|
|
32
33
|
addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
|
|
33
34
|
};
|
|
34
|
-
const KeyboardControllerView = exports.KeyboardControllerView =
|
|
35
|
+
const KeyboardControllerView = exports.KeyboardControllerView = KeyboardControllerViewNativeComponentModule.default;
|
|
36
|
+
const KeyboardControllerViewCommands = exports.KeyboardControllerViewCommands = KeyboardControllerViewNativeComponentModule.Commands;
|
|
35
37
|
const KeyboardGestureArea = exports.KeyboardGestureArea = _reactNative.Platform.OS === "android" && _reactNative.Platform.Version >= 30 || _reactNative.Platform.OS === "ios" ? require("./specs/KeyboardGestureAreaNativeComponent").default : ({
|
|
36
38
|
children
|
|
37
39
|
}) => children;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","RCTKeyboardController","KeyboardControllerNative","exports","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","NativeEventEmitter","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
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","KeyboardControllerViewNativeComponentModule","RCTKeyboardController","KeyboardControllerNative","exports","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","NativeEventEmitter","KeyboardEvents","addListener","name","cb","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardControllerViewCommands","Commands","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 KeyboardControllerViewNativeComponentModule = require(\"./specs/KeyboardControllerViewNativeComponent\");\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 KeyboardControllerViewNativeComponentModule.default;\nexport const KeyboardControllerViewCommands =\n KeyboardControllerViewNativeComponentModule.Commands;\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,IAAAA,YAAA,GAAAC,OAAA;AAcA,MAAMC,aAAa,GACjB,2FAA2F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,2CAA2C,GAAGN,OAAO,CAAC,+CAA+C,CAAC;AAC5G,MAAMO,qBAAqB,GACzBP,OAAO,CAAC,kCAAkC,CAAC,CAACK,OAAO;AAE9C,MAAMG,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GACnCD,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACX,aAAa,CAAC;EAChC;AACF,CACF,CAC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AAA,CAAAqB,sBAAA,GACxE9B,OAAO,CAAC,+CAA+C,CAAC,CAACK,OAAO;AAC3D,MAAM0B,mBAAoD,GAAAtB,OAAA,CAAAsB,mBAAA,GAC/D7B,qBAAQ,CAACwB,EAAE,KAAK,KAAK,GACjB1B,OAAO,CAAC,yCAAyC,CAAC,CAACK,OAAO,GAC1D,CAAC;EAAEuB;AAAgC,CAAC,KAAKA,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAnimatedKeyboard = exports.KeyboardState = void 0;
|
|
7
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
8
|
+
var _hooks = require("./hooks");
|
|
9
|
+
const KeyboardState = exports.KeyboardState = {
|
|
10
|
+
UNKNOWN: 0,
|
|
11
|
+
OPENING: 1,
|
|
12
|
+
OPEN: 2,
|
|
13
|
+
CLOSING: 3,
|
|
14
|
+
CLOSED: 4
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A compatibility layer for migration from https://docs.swmansion.com/react-native-reanimated/docs/device/useAnimatedKeyboard.
|
|
19
|
+
*
|
|
20
|
+
* @returns An object containing `height` and `state` properties represented as `SharedValue<number>`.
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { useAnimatedKeyboard, useAnimatedStyle } from 'react-native-keyboard-controller';
|
|
24
|
+
*
|
|
25
|
+
* export default function App() {
|
|
26
|
+
* const keyboard = useAnimatedKeyboard();
|
|
27
|
+
*
|
|
28
|
+
* const animatedStyles = useAnimatedStyle(() => ({
|
|
29
|
+
* transform: [{ translateY: -keyboard.height.value }],
|
|
30
|
+
* }));
|
|
31
|
+
* }
|
|
32
|
+
*/
|
|
33
|
+
const useAnimatedKeyboard = () => {
|
|
34
|
+
const height = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
35
|
+
const state = (0, _reactNativeReanimated.useSharedValue)(KeyboardState.UNKNOWN);
|
|
36
|
+
(0, _hooks.useKeyboardHandler)({
|
|
37
|
+
onStart: e => {
|
|
38
|
+
"worklet";
|
|
39
|
+
|
|
40
|
+
state.set(e.height > 0 ? KeyboardState.OPENING : KeyboardState.CLOSING);
|
|
41
|
+
},
|
|
42
|
+
onMove: e => {
|
|
43
|
+
"worklet";
|
|
44
|
+
|
|
45
|
+
height.set(e.height);
|
|
46
|
+
},
|
|
47
|
+
onInteractive: e => {
|
|
48
|
+
"worklet";
|
|
49
|
+
|
|
50
|
+
height.set(e.height);
|
|
51
|
+
},
|
|
52
|
+
onEnd: e => {
|
|
53
|
+
"worklet";
|
|
54
|
+
|
|
55
|
+
state.set(e.height > 0 ? KeyboardState.OPEN : KeyboardState.CLOSED);
|
|
56
|
+
height.set(e.height);
|
|
57
|
+
}
|
|
58
|
+
}, []);
|
|
59
|
+
return {
|
|
60
|
+
height,
|
|
61
|
+
state
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
exports.useAnimatedKeyboard = useAnimatedKeyboard;
|
|
65
|
+
//# sourceMappingURL=compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeReanimated","require","_hooks","KeyboardState","exports","UNKNOWN","OPENING","OPEN","CLOSING","CLOSED","useAnimatedKeyboard","height","useSharedValue","state","useKeyboardHandler","onStart","e","set","onMove","onInteractive","onEnd"],"sources":["compat.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport { useKeyboardHandler } from \"./hooks\";\n\nexport const KeyboardState = {\n UNKNOWN: 0,\n OPENING: 1,\n OPEN: 2,\n CLOSING: 3,\n CLOSED: 4,\n};\n\n/**\n * A compatibility layer for migration from https://docs.swmansion.com/react-native-reanimated/docs/device/useAnimatedKeyboard.\n *\n * @returns An object containing `height` and `state` properties represented as `SharedValue<number>`.\n * @example\n * ```ts\n * import { useAnimatedKeyboard, useAnimatedStyle } from 'react-native-keyboard-controller';\n *\n * export default function App() {\n * const keyboard = useAnimatedKeyboard();\n *\n * const animatedStyles = useAnimatedStyle(() => ({\n * transform: [{ translateY: -keyboard.height.value }],\n * }));\n * }\n */\nexport const useAnimatedKeyboard = () => {\n const height = useSharedValue(0);\n const state = useSharedValue(KeyboardState.UNKNOWN);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n state.set(e.height > 0 ? KeyboardState.OPENING : KeyboardState.CLOSING);\n },\n onMove: (e) => {\n \"worklet\";\n\n height.set(e.height);\n },\n onInteractive: (e) => {\n \"worklet\";\n\n height.set(e.height);\n },\n onEnd: (e) => {\n \"worklet\";\n\n state.set(e.height > 0 ? KeyboardState.OPEN : KeyboardState.CLOSED);\n height.set(e.height);\n },\n },\n [],\n );\n\n return { height, state };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG;EAC3BE,OAAO,EAAE,CAAC;EACVC,OAAO,EAAE,CAAC;EACVC,IAAI,EAAE,CAAC;EACPC,OAAO,EAAE,CAAC;EACVC,MAAM,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,mBAAmB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAG,IAAAC,qCAAc,EAAC,CAAC,CAAC;EAChC,MAAMC,KAAK,GAAG,IAAAD,qCAAc,EAACT,aAAa,CAACE,OAAO,CAAC;EAEnD,IAAAS,yBAAkB,EAChB;IACEC,OAAO,EAAGC,CAAC,IAAK;MACd,SAAS;;MAETH,KAAK,CAACI,GAAG,CAACD,CAAC,CAACL,MAAM,GAAG,CAAC,GAAGR,aAAa,CAACG,OAAO,GAAGH,aAAa,CAACK,OAAO,CAAC;IACzE,CAAC;IACDU,MAAM,EAAGF,CAAC,IAAK;MACb,SAAS;;MAETL,MAAM,CAACM,GAAG,CAACD,CAAC,CAACL,MAAM,CAAC;IACtB,CAAC;IACDQ,aAAa,EAAGH,CAAC,IAAK;MACpB,SAAS;;MAETL,MAAM,CAACM,GAAG,CAACD,CAAC,CAACL,MAAM,CAAC;IACtB,CAAC;IACDS,KAAK,EAAGJ,CAAC,IAAK;MACZ,SAAS;;MAETH,KAAK,CAACI,GAAG,CAACD,CAAC,CAACL,MAAM,GAAG,CAAC,GAAGR,aAAa,CAACI,IAAI,GAAGJ,aAAa,CAACM,MAAM,CAAC;MACnEE,MAAM,CAACM,GAAG,CAACD,CAAC,CAACL,MAAM,CAAC;IACtB;EACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEA,MAAM;IAAEE;EAAM,CAAC;AAC1B,CAAC;AAACT,OAAA,CAAAM,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -77,6 +77,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
77
77
|
...rest
|
|
78
78
|
}, ref) => {
|
|
79
79
|
const scrollViewAnimatedRef = (0, _reactNativeReanimated.useAnimatedRef)();
|
|
80
|
+
const scrollViewRef = _react.default.useRef(null);
|
|
80
81
|
const scrollViewTarget = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
81
82
|
const scrollPosition = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
82
83
|
const position = (0, _reactNativeReanimated.useScrollViewOffset)(scrollViewAnimatedRef);
|
|
@@ -87,7 +88,8 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
87
88
|
const initialKeyboardSize = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
88
89
|
const scrollBeforeKeyboardMovement = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
89
90
|
const {
|
|
90
|
-
input
|
|
91
|
+
input,
|
|
92
|
+
update
|
|
91
93
|
} = (0, _hooks.useReanimatedFocusedInput)();
|
|
92
94
|
const layout = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
93
95
|
const lastSelection = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
@@ -95,11 +97,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
95
97
|
height
|
|
96
98
|
} = (0, _hooks.useWindowDimensions)();
|
|
97
99
|
const onRef = (0, _react.useCallback)(assignedRef => {
|
|
98
|
-
|
|
99
|
-
ref(assignedRef);
|
|
100
|
-
} else if (ref) {
|
|
101
|
-
ref.current = assignedRef;
|
|
102
|
-
}
|
|
100
|
+
scrollViewRef.current = assignedRef;
|
|
103
101
|
scrollViewAnimatedRef(assignedRef);
|
|
104
102
|
}, []);
|
|
105
103
|
const onScrollViewLayout = (0, _react.useCallback)(e => {
|
|
@@ -272,8 +270,28 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
272
270
|
syncKeyboardFrame(e);
|
|
273
271
|
}
|
|
274
272
|
}, [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame]);
|
|
273
|
+
const synchronize = (0, _react.useCallback)(async () => {
|
|
274
|
+
await update();
|
|
275
|
+
(0, _reactNativeReanimated.runOnUI)(() => {
|
|
276
|
+
"worklet";
|
|
277
|
+
|
|
278
|
+
scrollFromCurrentPosition();
|
|
279
|
+
})();
|
|
280
|
+
}, [update, scrollFromCurrentPosition]);
|
|
281
|
+
(0, _react.useImperativeHandle)(ref, () => {
|
|
282
|
+
const scrollView = scrollViewRef.current;
|
|
283
|
+
const existingMethods = scrollView ? {
|
|
284
|
+
...scrollView
|
|
285
|
+
} : {};
|
|
286
|
+
return {
|
|
287
|
+
...existingMethods,
|
|
288
|
+
assureFocusedInputVisible: () => {
|
|
289
|
+
synchronize();
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}, [synchronize]);
|
|
275
293
|
(0, _react.useEffect)(() => {
|
|
276
|
-
(
|
|
294
|
+
synchronize();
|
|
277
295
|
}, [bottomOffset]);
|
|
278
296
|
(0, _reactNativeReanimated.useAnimatedReaction)(() => input.value, (current, previous) => {
|
|
279
297
|
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)) {
|