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.
Files changed (55) hide show
  1. package/android/.settings/org.eclipse.buildship.core.prefs +2 -0
  2. package/android/src/turbo/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +1 -0
  3. package/ios/KeyboardController.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  4. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  5. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  6. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcuserdata/kirylziusko.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  7. package/ios/Tests/Tests.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +32 -0
  8. package/lib/commonjs/animated.js +2 -3
  9. package/lib/commonjs/animated.js.map +1 -1
  10. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +13 -8
  11. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  12. package/lib/commonjs/context.js.map +1 -1
  13. package/lib/commonjs/hooks/index.js +41 -2
  14. package/lib/commonjs/hooks/index.js.map +1 -1
  15. package/lib/commonjs/internal.js +16 -16
  16. package/lib/commonjs/internal.js.map +1 -1
  17. package/lib/module/animated.js +2 -3
  18. package/lib/module/animated.js.map +1 -1
  19. package/lib/module/components/KeyboardAwareScrollView/index.js +13 -8
  20. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  21. package/lib/module/context.js.map +1 -1
  22. package/lib/module/hooks/index.js +41 -2
  23. package/lib/module/hooks/index.js.map +1 -1
  24. package/lib/module/internal.js +16 -16
  25. package/lib/module/internal.js.map +1 -1
  26. package/lib/typescript/context.d.ts +4 -4
  27. package/lib/typescript/hooks/index.d.ts +3 -4
  28. package/lib/typescript/internal.d.ts +2 -3
  29. package/package.json +1 -1
  30. package/src/animated.tsx +2 -11
  31. package/src/components/KeyboardAwareScrollView/index.tsx +19 -7
  32. package/src/context.ts +11 -8
  33. package/src/hooks/index.ts +64 -10
  34. package/src/internal.ts +33 -30
  35. package/lib/commonjs/event-handler.d.js +0 -6
  36. package/lib/commonjs/event-handler.d.js.map +0 -1
  37. package/lib/commonjs/event-handler.js +0 -19
  38. package/lib/commonjs/event-handler.js.map +0 -1
  39. package/lib/commonjs/event-handler.web.js +0 -10
  40. package/lib/commonjs/event-handler.web.js.map +0 -1
  41. package/lib/commonjs/event-mappings.js +0 -9
  42. package/lib/commonjs/event-mappings.js.map +0 -1
  43. package/lib/module/event-handler.d.js +0 -2
  44. package/lib/module/event-handler.d.js.map +0 -1
  45. package/lib/module/event-handler.js +0 -14
  46. package/lib/module/event-handler.js.map +0 -1
  47. package/lib/module/event-handler.web.js +0 -5
  48. package/lib/module/event-handler.web.js.map +0 -1
  49. package/lib/module/event-mappings.js +0 -3
  50. package/lib/module/event-mappings.js.map +0 -1
  51. package/lib/typescript/event-mappings.d.ts +0 -2
  52. package/src/event-handler.d.ts +0 -8
  53. package/src/event-handler.js +0 -15
  54. package/src/event-handler.web.js +0 -5
  55. package/src/event-mappings.ts +0 -14
@@ -0,0 +1,2 @@
1
+ connection.project.dir=../../../android
2
+ eclipse.preferences.version=1
@@ -59,5 +59,6 @@ class KeyboardControllerPackage : TurboReactPackage() {
59
59
  KeyboardControllerViewManager(),
60
60
  KeyboardGestureAreaViewManager(),
61
61
  OverKeyboardViewManager(),
62
+ KeyboardBackgroundViewManager(),
62
63
  )
63
64
  }
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>KeyboardController.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>Tests.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ <key>SuppressBuildableAutocreation</key>
14
+ <dict>
15
+ <key>083F2DF22B860D89004A1AD1</key>
16
+ <dict>
17
+ <key>primary</key>
18
+ <true/>
19
+ </dict>
20
+ <key>083F2E022B860D8C004A1AD1</key>
21
+ <dict>
22
+ <key>primary</key>
23
+ <true/>
24
+ </dict>
25
+ <key>083F2E0C2B860D8C004A1AD1</key>
26
+ <dict>
27
+ <key>primary</key>
28
+ <true/>
29
+ </dict>
30
+ </dict>
31
+ </dict>
32
+ </plist>
@@ -10,7 +10,6 @@ var _reactNativeIsEdgeToEdge = require("react-native-is-edge-to-edge");
10
10
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
11
11
  var _bindings = require("./bindings");
12
12
  var _context = require("./context");
13
- var _eventMappings = require("./event-mappings");
14
13
  var _internal = require("./internal");
15
14
  var _module = require("./module");
16
15
  var _reanimated = require("./reanimated");
@@ -66,8 +65,8 @@ const KeyboardProvider = props => {
66
65
  const progressSV = (0, _reactNativeReanimated.useSharedValue)(0);
67
66
  const heightSV = (0, _reactNativeReanimated.useSharedValue)(0);
68
67
  const layout = (0, _reactNativeReanimated.useSharedValue)(null);
69
- const setKeyboardHandlers = (0, _internal.useEventHandlerRegistration)(_eventMappings.keyboardEventsMap, viewTagRef);
70
- const setInputHandlers = (0, _internal.useEventHandlerRegistration)(_eventMappings.focusedInputEventsMap, viewTagRef);
68
+ const setKeyboardHandlers = (0, _internal.useEventHandlerRegistration)(viewTagRef);
69
+ const setInputHandlers = (0, _internal.useEventHandlerRegistration)(viewTagRef);
71
70
  // memo
72
71
  const context = (0, _react.useMemo)(() => ({
73
72
  enabled,
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeIsEdgeToEdge","_reactNativeReanimated","_bindings","_context","_eventMappings","_internal","_module","_reanimated","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","IS_EDGE_TO_EDGE","isEdgeToEdge","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","OS","Platform","KeyboardProvider","props","children","statusBarTranslucent","navigationBarTranslucent","preserveEdgeToEdge","enabled","initiallyEnabled","preload","viewTagRef","useRef","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","useEventHandlerRegistration","keyboardEventsMap","setInputHandlers","focusedInputEventsMap","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","onKeyboardMoveEnd","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","target","useEffect","KeyboardController","__DEV__","controlEdgeToEdgeValues","createElement","KeyboardContext","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View","exports"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Animated, Platform, StyleSheet } from \"react-native\";\nimport {\n controlEdgeToEdgeValues,\n isEdgeToEdge,\n} from \"react-native-is-edge-to-edge\";\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\n\nimport { KeyboardControllerView } from \"./bindings\";\nimport { KeyboardContext } from \"./context\";\nimport { focusedInputEventsMap, keyboardEventsMap } from \"./event-mappings\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { KeyboardController } from \"./module\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\n} from \"./reanimated\";\n\nimport type { KeyboardAnimationContext } from \"./context\";\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from \"./types\";\nimport type { ViewStyle } from \"react-native\";\n\nconst IS_EDGE_TO_EDGE = isEdgeToEdge();\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(KeyboardControllerView),\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: \"none\",\n position: \"absolute\",\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592\n */\n preserveEdgeToEdge?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state\n * (if you try to change this prop after component mount it will not have any effect).\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n /**\n * A boolean prop indicating whether to preload the keyboard to reduce time-to-interaction (TTI) on first input focus.\n * Defaults to `true`.\n *\n * @platform ios\n */\n preload?: boolean;\n};\n\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\n/**\n * 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,\n * maps these events to `Animated`/`Reanimated` values and store them in context.\n *\n * @param props - Provider props, such as `statusBarTranslucent`, `navigationBarTranslucent`, etc.\n * @returns A component that should be mounted in root of your App layout.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-provider|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardProvider>\n * <NavigationContainer />\n * </KeyboardProvider>\n * ```\n */\nexport const KeyboardProvider = (props: KeyboardProviderProps) => {\n const {\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n enabled: initiallyEnabled = true,\n preload = true,\n } = props;\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(\n keyboardEventsMap,\n viewTagRef,\n );\n const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(\n focusedInputEventsMap,\n viewTagRef,\n );\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled],\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n [],\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n // Setting useNativeDriver to true on web triggers a warning due to the absence of a native driver for web. Therefore, it is set to false.\n { useNativeDriver: Platform.OS !== \"web\" },\n ),\n [],\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n \"worklet\";\n\n if (platforms.includes(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n },\n [],\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n \"worklet\";\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n [],\n );\n\n useEffect(() => {\n if (preload) {\n KeyboardController.preload();\n }\n }, [preload]);\n\n if (__DEV__) {\n controlEdgeToEdgeValues({\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n });\n }\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}\n statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}\n preserveEdgeToEdge={IS_EDGE_TO_EDGE || preserveEdgeToEdge}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onKeyboardMoveEnd={OS === \"android\" ? onKeyboardMove : undefined}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AAIA,IAAAG,sBAAA,GAAAJ,uBAAA,CAAA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;IACtED,oBAAoB,EAAEpB,eAAe,IAAIoB,oBAAqB;IAC9DE,kBAAkB,EAAEtB,eAAe,IAAIsB,kBAAmB;IAC1DyB,KAAK,EAAExC,MAAM,CAACG;IACd;IAAA;IACAkE,wBAAwB,EAAEjB,eAAgB;IAC1CE,mBAAmB,EAAE9C,EAAE,KAAK,KAAK,GAAGoC,cAAc,GAAG0B,SAAU;IAC/D1B,cAAc,EAAEpC,EAAE,KAAK,SAAS,GAAGoC,cAAc,GAAG0B,SAAU;IAC9Df,yBAAyB,EAAEX,cAAe;IAC1CY,iBAAiB,EAAEhD,EAAE,KAAK,SAAS,GAAGoC,cAAc,GAAG0B,SAAU;IACjEC,qCAAqC,EAAEd;EAAmB,GAEzD7C,QAC6B,CAAC,eACjClD,MAAA,CAAAsB,OAAA,CAAAiF,aAAA,CAACpG,YAAA,CAAAiC,QAAQ,CAAC0E,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAhC,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAACiC,OAAA,CAAA/D,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeIsEdgeToEdge","_reactNativeReanimated","_bindings","_context","_internal","_module","_reanimated","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","IS_EDGE_TO_EDGE","isEdgeToEdge","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","OS","Platform","KeyboardProvider","props","children","statusBarTranslucent","navigationBarTranslucent","preserveEdgeToEdge","enabled","initiallyEnabled","preload","viewTagRef","useRef","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","useEventHandlerRegistration","setInputHandlers","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","onKeyboardMoveEnd","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","target","useEffect","KeyboardController","__DEV__","controlEdgeToEdgeValues","createElement","KeyboardContext","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View","exports"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Animated, Platform, StyleSheet } from \"react-native\";\nimport {\n controlEdgeToEdgeValues,\n isEdgeToEdge,\n} from \"react-native-is-edge-to-edge\";\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\n\nimport { KeyboardControllerView } from \"./bindings\";\nimport { KeyboardContext } from \"./context\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { KeyboardController } from \"./module\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\n} from \"./reanimated\";\n\nimport type { KeyboardAnimationContext } from \"./context\";\nimport type {\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n NativeEvent,\n} from \"./types\";\nimport type { ViewStyle } from \"react-native\";\n\nconst IS_EDGE_TO_EDGE = isEdgeToEdge();\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(KeyboardControllerView),\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: \"none\",\n position: \"absolute\",\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592\n */\n preserveEdgeToEdge?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state\n * (if you try to change this prop after component mount it will not have any effect).\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n /**\n * A boolean prop indicating whether to preload the keyboard to reduce time-to-interaction (TTI) on first input focus.\n * Defaults to `true`.\n *\n * @platform ios\n */\n preload?: boolean;\n};\n\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\n/**\n * 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,\n * maps these events to `Animated`/`Reanimated` values and store them in context.\n *\n * @param props - Provider props, such as `statusBarTranslucent`, `navigationBarTranslucent`, etc.\n * @returns A component that should be mounted in root of your App layout.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-provider|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardProvider>\n * <NavigationContainer />\n * </KeyboardProvider>\n * ```\n */\nexport const KeyboardProvider = (props: KeyboardProviderProps) => {\n const {\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n enabled: initiallyEnabled = true,\n preload = true,\n } = props;\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const setKeyboardHandlers = useEventHandlerRegistration(viewTagRef);\n const setInputHandlers = useEventHandlerRegistration(viewTagRef);\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled],\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n [],\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n // Setting useNativeDriver to true on web triggers a warning due to the absence of a native driver for web. Therefore, it is set to false.\n { useNativeDriver: Platform.OS !== \"web\" },\n ),\n [],\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n \"worklet\";\n\n if (platforms.includes(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n },\n [],\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n \"worklet\";\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n [],\n );\n\n useEffect(() => {\n if (preload) {\n KeyboardController.preload();\n }\n }, [preload]);\n\n if (__DEV__) {\n controlEdgeToEdgeValues({\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n });\n }\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}\n statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}\n preserveEdgeToEdge={IS_EDGE_TO_EDGE || preserveEdgeToEdge}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onKeyboardMoveEnd={OS === \"android\" ? onKeyboardMove : undefined}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AAIA,IAAAG,sBAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAEA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,O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G;IACd;IAAA;IACAgE,wBAAwB,EAAEjB,eAAgB;IAC1CE,mBAAmB,EAAE5C,EAAE,KAAK,KAAK,GAAGkC,cAAc,GAAG0B,SAAU;IAC/D1B,cAAc,EAAElC,EAAE,KAAK,SAAS,GAAGkC,cAAc,GAAG0B,SAAU;IAC9Df,yBAAyB,EAAEX,cAAe;IAC1CY,iBAAiB,EAAE9C,EAAE,KAAK,SAAS,GAAGkC,cAAc,GAAG0B,SAAU;IACjEC,qCAAqC,EAAEd;EAAmB,GAEzD3C,QAC6B,CAAC,eACjCjD,MAAA,CAAAqB,OAAA,CAAA+E,aAAA,CAACjG,YAAA,CAAAgC,QAAQ,CAACwE,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAhC,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAACiC,OAAA,CAAA7D,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -140,6 +140,16 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
140
140
  }
141
141
  return 0;
142
142
  }, [bottomOffset, enabled, height, snapToOffsets]);
143
+ const performScrollWithPositionRestoration = (0, _react.useCallback)(newPosition => {
144
+ "worklet";
145
+
146
+ const prevScroll = scrollPosition.value;
147
+
148
+ // eslint-disable-next-line react-compiler/react-compiler
149
+ scrollPosition.value = newPosition;
150
+ maybeScroll(keyboardHeight.value, true);
151
+ scrollPosition.value = prevScroll;
152
+ }, [scrollPosition, keyboardHeight, maybeScroll]);
143
153
  const syncKeyboardFrame = (0, _react.useCallback)(e => {
144
154
  "worklet";
145
155
 
@@ -168,18 +178,13 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
168
178
  const scrollFromCurrentPosition = (0, _react.useCallback)(() => {
169
179
  "worklet";
170
180
 
171
- const prevScrollPosition = scrollPosition.value;
172
181
  const prevLayout = layout.value;
173
182
  if (!updateLayoutFromSelection()) {
174
183
  return;
175
184
  }
176
-
177
- // eslint-disable-next-line react-compiler/react-compiler
178
- scrollPosition.value = position.value;
179
- maybeScroll(keyboardHeight.value, true);
180
- scrollPosition.value = prevScrollPosition;
185
+ performScrollWithPositionRestoration(position.value);
181
186
  layout.value = prevLayout;
182
- }, [maybeScroll]);
187
+ }, [performScrollWithPositionRestoration]);
183
188
  const onChangeText = (0, _react.useCallback)(() => {
184
189
  "worklet";
185
190
 
@@ -268,7 +273,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
268
273
  }
269
274
  }, [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame]);
270
275
  (0, _react.useEffect)(() => {
271
- (0, _reactNativeReanimated.runOnUI)(maybeScroll)(keyboardHeight.value, true);
276
+ (0, _reactNativeReanimated.runOnUI)(performScrollWithPositionRestoration)(scrollBeforeKeyboardMovement.value);
272
277
  }, [bottomOffset]);
273
278
  (0, _reactNativeReanimated.useAnimatedReaction)(() => input.value, (current, previous) => {
274
279
  if ((current === null || current === void 0 ? void 0 : current.target) === (previous === null || previous === void 0 ? void 0 : previous.target) && (current === null || current === void 0 ? void 0 : current.layout.height) !== (previous === null || previous === void 0 ? void 0 : previous.layout.height)) {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_hooks","_findNodeHandle","_useSmoothKeyboardHandler","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","KeyboardAwareScrollView","forwardRef","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","Reanimated","ScrollView","snapToOffsets","rest","ref","scrollViewAnimatedRef","useAnimatedRef","scrollViewTarget","useSharedValue","scrollPosition","position","useScrollViewOffset","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","useReanimatedFocusedInput","layout","lastSelection","height","useWindowDimensions","onRef","useCallback","assignedRef","current","onScrollViewLayout","value","findNodeHandle","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","interpolate","scrollDistanceWithRespectToSnapPoints","targetScrollY","Math","max","scrollTo","positionOnScreen","topOfScreen","syncKeyboardFrame","keyboardFrame","updateLayoutFromSelection","_lastSelection$value","_input$value","customHeight","selection","end","y","clamp","scrollFromCurrentPosition","prevScrollPosition","prevLayout","onChangeText","onChangeTextHandler","useMemo","debounce","onSelectionChange","_lastSelection$value2","_lastSelection$value3","lastTarget","target","latestSelection","start","useFocusedInputHandler","useSmoothKeyboardHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","onMove","onEnd","useEffect","runOnUI","useAnimatedReaction","previous","view","useAnimatedStyle","paddingBottom","createElement","scrollEventThrottle","View","style","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useMemo } from \"react\";\nimport Reanimated, {\n clamp,\n interpolate,\n runOnUI,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedStyle,\n useScrollViewOffset,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n useWindowDimensions,\n} from \"../../hooks\";\nimport { findNodeHandle } from \"../../utils/findNodeHandle\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce, scrollDistanceWithRespectToSnapPoints } from \"./utils\";\n\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type {\n FocusedInputLayoutChangedEvent,\n FocusedInputSelectionChangedEvent,\n NativeEvent,\n} from \"react-native-keyboard-controller\";\n\nexport type KeyboardAwareScrollViewProps = {\n /** The distance between the keyboard and the caret inside a focused `TextInput` when the keyboard is shown. Default is `0`. */\n bottomOffset?: number;\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\n disableScrollOnKeyboardHide?: boolean;\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true`. */\n enabled?: boolean;\n /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0`. */\n extraKeyboardSpace?: number;\n /** Custom component for `ScrollView`. Default is `ScrollView`. */\n ScrollViewComponent?: React.ComponentType<ScrollViewProps>;\n} & ScrollViewProps;\n\n// Everything begins from `onStart` handler. This handler is called every time,\n// when keyboard changes its size or when focused `TextInput` was changed. In\n// this handler we are calculating/memoizing values which later will be used\n// during layout movement. For that we calculate:\n// - layout of focused field (`layout`) - to understand whether there will be overlap\n// - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n// - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n// - current scroll position (`scrollPosition`) - used to scroll from this point\n//\n// Once we've calculated all necessary variables - we can actually start to use them.\n// It happens in `onMove` handler - this function simply calls `maybeScroll` with\n// current keyboard frame height. This functions makes the smooth transition.\n//\n// When the transition has finished we go to `onEnd` handler. In this handler\n// we verify, that the current field is not overlapped within a keyboard frame.\n// For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n// however there could be some cases, when `onMove` is not called:\n// - on iOS when TextInput was changed - keyboard transition is instant\n// - on Android when TextInput was changed and keyboard size wasn't changed\n// So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n//\n// ====================================================================================================================+\n// -----------------------------------------------------Flow chart-----------------------------------------------------+\n// ====================================================================================================================+\n//\n// +============================+ +============================+ +==================================+\n// + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n// + + + (run `onStart`) + + `onMove` is getting called +\n// +============================+ +============================+ +==================================+\n//\n// +============================+ +============================+ +=====================================+\n// + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n// + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n// +============================+ +============================+ +=====================================+\n//\n\n/**\n * A ScrollView component that automatically handles keyboard appearance and disappearance\n * by adjusting its content position to ensure the focused input remains visible.\n *\n * The component uses a sophisticated animation system to smoothly handle keyboard transitions\n * and maintain proper scroll position during keyboard interactions.\n *\n * @returns A ScrollView component that handles keyboard interactions.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-aware-scroll-view|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardAwareScrollView bottomOffset={20}>\n * <TextInput placeholder=\"Enter text\" />\n * <TextInput placeholder=\"Another input\" />\n * </KeyboardAwareScrollView>\n * ```\n */\nconst KeyboardAwareScrollView = forwardRef<\n ScrollView,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n extraKeyboardSpace = 0,\n ScrollViewComponent = Reanimated.ScrollView,\n snapToOffsets,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const position = useScrollViewOffset(scrollViewAnimatedRef);\n const currentKeyboardFrameHeight = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const keyboardWillAppear = useSharedValue(false);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const lastSelection =\n useSharedValue<FocusedInputSelectionChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\n if (typeof ref === \"function\") {\n ref(assignedRef);\n } else if (ref) {\n ref.current = assignedRef;\n }\n\n scrollViewAnimatedRef(assignedRef);\n }, []);\n const onScrollViewLayout = useCallback(\n (e: LayoutChangeEvent) => {\n scrollViewTarget.value = findNodeHandle(scrollViewAnimatedRef.current);\n\n onLayout?.(e);\n },\n [onLayout],\n );\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving.\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n \"worklet\";\n\n if (!enabled) {\n return 0;\n }\n\n // input belongs to ScrollView\n if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {\n return 0;\n }\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const relativeScrollTo =\n keyboardHeight.value - (height - point) + bottomOffset;\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [\n 0,\n scrollDistanceWithRespectToSnapPoints(\n relativeScrollTo + scrollPosition.value,\n snapToOffsets,\n ) - scrollPosition.value,\n ],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (point < 0) {\n const positionOnScreen = visibleRect - bottomOffset;\n const topOfScreen = scrollPosition.value + point;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled, height, snapToOffsets],\n );\n const syncKeyboardFrame = useCallback(\n (e: NativeEvent) => {\n \"worklet\";\n\n const keyboardFrame = interpolate(\n e.height,\n [0, keyboardHeight.value],\n [0, keyboardHeight.value + extraKeyboardSpace],\n );\n\n currentKeyboardFrameHeight.value = keyboardFrame;\n },\n [extraKeyboardSpace],\n );\n\n const updateLayoutFromSelection = useCallback(() => {\n \"worklet\";\n\n const customHeight = lastSelection.value?.selection.end.y;\n\n if (!input.value?.layout || !customHeight) {\n return false;\n }\n\n layout.value = {\n ...input.value,\n layout: {\n ...input.value.layout,\n // when we have multiline input with limited amount of lines, then custom height can be very big\n // so we clamp it to max input height\n height: clamp(customHeight, 0, input.value.layout.height),\n },\n };\n\n return true;\n }, [input, lastSelection, layout]);\n const scrollFromCurrentPosition = useCallback(() => {\n \"worklet\";\n\n const prevScrollPosition = scrollPosition.value;\n const prevLayout = layout.value;\n\n if (!updateLayoutFromSelection()) {\n return;\n }\n\n // eslint-disable-next-line react-compiler/react-compiler\n scrollPosition.value = position.value;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScrollPosition;\n layout.value = prevLayout;\n }, [maybeScroll]);\n const onChangeText = useCallback(() => {\n \"worklet\";\n scrollFromCurrentPosition();\n }, [scrollFromCurrentPosition]);\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n const onSelectionChange = useCallback(\n (e: FocusedInputSelectionChangedEvent) => {\n \"worklet\";\n\n const lastTarget = lastSelection.value?.target;\n const latestSelection = lastSelection.value?.selection;\n\n lastSelection.value = e;\n\n if (e.target !== lastTarget) {\n // ignore this event, because \"focus changed\" event handled in `useSmoothKeyboardHandler`\n return;\n }\n // caret in the end + end coordinates has been changed -> we moved to a new line\n // so input may grow\n if (\n e.selection.end.position === e.selection.start.position &&\n latestSelection?.end.y !== e.selection.end.y\n ) {\n return scrollFromCurrentPosition();\n }\n // selection has been changed\n if (e.selection.start.position !== e.selection.end.position) {\n return scrollFromCurrentPosition();\n }\n\n onChangeTextHandler();\n },\n [scrollFromCurrentPosition, onChangeTextHandler],\n );\n\n useFocusedInputHandler(\n {\n onSelectionChange: onSelectionChange,\n },\n [onSelectionChange],\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\n\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) ||\n keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n }\n\n if (\n keyboardWillAppear.value ||\n keyboardWillChangeSize ||\n focusWasChanged\n ) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n // save position of focused text input when keyboard starts to move\n updateLayoutFromSelection();\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && !keyboardWillAppear.value) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n syncKeyboardFrame(e);\n\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\n if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\n maybeScroll(e.height);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n\n syncKeyboardFrame(e);\n },\n },\n [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame],\n );\n\n useEffect(() => {\n runOnUI(maybeScroll)(keyboardHeight.value, true);\n }, [bottomOffset]);\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n // input has changed layout - let's check if we need to scroll\n // may happen when you paste text, then onSelectionChange will be\n // fired earlier than text actually changes its layout\n scrollFromCurrentPosition();\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () =>\n enabled\n ? {\n // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\n // re-calculation on every animation frame and it helps to achieve smooth animation.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n paddingBottom: currentKeyboardFrameHeight.value + 1,\n }\n : {},\n [enabled],\n );\n\n return (\n <ScrollViewComponent\n ref={onRef}\n {...rest}\n scrollEventThrottle={16}\n onLayout={onScrollViewLayout}\n >\n {children}\n {enabled && <Reanimated.View style={view} />}\n </ScrollViewComponent>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAF,uBAAA,CAAAC,OAAA;AAYA,IAAAE,MAAA,GAAAF,OAAA;AAKA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,yBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAA0E,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,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AAE7E,0BAA0B,CAACiB,KAAK,GAAG;EACpD,CAAC,GACD,CAAC,CAAC,EACR,CAAChC,OAAO,CACV,CAAC;EAED,oBACEvC,MAAA,CAAAkB,OAAA,CAAAkH,aAAA,CAAC3F,mBAAmB,EAAAd,QAAA;IAClBmB,GAAG,EAAEoB;EAAM,GACPrB,IAAI;IACRwF,mBAAmB,EAAE,EAAG;IACxBjG,QAAQ,EAAEkC;EAAmB,IAE5BnC,QAAQ,EACRI,OAAO,iBAAIvC,MAAA,CAAAkB,OAAA,CAAAkH,aAAA,CAACjI,sBAAA,CAAAe,OAAU,CAACoH,IAAI;IAACC,KAAK,EAAEN;EAAK,CAAE,CACxB,CAAC;AAE1B,CACF,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAAvH,OAAA,GAEae,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_hooks","_findNodeHandle","_useSmoothKeyboardHandler","_utils","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","KeyboardAwareScrollView","forwardRef","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","Reanimated","ScrollView","snapToOffsets","rest","ref","scrollViewAnimatedRef","useAnimatedRef","scrollViewTarget","useSharedValue","scrollPosition","position","useScrollViewOffset","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","useReanimatedFocusedInput","layout","lastSelection","height","useWindowDimensions","onRef","useCallback","assignedRef","current","onScrollViewLayout","value","findNodeHandle","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","interpolate","scrollDistanceWithRespectToSnapPoints","targetScrollY","Math","max","scrollTo","positionOnScreen","topOfScreen","performScrollWithPositionRestoration","newPosition","prevScroll","syncKeyboardFrame","keyboardFrame","updateLayoutFromSelection","_lastSelection$value","_input$value","customHeight","selection","end","y","clamp","scrollFromCurrentPosition","prevLayout","onChangeText","onChangeTextHandler","useMemo","debounce","onSelectionChange","_lastSelection$value2","_lastSelection$value3","lastTarget","target","latestSelection","start","useFocusedInputHandler","useSmoothKeyboardHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","onMove","onEnd","useEffect","runOnUI","useAnimatedReaction","previous","view","useAnimatedStyle","paddingBottom","createElement","scrollEventThrottle","View","style","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useMemo } from \"react\";\nimport Reanimated, {\n clamp,\n interpolate,\n runOnUI,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedStyle,\n useScrollViewOffset,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n useWindowDimensions,\n} from \"../../hooks\";\nimport { findNodeHandle } from \"../../utils/findNodeHandle\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce, scrollDistanceWithRespectToSnapPoints } from \"./utils\";\n\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type {\n FocusedInputLayoutChangedEvent,\n FocusedInputSelectionChangedEvent,\n NativeEvent,\n} from \"react-native-keyboard-controller\";\n\nexport type KeyboardAwareScrollViewProps = {\n /** The distance between the keyboard and the caret inside a focused `TextInput` when the keyboard is shown. Default is `0`. */\n bottomOffset?: number;\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\n disableScrollOnKeyboardHide?: boolean;\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true`. */\n enabled?: boolean;\n /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0`. */\n extraKeyboardSpace?: number;\n /** Custom component for `ScrollView`. Default is `ScrollView`. */\n ScrollViewComponent?: React.ComponentType<ScrollViewProps>;\n} & ScrollViewProps;\n\n// Everything begins from `onStart` handler. This handler is called every time,\n// when keyboard changes its size or when focused `TextInput` was changed. In\n// this handler we are calculating/memoizing values which later will be used\n// during layout movement. For that we calculate:\n// - layout of focused field (`layout`) - to understand whether there will be overlap\n// - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n// - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n// - current scroll position (`scrollPosition`) - used to scroll from this point\n//\n// Once we've calculated all necessary variables - we can actually start to use them.\n// It happens in `onMove` handler - this function simply calls `maybeScroll` with\n// current keyboard frame height. This functions makes the smooth transition.\n//\n// When the transition has finished we go to `onEnd` handler. In this handler\n// we verify, that the current field is not overlapped within a keyboard frame.\n// For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n// however there could be some cases, when `onMove` is not called:\n// - on iOS when TextInput was changed - keyboard transition is instant\n// - on Android when TextInput was changed and keyboard size wasn't changed\n// So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n//\n// ====================================================================================================================+\n// -----------------------------------------------------Flow chart-----------------------------------------------------+\n// ====================================================================================================================+\n//\n// +============================+ +============================+ +==================================+\n// + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n// + + + (run `onStart`) + + `onMove` is getting called +\n// +============================+ +============================+ +==================================+\n//\n// +============================+ +============================+ +=====================================+\n// + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n// + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n// +============================+ +============================+ +=====================================+\n//\n\n/**\n * A ScrollView component that automatically handles keyboard appearance and disappearance\n * by adjusting its content position to ensure the focused input remains visible.\n *\n * The component uses a sophisticated animation system to smoothly handle keyboard transitions\n * and maintain proper scroll position during keyboard interactions.\n *\n * @returns A ScrollView component that handles keyboard interactions.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-aware-scroll-view|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardAwareScrollView bottomOffset={20}>\n * <TextInput placeholder=\"Enter text\" />\n * <TextInput placeholder=\"Another input\" />\n * </KeyboardAwareScrollView>\n * ```\n */\nconst KeyboardAwareScrollView = forwardRef<\n ScrollView,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n extraKeyboardSpace = 0,\n ScrollViewComponent = Reanimated.ScrollView,\n snapToOffsets,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const position = useScrollViewOffset(scrollViewAnimatedRef);\n const currentKeyboardFrameHeight = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const keyboardWillAppear = useSharedValue(false);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const lastSelection =\n useSharedValue<FocusedInputSelectionChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\n if (typeof ref === \"function\") {\n ref(assignedRef);\n } else if (ref) {\n ref.current = assignedRef;\n }\n\n scrollViewAnimatedRef(assignedRef);\n }, []);\n const onScrollViewLayout = useCallback(\n (e: LayoutChangeEvent) => {\n scrollViewTarget.value = findNodeHandle(scrollViewAnimatedRef.current);\n\n onLayout?.(e);\n },\n [onLayout],\n );\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving.\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n \"worklet\";\n\n if (!enabled) {\n return 0;\n }\n\n // input belongs to ScrollView\n if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {\n return 0;\n }\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const relativeScrollTo =\n keyboardHeight.value - (height - point) + bottomOffset;\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [\n 0,\n scrollDistanceWithRespectToSnapPoints(\n relativeScrollTo + scrollPosition.value,\n snapToOffsets,\n ) - scrollPosition.value,\n ],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (point < 0) {\n const positionOnScreen = visibleRect - bottomOffset;\n const topOfScreen = scrollPosition.value + point;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled, height, snapToOffsets],\n );\n const performScrollWithPositionRestoration = useCallback(\n (newPosition: number) => {\n \"worklet\";\n\n const prevScroll = scrollPosition.value;\n\n // eslint-disable-next-line react-compiler/react-compiler\n scrollPosition.value = newPosition;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScroll;\n },\n [scrollPosition, keyboardHeight, maybeScroll],\n );\n const syncKeyboardFrame = useCallback(\n (e: NativeEvent) => {\n \"worklet\";\n\n const keyboardFrame = interpolate(\n e.height,\n [0, keyboardHeight.value],\n [0, keyboardHeight.value + extraKeyboardSpace],\n );\n\n currentKeyboardFrameHeight.value = keyboardFrame;\n },\n [extraKeyboardSpace],\n );\n\n const updateLayoutFromSelection = useCallback(() => {\n \"worklet\";\n\n const customHeight = lastSelection.value?.selection.end.y;\n\n if (!input.value?.layout || !customHeight) {\n return false;\n }\n\n layout.value = {\n ...input.value,\n layout: {\n ...input.value.layout,\n // when we have multiline input with limited amount of lines, then custom height can be very big\n // so we clamp it to max input height\n height: clamp(customHeight, 0, input.value.layout.height),\n },\n };\n\n return true;\n }, [input, lastSelection, layout]);\n const scrollFromCurrentPosition = useCallback(() => {\n \"worklet\";\n\n const prevLayout = layout.value;\n\n if (!updateLayoutFromSelection()) {\n return;\n }\n\n performScrollWithPositionRestoration(position.value);\n\n layout.value = prevLayout;\n }, [performScrollWithPositionRestoration]);\n const onChangeText = useCallback(() => {\n \"worklet\";\n scrollFromCurrentPosition();\n }, [scrollFromCurrentPosition]);\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n const onSelectionChange = useCallback(\n (e: FocusedInputSelectionChangedEvent) => {\n \"worklet\";\n\n const lastTarget = lastSelection.value?.target;\n const latestSelection = lastSelection.value?.selection;\n\n lastSelection.value = e;\n\n if (e.target !== lastTarget) {\n // ignore this event, because \"focus changed\" event handled in `useSmoothKeyboardHandler`\n return;\n }\n // caret in the end + end coordinates has been changed -> we moved to a new line\n // so input may grow\n if (\n e.selection.end.position === e.selection.start.position &&\n latestSelection?.end.y !== e.selection.end.y\n ) {\n return scrollFromCurrentPosition();\n }\n // selection has been changed\n if (e.selection.start.position !== e.selection.end.position) {\n return scrollFromCurrentPosition();\n }\n\n onChangeTextHandler();\n },\n [scrollFromCurrentPosition, onChangeTextHandler],\n );\n\n useFocusedInputHandler(\n {\n onSelectionChange: onSelectionChange,\n },\n [onSelectionChange],\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\n\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) ||\n keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n }\n\n if (\n keyboardWillAppear.value ||\n keyboardWillChangeSize ||\n focusWasChanged\n ) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n // save position of focused text input when keyboard starts to move\n updateLayoutFromSelection();\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && !keyboardWillAppear.value) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n syncKeyboardFrame(e);\n\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\n if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\n maybeScroll(e.height);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n\n syncKeyboardFrame(e);\n },\n },\n [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame],\n );\n\n useEffect(() => {\n runOnUI(performScrollWithPositionRestoration)(\n scrollBeforeKeyboardMovement.value,\n );\n }, [bottomOffset]);\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n // input has changed layout - let's check if we need to scroll\n // may happen when you paste text, then onSelectionChange will be\n // fired earlier than text actually changes its layout\n scrollFromCurrentPosition();\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () =>\n enabled\n ? {\n // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\n // re-calculation on every animation frame and it helps to achieve smooth animation.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n paddingBottom: currentKeyboardFrameHeight.value + 1,\n }\n : {},\n [enabled],\n );\n\n return (\n <ScrollViewComponent\n ref={onRef}\n {...rest}\n scrollEventThrottle={16}\n onLayout={onScrollViewLayout}\n >\n {children}\n {enabled && <Reanimated.View style={view} />}\n </ScrollViewComponent>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAF,uBAAA,CAAAC,OAAA;AAYA,IAAAE,MAAA,GAAAF,OAAA;AAKA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,yBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAA0E,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IA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AAC;EAED,MAAMyB,IAAI,GAAG,IAAAC,uCAAgB,EAC3B,MACE7F,OAAO,GACH;IACE;IACA;IACA;IACA;IACA;IACA;IACA8F,aAAa,EAAE/E,0BAA0B,CAACiB,KAAK,GAAG;EACpD,CAAC,GACD,CAAC,CAAC,EACR,CAAChC,OAAO,CACV,CAAC;EAED,oBACEvC,MAAA,CAAAkB,OAAA,CAAAoH,aAAA,CAAC7F,mBAAmB,EAAAd,QAAA;IAClBmB,GAAG,EAAEoB;EAAM,GACPrB,IAAI;IACR0F,mBAAmB,EAAE,EAAG;IACxBnG,QAAQ,EAAEkC;EAAmB,IAE5BnC,QAAQ,EACRI,OAAO,iBAAIvC,MAAA,CAAAkB,OAAA,CAAAoH,aAAA,CAACnI,sBAAA,CAAAe,OAAU,CAACsH,IAAI;IAACC,KAAK,EAAEN;EAAK,CAAE,CACxB,CAAC;AAE1B,CACF,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAAzH,OAAA,GAEae,uBAAuB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_reactNative","NOOP","NESTED_NOOP","withSharedValue","value","addListener","removeListener","modify","get","set","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Animated","Value","height","reanimated","layout","setKeyboardHandlers","setInputHandlers","setEnabled","KeyboardContext","exports","createContext","useKeyboardContext","context","useContext","__DEV__","console","warn"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardHandler,\n} from \"./types\";\nimport type React from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nexport type AnimatedContext = {\n /**\n * A value between `0` and `1` indicating keyboard position, where `0` means keyboard is closed and `1` means keyboard is fully visible.\n * Represented as `Animated.Value`.\n */\n progress: Animated.Value;\n /** Height of the keyboard. Represented as `Animated.Value`. */\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n /**\n * A value between `0` and `1` indicating keyboard position, where `0` means keyboard is closed and `1` means keyboard is fully visible.\n * Represented as `SharedValue`.\n */\n progress: SharedValue<number>;\n /** Height of the keyboard. Represented as `SharedValue`. */\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n /** Whether KeyboardController library is active or not. */\n enabled: boolean;\n /** Object that stores animated values that reflect the keyboard’s current position and movement. */\n animated: AnimatedContext;\n /** Object that stores reanimated values that reflect the keyboard’s current position and movement. */\n reanimated: ReanimatedContext;\n /** Layout of the focused `TextInput` represented as `SharedValue`. */\n layout: SharedValue<FocusedInputLayoutChangedEvent | null>;\n /** Method for setting workletized keyboard handlers. */\n setKeyboardHandlers: (handlers: KeyboardHandler) => () => void;\n /** Method for setting workletized handlers for tracking focused input events. */\n setInputHandlers: (handlers: FocusedInputHandler) => () => void;\n /** Method to enable/disable KeyboardController library. */\n setEnabled: React.Dispatch<React.SetStateAction<boolean>>;\n};\nconst NOOP = () => {};\nconst NESTED_NOOP = () => NOOP;\nconst withSharedValue = <T>(value: T): SharedValue<T> => ({\n value,\n addListener: NOOP,\n removeListener: NOOP,\n modify: NOOP,\n get: () => value,\n set: NOOP,\n});\nconst DEFAULT_SHARED_VALUE = withSharedValue(0);\nconst DEFAULT_LAYOUT = withSharedValue<FocusedInputLayoutChangedEvent | null>(\n null,\n);\nconst defaultContext: KeyboardAnimationContext = {\n enabled: true,\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: DEFAULT_SHARED_VALUE,\n height: DEFAULT_SHARED_VALUE,\n },\n layout: DEFAULT_LAYOUT,\n setKeyboardHandlers: NESTED_NOOP,\n setInputHandlers: NESTED_NOOP,\n setEnabled: NOOP,\n};\n\nexport const KeyboardContext = createContext(defaultContext);\n\n/**\n * A hook that returns a reference to {@link KeyboardAnimationContext} object.\n *\n * @returns Object {@link KeyboardAnimationContext|containing} keyboard-controller context.\n * @example\n * ```ts\n * const context = useKeyboardContext();\n *\n * useLayoutEffect(() => {\n * const cleanup = context.setInputHandlers(handler);\n *\n * return () => cleanup();\n * }, deps);\n * ```\n */\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n\n if (__DEV__ && context === defaultContext) {\n console.warn(\n \"Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.\",\n );\n }\n\n return context;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AA4CA,MAAME,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,WAAW,GAAGA,CAAA,KAAMD,IAAI;AAC9B,MAAME,eAAe,GAAOC,KAAQ,KAAsB;EACxDA,KAAK;EACLC,WAAW,EAAEJ,IAAI;EACjBK,cAAc,EAAEL,IAAI;EACpBM,MAAM,EAAEN,IAAI;EACZO,GAAG,EAAEA,CAAA,KAAMJ,KAAK;EAChBK,GAAG,EAAER;AACP,CAAC,CAAC;AACF,MAAMS,oBAAoB,GAAGP,eAAe,CAAC,CAAC,CAAC;AAC/C,MAAMQ,cAAc,GAAGR,eAAe,CACpC,IACF,CAAC;AACD,MAAMS,cAAwC,GAAG;EAC/CC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIC,qBAAQ,CAACC,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIF,qBAAQ,CAACC,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVJ,QAAQ,EAAEL,oBAAoB;IAC9BQ,MAAM,EAAER;EACV,CAAC;EACDU,MAAM,EAAET,cAAc;EACtBU,mBAAmB,EAAEnB,WAAW;EAChCoB,gBAAgB,EAAEpB,WAAW;EAC7BqB,UAAU,EAAEtB;AACd,CAAC;AAEM,MAAMuB,eAAe,GAAAC,OAAA,CAAAD,eAAA,gBAAG,IAAAE,oBAAa,EAACd,cAAc,CAAC;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMe,kBAAkB,GAAGA,CAAA,KAAM;EACtC,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACL,eAAe,CAAC;EAE3C,IAAIM,OAAO,IAAIF,OAAO,KAAKhB,cAAc,EAAE;IACzCmB,OAAO,CAACC,IAAI,CACV,sLACF,CAAC;EACH;EAEA,OAAOJ,OAAO;AAChB,CAAC;AAACH,OAAA,CAAAE,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_reactNative","NOOP","NESTED_NOOP","withSharedValue","value","addListener","removeListener","modify","get","set","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Animated","Value","height","reanimated","layout","setKeyboardHandlers","setInputHandlers","setEnabled","KeyboardContext","exports","createContext","useKeyboardContext","context","useContext","__DEV__","console","warn"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport type { FocusedInputLayoutChangedEvent } from \"./types\";\nimport type React from \"react\";\nimport type {\n EventHandlerProcessed,\n SharedValue,\n} from \"react-native-reanimated\";\n\nexport type AnimatedContext = {\n /**\n * A value between `0` and `1` indicating keyboard position, where `0` means keyboard is closed and `1` means keyboard is fully visible.\n * Represented as `Animated.Value`.\n */\n progress: Animated.Value;\n /** Height of the keyboard. Represented as `Animated.Value`. */\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n /**\n * A value between `0` and `1` indicating keyboard position, where `0` means keyboard is closed and `1` means keyboard is fully visible.\n * Represented as `SharedValue`.\n */\n progress: SharedValue<number>;\n /** Height of the keyboard. Represented as `SharedValue`. */\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n /** Whether KeyboardController library is active or not. */\n enabled: boolean;\n /** Object that stores animated values that reflect the keyboard’s current position and movement. */\n animated: AnimatedContext;\n /** Object that stores reanimated values that reflect the keyboard’s current position and movement. */\n reanimated: ReanimatedContext;\n /** Layout of the focused `TextInput` represented as `SharedValue`. */\n layout: SharedValue<FocusedInputLayoutChangedEvent | null>;\n /** Method for setting workletized keyboard handlers. */\n setKeyboardHandlers: (\n handlers: EventHandlerProcessed<never, never>,\n ) => () => void;\n /** Method for setting workletized handlers for tracking focused input events. */\n setInputHandlers: (\n handlers: EventHandlerProcessed<never, never>,\n ) => () => void;\n /** Method to enable/disable KeyboardController library. */\n setEnabled: React.Dispatch<React.SetStateAction<boolean>>;\n};\nconst NOOP = () => {};\nconst NESTED_NOOP = () => NOOP;\nconst withSharedValue = <T>(value: T): SharedValue<T> => ({\n value,\n addListener: NOOP,\n removeListener: NOOP,\n modify: NOOP,\n get: () => value,\n set: NOOP,\n});\nconst DEFAULT_SHARED_VALUE = withSharedValue(0);\nconst DEFAULT_LAYOUT = withSharedValue<FocusedInputLayoutChangedEvent | null>(\n null,\n);\nconst defaultContext: KeyboardAnimationContext = {\n enabled: true,\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: DEFAULT_SHARED_VALUE,\n height: DEFAULT_SHARED_VALUE,\n },\n layout: DEFAULT_LAYOUT,\n setKeyboardHandlers: NESTED_NOOP,\n setInputHandlers: NESTED_NOOP,\n setEnabled: NOOP,\n};\n\nexport const KeyboardContext = createContext(defaultContext);\n\n/**\n * A hook that returns a reference to {@link KeyboardAnimationContext} object.\n *\n * @returns Object {@link KeyboardAnimationContext|containing} keyboard-controller context.\n * @example\n * ```ts\n * const context = useKeyboardContext();\n *\n * useLayoutEffect(() => {\n * const cleanup = context.setInputHandlers(handler);\n *\n * return () => cleanup();\n * }, deps);\n * ```\n */\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n\n if (__DEV__ && context === defaultContext) {\n console.warn(\n \"Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.\",\n );\n }\n\n return context;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AA+CA,MAAME,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,WAAW,GAAGA,CAAA,KAAMD,IAAI;AAC9B,MAAME,eAAe,GAAOC,KAAQ,KAAsB;EACxDA,KAAK;EACLC,WAAW,EAAEJ,IAAI;EACjBK,cAAc,EAAEL,IAAI;EACpBM,MAAM,EAAEN,IAAI;EACZO,GAAG,EAAEA,CAAA,KAAMJ,KAAK;EAChBK,GAAG,EAAER;AACP,CAAC,CAAC;AACF,MAAMS,oBAAoB,GAAGP,eAAe,CAAC,CAAC,CAAC;AAC/C,MAAMQ,cAAc,GAAGR,eAAe,CACpC,IACF,CAAC;AACD,MAAMS,cAAwC,GAAG;EAC/CC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIC,qBAAQ,CAACC,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIF,qBAAQ,CAACC,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVJ,QAAQ,EAAEL,oBAAoB;IAC9BQ,MAAM,EAAER;EACV,CAAC;EACDU,MAAM,EAAET,cAAc;EACtBU,mBAAmB,EAAEnB,WAAW;EAChCoB,gBAAgB,EAAEpB,WAAW;EAC7BqB,UAAU,EAAEtB;AACd,CAAC;AAEM,MAAMuB,eAAe,GAAAC,OAAA,CAAAD,eAAA,gBAAG,IAAAE,oBAAa,EAACd,cAAc,CAAC;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMe,kBAAkB,GAAGA,CAAA,KAAM;EACtC,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACL,eAAe,CAAC;EAE3C,IAAIM,OAAO,IAAIF,OAAO,KAAKhB,cAAc,EAAE;IACzCmB,OAAO,CAACC,IAAI,CACV,sLACF,CAAC;EACH;EAEA,OAAOJ,OAAO;AAChB,CAAC;AAACH,OAAA,CAAAE,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -21,6 +21,7 @@ exports.useKeyboardHandler = useKeyboardHandler;
21
21
  exports.useReanimatedFocusedInput = useReanimatedFocusedInput;
22
22
  exports.useResizeMode = exports.useReanimatedKeyboardAnimation = void 0;
23
23
  var _react = require("react");
24
+ var _reactNativeReanimated = require("react-native-reanimated");
24
25
  var _constants = require("../constants");
25
26
  var _context = require("../context");
26
27
  var _module = require("../module");
@@ -145,8 +146,31 @@ const useReanimatedKeyboardAnimation = () => {
145
146
  exports.useReanimatedKeyboardAnimation = useReanimatedKeyboardAnimation;
146
147
  function useGenericKeyboardHandler(handler, deps) {
147
148
  const context = (0, _context.useKeyboardContext)();
149
+ const {
150
+ doDependenciesDiffer
151
+ } = (0, _reactNativeReanimated.useHandler)(handler, deps);
152
+ const eventHandler = (0, _reactNativeReanimated.useEvent)(event => {
153
+ "worklet";
154
+
155
+ if (event.eventName.endsWith("onKeyboardMoveStart")) {
156
+ var _handler$onStart;
157
+ (_handler$onStart = handler.onStart) === null || _handler$onStart === void 0 || _handler$onStart.call(handler, event);
158
+ }
159
+ if (event.eventName.endsWith("onKeyboardMove")) {
160
+ var _handler$onMove;
161
+ (_handler$onMove = handler.onMove) === null || _handler$onMove === void 0 || _handler$onMove.call(handler, event);
162
+ }
163
+ if (event.eventName.endsWith("onKeyboardMoveEnd")) {
164
+ var _handler$onEnd;
165
+ (_handler$onEnd = handler.onEnd) === null || _handler$onEnd === void 0 || _handler$onEnd.call(handler, event);
166
+ }
167
+ if (event.eventName.endsWith("onKeyboardMoveInteractive")) {
168
+ var _handler$onInteractiv;
169
+ (_handler$onInteractiv = handler.onInteractive) === null || _handler$onInteractiv === void 0 || _handler$onInteractiv.call(handler, event);
170
+ }
171
+ }, ["onKeyboardMoveStart", "onKeyboardMove", "onKeyboardMoveEnd", "onKeyboardMoveInteractive"], doDependenciesDiffer);
148
172
  (0, _react.useLayoutEffect)(() => {
149
- const cleanup = context.setKeyboardHandlers(handler);
173
+ const cleanup = context.setKeyboardHandlers(eventHandler);
150
174
  return () => cleanup();
151
175
  }, deps);
152
176
  }
@@ -257,8 +281,23 @@ function useReanimatedFocusedInput() {
257
281
  */
258
282
  function useFocusedInputHandler(handler, deps) {
259
283
  const context = (0, _context.useKeyboardContext)();
284
+ const {
285
+ doDependenciesDiffer
286
+ } = (0, _reactNativeReanimated.useHandler)(handler, deps);
287
+ const eventHandler = (0, _reactNativeReanimated.useEvent)(event => {
288
+ "worklet";
289
+
290
+ if (event.eventName.endsWith("onFocusedInputTextChanged")) {
291
+ var _handler$onChangeText;
292
+ (_handler$onChangeText = handler.onChangeText) === null || _handler$onChangeText === void 0 || _handler$onChangeText.call(handler, event);
293
+ }
294
+ if (event.eventName.endsWith("onFocusedInputSelectionChanged")) {
295
+ var _handler$onSelectionC;
296
+ (_handler$onSelectionC = handler.onSelectionChange) === null || _handler$onSelectionC === void 0 || _handler$onSelectionC.call(handler, event);
297
+ }
298
+ }, ["onFocusedInputTextChanged", "onFocusedInputSelectionChanged"], doDependenciesDiffer);
260
299
  (0, _react.useLayoutEffect)(() => {
261
- const cleanup = context.setInputHandlers(handler);
300
+ const cleanup = context.setInputHandlers(eventHandler);
262
301
  return () => cleanup();
263
302
  }, deps);
264
303
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_constants","_context","_module","_useWindowDimensions","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_useKeyboardState","useResizeMode","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","useKeyboardContext","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","useLayoutEffect","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,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAyOA,IAAAI,oBAAA,GAAAJ,OAAA;AAAAK,MAAA,CAAAC,IAAA,CAAAF,oBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,oBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,oBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,iBAAA,GAAAjB,OAAA;AAAAK,MAAA,CAAAC,IAAA,CAAAW,iBAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,iBAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAA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AAC,CAAC;EAEpC,IAAAO,sBAAe,EAAC,MAAM;IACpB,MAAMC,OAAO,GAAGT,OAAO,CAACU,mBAAmB,CAACJ,OAAO,CAAC;IAEpD,OAAO,MAAMG,OAAO,CAAC,CAAC;EACxB,CAAC,EAAEF,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;AACO,SAASI,kBAAkBA,CAChCL,OAAwB,EACxBC,IAAqB,EACrB;EACAf,aAAa,CAAC,CAAC;EACfa,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;AACO,SAASK,qBAAqBA,CAAA,EAAG;EACtC,MAAMZ,OAAO,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAEpC,OAAO;IAAEY,UAAU,EAAEb,OAAO,CAACa,UAAU;IAAEC,OAAO,EAAEd,OAAO,CAACc;EAAQ,CAAC;AACrE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,yBAAyBA,CAAA,EAAG;EAC1C,MAAMf,OAAO,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAEpC,OAAO;IAAEe,KAAK,EAAEhB,OAAO,CAACiB;EAAO,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CACpCZ,OAA4B,EAC5BC,IAAqB,EACrB;EACA,MAAMP,OAAO,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAEpC,IAAAO,sBAAe,EAAC,MAAM;IACpB,MAAMC,OAAO,GAAGT,OAAO,CAACmB,gBAAgB,CAACb,OAAO,CAAC;IAEjD,OAAO,MAAMG,OAAO,CAAC,CAAC;EACxB,CAAC,EAAEF,IAAI,CAAC;AACV","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_reactNativeReanimated","_constants","_context","_module","_useWindowDimensions","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_useKeyboardState","useResizeMode","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","useKeyboardContext","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","doDependenciesDiffer","useHandler","eventHandler","useEvent","event","eventName","endsWith","_handler$onStart","onStart","_handler$onMove","onMove","_handler$onEnd","onEnd","_handler$onInteractiv","onInteractive","useLayoutEffect","cleanup","setKeyboardHandlers","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","_handler$onChangeText","onChangeText","_handler$onSelectionC","onSelectionChange","setInputHandlers"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from \"react\";\nimport { useEvent, useHandler } from \"react-native-reanimated\";\n\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\nimport { KeyboardController } from \"../module\";\n\nimport type { AnimatedContext, ReanimatedContext } from \"../context\";\nimport type {\n FocusedInputHandler,\n FocusedInputSelectionChangedEvent,\n FocusedInputTextChangedEvent,\n KeyboardHandler,\n NativeEvent,\n} from \"../types\";\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?: unknown[],\n) {\n const context = useKeyboardContext();\n\n const { doDependenciesDiffer } = useHandler(handler, deps);\n\n const eventHandler = useEvent<NativeEvent>(\n (event) => {\n \"worklet\";\n\n if (event.eventName.endsWith(\"onKeyboardMoveStart\")) {\n handler.onStart?.(event);\n }\n\n if (event.eventName.endsWith(\"onKeyboardMove\")) {\n handler.onMove?.(event);\n }\n\n if (event.eventName.endsWith(\"onKeyboardMoveEnd\")) {\n handler.onEnd?.(event);\n }\n\n if (event.eventName.endsWith(\"onKeyboardMoveInteractive\")) {\n handler.onInteractive?.(event);\n }\n },\n [\n \"onKeyboardMoveStart\",\n \"onKeyboardMove\",\n \"onKeyboardMoveEnd\",\n \"onKeyboardMoveInteractive\",\n ],\n doDependenciesDiffer,\n );\n\n useLayoutEffect(() => {\n const cleanup = context.setKeyboardHandlers(eventHandler);\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(handler: KeyboardHandler, deps?: unknown[]) {\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?: unknown[],\n) {\n const context = useKeyboardContext();\n\n const { doDependenciesDiffer } = useHandler<never, never>(handler, deps);\n\n const eventHandler = useEvent<\n FocusedInputSelectionChangedEvent | FocusedInputTextChangedEvent\n >(\n (event) => {\n \"worklet\";\n\n if (event.eventName.endsWith(\"onFocusedInputTextChanged\")) {\n handler.onChangeText?.(event as FocusedInputTextChangedEvent);\n }\n\n if (event.eventName.endsWith(\"onFocusedInputSelectionChanged\")) {\n handler.onSelectionChange?.(event as FocusedInputSelectionChangedEvent);\n }\n },\n [\"onFocusedInputTextChanged\", \"onFocusedInputSelectionChanged\"],\n doDependenciesDiffer,\n );\n\n useLayoutEffect(() => {\n const cleanup = context.setInputHandlers(eventHandler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport * from \"./useWindowDimensions\";\nexport * from \"./useKeyboardState\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AA8RA,IAAAK,oBAAA,GAAAL,OAAA;AAAAM,MAAA,CAAAC,IAAA,CAAAF,oBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,oBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,oBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,iBAAA,GAAAlB,OAAA;AAAAM,MAAA,CAAAC,IAAA,CAAAW,iBAAA,EAAAV,OAAA,WAAAC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ACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CACpC3B,OAA4B,EAC5BC,IAAgB,EAChB;EACA,MAAMP,OAAO,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAEpC,MAAM;IAAEO;EAAqB,CAAC,GAAG,IAAAC,iCAAU,EAAeH,OAAO,EAAEC,IAAI,CAAC;EAExE,MAAMG,YAAY,GAAG,IAAAC,+BAAQ,EAG1BC,KAAK,IAAK;IACT,SAAS;;IAET,IAAIA,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC,2BAA2B,CAAC,EAAE;MAAA,IAAAoB,qBAAA;MACzD,CAAAA,qBAAA,GAAA5B,OAAO,CAAC6B,YAAY,cAAAD,qBAAA,eAApBA,qBAAA,CAAAjD,IAAA,CAAAqB,OAAO,EAAgBM,KAAqC,CAAC;IAC/D;IAEA,IAAIA,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC,gCAAgC,CAAC,EAAE;MAAA,IAAAsB,qBAAA;MAC9D,CAAAA,qBAAA,GAAA9B,OAAO,CAAC+B,iBAAiB,cAAAD,qBAAA,eAAzBA,qBAAA,CAAAnD,IAAA,CAAAqB,OAAO,EAAqBM,KAA0C,CAAC;IACzE;EACF,CAAC,EACD,CAAC,2BAA2B,EAAE,gCAAgC,CAAC,EAC/DJ,oBACF,CAAC;EAED,IAAAe,sBAAe,EAAC,MAAM;IACpB,MAAMC,OAAO,GAAGxB,OAAO,CAACsC,gBAAgB,CAAC5B,YAAY,CAAC;IAEtD,OAAO,MAAMc,OAAO,CAAC,CAAC;EACxB,CAAC,EAAEjB,IAAI,CAAC;AACV","ignoreList":[]}
@@ -7,12 +7,10 @@ exports.useAnimatedValue = useAnimatedValue;
7
7
  exports.useEventHandlerRegistration = useEventHandlerRegistration;
8
8
  var _react = require("react");
9
9
  var _reactNative = require("react-native");
10
- var _eventHandler = require("./event-handler");
11
10
  var _findNodeHandle = require("./utils/findNodeHandle");
12
11
  /**
13
12
  * An internal hook that helps to register workletized event handlers.
14
13
  *
15
- * @param map - Map of event handlers and their names.
16
14
  * @param viewTagRef - Ref to the view that produces events.
17
15
  * @returns A function that registers supplied event handlers.
18
16
  * @example
@@ -23,26 +21,21 @@ var _findNodeHandle = require("./utils/findNodeHandle");
23
21
  * );
24
22
  * ```
25
23
  */
26
- function useEventHandlerRegistration(map, viewTagRef) {
24
+ function useEventHandlerRegistration(viewTagRef) {
27
25
  const onRegisterHandler = handler => {
28
- const ids = [];
26
+ const currentHandler = handler;
29
27
  const attachWorkletHandlers = () => {
30
28
  const viewTag = (0, _findNodeHandle.findNodeHandle)(viewTagRef.current);
31
29
  if (__DEV__ && !viewTag) {
32
30
  console.warn("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.");
33
31
  }
34
- ids.push(...Object.keys(handler).map(handlerName => {
35
- const eventName = map.get(handlerName);
36
- const functionToCall = handler[handlerName];
37
- if (eventName && viewTag) {
38
- return (0, _eventHandler.registerEventHandler)(event => {
39
- "worklet";
40
-
41
- functionToCall === null || functionToCall === void 0 || functionToCall(event);
42
- }, eventName, viewTag);
32
+ if (viewTag) {
33
+ if ("workletEventHandler" in currentHandler) {
34
+ currentHandler.workletEventHandler.registerForEvents(viewTag);
35
+ } else {
36
+ currentHandler.registerForEvents(viewTag);
43
37
  }
44
- return null;
45
- }));
38
+ }
46
39
  };
47
40
  if (viewTagRef.current) {
48
41
  attachWorkletHandlers();
@@ -51,7 +44,14 @@ function useEventHandlerRegistration(map, viewTagRef) {
51
44
  queueMicrotask(attachWorkletHandlers);
52
45
  }
53
46
  return () => {
54
- ids.forEach(id => id ? (0, _eventHandler.unregisterEventHandler)(id) : null);
47
+ const viewTag = (0, _findNodeHandle.findNodeHandle)(viewTagRef.current);
48
+ if (viewTag) {
49
+ if ("workletEventHandler" in currentHandler) {
50
+ currentHandler.workletEventHandler.unregisterFromEvents(viewTag);
51
+ } else {
52
+ currentHandler.unregisterFromEvents(viewTag);
53
+ }
54
+ }
55
55
  };
56
56
  };
57
57
  return onRegisterHandler;