react-native-keyboard-controller 1.19.5 → 1.20.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/.settings/org.eclipse.buildship.core.prefs +2 -0
- package/android/src/turbo/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +1 -0
- package/ios/KeyboardController.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/Tests/Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcuserdata/kirylziusko.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Tests/Tests.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +32 -0
- package/lib/commonjs/animated.js +2 -3
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +13 -8
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks/index.js +41 -2
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/internal.js +16 -16
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/module/animated.js +2 -3
- package/lib/module/animated.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +13 -8
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks/index.js +41 -2
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/internal.js +16 -16
- package/lib/module/internal.js.map +1 -1
- package/lib/typescript/context.d.ts +4 -4
- package/lib/typescript/hooks/index.d.ts +3 -4
- package/lib/typescript/internal.d.ts +2 -3
- package/package.json +1 -1
- package/src/animated.tsx +2 -11
- package/src/components/KeyboardAwareScrollView/index.tsx +19 -7
- package/src/context.ts +11 -8
- package/src/hooks/index.ts +64 -10
- package/src/internal.ts +33 -30
- package/lib/commonjs/event-handler.d.js +0 -6
- package/lib/commonjs/event-handler.d.js.map +0 -1
- package/lib/commonjs/event-handler.js +0 -19
- package/lib/commonjs/event-handler.js.map +0 -1
- package/lib/commonjs/event-handler.web.js +0 -10
- package/lib/commonjs/event-handler.web.js.map +0 -1
- package/lib/commonjs/event-mappings.js +0 -9
- package/lib/commonjs/event-mappings.js.map +0 -1
- package/lib/module/event-handler.d.js +0 -2
- package/lib/module/event-handler.d.js.map +0 -1
- package/lib/module/event-handler.js +0 -14
- package/lib/module/event-handler.js.map +0 -1
- package/lib/module/event-handler.web.js +0 -5
- package/lib/module/event-handler.web.js.map +0 -1
- package/lib/module/event-mappings.js +0 -3
- package/lib/module/event-mappings.js.map +0 -1
- package/lib/typescript/event-mappings.d.ts +0 -2
- package/src/event-handler.d.ts +0 -8
- package/src/event-handler.js +0 -15
- package/src/event-handler.web.js +0 -5
- package/src/event-mappings.ts +0 -14
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AnimatedContext, ReanimatedContext } from "../context";
|
|
2
2
|
import type { FocusedInputHandler, KeyboardHandler } from "../types";
|
|
3
|
-
import type { DependencyList } from "react";
|
|
4
3
|
/**
|
|
5
4
|
* Hook that sets the Android soft input mode to adjust resize on mount and
|
|
6
5
|
* restores default mode on unmount. This ensures the keyboard behavior is consistent
|
|
@@ -77,7 +76,7 @@ export declare const useReanimatedKeyboardAnimation: () => ReanimatedContext;
|
|
|
77
76
|
* }
|
|
78
77
|
* ```
|
|
79
78
|
*/
|
|
80
|
-
export declare function useGenericKeyboardHandler(handler: KeyboardHandler, deps?:
|
|
79
|
+
export declare function useGenericKeyboardHandler(handler: KeyboardHandler, deps?: unknown[]): void;
|
|
81
80
|
/**
|
|
82
81
|
* Hook that gives an access to each aspect of keyboard movement with workletized `onStart`/`onMove`/`onInteractive`/`onEnd` handlers.
|
|
83
82
|
*
|
|
@@ -109,7 +108,7 @@ export declare function useGenericKeyboardHandler(handler: KeyboardHandler, deps
|
|
|
109
108
|
* }
|
|
110
109
|
* ```
|
|
111
110
|
*/
|
|
112
|
-
export declare function useKeyboardHandler(handler: KeyboardHandler, deps?:
|
|
111
|
+
export declare function useKeyboardHandler(handler: KeyboardHandler, deps?: unknown[]): void;
|
|
113
112
|
/**
|
|
114
113
|
* Hook for controlling keyboard controller module.
|
|
115
114
|
* Allows to disable/enable it and check the actual state (whether it's enabled or not).
|
|
@@ -170,6 +169,6 @@ export declare function useReanimatedFocusedInput(): {
|
|
|
170
169
|
* }
|
|
171
170
|
* ```
|
|
172
171
|
*/
|
|
173
|
-
export declare function useFocusedInputHandler(handler: FocusedInputHandler, deps?:
|
|
172
|
+
export declare function useFocusedInputHandler(handler: FocusedInputHandler, deps?: unknown[]): void;
|
|
174
173
|
export * from "./useWindowDimensions";
|
|
175
174
|
export * from "./useKeyboardState";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Animated } from "react-native";
|
|
2
2
|
import { findNodeHandle } from "./utils/findNodeHandle";
|
|
3
|
-
type
|
|
3
|
+
import type { EventHandlerProcessed } from "react-native-reanimated";
|
|
4
4
|
type ComponentOrHandle = Parameters<typeof findNodeHandle>[0];
|
|
5
5
|
/**
|
|
6
6
|
* An internal hook that helps to register workletized event handlers.
|
|
7
7
|
*
|
|
8
|
-
* @param map - Map of event handlers and their names.
|
|
9
8
|
* @param viewTagRef - Ref to the view that produces events.
|
|
10
9
|
* @returns A function that registers supplied event handlers.
|
|
11
10
|
* @example
|
|
@@ -16,7 +15,7 @@ type ComponentOrHandle = Parameters<typeof findNodeHandle>[0];
|
|
|
16
15
|
* );
|
|
17
16
|
* ```
|
|
18
17
|
*/
|
|
19
|
-
export declare function useEventHandlerRegistration
|
|
18
|
+
export declare function useEventHandlerRegistration(viewTagRef: React.MutableRefObject<ComponentOrHandle>): (handler: EventHandlerProcessed<never, never>) => () => void;
|
|
20
19
|
/**
|
|
21
20
|
* TS variant of `useAnimatedValue` hook which is added in RN 0.71
|
|
22
21
|
* A better alternative of storing animated values in refs, since
|
package/package.json
CHANGED
package/src/animated.tsx
CHANGED
|
@@ -9,7 +9,6 @@ import Reanimated, { useSharedValue } from "react-native-reanimated";
|
|
|
9
9
|
|
|
10
10
|
import { KeyboardControllerView } from "./bindings";
|
|
11
11
|
import { KeyboardContext } from "./context";
|
|
12
|
-
import { focusedInputEventsMap, keyboardEventsMap } from "./event-mappings";
|
|
13
12
|
import { useAnimatedValue, useEventHandlerRegistration } from "./internal";
|
|
14
13
|
import { KeyboardController } from "./module";
|
|
15
14
|
import {
|
|
@@ -19,10 +18,8 @@ import {
|
|
|
19
18
|
|
|
20
19
|
import type { KeyboardAnimationContext } from "./context";
|
|
21
20
|
import type {
|
|
22
|
-
FocusedInputHandler,
|
|
23
21
|
FocusedInputLayoutChangedEvent,
|
|
24
22
|
KeyboardControllerProps,
|
|
25
|
-
KeyboardHandler,
|
|
26
23
|
NativeEvent,
|
|
27
24
|
} from "./types";
|
|
28
25
|
import type { ViewStyle } from "react-native";
|
|
@@ -130,14 +127,8 @@ export const KeyboardProvider = (props: KeyboardProviderProps) => {
|
|
|
130
127
|
const progressSV = useSharedValue(0);
|
|
131
128
|
const heightSV = useSharedValue(0);
|
|
132
129
|
const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);
|
|
133
|
-
const setKeyboardHandlers = useEventHandlerRegistration
|
|
134
|
-
|
|
135
|
-
viewTagRef,
|
|
136
|
-
);
|
|
137
|
-
const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(
|
|
138
|
-
focusedInputEventsMap,
|
|
139
|
-
viewTagRef,
|
|
140
|
-
);
|
|
130
|
+
const setKeyboardHandlers = useEventHandlerRegistration(viewTagRef);
|
|
131
|
+
const setInputHandlers = useEventHandlerRegistration(viewTagRef);
|
|
141
132
|
// memo
|
|
142
133
|
const context = useMemo<KeyboardAnimationContext>(
|
|
143
134
|
() => ({
|
|
@@ -210,6 +210,19 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
210
210
|
},
|
|
211
211
|
[bottomOffset, enabled, height, snapToOffsets],
|
|
212
212
|
);
|
|
213
|
+
const performScrollWithPositionRestoration = useCallback(
|
|
214
|
+
(newPosition: number) => {
|
|
215
|
+
"worklet";
|
|
216
|
+
|
|
217
|
+
const prevScroll = scrollPosition.value;
|
|
218
|
+
|
|
219
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
220
|
+
scrollPosition.value = newPosition;
|
|
221
|
+
maybeScroll(keyboardHeight.value, true);
|
|
222
|
+
scrollPosition.value = prevScroll;
|
|
223
|
+
},
|
|
224
|
+
[scrollPosition, keyboardHeight, maybeScroll],
|
|
225
|
+
);
|
|
213
226
|
const syncKeyboardFrame = useCallback(
|
|
214
227
|
(e: NativeEvent) => {
|
|
215
228
|
"worklet";
|
|
@@ -249,19 +262,16 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
249
262
|
const scrollFromCurrentPosition = useCallback(() => {
|
|
250
263
|
"worklet";
|
|
251
264
|
|
|
252
|
-
const prevScrollPosition = scrollPosition.value;
|
|
253
265
|
const prevLayout = layout.value;
|
|
254
266
|
|
|
255
267
|
if (!updateLayoutFromSelection()) {
|
|
256
268
|
return;
|
|
257
269
|
}
|
|
258
270
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
maybeScroll(keyboardHeight.value, true);
|
|
262
|
-
scrollPosition.value = prevScrollPosition;
|
|
271
|
+
performScrollWithPositionRestoration(position.value);
|
|
272
|
+
|
|
263
273
|
layout.value = prevLayout;
|
|
264
|
-
}, [
|
|
274
|
+
}, [performScrollWithPositionRestoration]);
|
|
265
275
|
const onChangeText = useCallback(() => {
|
|
266
276
|
"worklet";
|
|
267
277
|
scrollFromCurrentPosition();
|
|
@@ -383,7 +393,9 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
383
393
|
);
|
|
384
394
|
|
|
385
395
|
useEffect(() => {
|
|
386
|
-
runOnUI(
|
|
396
|
+
runOnUI(performScrollWithPositionRestoration)(
|
|
397
|
+
scrollBeforeKeyboardMovement.value,
|
|
398
|
+
);
|
|
387
399
|
}, [bottomOffset]);
|
|
388
400
|
|
|
389
401
|
useAnimatedReaction(
|
package/src/context.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
2
|
import { Animated } from "react-native";
|
|
3
3
|
|
|
4
|
-
import type {
|
|
5
|
-
FocusedInputHandler,
|
|
6
|
-
FocusedInputLayoutChangedEvent,
|
|
7
|
-
KeyboardHandler,
|
|
8
|
-
} from "./types";
|
|
4
|
+
import type { FocusedInputLayoutChangedEvent } from "./types";
|
|
9
5
|
import type React from "react";
|
|
10
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
EventHandlerProcessed,
|
|
8
|
+
SharedValue,
|
|
9
|
+
} from "react-native-reanimated";
|
|
11
10
|
|
|
12
11
|
export type AnimatedContext = {
|
|
13
12
|
/**
|
|
@@ -37,9 +36,13 @@ export type KeyboardAnimationContext = {
|
|
|
37
36
|
/** Layout of the focused `TextInput` represented as `SharedValue`. */
|
|
38
37
|
layout: SharedValue<FocusedInputLayoutChangedEvent | null>;
|
|
39
38
|
/** Method for setting workletized keyboard handlers. */
|
|
40
|
-
setKeyboardHandlers: (
|
|
39
|
+
setKeyboardHandlers: (
|
|
40
|
+
handlers: EventHandlerProcessed<never, never>,
|
|
41
|
+
) => () => void;
|
|
41
42
|
/** Method for setting workletized handlers for tracking focused input events. */
|
|
42
|
-
setInputHandlers: (
|
|
43
|
+
setInputHandlers: (
|
|
44
|
+
handlers: EventHandlerProcessed<never, never>,
|
|
45
|
+
) => () => void;
|
|
43
46
|
/** Method to enable/disable KeyboardController library. */
|
|
44
47
|
setEnabled: React.Dispatch<React.SetStateAction<boolean>>;
|
|
45
48
|
};
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect } from "react";
|
|
2
|
+
import { useEvent, useHandler } from "react-native-reanimated";
|
|
2
3
|
|
|
3
4
|
import { AndroidSoftInputModes } from "../constants";
|
|
4
5
|
import { useKeyboardContext } from "../context";
|
|
5
6
|
import { KeyboardController } from "../module";
|
|
6
7
|
|
|
7
8
|
import type { AnimatedContext, ReanimatedContext } from "../context";
|
|
8
|
-
import type {
|
|
9
|
-
|
|
9
|
+
import type {
|
|
10
|
+
FocusedInputHandler,
|
|
11
|
+
FocusedInputSelectionChangedEvent,
|
|
12
|
+
FocusedInputTextChangedEvent,
|
|
13
|
+
KeyboardHandler,
|
|
14
|
+
NativeEvent,
|
|
15
|
+
} from "../types";
|
|
10
16
|
|
|
11
17
|
/**
|
|
12
18
|
* Hook that sets the Android soft input mode to adjust resize on mount and
|
|
@@ -107,12 +113,43 @@ export const useReanimatedKeyboardAnimation = (): ReanimatedContext => {
|
|
|
107
113
|
*/
|
|
108
114
|
export function useGenericKeyboardHandler(
|
|
109
115
|
handler: KeyboardHandler,
|
|
110
|
-
deps?:
|
|
116
|
+
deps?: unknown[],
|
|
111
117
|
) {
|
|
112
118
|
const context = useKeyboardContext();
|
|
113
119
|
|
|
120
|
+
const { doDependenciesDiffer } = useHandler(handler, deps);
|
|
121
|
+
|
|
122
|
+
const eventHandler = useEvent<NativeEvent>(
|
|
123
|
+
(event) => {
|
|
124
|
+
"worklet";
|
|
125
|
+
|
|
126
|
+
if (event.eventName.endsWith("onKeyboardMoveStart")) {
|
|
127
|
+
handler.onStart?.(event);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (event.eventName.endsWith("onKeyboardMove")) {
|
|
131
|
+
handler.onMove?.(event);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (event.eventName.endsWith("onKeyboardMoveEnd")) {
|
|
135
|
+
handler.onEnd?.(event);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (event.eventName.endsWith("onKeyboardMoveInteractive")) {
|
|
139
|
+
handler.onInteractive?.(event);
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
[
|
|
143
|
+
"onKeyboardMoveStart",
|
|
144
|
+
"onKeyboardMove",
|
|
145
|
+
"onKeyboardMoveEnd",
|
|
146
|
+
"onKeyboardMoveInteractive",
|
|
147
|
+
],
|
|
148
|
+
doDependenciesDiffer,
|
|
149
|
+
);
|
|
150
|
+
|
|
114
151
|
useLayoutEffect(() => {
|
|
115
|
-
const cleanup = context.setKeyboardHandlers(
|
|
152
|
+
const cleanup = context.setKeyboardHandlers(eventHandler);
|
|
116
153
|
|
|
117
154
|
return () => cleanup();
|
|
118
155
|
}, deps);
|
|
@@ -149,10 +186,7 @@ export function useGenericKeyboardHandler(
|
|
|
149
186
|
* }
|
|
150
187
|
* ```
|
|
151
188
|
*/
|
|
152
|
-
export function useKeyboardHandler(
|
|
153
|
-
handler: KeyboardHandler,
|
|
154
|
-
deps?: DependencyList,
|
|
155
|
-
) {
|
|
189
|
+
export function useKeyboardHandler(handler: KeyboardHandler, deps?: unknown[]) {
|
|
156
190
|
useResizeMode();
|
|
157
191
|
useGenericKeyboardHandler(handler, deps);
|
|
158
192
|
}
|
|
@@ -224,12 +258,32 @@ export function useReanimatedFocusedInput() {
|
|
|
224
258
|
*/
|
|
225
259
|
export function useFocusedInputHandler(
|
|
226
260
|
handler: FocusedInputHandler,
|
|
227
|
-
deps?:
|
|
261
|
+
deps?: unknown[],
|
|
228
262
|
) {
|
|
229
263
|
const context = useKeyboardContext();
|
|
230
264
|
|
|
265
|
+
const { doDependenciesDiffer } = useHandler<never, never>(handler, deps);
|
|
266
|
+
|
|
267
|
+
const eventHandler = useEvent<
|
|
268
|
+
FocusedInputSelectionChangedEvent | FocusedInputTextChangedEvent
|
|
269
|
+
>(
|
|
270
|
+
(event) => {
|
|
271
|
+
"worklet";
|
|
272
|
+
|
|
273
|
+
if (event.eventName.endsWith("onFocusedInputTextChanged")) {
|
|
274
|
+
handler.onChangeText?.(event as FocusedInputTextChangedEvent);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (event.eventName.endsWith("onFocusedInputSelectionChanged")) {
|
|
278
|
+
handler.onSelectionChange?.(event as FocusedInputSelectionChangedEvent);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
["onFocusedInputTextChanged", "onFocusedInputSelectionChanged"],
|
|
282
|
+
doDependenciesDiffer,
|
|
283
|
+
);
|
|
284
|
+
|
|
231
285
|
useLayoutEffect(() => {
|
|
232
|
-
const cleanup = context.setInputHandlers(
|
|
286
|
+
const cleanup = context.setInputHandlers(eventHandler);
|
|
233
287
|
|
|
234
288
|
return () => cleanup();
|
|
235
289
|
}, deps);
|
package/src/internal.ts
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { useRef } from "react";
|
|
2
2
|
import { Animated } from "react-native";
|
|
3
3
|
|
|
4
|
-
import { registerEventHandler, unregisterEventHandler } from "./event-handler";
|
|
5
4
|
import { findNodeHandle } from "./utils/findNodeHandle";
|
|
6
5
|
|
|
7
|
-
type
|
|
6
|
+
import type { EventHandlerProcessed } from "react-native-reanimated";
|
|
7
|
+
|
|
8
8
|
type ComponentOrHandle = Parameters<typeof findNodeHandle>[0];
|
|
9
9
|
|
|
10
|
+
type WorkletHandler = {
|
|
11
|
+
registerForEvents: (viewTag: number) => void;
|
|
12
|
+
unregisterFromEvents: (viewTag: number) => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type WorkletHandlerOrWorkletHandlerObject =
|
|
16
|
+
| WorkletHandler
|
|
17
|
+
| {
|
|
18
|
+
workletEventHandler: WorkletHandler;
|
|
19
|
+
};
|
|
20
|
+
|
|
10
21
|
/**
|
|
11
22
|
* An internal hook that helps to register workletized event handlers.
|
|
12
23
|
*
|
|
13
|
-
* @param map - Map of event handlers and their names.
|
|
14
24
|
* @param viewTagRef - Ref to the view that produces events.
|
|
15
25
|
* @returns A function that registers supplied event handlers.
|
|
16
26
|
* @example
|
|
@@ -21,14 +31,12 @@ type ComponentOrHandle = Parameters<typeof findNodeHandle>[0];
|
|
|
21
31
|
* );
|
|
22
32
|
* ```
|
|
23
33
|
*/
|
|
24
|
-
export function useEventHandlerRegistration
|
|
25
|
-
H extends Partial<Record<string, EventHandler>>,
|
|
26
|
-
>(
|
|
27
|
-
map: Map<keyof H, string>,
|
|
34
|
+
export function useEventHandlerRegistration(
|
|
28
35
|
viewTagRef: React.MutableRefObject<ComponentOrHandle>,
|
|
29
36
|
) {
|
|
30
|
-
const onRegisterHandler = (handler:
|
|
31
|
-
const
|
|
37
|
+
const onRegisterHandler = (handler: EventHandlerProcessed<never, never>) => {
|
|
38
|
+
const currentHandler =
|
|
39
|
+
handler as unknown as WorkletHandlerOrWorkletHandlerObject;
|
|
32
40
|
const attachWorkletHandlers = () => {
|
|
33
41
|
const viewTag = findNodeHandle(viewTagRef.current);
|
|
34
42
|
|
|
@@ -38,26 +46,13 @@ export function useEventHandlerRegistration<
|
|
|
38
46
|
);
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
(event: Parameters<NonNullable<H[keyof H]>>[0]) => {
|
|
49
|
-
"worklet";
|
|
50
|
-
|
|
51
|
-
functionToCall?.(event);
|
|
52
|
-
},
|
|
53
|
-
eventName,
|
|
54
|
-
viewTag,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return null;
|
|
59
|
-
}),
|
|
60
|
-
);
|
|
49
|
+
if (viewTag) {
|
|
50
|
+
if ("workletEventHandler" in currentHandler) {
|
|
51
|
+
currentHandler.workletEventHandler.registerForEvents(viewTag);
|
|
52
|
+
} else {
|
|
53
|
+
currentHandler.registerForEvents(viewTag);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
61
56
|
};
|
|
62
57
|
|
|
63
58
|
if (viewTagRef.current) {
|
|
@@ -68,7 +63,15 @@ export function useEventHandlerRegistration<
|
|
|
68
63
|
}
|
|
69
64
|
|
|
70
65
|
return () => {
|
|
71
|
-
|
|
66
|
+
const viewTag = findNodeHandle(viewTagRef.current);
|
|
67
|
+
|
|
68
|
+
if (viewTag) {
|
|
69
|
+
if ("workletEventHandler" in currentHandler) {
|
|
70
|
+
currentHandler.workletEventHandler.unregisterFromEvents(viewTag);
|
|
71
|
+
} else {
|
|
72
|
+
currentHandler.unregisterFromEvents(viewTag);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
72
75
|
};
|
|
73
76
|
};
|
|
74
77
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["event-handler.d.ts"],"sourcesContent":["declare function registerEventHandler(\n handler: (event: never) => void,\n eventName: string,\n viewTag: number,\n): number;\ndeclare function unregisterEventHandler(id: number): void;\n\nexport { registerEventHandler, unregisterEventHandler };\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.unregisterEventHandler = exports.registerEventHandler = void 0;
|
|
7
|
-
let REACore = null;
|
|
8
|
-
try {
|
|
9
|
-
REACore = require("react-native-reanimated/src/core");
|
|
10
|
-
} catch (e1) {
|
|
11
|
-
try {
|
|
12
|
-
REACore = require("react-native-reanimated/src/reanimated2/core");
|
|
13
|
-
} catch (e2) {
|
|
14
|
-
console.warn("Failed to load REACore from both paths");
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const registerEventHandler = exports.registerEventHandler = REACore.registerEventHandler;
|
|
18
|
-
const unregisterEventHandler = exports.unregisterEventHandler = REACore.unregisterEventHandler;
|
|
19
|
-
//# sourceMappingURL=event-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["REACore","require","e1","e2","console","warn","registerEventHandler","exports","unregisterEventHandler"],"sources":["event-handler.js"],"sourcesContent":["let REACore = null;\n\ntry {\n REACore = require(\"react-native-reanimated/src/core\");\n} catch (e1) {\n try {\n REACore = require(\"react-native-reanimated/src/reanimated2/core\");\n } catch (e2) {\n console.warn(\"Failed to load REACore from both paths\");\n }\n}\nconst registerEventHandler = REACore.registerEventHandler;\nconst unregisterEventHandler = REACore.unregisterEventHandler;\n\nexport { registerEventHandler, unregisterEventHandler };\n"],"mappings":";;;;;;AAAA,IAAIA,OAAO,GAAG,IAAI;AAElB,IAAI;EACFA,OAAO,GAAGC,OAAO,CAAC,kCAAkC,CAAC;AACvD,CAAC,CAAC,OAAOC,EAAE,EAAE;EACX,IAAI;IACFF,OAAO,GAAGC,OAAO,CAAC,8CAA8C,CAAC;EACnE,CAAC,CAAC,OAAOE,EAAE,EAAE;IACXC,OAAO,CAACC,IAAI,CAAC,wCAAwC,CAAC;EACxD;AACF;AACA,MAAMC,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAGN,OAAO,CAACM,oBAAoB;AACzD,MAAME,sBAAsB,GAAAD,OAAA,CAAAC,sBAAA,GAAGR,OAAO,CAACQ,sBAAsB","ignoreList":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.unregisterEventHandler = exports.registerEventHandler = void 0;
|
|
7
|
-
const NOOP = () => {};
|
|
8
|
-
const registerEventHandler = exports.registerEventHandler = NOOP;
|
|
9
|
-
const unregisterEventHandler = exports.unregisterEventHandler = NOOP;
|
|
10
|
-
//# sourceMappingURL=event-handler.web.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["NOOP","registerEventHandler","exports","unregisterEventHandler"],"sources":["event-handler.web.js"],"sourcesContent":["const NOOP = () => {};\nconst registerEventHandler = NOOP;\nconst unregisterEventHandler = NOOP;\n\nexport { registerEventHandler, unregisterEventHandler };\n"],"mappings":";;;;;;AAAA,MAAMA,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAGD,IAAI;AACjC,MAAMG,sBAAsB,GAAAD,OAAA,CAAAC,sBAAA,GAAGH,IAAI","ignoreList":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.keyboardEventsMap = exports.focusedInputEventsMap = void 0;
|
|
7
|
-
const keyboardEventsMap = exports.keyboardEventsMap = new Map([["onStart", "onKeyboardMoveStart"], ["onMove", "onKeyboardMove"], ["onEnd", "onKeyboardMoveEnd"], ["onInteractive", "onKeyboardMoveInteractive"]]);
|
|
8
|
-
const focusedInputEventsMap = exports.focusedInputEventsMap = new Map([["onChangeText", "onFocusedInputTextChanged"], ["onSelectionChange", "onFocusedInputSelectionChanged"]]);
|
|
9
|
-
//# sourceMappingURL=event-mappings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["keyboardEventsMap","exports","Map","focusedInputEventsMap"],"sources":["event-mappings.ts"],"sourcesContent":["import type { FocusedInputHandler, KeyboardHandler } from \"./types\";\n\nexport const keyboardEventsMap = new Map<keyof KeyboardHandler, string>([\n [\"onStart\", \"onKeyboardMoveStart\"],\n [\"onMove\", \"onKeyboardMove\"],\n [\"onEnd\", \"onKeyboardMoveEnd\"],\n [\"onInteractive\", \"onKeyboardMoveInteractive\"],\n]);\nexport const focusedInputEventsMap = new Map<keyof FocusedInputHandler, string>(\n [\n [\"onChangeText\", \"onFocusedInputTextChanged\"],\n [\"onSelectionChange\", \"onFocusedInputSelectionChanged\"],\n ],\n);\n"],"mappings":";;;;;;AAEO,MAAMA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAIE,GAAG,CAAgC,CACtE,CAAC,SAAS,EAAE,qBAAqB,CAAC,EAClC,CAAC,QAAQ,EAAE,gBAAgB,CAAC,EAC5B,CAAC,OAAO,EAAE,mBAAmB,CAAC,EAC9B,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAC/C,CAAC;AACK,MAAMC,qBAAqB,GAAAF,OAAA,CAAAE,qBAAA,GAAG,IAAID,GAAG,CAC1C,CACE,CAAC,cAAc,EAAE,2BAA2B,CAAC,EAC7C,CAAC,mBAAmB,EAAE,gCAAgC,CAAC,CAE3D,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["event-handler.d.ts"],"sourcesContent":["declare function registerEventHandler(\n handler: (event: never) => void,\n eventName: string,\n viewTag: number,\n): number;\ndeclare function unregisterEventHandler(id: number): void;\n\nexport { registerEventHandler, unregisterEventHandler };\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
let REACore = null;
|
|
2
|
-
try {
|
|
3
|
-
REACore = require("react-native-reanimated/src/core");
|
|
4
|
-
} catch (e1) {
|
|
5
|
-
try {
|
|
6
|
-
REACore = require("react-native-reanimated/src/reanimated2/core");
|
|
7
|
-
} catch (e2) {
|
|
8
|
-
console.warn("Failed to load REACore from both paths");
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
const registerEventHandler = REACore.registerEventHandler;
|
|
12
|
-
const unregisterEventHandler = REACore.unregisterEventHandler;
|
|
13
|
-
export { registerEventHandler, unregisterEventHandler };
|
|
14
|
-
//# sourceMappingURL=event-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["REACore","require","e1","e2","console","warn","registerEventHandler","unregisterEventHandler"],"sources":["event-handler.js"],"sourcesContent":["let REACore = null;\n\ntry {\n REACore = require(\"react-native-reanimated/src/core\");\n} catch (e1) {\n try {\n REACore = require(\"react-native-reanimated/src/reanimated2/core\");\n } catch (e2) {\n console.warn(\"Failed to load REACore from both paths\");\n }\n}\nconst registerEventHandler = REACore.registerEventHandler;\nconst unregisterEventHandler = REACore.unregisterEventHandler;\n\nexport { registerEventHandler, unregisterEventHandler };\n"],"mappings":"AAAA,IAAIA,OAAO,GAAG,IAAI;AAElB,IAAI;EACFA,OAAO,GAAGC,OAAO,CAAC,kCAAkC,CAAC;AACvD,CAAC,CAAC,OAAOC,EAAE,EAAE;EACX,IAAI;IACFF,OAAO,GAAGC,OAAO,CAAC,8CAA8C,CAAC;EACnE,CAAC,CAAC,OAAOE,EAAE,EAAE;IACXC,OAAO,CAACC,IAAI,CAAC,wCAAwC,CAAC;EACxD;AACF;AACA,MAAMC,oBAAoB,GAAGN,OAAO,CAACM,oBAAoB;AACzD,MAAMC,sBAAsB,GAAGP,OAAO,CAACO,sBAAsB;AAE7D,SAASD,oBAAoB,EAAEC,sBAAsB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["NOOP","registerEventHandler","unregisterEventHandler"],"sources":["event-handler.web.js"],"sourcesContent":["const NOOP = () => {};\nconst registerEventHandler = NOOP;\nconst unregisterEventHandler = NOOP;\n\nexport { registerEventHandler, unregisterEventHandler };\n"],"mappings":"AAAA,MAAMA,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,oBAAoB,GAAGD,IAAI;AACjC,MAAME,sBAAsB,GAAGF,IAAI;AAEnC,SAASC,oBAAoB,EAAEC,sBAAsB","ignoreList":[]}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export const keyboardEventsMap = new Map([["onStart", "onKeyboardMoveStart"], ["onMove", "onKeyboardMove"], ["onEnd", "onKeyboardMoveEnd"], ["onInteractive", "onKeyboardMoveInteractive"]]);
|
|
2
|
-
export const focusedInputEventsMap = new Map([["onChangeText", "onFocusedInputTextChanged"], ["onSelectionChange", "onFocusedInputSelectionChanged"]]);
|
|
3
|
-
//# sourceMappingURL=event-mappings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["keyboardEventsMap","Map","focusedInputEventsMap"],"sources":["event-mappings.ts"],"sourcesContent":["import type { FocusedInputHandler, KeyboardHandler } from \"./types\";\n\nexport const keyboardEventsMap = new Map<keyof KeyboardHandler, string>([\n [\"onStart\", \"onKeyboardMoveStart\"],\n [\"onMove\", \"onKeyboardMove\"],\n [\"onEnd\", \"onKeyboardMoveEnd\"],\n [\"onInteractive\", \"onKeyboardMoveInteractive\"],\n]);\nexport const focusedInputEventsMap = new Map<keyof FocusedInputHandler, string>(\n [\n [\"onChangeText\", \"onFocusedInputTextChanged\"],\n [\"onSelectionChange\", \"onFocusedInputSelectionChanged\"],\n ],\n);\n"],"mappings":"AAEA,OAAO,MAAMA,iBAAiB,GAAG,IAAIC,GAAG,CAAgC,CACtE,CAAC,SAAS,EAAE,qBAAqB,CAAC,EAClC,CAAC,QAAQ,EAAE,gBAAgB,CAAC,EAC5B,CAAC,OAAO,EAAE,mBAAmB,CAAC,EAC9B,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAC/C,CAAC;AACF,OAAO,MAAMC,qBAAqB,GAAG,IAAID,GAAG,CAC1C,CACE,CAAC,cAAc,EAAE,2BAA2B,CAAC,EAC7C,CAAC,mBAAmB,EAAE,gCAAgC,CAAC,CAE3D,CAAC","ignoreList":[]}
|
package/src/event-handler.d.ts
DELETED
package/src/event-handler.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
let REACore = null;
|
|
2
|
-
|
|
3
|
-
try {
|
|
4
|
-
REACore = require("react-native-reanimated/src/core");
|
|
5
|
-
} catch (e1) {
|
|
6
|
-
try {
|
|
7
|
-
REACore = require("react-native-reanimated/src/reanimated2/core");
|
|
8
|
-
} catch (e2) {
|
|
9
|
-
console.warn("Failed to load REACore from both paths");
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const registerEventHandler = REACore.registerEventHandler;
|
|
13
|
-
const unregisterEventHandler = REACore.unregisterEventHandler;
|
|
14
|
-
|
|
15
|
-
export { registerEventHandler, unregisterEventHandler };
|
package/src/event-handler.web.js
DELETED
package/src/event-mappings.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { FocusedInputHandler, KeyboardHandler } from "./types";
|
|
2
|
-
|
|
3
|
-
export const keyboardEventsMap = new Map<keyof KeyboardHandler, string>([
|
|
4
|
-
["onStart", "onKeyboardMoveStart"],
|
|
5
|
-
["onMove", "onKeyboardMove"],
|
|
6
|
-
["onEnd", "onKeyboardMoveEnd"],
|
|
7
|
-
["onInteractive", "onKeyboardMoveInteractive"],
|
|
8
|
-
]);
|
|
9
|
-
export const focusedInputEventsMap = new Map<keyof FocusedInputHandler, string>(
|
|
10
|
-
[
|
|
11
|
-
["onChangeText", "onFocusedInputTextChanged"],
|
|
12
|
-
["onSelectionChange", "onFocusedInputSelectionChanged"],
|
|
13
|
-
],
|
|
14
|
-
);
|