react-native-keyboard-controller 1.12.1 → 1.12.3
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/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +11 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +11 -2
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/WindowDimensionListener.kt +57 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +9 -9
- package/ios/Extensions.swift +1 -1
- package/ios/delegates/KCTextInputCompositeDelegate.swift +1 -0
- package/ios/traversal/KeyboardView.swift +5 -8
- package/jest/index.js +3 -1
- package/lib/commonjs/bindings.js +6 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +4 -1
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +2 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +8 -5
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js +11 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/commonjs/{hooks.js → hooks/index.js} +27 -5
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/useWindowDimensions/index.android.js +29 -0
- package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -0
- package/lib/commonjs/hooks/useWindowDimensions/index.js +13 -0
- package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/bindings.js +5 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +3 -0
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +2 -1
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +10 -7
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/utils.js +9 -0
- package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/module/{hooks.js → hooks/index.js} +6 -5
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useWindowDimensions/index.android.js +22 -0
- package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -0
- package/lib/module/hooks/useWindowDimensions/index.js +2 -0
- package/lib/module/hooks/useWindowDimensions/index.js.map +1 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/bindings.d.ts +2 -1
- package/lib/typescript/bindings.native.d.ts +2 -1
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -0
- package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +1 -0
- package/lib/typescript/{hooks.d.ts → hooks/index.d.ts} +4 -3
- package/lib/typescript/hooks/useWindowDimensions/index.android.d.ts +2 -0
- package/lib/typescript/hooks/useWindowDimensions/index.d.ts +1 -0
- package/lib/typescript/types.d.ts +8 -0
- package/package.json +1 -1
- package/src/bindings.native.ts +5 -0
- package/src/bindings.ts +4 -0
- package/src/components/KeyboardAvoidingView/index.tsx +3 -1
- package/src/components/KeyboardAwareScrollView/index.tsx +23 -6
- package/src/components/KeyboardAwareScrollView/utils.ts +15 -0
- package/src/{hooks.ts → hooks/index.ts} +8 -6
- package/src/hooks/useWindowDimensions/index.android.ts +33 -0
- package/src/hooks/useWindowDimensions/index.ts +1 -0
- package/src/types.ts +11 -0
- package/lib/commonjs/hooks.js.map +0 -1
- package/lib/module/hooks.js.map +0 -1
|
@@ -7,6 +7,8 @@ export type KeyboardAwareScrollViewProps = {
|
|
|
7
7
|
disableScrollOnKeyboardHide?: boolean;
|
|
8
8
|
/** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */
|
|
9
9
|
enabled?: boolean;
|
|
10
|
+
/** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */
|
|
11
|
+
extraKeyboardSpace?: number;
|
|
10
12
|
} & ScrollViewProps;
|
|
11
13
|
declare const KeyboardAwareScrollView: React.ForwardRefExoticComponent<{
|
|
12
14
|
/** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */
|
|
@@ -15,6 +17,8 @@ declare const KeyboardAwareScrollView: React.ForwardRefExoticComponent<{
|
|
|
15
17
|
disableScrollOnKeyboardHide?: boolean | undefined;
|
|
16
18
|
/** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */
|
|
17
19
|
enabled?: boolean | undefined;
|
|
20
|
+
/** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */
|
|
21
|
+
extraKeyboardSpace?: number | undefined;
|
|
18
22
|
} & ScrollViewProps & {
|
|
19
23
|
children?: React.ReactNode;
|
|
20
24
|
} & React.RefAttributes<ScrollView>>;
|
|
@@ -1 +1,2 @@
|
|
|
1
1
|
export declare const debounce: <F extends (...args: Parameters<F>) => ReturnType<F>>(worklet: F, wait?: number) => (...args: Parameters<F>) => void | ReturnType<F>;
|
|
2
|
+
export declare const scrollDistanceWithRespectToSnapPoints: (defaultScrollValue: number, snapPoints?: number[]) => number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AnimatedContext, ReanimatedContext } from "
|
|
2
|
-
import type { FocusedInputHandler, KeyboardHandler } from "
|
|
1
|
+
import type { AnimatedContext, ReanimatedContext } from "../context";
|
|
2
|
+
import type { FocusedInputHandler, KeyboardHandler } from "../types";
|
|
3
3
|
import type { DependencyList } from "react";
|
|
4
4
|
export declare const useResizeMode: () => void;
|
|
5
5
|
export declare const useKeyboardAnimation: () => AnimatedContext;
|
|
@@ -11,6 +11,7 @@ export declare function useKeyboardController(): {
|
|
|
11
11
|
enabled: boolean;
|
|
12
12
|
};
|
|
13
13
|
export declare function useReanimatedFocusedInput(): {
|
|
14
|
-
input: import("react-native-reanimated").SharedValue<import("
|
|
14
|
+
input: import("react-native-reanimated").SharedValue<import("../types").FocusedInputLayoutChangedEvent | null>;
|
|
15
15
|
};
|
|
16
16
|
export declare function useFocusedInputHandler(handler?: FocusedInputHandler, deps?: DependencyList): void;
|
|
17
|
+
export * from "./useWindowDimensions";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useWindowDimensions } from "react-native";
|
|
@@ -95,6 +95,14 @@ export type FocusedInputEventData = {
|
|
|
95
95
|
export type FocusedInputEventsModule = {
|
|
96
96
|
addListener: (name: FocusedInputAvailableEvents, cb: (e: FocusedInputEventData) => void) => EmitterSubscription;
|
|
97
97
|
};
|
|
98
|
+
export type WindowDimensionsAvailableEvents = "windowDidResize";
|
|
99
|
+
export type WindowDimensionsEventData = {
|
|
100
|
+
width: number;
|
|
101
|
+
height: number;
|
|
102
|
+
};
|
|
103
|
+
export type WindowDimensionsEventsModule = {
|
|
104
|
+
addListener: (name: WindowDimensionsAvailableEvents, cb: (e: WindowDimensionsEventData) => void) => EmitterSubscription;
|
|
105
|
+
};
|
|
98
106
|
export type KeyboardHandlerHook<TContext, Event> = (handlers: {
|
|
99
107
|
onKeyboardMoveStart?: (e: NativeEvent, context: TContext) => void;
|
|
100
108
|
onKeyboardMove?: (e: NativeEvent, context: TContext) => void;
|
package/package.json
CHANGED
package/src/bindings.native.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
KeyboardControllerProps,
|
|
7
7
|
KeyboardEventsModule,
|
|
8
8
|
KeyboardGestureAreaProps,
|
|
9
|
+
WindowDimensionsEventsModule,
|
|
9
10
|
} from "./types";
|
|
10
11
|
|
|
11
12
|
const LINKING_ERROR =
|
|
@@ -44,6 +45,10 @@ export const FocusedInputEvents: FocusedInputEventsModule = {
|
|
|
44
45
|
addListener: (name, cb) =>
|
|
45
46
|
eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),
|
|
46
47
|
};
|
|
48
|
+
export const WindowDimensionsEvents: WindowDimensionsEventsModule = {
|
|
49
|
+
addListener: (name, cb) =>
|
|
50
|
+
eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),
|
|
51
|
+
};
|
|
47
52
|
export const KeyboardControllerView: React.FC<KeyboardControllerProps> =
|
|
48
53
|
require("./specs/KeyboardControllerViewNativeComponent").default;
|
|
49
54
|
export const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =
|
package/src/bindings.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
KeyboardControllerProps,
|
|
7
7
|
KeyboardEventsModule,
|
|
8
8
|
KeyboardGestureAreaProps,
|
|
9
|
+
WindowDimensionsEventsModule,
|
|
9
10
|
} from "./types";
|
|
10
11
|
import type { EmitterSubscription } from "react-native";
|
|
11
12
|
|
|
@@ -28,6 +29,9 @@ export const KeyboardEvents: KeyboardEventsModule = {
|
|
|
28
29
|
export const FocusedInputEvents: FocusedInputEventsModule = {
|
|
29
30
|
addListener: () => ({ remove: NOOP } as EmitterSubscription),
|
|
30
31
|
};
|
|
32
|
+
export const WindowDimensionsEvents: WindowDimensionsEventsModule = {
|
|
33
|
+
addListener: () => ({ remove: NOOP } as EmitterSubscription),
|
|
34
|
+
};
|
|
31
35
|
export const KeyboardControllerView =
|
|
32
36
|
View as unknown as React.FC<KeyboardControllerProps>;
|
|
33
37
|
export const KeyboardGestureArea =
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, useCallback, useMemo } from "react";
|
|
2
|
-
import { View
|
|
2
|
+
import { View } from "react-native";
|
|
3
3
|
import Reanimated, {
|
|
4
4
|
interpolate,
|
|
5
5
|
runOnUI,
|
|
@@ -8,6 +8,8 @@ import Reanimated, {
|
|
|
8
8
|
useSharedValue,
|
|
9
9
|
} from "react-native-reanimated";
|
|
10
10
|
|
|
11
|
+
import { useWindowDimensions } from "react-native-keyboard-controller";
|
|
12
|
+
|
|
11
13
|
import { useKeyboardAnimation } from "./hooks";
|
|
12
14
|
|
|
13
15
|
import type { LayoutRectangle, ViewProps } from "react-native";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, useCallback, useMemo } from "react";
|
|
2
|
-
import { findNodeHandle
|
|
2
|
+
import { findNodeHandle } from "react-native";
|
|
3
3
|
import Reanimated, {
|
|
4
4
|
interpolate,
|
|
5
5
|
scrollTo,
|
|
@@ -12,10 +12,11 @@ import Reanimated, {
|
|
|
12
12
|
import {
|
|
13
13
|
useFocusedInputHandler,
|
|
14
14
|
useReanimatedFocusedInput,
|
|
15
|
+
useWindowDimensions,
|
|
15
16
|
} from "react-native-keyboard-controller";
|
|
16
17
|
|
|
17
18
|
import { useSmoothKeyboardHandler } from "./useSmoothKeyboardHandler";
|
|
18
|
-
import { debounce } from "./utils";
|
|
19
|
+
import { debounce, scrollDistanceWithRespectToSnapPoints } from "./utils";
|
|
19
20
|
|
|
20
21
|
import type {
|
|
21
22
|
LayoutChangeEvent,
|
|
@@ -31,6 +32,8 @@ export type KeyboardAwareScrollViewProps = {
|
|
|
31
32
|
disableScrollOnKeyboardHide?: boolean;
|
|
32
33
|
/** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */
|
|
33
34
|
enabled?: boolean;
|
|
35
|
+
/** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */
|
|
36
|
+
extraKeyboardSpace?: number;
|
|
34
37
|
} & ScrollViewProps;
|
|
35
38
|
|
|
36
39
|
/*
|
|
@@ -83,6 +86,7 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
83
86
|
disableScrollOnKeyboardHide = false,
|
|
84
87
|
enabled = true,
|
|
85
88
|
onScroll: onScrollProps,
|
|
89
|
+
extraKeyboardSpace = 0,
|
|
86
90
|
...rest
|
|
87
91
|
},
|
|
88
92
|
ref,
|
|
@@ -151,10 +155,18 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
151
155
|
const point = absoluteY + inputHeight;
|
|
152
156
|
|
|
153
157
|
if (visibleRect - point <= bottomOffset) {
|
|
158
|
+
const relativeScrollTo =
|
|
159
|
+
keyboardHeight.value - (height - point) + bottomOffset;
|
|
154
160
|
const interpolatedScrollTo = interpolate(
|
|
155
161
|
e,
|
|
156
162
|
[initialKeyboardSize.value, keyboardHeight.value],
|
|
157
|
-
[
|
|
163
|
+
[
|
|
164
|
+
0,
|
|
165
|
+
scrollDistanceWithRespectToSnapPoints(
|
|
166
|
+
relativeScrollTo + scrollPosition.value,
|
|
167
|
+
rest.snapToOffsets,
|
|
168
|
+
) - scrollPosition.value,
|
|
169
|
+
],
|
|
158
170
|
);
|
|
159
171
|
const targetScrollY =
|
|
160
172
|
Math.max(interpolatedScrollTo, 0) + scrollPosition.value;
|
|
@@ -177,7 +189,7 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
177
189
|
|
|
178
190
|
return 0;
|
|
179
191
|
},
|
|
180
|
-
[bottomOffset, enabled],
|
|
192
|
+
[bottomOffset, enabled, rest.snapToOffsets],
|
|
181
193
|
);
|
|
182
194
|
|
|
183
195
|
const onChangeText = useCallback(() => {
|
|
@@ -265,7 +277,12 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
265
277
|
onMove: (e) => {
|
|
266
278
|
"worklet";
|
|
267
279
|
|
|
268
|
-
|
|
280
|
+
const keyboardFrame = interpolate(
|
|
281
|
+
e.height,
|
|
282
|
+
[0, keyboardHeight.value],
|
|
283
|
+
[0, keyboardHeight.value + extraKeyboardSpace],
|
|
284
|
+
);
|
|
285
|
+
currentKeyboardFrameHeight.value = keyboardFrame;
|
|
269
286
|
|
|
270
287
|
// if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens
|
|
271
288
|
if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {
|
|
@@ -279,7 +296,7 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
279
296
|
scrollPosition.value = position.value;
|
|
280
297
|
},
|
|
281
298
|
},
|
|
282
|
-
[height, maybeScroll, disableScrollOnKeyboardHide],
|
|
299
|
+
[height, maybeScroll, disableScrollOnKeyboardHide, extraKeyboardSpace],
|
|
283
300
|
);
|
|
284
301
|
|
|
285
302
|
useAnimatedReaction(
|
|
@@ -24,3 +24,18 @@ export const debounce = <F extends (...args: Parameters<F>) => ReturnType<F>>(
|
|
|
24
24
|
return worklet(...args);
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
+
|
|
28
|
+
export const scrollDistanceWithRespectToSnapPoints = (
|
|
29
|
+
defaultScrollValue: number,
|
|
30
|
+
snapPoints?: number[],
|
|
31
|
+
) => {
|
|
32
|
+
"worklet";
|
|
33
|
+
|
|
34
|
+
let snapPoint: number | undefined;
|
|
35
|
+
|
|
36
|
+
if (snapPoints) {
|
|
37
|
+
snapPoint = snapPoints.find((offset) => offset >= defaultScrollValue);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return snapPoint ?? defaultScrollValue;
|
|
41
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
|
|
3
|
-
import { KeyboardController } from "
|
|
4
|
-
import { AndroidSoftInputModes } from "
|
|
5
|
-
import { useKeyboardContext } from "
|
|
6
|
-
import { uuid } from "
|
|
3
|
+
import { KeyboardController } from "../bindings";
|
|
4
|
+
import { AndroidSoftInputModes } from "../constants";
|
|
5
|
+
import { useKeyboardContext } from "../context";
|
|
6
|
+
import { uuid } from "../utils";
|
|
7
7
|
|
|
8
|
-
import type { AnimatedContext, ReanimatedContext } from "
|
|
9
|
-
import type { FocusedInputHandler, KeyboardHandler } from "
|
|
8
|
+
import type { AnimatedContext, ReanimatedContext } from "../context";
|
|
9
|
+
import type { FocusedInputHandler, KeyboardHandler } from "../types";
|
|
10
10
|
import type { DependencyList } from "react";
|
|
11
11
|
|
|
12
12
|
export const useResizeMode = () => {
|
|
@@ -86,3 +86,5 @@ export function useFocusedInputHandler(
|
|
|
86
86
|
};
|
|
87
87
|
}, deps);
|
|
88
88
|
}
|
|
89
|
+
|
|
90
|
+
export * from "./useWindowDimensions";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { WindowDimensionsEvents } from "../../bindings";
|
|
4
|
+
|
|
5
|
+
import type { WindowDimensionsEventData } from "../../types";
|
|
6
|
+
|
|
7
|
+
let initialDimensions: WindowDimensionsEventData = {
|
|
8
|
+
width: 0,
|
|
9
|
+
height: 0,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
WindowDimensionsEvents.addListener("windowDidResize", (e) => {
|
|
13
|
+
initialDimensions = e;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const useWindowDimensions = () => {
|
|
17
|
+
const [dimensions, setDimensions] = useState(initialDimensions);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const subscription = WindowDimensionsEvents.addListener(
|
|
21
|
+
"windowDidResize",
|
|
22
|
+
(e) => {
|
|
23
|
+
setDimensions(e);
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return () => {
|
|
28
|
+
subscription.remove();
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
return dimensions;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useWindowDimensions } from "react-native";
|
package/src/types.ts
CHANGED
|
@@ -145,6 +145,17 @@ export type FocusedInputEventsModule = {
|
|
|
145
145
|
cb: (e: FocusedInputEventData) => void,
|
|
146
146
|
) => EmitterSubscription;
|
|
147
147
|
};
|
|
148
|
+
export type WindowDimensionsAvailableEvents = "windowDidResize";
|
|
149
|
+
export type WindowDimensionsEventData = {
|
|
150
|
+
width: number;
|
|
151
|
+
height: number;
|
|
152
|
+
};
|
|
153
|
+
export type WindowDimensionsEventsModule = {
|
|
154
|
+
addListener: (
|
|
155
|
+
name: WindowDimensionsAvailableEvents,
|
|
156
|
+
cb: (e: WindowDimensionsEventData) => void,
|
|
157
|
+
) => EmitterSubscription;
|
|
158
|
+
};
|
|
148
159
|
|
|
149
160
|
// reanimated hook declaration
|
|
150
161
|
export type KeyboardHandlerHook<TContext, Event> = (
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_bindings","_constants","_context","_utils","useResizeMode","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","exports","useKeyboardAnimation","context","useKeyboardContext","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","key","uuid","setKeyboardHandlers","undefined","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","setInputHandlers"],"sources":["hooks.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { KeyboardController } from \"./bindings\";\nimport { AndroidSoftInputModes } from \"./constants\";\nimport { useKeyboardContext } from \"./context\";\nimport { uuid } from \"./utils\";\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 useEffect(() => {\n const key = uuid();\n\n context.setKeyboardHandlers({ [key]: handler });\n\n return () => {\n context.setKeyboardHandlers({ [key]: undefined });\n };\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 useEffect(() => {\n const key = uuid();\n\n context.setInputHandlers({ [key]: handler });\n\n return () => {\n context.setInputHandlers({ [key]: undefined });\n };\n }, deps);\n}\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAMO,MAAMK,aAAa,GAAGA,CAAA,KAAM;EACjC,IAAAC,gBAAS,EAAC,MAAM;IACdC,4BAAkB,CAACC,YAAY,CAC7BC,gCAAqB,CAACC,wBACxB,CAAC;IAED,OAAO,MAAMH,4BAAkB,CAACI,cAAc,CAAC,CAAC;EAClD,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAACC,OAAA,CAAAP,aAAA,GAAAA,aAAA;AAEK,MAAMQ,oBAAoB,GAAGA,CAAA,KAAuB;EACzDR,aAAa,CAAC,CAAC;EACf,MAAMS,OAAO,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAEpC,OAAOD,OAAO,CAACE,QAAQ;AACzB,CAAC;AAACJ,OAAA,CAAAC,oBAAA,GAAAA,oBAAA;AAEK,MAAMI,8BAA8B,GAAGA,CAAA,KAAyB;EACrEZ,aAAa,CAAC,CAAC;EACf,MAAMS,OAAO,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAEpC,OAAOD,OAAO,CAACI,UAAU;AAC3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MAAM;MACXN,OAAO,CAACoB,gBAAgB,CAAC;QAAE,CAACZ,GAAG,GAAGG;MAAU,CAAC,CAAC;IAChD,CAAC;EACH,CAAC,EAAEJ,IAAI,CAAC;AACV","ignoreList":[]}
|
package/lib/module/hooks.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","KeyboardController","AndroidSoftInputModes","useKeyboardContext","uuid","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","key","setKeyboardHandlers","undefined","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","setInputHandlers"],"sources":["hooks.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { KeyboardController } from \"./bindings\";\nimport { AndroidSoftInputModes } from \"./constants\";\nimport { useKeyboardContext } from \"./context\";\nimport { uuid } from \"./utils\";\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 useEffect(() => {\n const key = uuid();\n\n context.setKeyboardHandlers({ [key]: handler });\n\n return () => {\n context.setKeyboardHandlers({ [key]: undefined });\n };\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 useEffect(() => {\n const key = uuid();\n\n context.setInputHandlers({ [key]: handler });\n\n return () => {\n context.setInputHandlers({ [key]: undefined });\n };\n }, deps);\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,qBAAqB,QAAQ,aAAa;AACnD,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SAASC,IAAI,QAAQ,SAAS;AAM9B,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjCL,SAAS,CAAC,MAAM;IACdC,kBAAkB,CAACK,YAAY,CAC7BJ,qBAAqB,CAACK,wBACxB,CAAC;IAED,OAAO,MAAMN,kBAAkB,CAACO,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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