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.
Files changed (91) 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 -4
  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/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
  22. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  23. package/lib/commonjs/components/index.js.map +1 -1
  24. package/lib/commonjs/context.js +1 -0
  25. package/lib/commonjs/context.js.map +1 -1
  26. package/lib/commonjs/hooks/index.js +2 -1
  27. package/lib/commonjs/hooks/index.js.map +1 -1
  28. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
  29. package/lib/commonjs/index.js +12 -0
  30. package/lib/commonjs/index.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 -6
  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/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
  46. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  47. package/lib/module/components/index.js.map +1 -1
  48. package/lib/module/context.js +1 -0
  49. package/lib/module/context.js.map +1 -1
  50. package/lib/module/hooks/index.js +2 -1
  51. package/lib/module/hooks/index.js.map +1 -1
  52. package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
  53. package/lib/module/index.js +1 -0
  54. package/lib/module/index.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 +2 -0
  65. package/lib/typescript/hooks/index.d.ts +1 -0
  66. package/lib/typescript/hooks/useKeyboardState/index.d.ts +3 -3
  67. package/lib/typescript/index.d.ts +2 -1
  68. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
  69. package/lib/typescript/types/internal.d.ts +1 -1
  70. package/lib/typescript/types/module.d.ts +3 -2
  71. package/package.json +1 -1
  72. package/src/animated.tsx +32 -6
  73. package/src/bindings.native.ts +4 -1
  74. package/src/bindings.ts +5 -0
  75. package/src/compat.ts +61 -0
  76. package/src/components/KeyboardAwareScrollView/index.tsx +43 -11
  77. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +2 -2
  78. package/src/components/index.ts +4 -1
  79. package/src/context.ts +3 -0
  80. package/src/hooks/index.ts +4 -1
  81. package/src/hooks/useKeyboardState/index.ts +4 -4
  82. package/src/index.ts +2 -0
  83. package/src/specs/KeyboardControllerViewNativeComponent.ts +11 -0
  84. package/src/types/internal.ts +3 -1
  85. package/src/types/module.ts +3 -2
  86. package/android/.settings/org.eclipse.buildship.core.prefs +0 -2
  87. package/ios/KeyboardController.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  88. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  89. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  90. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcuserdata/kirylziusko.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  91. package/ios/Tests/Tests.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +0 -32
@@ -86,8 +86,8 @@ export const useSmoothKeyboardHandler: typeof useKeyboardHandler = (
86
86
  persistedHeight.value = height.value;
87
87
  }
88
88
  },
89
- // REA uses own version of `DependencyList` and it's not compatible with the same type from React
90
- deps as unknown[],
89
+ // create shallow copy (if deps specified) since `useAnimatedReaction` modifies them
90
+ deps ? [...deps] : deps,
91
91
  );
92
92
 
93
93
  useKeyboardHandler(
@@ -7,5 +7,8 @@ export {
7
7
  } from "./KeyboardToolbar";
8
8
  export type { KeyboardAvoidingViewProps } from "./KeyboardAvoidingView";
9
9
  export type { KeyboardStickyViewProps } from "./KeyboardStickyView";
10
- export type { KeyboardAwareScrollViewProps } from "./KeyboardAwareScrollView";
10
+ export type {
11
+ KeyboardAwareScrollViewProps,
12
+ KeyboardAwareScrollViewRef,
13
+ } from "./KeyboardAwareScrollView";
11
14
  export type { KeyboardToolbarProps } from "./KeyboardToolbar";
package/src/context.ts CHANGED
@@ -35,6 +35,8 @@ export type KeyboardAnimationContext = {
35
35
  reanimated: ReanimatedContext;
36
36
  /** Layout of the focused `TextInput` represented as `SharedValue`. */
37
37
  layout: SharedValue<FocusedInputLayoutChangedEvent | null>;
38
+ /** Method for updating info about focused input layout. */
39
+ update: () => Promise<void>;
38
40
  /** Method for setting workletized keyboard handlers. */
39
41
  setKeyboardHandlers: (
40
42
  handlers: EventHandlerProcessed<never, never>,
@@ -71,6 +73,7 @@ const defaultContext: KeyboardAnimationContext = {
71
73
  height: DEFAULT_SHARED_VALUE,
72
74
  },
73
75
  layout: DEFAULT_LAYOUT,
76
+ update: Promise.resolve,
74
77
  setKeyboardHandlers: NESTED_NOOP,
75
78
  setInputHandlers: NESTED_NOOP,
76
79
  setEnabled: NOOP,
@@ -236,7 +236,10 @@ export function useKeyboardController() {
236
236
  export function useReanimatedFocusedInput() {
237
237
  const context = useKeyboardContext();
238
238
 
239
- return { input: context.layout };
239
+ return {
240
+ input: context.layout,
241
+ update: context.update,
242
+ };
240
243
  }
241
244
 
242
245
  /**
@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
3
3
  import { KeyboardEvents } from "../../bindings";
4
4
  import { KeyboardController } from "../../module";
5
5
 
6
- import type { KeyboardState } from "../../types";
6
+ import type { IKeyboardState } from "../../types";
7
7
 
8
8
  const EVENTS = ["keyboardDidShow", "keyboardDidHide"] as const;
9
9
 
@@ -12,9 +12,9 @@ const getLatestState = () => ({
12
12
  isVisible: KeyboardController.isVisible(),
13
13
  });
14
14
 
15
- type KeyboardStateSelector<T> = (state: KeyboardState) => T;
15
+ type KeyboardStateSelector<T> = (state: IKeyboardState) => T;
16
16
 
17
- const defaultSelector: KeyboardStateSelector<KeyboardState> = (state) => state;
17
+ const defaultSelector: KeyboardStateSelector<IKeyboardState> = (state) => state;
18
18
 
19
19
  /**
20
20
  * React Hook that represents the current keyboard state on iOS and Android.
@@ -40,7 +40,7 @@ const defaultSelector: KeyboardStateSelector<KeyboardState> = (state) => state;
40
40
  * }
41
41
  * ```
42
42
  */
43
- function useKeyboardState<T = KeyboardState>(
43
+ function useKeyboardState<T = IKeyboardState>(
44
44
  selector: KeyboardStateSelector<T> = defaultSelector as KeyboardStateSelector<T>,
45
45
  ): T {
46
46
  const [state, setState] = useState<T>(() => selector(getLatestState()));
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export * from "./hooks";
5
5
  export * from "./constants";
6
6
  export * from "./module";
7
7
  export * from "./types";
8
+ export * from "./compat";
8
9
 
9
10
  export {
10
11
  KeyboardAvoidingView,
@@ -18,6 +19,7 @@ export type {
18
19
  KeyboardAvoidingViewProps,
19
20
  KeyboardStickyViewProps,
20
21
  KeyboardAwareScrollViewProps,
22
+ KeyboardAwareScrollViewRef,
21
23
  KeyboardToolbarProps,
22
24
  } from "./components";
23
25
  export { OverKeyboardView, KeyboardExtender } from "./views";
@@ -1,3 +1,4 @@
1
+ import codegenNativeCommands from "react-native/Libraries/Utilities/codegenNativeCommands";
1
2
  import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
2
3
 
3
4
  import type { HostComponent } from "react-native";
@@ -66,6 +67,16 @@ export interface NativeProps extends ViewProps {
66
67
  onFocusedInputSelectionChanged?: DirectEventHandler<FocusedInputSelectionChangedEvent>;
67
68
  }
68
69
 
70
+ interface NativeCommands {
71
+ synchronizeFocusedInputLayout: (
72
+ viewRef: React.ElementRef<HostComponent<NativeProps>>,
73
+ ) => void;
74
+ }
75
+
76
+ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
77
+ supportedCommands: ["synchronizeFocusedInputLayout"],
78
+ });
79
+
69
80
  export default codegenNativeComponent<NativeProps>("KeyboardControllerView", {
70
81
  interfaceOnly: true,
71
82
  }) as HostComponent<NativeProps>;
@@ -1,6 +1,8 @@
1
1
  import type { EmitterSubscription } from "react-native";
2
2
 
3
- export type FocusedInputAvailableEvents = "focusDidSet";
3
+ export type FocusedInputAvailableEvents =
4
+ | "focusDidSet"
5
+ | "layoutDidSynchronize";
4
6
  export type FocusedInputEventData = {
5
7
  current: number;
6
8
  count: number;
@@ -23,7 +23,7 @@ export type KeyboardEventData = {
23
23
  /**
24
24
  * An object that represent current keyboard state.
25
25
  */
26
- export type KeyboardState = {
26
+ export type IKeyboardState = {
27
27
  /** Whether the keyboard is currently visible. */
28
28
  isVisible: boolean;
29
29
  } & KeyboardEventData;
@@ -85,10 +85,11 @@ export type KeyboardControllerModule = {
85
85
  // all platforms
86
86
  /**
87
87
  * Dismisses the active keyboard. Removes a focus by default, but allows to pass `{keepFocus: true}` to keep focus.
88
+ * If you want to close keyboard immediately pass `{animated: false}`.
88
89
  *
89
90
  * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#dismiss|docs} page for more details.
90
91
  */
91
- dismiss: (options?: DismissOptions) => Promise<void>;
92
+ dismiss: (options?: Partial<DismissOptions>) => Promise<void>;
92
93
  /**
93
94
  * Moves focus to the specified direction (`next`, `prev` or `current` to restore a focus).
94
95
  *
@@ -1,2 +0,0 @@
1
- connection.project.dir=../../../android
2
- eclipse.preferences.version=1
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>SchemeUserState</key>
6
- <dict>
7
- <key>KeyboardController.xcscheme_^#shared#^_</key>
8
- <dict>
9
- <key>orderHint</key>
10
- <integer>0</integer>
11
- </dict>
12
- </dict>
13
- </dict>
14
- </plist>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Workspace
3
- version = "1.0">
4
- <FileRef
5
- location = "self:">
6
- </FileRef>
7
- </Workspace>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>IDEDidComputeMac32BitWarning</key>
6
- <true/>
7
- </dict>
8
- </plist>
@@ -1,32 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>SchemeUserState</key>
6
- <dict>
7
- <key>Tests.xcscheme_^#shared#^_</key>
8
- <dict>
9
- <key>orderHint</key>
10
- <integer>0</integer>
11
- </dict>
12
- </dict>
13
- <key>SuppressBuildableAutocreation</key>
14
- <dict>
15
- <key>083F2DF22B860D89004A1AD1</key>
16
- <dict>
17
- <key>primary</key>
18
- <true/>
19
- </dict>
20
- <key>083F2E022B860D8C004A1AD1</key>
21
- <dict>
22
- <key>primary</key>
23
- <true/>
24
- </dict>
25
- <key>083F2E0C2B860D8C004A1AD1</key>
26
- <dict>
27
- <key>primary</key>
28
- <true/>
29
- </dict>
30
- </dict>
31
- </dict>
32
- </plist>