react-native-keyboard-controller 1.17.1 → 1.17.2
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/README.md +24 -23
- package/lib/commonjs/animated.js +23 -7
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js +19 -0
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +11 -2
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +51 -36
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +17 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/commonjs/components/KeyboardStickyView/index.js +13 -0
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/index.js +31 -22
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/context.js +16 -0
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks/index.js +164 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useKeyboardState/index.js +21 -0
- package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
- package/lib/commonjs/internal.js +21 -0
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/module.js +4 -0
- package/lib/commonjs/module.js.map +1 -1
- package/lib/commonjs/monkey-patch.android.js +0 -5
- package/lib/commonjs/monkey-patch.android.js.map +1 -1
- package/lib/commonjs/{types.js → types/hooks.js} +1 -1
- package/lib/commonjs/types/hooks.js.map +1 -0
- package/lib/commonjs/types/index.js +50 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/internal.js +6 -0
- package/lib/commonjs/types/internal.js.map +1 -0
- package/lib/commonjs/types/module.js +6 -0
- package/lib/commonjs/types/module.js.map +1 -0
- package/lib/commonjs/types/views.js +6 -0
- package/lib/commonjs/types/views.js.map +1 -0
- package/lib/commonjs/views/OverKeyboardView/index.js +18 -4
- package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
- package/lib/module/animated.js +23 -7
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js +19 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +11 -2
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +51 -36
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +17 -1
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/module/components/KeyboardStickyView/index.js +13 -0
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/index.js +31 -22
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/context.js +16 -0
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks/index.js +164 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useKeyboardState/index.js +21 -0
- package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
- package/lib/module/internal.js +21 -0
- package/lib/module/internal.js.map +1 -1
- package/lib/module/module.js +4 -0
- package/lib/module/module.js.map +1 -1
- package/lib/module/monkey-patch.android.js +0 -5
- package/lib/module/monkey-patch.android.js.map +1 -1
- package/lib/module/types/hooks.js +2 -0
- package/lib/module/types/hooks.js.map +1 -0
- package/lib/module/types/index.js +5 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/internal.js +2 -0
- package/lib/module/types/internal.js.map +1 -0
- package/lib/module/types/module.js +2 -0
- package/lib/module/types/module.js.map +1 -0
- package/lib/module/types/views.js +2 -0
- package/lib/module/types/views.js.map +1 -0
- package/lib/module/views/OverKeyboardView/index.js +18 -4
- package/lib/module/views/OverKeyboardView/index.js.map +1 -1
- package/lib/typescript/animated.d.ts +20 -6
- package/lib/typescript/bindings.d.ts +19 -0
- package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +11 -2
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +23 -6
- package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +17 -1
- package/lib/typescript/components/KeyboardStickyView/index.d.ts +15 -2
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +13 -2
- package/lib/typescript/context.d.ts +32 -0
- package/lib/typescript/hooks/index.d.ts +157 -0
- package/lib/typescript/hooks/useKeyboardState/index.d.ts +20 -0
- package/lib/typescript/internal.d.ts +21 -0
- package/lib/typescript/module.d.ts +3 -0
- package/lib/typescript/{types.d.ts → types/hooks.d.ts} +72 -78
- package/lib/typescript/types/index.d.ts +4 -0
- package/lib/typescript/types/internal.d.ts +17 -0
- package/lib/typescript/types/module.d.ts +91 -0
- package/lib/typescript/types/views.d.ts +45 -0
- package/lib/typescript/views/OverKeyboardView/index.d.ts +14 -1
- package/package.json +2 -1
- package/src/animated.tsx +27 -12
- package/src/bindings.ts +19 -0
- package/src/components/KeyboardAvoidingView/index.tsx +11 -2
- package/src/components/KeyboardAwareScrollView/index.tsx +54 -39
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +17 -1
- package/src/components/KeyboardStickyView/index.tsx +14 -1
- package/src/components/KeyboardToolbar/index.tsx +31 -19
- package/src/context.ts +33 -0
- package/src/hooks/index.ts +157 -0
- package/src/hooks/useKeyboardState/index.ts +20 -0
- package/src/internal.ts +21 -0
- package/src/module.ts +3 -0
- package/src/monkey-patch.android.ts +3 -6
- package/src/{types.ts → types/hooks.ts} +72 -105
- package/src/types/index.ts +4 -0
- package/src/types/internal.ts +24 -0
- package/src/types/module.ts +105 -0
- package/src/types/views.ts +46 -0
- package/src/views/OverKeyboardView/index.tsx +15 -4
- package/lib/commonjs/types.js.map +0 -1
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
|
@@ -2,22 +2,98 @@ import { useEffect, useLayoutEffect } from "react";
|
|
|
2
2
|
import { AndroidSoftInputModes } from "../constants";
|
|
3
3
|
import { useKeyboardContext } from "../context";
|
|
4
4
|
import { KeyboardController } from "../module";
|
|
5
|
+
/**
|
|
6
|
+
* Hook that sets the Android soft input mode to adjust resize on mount and
|
|
7
|
+
* restores default mode on unmount. This ensures the keyboard behavior is consistent
|
|
8
|
+
* on all Android versions.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|Documentation} page for more details.
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* function MyComponent() {
|
|
14
|
+
* useResizeMode();
|
|
15
|
+
* return <View />;
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
5
19
|
export const useResizeMode = () => {
|
|
6
20
|
useEffect(() => {
|
|
7
21
|
KeyboardController.setInputMode(AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
|
|
8
22
|
return () => KeyboardController.setDefaultMode();
|
|
9
23
|
}, []);
|
|
10
24
|
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Hook that provides animated (`height`/`progress`) values for tracking keyboard movement.
|
|
28
|
+
* Automatically sets the resize mode for Android.
|
|
29
|
+
*
|
|
30
|
+
* @returns Object {@link AnimatedContext|containing} animated values for keyboard movement.
|
|
31
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-animation|Documentation} page for more details.
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* function MyComponent() {
|
|
35
|
+
* const { height, progress } = useKeyboardAnimation();
|
|
36
|
+
* return <Animated.View style={{ transform: [{ translateY: height }] }} />;
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
11
40
|
export const useKeyboardAnimation = () => {
|
|
12
41
|
useResizeMode();
|
|
13
42
|
const context = useKeyboardContext();
|
|
14
43
|
return context.animated;
|
|
15
44
|
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Hook that provides reanimated (`height`/`progress`) values for tracking keyboard movement.
|
|
48
|
+
* Automatically sets the resize mode for Android.
|
|
49
|
+
*
|
|
50
|
+
* @returns Object {@link ReanimatedContext|containing} reanimated values for keyboard movement.
|
|
51
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-reanimated-keyboard-animation|Documentation} page for more details.
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* function MyComponent() {
|
|
55
|
+
* const { height, progress } = useReanimatedKeyboardAnimation();
|
|
56
|
+
* return <Reanimated.View style={{ transform: [{ translateY: height }] }} />;
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
16
60
|
export const useReanimatedKeyboardAnimation = () => {
|
|
17
61
|
useResizeMode();
|
|
18
62
|
const context = useKeyboardContext();
|
|
19
63
|
return context.reanimated;
|
|
20
64
|
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* An alternative to {@link useKeyboardHandler} that doesn't set resize mode on mount. If your
|
|
68
|
+
* app already uses `adjustResize`, then you can use this hook instead of `useKeyboardHandler`.
|
|
69
|
+
*
|
|
70
|
+
* @param handler - Object containing keyboard event handlers.
|
|
71
|
+
* @param [deps] - Dependencies array for the effect.
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* function MyComponent() {
|
|
75
|
+
* const height = useSharedValue(0);
|
|
76
|
+
* const progress = useSharedValue(0);
|
|
77
|
+
*
|
|
78
|
+
* useGenericKeyboardHandler({
|
|
79
|
+
* onMove: (e) => {
|
|
80
|
+
* "worklet";
|
|
81
|
+
*
|
|
82
|
+
* height.value = e.height;
|
|
83
|
+
* progress.value = e.progress;
|
|
84
|
+
* },
|
|
85
|
+
* onEnd: (e) => {
|
|
86
|
+
* "worklet";
|
|
87
|
+
*
|
|
88
|
+
* height.value = e.height;
|
|
89
|
+
* progress.value = e.progress;
|
|
90
|
+
* },
|
|
91
|
+
* }, []);
|
|
92
|
+
*
|
|
93
|
+
* return <Reanimated.View style={{ height: height }] }} />;
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
21
97
|
export function useGenericKeyboardHandler(handler, deps) {
|
|
22
98
|
const context = useKeyboardContext();
|
|
23
99
|
useLayoutEffect(() => {
|
|
@@ -25,10 +101,66 @@ export function useGenericKeyboardHandler(handler, deps) {
|
|
|
25
101
|
return () => cleanup();
|
|
26
102
|
}, deps);
|
|
27
103
|
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Hook that gives an access to each aspect of keyboard movement with workletized `onStart`/`onMove`/`onInteractive`/`onEnd` handlers.
|
|
107
|
+
*
|
|
108
|
+
* @param handler - Object containing keyboard event handlers.
|
|
109
|
+
* @param [deps] - Dependencies array for the effect.
|
|
110
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-handler|Documentation} page for more details.
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* function MyComponent() {
|
|
114
|
+
* const height = useSharedValue(0);
|
|
115
|
+
* const progress = useSharedValue(0);
|
|
116
|
+
*
|
|
117
|
+
* useKeyboardHandler({
|
|
118
|
+
* onMove: (e) => {
|
|
119
|
+
* "worklet";
|
|
120
|
+
*
|
|
121
|
+
* height.value = e.height;
|
|
122
|
+
* progress.value = e.progress;
|
|
123
|
+
* },
|
|
124
|
+
* onEnd: (e) => {
|
|
125
|
+
* "worklet";
|
|
126
|
+
*
|
|
127
|
+
* height.value = e.height;
|
|
128
|
+
* progress.value = e.progress;
|
|
129
|
+
* },
|
|
130
|
+
* }, []);
|
|
131
|
+
*
|
|
132
|
+
* return <Reanimated.View style={{ height: height }] }} />;
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
28
136
|
export function useKeyboardHandler(handler, deps) {
|
|
29
137
|
useResizeMode();
|
|
30
138
|
useGenericKeyboardHandler(handler, deps);
|
|
31
139
|
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Hook for controlling keyboard controller module.
|
|
143
|
+
* Allows to disable/enable it and check the actual state (whether it's enabled or not).
|
|
144
|
+
* When disabled it fallbacks to default android keyboard handling and stops tracking all
|
|
145
|
+
* the events that are exposed from this library.
|
|
146
|
+
*
|
|
147
|
+
* @property {Function} setEnabled - Function to enable/disable keyboard handling.
|
|
148
|
+
* @property {boolean} enabled - Current enabled state.
|
|
149
|
+
* @returns Object containing keyboard control functions and state.
|
|
150
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/module/use-keyboard-controller|Documentation} page for more details.
|
|
151
|
+
* @example
|
|
152
|
+
* ```tsx
|
|
153
|
+
* function MyComponent() {
|
|
154
|
+
* const { setEnabled, enabled } = useKeyboardController();
|
|
155
|
+
* return (
|
|
156
|
+
* <Button
|
|
157
|
+
* title={enabled ? 'Disable' : 'Enable'}
|
|
158
|
+
* onPress={() => setEnabled(!enabled)}
|
|
159
|
+
* />
|
|
160
|
+
* );
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
32
164
|
export function useKeyboardController() {
|
|
33
165
|
const context = useKeyboardContext();
|
|
34
166
|
return {
|
|
@@ -36,12 +168,44 @@ export function useKeyboardController() {
|
|
|
36
168
|
enabled: context.enabled
|
|
37
169
|
};
|
|
38
170
|
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Hook that provides access to the layout of the currently focused input.
|
|
174
|
+
*
|
|
175
|
+
* @returns Object containing reanimated values for focused input.
|
|
176
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/input/use-reanimated-focused-input|Documentation} page for more details.
|
|
177
|
+
* @example
|
|
178
|
+
* ```tsx
|
|
179
|
+
* function MyComponent() {
|
|
180
|
+
* const { input } = useReanimatedFocusedInput();
|
|
181
|
+
* return <Reanimated.View style={{ height: input.value?.layout.height }} />;
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
39
185
|
export function useReanimatedFocusedInput() {
|
|
40
186
|
const context = useKeyboardContext();
|
|
41
187
|
return {
|
|
42
188
|
input: context.layout
|
|
43
189
|
};
|
|
44
190
|
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Hook for handling focused input events, such as changes of selection, text etc.
|
|
194
|
+
*
|
|
195
|
+
* @param handler - Object containing focused input event handlers.
|
|
196
|
+
* @param [deps] - Dependencies array for the effect.
|
|
197
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/input/use-focused-input-handler|Documentation} page for more details.
|
|
198
|
+
* @example
|
|
199
|
+
* ```tsx
|
|
200
|
+
* function MyComponent() {
|
|
201
|
+
* useFocusedInputHandler({
|
|
202
|
+
* onChangeText: (e) => console.log('Text changed:', e.text),
|
|
203
|
+
* onSelectionChange: (e) => console.log('Selection changed:', e.selection)
|
|
204
|
+
* });
|
|
205
|
+
* return <View />;
|
|
206
|
+
* }
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
45
209
|
export function useFocusedInputHandler(handler, deps) {
|
|
46
210
|
const context = useKeyboardContext();
|
|
47
211
|
useLayoutEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","AndroidSoftInputModes","useKeyboardContext","KeyboardController","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","cleanup","setKeyboardHandlers","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","setInputHandlers"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from \"react\";\n\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\nimport { KeyboardController } from \"../module\";\n\nimport type { AnimatedContext, ReanimatedContext } from \"../context\";\nimport type { FocusedInputHandler, KeyboardHandler } from \"../types\";\nimport type { DependencyList } from \"react\";\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE,\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.reanimated;\n};\n\nexport function useGenericKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useLayoutEffect(() => {\n const cleanup = context.setKeyboardHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport function useKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n useResizeMode();\n useGenericKeyboardHandler(handler, deps);\n}\n\nexport function useKeyboardController() {\n const context = useKeyboardContext();\n\n return { setEnabled: context.setEnabled, enabled: context.enabled };\n}\n\nexport function useReanimatedFocusedInput() {\n const context = useKeyboardContext();\n\n return { input: context.layout };\n}\n\nexport function useFocusedInputHandler(\n handler: FocusedInputHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useLayoutEffect(() => {\n const cleanup = context.setInputHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport * from \"./useWindowDimensions\";\nexport * from \"./useKeyboardState\";\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO;AAElD,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,kBAAkB,QAAQ,WAAW;AAM9C,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjCL,SAAS,CAAC,MAAM;IACdI,kBAAkB,CAACE,YAAY,CAC7BJ,qBAAqB,CAACK,wBACxB,CAAC;IAED,OAAO,MAAMH,kBAAkB,CAACI,cAAc,CAAC,CAAC;EAClD,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAED,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAuB;EACzDJ,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACC,QAAQ;AACzB,CAAC;AAED,OAAO,MAAMC,8BAA8B,GAAGA,CAAA,KAAyB;EACrEP,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACG,UAAU;AAC3B,CAAC;AAED,OAAO,SAASC,yBAAyBA,CACvCC,OAAwB,EACxBC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCF,eAAe,CAAC,MAAM;IACpB,MAAMgB,OAAO,GAAGP,OAAO,CAACQ,mBAAmB,CAACH,OAAO,CAAC;IAEpD,OAAO,MAAME,OAAO,CAAC,CAAC;EACxB,CAAC,EAAED,IAAI,CAAC;AACV;AAEA,OAAO,SAASG,kBAAkBA,CAChCJ,OAAwB,EACxBC,IAAqB,EACrB;EACAX,aAAa,CAAC,CAAC;EACfS,yBAAyB,CAACC,OAAO,EAAEC,IAAI,CAAC;AAC1C;AAEA,OAAO,SAASI,qBAAqBA,CAAA,EAAG;EACtC,MAAMV,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEkB,UAAU,EAAEX,OAAO,CAACW,UAAU;IAAEC,OAAO,EAAEZ,OAAO,CAACY;EAAQ,CAAC;AACrE;AAEA,OAAO,SAASC,yBAAyBA,CAAA,EAAG;EAC1C,MAAMb,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEqB,KAAK,EAAEd,OAAO,CAACe;EAAO,CAAC;AAClC;AAEA,OAAO,SAASC,sBAAsBA,CACpCX,OAA4B,EAC5BC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCF,eAAe,CAAC,MAAM;IACpB,MAAMgB,OAAO,GAAGP,OAAO,CAACiB,gBAAgB,CAACZ,OAAO,CAAC;IAEjD,OAAO,MAAME,OAAO,CAAC,CAAC;EACxB,CAAC,EAAED,IAAI,CAAC;AACV;AAEA,cAAc,uBAAuB;AACrC,cAAc,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","AndroidSoftInputModes","useKeyboardContext","KeyboardController","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","cleanup","setKeyboardHandlers","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","setInputHandlers"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from \"react\";\n\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\nimport { KeyboardController } from \"../module\";\n\nimport type { AnimatedContext, ReanimatedContext } from \"../context\";\nimport type { FocusedInputHandler, KeyboardHandler } from \"../types\";\nimport type { DependencyList } from \"react\";\n\n/**\n * Hook that sets the Android soft input mode to adjust resize on mount and\n * restores default mode on unmount. This ensures the keyboard behavior is consistent\n * on all Android versions.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * useResizeMode();\n * return <View />;\n * }\n * ```\n */\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE,\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\n/**\n * Hook that provides animated (`height`/`progress`) values for tracking keyboard movement.\n * Automatically sets the resize mode for Android.\n *\n * @returns Object {@link AnimatedContext|containing} animated values for keyboard movement.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-animation|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { height, progress } = useKeyboardAnimation();\n * return <Animated.View style={{ transform: [{ translateY: height }] }} />;\n * }\n * ```\n */\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.animated;\n};\n\n/**\n * Hook that provides reanimated (`height`/`progress`) values for tracking keyboard movement.\n * Automatically sets the resize mode for Android.\n *\n * @returns Object {@link ReanimatedContext|containing} reanimated values for keyboard movement.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-reanimated-keyboard-animation|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { height, progress } = useReanimatedKeyboardAnimation();\n * return <Reanimated.View style={{ transform: [{ translateY: height }] }} />;\n * }\n * ```\n */\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.reanimated;\n};\n\n/**\n * An alternative to {@link useKeyboardHandler} that doesn't set resize mode on mount. If your\n * app already uses `adjustResize`, then you can use this hook instead of `useKeyboardHandler`.\n *\n * @param handler - Object containing keyboard event handlers.\n * @param [deps] - Dependencies array for the effect.\n * @example\n * ```tsx\n * function MyComponent() {\n * const height = useSharedValue(0);\n * const progress = useSharedValue(0);\n *\n * useGenericKeyboardHandler({\n * onMove: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * onEnd: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * }, []);\n *\n * return <Reanimated.View style={{ height: height }] }} />;\n * }\n * ```\n */\nexport function useGenericKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useLayoutEffect(() => {\n const cleanup = context.setKeyboardHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\n/**\n * Hook that gives an access to each aspect of keyboard movement with workletized `onStart`/`onMove`/`onInteractive`/`onEnd` handlers.\n *\n * @param handler - Object containing keyboard event handlers.\n * @param [deps] - Dependencies array for the effect.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-handler|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const height = useSharedValue(0);\n * const progress = useSharedValue(0);\n *\n * useKeyboardHandler({\n * onMove: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * onEnd: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * }, []);\n *\n * return <Reanimated.View style={{ height: height }] }} />;\n * }\n * ```\n */\nexport function useKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n useResizeMode();\n useGenericKeyboardHandler(handler, deps);\n}\n\n/**\n * Hook for controlling keyboard controller module.\n * Allows to disable/enable it and check the actual state (whether it's enabled or not).\n * When disabled it fallbacks to default android keyboard handling and stops tracking all\n * the events that are exposed from this library.\n *\n * @property {Function} setEnabled - Function to enable/disable keyboard handling.\n * @property {boolean} enabled - Current enabled state.\n * @returns Object containing keyboard control functions and state.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/module/use-keyboard-controller|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { setEnabled, enabled } = useKeyboardController();\n * return (\n * <Button\n * title={enabled ? 'Disable' : 'Enable'}\n * onPress={() => setEnabled(!enabled)}\n * />\n * );\n * }\n * ```\n */\nexport function useKeyboardController() {\n const context = useKeyboardContext();\n\n return { setEnabled: context.setEnabled, enabled: context.enabled };\n}\n\n/**\n * Hook that provides access to the layout of the currently focused input.\n *\n * @returns Object containing reanimated values for focused input.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/input/use-reanimated-focused-input|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { input } = useReanimatedFocusedInput();\n * return <Reanimated.View style={{ height: input.value?.layout.height }} />;\n * }\n * ```\n */\nexport function useReanimatedFocusedInput() {\n const context = useKeyboardContext();\n\n return { input: context.layout };\n}\n\n/**\n * Hook for handling focused input events, such as changes of selection, text etc.\n *\n * @param handler - Object containing focused input event handlers.\n * @param [deps] - Dependencies array for the effect.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/input/use-focused-input-handler|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * useFocusedInputHandler({\n * onChangeText: (e) => console.log('Text changed:', e.text),\n * onSelectionChange: (e) => console.log('Selection changed:', e.selection)\n * });\n * return <View />;\n * }\n * ```\n */\nexport function useFocusedInputHandler(\n handler: FocusedInputHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useLayoutEffect(() => {\n const cleanup = context.setInputHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport * from \"./useWindowDimensions\";\nexport * from \"./useKeyboardState\";\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO;AAElD,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,kBAAkB,QAAQ,WAAW;AAM9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjCL,SAAS,CAAC,MAAM;IACdI,kBAAkB,CAACE,YAAY,CAC7BJ,qBAAqB,CAACK,wBACxB,CAAC;IAED,OAAO,MAAMH,kBAAkB,CAACI,cAAc,CAAC,CAAC;EAClD,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAuB;EACzDJ,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACC,QAAQ;AACzB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,8BAA8B,GAAGA,CAAA,KAAyB;EACrEP,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACG,UAAU;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACvCC,OAAwB,EACxBC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCF,eAAe,CAAC,MAAM;IACpB,MAAMgB,OAAO,GAAGP,OAAO,CAACQ,mBAAmB,CAACH,OAAO,CAAC;IAEpD,OAAO,MAAME,OAAO,CAAC,CAAC;EACxB,CAAC,EAAED,IAAI,CAAC;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,kBAAkBA,CAChCJ,OAAwB,EACxBC,IAAqB,EACrB;EACAX,aAAa,CAAC,CAAC;EACfS,yBAAyB,CAACC,OAAO,EAAEC,IAAI,CAAC;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,qBAAqBA,CAAA,EAAG;EACtC,MAAMV,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEkB,UAAU,EAAEX,OAAO,CAACW,UAAU;IAAEC,OAAO,EAAEZ,OAAO,CAACY;EAAQ,CAAC;AACrE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAA,EAAG;EAC1C,MAAMb,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEqB,KAAK,EAAEd,OAAO,CAACe;EAAO,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCX,OAA4B,EAC5BC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCF,eAAe,CAAC,MAAM;IACpB,MAAMgB,OAAO,GAAGP,OAAO,CAACiB,gBAAgB,CAACZ,OAAO,CAAC;IAEjD,OAAO,MAAME,OAAO,CAAC,CAAC;EACxB,CAAC,EAAED,IAAI,CAAC;AACV;AAEA,cAAc,uBAAuB;AACrC,cAAc,oBAAoB","ignoreList":[]}
|
|
@@ -6,6 +6,27 @@ const getLatestState = () => ({
|
|
|
6
6
|
...KeyboardController.state(),
|
|
7
7
|
isVisible: KeyboardController.isVisible()
|
|
8
8
|
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* React Hook that represents the current keyboard state on iOS and Android.
|
|
12
|
+
* It tracks keyboard visibility, height, appearance, type and other properties.
|
|
13
|
+
* This hook subscribes to keyboard events and updates the state reactively.
|
|
14
|
+
*
|
|
15
|
+
* @returns Object {@link KeyboardState|containing} keyboard state information.
|
|
16
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-state|Documentation} page for more details.
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* function MyComponent() {
|
|
20
|
+
* const { isVisible, height } = useKeyboardState();
|
|
21
|
+
* return (
|
|
22
|
+
* <View>
|
|
23
|
+
* <Text>Keyboard is {isVisible ? 'visible' : 'hidden'}</Text>
|
|
24
|
+
* <Text>Keyboard height: {height}</Text>
|
|
25
|
+
* </View>
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
9
30
|
export const useKeyboardState = () => {
|
|
10
31
|
const [state, setState] = useState(getLatestState);
|
|
11
32
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useState","KeyboardEvents","KeyboardController","EVENTS","getLatestState","state","isVisible","useKeyboardState","setState","subscriptions","map","event","addListener","forEach","subscription","remove"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { KeyboardEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\n\nimport type { KeyboardState } from \"../../types\";\n\nconst EVENTS = [\"keyboardDidShow\", \"keyboardDidHide\"] as const;\n\nconst getLatestState = () => ({\n ...KeyboardController.state(),\n isVisible: KeyboardController.isVisible(),\n});\n\nexport const useKeyboardState = (): KeyboardState => {\n const [state, setState] = useState(getLatestState);\n\n useEffect(() => {\n const subscriptions = EVENTS.map((event) =>\n KeyboardEvents.addListener(event, () =>\n // state will be updated by global listener first,\n // so we simply read it and don't derive data from the event\n setState(getLatestState),\n ),\n );\n\n // we might have missed an update between reading a value in render and\n // `addListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n setState(getLatestState);\n\n return () => {\n subscriptions.forEach((subscription) => subscription.remove());\n };\n }, []);\n\n return state;\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,SAASC,cAAc,QAAQ,gBAAgB;AAC/C,SAASC,kBAAkB,QAAQ,cAAc;AAIjD,MAAMC,MAAM,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAU;AAE9D,MAAMC,cAAc,GAAGA,CAAA,MAAO;EAC5B,GAAGF,kBAAkB,CAACG,KAAK,CAAC,CAAC;EAC7BC,SAAS,EAAEJ,kBAAkB,CAACI,SAAS,CAAC;AAC1C,CAAC,CAAC;
|
|
1
|
+
{"version":3,"names":["useEffect","useState","KeyboardEvents","KeyboardController","EVENTS","getLatestState","state","isVisible","useKeyboardState","setState","subscriptions","map","event","addListener","forEach","subscription","remove"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { KeyboardEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\n\nimport type { KeyboardState } from \"../../types\";\n\nconst EVENTS = [\"keyboardDidShow\", \"keyboardDidHide\"] as const;\n\nconst getLatestState = () => ({\n ...KeyboardController.state(),\n isVisible: KeyboardController.isVisible(),\n});\n\n/**\n * React Hook that represents the current keyboard state on iOS and Android.\n * It tracks keyboard visibility, height, appearance, type and other properties.\n * This hook subscribes to keyboard events and updates the state reactively.\n *\n * @returns Object {@link KeyboardState|containing} keyboard state information.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-state|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { isVisible, height } = useKeyboardState();\n * return (\n * <View>\n * <Text>Keyboard is {isVisible ? 'visible' : 'hidden'}</Text>\n * <Text>Keyboard height: {height}</Text>\n * </View>\n * );\n * }\n * ```\n */\nexport const useKeyboardState = (): KeyboardState => {\n const [state, setState] = useState(getLatestState);\n\n useEffect(() => {\n const subscriptions = EVENTS.map((event) =>\n KeyboardEvents.addListener(event, () =>\n // state will be updated by global listener first,\n // so we simply read it and don't derive data from the event\n setState(getLatestState),\n ),\n );\n\n // we might have missed an update between reading a value in render and\n // `addListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n setState(getLatestState);\n\n return () => {\n subscriptions.forEach((subscription) => subscription.remove());\n };\n }, []);\n\n return state;\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,SAASC,cAAc,QAAQ,gBAAgB;AAC/C,SAASC,kBAAkB,QAAQ,cAAc;AAIjD,MAAMC,MAAM,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAU;AAE9D,MAAMC,cAAc,GAAGA,CAAA,MAAO;EAC5B,GAAGF,kBAAkB,CAACG,KAAK,CAAC,CAAC;EAC7BC,SAAS,EAAEJ,kBAAkB,CAACI,SAAS,CAAC;AAC1C,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAqB;EACnD,MAAM,CAACF,KAAK,EAAEG,QAAQ,CAAC,GAAGR,QAAQ,CAACI,cAAc,CAAC;EAElDL,SAAS,CAAC,MAAM;IACd,MAAMU,aAAa,GAAGN,MAAM,CAACO,GAAG,CAAEC,KAAK,IACrCV,cAAc,CAACW,WAAW,CAACD,KAAK,EAAE;IAChC;IACA;IACAH,QAAQ,CAACJ,cAAc,CACzB,CACF,CAAC;;IAED;IACA;IACA;IACAI,QAAQ,CAACJ,cAAc,CAAC;IAExB,OAAO,MAAM;MACXK,aAAa,CAACI,OAAO,CAAEC,YAAY,IAAKA,YAAY,CAACC,MAAM,CAAC,CAAC,CAAC;IAChE,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOV,KAAK;AACd,CAAC","ignoreList":[]}
|
package/lib/module/internal.js
CHANGED
|
@@ -2,6 +2,20 @@ import { useRef } from "react";
|
|
|
2
2
|
import { Animated } from "react-native";
|
|
3
3
|
import { registerEventHandler, unregisterEventHandler } from "./event-handler";
|
|
4
4
|
import { findNodeHandle } from "./utils/findNodeHandle";
|
|
5
|
+
/**
|
|
6
|
+
* An internal hook that helps to register workletized event handlers.
|
|
7
|
+
*
|
|
8
|
+
* @param map - Map of event handlers and their names.
|
|
9
|
+
* @param viewTagRef - Ref to the view that produces events.
|
|
10
|
+
* @returns A function that registers supplied event handlers.
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(
|
|
14
|
+
* keyboardEventsMap,
|
|
15
|
+
* viewTagRef,
|
|
16
|
+
* );
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
5
19
|
export function useEventHandlerRegistration(map, viewTagRef) {
|
|
6
20
|
const onRegisterHandler = handler => {
|
|
7
21
|
const ids = [];
|
|
@@ -43,7 +57,14 @@ export function useEventHandlerRegistration(map, viewTagRef) {
|
|
|
43
57
|
* and therefore consumes less memory. We can not use a variant from
|
|
44
58
|
* RN, since this library supports earlier versions of RN.
|
|
45
59
|
*
|
|
60
|
+
* @param initialValue - Initial value of the animated value (numeric).
|
|
61
|
+
* @param config - Additional {@link Animated.AnimatedConfig|configuration} for the animated value.
|
|
62
|
+
* @returns Properly memoized {@link Animated.Value|Animated} value.
|
|
46
63
|
* @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const progress = useAnimatedValue(0);
|
|
67
|
+
* ```
|
|
47
68
|
*/
|
|
48
69
|
export function useAnimatedValue(initialValue, config) {
|
|
49
70
|
const ref = useRef(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","Animated","registerEventHandler","unregisterEventHandler","findNodeHandle","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","ids","attachWorkletHandlers","viewTag","current","__DEV__","console","warn","push","Object","keys","handlerName","eventName","get","functionToCall","event","queueMicrotask","forEach","id","useAnimatedValue","initialValue","config","ref","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport { registerEventHandler, unregisterEventHandler } from \"./event-handler\";\nimport { findNodeHandle } from \"./utils/findNodeHandle\";\n\ntype EventHandler = (event: never) => void;\ntype ComponentOrHandle = Parameters<typeof findNodeHandle>[0];\n\nexport function useEventHandlerRegistration<\n H extends Partial<Record<string, EventHandler>>,\n>(\n map: Map<keyof H, string>,\n viewTagRef: React.MutableRefObject<ComponentOrHandle>,\n) {\n const onRegisterHandler = (handler: H) => {\n const ids: (number | null)[] = [];\n const attachWorkletHandlers = () => {\n const viewTag = findNodeHandle(viewTagRef.current);\n\n if (__DEV__ && !viewTag) {\n console.warn(\n \"Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.\",\n );\n }\n\n ids.push(\n ...Object.keys(handler).map((handlerName) => {\n const eventName = map.get(handlerName as keyof H);\n const functionToCall = handler[handlerName as keyof H];\n\n if (eventName && viewTag) {\n return registerEventHandler(\n (event: Parameters<NonNullable<H[keyof H]>>[0]) => {\n \"worklet\";\n\n functionToCall?.(event);\n },\n eventName,\n viewTag,\n );\n }\n\n return null;\n }),\n );\n };\n\n if (viewTagRef.current) {\n attachWorkletHandlers();\n } else {\n // view may not be mounted yet - defer registration until call-stack becomes empty\n queueMicrotask(attachWorkletHandlers);\n }\n\n return () => {\n ids.forEach((id) => (id ? unregisterEventHandler(id) : null));\n };\n };\n\n return onRegisterHandler;\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig,\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current === null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,oBAAoB,EAAEC,sBAAsB,QAAQ,iBAAiB;AAC9E,SAASC,cAAc,QAAQ,wBAAwB;AAKvD,OAAO,SAASC,2BAA2BA,CAGzCC,GAAyB,EACzBC,UAAqD,EACrD;EACA,MAAMC,iBAAiB,GAAIC,OAAU,IAAK;IACxC,MAAMC,GAAsB,GAAG,EAAE;IACjC,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;MAClC,MAAMC,OAAO,GAAGR,cAAc,CAACG,UAAU,CAACM,OAAO,CAAC;MAElD,IAAIC,OAAO,IAAI,CAACF,OAAO,EAAE;QACvBG,OAAO,CAACC,IAAI,CACV,uPACF,CAAC;MACH;MAEAN,GAAG,CAACO,IAAI,CACN,GAAGC,MAAM,CAACC,IAAI,CAACV,OAAO,CAAC,CAACH,GAAG,CAAEc,WAAW,IAAK;QAC3C,MAAMC,SAAS,GAAGf,GAAG,CAACgB,GAAG,CAACF,WAAsB,CAAC;QACjD,MAAMG,cAAc,GAAGd,OAAO,CAACW,WAAW,CAAY;QAEtD,IAAIC,SAAS,IAAIT,OAAO,EAAE;UACxB,OAAOV,oBAAoB,CACxBsB,KAA6C,IAAK;YACjD,SAAS;;YAETD,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAGC,KAAK,CAAC;UACzB,CAAC,EACDH,SAAS,EACTT,OACF,CAAC;QACH;QAEA,OAAO,IAAI;MACb,CAAC,CACH,CAAC;IACH,CAAC;IAED,IAAIL,UAAU,CAACM,OAAO,EAAE;MACtBF,qBAAqB,CAAC,CAAC;IACzB,CAAC,MAAM;MACL;MACAc,cAAc,CAACd,qBAAqB,CAAC;IACvC;IAEA,OAAO,MAAM;MACXD,GAAG,CAACgB,OAAO,CAAEC,EAAE,IAAMA,EAAE,GAAGxB,sBAAsB,CAACwB,EAAE,CAAC,GAAG,IAAK,CAAC;IAC/D,CAAC;EACH,CAAC;EAED,OAAOnB,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASoB,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG/B,MAAM,CAAwB,IAAI,CAAC;EAE/C,IAAI+B,GAAG,CAAClB,OAAO,KAAK,IAAI,EAAE;IACxBkB,GAAG,CAAClB,OAAO,GAAG,IAAIZ,QAAQ,CAAC+B,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAAClB,OAAO;AACpB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useRef","Animated","registerEventHandler","unregisterEventHandler","findNodeHandle","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","ids","attachWorkletHandlers","viewTag","current","__DEV__","console","warn","push","Object","keys","handlerName","eventName","get","functionToCall","event","queueMicrotask","forEach","id","useAnimatedValue","initialValue","config","ref","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport { registerEventHandler, unregisterEventHandler } from \"./event-handler\";\nimport { findNodeHandle } from \"./utils/findNodeHandle\";\n\ntype EventHandler = (event: never) => void;\ntype ComponentOrHandle = Parameters<typeof findNodeHandle>[0];\n\n/**\n * An internal hook that helps to register workletized event handlers.\n *\n * @param map - Map of event handlers and their names.\n * @param viewTagRef - Ref to the view that produces events.\n * @returns A function that registers supplied event handlers.\n * @example\n * ```ts\n * const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(\n * keyboardEventsMap,\n * viewTagRef,\n * );\n * ```\n */\nexport function useEventHandlerRegistration<\n H extends Partial<Record<string, EventHandler>>,\n>(\n map: Map<keyof H, string>,\n viewTagRef: React.MutableRefObject<ComponentOrHandle>,\n) {\n const onRegisterHandler = (handler: H) => {\n const ids: (number | null)[] = [];\n const attachWorkletHandlers = () => {\n const viewTag = findNodeHandle(viewTagRef.current);\n\n if (__DEV__ && !viewTag) {\n console.warn(\n \"Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.\",\n );\n }\n\n ids.push(\n ...Object.keys(handler).map((handlerName) => {\n const eventName = map.get(handlerName as keyof H);\n const functionToCall = handler[handlerName as keyof H];\n\n if (eventName && viewTag) {\n return registerEventHandler(\n (event: Parameters<NonNullable<H[keyof H]>>[0]) => {\n \"worklet\";\n\n functionToCall?.(event);\n },\n eventName,\n viewTag,\n );\n }\n\n return null;\n }),\n );\n };\n\n if (viewTagRef.current) {\n attachWorkletHandlers();\n } else {\n // view may not be mounted yet - defer registration until call-stack becomes empty\n queueMicrotask(attachWorkletHandlers);\n }\n\n return () => {\n ids.forEach((id) => (id ? unregisterEventHandler(id) : null));\n };\n };\n\n return onRegisterHandler;\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @param initialValue - Initial value of the animated value (numeric).\n * @param config - Additional {@link Animated.AnimatedConfig|configuration} for the animated value.\n * @returns Properly memoized {@link Animated.Value|Animated} value.\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n * @example\n * ```ts\n * const progress = useAnimatedValue(0);\n * ```\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig,\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current === null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,oBAAoB,EAAEC,sBAAsB,QAAQ,iBAAiB;AAC9E,SAASC,cAAc,QAAQ,wBAAwB;AAKvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,2BAA2BA,CAGzCC,GAAyB,EACzBC,UAAqD,EACrD;EACA,MAAMC,iBAAiB,GAAIC,OAAU,IAAK;IACxC,MAAMC,GAAsB,GAAG,EAAE;IACjC,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;MAClC,MAAMC,OAAO,GAAGR,cAAc,CAACG,UAAU,CAACM,OAAO,CAAC;MAElD,IAAIC,OAAO,IAAI,CAACF,OAAO,EAAE;QACvBG,OAAO,CAACC,IAAI,CACV,uPACF,CAAC;MACH;MAEAN,GAAG,CAACO,IAAI,CACN,GAAGC,MAAM,CAACC,IAAI,CAACV,OAAO,CAAC,CAACH,GAAG,CAAEc,WAAW,IAAK;QAC3C,MAAMC,SAAS,GAAGf,GAAG,CAACgB,GAAG,CAACF,WAAsB,CAAC;QACjD,MAAMG,cAAc,GAAGd,OAAO,CAACW,WAAW,CAAY;QAEtD,IAAIC,SAAS,IAAIT,OAAO,EAAE;UACxB,OAAOV,oBAAoB,CACxBsB,KAA6C,IAAK;YACjD,SAAS;;YAETD,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAGC,KAAK,CAAC;UACzB,CAAC,EACDH,SAAS,EACTT,OACF,CAAC;QACH;QAEA,OAAO,IAAI;MACb,CAAC,CACH,CAAC;IACH,CAAC;IAED,IAAIL,UAAU,CAACM,OAAO,EAAE;MACtBF,qBAAqB,CAAC,CAAC;IACzB,CAAC,MAAM;MACL;MACAc,cAAc,CAACd,qBAAqB,CAAC;IACvC;IAEA,OAAO,MAAM;MACXD,GAAG,CAACgB,OAAO,CAAEC,EAAE,IAAMA,EAAE,GAAGxB,sBAAsB,CAACwB,EAAE,CAAC,GAAG,IAAK,CAAC;IAC/D,CAAC;EACH,CAAC;EAED,OAAOnB,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASoB,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG/B,MAAM,CAAwB,IAAI,CAAC;EAE/C,IAAI+B,GAAG,CAAClB,OAAO,KAAK,IAAI,EAAE;IACxBkB,GAAG,CAAClB,OAAO,GAAG,IAAIZ,QAAQ,CAAC+B,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAAClB,OAAO;AACpB","ignoreList":[]}
|
package/lib/module/module.js
CHANGED
|
@@ -32,6 +32,10 @@ const dismiss = async options => {
|
|
|
32
32
|
};
|
|
33
33
|
const isVisible = () => !isClosed;
|
|
34
34
|
const state = () => lastState;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* KeyboardController module. Helps to perform imperative actions/checks with keyboard.
|
|
38
|
+
*/
|
|
35
39
|
export const KeyboardController = {
|
|
36
40
|
setDefaultMode: KeyboardControllerNative.setDefaultMode,
|
|
37
41
|
setInputMode: KeyboardControllerNative.setInputMode,
|
package/lib/module/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardControllerNative","KeyboardEvents","isClosed","lastState","height","duration","timestamp","Date","getTime","target","type","appearance","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","isVisible","state","KeyboardController","setDefaultMode","setInputMode","setFocusTo"],"sources":["module.ts"],"sourcesContent":["import { KeyboardControllerNative, KeyboardEvents } from \"./bindings\";\n\nimport type {\n DismissOptions,\n KeyboardControllerModule,\n KeyboardEventData,\n} from \"./types\";\n\nlet isClosed = true;\nlet lastState: KeyboardEventData = {\n height: 0,\n duration: 0,\n timestamp: new Date().getTime(),\n target: -1,\n type: \"default\",\n appearance: \"default\",\n};\n\nKeyboardEvents.addListener(\"keyboardDidHide\", (e) => {\n isClosed = true;\n lastState = e;\n});\n\nKeyboardEvents.addListener(\"keyboardDidShow\", (e) => {\n isClosed = false;\n lastState = e;\n});\n\nconst dismiss = async (options?: DismissOptions): Promise<void> => {\n const keepFocus = options?.keepFocus ?? false;\n\n return new Promise((resolve) => {\n if (isClosed) {\n resolve();\n\n return;\n }\n\n const subscription = KeyboardEvents.addListener(\"keyboardDidHide\", () => {\n resolve(undefined);\n subscription.remove();\n });\n\n KeyboardControllerNative.dismiss(keepFocus);\n });\n};\nconst isVisible = () => !isClosed;\nconst state = () => lastState;\n\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: KeyboardControllerNative.setDefaultMode,\n setInputMode: KeyboardControllerNative.setInputMode,\n setFocusTo: KeyboardControllerNative.setFocusTo,\n dismiss,\n isVisible,\n state,\n};\n"],"mappings":"AAAA,SAASA,wBAAwB,EAAEC,cAAc,QAAQ,YAAY;AAQrE,IAAIC,QAAQ,GAAG,IAAI;AACnB,IAAIC,SAA4B,GAAG;EACjCC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAE,CAAC;EACXC,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAC/BC,MAAM,EAAE,CAAC,CAAC;EACVC,IAAI,EAAE,SAAS;EACfC,UAAU,EAAE;AACd,CAAC;AAEDV,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,IAAI;EACfC,SAAS,GAAGU,CAAC;AACf,CAAC,CAAC;AAEFZ,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAGU,CAAC;AACf,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,MAAOC,OAAwB,IAAoB;EACjE,MAAMC,SAAS,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,SAAS,KAAI,KAAK;EAE7C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,IAAIhB,QAAQ,EAAE;MACZgB,OAAO,CAAC,CAAC;MAET;IACF;IAEA,MAAMC,YAAY,GAAGlB,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAE,MAAM;MACvEM,OAAO,CAACE,SAAS,CAAC;MAClBD,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFrB,wBAAwB,CAACc,OAAO,CAACE,SAAS,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC;AACD,MAAMM,SAAS,GAAGA,CAAA,KAAM,CAACpB,QAAQ;AACjC,MAAMqB,KAAK,GAAGA,CAAA,KAAMpB,SAAS;
|
|
1
|
+
{"version":3,"names":["KeyboardControllerNative","KeyboardEvents","isClosed","lastState","height","duration","timestamp","Date","getTime","target","type","appearance","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","isVisible","state","KeyboardController","setDefaultMode","setInputMode","setFocusTo"],"sources":["module.ts"],"sourcesContent":["import { KeyboardControllerNative, KeyboardEvents } from \"./bindings\";\n\nimport type {\n DismissOptions,\n KeyboardControllerModule,\n KeyboardEventData,\n} from \"./types\";\n\nlet isClosed = true;\nlet lastState: KeyboardEventData = {\n height: 0,\n duration: 0,\n timestamp: new Date().getTime(),\n target: -1,\n type: \"default\",\n appearance: \"default\",\n};\n\nKeyboardEvents.addListener(\"keyboardDidHide\", (e) => {\n isClosed = true;\n lastState = e;\n});\n\nKeyboardEvents.addListener(\"keyboardDidShow\", (e) => {\n isClosed = false;\n lastState = e;\n});\n\nconst dismiss = async (options?: DismissOptions): Promise<void> => {\n const keepFocus = options?.keepFocus ?? false;\n\n return new Promise((resolve) => {\n if (isClosed) {\n resolve();\n\n return;\n }\n\n const subscription = KeyboardEvents.addListener(\"keyboardDidHide\", () => {\n resolve(undefined);\n subscription.remove();\n });\n\n KeyboardControllerNative.dismiss(keepFocus);\n });\n};\nconst isVisible = () => !isClosed;\nconst state = () => lastState;\n\n/**\n * KeyboardController module. Helps to perform imperative actions/checks with keyboard.\n */\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: KeyboardControllerNative.setDefaultMode,\n setInputMode: KeyboardControllerNative.setInputMode,\n setFocusTo: KeyboardControllerNative.setFocusTo,\n dismiss,\n isVisible,\n state,\n};\n"],"mappings":"AAAA,SAASA,wBAAwB,EAAEC,cAAc,QAAQ,YAAY;AAQrE,IAAIC,QAAQ,GAAG,IAAI;AACnB,IAAIC,SAA4B,GAAG;EACjCC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAE,CAAC;EACXC,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAC/BC,MAAM,EAAE,CAAC,CAAC;EACVC,IAAI,EAAE,SAAS;EACfC,UAAU,EAAE;AACd,CAAC;AAEDV,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,IAAI;EACfC,SAAS,GAAGU,CAAC;AACf,CAAC,CAAC;AAEFZ,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAGU,CAAC;AACf,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,MAAOC,OAAwB,IAAoB;EACjE,MAAMC,SAAS,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,SAAS,KAAI,KAAK;EAE7C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,IAAIhB,QAAQ,EAAE;MACZgB,OAAO,CAAC,CAAC;MAET;IACF;IAEA,MAAMC,YAAY,GAAGlB,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAE,MAAM;MACvEM,OAAO,CAACE,SAAS,CAAC;MAClBD,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFrB,wBAAwB,CAACc,OAAO,CAACE,SAAS,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC;AACD,MAAMM,SAAS,GAAGA,CAAA,KAAM,CAACpB,QAAQ;AACjC,MAAMqB,KAAK,GAAGA,CAAA,KAAMpB,SAAS;;AAE7B;AACA;AACA;AACA,OAAO,MAAMqB,kBAA4C,GAAG;EAC1DC,cAAc,EAAEzB,wBAAwB,CAACyB,cAAc;EACvDC,YAAY,EAAE1B,wBAAwB,CAAC0B,YAAY;EACnDC,UAAU,EAAE3B,wBAAwB,CAAC2B,UAAU;EAC/Cb,OAAO;EACPQ,SAAS;EACTC;AACF,CAAC","ignoreList":[]}
|
|
@@ -22,11 +22,6 @@ const ModifiedNativeAndroidManager = {
|
|
|
22
22
|
setTranslucent: translucent => {
|
|
23
23
|
RCTStatusBarManagerCompat.setTranslucent(translucent);
|
|
24
24
|
},
|
|
25
|
-
/**
|
|
26
|
-
* - statusBarStyles can be:
|
|
27
|
-
* - 'default'
|
|
28
|
-
* - 'dark-content'
|
|
29
|
-
*/
|
|
30
25
|
setStyle: statusBarStyle => {
|
|
31
26
|
RCTStatusBarManagerCompat.setStyle(statusBarStyle);
|
|
32
27
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeAndroidManager","RCTStatusBarManagerCompat","require","default","OriginalNativeAndroidManager","ModifiedNativeAndroidManager","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden","applyMonkeyPatch","Object","assign","revertMonkeyPatch"],"sources":["monkey-patch.android.ts"],"sourcesContent":["// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from \"react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid\";\n\nconst RCTStatusBarManagerCompat =\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require(\"./specs/NativeStatusBarManagerCompat\").default;\n\n// Copy original default manager to keep its original state and methods\nconst OriginalNativeAndroidManager = { ...NativeAndroidManager.default };\n\n// Create a new object that modifies the necessary methods\n// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so\n// in order to use library on all available platforms we have to monkey patch\n// default RN implementation and use modern `WindowInsetsControllerCompat`.\nconst ModifiedNativeAndroidManager = {\n ...NativeAndroidManager.default, // Spread original properties to keep existing functionality\n setColor: (color: number, animated: boolean): void => {\n RCTStatusBarManagerCompat.setColor(color, animated);\n },\n setTranslucent: (translucent: boolean): void => {\n RCTStatusBarManagerCompat.setTranslucent(translucent);\n },\n
|
|
1
|
+
{"version":3,"names":["NativeAndroidManager","RCTStatusBarManagerCompat","require","default","OriginalNativeAndroidManager","ModifiedNativeAndroidManager","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden","applyMonkeyPatch","Object","assign","revertMonkeyPatch"],"sources":["monkey-patch.android.ts"],"sourcesContent":["// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from \"react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid\";\n\nconst RCTStatusBarManagerCompat =\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require(\"./specs/NativeStatusBarManagerCompat\").default;\n\n// Copy original default manager to keep its original state and methods\nconst OriginalNativeAndroidManager = { ...NativeAndroidManager.default };\n\n// Create a new object that modifies the necessary methods\n// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so\n// in order to use library on all available platforms we have to monkey patch\n// default RN implementation and use modern `WindowInsetsControllerCompat`.\nconst ModifiedNativeAndroidManager = {\n ...NativeAndroidManager.default, // Spread original properties to keep existing functionality\n setColor: (color: number, animated: boolean): void => {\n RCTStatusBarManagerCompat.setColor(color, animated);\n },\n setTranslucent: (translucent: boolean): void => {\n RCTStatusBarManagerCompat.setTranslucent(translucent);\n },\n setStyle: (\n statusBarStyle?: \"default\" | \"dark-content\" | \"light-content\",\n ): void => {\n RCTStatusBarManagerCompat.setStyle(statusBarStyle);\n },\n setHidden: (hidden: boolean): void => {\n RCTStatusBarManagerCompat.setHidden(hidden);\n },\n};\n\n// Define a function to apply the monkey patch\nexport const applyMonkeyPatch = () => {\n Object.assign(NativeAndroidManager.default, ModifiedNativeAndroidManager);\n};\n\n// Define a function to revert changes back to the original state\nexport const revertMonkeyPatch = () => {\n Object.assign(NativeAndroidManager.default, OriginalNativeAndroidManager);\n};\n"],"mappings":"AAAA;AACA,OAAO,KAAKA,oBAAoB,MAAM,2EAA2E;AAEjH,MAAMC,yBAAyB;AAC7B;AACAC,OAAO,CAAC,sCAAsC,CAAC,CAACC,OAAO;;AAEzD;AACA,MAAMC,4BAA4B,GAAG;EAAE,GAAGJ,oBAAoB,CAACG;AAAQ,CAAC;;AAExE;AACA;AACA;AACA;AACA,MAAME,4BAA4B,GAAG;EACnC,GAAGL,oBAAoB,CAACG,OAAO;EAAE;EACjCG,QAAQ,EAAEA,CAACC,KAAa,EAAEC,QAAiB,KAAW;IACpDP,yBAAyB,CAACK,QAAQ,CAACC,KAAK,EAAEC,QAAQ,CAAC;EACrD,CAAC;EACDC,cAAc,EAAGC,WAAoB,IAAW;IAC9CT,yBAAyB,CAACQ,cAAc,CAACC,WAAW,CAAC;EACvD,CAAC;EACDC,QAAQ,EACNC,cAA6D,IACpD;IACTX,yBAAyB,CAACU,QAAQ,CAACC,cAAc,CAAC;EACpD,CAAC;EACDC,SAAS,EAAGC,MAAe,IAAW;IACpCb,yBAAyB,CAACY,SAAS,CAACC,MAAM,CAAC;EAC7C;AACF,CAAC;;AAED;AACA,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;EACpCC,MAAM,CAACC,MAAM,CAACjB,oBAAoB,CAACG,OAAO,EAAEE,4BAA4B,CAAC;AAC3E,CAAC;;AAED;AACA,OAAO,MAAMa,iBAAiB,GAAGA,CAAA,KAAM;EACrCF,MAAM,CAACC,MAAM,CAACjB,oBAAoB,CAACG,OAAO,EAAEC,4BAA4B,CAAC;AAC3E,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["hooks.ts"],"sourcesContent":["import type { NativeSyntheticEvent, ViewProps } from \"react-native\";\n\n// DirectEventHandler events declaration\nexport type NativeEvent = {\n /** A value between `0` and `1` indicating keyboard position, where `0` means keyboard is closed and `1` means keyboard is fully visible. */\n progress: number;\n /** Height of the keyboard. */\n height: number;\n /** Duration of the keyboard animation. */\n duration: number;\n /** Tag of the focused `TextInput`. */\n target: number;\n};\nexport type FocusedInputLayoutChangedEvent = {\n /** Tag of the focused `TextInput`. */\n target: number;\n /** Tag of the parent `ScrollView`. */\n parentScrollViewTarget: number;\n layout: {\n /** X coordinate of the focused `TextInput`. */\n x: number;\n /** Y coordinate of the focused `TextInput`. */\n y: number;\n /** Width of the focused `TextInput`. */\n width: number;\n /** Height of the focused `TextInput`. */\n height: number;\n /** X coordinate of the focused `TextInput` relative to the screen. */\n absoluteX: number;\n /** Y coordinate of the focused `TextInput` relative to the screen. */\n absoluteY: number;\n };\n};\nexport type FocusedInputTextChangedEvent = {\n /** Text that user typed in the focused `TextInput`. */\n text: string;\n};\nexport type FocusedInputSelectionChangedEvent = {\n /** Tag of the focused `TextInput`. */\n target: number;\n selection: {\n /** Start of the selection. Represents top-left point of rectangle. */\n start: {\n /** X coordinate of the selection start (relative to the `TextInput`). */\n x: number;\n /** Y coordinate of the selection start (relative to the `TextInput`). */\n y: number;\n /** The start of selection. */\n position: number;\n };\n /** End of the selection. Represents bottom-right point of rectangle. */\n end: {\n /** X coordinate of the selection end (relative to the `TextInput`). */\n x: number;\n /** Y coordinate of the selection end (relative to the `TextInput`). */\n y: number;\n /** The end of selection. */\n position: number;\n };\n };\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n //ref prop\n ref?: React.Ref<React.Component<KeyboardControllerProps>>;\n // callback props\n onKeyboardMoveStart?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMove?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveEnd?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveInteractive?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n onFocusedInputSelectionChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\n ) => void;\n // fake props used to activate reanimated bindings\n onKeyboardMoveReanimated?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n onFocusedInputSelectionChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\n ) => void;\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n preserveEdgeToEdge?: boolean;\n enabled?: boolean;\n} & ViewProps;\n\n// reanimated hook declaration\nexport type KeyboardHandlerHook<TContext, Event> = (\n handlers: {\n onKeyboardMoveStart?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveEnd?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveInteractive?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputLayoutHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputLayoutChanged?: (\n e: FocusedInputLayoutChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputTextHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputTextChanged?: (\n e: FocusedInputTextChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputSelectionHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputSelectionChanged?: (\n e: FocusedInputSelectionChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\n\n// package types\nexport type Handlers<T> = Record<string, T | undefined>;\nexport type KeyboardHandler = Partial<{\n /**\n * A callback that gets invoked when keyboard starts its movement.\n * The event contains DESTINATION values.\n *\n * @example\n * ```ts\n * onStart: (e) => {\n * \"worklet\";\n *\n * const willKeyboardAppear = e.progress === 1;\n * }\n * ```\n */\n onStart: (e: NativeEvent) => void;\n /**\n * A callback that gets involved every frame when keyboard changes its position.\n *\n * @example\n * ```ts\n * onMove: (e) => {\n * \"worklet\";\n *\n * const keyboardHeight = e.height;\n * }\n */\n onMove: (e: NativeEvent) => void;\n /**\n * A callback that gets invoked when keyboard finished its movement.\n *\n * @example\n * ```ts\n * onEnd: (e) => {\n * \"worklet\";\n *\n * const isKeyboardShown = e.progress === 1;\n * }\n * ```\n */\n onEnd: (e: NativeEvent) => void;\n /**\n * A callback that gets invoked every frame when keyboard changes its position due to interactive dismissal.\n *\n * @example\n * ```ts\n * onInteractive: (e) => {\n * \"worklet\";\n *\n * const keyboardHeight = e.height;\n * }\n */\n onInteractive: (e: NativeEvent) => void;\n}>;\nexport type KeyboardHandlers = Handlers<KeyboardHandler>;\nexport type FocusedInputHandler = Partial<{\n /** A callback that gets invoked every time when the text changes in focused input. */\n onChangeText: (e: FocusedInputTextChangedEvent) => void;\n /** A callback that gets invoked every time when the selection (cursor) coordinates change in focused input. */\n onSelectionChange: (e: FocusedInputSelectionChangedEvent) => void;\n}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./hooks\";\nexport * from \"./views\";\nexport * from \"./module\";\nexport * from \"./internal\";\n"],"mappings":"AAAA,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["internal.ts"],"sourcesContent":["import type { EmitterSubscription } from \"react-native\";\n\nexport type FocusedInputAvailableEvents = \"focusDidSet\";\nexport type FocusedInputEventData = {\n current: number;\n count: number;\n};\nexport type FocusedInputEventsModule = {\n addListener: (\n name: FocusedInputAvailableEvents,\n cb: (e: FocusedInputEventData) => void,\n ) => EmitterSubscription;\n};\nexport type WindowDimensionsAvailableEvents = \"windowDidResize\";\nexport type WindowDimensionsEventData = {\n width: number;\n height: number;\n};\nexport type WindowDimensionsEventsModule = {\n addListener: (\n name: WindowDimensionsAvailableEvents,\n cb: (e: WindowDimensionsEventData) => void,\n ) => EmitterSubscription;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["module.ts"],"sourcesContent":["import type { EmitterSubscription, TextInputProps } from \"react-native\";\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n /** Height of the keyboard. */\n height: number;\n /** Duration of the keyboard animation. */\n duration: number;\n /** Timestamp of the last keyboard event. */\n timestamp: number;\n /** Tag of the focused `TextInput`. */\n target: number;\n /** `keyboardType` property from focused `TextInput`. */\n type: NonNullable<TextInputProps[\"keyboardType\"]>;\n /** Keyboard appearance. Can be one of `default`, `dark` or `light`. */\n appearance: NonNullable<TextInputProps[\"keyboardAppearance\"]>;\n};\n/**\n * An object that represent current keyboard state.\n */\nexport type KeyboardState = {\n /** Whether the keyboard is currently visible. */\n isVisible: boolean;\n} & KeyboardEventData;\nexport type KeyboardEventsModule = {\n /**\n * The `addListener` function connects a JavaScript function to an identified native\n * keyboard notification event.\n *\n * This function then returns the reference to the listener.\n *\n * `name` is the string that identifies the event you're listening for. This\n * can be any of the following:\n *\n * - `keyboardWillShow`;\n * - `keyboardDidShow`;\n * - `keyboardWillHide`;\n * - `keyboardDidHide`.\n */\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void,\n ) => EmitterSubscription;\n};\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type DismissOptions = {\n /**\n * A boolean property indicating whether focus should be kept on the input after dismissing the keyboard. Default is `false`.\n */\n keepFocus: boolean;\n};\nexport type KeyboardControllerModule = {\n // android only\n /**\n * Sets default `windowSoftInputMode` (the one that declared in `AndroidManifest.xml`).\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setdefaultmode-|docs} page for more details.\n */\n setDefaultMode: () => void;\n /**\n * Changes `windowSoftInputMode` on Android. @see AndroidSoftInputModes for all possible values and {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|docs} page for more details.\n */\n setInputMode: (mode: number) => void;\n // all platforms\n /**\n * Dismisses the active keyboard. Removes a focus by default, but allows to pass `{keepFocus: true}` to keep focus.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#dismiss|docs} page for more details.\n */\n dismiss: (options?: DismissOptions) => Promise<void>;\n /**\n * Moves focus to the specified direction (`next`, `prev` or `current` to restore a focus).\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setfocusto|docs} page for more details.\n */\n setFocusTo: (direction: Direction) => void;\n /**\n * Whether the keyboard is fully visible.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#isvisible|docs} page for more details.\n */\n isVisible: () => boolean;\n /**\n * Method that returns current keyboard state.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#state|docs} page for more details.\n */\n state: () => KeyboardEventData;\n};\nexport type KeyboardControllerNativeModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: (keepFocus: boolean) => void;\n setFocusTo: (direction: Direction) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["views.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type { ViewProps } from \"react-native\";\n\nexport type KeyboardGestureAreaProps = {\n /**\n * Determines how the keyboard position will be controlled:\n * - `ios` - keyboard will be following finger only when finger touches keyboard\n * - `linear` - keyboard will be following finger position linearly.\n *\n * @platform android\n */\n interpolator?: \"ios\" | \"linear\";\n /**\n * Whether to allow to show a keyboard from dismissed state by swipe up.\n * Default to `false`.\n *\n * @platform android\n */\n showOnSwipeUp?: boolean;\n /**\n * Whether to allow to control a keyboard by gestures. The strategy how\n * it should be controlled is determined by `interpolator` property.\n * Defaults to `true`.\n *\n * @platform android\n */\n enableSwipeToDismiss?: boolean;\n /**\n * Extra distance to the keyboard.\n */\n offset?: number;\n /**\n * A corresponding `nativeID` value from the associated `TextInput` (a string that links the `KeyboardGestureArea` to one or more `TextInput` components).\n * This is **required on iOS** in order to apply the `offset` when the keyboard is shown. Only the currently focused `TextInput` with a matching `nativeID`\n * will receive offset behavior.\n *\n * @platform ios\n */\n textInputNativeID?: string;\n} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n /**\n * A boolean prop indicating whether the view is visible or not. If it's true then view is shown on the screen. If it's false then view is hidden.\n */\n visible: boolean;\n}>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -2,10 +2,24 @@ import React, { useMemo } from "react";
|
|
|
2
2
|
import { Platform, StyleSheet, View } from "react-native";
|
|
3
3
|
import { RCTOverKeyboardView } from "../../bindings";
|
|
4
4
|
import { useWindowDimensions } from "../../hooks";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A view component that renders its children over the keyboard without closing the keyboard.
|
|
7
|
+
* Acts similar to modal, but doesn't close the keyboard when it's visible.
|
|
8
|
+
*
|
|
9
|
+
* @param props - Component props.
|
|
10
|
+
* @returns A view component that renders over the keyboard.
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <OverKeyboardView visible={true}>
|
|
14
|
+
* <Text>This will appear over the keyboard</Text>
|
|
15
|
+
* </OverKeyboardView>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
const OverKeyboardView = props => {
|
|
19
|
+
const {
|
|
20
|
+
children,
|
|
21
|
+
visible
|
|
22
|
+
} = props;
|
|
9
23
|
const {
|
|
10
24
|
height,
|
|
11
25
|
width
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","Platform","StyleSheet","View","RCTOverKeyboardView","useWindowDimensions","OverKeyboardView","children","visible","height","width","inner","style","styles","absolute","OS","undefined","stretch","createElement","collapsable","create","position","top","bottom","left","right"],"sources":["index.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Platform, StyleSheet, View } from \"react-native\";\n\nimport { RCTOverKeyboardView } from \"../../bindings\";\nimport { useWindowDimensions } from \"../../hooks\";\n\nimport type { OverKeyboardViewProps } from \"../../types\";\nimport type { PropsWithChildren } from \"react\";\n\
|
|
1
|
+
{"version":3,"names":["React","useMemo","Platform","StyleSheet","View","RCTOverKeyboardView","useWindowDimensions","OverKeyboardView","props","children","visible","height","width","inner","style","styles","absolute","OS","undefined","stretch","createElement","collapsable","create","position","top","bottom","left","right"],"sources":["index.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Platform, StyleSheet, View } from \"react-native\";\n\nimport { RCTOverKeyboardView } from \"../../bindings\";\nimport { useWindowDimensions } from \"../../hooks\";\n\nimport type { OverKeyboardViewProps } from \"../../types\";\nimport type { PropsWithChildren } from \"react\";\n\n/**\n * A view component that renders its children over the keyboard without closing the keyboard.\n * Acts similar to modal, but doesn't close the keyboard when it's visible.\n *\n * @param props - Component props.\n * @returns A view component that renders over the keyboard.\n * @example\n * ```tsx\n * <OverKeyboardView visible={true}>\n * <Text>This will appear over the keyboard</Text>\n * </OverKeyboardView>\n * ```\n */\nconst OverKeyboardView = (props: PropsWithChildren<OverKeyboardViewProps>) => {\n const { children, visible } = props;\n const { height, width } = useWindowDimensions();\n const inner = useMemo(() => ({ height, width }), [height, width]);\n const style = useMemo(\n () => [\n styles.absolute,\n // On iOS - stretch view to full window dimensions to make yoga work\n Platform.OS === \"ios\" ? inner : undefined,\n // On Android - we are laid out by ShadowNode, so just stretch to full container\n Platform.OS === \"android\" ? styles.stretch : undefined,\n ],\n [inner],\n );\n\n return (\n <RCTOverKeyboardView visible={visible}>\n {/* `OverKeyboardView` should always have a single child */}\n <View collapsable={false} style={style}>\n {/* Match RN behavior and trigger mount/unmount when visibility changes */}\n {visible && children}\n </View>\n </RCTOverKeyboardView>\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: \"absolute\",\n },\n stretch: {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n },\n});\n\nexport default OverKeyboardView;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAEzD,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,mBAAmB,QAAQ,aAAa;AAKjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAIC,KAA+C,IAAK;EAC5E,MAAM;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,GAAGF,KAAK;EACnC,MAAM;IAAEG,MAAM;IAAEC;EAAM,CAAC,GAAGN,mBAAmB,CAAC,CAAC;EAC/C,MAAMO,KAAK,GAAGZ,OAAO,CAAC,OAAO;IAAEU,MAAM;IAAEC;EAAM,CAAC,CAAC,EAAE,CAACD,MAAM,EAAEC,KAAK,CAAC,CAAC;EACjE,MAAME,KAAK,GAAGb,OAAO,CACnB,MAAM,CACJc,MAAM,CAACC,QAAQ;EACf;EACAd,QAAQ,CAACe,EAAE,KAAK,KAAK,GAAGJ,KAAK,GAAGK,SAAS;EACzC;EACAhB,QAAQ,CAACe,EAAE,KAAK,SAAS,GAAGF,MAAM,CAACI,OAAO,GAAGD,SAAS,CACvD,EACD,CAACL,KAAK,CACR,CAAC;EAED,oBACEb,KAAA,CAAAoB,aAAA,CAACf,mBAAmB;IAACK,OAAO,EAAEA;EAAQ,gBAEpCV,KAAA,CAAAoB,aAAA,CAAChB,IAAI;IAACiB,WAAW,EAAE,KAAM;IAACP,KAAK,EAAEA;EAAM,GAEpCJ,OAAO,IAAID,QACR,CACa,CAAC;AAE1B,CAAC;AAED,MAAMM,MAAM,GAAGZ,UAAU,CAACmB,MAAM,CAAC;EAC/BN,QAAQ,EAAE;IACRO,QAAQ,EAAE;EACZ,CAAC;EACDJ,OAAO,EAAE;IACPK,GAAG,EAAE,CAAC;IACNC,MAAM,EAAE,CAAC;IACTC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE;EACT;AACF,CAAC,CAAC;AAEF,eAAepB,gBAAgB","ignoreList":[]}
|
|
@@ -7,33 +7,47 @@ type KeyboardProviderProps = {
|
|
|
7
7
|
* or `StatusBar` component from `react-native`, you can ignore it.
|
|
8
8
|
* Defaults to `false`.
|
|
9
9
|
*
|
|
10
|
-
* @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14
|
|
11
10
|
* @platform android
|
|
11
|
+
* @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14
|
|
12
12
|
*/
|
|
13
13
|
statusBarTranslucent?: boolean;
|
|
14
14
|
/**
|
|
15
15
|
* Set the value to `true`, if you use translucent navigation bar on Android.
|
|
16
16
|
* Defaults to `false`.
|
|
17
17
|
*
|
|
18
|
-
* @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119
|
|
19
18
|
* @platform android
|
|
19
|
+
* @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119
|
|
20
20
|
*/
|
|
21
21
|
navigationBarTranslucent?: boolean;
|
|
22
22
|
/**
|
|
23
23
|
* A boolean property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).
|
|
24
24
|
* Defaults to `false`.
|
|
25
25
|
*
|
|
26
|
-
* @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592
|
|
27
26
|
* @platform android
|
|
27
|
+
* @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592
|
|
28
28
|
*/
|
|
29
29
|
preserveEdgeToEdge?: boolean;
|
|
30
30
|
/**
|
|
31
|
-
* A boolean prop indicating whether the module is enabled. It indicate only initial state
|
|
32
|
-
*
|
|
31
|
+
* A boolean prop indicating whether the module is enabled. It indicate only initial state
|
|
32
|
+
* (if you try to change this prop after component mount it will not have any effect).
|
|
33
33
|
* To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.
|
|
34
34
|
* Defaults to `true`.
|
|
35
35
|
*/
|
|
36
36
|
enabled?: boolean;
|
|
37
37
|
};
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* A component that wrap your app. Under the hood it works with {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|KeyboardControllerView} to receive events during keyboard movements,
|
|
40
|
+
* maps these events to `Animated`/`Reanimated` values and store them in context.
|
|
41
|
+
*
|
|
42
|
+
* @param props - Provider props, such as `statusBarTranslucent`, `navigationBarTranslucent`, etc.
|
|
43
|
+
* @returns A component that should be mounted in root of your App layout.
|
|
44
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-provider|Documentation} page for more details.
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <KeyboardProvider>
|
|
48
|
+
* <NavigationContainer />
|
|
49
|
+
* </KeyboardProvider>
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare const KeyboardProvider: (props: KeyboardProviderProps) => React.JSX.Element;
|
|
39
53
|
export {};
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { FocusedInputEventsModule, KeyboardControllerNativeModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
|
|
2
2
|
export declare const KeyboardControllerNative: KeyboardControllerNativeModule;
|
|
3
|
+
/**
|
|
4
|
+
* An event emitter that provides a way to subscribe to next keyboard events:
|
|
5
|
+
* - `keyboardWillShow`;
|
|
6
|
+
* - `keyboardDidShow`;
|
|
7
|
+
* - `keyboardWillHide`;
|
|
8
|
+
* - `keyboardDidHide`.
|
|
9
|
+
*
|
|
10
|
+
* Use `addListener` function to add your event listener for a specific keyboard event.
|
|
11
|
+
*/
|
|
3
12
|
export declare const KeyboardEvents: KeyboardEventsModule;
|
|
4
13
|
/**
|
|
5
14
|
* This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
|
|
@@ -7,6 +16,16 @@ export declare const KeyboardEvents: KeyboardEventsModule;
|
|
|
7
16
|
*/
|
|
8
17
|
export declare const FocusedInputEvents: FocusedInputEventsModule;
|
|
9
18
|
export declare const WindowDimensionsEvents: WindowDimensionsEventsModule;
|
|
19
|
+
/**
|
|
20
|
+
* A view that sends events whenever keyboard or focused events are happening.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|Documentation} page for more details.
|
|
23
|
+
*/
|
|
10
24
|
export declare const KeyboardControllerView: React.FC<KeyboardControllerProps>;
|
|
25
|
+
/**
|
|
26
|
+
* A view that defines a region on the screen, where gestures will control the keyboard position.
|
|
27
|
+
*
|
|
28
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-gesture-area|Documentation} page for more details.
|
|
29
|
+
*/
|
|
11
30
|
export declare const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps>;
|
|
12
31
|
export declare const RCTOverKeyboardView: React.FC<OverKeyboardViewProps>;
|