react-native-keyboard-controller 1.21.13 → 1.22.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.
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +4 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/KeyboardAnimationController.kt +6 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +5 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/ClippingScrollViewDecoratorView.kt +12 -7
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -0
- package/ios/KeyboardBackdropController.swift +64 -0
- package/ios/KeyboardControllerModule.mm +11 -0
- package/ios/KeyboardControllerModuleImpl.swift +5 -0
- package/ios/extensions/UIWindow.swift +5 -1
- package/jest/index.js +1 -0
- package/lib/commonjs/bindings.js +1 -0
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/components/KeyboardChatScrollView/index.js +6 -0
- package/lib/commonjs/components/KeyboardChatScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardChatScrollView/useFrozenPadding/index.js +62 -0
- package/lib/commonjs/components/KeyboardChatScrollView/useFrozenPadding/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardEffects/index.js +92 -0
- package/lib/commonjs/components/KeyboardEffects/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/constants.js +2 -3
- package/lib/commonjs/components/KeyboardToolbar/constants.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/index.js +8 -7
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/constants.js +2 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/module.js +1 -0
- package/lib/commonjs/module.js.map +1 -1
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/types/module.js.map +1 -1
- package/lib/module/bindings.js +1 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/components/KeyboardChatScrollView/index.js +6 -0
- package/lib/module/components/KeyboardChatScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardChatScrollView/useFrozenPadding/index.js +57 -0
- package/lib/module/components/KeyboardChatScrollView/useFrozenPadding/index.js.map +1 -0
- package/lib/module/components/KeyboardEffects/index.js +84 -0
- package/lib/module/components/KeyboardEffects/index.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/constants.js +1 -2
- package/lib/module/components/KeyboardToolbar/constants.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/index.js +2 -1
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/constants.js +1 -0
- package/lib/module/constants.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/module.js +1 -0
- package/lib/module/module.js.map +1 -1
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/types/module.js.map +1 -1
- package/lib/typescript/components/KeyboardChatScrollView/useFrozenPadding/index.d.ts +30 -0
- package/lib/typescript/components/KeyboardEffects/index.d.ts +44 -0
- package/lib/typescript/components/KeyboardToolbar/constants.d.ts +0 -1
- package/lib/typescript/components/index.d.ts +2 -0
- package/lib/typescript/constants.d.ts +1 -0
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/specs/NativeKeyboardController.d.ts +1 -0
- package/lib/typescript/types/module.d.ts +7 -0
- package/package.json +1 -1
- package/src/bindings.ts +1 -0
- package/src/components/KeyboardChatScrollView/index.tsx +7 -0
- package/src/components/KeyboardChatScrollView/useFrozenPadding/index.ts +83 -0
- package/src/components/KeyboardEffects/index.tsx +121 -0
- package/src/components/KeyboardToolbar/constants.ts +1 -2
- package/src/components/KeyboardToolbar/index.tsx +1 -1
- package/src/components/index.ts +2 -0
- package/src/constants.ts +1 -0
- package/src/index.ts +2 -0
- package/src/module.ts +1 -0
- package/src/specs/NativeKeyboardController.ts +1 -0
- package/src/types/module.ts +7 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { forwardRef, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
KEYBOARD_BORDER_RADIUS,
|
|
6
|
+
KEYBOARD_HAS_ROUNDED_CORNERS,
|
|
7
|
+
} from "../../constants";
|
|
8
|
+
import { KeyboardController } from "../../module";
|
|
9
|
+
import KeyboardStickyView from "../KeyboardStickyView";
|
|
10
|
+
|
|
11
|
+
import type { KeyboardStickyViewProps } from "../KeyboardStickyView";
|
|
12
|
+
|
|
13
|
+
type TranslucentStackEntry = { translucent: boolean };
|
|
14
|
+
|
|
15
|
+
const translucentStack: TranslucentStackEntry[] = [];
|
|
16
|
+
let currentTranslucent = false;
|
|
17
|
+
|
|
18
|
+
const applyTranslucent = () => {
|
|
19
|
+
const next =
|
|
20
|
+
translucentStack.length > 0
|
|
21
|
+
? translucentStack[translucentStack.length - 1].translucent
|
|
22
|
+
: false;
|
|
23
|
+
|
|
24
|
+
if (next !== currentTranslucent) {
|
|
25
|
+
currentTranslucent = next;
|
|
26
|
+
KeyboardController.setTranslucent(next);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const pushTranslucentEntry = (entry: TranslucentStackEntry) => {
|
|
31
|
+
translucentStack.push(entry);
|
|
32
|
+
applyTranslucent();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const removeTranslucentEntry = (entry: TranslucentStackEntry) => {
|
|
36
|
+
const index = translucentStack.indexOf(entry);
|
|
37
|
+
|
|
38
|
+
if (index !== -1) {
|
|
39
|
+
translucentStack.splice(index, 1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
applyTranslucent();
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type KeyboardEffectsProps = {
|
|
46
|
+
/**
|
|
47
|
+
* Whether the keyboard backdrop should be translucent.
|
|
48
|
+
*
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
translucent?: boolean;
|
|
52
|
+
} & KeyboardStickyViewProps;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A component that renders content behind the keyboard. Since the keyboard
|
|
56
|
+
* is translucent, the content (colors, gradients, animations) will blend
|
|
57
|
+
* through and create visual effects on the keyboard.
|
|
58
|
+
*
|
|
59
|
+
* On iOS 26+ the keyboard has rounded corners, and the effect view
|
|
60
|
+
* automatically matches that shape.
|
|
61
|
+
*
|
|
62
|
+
* @returns A view component positioned behind the keyboard.
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* <KeyboardEffects>
|
|
66
|
+
* <View style={{ flex: 1, backgroundColor: "purple" }} />
|
|
67
|
+
* </KeyboardEffects>
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
const KeyboardEffects = forwardRef<
|
|
71
|
+
View,
|
|
72
|
+
React.PropsWithChildren<KeyboardEffectsProps>
|
|
73
|
+
>(({ translucent, children, ...props }, ref) => {
|
|
74
|
+
const stackEntry = useRef<TranslucentStackEntry>({
|
|
75
|
+
translucent: Boolean(translucent),
|
|
76
|
+
}).current;
|
|
77
|
+
const containerStyle = useMemo(
|
|
78
|
+
() => [
|
|
79
|
+
styles.container,
|
|
80
|
+
KEYBOARD_HAS_ROUNDED_CORNERS && !translucent && styles.rounded,
|
|
81
|
+
],
|
|
82
|
+
[translucent],
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
pushTranslucentEntry(stackEntry);
|
|
87
|
+
|
|
88
|
+
return () => {
|
|
89
|
+
removeTranslucentEntry(stackEntry);
|
|
90
|
+
};
|
|
91
|
+
}, [stackEntry]);
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
stackEntry.translucent = Boolean(translucent);
|
|
95
|
+
applyTranslucent();
|
|
96
|
+
}, [stackEntry, translucent]);
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<KeyboardStickyView ref={ref} {...props}>
|
|
100
|
+
<View style={containerStyle}>{children}</View>
|
|
101
|
+
</KeyboardStickyView>
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const styles = StyleSheet.create({
|
|
106
|
+
container: {
|
|
107
|
+
position: "absolute",
|
|
108
|
+
bottom: 0,
|
|
109
|
+
top: 0,
|
|
110
|
+
left: 0,
|
|
111
|
+
right: 0,
|
|
112
|
+
height: 999,
|
|
113
|
+
},
|
|
114
|
+
rounded: {
|
|
115
|
+
borderTopLeftRadius: KEYBOARD_BORDER_RADIUS,
|
|
116
|
+
borderTopRightRadius: KEYBOARD_BORDER_RADIUS,
|
|
117
|
+
overflow: "hidden",
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
export default KeyboardEffects;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KEYBOARD_HAS_ROUNDED_CORNERS } from "../../constants";
|
|
2
2
|
|
|
3
3
|
import type { HEX } from "./types";
|
|
4
4
|
|
|
@@ -10,5 +10,4 @@ export const TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;
|
|
|
10
10
|
|
|
11
11
|
export const KEYBOARD_TOOLBAR_HEIGHT = 42;
|
|
12
12
|
export const DEFAULT_OPACITY: HEX = "FF";
|
|
13
|
-
export const KEYBOARD_HAS_ROUNDED_CORNERS = KEYBOARD_BORDER_RADIUS > 0;
|
|
14
13
|
export const OPENED_OFFSET = KEYBOARD_HAS_ROUNDED_CORNERS ? -11 : 0;
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
FocusedInputEvents,
|
|
6
6
|
RCTKeyboardToolbarGroupView,
|
|
7
7
|
} from "../../bindings";
|
|
8
|
+
import { KEYBOARD_HAS_ROUNDED_CORNERS } from "../../constants";
|
|
8
9
|
import { useKeyboardState } from "../../hooks";
|
|
9
10
|
import KeyboardStickyView from "../KeyboardStickyView";
|
|
10
11
|
|
|
@@ -15,7 +16,6 @@ import { Background, Content, Done, Next, Prev } from "./compound/components";
|
|
|
15
16
|
import { ToolbarContext } from "./compound/context";
|
|
16
17
|
import {
|
|
17
18
|
DEFAULT_OPACITY,
|
|
18
|
-
KEYBOARD_HAS_ROUNDED_CORNERS,
|
|
19
19
|
KEYBOARD_TOOLBAR_HEIGHT,
|
|
20
20
|
OPENED_OFFSET,
|
|
21
21
|
TEST_ID_KEYBOARD_TOOLBAR,
|
package/src/components/index.ts
CHANGED
|
@@ -6,8 +6,10 @@ export {
|
|
|
6
6
|
DefaultKeyboardToolbarTheme,
|
|
7
7
|
} from "./KeyboardToolbar";
|
|
8
8
|
export { default as KeyboardChatScrollView } from "./KeyboardChatScrollView";
|
|
9
|
+
export { default as KeyboardEffects } from "./KeyboardEffects";
|
|
9
10
|
export type { KeyboardAvoidingViewProps } from "./KeyboardAvoidingView";
|
|
10
11
|
export type { KeyboardStickyViewProps } from "./KeyboardStickyView";
|
|
12
|
+
export type { KeyboardEffectsProps } from "./KeyboardEffects";
|
|
11
13
|
export type {
|
|
12
14
|
KeyboardAwareScrollViewMode,
|
|
13
15
|
KeyboardAwareScrollViewProps,
|
package/src/constants.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export {
|
|
|
15
15
|
// keyboard toolbar
|
|
16
16
|
KeyboardToolbar,
|
|
17
17
|
DefaultKeyboardToolbarTheme,
|
|
18
|
+
KeyboardEffects,
|
|
18
19
|
} from "./components";
|
|
19
20
|
export type {
|
|
20
21
|
KeyboardChatScrollViewProps,
|
|
@@ -24,5 +25,6 @@ export type {
|
|
|
24
25
|
KeyboardAwareScrollViewProps,
|
|
25
26
|
KeyboardAwareScrollViewRef,
|
|
26
27
|
KeyboardToolbarProps,
|
|
28
|
+
KeyboardEffectsProps,
|
|
27
29
|
} from "./components";
|
|
28
30
|
export { OverKeyboardView, KeyboardExtender } from "./views";
|
package/src/module.ts
CHANGED
|
@@ -56,6 +56,7 @@ export const KeyboardController: KeyboardControllerModule = {
|
|
|
56
56
|
setInputMode: KeyboardControllerNative.setInputMode,
|
|
57
57
|
setFocusTo: KeyboardControllerNative.setFocusTo,
|
|
58
58
|
preload: KeyboardControllerNative.preload,
|
|
59
|
+
setTranslucent: KeyboardControllerNative.setTranslucent,
|
|
59
60
|
dismiss,
|
|
60
61
|
isVisible,
|
|
61
62
|
state,
|
|
@@ -11,6 +11,7 @@ export interface Spec extends TurboModule {
|
|
|
11
11
|
setInputMode(mode: number): void;
|
|
12
12
|
setDefaultMode(): void;
|
|
13
13
|
preload(): void;
|
|
14
|
+
setTranslucent(translucent: boolean): void;
|
|
14
15
|
dismiss(keepFocus: boolean, animated: boolean): void;
|
|
15
16
|
setFocusTo(direction: string): void;
|
|
16
17
|
viewPositionInWindow(viewTag: number): Promise<object>;
|
package/src/types/module.ts
CHANGED
|
@@ -82,6 +82,12 @@ export type KeyboardControllerModule = {
|
|
|
82
82
|
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#preload-|docs} page for more details.
|
|
83
83
|
*/
|
|
84
84
|
preload: () => void;
|
|
85
|
+
/**
|
|
86
|
+
* Sets the keyboard backdrop translucency.
|
|
87
|
+
*
|
|
88
|
+
* @platform ios
|
|
89
|
+
*/
|
|
90
|
+
setTranslucent: (translucent: boolean) => void;
|
|
85
91
|
// all platforms
|
|
86
92
|
/**
|
|
87
93
|
* Dismisses the active keyboard. Removes a focus by default, but allows to pass `{keepFocus: true}` to keep focus.
|
|
@@ -121,6 +127,7 @@ export type KeyboardControllerNativeModule = {
|
|
|
121
127
|
setInputMode: (mode: number) => void;
|
|
122
128
|
// ios only
|
|
123
129
|
preload: () => void;
|
|
130
|
+
setTranslucent: (translucent: boolean) => void;
|
|
124
131
|
// all platforms
|
|
125
132
|
dismiss: (keepFocus: boolean, animated: boolean) => void;
|
|
126
133
|
setFocusTo: (direction: Direction) => void;
|