react-native-keyboard-controller 1.20.0-beta.0 → 1.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +18 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +1 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +7 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +2 -2
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +16 -0
- package/ios/KeyboardControllerModule.mm +1 -0
- package/ios/observers/FocusedInputObserver.swift +1 -1
- package/ios/views/KeyboardControllerView.mm +11 -0
- package/ios/views/KeyboardControllerViewManager.mm +3 -0
- package/ios/views/KeyboardControllerViewManager.swift +13 -1
- package/lib/commonjs/animated.js +14 -4
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js +4 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +4 -2
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/compat.js +65 -0
- package/lib/commonjs/compat.js.map +1 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +25 -7
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/context.js +1 -0
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks/index.js +2 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +5 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/types/internal.js.map +1 -1
- package/lib/commonjs/types/module.js.map +1 -1
- package/lib/module/animated.js +16 -6
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js +3 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +3 -1
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/compat.js +58 -0
- package/lib/module/compat.js.map +1 -0
- package/lib/module/components/KeyboardAwareScrollView/index.js +26 -8
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/context.js +1 -0
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks/index.js +2 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js +4 -0
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/types/internal.js.map +1 -1
- package/lib/module/types/module.js.map +1 -1
- package/lib/typescript/bindings.d.ts +3 -0
- package/lib/typescript/bindings.native.d.ts +1 -0
- package/lib/typescript/compat.d.ts +27 -0
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -1
- package/lib/typescript/components/index.d.ts +1 -1
- package/lib/typescript/context.d.ts +2 -0
- package/lib/typescript/hooks/index.d.ts +1 -0
- package/lib/typescript/hooks/useKeyboardState/index.d.ts +3 -3
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
- package/lib/typescript/types/internal.d.ts +1 -1
- package/lib/typescript/types/module.d.ts +3 -2
- package/package.json +1 -1
- package/src/animated.tsx +32 -6
- package/src/bindings.native.ts +4 -1
- package/src/bindings.ts +5 -0
- package/src/compat.ts +61 -0
- package/src/components/KeyboardAwareScrollView/index.tsx +43 -11
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +2 -2
- package/src/components/index.ts +4 -1
- package/src/context.ts +3 -0
- package/src/hooks/index.ts +4 -1
- package/src/hooks/useKeyboardState/index.ts +4 -4
- package/src/index.ts +2 -0
- package/src/specs/KeyboardControllerViewNativeComponent.ts +11 -0
- package/src/types/internal.ts +3 -1
- package/src/types/module.ts +3 -2
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -2
- package/ios/KeyboardController.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/Tests/Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcuserdata/kirylziusko.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Tests/Tests.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +0 -32
|
@@ -86,8 +86,8 @@ export const useSmoothKeyboardHandler: typeof useKeyboardHandler = (
|
|
|
86
86
|
persistedHeight.value = height.value;
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
|
-
//
|
|
90
|
-
deps
|
|
89
|
+
// create shallow copy (if deps specified) since `useAnimatedReaction` modifies them
|
|
90
|
+
deps ? [...deps] : deps,
|
|
91
91
|
);
|
|
92
92
|
|
|
93
93
|
useKeyboardHandler(
|
package/src/components/index.ts
CHANGED
|
@@ -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 {
|
|
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,
|
package/src/hooks/index.ts
CHANGED
|
@@ -236,7 +236,10 @@ export function useKeyboardController() {
|
|
|
236
236
|
export function useReanimatedFocusedInput() {
|
|
237
237
|
const context = useKeyboardContext();
|
|
238
238
|
|
|
239
|
-
return {
|
|
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 {
|
|
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:
|
|
15
|
+
type KeyboardStateSelector<T> = (state: IKeyboardState) => T;
|
|
16
16
|
|
|
17
|
-
const defaultSelector: KeyboardStateSelector<
|
|
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 =
|
|
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>;
|
package/src/types/internal.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { EmitterSubscription } from "react-native";
|
|
2
2
|
|
|
3
|
-
export type FocusedInputAvailableEvents =
|
|
3
|
+
export type FocusedInputAvailableEvents =
|
|
4
|
+
| "focusDidSet"
|
|
5
|
+
| "layoutDidSynchronize";
|
|
4
6
|
export type FocusedInputEventData = {
|
|
5
7
|
current: number;
|
|
6
8
|
count: number;
|
package/src/types/module.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type KeyboardEventData = {
|
|
|
23
23
|
/**
|
|
24
24
|
* An object that represent current keyboard state.
|
|
25
25
|
*/
|
|
26
|
-
export type
|
|
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,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>
|
|
Binary file
|
|
@@ -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>
|