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
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_reactNative","_eventHandler","_findNodeHandle","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","ids","attachWorkletHandlers","viewTag","findNodeHandle","current","__DEV__","console","warn","push","Object","keys","handlerName","eventName","get","functionToCall","registerEventHandler","event","queueMicrotask","forEach","id","unregisterEventHandler","useAnimatedValue","initialValue","config","ref","useRef","Animated","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport { registerEventHandler, unregisterEventHandler } from \"./event-handler\";\nimport { findNodeHandle } from \"./utils/findNodeHandle\";\n\ntype EventHandler = (event: never) => void;\ntype ComponentOrHandle = Parameters<typeof findNodeHandle>[0];\n\n/**\n * An internal hook that helps to register workletized event handlers.\n *\n * @param map - Map of event handlers and their names.\n * @param viewTagRef - Ref to the view that produces events.\n * @returns A function that registers supplied event handlers.\n * @example\n * ```ts\n * const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(\n * keyboardEventsMap,\n * viewTagRef,\n * );\n * ```\n */\nexport function useEventHandlerRegistration<\n H extends Partial<Record<string, EventHandler>>,\n>(\n map: Map<keyof H, string>,\n viewTagRef: React.MutableRefObject<ComponentOrHandle>,\n) {\n const onRegisterHandler = (handler: H) => {\n const ids: (number | null)[] = [];\n const attachWorkletHandlers = () => {\n const viewTag = findNodeHandle(viewTagRef.current);\n\n if (__DEV__ && !viewTag) {\n console.warn(\n \"Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.\",\n );\n }\n\n ids.push(\n ...Object.keys(handler).map((handlerName) => {\n const eventName = map.get(handlerName as keyof H);\n const functionToCall = handler[handlerName as keyof H];\n\n if (eventName && viewTag) {\n return registerEventHandler(\n (event: Parameters<NonNullable<H[keyof H]>>[0]) => {\n \"worklet\";\n\n functionToCall?.(event);\n },\n eventName,\n viewTag,\n );\n }\n\n return null;\n }),\n );\n };\n\n if (viewTagRef.current) {\n attachWorkletHandlers();\n } else {\n // view may not be mounted yet - defer registration until call-stack becomes empty\n queueMicrotask(attachWorkletHandlers);\n }\n\n return () => {\n ids.forEach((id) => (id ? unregisterEventHandler(id) : null));\n };\n };\n\n return onRegisterHandler;\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @param initialValue - Initial value of the animated value (numeric).\n * @param config - Additional {@link Animated.AnimatedConfig|configuration} for the animated value.\n * @returns Properly memoized {@link Animated.Value|Animated} value.\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n * @example\n * ```ts\n * const progress = useAnimatedValue(0);\n * ```\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig,\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current === null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,2BAA2BA,CAGzCC,GAAyB,EACzBC,UAAqD,EACrD;EACA,MAAMC,iBAAiB,GAAIC,OAAU,IAAK;IACxC,MAAMC,GAAsB,GAAG,EAAE;IACjC,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;MAClC,MAAMC,OAAO,GAAG,IAAAC,8BAAc,EAACN,UAAU,CAACO,OAAO,CAAC;MAElD,IAAIC,OAAO,IAAI,CAACH,OAAO,EAAE;QACvBI,OAAO,CAACC,IAAI,CACV,uPACF,CAAC;MACH;MAEAP,GAAG,CAACQ,IAAI,CACN,GAAGC,MAAM,CAACC,IAAI,CAACX,OAAO,CAAC,CAACH,GAAG,CAAEe,WAAW,IAAK;QAC3C,MAAMC,SAAS,GAAGhB,GAAG,CAACiB,GAAG,CAACF,WAAsB,CAAC;QACjD,MAAMG,cAAc,GAAGf,OAAO,CAACY,WAAW,CAAY;QAEtD,IAAIC,SAAS,IAAIV,OAAO,EAAE;UACxB,OAAO,IAAAa,kCAAoB,EACxBC,KAA6C,IAAK;YACjD,SAAS;;YAETF,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAGE,KAAK,CAAC;UACzB,CAAC,EACDJ,SAAS,EACTV,OACF,CAAC;QACH;QAEA,OAAO,IAAI;MACb,CAAC,CACH,CAAC;IACH,CAAC;IAED,IAAIL,UAAU,CAACO,OAAO,EAAE;MACtBH,qBAAqB,CAAC,CAAC;IACzB,CAAC,MAAM;MACL;MACAgB,cAAc,CAAChB,qBAAqB,CAAC;IACvC;IAEA,OAAO,MAAM;MACXD,GAAG,CAACkB,OAAO,CAAEC,EAAE,IAAMA,EAAE,GAAG,IAAAC,oCAAsB,EAACD,EAAE,CAAC,GAAG,IAAK,CAAC;IAC/D,CAAC;EACH,CAAC;EAED,OAAOrB,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASuB,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG,IAAAC,aAAM,EAAwB,IAAI,CAAC;EAE/C,IAAID,GAAG,CAACpB,OAAO,KAAK,IAAI,EAAE;IACxBoB,GAAG,CAACpB,OAAO,GAAG,IAAIsB,qBAAQ,CAACC,KAAK,CAACL,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAACpB,OAAO;AACpB","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_reactNative","_findNodeHandle","useEventHandlerRegistration","viewTagRef","onRegisterHandler","handler","currentHandler","attachWorkletHandlers","viewTag","findNodeHandle","current","__DEV__","console","warn","workletEventHandler","registerForEvents","queueMicrotask","unregisterFromEvents","useAnimatedValue","initialValue","config","ref","useRef","Animated","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport { findNodeHandle } from \"./utils/findNodeHandle\";\n\nimport type { EventHandlerProcessed } from \"react-native-reanimated\";\n\ntype ComponentOrHandle = Parameters<typeof findNodeHandle>[0];\n\ntype WorkletHandler = {\n registerForEvents: (viewTag: number) => void;\n unregisterFromEvents: (viewTag: number) => void;\n};\n\ntype WorkletHandlerOrWorkletHandlerObject =\n | WorkletHandler\n | {\n workletEventHandler: WorkletHandler;\n };\n\n/**\n * An internal hook that helps to register workletized event handlers.\n *\n * @param viewTagRef - Ref to the view that produces events.\n * @returns A function that registers supplied event handlers.\n * @example\n * ```ts\n * const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(\n * keyboardEventsMap,\n * viewTagRef,\n * );\n * ```\n */\nexport function useEventHandlerRegistration(\n viewTagRef: React.MutableRefObject<ComponentOrHandle>,\n) {\n const onRegisterHandler = (handler: EventHandlerProcessed<never, never>) => {\n const currentHandler =\n handler as unknown as WorkletHandlerOrWorkletHandlerObject;\n const attachWorkletHandlers = () => {\n const viewTag = findNodeHandle(viewTagRef.current);\n\n if (__DEV__ && !viewTag) {\n console.warn(\n \"Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.\",\n );\n }\n\n if (viewTag) {\n if (\"workletEventHandler\" in currentHandler) {\n currentHandler.workletEventHandler.registerForEvents(viewTag);\n } else {\n currentHandler.registerForEvents(viewTag);\n }\n }\n };\n\n if (viewTagRef.current) {\n attachWorkletHandlers();\n } else {\n // view may not be mounted yet - defer registration until call-stack becomes empty\n queueMicrotask(attachWorkletHandlers);\n }\n\n return () => {\n const viewTag = findNodeHandle(viewTagRef.current);\n\n if (viewTag) {\n if (\"workletEventHandler\" in currentHandler) {\n currentHandler.workletEventHandler.unregisterFromEvents(viewTag);\n } else {\n currentHandler.unregisterFromEvents(viewTag);\n }\n }\n };\n };\n\n return onRegisterHandler;\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @param initialValue - Initial value of the animated value (numeric).\n * @param config - Additional {@link Animated.AnimatedConfig|configuration} for the animated value.\n * @returns Properly memoized {@link Animated.Value|Animated} value.\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n * @example\n * ```ts\n * const progress = useAnimatedValue(0);\n * ```\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig,\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current === null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,2BAA2BA,CACzCC,UAAqD,EACrD;EACA,MAAMC,iBAAiB,GAAIC,OAA4C,IAAK;IAC1E,MAAMC,cAAc,GAClBD,OAA0D;IAC5D,MAAME,qBAAqB,GAAGA,CAAA,KAAM;MAClC,MAAMC,OAAO,GAAG,IAAAC,8BAAc,EAACN,UAAU,CAACO,OAAO,CAAC;MAElD,IAAIC,OAAO,IAAI,CAACH,OAAO,EAAE;QACvBI,OAAO,CAACC,IAAI,CACV,uPACF,CAAC;MACH;MAEA,IAAIL,OAAO,EAAE;QACX,IAAI,qBAAqB,IAAIF,cAAc,EAAE;UAC3CA,cAAc,CAACQ,mBAAmB,CAACC,iBAAiB,CAACP,OAAO,CAAC;QAC/D,CAAC,MAAM;UACLF,cAAc,CAACS,iBAAiB,CAACP,OAAO,CAAC;QAC3C;MACF;IACF,CAAC;IAED,IAAIL,UAAU,CAACO,OAAO,EAAE;MACtBH,qBAAqB,CAAC,CAAC;IACzB,CAAC,MAAM;MACL;MACAS,cAAc,CAACT,qBAAqB,CAAC;IACvC;IAEA,OAAO,MAAM;MACX,MAAMC,OAAO,GAAG,IAAAC,8BAAc,EAACN,UAAU,CAACO,OAAO,CAAC;MAElD,IAAIF,OAAO,EAAE;QACX,IAAI,qBAAqB,IAAIF,cAAc,EAAE;UAC3CA,cAAc,CAACQ,mBAAmB,CAACG,oBAAoB,CAACT,OAAO,CAAC;QAClE,CAAC,MAAM;UACLF,cAAc,CAACW,oBAAoB,CAACT,OAAO,CAAC;QAC9C;MACF;IACF,CAAC;EACH,CAAC;EAED,OAAOJ,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASc,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG,IAAAC,aAAM,EAAwB,IAAI,CAAC;EAE/C,IAAID,GAAG,CAACX,OAAO,KAAK,IAAI,EAAE;IACxBW,GAAG,CAACX,OAAO,GAAG,IAAIa,qBAAQ,CAACC,KAAK,CAACL,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAACX,OAAO;AACpB","ignoreList":[]}
@@ -5,7 +5,6 @@ import { controlEdgeToEdgeValues, isEdgeToEdge } from "react-native-is-edge-to-e
5
5
  import Reanimated, { useSharedValue } from "react-native-reanimated";
6
6
  import { KeyboardControllerView } from "./bindings";
7
7
  import { KeyboardContext } from "./context";
8
- import { focusedInputEventsMap, keyboardEventsMap } from "./event-mappings";
9
8
  import { useAnimatedValue, useEventHandlerRegistration } from "./internal";
10
9
  import { KeyboardController } from "./module";
11
10
  import { useAnimatedKeyboardHandler, useFocusedInputLayoutHandler } from "./reanimated";
@@ -58,8 +57,8 @@ export const KeyboardProvider = props => {
58
57
  const progressSV = useSharedValue(0);
59
58
  const heightSV = useSharedValue(0);
60
59
  const layout = useSharedValue(null);
61
- const setKeyboardHandlers = useEventHandlerRegistration(keyboardEventsMap, viewTagRef);
62
- const setInputHandlers = useEventHandlerRegistration(focusedInputEventsMap, viewTagRef);
60
+ const setKeyboardHandlers = useEventHandlerRegistration(viewTagRef);
61
+ const setInputHandlers = useEventHandlerRegistration(viewTagRef);
63
62
  // memo
64
63
  const context = useMemo(() => ({
65
64
  enabled,
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useMemo","useRef","useState","Animated","Platform","StyleSheet","controlEdgeToEdgeValues","isEdgeToEdge","Reanimated","useSharedValue","KeyboardControllerView","KeyboardContext","focusedInputEventsMap","keyboardEventsMap","useAnimatedValue","useEventHandlerRegistration","KeyboardController","useAnimatedKeyboardHandler","useFocusedInputLayoutHandler","IS_EDGE_TO_EDGE","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","OS","KeyboardProvider","props","children","statusBarTranslucent","navigationBarTranslucent","preserveEdgeToEdge","enabled","initiallyEnabled","preload","viewTagRef","setEnabled","progress","height","progressSV","heightSV","layout","setKeyboardHandlers","setInputHandlers","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","onKeyboardMoveEnd","inputLayoutHandler","onFocusedInputLayoutChanged","e","target","__DEV__","createElement","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View"],"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":"AAAA;AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnE,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AAC7D,SACEC,uBAAuB,EACvBC,YAAY,QACP,8BAA8B;AACrC,OAAOC,UAAU,IAAIC,cAAc,QAAQ,yBAAyB;AAEpE,SAASC,sBAAsB,QAAQ,YAAY;AACnD,SAASC,eAAe,QAAQ,WAAW;AAC3C,SAASC,qBAAqB,EAAEC,iBAAiB,QAAQ,kBAAkB;AAC3E,SAASC,gBAAgB,EAAEC,2BAA2B,QAAQ,YAAY;AAC1E,SAASC,kBAAkB,QAAQ,UAAU;AAC7C,SACEC,0BAA0B,EAC1BC,4BAA4B,QACvB,cAAc;AAYrB,MAAMC,eAAe,GAAGZ,YAAY,CAAC,CAAC;AAEtC,MAAMa,8BAA8B,GAAGZ,UAAU,CAACa,uBAAuB,CACvElB,QAAQ,CAACkB,uBAAuB,CAACX,sBAAsB,CACzD,CAAC;AAOD,MAAMY,MAAM,GAAGjB,UAAU,CAACkB,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;A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c,GAAGqB,SAAU;IACjEC,qCAAqC,EAAEV;EAAmB,GAEzDpC,QAC6B,CAAC,eACjClC,KAAA,CAAA2E,aAAA,CAACtE,QAAQ,CAAC4E,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA3B,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useEffect","useMemo","useRef","useState","Animated","Platform","StyleSheet","controlEdgeToEdgeValues","isEdgeToEdge","Reanimated","useSharedValue","KeyboardControllerView","KeyboardContext","useAnimatedValue","useEventHandlerRegistration","KeyboardController","useAnimatedKeyboardHandler","useFocusedInputLayoutHandler","IS_EDGE_TO_EDGE","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","OS","KeyboardProvider","props","children","statusBarTranslucent","navigationBarTranslucent","preserveEdgeToEdge","enabled","initiallyEnabled","preload","viewTagRef","setEnabled","progress","height","progressSV","heightSV","layout","setKeyboardHandlers","setInputHandlers","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","onKeyboardMoveEnd","inputLayoutHandler","onFocusedInputLayoutChanged","e","target","__DEV__","createElement","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View"],"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":"AAAA;AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnE,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AAC7D,SACEC,uBAAuB,EACvBC,YAAY,QACP,8BAA8B;AACrC,OAAOC,UAAU,IAAIC,cAAc,QAAQ,yBAAyB;AAEpE,SAASC,sBAAsB,QAAQ,YAAY;AACnD,SAASC,eAAe,QAAQ,WAAW;AAC3C,SAASC,gBAAgB,EAAEC,2BAA2B,QAAQ,YAAY;AAC1E,SAASC,kBAAkB,QAAQ,UAAU;AAC7C,SACEC,0BAA0B,EAC1BC,4BAA4B,QACvB,cAAc;AAUrB,MAAMC,eAAe,GAAGV,YAAY,CAAC,CAAC;AAEtC,MAAMW,8BAA8B,GAAGV,UAAU,CAACW,uBAAuB,CACvEhB,QAAQ,CAACgB,uBAAuB,CAACT,sBAAsB,CACzD,CAAC;AAOD,MAAMU,MAAM,GAAGf,UAAU,CAACgB,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AA8CF;AACA;AACA,MAAMC,EAAE,GAAGvB,QAAQ,CAACuB,EAAE;;AAEtB;AACA;AACA;AACA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CAAC0E,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA3B,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC","ignoreList":[]}
@@ -133,6 +133,16 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
133
133
  }
134
134
  return 0;
135
135
  }, [bottomOffset, enabled, height, snapToOffsets]);
136
+ const performScrollWithPositionRestoration = useCallback(newPosition => {
137
+ "worklet";
138
+
139
+ const prevScroll = scrollPosition.value;
140
+
141
+ // eslint-disable-next-line react-compiler/react-compiler
142
+ scrollPosition.value = newPosition;
143
+ maybeScroll(keyboardHeight.value, true);
144
+ scrollPosition.value = prevScroll;
145
+ }, [scrollPosition, keyboardHeight, maybeScroll]);
136
146
  const syncKeyboardFrame = useCallback(e => {
137
147
  "worklet";
138
148
 
@@ -161,18 +171,13 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
161
171
  const scrollFromCurrentPosition = useCallback(() => {
162
172
  "worklet";
163
173
 
164
- const prevScrollPosition = scrollPosition.value;
165
174
  const prevLayout = layout.value;
166
175
  if (!updateLayoutFromSelection()) {
167
176
  return;
168
177
  }
169
-
170
- // eslint-disable-next-line react-compiler/react-compiler
171
- scrollPosition.value = position.value;
172
- maybeScroll(keyboardHeight.value, true);
173
- scrollPosition.value = prevScrollPosition;
178
+ performScrollWithPositionRestoration(position.value);
174
179
  layout.value = prevLayout;
175
- }, [maybeScroll]);
180
+ }, [performScrollWithPositionRestoration]);
176
181
  const onChangeText = useCallback(() => {
177
182
  "worklet";
178
183
 
@@ -261,7 +266,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
261
266
  }
262
267
  }, [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame]);
263
268
  useEffect(() => {
264
- runOnUI(maybeScroll)(keyboardHeight.value, true);
269
+ runOnUI(performScrollWithPositionRestoration)(scrollBeforeKeyboardMovement.value);
265
270
  }, [bottomOffset]);
266
271
  useAnimatedReaction(() => input.value, (current, previous) => {
267
272
  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","forwardRef","useCallback","useEffect","useMemo","Reanimated","clamp","interpolate","runOnUI","scrollTo","useAnimatedReaction","useAnimatedRef","useAnimatedStyle","useScrollViewOffset","useSharedValue","useFocusedInputHandler","useReanimatedFocusedInput","useWindowDimensions","findNodeHandle","useSmoothKeyboardHandler","debounce","scrollDistanceWithRespectToSnapPoints","KeyboardAwareScrollView","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","ScrollView","snapToOffsets","rest","ref","scrollViewAnimatedRef","scrollViewTarget","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","layout","lastSelection","height","onRef","assignedRef","current","onScrollViewLayout","e","value","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","targetScrollY","Math","max","positionOnScreen","topOfScreen","syncKeyboardFrame","keyboardFrame","updateLayoutFromSelection","_lastSelection$value","_input$value","customHeight","selection","end","y","scrollFromCurrentPosition","prevScrollPosition","prevLayout","onChangeText","onChangeTextHandler","onSelectionChange","_lastSelection$value2","_lastSelection$value3","lastTarget","target","latestSelection","start","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","onMove","onEnd","previous","view","paddingBottom","createElement","_extends","scrollEventThrottle","View","style"],"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,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAC1E,OAAOC,UAAU,IACfC,KAAK,EACLC,WAAW,EACXC,OAAO,EACPC,QAAQ,EACRC,mBAAmB,EACnBC,cAAc,EACdC,gBAAgB,EAChBC,mBAAmB,EACnBC,cAAc,QACT,yBAAyB;AAEhC,SACEC,sBAAsB,EACtBC,yBAAyB,EACzBC,mBAAmB,QACd,aAAa;AACpB,SAASC,cAAc,QAAQ,4BAA4B;AAE3D,SA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MAAM,CAACE,MAAM,OAAKmD,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAErD,MAAM,CAACE,MAAM,GAClD;MACA;MACA;MACA;MACAiC,yBAAyB,CAAC,CAAC;IAC7B;EACF,CAAC,EACD,EACF,CAAC;EAED,MAAMmB,IAAI,GAAGvF,gBAAgB,CAC3B,MACEe,OAAO,GACH;IACE;IACA;IACA;IACA;IACA;IACA;IACAyE,aAAa,EAAE9D,0BAA0B,CAACe,KAAK,GAAG;EACpD,CAAC,GACD,CAAC,CAAC,EACR,CAAC1B,OAAO,CACV,CAAC;EAED,oBACE3B,KAAA,CAAAqG,aAAA,CAACxE,mBAAmB,EAAAyE,QAAA;IAClBrE,GAAG,EAAEe;EAAM,GACPhB,IAAI;IACRuE,mBAAmB,EAAE,EAAG;IACxB/E,QAAQ,EAAE2B;EAAmB,IAE5B5B,QAAQ,EACRI,OAAO,iBAAI3B,KAAA,CAAAqG,aAAA,CAAChG,UAAU,CAACmG,IAAI;IAACC,KAAK,EAAEN;EAAK,CAAE,CACxB,CAAC;AAE1B,CACF,CAAC;AAED,eAAe7E,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["React","forwardRef","useCallback","useEffect","useMemo","Reanimated","clamp","interpolate","runOnUI","scrollTo","useAnimatedReaction","useAnimatedRef","useAnimatedStyle","useScrollViewOffset","useSharedValue","useFocusedInputHandler","useReanimatedFocusedInput","useWindowDimensions","findNodeHandle","useSmoothKeyboardHandler","debounce","scrollDistanceWithRespectToSnapPoints","KeyboardAwareScrollView","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","ScrollView","snapToOffsets","rest","ref","scrollViewAnimatedRef","scrollViewTarget","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","layout","lastSelection","height","onRef","assignedRef","current","onScrollViewLayout","e","value","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","targetScrollY","Math","max","positionOnScreen","topOfScreen","performScrollWithPositionRestoration","newPosition","prevScroll","syncKeyboardFrame","keyboardFrame","updateLayoutFromSelection","_lastSelection$value","_input$value","customHeight","selection","end","y","scrollFromCurrentPosition","prevLayout","onChangeText","onChangeTextHandler","onSelectionChange","_lastSelection$value2","_lastSelection$value3","lastTarget","target","latestSelection","start","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","onMove","onEnd","previous","view","paddingBottom","createElement","_extends","scrollEventThrottle","View","style"],"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,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAC1E,OAAOC,UAAU,IACfC,KAAK,EACLC,WAAW,EACXC,OAAO,EACPC,QAAQ,EACRC,mBAAmB,EACnBC,cAAc,EACdC,gBAAgB,EAChBC,mBAAmB,EACnBC,cAAc,QACT,yBAAyB;AAEhC,SACEC,sBAAsB,EACtBC,yBAAyB,EACzBC,mBAAmB,QACd,aAAa;AACpB,SAASC,cAAc,QAAQ,4BAA4B;AAE3D,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,QAAQ,EAAEC,qCAAqC,QAAQ,SAAS;AA0BzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,uBAAuB,gBAAGrB,UAAU,CAIxC,CACE;EACEsB,QAAQ;EACRC,QAAQ;EACRC,YAAY,GAAG,CAAC;EAChBC,2BAA2B,GAAG,KAAK;EACnCC,OAAO,GAAG,IAAI;EACdC,kBAAkB,GAAG,CAAC;EACtBC,mBAAmB,GAAGxB,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ED,oBACE3B,KAAA,CAAAuG,aAAA,CAAC1E,mBAAmB,EAAA2E,QAAA;IAClBvE,GAAG,EAAEe;EAAM,GACPhB,IAAI;IACRyE,mBAAmB,EAAE,EAAG;IACxBjF,QAAQ,EAAE2B;EAAmB,IAE5B5B,QAAQ,EACRI,OAAO,iBAAI3B,KAAA,CAAAuG,aAAA,CAAClG,UAAU,CAACqG,IAAI;IAACC,KAAK,EAAEN;EAAK,CAAE,CACxB,CAAC;AAE1B,CACF,CAAC;AAED,eAAe/E,uBAAuB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["createContext","useContext","Animated","NOOP","NESTED_NOOP","withSharedValue","value","addListener","removeListener","modify","get","set","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Value","height","reanimated","layout","setKeyboardHandlers","setInputHandlers","setEnabled","KeyboardContext","useKeyboardContext","context","__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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AOH,OAAO;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createContext","useContext","Animated","NOOP","NESTED_NOOP","withSharedValue","value","addListener","removeListener","modify","get","set","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Value","height","reanimated","layout","setKeyboardHandlers","setInputHandlers","setEnabled","KeyboardContext","useKeyboardContext","context","__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,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AACjD,SAASC,QAAQ,QAAQ,cAAc;AA+CvC,MAAMC,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,IAAIf,QAAQ,CAACgB,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIjB,QAAQ,CAACgB,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVH,QAAQ,EAAEL,oBAAoB;IAC9BO,MAAM,EAAEP;EACV,CAAC;EACDS,MAAM,EAAER,cAAc;EACtBS,mBAAmB,EAAElB,WAAW;EAChCmB,gBAAgB,EAAEnB,WAAW;EAC7BoB,UAAU,EAAErB;AACd,CAAC;AAED,OAAO,MAAMsB,eAAe,gBAAGzB,aAAa,CAACc,cAAc,CAAC;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMY,kBAAkB,GAAGA,CAAA,KAAM;EACtC,MAAMC,OAAO,GAAG1B,UAAU,CAACwB,eAAe,CAAC;EAE3C,IAAIG,OAAO,IAAID,OAAO,KAAKb,cAAc,EAAE;IACzCe,OAAO,CAACC,IAAI,CACV,sLACF,CAAC;EACH;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useLayoutEffect } from "react";
2
+ import { useEvent, useHandler } from "react-native-reanimated";
2
3
  import { AndroidSoftInputModes } from "../constants";
3
4
  import { useKeyboardContext } from "../context";
4
5
  import { KeyboardController } from "../module";
@@ -96,8 +97,31 @@ export const useReanimatedKeyboardAnimation = () => {
96
97
  */
97
98
  export function useGenericKeyboardHandler(handler, deps) {
98
99
  const context = useKeyboardContext();
100
+ const {
101
+ doDependenciesDiffer
102
+ } = useHandler(handler, deps);
103
+ const eventHandler = useEvent(event => {
104
+ "worklet";
105
+
106
+ if (event.eventName.endsWith("onKeyboardMoveStart")) {
107
+ var _handler$onStart;
108
+ (_handler$onStart = handler.onStart) === null || _handler$onStart === void 0 || _handler$onStart.call(handler, event);
109
+ }
110
+ if (event.eventName.endsWith("onKeyboardMove")) {
111
+ var _handler$onMove;
112
+ (_handler$onMove = handler.onMove) === null || _handler$onMove === void 0 || _handler$onMove.call(handler, event);
113
+ }
114
+ if (event.eventName.endsWith("onKeyboardMoveEnd")) {
115
+ var _handler$onEnd;
116
+ (_handler$onEnd = handler.onEnd) === null || _handler$onEnd === void 0 || _handler$onEnd.call(handler, event);
117
+ }
118
+ if (event.eventName.endsWith("onKeyboardMoveInteractive")) {
119
+ var _handler$onInteractiv;
120
+ (_handler$onInteractiv = handler.onInteractive) === null || _handler$onInteractiv === void 0 || _handler$onInteractiv.call(handler, event);
121
+ }
122
+ }, ["onKeyboardMoveStart", "onKeyboardMove", "onKeyboardMoveEnd", "onKeyboardMoveInteractive"], doDependenciesDiffer);
99
123
  useLayoutEffect(() => {
100
- const cleanup = context.setKeyboardHandlers(handler);
124
+ const cleanup = context.setKeyboardHandlers(eventHandler);
101
125
  return () => cleanup();
102
126
  }, deps);
103
127
  }
@@ -208,8 +232,23 @@ export function useReanimatedFocusedInput() {
208
232
  */
209
233
  export function useFocusedInputHandler(handler, deps) {
210
234
  const context = useKeyboardContext();
235
+ const {
236
+ doDependenciesDiffer
237
+ } = useHandler(handler, deps);
238
+ const eventHandler = useEvent(event => {
239
+ "worklet";
240
+
241
+ if (event.eventName.endsWith("onFocusedInputTextChanged")) {
242
+ var _handler$onChangeText;
243
+ (_handler$onChangeText = handler.onChangeText) === null || _handler$onChangeText === void 0 || _handler$onChangeText.call(handler, event);
244
+ }
245
+ if (event.eventName.endsWith("onFocusedInputSelectionChanged")) {
246
+ var _handler$onSelectionC;
247
+ (_handler$onSelectionC = handler.onSelectionChange) === null || _handler$onSelectionC === void 0 || _handler$onSelectionC.call(handler, event);
248
+ }
249
+ }, ["onFocusedInputTextChanged", "onFocusedInputSelectionChanged"], doDependenciesDiffer);
211
250
  useLayoutEffect(() => {
212
- const cleanup = context.setInputHandlers(handler);
251
+ const cleanup = context.setInputHandlers(eventHandler);
213
252
  return () => cleanup();
214
253
  }, deps);
215
254
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useLayoutEffect","AndroidSoftInputModes","useKeyboardContext","KeyboardController","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","cleanup","setKeyboardHandlers","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","setInputHandlers"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from \"react\";\n\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\nimport { KeyboardController } from \"../module\";\n\nimport type { AnimatedContext, ReanimatedContext } from \"../context\";\nimport type { FocusedInputHandler, KeyboardHandler } from \"../types\";\nimport type { DependencyList } from \"react\";\n\n/**\n * Hook that sets the Android soft input mode to adjust resize on mount and\n * restores default mode on unmount. This ensures the keyboard behavior is consistent\n * on all Android versions.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * useResizeMode();\n * return <View />;\n * }\n * ```\n */\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE,\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\n/**\n * Hook that provides animated (`height`/`progress`) values for tracking keyboard movement.\n * Automatically sets the resize mode for Android.\n *\n * @returns Object {@link AnimatedContext|containing} animated values for keyboard movement.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-animation|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { height, progress } = useKeyboardAnimation();\n * return <Animated.View style={{ transform: [{ translateY: height }] }} />;\n * }\n * ```\n */\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.animated;\n};\n\n/**\n * Hook that provides reanimated (`height`/`progress`) values for tracking keyboard movement.\n * Automatically sets the resize mode for Android.\n *\n * @returns Object {@link ReanimatedContext|containing} reanimated values for keyboard movement.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-reanimated-keyboard-animation|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { height, progress } = useReanimatedKeyboardAnimation();\n * return <Reanimated.View style={{ transform: [{ translateY: height }] }} />;\n * }\n * ```\n */\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.reanimated;\n};\n\n/**\n * An alternative to {@link useKeyboardHandler} that doesn't set resize mode on mount. If your\n * app already uses `adjustResize`, then you can use this hook instead of `useKeyboardHandler`.\n *\n * @param handler - Object containing keyboard event handlers.\n * @param [deps] - Dependencies array for the effect.\n * @example\n * ```tsx\n * function MyComponent() {\n * const height = useSharedValue(0);\n * const progress = useSharedValue(0);\n *\n * useGenericKeyboardHandler({\n * onMove: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * onEnd: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * }, []);\n *\n * return <Reanimated.View style={{ height: height }] }} />;\n * }\n * ```\n */\nexport function useGenericKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useLayoutEffect(() => {\n const cleanup = context.setKeyboardHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\n/**\n * Hook that gives an access to each aspect of keyboard movement with workletized `onStart`/`onMove`/`onInteractive`/`onEnd` handlers.\n *\n * @param handler - Object containing keyboard event handlers.\n * @param [deps] - Dependencies array for the effect.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-handler|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const height = useSharedValue(0);\n * const progress = useSharedValue(0);\n *\n * useKeyboardHandler({\n * onMove: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * onEnd: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * }, []);\n *\n * return <Reanimated.View style={{ height: height }] }} />;\n * }\n * ```\n */\nexport function useKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n useResizeMode();\n useGenericKeyboardHandler(handler, deps);\n}\n\n/**\n * Hook for controlling keyboard controller module.\n * Allows to disable/enable it and check the actual state (whether it's enabled or not).\n * When disabled it fallbacks to default android keyboard handling and stops tracking all\n * the events that are exposed from this library.\n *\n * @property {Function} setEnabled - Function to enable/disable keyboard handling.\n * @property {boolean} enabled - Current enabled state.\n * @returns Object containing keyboard control functions and state.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/module/use-keyboard-controller|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { setEnabled, enabled } = useKeyboardController();\n * return (\n * <Button\n * title={enabled ? 'Disable' : 'Enable'}\n * onPress={() => setEnabled(!enabled)}\n * />\n * );\n * }\n * ```\n */\nexport function useKeyboardController() {\n const context = useKeyboardContext();\n\n return { setEnabled: context.setEnabled, enabled: context.enabled };\n}\n\n/**\n * Hook that provides access to the layout of the currently focused input.\n *\n * @returns Object containing reanimated values for focused input.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/input/use-reanimated-focused-input|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { input } = useReanimatedFocusedInput();\n * return <Reanimated.View style={{ height: input.value?.layout.height }} />;\n * }\n * ```\n */\nexport function useReanimatedFocusedInput() {\n const context = useKeyboardContext();\n\n return { input: context.layout };\n}\n\n/**\n * Hook for handling focused input events, such as changes of selection, text etc.\n *\n * @param handler - Object containing focused input event handlers.\n * @param [deps] - Dependencies array for the effect.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/input/use-focused-input-handler|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * useFocusedInputHandler({\n * onChangeText: (e) => console.log('Text changed:', e.text),\n * onSelectionChange: (e) => console.log('Selection changed:', e.selection)\n * });\n * return <View />;\n * }\n * ```\n */\nexport function useFocusedInputHandler(\n handler: FocusedInputHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useLayoutEffect(() => {\n const cleanup = context.setInputHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport * from \"./useWindowDimensions\";\nexport * from \"./useKeyboardState\";\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO;AAElD,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,kBAAkB,QAAQ,WAAW;AAM9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjCL,SAAS,CAAC,MAAM;IACdI,kBAAkB,CAACE,YAAY,CAC7BJ,qBAAqB,CAACK,wBACxB,CAAC;IAED,OAAO,MAAMH,kBAAkB,CAACI,cAAc,CAAC,CAAC;EAClD,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAuB;EACzDJ,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACC,QAAQ;AACzB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,8BAA8B,GAAGA,CAAA,KAAyB;EACrEP,aAAa,CAAC,CAAC;EACf,MAAMK,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAOO,OAAO,CAACG,UAAU;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACvCC,OAAwB,EACxBC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCF,eAAe,CAAC,MAAM;IACpB,MAAMgB,OAAO,GAAGP,OAAO,CAACQ,mBAAmB,CAACH,OAAO,CAAC;IAEpD,OAAO,MAAME,OAAO,CAAC,CAAC;EACxB,CAAC,EAAED,IAAI,CAAC;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,kBAAkBA,CAChCJ,OAAwB,EACxBC,IAAqB,EACrB;EACAX,aAAa,CAAC,CAAC;EACfS,yBAAyB,CAACC,OAAO,EAAEC,IAAI,CAAC;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,qBAAqBA,CAAA,EAAG;EACtC,MAAMV,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEkB,UAAU,EAAEX,OAAO,CAACW,UAAU;IAAEC,OAAO,EAAEZ,OAAO,CAACY;EAAQ,CAAC;AACrE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAA,EAAG;EAC1C,MAAMb,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpC,OAAO;IAAEqB,KAAK,EAAEd,OAAO,CAACe;EAAO,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCX,OAA4B,EAC5BC,IAAqB,EACrB;EACA,MAAMN,OAAO,GAAGP,kBAAkB,CAAC,CAAC;EAEpCF,eAAe,CAAC,MAAM;IACpB,MAAMgB,OAAO,GAAGP,OAAO,CAACiB,gBAAgB,CAACZ,OAAO,CAAC;IAEjD,OAAO,MAAME,OAAO,CAAC,CAAC;EACxB,CAAC,EAAED,IAAI,CAAC;AACV;AAEA,cAAc,uBAAuB;AACrC,cAAc,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","useLayoutEffect","useEvent","useHandler","AndroidSoftInputModes","useKeyboardContext","KeyboardController","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","doDependenciesDiffer","eventHandler","event","eventName","endsWith","_handler$onStart","onStart","call","_handler$onMove","onMove","_handler$onEnd","onEnd","_handler$onInteractiv","onInteractive","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,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO;AAClD,SAASC,QAAQ,EAAEC,UAAU,QAAQ,yBAAyB;AAE9D,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,k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C,CAAC;IAC/D;IAEA,IAAIA,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC,gCAAgC,CAAC,EAAE;MAAA,IAAAsB,qBAAA;MAC9D,CAAAA,qBAAA,GAAA5B,OAAO,CAAC6B,iBAAiB,cAAAD,qBAAA,eAAzBA,qBAAA,CAAAnB,IAAA,CAAAT,OAAO,EAAqBI,KAA0C,CAAC;IACzE;EACF,CAAC,EACD,CAAC,2BAA2B,EAAE,gCAAgC,CAAC,EAC/DF,oBACF,CAAC;EAEDlB,eAAe,CAAC,MAAM;IACpB,MAAMgC,OAAO,GAAGrB,OAAO,CAACmC,gBAAgB,CAAC3B,YAAY,CAAC;IAEtD,OAAO,MAAMa,OAAO,CAAC,CAAC;EACxB,CAAC,EAAEf,IAAI,CAAC;AACV;AAEA,cAAc,uBAAuB;AACrC,cAAc,oBAAoB","ignoreList":[]}
@@ -1,11 +1,9 @@
1
1
  import { useRef } from "react";
2
2
  import { Animated } from "react-native";
3
- import { registerEventHandler, unregisterEventHandler } from "./event-handler";
4
3
  import { findNodeHandle } from "./utils/findNodeHandle";
5
4
  /**
6
5
  * An internal hook that helps to register workletized event handlers.
7
6
  *
8
- * @param map - Map of event handlers and their names.
9
7
  * @param viewTagRef - Ref to the view that produces events.
10
8
  * @returns A function that registers supplied event handlers.
11
9
  * @example
@@ -16,26 +14,21 @@ import { findNodeHandle } from "./utils/findNodeHandle";
16
14
  * );
17
15
  * ```
18
16
  */
19
- export function useEventHandlerRegistration(map, viewTagRef) {
17
+ export function useEventHandlerRegistration(viewTagRef) {
20
18
  const onRegisterHandler = handler => {
21
- const ids = [];
19
+ const currentHandler = handler;
22
20
  const attachWorkletHandlers = () => {
23
21
  const viewTag = findNodeHandle(viewTagRef.current);
24
22
  if (__DEV__ && !viewTag) {
25
23
  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.");
26
24
  }
27
- ids.push(...Object.keys(handler).map(handlerName => {
28
- const eventName = map.get(handlerName);
29
- const functionToCall = handler[handlerName];
30
- if (eventName && viewTag) {
31
- return registerEventHandler(event => {
32
- "worklet";
33
-
34
- functionToCall === null || functionToCall === void 0 || functionToCall(event);
35
- }, eventName, viewTag);
25
+ if (viewTag) {
26
+ if ("workletEventHandler" in currentHandler) {
27
+ currentHandler.workletEventHandler.registerForEvents(viewTag);
28
+ } else {
29
+ currentHandler.registerForEvents(viewTag);
36
30
  }
37
- return null;
38
- }));
31
+ }
39
32
  };
40
33
  if (viewTagRef.current) {
41
34
  attachWorkletHandlers();
@@ -44,7 +37,14 @@ export function useEventHandlerRegistration(map, viewTagRef) {
44
37
  queueMicrotask(attachWorkletHandlers);
45
38
  }
46
39
  return () => {
47
- ids.forEach(id => id ? unregisterEventHandler(id) : null);
40
+ const viewTag = findNodeHandle(viewTagRef.current);
41
+ if (viewTag) {
42
+ if ("workletEventHandler" in currentHandler) {
43
+ currentHandler.workletEventHandler.unregisterFromEvents(viewTag);
44
+ } else {
45
+ currentHandler.unregisterFromEvents(viewTag);
46
+ }
47
+ }
48
48
  };
49
49
  };
50
50
  return onRegisterHandler;
@@ -1 +1 @@
1
- {"version":3,"names":["useRef","Animated","registerEventHandler","unregisterEventHandler","findNodeHandle","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","ids","attachWorkletHandlers","viewTag","current","__DEV__","console","warn","push","Object","keys","handlerName","eventName","get","functionToCall","event","queueMicrotask","forEach","id","useAnimatedValue","initialValue","config","ref","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport { registerEventHandler, unregisterEventHandler } from \"./event-handler\";\nimport { findNodeHandle } from \"./utils/findNodeHandle\";\n\ntype EventHandler = (event: never) => void;\ntype ComponentOrHandle = Parameters<typeof findNodeHandle>[0];\n\n/**\n * An internal hook that helps to register workletized event handlers.\n *\n * @param map - Map of event handlers and their names.\n * @param viewTagRef - Ref to the view that produces events.\n * @returns A function that registers supplied event handlers.\n * @example\n * ```ts\n * const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(\n * keyboardEventsMap,\n * viewTagRef,\n * );\n * ```\n */\nexport function useEventHandlerRegistration<\n H extends Partial<Record<string, EventHandler>>,\n>(\n map: Map<keyof H, string>,\n viewTagRef: React.MutableRefObject<ComponentOrHandle>,\n) {\n const onRegisterHandler = (handler: H) => {\n const ids: (number | null)[] = [];\n const attachWorkletHandlers = () => {\n const viewTag = findNodeHandle(viewTagRef.current);\n\n if (__DEV__ && !viewTag) {\n console.warn(\n \"Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.\",\n );\n }\n\n ids.push(\n ...Object.keys(handler).map((handlerName) => {\n const eventName = map.get(handlerName as keyof H);\n const functionToCall = handler[handlerName as keyof H];\n\n if (eventName && viewTag) {\n return registerEventHandler(\n (event: Parameters<NonNullable<H[keyof H]>>[0]) => {\n \"worklet\";\n\n functionToCall?.(event);\n },\n eventName,\n viewTag,\n );\n }\n\n return null;\n }),\n );\n };\n\n if (viewTagRef.current) {\n attachWorkletHandlers();\n } else {\n // view may not be mounted yet - defer registration until call-stack becomes empty\n queueMicrotask(attachWorkletHandlers);\n }\n\n return () => {\n ids.forEach((id) => (id ? unregisterEventHandler(id) : null));\n };\n };\n\n return onRegisterHandler;\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @param initialValue - Initial value of the animated value (numeric).\n * @param config - Additional {@link Animated.AnimatedConfig|configuration} for the animated value.\n * @returns Properly memoized {@link Animated.Value|Animated} value.\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n * @example\n * ```ts\n * const progress = useAnimatedValue(0);\n * ```\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig,\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current === null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,oBAAoB,EAAEC,sBAAsB,QAAQ,iBAAiB;AAC9E,SAASC,cAAc,QAAQ,wBAAwB;AAKvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,2BAA2BA,CAGzCC,GAAyB,EACzBC,UAAqD,EACrD;EACA,MAAMC,iBAAiB,GAAIC,OAAU,IAAK;IACxC,MAAMC,GAAsB,GAAG,EAAE;IACjC,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;MAClC,MAAMC,OAAO,GAAGR,cAAc,CAACG,UAAU,CAACM,OAAO,CAAC;MAElD,IAAIC,OAAO,IAAI,CAACF,OAAO,EAAE;QACvBG,OAAO,CAACC,IAAI,CACV,uPACF,CAAC;MACH;MAEAN,GAAG,CAACO,IAAI,CACN,GAAGC,MAAM,CAACC,IAAI,CAACV,OAAO,CAAC,CAACH,GAAG,CAAEc,WAAW,IAAK;QAC3C,MAAMC,SAAS,GAAGf,GAAG,CAACgB,GAAG,CAACF,WAAsB,CAAC;QACjD,MAAMG,cAAc,GAAGd,OAAO,CAACW,WAAW,CAAY;QAEtD,IAAIC,SAAS,IAAIT,OAAO,EAAE;UACxB,OAAOV,oBAAoB,CACxBsB,KAA6C,IAAK;YACjD,SAAS;;YAETD,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAGC,KAAK,CAAC;UACzB,CAAC,EACDH,SAAS,EACTT,OACF,CAAC;QACH;QAEA,OAAO,IAAI;MACb,CAAC,CACH,CAAC;IACH,CAAC;IAED,IAAIL,UAAU,CAACM,OAAO,EAAE;MACtBF,qBAAqB,CAAC,CAAC;IACzB,CAAC,MAAM;MACL;MACAc,cAAc,CAACd,qBAAqB,CAAC;IACvC;IAEA,OAAO,MAAM;MACXD,GAAG,CAACgB,OAAO,CAAEC,EAAE,IAAMA,EAAE,GAAGxB,sBAAsB,CAACwB,EAAE,CAAC,GAAG,IAAK,CAAC;IAC/D,CAAC;EACH,CAAC;EAED,OAAOnB,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASoB,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG/B,MAAM,CAAwB,IAAI,CAAC;EAE/C,IAAI+B,GAAG,CAAClB,OAAO,KAAK,IAAI,EAAE;IACxBkB,GAAG,CAAClB,OAAO,GAAG,IAAIZ,QAAQ,CAAC+B,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAAClB,OAAO;AACpB","ignoreList":[]}
1
+ {"version":3,"names":["useRef","Animated","findNodeHandle","useEventHandlerRegistration","viewTagRef","onRegisterHandler","handler","currentHandler","attachWorkletHandlers","viewTag","current","__DEV__","console","warn","workletEventHandler","registerForEvents","queueMicrotask","unregisterFromEvents","useAnimatedValue","initialValue","config","ref","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport { findNodeHandle } from \"./utils/findNodeHandle\";\n\nimport type { EventHandlerProcessed } from \"react-native-reanimated\";\n\ntype ComponentOrHandle = Parameters<typeof findNodeHandle>[0];\n\ntype WorkletHandler = {\n registerForEvents: (viewTag: number) => void;\n unregisterFromEvents: (viewTag: number) => void;\n};\n\ntype WorkletHandlerOrWorkletHandlerObject =\n | WorkletHandler\n | {\n workletEventHandler: WorkletHandler;\n };\n\n/**\n * An internal hook that helps to register workletized event handlers.\n *\n * @param viewTagRef - Ref to the view that produces events.\n * @returns A function that registers supplied event handlers.\n * @example\n * ```ts\n * const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(\n * keyboardEventsMap,\n * viewTagRef,\n * );\n * ```\n */\nexport function useEventHandlerRegistration(\n viewTagRef: React.MutableRefObject<ComponentOrHandle>,\n) {\n const onRegisterHandler = (handler: EventHandlerProcessed<never, never>) => {\n const currentHandler =\n handler as unknown as WorkletHandlerOrWorkletHandlerObject;\n const attachWorkletHandlers = () => {\n const viewTag = findNodeHandle(viewTagRef.current);\n\n if (__DEV__ && !viewTag) {\n console.warn(\n \"Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.\",\n );\n }\n\n if (viewTag) {\n if (\"workletEventHandler\" in currentHandler) {\n currentHandler.workletEventHandler.registerForEvents(viewTag);\n } else {\n currentHandler.registerForEvents(viewTag);\n }\n }\n };\n\n if (viewTagRef.current) {\n attachWorkletHandlers();\n } else {\n // view may not be mounted yet - defer registration until call-stack becomes empty\n queueMicrotask(attachWorkletHandlers);\n }\n\n return () => {\n const viewTag = findNodeHandle(viewTagRef.current);\n\n if (viewTag) {\n if (\"workletEventHandler\" in currentHandler) {\n currentHandler.workletEventHandler.unregisterFromEvents(viewTag);\n } else {\n currentHandler.unregisterFromEvents(viewTag);\n }\n }\n };\n };\n\n return onRegisterHandler;\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @param initialValue - Initial value of the animated value (numeric).\n * @param config - Additional {@link Animated.AnimatedConfig|configuration} for the animated value.\n * @returns Properly memoized {@link Animated.Value|Animated} value.\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n * @example\n * ```ts\n * const progress = useAnimatedValue(0);\n * ```\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig,\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current === null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,cAAc,QAAQ,wBAAwB;AAiBvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,2BAA2BA,CACzCC,UAAqD,EACrD;EACA,MAAMC,iBAAiB,GAAIC,OAA4C,IAAK;IAC1E,MAAMC,cAAc,GAClBD,OAA0D;IAC5D,MAAME,qBAAqB,GAAGA,CAAA,KAAM;MAClC,MAAMC,OAAO,GAAGP,cAAc,CAACE,UAAU,CAACM,OAAO,CAAC;MAElD,IAAIC,OAAO,IAAI,CAACF,OAAO,EAAE;QACvBG,OAAO,CAACC,IAAI,CACV,uPACF,CAAC;MACH;MAEA,IAAIJ,OAAO,EAAE;QACX,IAAI,qBAAqB,IAAIF,cAAc,EAAE;UAC3CA,cAAc,CAACO,mBAAmB,CAACC,iBAAiB,CAACN,OAAO,CAAC;QAC/D,CAAC,MAAM;UACLF,cAAc,CAACQ,iBAAiB,CAACN,OAAO,CAAC;QAC3C;MACF;IACF,CAAC;IAED,IAAIL,UAAU,CAACM,OAAO,EAAE;MACtBF,qBAAqB,CAAC,CAAC;IACzB,CAAC,MAAM;MACL;MACAQ,cAAc,CAACR,qBAAqB,CAAC;IACvC;IAEA,OAAO,MAAM;MACX,MAAMC,OAAO,GAAGP,cAAc,CAACE,UAAU,CAACM,OAAO,CAAC;MAElD,IAAID,OAAO,EAAE;QACX,IAAI,qBAAqB,IAAIF,cAAc,EAAE;UAC3CA,cAAc,CAACO,mBAAmB,CAACG,oBAAoB,CAACR,OAAO,CAAC;QAClE,CAAC,MAAM;UACLF,cAAc,CAACU,oBAAoB,CAACR,OAAO,CAAC;QAC9C;MACF;IACF,CAAC;EACH,CAAC;EAED,OAAOJ,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASa,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAGrB,MAAM,CAAwB,IAAI,CAAC;EAE/C,IAAIqB,GAAG,CAACX,OAAO,KAAK,IAAI,EAAE;IACxBW,GAAG,CAACX,OAAO,GAAG,IAAIT,QAAQ,CAACqB,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAACX,OAAO;AACpB","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import { Animated } from "react-native";
2
- import type { FocusedInputHandler, FocusedInputLayoutChangedEvent, KeyboardHandler } from "./types";
2
+ import type { FocusedInputLayoutChangedEvent } from "./types";
3
3
  import type React from "react";
4
- import type { SharedValue } from "react-native-reanimated";
4
+ import type { EventHandlerProcessed, SharedValue } from "react-native-reanimated";
5
5
  export type AnimatedContext = {
6
6
  /**
7
7
  * A value between `0` and `1` indicating keyboard position, where `0` means keyboard is closed and `1` means keyboard is fully visible.
@@ -30,9 +30,9 @@ export type KeyboardAnimationContext = {
30
30
  /** Layout of the focused `TextInput` represented as `SharedValue`. */
31
31
  layout: SharedValue<FocusedInputLayoutChangedEvent | null>;
32
32
  /** Method for setting workletized keyboard handlers. */
33
- setKeyboardHandlers: (handlers: KeyboardHandler) => () => void;
33
+ setKeyboardHandlers: (handlers: EventHandlerProcessed<never, never>) => () => void;
34
34
  /** Method for setting workletized handlers for tracking focused input events. */
35
- setInputHandlers: (handlers: FocusedInputHandler) => () => void;
35
+ setInputHandlers: (handlers: EventHandlerProcessed<never, never>) => () => void;
36
36
  /** Method to enable/disable KeyboardController library. */
37
37
  setEnabled: React.Dispatch<React.SetStateAction<boolean>>;
38
38
  };