react-native-keyboard-controller 1.16.7 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +2 -8
  2. package/android/src/fabric/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt +11 -0
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardViewGroup.kt +17 -0
  4. package/android/src/main/jni/CMakeLists.txt +85 -0
  5. package/android/src/main/jni/reactnativekeyboardcontroller.h +23 -0
  6. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewComponentDescriptor.h +21 -0
  7. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewShadowNode.cpp +7 -0
  8. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewShadowNode.h +23 -0
  9. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardControllerViewState.h +21 -0
  10. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaComponentDescriptor.h +20 -0
  11. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaShadowNode.cpp +7 -0
  12. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaShadowNode.h +23 -0
  13. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardGestureAreaState.h +21 -0
  14. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewComponentDescriptor.h +31 -0
  15. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewShadowNode.cpp +7 -0
  16. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewShadowNode.h +23 -0
  17. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewState.cpp +12 -0
  18. package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCOverKeyboardViewState.h +43 -0
  19. package/ios/KeyboardController-Bridging-Header.h +0 -1
  20. package/ios/objc/{RCTUITextView+DelegateManager.h → UITextView+DelegateManager.h} +2 -4
  21. package/ios/objc/{RCTUITextView+DelegateManager.m → UITextView+DelegateManager.m} +3 -3
  22. package/ios/observers/FocusedInputObserver.swift +2 -2
  23. package/ios/views/KeyboardControllerView.mm +1 -1
  24. package/ios/views/KeyboardGestureAreaManager.mm +1 -1
  25. package/ios/views/OverKeyboardViewManager.mm +1 -1
  26. package/jest/index.js +14 -1
  27. package/lib/commonjs/components/KeyboardAvoidingView/index.js +2 -2
  28. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  29. package/lib/commonjs/components/KeyboardStickyView/index.js +12 -12
  30. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  31. package/lib/commonjs/components/KeyboardToolbar/index.js +18 -8
  32. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  33. package/lib/commonjs/hooks/index.js +12 -0
  34. package/lib/commonjs/hooks/index.js.map +1 -1
  35. package/lib/commonjs/hooks/useKeyboardState/index.js +34 -0
  36. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -0
  37. package/lib/commonjs/module.js +12 -5
  38. package/lib/commonjs/module.js.map +1 -1
  39. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +3 -1
  40. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  41. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +3 -1
  42. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  43. package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js +3 -1
  44. package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -1
  45. package/lib/commonjs/types.js.map +1 -1
  46. package/lib/commonjs/views/OverKeyboardView/index.js +10 -4
  47. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
  48. package/lib/module/components/KeyboardAvoidingView/index.js +2 -2
  49. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  50. package/lib/module/components/KeyboardStickyView/index.js +13 -13
  51. package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
  52. package/lib/module/components/KeyboardToolbar/index.js +18 -8
  53. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  54. package/lib/module/hooks/index.js +1 -0
  55. package/lib/module/hooks/index.js.map +1 -1
  56. package/lib/module/hooks/useKeyboardState/index.js +27 -0
  57. package/lib/module/hooks/useKeyboardState/index.js.map +1 -0
  58. package/lib/module/module.js +12 -5
  59. package/lib/module/module.js.map +1 -1
  60. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +3 -1
  61. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  62. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +3 -1
  63. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
  64. package/lib/module/specs/OverKeyboardViewNativeComponent.js +3 -1
  65. package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -1
  66. package/lib/module/types.js.map +1 -1
  67. package/lib/module/views/OverKeyboardView/index.js +10 -4
  68. package/lib/module/views/OverKeyboardView/index.js.map +1 -1
  69. package/lib/typescript/components/KeyboardToolbar/index.d.ts +5 -0
  70. package/lib/typescript/hooks/index.d.ts +1 -0
  71. package/lib/typescript/hooks/useKeyboardState/index.d.ts +2 -0
  72. package/lib/typescript/types.d.ts +4 -1
  73. package/package.json +4 -1
  74. package/react-native-keyboard-controller.podspec +8 -0
  75. package/react-native.config.js +14 -0
  76. package/src/components/KeyboardAvoidingView/index.tsx +14 -7
  77. package/src/components/KeyboardStickyView/index.tsx +18 -17
  78. package/src/components/KeyboardToolbar/index.tsx +36 -19
  79. package/src/hooks/index.ts +1 -0
  80. package/src/hooks/useKeyboardState/index.ts +38 -0
  81. package/src/module.ts +12 -5
  82. package/src/specs/KeyboardControllerViewNativeComponent.ts +3 -3
  83. package/src/specs/KeyboardGestureAreaNativeComponent.ts +3 -3
  84. package/src/specs/OverKeyboardViewNativeComponent.ts +3 -3
  85. package/src/types.ts +4 -1
  86. package/src/views/OverKeyboardView/index.tsx +11 -4
  87. package/lib/commonjs/architecture.js +0 -8
  88. package/lib/commonjs/architecture.js.map +0 -1
  89. package/lib/module/architecture.js +0 -2
  90. package/lib/module/architecture.js.map +0 -1
  91. package/lib/typescript/architecture.d.ts +0 -1
  92. package/src/architecture.ts +0 -1
@@ -15,3 +15,4 @@ export declare function useReanimatedFocusedInput(): {
15
15
  };
16
16
  export declare function useFocusedInputHandler(handler: FocusedInputHandler, deps?: DependencyList): void;
17
17
  export * from "./useWindowDimensions";
18
+ export * from "./useKeyboardState";
@@ -0,0 +1,2 @@
1
+ import type { KeyboardState } from "../../types";
2
+ export declare const useKeyboardState: () => KeyboardState;
@@ -92,7 +92,7 @@ export type KeyboardControllerModule = {
92
92
  dismiss: (options?: DismissOptions) => Promise<void>;
93
93
  setFocusTo: (direction: Direction) => void;
94
94
  isVisible: () => boolean;
95
- state: () => KeyboardEventData | null;
95
+ state: () => KeyboardEventData;
96
96
  };
97
97
  export type KeyboardControllerNativeModule = {
98
98
  setDefaultMode: () => void;
@@ -111,6 +111,9 @@ export type KeyboardEventData = {
111
111
  type: NonNullable<TextInputProps["keyboardType"]>;
112
112
  appearance: NonNullable<TextInputProps["keyboardAppearance"]>;
113
113
  };
114
+ export type KeyboardState = {
115
+ isVisible: boolean;
116
+ } & KeyboardEventData;
114
117
  export type KeyboardEventsModule = {
115
118
  addListener: (name: KeyboardControllerEvents, cb: (e: KeyboardEventData) => void) => EmitterSubscription;
116
119
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.16.7",
3
+ "version": "1.17.0",
4
4
  "description": "Keyboard manager which works in identical way on both iOS and Android",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -12,10 +12,13 @@
12
12
  "lib",
13
13
  "android",
14
14
  "ios",
15
+ "common",
15
16
  "cpp",
16
17
  "react-native-keyboard-controller.podspec",
18
+ "react-native.config.js",
17
19
  "jest",
18
20
  "!lib/typescript/example",
21
+ "!android/detekt.yml",
19
22
  "!android/build",
20
23
  "!android/src/test",
21
24
  "!android/.gradle",
@@ -58,4 +58,12 @@ Pod::Spec.new do |s|
58
58
  s.dependency "ReactCommon/turbomodule/core"
59
59
  end
60
60
  end
61
+ if new_arch_enabled
62
+ s.subspec "common" do |ss|
63
+ ss.source_files = ["common/cpp/**/*.{cpp,h}"]
64
+ ss.header_dir = "react/renderer/components/reactnativekeyboardcontroller"
65
+ ss.private_header_files = "common/cpp/**/*.{h}"
66
+ ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" }
67
+ end
68
+ end
61
69
  end
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ android: {
5
+ componentDescriptors: [
6
+ "KeyboardControllerViewComponentDescriptor",
7
+ "KeyboardGestureAreaComponentDescriptor",
8
+ "OverKeyboardViewComponentDescriptor",
9
+ ],
10
+ cmakeListsPath: "../android/src/main/jni/CMakeLists.txt",
11
+ },
12
+ },
13
+ },
14
+ };
@@ -106,14 +106,21 @@ const KeyboardAvoidingView = forwardRef<
106
106
  [relativeKeyboardHeight],
107
107
  );
108
108
 
109
- const onLayoutWorklet = useCallback((layout: LayoutRectangle) => {
110
- "worklet";
109
+ const onLayoutWorklet = useCallback(
110
+ (layout: LayoutRectangle) => {
111
+ "worklet";
111
112
 
112
- if (keyboard.isClosed.value || initialFrame.value === null) {
113
- // eslint-disable-next-line react-compiler/react-compiler
114
- initialFrame.value = layout;
115
- }
116
- }, []);
113
+ if (
114
+ keyboard.isClosed.value ||
115
+ initialFrame.value === null ||
116
+ behavior !== "height"
117
+ ) {
118
+ // eslint-disable-next-line react-compiler/react-compiler
119
+ initialFrame.value = layout;
120
+ }
121
+ },
122
+ [behavior],
123
+ );
117
124
  const onLayout = useCallback<NonNullable<ViewProps["onLayout"]>>(
118
125
  (e) => {
119
126
  runOnUI(onLayoutWorklet)(e.nativeEvent.layout);
@@ -1,10 +1,7 @@
1
1
  import React, { forwardRef, useMemo } from "react";
2
- import Reanimated, {
3
- interpolate,
4
- useAnimatedStyle,
5
- } from "react-native-reanimated";
2
+ import { Animated } from "react-native";
6
3
 
7
- import { useReanimatedKeyboardAnimation } from "../../hooks";
4
+ import { useKeyboardAnimation } from "../../hooks";
8
5
 
9
6
  import type { View, ViewProps } from "react-native";
10
7
 
@@ -41,25 +38,29 @@ const KeyboardStickyView = forwardRef<
41
38
  },
42
39
  ref,
43
40
  ) => {
44
- const { height, progress } = useReanimatedKeyboardAnimation();
41
+ const { height, progress } = useKeyboardAnimation();
45
42
 
46
- const stickyViewStyle = useAnimatedStyle(() => {
47
- const offset = interpolate(progress.value, [0, 1], [closed, opened]);
48
-
49
- return {
50
- transform: [{ translateY: enabled ? height.value + offset : closed }],
51
- };
52
- }, [closed, opened, enabled]);
43
+ const offset = progress.interpolate({
44
+ inputRange: [0, 1],
45
+ outputRange: [closed, opened],
46
+ });
53
47
 
54
48
  const styles = useMemo(
55
- () => [style, stickyViewStyle],
56
- [style, stickyViewStyle],
49
+ () => [
50
+ {
51
+ transform: [
52
+ { translateY: enabled ? Animated.add(height, offset) : closed },
53
+ ],
54
+ },
55
+ style,
56
+ ],
57
+ [closed, enabled, height, offset, style],
57
58
  );
58
59
 
59
60
  return (
60
- <Reanimated.View ref={ref} style={styles} {...props}>
61
+ <Animated.View ref={ref} style={styles} {...props}>
61
62
  {children}
62
- </Reanimated.View>
63
+ </Animated.View>
63
64
  );
64
65
  },
65
66
  );
@@ -15,6 +15,11 @@ import type { KeyboardStickyViewProps } from "../KeyboardStickyView";
15
15
  import type { ReactNode } from "react";
16
16
  import type { GestureResponderEvent, ViewProps } from "react-native";
17
17
 
18
+ type SafeAreaInsets = {
19
+ left: number;
20
+ right: number;
21
+ };
22
+
18
23
  export type KeyboardToolbarProps = Omit<
19
24
  ViewProps,
20
25
  "style" | "testID" | "children"
@@ -54,6 +59,7 @@ export type KeyboardToolbarProps = Omit<
54
59
  * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.
55
60
  */
56
61
  opacity?: HEX;
62
+ insets?: SafeAreaInsets;
57
63
  } & Pick<KeyboardStickyViewProps, "offset" | "enabled">;
58
64
 
59
65
  const TEST_ID_KEYBOARD_TOOLBAR = "keyboard.toolbar";
@@ -72,7 +78,7 @@ const DEFAULT_OPACITY: HEX = "FF";
72
78
  const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
73
79
  content,
74
80
  theme = colors,
75
- doneText,
81
+ doneText = "Done",
76
82
  button,
77
83
  icon,
78
84
  showArrows = true,
@@ -83,6 +89,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
83
89
  opacity = DEFAULT_OPACITY,
84
90
  offset: { closed = 0, opened = 0 } = {},
85
91
  enabled = true,
92
+ insets,
86
93
  ...rest
87
94
  }) => {
88
95
  const colorScheme = useColorScheme();
@@ -110,8 +117,12 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
110
117
  {
111
118
  backgroundColor: `${theme[colorScheme].background}${opacity}`,
112
119
  },
120
+ {
121
+ paddingLeft: insets?.left,
122
+ paddingRight: insets?.right,
123
+ },
113
124
  ],
114
- [colorScheme, opacity, theme],
125
+ [colorScheme, opacity, theme, insets],
115
126
  );
116
127
  const offset = useMemo(
117
128
  () => ({ closed: closed + KEYBOARD_TOOLBAR_HEIGHT, opened }),
@@ -156,7 +167,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
156
167
  <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>
157
168
  {blur}
158
169
  {showArrows && (
159
- <>
170
+ <View style={styles.arrows}>
160
171
  <ButtonContainer
161
172
  accessibilityHint="Moves focus to the previous field"
162
173
  accessibilityLabel="Previous"
@@ -185,25 +196,27 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
185
196
  type="next"
186
197
  />
187
198
  </ButtonContainer>
188
- </>
199
+ </View>
189
200
  )}
190
201
 
191
202
  <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>
192
203
  {content}
193
204
  </View>
194
- <ButtonContainer
195
- accessibilityHint="Closes the keyboard"
196
- accessibilityLabel="Done"
197
- rippleRadius={28}
198
- style={styles.doneButtonContainer}
199
- testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}
200
- theme={theme}
201
- onPress={onPressDone}
202
- >
203
- <Text maxFontSizeMultiplier={1.3} style={doneStyle}>
204
- {doneText || "Done"}
205
- </Text>
206
- </ButtonContainer>
205
+ {doneText && (
206
+ <ButtonContainer
207
+ accessibilityHint="Closes the keyboard"
208
+ accessibilityLabel="Done"
209
+ rippleRadius={28}
210
+ style={styles.doneButtonContainer}
211
+ testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}
212
+ theme={theme}
213
+ onPress={onPressDone}
214
+ >
215
+ <Text maxFontSizeMultiplier={1.3} style={doneStyle}>
216
+ {doneText}
217
+ </Text>
218
+ </ButtonContainer>
219
+ )}
207
220
  </View>
208
221
  </KeyboardStickyView>
209
222
  );
@@ -220,14 +233,18 @@ const styles = StyleSheet.create({
220
233
  width: "100%",
221
234
  flexDirection: "row",
222
235
  height: KEYBOARD_TOOLBAR_HEIGHT,
223
- paddingHorizontal: 8,
236
+ },
237
+ arrows: {
238
+ flexDirection: "row",
239
+ paddingLeft: 8,
224
240
  },
225
241
  doneButton: {
226
242
  fontWeight: "600",
227
243
  fontSize: 15,
228
244
  },
229
245
  doneButtonContainer: {
230
- marginRight: 8,
246
+ marginRight: 16,
247
+ marginLeft: 8,
231
248
  },
232
249
  });
233
250
 
@@ -79,3 +79,4 @@ export function useFocusedInputHandler(
79
79
  }
80
80
 
81
81
  export * from "./useWindowDimensions";
82
+ export * from "./useKeyboardState";
@@ -0,0 +1,38 @@
1
+ import { useEffect, useState } from "react";
2
+
3
+ import { KeyboardEvents } from "../../bindings";
4
+ import { KeyboardController } from "../../module";
5
+
6
+ import type { KeyboardState } from "../../types";
7
+
8
+ const EVENTS = ["keyboardDidShow", "keyboardDidHide"] as const;
9
+
10
+ const getLatestState = () => ({
11
+ ...KeyboardController.state(),
12
+ isVisible: KeyboardController.isVisible(),
13
+ });
14
+
15
+ export const useKeyboardState = (): KeyboardState => {
16
+ const [state, setState] = useState(getLatestState);
17
+
18
+ useEffect(() => {
19
+ const subscriptions = EVENTS.map((event) =>
20
+ KeyboardEvents.addListener(event, () =>
21
+ // state will be updated by global listener first,
22
+ // so we simply read it and don't derive data from the event
23
+ setState(getLatestState),
24
+ ),
25
+ );
26
+
27
+ // we might have missed an update between reading a value in render and
28
+ // `addListener` in this handler, so we set it here. If there was
29
+ // no change, React will filter out this update as a no-op.
30
+ setState(getLatestState);
31
+
32
+ return () => {
33
+ subscriptions.forEach((subscription) => subscription.remove());
34
+ };
35
+ }, []);
36
+
37
+ return state;
38
+ };
package/src/module.ts CHANGED
@@ -6,17 +6,24 @@ import type {
6
6
  KeyboardEventData,
7
7
  } from "./types";
8
8
 
9
- let isClosed = false;
10
- let lastEvent: KeyboardEventData | null = null;
9
+ let isClosed = true;
10
+ let lastState: KeyboardEventData = {
11
+ height: 0,
12
+ duration: 0,
13
+ timestamp: new Date().getTime(),
14
+ target: -1,
15
+ type: "default",
16
+ appearance: "default",
17
+ };
11
18
 
12
19
  KeyboardEvents.addListener("keyboardDidHide", (e) => {
13
20
  isClosed = true;
14
- lastEvent = e;
21
+ lastState = e;
15
22
  });
16
23
 
17
24
  KeyboardEvents.addListener("keyboardDidShow", (e) => {
18
25
  isClosed = false;
19
- lastEvent = e;
26
+ lastState = e;
20
27
  });
21
28
 
22
29
  const dismiss = async (options?: DismissOptions): Promise<void> => {
@@ -38,7 +45,7 @@ const dismiss = async (options?: DismissOptions): Promise<void> => {
38
45
  });
39
46
  };
40
47
  const isVisible = () => !isClosed;
41
- const state = () => lastEvent;
48
+ const state = () => lastState;
42
49
 
43
50
  export const KeyboardController: KeyboardControllerModule = {
44
51
  setDefaultMode: KeyboardControllerNative.setDefaultMode,
@@ -66,6 +66,6 @@ export interface NativeProps extends ViewProps {
66
66
  onFocusedInputSelectionChanged?: DirectEventHandler<FocusedInputSelectionChangedEvent>;
67
67
  }
68
68
 
69
- export default codegenNativeComponent<NativeProps>(
70
- "KeyboardControllerView",
71
- ) as HostComponent<NativeProps>;
69
+ export default codegenNativeComponent<NativeProps>("KeyboardControllerView", {
70
+ interfaceOnly: true,
71
+ }) as HostComponent<NativeProps>;
@@ -15,6 +15,6 @@ export interface NativeProps extends ViewProps {
15
15
  textInputNativeID?: string;
16
16
  }
17
17
 
18
- export default codegenNativeComponent<NativeProps>(
19
- "KeyboardGestureArea",
20
- ) as HostComponent<NativeProps>;
18
+ export default codegenNativeComponent<NativeProps>("KeyboardGestureArea", {
19
+ interfaceOnly: true,
20
+ }) as HostComponent<NativeProps>;
@@ -7,6 +7,6 @@ export interface NativeProps extends ViewProps {
7
7
  visible?: boolean;
8
8
  }
9
9
 
10
- export default codegenNativeComponent<NativeProps>(
11
- "OverKeyboardView",
12
- ) as HostComponent<NativeProps>;
10
+ export default codegenNativeComponent<NativeProps>("OverKeyboardView", {
11
+ interfaceOnly: true,
12
+ }) as HostComponent<NativeProps>;
package/src/types.ts CHANGED
@@ -131,7 +131,7 @@ export type KeyboardControllerModule = {
131
131
  dismiss: (options?: DismissOptions) => Promise<void>;
132
132
  setFocusTo: (direction: Direction) => void;
133
133
  isVisible: () => boolean;
134
- state: () => KeyboardEventData | null;
134
+ state: () => KeyboardEventData;
135
135
  };
136
136
  export type KeyboardControllerNativeModule = {
137
137
  // android only
@@ -159,6 +159,9 @@ export type KeyboardEventData = {
159
159
  type: NonNullable<TextInputProps["keyboardType"]>;
160
160
  appearance: NonNullable<TextInputProps["keyboardAppearance"]>;
161
161
  };
162
+ export type KeyboardState = {
163
+ isVisible: boolean;
164
+ } & KeyboardEventData;
162
165
  export type KeyboardEventsModule = {
163
166
  addListener: (
164
167
  name: KeyboardControllerEvents,
@@ -1,7 +1,6 @@
1
1
  import React, { useMemo } from "react";
2
2
  import { Platform, StyleSheet, View } from "react-native";
3
3
 
4
- import { IS_FABRIC } from "../../architecture";
5
4
  import { RCTOverKeyboardView } from "../../bindings";
6
5
  import { useWindowDimensions } from "../../hooks";
7
6
 
@@ -18,8 +17,9 @@ const OverKeyboardView = ({
18
17
  () => [
19
18
  styles.absolute,
20
19
  // On iOS - stretch view to full window dimensions to make yoga work
21
- // On Android Fabric we temporarily use the same approach
22
- Platform.OS === "ios" || IS_FABRIC ? inner : undefined,
20
+ Platform.OS === "ios" ? inner : undefined,
21
+ // On Android - we are laid out by ShadowNode, so just stretch to full container
22
+ Platform.OS === "android" ? styles.stretch : undefined,
23
23
  ],
24
24
  [inner],
25
25
  );
@@ -28,7 +28,8 @@ const OverKeyboardView = ({
28
28
  <RCTOverKeyboardView visible={visible}>
29
29
  {/* `OverKeyboardView` should always have a single child */}
30
30
  <View collapsable={false} style={style}>
31
- {children}
31
+ {/* Match RN behavior and trigger mount/unmount when visibility changes */}
32
+ {visible && children}
32
33
  </View>
33
34
  </RCTOverKeyboardView>
34
35
  );
@@ -38,6 +39,12 @@ const styles = StyleSheet.create({
38
39
  absolute: {
39
40
  position: "absolute",
40
41
  },
42
+ stretch: {
43
+ top: 0,
44
+ bottom: 0,
45
+ left: 0,
46
+ right: 0,
47
+ },
41
48
  });
42
49
 
43
50
  export default OverKeyboardView;
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.IS_FABRIC = void 0;
7
- const IS_FABRIC = exports.IS_FABRIC = "nativeFabricUIManager" in global;
8
- //# sourceMappingURL=architecture.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["IS_FABRIC","exports","global"],"sources":["architecture.ts"],"sourcesContent":["export const IS_FABRIC = \"nativeFabricUIManager\" in global;\n"],"mappings":";;;;;;AAAO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,uBAAuB,IAAIE,MAAM","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export const IS_FABRIC = "nativeFabricUIManager" in global;
2
- //# sourceMappingURL=architecture.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["IS_FABRIC","global"],"sources":["architecture.ts"],"sourcesContent":["export const IS_FABRIC = \"nativeFabricUIManager\" in global;\n"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAG,uBAAuB,IAAIC,MAAM","ignoreList":[]}
@@ -1 +0,0 @@
1
- export declare const IS_FABRIC: boolean;
@@ -1 +0,0 @@
1
- export const IS_FABRIC = "nativeFabricUIManager" in global;