react-native-keyboard-controller 1.19.6 → 1.20.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.
Files changed (107) hide show
  1. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +18 -0
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +1 -1
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +7 -0
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +2 -2
  5. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +16 -0
  6. package/ios/KeyboardControllerModule.mm +1 -0
  7. package/ios/observers/FocusedInputObserver.swift +1 -1
  8. package/ios/views/KeyboardControllerView.mm +11 -0
  9. package/ios/views/KeyboardControllerViewManager.mm +3 -0
  10. package/ios/views/KeyboardControllerViewManager.swift +13 -1
  11. package/lib/commonjs/animated.js +14 -5
  12. package/lib/commonjs/animated.js.map +1 -1
  13. package/lib/commonjs/bindings.js +4 -1
  14. package/lib/commonjs/bindings.js.map +1 -1
  15. package/lib/commonjs/bindings.native.js +4 -2
  16. package/lib/commonjs/bindings.native.js.map +1 -1
  17. package/lib/commonjs/compat.js +65 -0
  18. package/lib/commonjs/compat.js.map +1 -0
  19. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +25 -7
  20. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  21. package/lib/commonjs/components/index.js.map +1 -1
  22. package/lib/commonjs/context.js +1 -0
  23. package/lib/commonjs/context.js.map +1 -1
  24. package/lib/commonjs/hooks/index.js +43 -3
  25. package/lib/commonjs/hooks/index.js.map +1 -1
  26. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
  27. package/lib/commonjs/index.js +12 -0
  28. package/lib/commonjs/index.js.map +1 -1
  29. package/lib/commonjs/internal.js +16 -16
  30. package/lib/commonjs/internal.js.map +1 -1
  31. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +5 -1
  32. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  33. package/lib/commonjs/types/internal.js.map +1 -1
  34. package/lib/commonjs/types/module.js.map +1 -1
  35. package/lib/module/animated.js +16 -7
  36. package/lib/module/animated.js.map +1 -1
  37. package/lib/module/bindings.js +3 -0
  38. package/lib/module/bindings.js.map +1 -1
  39. package/lib/module/bindings.native.js +3 -1
  40. package/lib/module/bindings.native.js.map +1 -1
  41. package/lib/module/compat.js +58 -0
  42. package/lib/module/compat.js.map +1 -0
  43. package/lib/module/components/KeyboardAwareScrollView/index.js +26 -8
  44. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  45. package/lib/module/components/index.js.map +1 -1
  46. package/lib/module/context.js +1 -0
  47. package/lib/module/context.js.map +1 -1
  48. package/lib/module/hooks/index.js +43 -3
  49. package/lib/module/hooks/index.js.map +1 -1
  50. package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
  51. package/lib/module/index.js +1 -0
  52. package/lib/module/index.js.map +1 -1
  53. package/lib/module/internal.js +16 -16
  54. package/lib/module/internal.js.map +1 -1
  55. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +4 -0
  56. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  57. package/lib/module/types/internal.js.map +1 -1
  58. package/lib/module/types/module.js.map +1 -1
  59. package/lib/typescript/bindings.d.ts +3 -0
  60. package/lib/typescript/bindings.native.d.ts +1 -0
  61. package/lib/typescript/compat.d.ts +27 -0
  62. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -1
  63. package/lib/typescript/components/index.d.ts +1 -1
  64. package/lib/typescript/context.d.ts +6 -4
  65. package/lib/typescript/hooks/index.d.ts +4 -4
  66. package/lib/typescript/hooks/useKeyboardState/index.d.ts +3 -3
  67. package/lib/typescript/index.d.ts +2 -1
  68. package/lib/typescript/internal.d.ts +2 -3
  69. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
  70. package/lib/typescript/types/internal.d.ts +1 -1
  71. package/lib/typescript/types/module.d.ts +3 -2
  72. package/package.json +1 -1
  73. package/src/animated.tsx +32 -15
  74. package/src/bindings.native.ts +4 -1
  75. package/src/bindings.ts +5 -0
  76. package/src/compat.ts +61 -0
  77. package/src/components/KeyboardAwareScrollView/index.tsx +43 -11
  78. package/src/components/index.ts +4 -1
  79. package/src/context.ts +14 -8
  80. package/src/hooks/index.ts +68 -11
  81. package/src/hooks/useKeyboardState/index.ts +4 -4
  82. package/src/index.ts +2 -0
  83. package/src/internal.ts +33 -30
  84. package/src/specs/KeyboardControllerViewNativeComponent.ts +11 -0
  85. package/src/types/internal.ts +3 -1
  86. package/src/types/module.ts +3 -2
  87. package/lib/commonjs/event-handler.d.js +0 -6
  88. package/lib/commonjs/event-handler.d.js.map +0 -1
  89. package/lib/commonjs/event-handler.js +0 -19
  90. package/lib/commonjs/event-handler.js.map +0 -1
  91. package/lib/commonjs/event-handler.web.js +0 -10
  92. package/lib/commonjs/event-handler.web.js.map +0 -1
  93. package/lib/commonjs/event-mappings.js +0 -9
  94. package/lib/commonjs/event-mappings.js.map +0 -1
  95. package/lib/module/event-handler.d.js +0 -2
  96. package/lib/module/event-handler.d.js.map +0 -1
  97. package/lib/module/event-handler.js +0 -14
  98. package/lib/module/event-handler.js.map +0 -1
  99. package/lib/module/event-handler.web.js +0 -5
  100. package/lib/module/event-handler.web.js.map +0 -1
  101. package/lib/module/event-mappings.js +0 -3
  102. package/lib/module/event-mappings.js.map +0 -1
  103. package/lib/typescript/event-mappings.d.ts +0 -2
  104. package/src/event-handler.d.ts +0 -8
  105. package/src/event-handler.js +0 -15
  106. package/src/event-handler.web.js +0 -5
  107. package/src/event-mappings.ts +0 -14
@@ -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
- private var layoutObserver: FocusedInputObserver? = null
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,
@@ -38,7 +38,7 @@ object EdgeToEdgeViewRegistry {
38
38
  @Suppress("detekt:TooManyFunctions")
39
39
  @SuppressLint("ViewConstructor")
40
40
  class EdgeToEdgeReactViewGroup(
41
- private val reactContext: ThemedReactContext,
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
- private var callback: KeyboardAnimationCallback? = null
61
+ internal var callback: KeyboardAnimationCallback? = null
62
62
  private val config =
63
63
  KeyboardAnimationCallbackConfig(
64
64
  persistentInsetTypes = WindowInsetsCompat.Type.systemBars(),
@@ -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
- private var inputObserver: FocusedInputObserver?
27
+ var inputObserver: FocusedInputObserver?
16
28
  private var eventDispatcher: RCTEventDispatcherProtocol
17
29
  private var bridge: RCTBridge
18
30
  // internal state
@@ -10,7 +10,6 @@ var _reactNativeIsEdgeToEdge = require("react-native-is-edge-to-edge");
10
10
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
11
11
  var _bindings = require("./bindings");
12
12
  var _context = require("./context");
13
- var _eventMappings = require("./event-mappings");
14
13
  var _internal = require("./internal");
15
14
  var _module = require("./module");
16
15
  var _reanimated = require("./reanimated");
@@ -56,7 +55,7 @@ const KeyboardProvider = props => {
56
55
  preload = true
57
56
  } = props;
58
57
  // ref
59
- const viewTagRef = (0, _react.useRef)(null);
58
+ const viewRef = (0, _react.useRef)(null);
60
59
  // state
61
60
  const [enabled, setEnabled] = (0, _react.useState)(initiallyEnabled);
62
61
  // animated values
@@ -66,8 +65,17 @@ const KeyboardProvider = props => {
66
65
  const progressSV = (0, _reactNativeReanimated.useSharedValue)(0);
67
66
  const heightSV = (0, _reactNativeReanimated.useSharedValue)(0);
68
67
  const layout = (0, _reactNativeReanimated.useSharedValue)(null);
69
- const setKeyboardHandlers = (0, _internal.useEventHandlerRegistration)(_eventMappings.keyboardEventsMap, viewTagRef);
70
- const setInputHandlers = (0, _internal.useEventHandlerRegistration)(_eventMappings.focusedInputEventsMap, viewTagRef);
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
+ }, []);
71
79
  // memo
72
80
  const context = (0, _react.useMemo)(() => ({
73
81
  enabled,
@@ -80,6 +88,7 @@ const KeyboardProvider = props => {
80
88
  height: heightSV
81
89
  },
82
90
  layout,
91
+ update,
83
92
  setKeyboardHandlers,
84
93
  setInputHandlers,
85
94
  setEnabled
@@ -159,7 +168,7 @@ const KeyboardProvider = props => {
159
168
  return /*#__PURE__*/_react.default.createElement(_context.KeyboardContext.Provider, {
160
169
  value: context
161
170
  }, /*#__PURE__*/_react.default.createElement(KeyboardControllerViewAnimated, {
162
- ref: viewTagRef,
171
+ ref: viewRef,
163
172
  enabled: enabled,
164
173
  navigationBarTranslucent: IS_EDGE_TO_EDGE || navigationBarTranslucent,
165
174
  statusBarTranslucent: IS_EDGE_TO_EDGE || statusBarTranslucent,
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeIsEdgeToEdge","_reactNativeReanimated","_bindings","_context","_eventMappings","_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","keyboardEventsMap","setInputHandlers","focusedInputEventsMap","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 { focusedInputEventsMap, keyboardEventsMap } from \"./event-mappings\";\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 FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\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<KeyboardHandler>(\n keyboardEventsMap,\n viewTagRef,\n );\n const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(\n focusedInputEventsMap,\n viewTagRef,\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 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,SAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AAGsB,SAAAD,wBAAAW,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAW,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,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AEb,IAAI6C,OAAO,EAAE;IACX,IAAAC,gDAAuB,EAAC;MACtBnD,oBAAoB;MACpBC,wBAAwB;MACxBC;IACF,CAAC,CAAC;EACJ;EAEA,oBACErD,MAAA,CAAAsB,OAAA,CAAAiF,aAAA,CAAChG,QAAA,CAAAiG,eAAe,CAACC,QAAQ;IAAChB,KAAK,EAAEhB;EAAQ,gBACvCzE,MAAA,CAAAsB,OAAA,CAAAiF,aAAA,CAACtE,8BAA8B;IAC7ByE,GAAG,EAAEjD,UAAW;IAChBH,OAAO,EAAEA,OAAQ;IACjBF,wBAAwB,EAAErB,eAAe,IAAIqB,wBAAyB;IACtED,oBAAoB,EAAEpB,eAAe,IAAIoB,oBAAqB;IAC9DE,kBAAkB,EAAEtB,eAAe,IAAIsB,kBAAmB;IAC1DyB,KAAK,EAAExC,MAAM,CAACG;IACd;IAAA;IACAkE,wBAAwB,EAAEjB,eAAgB;IAC1CE,mBAAmB,EAAE9C,EAAE,KAAK,KAAK,GAAGoC,cAAc,GAAG0B,SAAU;IAC/D1B,cAAc,EAAEpC,EAAE,KAAK,SAAS,GAAGoC,cAAc,GAAG0B,SAAU;IAC9Df,yBAAyB,EAAEX,cAAe;IAC1CY,iBAAiB,EAAEhD,EAAE,KAAK,SAAS,GAAGoC,cAAc,GAAG0B,SAAU;IACjEC,qCAAqC,EAAEd;EAAmB,GAEzD7C,QAC6B,CAAC,eACjClD,MAAA,CAAAsB,OAAA,CAAAiF,aAAA,CAACpG,YAAA,CAAAiC,QAAQ,CAAC0E,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAhC,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAACiC,OAAA,CAAA/D,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};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AAIA,IAAAG,sBAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAEA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAGsB,SAAAD,wBAAAU,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAU,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,C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E7C,EAAE,KAAK,SAAS,GAAG6C,cAAc,GAAG0B,SAAU;IAC9Df,yBAAyB,EAAEX,cAAe;IAC1CY,iBAAiB,EAAEzD,EAAE,KAAK,SAAS,GAAG6C,cAAc,GAAG0B,SAAU;IACjEC,qCAAqC,EAAEd;EAAmB,GAEzDtD,QAC6B,CAAC,eACjCjD,MAAA,CAAAqB,OAAA,CAAA0F,aAAA,CAAC5G,YAAA,CAAAgC,QAAQ,CAACmF,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAhC,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAACiC,OAAA,CAAAxE,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -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;AACtD;AACA;AACA;AACA;AACA;AACO,MAAMC,mBAAmB,GAAAd,OAAA,CAAAc,mBAAA,GAC9BD,iBAAqD;AAChD,MAAME,mBAAmB,GAAAf,OAAA,CAAAe,mBAAA,GAC9BF,iBAAkD;AACpD;AACA;AACA;AACA;AACA;AACO,MAAMG,sBAAsB,GAAAhB,OAAA,CAAAgB,sBAAA,GACjCH,iBAAwD;AAC1D;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,mBAAmB,GAAAjB,OAAA,CAAAiB,mBAAA,GAC9BJ,iBAAkD","ignoreList":[]}
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 RCTKeyboardExt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MM,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 = require("./specs/KeyboardControllerViewNativeComponent").default;
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 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,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,qBAAqB,GACzBN,OAAO,CAAC,kCAAkC,CAAC,CAACK,OAAO;AAE9C,MAAME,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GACnCD,qBA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AA,GAC/D1B,OAAO,CAAC,yCAAyC,CAAC,CAACK,OAAO;AACrD,MAAMsB,sBAA6D,GAAAnB,OAAA,CAAAmB,sBAAA,GACxE3B,OAAO,CAAC,+CAA+C,CAAC,CAACK,OAAO;AAC3D,MAAMuB,mBAAoD,GAAApB,OAAA,CAAAoB,mBAAA,GAC/D1B,qBAAQ,CAACqB,EAAE,KAAK,KAAK,GACjBvB,OAAO,CAAC,yCAAyC,CAAC,CAACK,OAAO,GAC1D,CAAC;EAAEoB;AAAgC,CAAC,KAAKA,QAAQ","ignoreList":[]}
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,CA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8BAAA,GACzCjB,2CAA2C,CAACkB,QAAQ;AAC/C,MAAMC,mBAAuD,GAAAhB,OAAA,CAAAgB,mBAAA,GACjEvB,qBAAQ,CAACwB,EAAE,KAAK,SAAS,IAAIxB,qBAAQ,CAACyB,OAAO,IAAI,EAAE,IAAKzB,qBAAQ,CAACwB,EAAE,KAAK,KAAK,GAC1E1B,OAAO,CAAC,4CAA4C,CAAC,CAACK,OAAO,GAC7D,CAAC;EAAEuB;AAAmC,CAAC,KAAKA,QAAQ;AACnD,MAAMC,mBAAoD,GAAApB,OAAA,CAAAoB,mBAAA,GAC/D7B,OAAO,CAAC,yCAAyC,CAAC,CAACK,OAAO;AACrD,MAAMyB,sBAA6D,GAAArB,OAAA,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
- if (typeof ref === "function") {
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
- (0, _reactNativeReanimated.runOnUI)(performScrollWithPositionRestoration)(scrollBeforeKeyboardMovement.value);
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)) {