react-native-keyboard-controller 1.14.3 → 1.14.5
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/react-native-helpers.gradle +5 -11
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/JSPointerDispatcherCompat.kt +56 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardViewGroup.kt +10 -7
- package/ios/extensions/Notification.swift +17 -0
- package/ios/observers/KeyboardMovementObserver.swift +4 -13
- package/lib/commonjs/animated.js +4 -2
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js +1 -3
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +10 -3
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +9 -3
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/index.js +3 -6
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/animated.js +4 -2
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js +1 -3
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +9 -2
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +9 -3
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/index.js +3 -6
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/bindings.d.ts +3 -4
- package/lib/typescript/bindings.native.d.ts +3 -3
- package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +4 -4
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +6 -6
- package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +1 -1
- package/lib/typescript/components/KeyboardStickyView/index.d.ts +4 -4
- package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -1
- package/lib/typescript/internal.d.ts +0 -1
- package/lib/typescript/types.d.ts +3 -1
- package/package.json +6 -4
- package/src/animated.tsx +2 -1
- package/src/bindings.native.ts +11 -3
- package/src/bindings.ts +0 -2
- package/src/components/KeyboardAwareScrollView/index.tsx +19 -8
- package/src/components/KeyboardToolbar/index.tsx +3 -7
- package/src/types.ts +3 -1
- /package/ios/{traversal → protocols}/TextInput.swift +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const KeyboardController: KeyboardControllerModule;
|
|
1
|
+
import type { FocusedInputEventsModule, KeyboardControllerModule, KeyboardControllerNativeModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
|
|
2
|
+
export declare const KeyboardControllerNative: KeyboardControllerNativeModule;
|
|
4
3
|
export declare const KeyboardEvents: KeyboardEventsModule;
|
|
4
|
+
export declare const KeyboardController: KeyboardControllerModule;
|
|
5
5
|
/**
|
|
6
6
|
* This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
|
|
7
7
|
* Use it with cautious.
|
|
@@ -29,7 +29,7 @@ declare const KeyboardAvoidingView: React.ForwardRefExoticComponent<{
|
|
|
29
29
|
/**
|
|
30
30
|
* Specify how to react to the presence of the keyboard.
|
|
31
31
|
*/
|
|
32
|
-
behavior?: "height" | "
|
|
32
|
+
behavior?: "height" | "position" | "padding";
|
|
33
33
|
/**
|
|
34
34
|
* Style of the content container when `behavior` is 'position'.
|
|
35
35
|
*/
|
|
@@ -38,13 +38,13 @@ declare const KeyboardAvoidingView: React.ForwardRefExoticComponent<{
|
|
|
38
38
|
* Controls whether this `KeyboardAvoidingView` instance should take effect.
|
|
39
39
|
* This is useful when more than one is on the screen. Defaults to true.
|
|
40
40
|
*/
|
|
41
|
-
enabled?: boolean
|
|
41
|
+
enabled?: boolean;
|
|
42
42
|
/**
|
|
43
43
|
* Distance between the top of the user screen and the React Native view. This
|
|
44
44
|
* may be non-zero in some cases. Defaults to 0.
|
|
45
45
|
*/
|
|
46
|
-
keyboardVerticalOffset?: number
|
|
46
|
+
keyboardVerticalOffset?: number;
|
|
47
47
|
} & ViewProps & {
|
|
48
|
-
children?: React.ReactNode;
|
|
48
|
+
children?: React.ReactNode | undefined;
|
|
49
49
|
} & React.RefAttributes<View>>;
|
|
50
50
|
export default KeyboardAvoidingView;
|
|
@@ -14,16 +14,16 @@ export type KeyboardAwareScrollViewProps = {
|
|
|
14
14
|
} & ScrollViewProps;
|
|
15
15
|
declare const KeyboardAwareScrollView: React.ForwardRefExoticComponent<{
|
|
16
16
|
/** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */
|
|
17
|
-
bottomOffset?: number
|
|
17
|
+
bottomOffset?: number;
|
|
18
18
|
/** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */
|
|
19
|
-
disableScrollOnKeyboardHide?: boolean
|
|
19
|
+
disableScrollOnKeyboardHide?: boolean;
|
|
20
20
|
/** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */
|
|
21
|
-
enabled?: boolean
|
|
21
|
+
enabled?: boolean;
|
|
22
22
|
/** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */
|
|
23
|
-
extraKeyboardSpace?: number
|
|
23
|
+
extraKeyboardSpace?: number;
|
|
24
24
|
/** Custom component for `ScrollView`. Default is `ScrollView` */
|
|
25
|
-
ScrollViewComponent?: React.ComponentType<ScrollViewProps
|
|
25
|
+
ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
|
|
26
26
|
} & ScrollViewProps & {
|
|
27
|
-
children?: React.ReactNode;
|
|
27
|
+
children?: React.ReactNode | undefined;
|
|
28
28
|
} & React.RefAttributes<ScrollView>>;
|
|
29
29
|
export default KeyboardAwareScrollView;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const debounce: <F extends (...args: Parameters<F>) => ReturnType<F>>(worklet: F, wait?: number) => (...args: Parameters<F>) =>
|
|
1
|
+
export declare const debounce: <F extends (...args: Parameters<F>) => ReturnType<F>>(worklet: F, wait?: number) => (...args: Parameters<F>) => ReturnType<F> | void;
|
|
2
2
|
export declare const scrollDistanceWithRespectToSnapPoints: (defaultScrollValue: number, snapPoints?: number[]) => number;
|
|
@@ -23,13 +23,13 @@ declare const KeyboardStickyView: React.ForwardRefExoticComponent<{
|
|
|
23
23
|
/**
|
|
24
24
|
* Adds additional `translateY` when keyboard is close. By default `0`.
|
|
25
25
|
*/
|
|
26
|
-
closed?: number
|
|
26
|
+
closed?: number;
|
|
27
27
|
/**
|
|
28
28
|
* Adds additional `translateY` when keyboard is open. By default `0`.
|
|
29
29
|
*/
|
|
30
|
-
opened?: number
|
|
31
|
-
}
|
|
30
|
+
opened?: number;
|
|
31
|
+
};
|
|
32
32
|
} & ViewProps & {
|
|
33
|
-
children?: React.ReactNode;
|
|
33
|
+
children?: React.ReactNode | undefined;
|
|
34
34
|
} & React.RefAttributes<View>>;
|
|
35
35
|
export default KeyboardStickyView;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { KeyboardToolbarTheme } from "./types";
|
|
3
|
+
import type { PropsWithChildren } from "react";
|
|
3
4
|
import type { GestureResponderEvent, ViewStyle } from "react-native";
|
|
4
5
|
type ButtonProps = {
|
|
5
6
|
disabled?: boolean;
|
|
@@ -11,5 +12,5 @@ type ButtonProps = {
|
|
|
11
12
|
style?: ViewStyle;
|
|
12
13
|
theme: KeyboardToolbarTheme;
|
|
13
14
|
};
|
|
14
|
-
declare const _default: ({ children, onPress, disabled, accessibilityLabel, accessibilityHint, testID, style, }:
|
|
15
|
+
declare const _default: ({ children, onPress, disabled, accessibilityLabel, accessibilityHint, testID, style, }: PropsWithChildren<ButtonProps>) => React.JSX.Element;
|
|
15
16
|
export default _default;
|
|
@@ -83,9 +83,11 @@ export type KeyboardControllerModule = {
|
|
|
83
83
|
setInputMode: (mode: number) => void;
|
|
84
84
|
dismiss: () => void;
|
|
85
85
|
setFocusTo: (direction: Direction) => void;
|
|
86
|
+
};
|
|
87
|
+
export type KeyboardControllerNativeModule = {
|
|
86
88
|
addListener: (eventName: string) => void;
|
|
87
89
|
removeListeners: (count: number) => void;
|
|
88
|
-
};
|
|
90
|
+
} & KeyboardControllerModule;
|
|
89
91
|
export type KeyboardControllerEvents = "keyboardWillShow" | "keyboardDidShow" | "keyboardWillHide" | "keyboardDidHide";
|
|
90
92
|
export type KeyboardEventData = {
|
|
91
93
|
height: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-keyboard-controller",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.5",
|
|
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",
|
|
@@ -79,7 +79,8 @@
|
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@commitlint/config-conventional": "^11.0.0",
|
|
82
|
-
"@react-native/
|
|
82
|
+
"@react-native/babel-preset": "0.76.2",
|
|
83
|
+
"@react-native/eslint-config": "0.76.2",
|
|
83
84
|
"@release-it/conventional-changelog": "^2.0.0",
|
|
84
85
|
"@testing-library/react-hooks": "^8.0.1",
|
|
85
86
|
"@types/jest": "^29.2.1",
|
|
@@ -92,6 +93,7 @@
|
|
|
92
93
|
"eslint-config-prettier": "^8.5.0",
|
|
93
94
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
94
95
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
96
|
+
"eslint-plugin-ft-flow": "^3.0.11",
|
|
95
97
|
"eslint-plugin-import": "^2.28.1",
|
|
96
98
|
"eslint-plugin-jest": "^26.5.3",
|
|
97
99
|
"eslint-plugin-prettier": "^4.2.1",
|
|
@@ -102,12 +104,12 @@
|
|
|
102
104
|
"pod-install": "^0.1.0",
|
|
103
105
|
"prettier": "^2.8.8",
|
|
104
106
|
"react": "18.3.1",
|
|
105
|
-
"react-native": "0.
|
|
107
|
+
"react-native": "0.76.2",
|
|
106
108
|
"react-native-builder-bob": "^0.18.0",
|
|
107
109
|
"react-native-reanimated": "3.16.1",
|
|
108
110
|
"react-test-renderer": "18.2.0",
|
|
109
111
|
"release-it": "^14.2.2",
|
|
110
|
-
"typescript": "5.
|
|
112
|
+
"typescript": "5.6.3"
|
|
111
113
|
},
|
|
112
114
|
"peerDependencies": {
|
|
113
115
|
"react": "*",
|
package/src/animated.tsx
CHANGED
|
@@ -137,7 +137,8 @@ export const KeyboardProvider = ({
|
|
|
137
137
|
},
|
|
138
138
|
},
|
|
139
139
|
],
|
|
140
|
-
|
|
140
|
+
// 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.
|
|
141
|
+
{ useNativeDriver: Platform.OS !== "web" },
|
|
141
142
|
),
|
|
142
143
|
[],
|
|
143
144
|
);
|
package/src/bindings.native.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { NativeEventEmitter, Platform } from "react-native";
|
|
|
3
3
|
import type {
|
|
4
4
|
FocusedInputEventsModule,
|
|
5
5
|
KeyboardControllerModule,
|
|
6
|
+
KeyboardControllerNativeModule,
|
|
6
7
|
KeyboardControllerProps,
|
|
7
8
|
KeyboardEventsModule,
|
|
8
9
|
KeyboardGestureAreaProps,
|
|
@@ -19,7 +20,7 @@ const LINKING_ERROR =
|
|
|
19
20
|
const RCTKeyboardController =
|
|
20
21
|
require("./specs/NativeKeyboardController").default;
|
|
21
22
|
|
|
22
|
-
export const
|
|
23
|
+
export const KeyboardControllerNative = (
|
|
23
24
|
RCTKeyboardController
|
|
24
25
|
? RCTKeyboardController
|
|
25
26
|
: new Proxy(
|
|
@@ -30,15 +31,22 @@ export const KeyboardController = (
|
|
|
30
31
|
},
|
|
31
32
|
},
|
|
32
33
|
)
|
|
33
|
-
) as
|
|
34
|
+
) as KeyboardControllerNativeModule;
|
|
34
35
|
|
|
35
36
|
const KEYBOARD_CONTROLLER_NAMESPACE = "KeyboardController::";
|
|
36
|
-
const eventEmitter = new NativeEventEmitter(
|
|
37
|
+
const eventEmitter = new NativeEventEmitter(KeyboardControllerNative);
|
|
37
38
|
|
|
38
39
|
export const KeyboardEvents: KeyboardEventsModule = {
|
|
39
40
|
addListener: (name, cb) =>
|
|
40
41
|
eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),
|
|
41
42
|
};
|
|
43
|
+
export const KeyboardController: KeyboardControllerModule = {
|
|
44
|
+
setDefaultMode: KeyboardControllerNative.setDefaultMode,
|
|
45
|
+
setInputMode: KeyboardControllerNative.setInputMode,
|
|
46
|
+
setFocusTo: KeyboardControllerNative.setFocusTo,
|
|
47
|
+
// additional function is needed because of this https://github.com/kirillzyusko/react-native-keyboard-controller/issues/684
|
|
48
|
+
dismiss: () => KeyboardControllerNative.dismiss(),
|
|
49
|
+
};
|
|
42
50
|
/**
|
|
43
51
|
* This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
|
|
44
52
|
* Use it with cautious.
|
package/src/bindings.ts
CHANGED
|
@@ -18,8 +18,6 @@ export const KeyboardController: KeyboardControllerModule = {
|
|
|
18
18
|
setInputMode: NOOP,
|
|
19
19
|
dismiss: NOOP,
|
|
20
20
|
setFocusTo: NOOP,
|
|
21
|
-
addListener: NOOP,
|
|
22
|
-
removeListeners: NOOP,
|
|
23
21
|
};
|
|
24
22
|
export const KeyboardEvents: KeyboardEventsModule = {
|
|
25
23
|
addListener: () => ({ remove: NOOP } as EmitterSubscription),
|
|
@@ -27,6 +27,7 @@ import type {
|
|
|
27
27
|
import type {
|
|
28
28
|
FocusedInputLayoutChangedEvent,
|
|
29
29
|
FocusedInputSelectionChangedEvent,
|
|
30
|
+
NativeEvent,
|
|
30
31
|
} from "react-native-keyboard-controller";
|
|
31
32
|
|
|
32
33
|
export type KeyboardAwareScrollViewProps = {
|
|
@@ -190,6 +191,20 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
190
191
|
},
|
|
191
192
|
[bottomOffset, enabled, height, snapToOffsets],
|
|
192
193
|
);
|
|
194
|
+
const syncKeyboardFrame = useCallback(
|
|
195
|
+
(e: NativeEvent) => {
|
|
196
|
+
"worklet";
|
|
197
|
+
|
|
198
|
+
const keyboardFrame = interpolate(
|
|
199
|
+
e.height,
|
|
200
|
+
[0, keyboardHeight.value],
|
|
201
|
+
[0, keyboardHeight.value + extraKeyboardSpace],
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
currentKeyboardFrameHeight.value = keyboardFrame;
|
|
205
|
+
},
|
|
206
|
+
[extraKeyboardSpace],
|
|
207
|
+
);
|
|
193
208
|
|
|
194
209
|
const scrollFromCurrentPosition = useCallback(
|
|
195
210
|
(customHeight?: number) => {
|
|
@@ -308,13 +323,7 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
308
323
|
onMove: (e) => {
|
|
309
324
|
"worklet";
|
|
310
325
|
|
|
311
|
-
|
|
312
|
-
e.height,
|
|
313
|
-
[0, keyboardHeight.value],
|
|
314
|
-
[0, keyboardHeight.value + extraKeyboardSpace],
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
currentKeyboardFrameHeight.value = keyboardFrame;
|
|
326
|
+
syncKeyboardFrame(e);
|
|
318
327
|
|
|
319
328
|
// if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens
|
|
320
329
|
if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {
|
|
@@ -326,9 +335,11 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
326
335
|
|
|
327
336
|
keyboardHeight.value = e.height;
|
|
328
337
|
scrollPosition.value = position.value;
|
|
338
|
+
|
|
339
|
+
syncKeyboardFrame(e);
|
|
329
340
|
},
|
|
330
341
|
},
|
|
331
|
-
[maybeScroll, disableScrollOnKeyboardHide,
|
|
342
|
+
[maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame],
|
|
332
343
|
);
|
|
333
344
|
|
|
334
345
|
useAnimatedReaction(
|
|
@@ -64,10 +64,6 @@ const KEYBOARD_TOOLBAR_HEIGHT = 42;
|
|
|
64
64
|
const DEFAULT_OPACITY: HEX = "FF";
|
|
65
65
|
const offset = { closed: KEYBOARD_TOOLBAR_HEIGHT };
|
|
66
66
|
|
|
67
|
-
const dismissKeyboard = () => KeyboardController.dismiss();
|
|
68
|
-
const goToNextField = () => KeyboardController.setFocusTo("next");
|
|
69
|
-
const goToPrevField = () => KeyboardController.setFocusTo("prev");
|
|
70
|
-
|
|
71
67
|
/**
|
|
72
68
|
* `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and
|
|
73
69
|
* `Done` buttons.
|
|
@@ -122,7 +118,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
122
118
|
onNextCallback?.(event);
|
|
123
119
|
|
|
124
120
|
if (!event.isDefaultPrevented()) {
|
|
125
|
-
|
|
121
|
+
KeyboardController.setFocusTo("next");
|
|
126
122
|
}
|
|
127
123
|
},
|
|
128
124
|
[onNextCallback],
|
|
@@ -132,7 +128,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
132
128
|
onPrevCallback?.(event);
|
|
133
129
|
|
|
134
130
|
if (!event.isDefaultPrevented()) {
|
|
135
|
-
|
|
131
|
+
KeyboardController.setFocusTo("prev");
|
|
136
132
|
}
|
|
137
133
|
},
|
|
138
134
|
[onPrevCallback],
|
|
@@ -142,7 +138,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
142
138
|
onDoneCallback?.(event);
|
|
143
139
|
|
|
144
140
|
if (!event.isDefaultPrevented()) {
|
|
145
|
-
|
|
141
|
+
KeyboardController.dismiss();
|
|
146
142
|
}
|
|
147
143
|
},
|
|
148
144
|
[onDoneCallback],
|
package/src/types.ts
CHANGED
|
@@ -121,10 +121,12 @@ export type KeyboardControllerModule = {
|
|
|
121
121
|
// all platforms
|
|
122
122
|
dismiss: () => void;
|
|
123
123
|
setFocusTo: (direction: Direction) => void;
|
|
124
|
+
};
|
|
125
|
+
export type KeyboardControllerNativeModule = {
|
|
124
126
|
// native event module stuff
|
|
125
127
|
addListener: (eventName: string) => void;
|
|
126
128
|
removeListeners: (count: number) => void;
|
|
127
|
-
};
|
|
129
|
+
} & KeyboardControllerModule;
|
|
128
130
|
|
|
129
131
|
// Event module declarations
|
|
130
132
|
export type KeyboardControllerEvents =
|
|
File without changes
|