react-native-keyboard-controller 1.20.0-beta.0 → 1.20.1

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 (91) hide show
  1. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +18 -0
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +1 -1
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +7 -0
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +2 -2
  5. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +16 -0
  6. package/ios/KeyboardControllerModule.mm +1 -0
  7. package/ios/observers/FocusedInputObserver.swift +1 -1
  8. package/ios/views/KeyboardControllerView.mm +11 -0
  9. package/ios/views/KeyboardControllerViewManager.mm +3 -0
  10. package/ios/views/KeyboardControllerViewManager.swift +13 -1
  11. package/lib/commonjs/animated.js +14 -4
  12. package/lib/commonjs/animated.js.map +1 -1
  13. package/lib/commonjs/bindings.js +4 -1
  14. package/lib/commonjs/bindings.js.map +1 -1
  15. package/lib/commonjs/bindings.native.js +4 -2
  16. package/lib/commonjs/bindings.native.js.map +1 -1
  17. package/lib/commonjs/compat.js +65 -0
  18. package/lib/commonjs/compat.js.map +1 -0
  19. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +25 -7
  20. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  21. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
  22. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  23. package/lib/commonjs/components/index.js.map +1 -1
  24. package/lib/commonjs/context.js +1 -0
  25. package/lib/commonjs/context.js.map +1 -1
  26. package/lib/commonjs/hooks/index.js +2 -1
  27. package/lib/commonjs/hooks/index.js.map +1 -1
  28. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
  29. package/lib/commonjs/index.js +12 -0
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +5 -1
  32. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  33. package/lib/commonjs/types/internal.js.map +1 -1
  34. package/lib/commonjs/types/module.js.map +1 -1
  35. package/lib/module/animated.js +16 -6
  36. package/lib/module/animated.js.map +1 -1
  37. package/lib/module/bindings.js +3 -0
  38. package/lib/module/bindings.js.map +1 -1
  39. package/lib/module/bindings.native.js +3 -1
  40. package/lib/module/bindings.native.js.map +1 -1
  41. package/lib/module/compat.js +58 -0
  42. package/lib/module/compat.js.map +1 -0
  43. package/lib/module/components/KeyboardAwareScrollView/index.js +26 -8
  44. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  45. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +2 -2
  46. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  47. package/lib/module/components/index.js.map +1 -1
  48. package/lib/module/context.js +1 -0
  49. package/lib/module/context.js.map +1 -1
  50. package/lib/module/hooks/index.js +2 -1
  51. package/lib/module/hooks/index.js.map +1 -1
  52. package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
  53. package/lib/module/index.js +1 -0
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +4 -0
  56. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  57. package/lib/module/types/internal.js.map +1 -1
  58. package/lib/module/types/module.js.map +1 -1
  59. package/lib/typescript/bindings.d.ts +3 -0
  60. package/lib/typescript/bindings.native.d.ts +1 -0
  61. package/lib/typescript/compat.d.ts +27 -0
  62. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +4 -1
  63. package/lib/typescript/components/index.d.ts +1 -1
  64. package/lib/typescript/context.d.ts +2 -0
  65. package/lib/typescript/hooks/index.d.ts +1 -0
  66. package/lib/typescript/hooks/useKeyboardState/index.d.ts +3 -3
  67. package/lib/typescript/index.d.ts +2 -1
  68. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
  69. package/lib/typescript/types/internal.d.ts +1 -1
  70. package/lib/typescript/types/module.d.ts +3 -2
  71. package/package.json +1 -1
  72. package/src/animated.tsx +32 -6
  73. package/src/bindings.native.ts +4 -1
  74. package/src/bindings.ts +5 -0
  75. package/src/compat.ts +61 -0
  76. package/src/components/KeyboardAwareScrollView/index.tsx +43 -11
  77. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +2 -2
  78. package/src/components/index.ts +4 -1
  79. package/src/context.ts +3 -0
  80. package/src/hooks/index.ts +4 -1
  81. package/src/hooks/useKeyboardState/index.ts +4 -4
  82. package/src/index.ts +2 -0
  83. package/src/specs/KeyboardControllerViewNativeComponent.ts +11 -0
  84. package/src/types/internal.ts +3 -1
  85. package/src/types/module.ts +3 -2
  86. package/android/.settings/org.eclipse.buildship.core.prefs +0 -2
  87. package/ios/KeyboardController.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  88. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  89. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  90. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcuserdata/kirylziusko.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  91. package/ios/Tests/Tests.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +0 -32
@@ -1 +1 @@
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,kBAAkB,QAAQ,WAAW;AAW9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjCP,SAAS,CAAC,MAAM;IACdM,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,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ExE,MAAME,YAAY,GAAGlB,QAAQ,CAG1BmB,KAAK,IAAK;IACT,SAAS;;IAET,IAAIA,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC,2BAA2B,CAAC,EAAE;MAAA,IAAAoB,qBAAA;MACzD,CAAAA,qBAAA,GAAA1B,OAAO,CAAC2B,YAAY,cAAAD,qBAAA,eAApBA,qBAAA,CAAAjB,IAAA,CAAAT,OAAO,EAAgBI,KAAqC,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
+ {"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","update","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 {\n input: context.layout,\n update: context.update,\n };\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,Q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AD,qBAAA,eAApBA,qBAAA,CAAAlB,IAAA,CAAAT,OAAO,EAAgBI,KAAqC,CAAC;IAC/D;IAEA,IAAIA,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC,gCAAgC,CAAC,EAAE;MAAA,IAAAuB,qBAAA;MAC9D,CAAAA,qBAAA,GAAA7B,OAAO,CAAC8B,iBAAiB,cAAAD,qBAAA,eAAzBA,qBAAA,CAAApB,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,CAACoC,gBAAgB,CAAC5B,YAAY,CAAC;IAEtD,OAAO,MAAMa,OAAO,CAAC,CAAC;EACxB,CAAC,EAAEf,IAAI,CAAC;AACV;AAEA,cAAc,uBAAuB;AACrC,cAAc,oBAAoB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useState","KeyboardEvents","KeyboardController","EVENTS","getLatestState","state","isVisible","defaultSelector","useKeyboardState","selector","setState","subscriptions","map","event","addListener","willShowSubscription","e","appearance","forEach","subscription","remove"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { KeyboardEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\n\nimport type { KeyboardState } from \"../../types\";\n\nconst EVENTS = [\"keyboardDidShow\", \"keyboardDidHide\"] as const;\n\nconst getLatestState = () => ({\n ...KeyboardController.state(),\n isVisible: KeyboardController.isVisible(),\n});\n\ntype KeyboardStateSelector<T> = (state: KeyboardState) => T;\n\nconst defaultSelector: KeyboardStateSelector<KeyboardState> = (state) => state;\n\n/**\n * React Hook that represents the current keyboard state on iOS and Android.\n * It tracks keyboard visibility, height, appearance, type and other properties.\n * This hook subscribes to keyboard events and updates the state reactively.\n *\n * @template T - A type of the returned object from the `selector`.\n * @param selector - A function that receives the current keyboard state and picks only necessary properties to avoid frequent re-renders.\n * @returns Object {@link KeyboardState|containing} keyboard state information.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-state|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const isVisible = useKeyboardState((state) => state.isVisible);\n * const height = useKeyboardState((state) => state.height);\n *\n * return (\n * <View>\n * <Text>Keyboard is {isVisible ? 'visible' : 'hidden'}</Text>\n * <Text>Keyboard height: {height}</Text>\n * </View>\n * );\n * }\n * ```\n */\nfunction useKeyboardState<T = KeyboardState>(\n selector: KeyboardStateSelector<T> = defaultSelector as KeyboardStateSelector<T>,\n): T {\n const [state, setState] = useState<T>(() => selector(getLatestState()));\n\n useEffect(() => {\n const subscriptions = EVENTS.map((event) =>\n KeyboardEvents.addListener(event, () =>\n // state will be updated by global listener first,\n // so we simply read it and don't derive data from the event\n setState(selector(getLatestState())),\n ),\n );\n // update `appearance` prematurely\n const willShowSubscription = KeyboardEvents.addListener(\n \"keyboardWillShow\",\n (e) =>\n setState(selector({ ...getLatestState(), appearance: e.appearance })),\n );\n\n // we might have missed an update between reading a value in render and\n // `addListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n setState(selector(getLatestState()));\n\n return () => {\n subscriptions.forEach((subscription) => subscription.remove());\n willShowSubscription.remove();\n };\n }, []);\n\n return state;\n}\n\nexport { useKeyboardState };\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,SAASC,cAAc,QAAQ,gBAAgB;AAC/C,SAASC,kBAAkB,QAAQ,cAAc;AAIjD,MAAMC,MAAM,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAU;AAE9D,MAAMC,cAAc,GAAGA,CAAA,MAAO;EAC5B,GAAGF,kBAAkB,CAACG,KAAK,CAAC,CAAC;EAC7BC,SAAS,EAAEJ,kBAAkB,CAACI,SAAS,CAAC;AAC1C,CAAC,CAAC;AAIF,MAAMC,eAAqD,GAAIF,KAAK,IAAKA,KAAK;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,gBAAgBA,CACvBC,QAAkC,GAAGF,eAA2C,EAC7E;EACH,MAAM,CAACF,KAAK,EAAEK,QAAQ,CAAC,GAAGV,QAAQ,CAAI,MAAMS,QAAQ,CAACL,cAAc,CAAC,CAAC,CAAC,CAAC;EAEvEL,SAAS,CAAC,MAAM;IACd,MAAMY,aAAa,GAAGR,MAAM,CAACS,GAAG,CAAEC,KAAK,IACrCZ,cAAc,CAACa,WAAW,CAACD,KAAK,EAAE;IAChC;IACA;IACAH,QAAQ,CAACD,QAAQ,CAACL,cAAc,CAAC,CAAC,CAAC,CACrC,CACF,CAAC;IACD;IACA,MAAMW,oBAAoB,GAAGd,cAAc,CAACa,WAAW,CACrD,kBAAkB,EACjBE,CAAC,IACAN,QAAQ,CAACD,QAAQ,CAAC;MAAE,GAAGL,cAAc,CAAC,CAAC;MAAEa,UAAU,EAAED,CAAC,CAACC;IAAW,CAAC,CAAC,CACxE,CAAC;;IAED;IACA;IACA;IACAP,QAAQ,CAACD,QAAQ,CAACL,cAAc,CAAC,CAAC,CAAC,CAAC;IAEpC,OAAO,MAAM;MACXO,aAAa,CAACO,OAAO,CAAEC,YAAY,IAAKA,YAAY,CAACC,MAAM,CAAC,CAAC,CAAC;MAC9DL,oBAAoB,CAACK,MAAM,CAAC,CAAC;IAC/B,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOf,KAAK;AACd;AAEA,SAASG,gBAAgB","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","useState","KeyboardEvents","KeyboardController","EVENTS","getLatestState","state","isVisible","defaultSelector","useKeyboardState","selector","setState","subscriptions","map","event","addListener","willShowSubscription","e","appearance","forEach","subscription","remove"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { KeyboardEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\n\nimport type { IKeyboardState } from \"../../types\";\n\nconst EVENTS = [\"keyboardDidShow\", \"keyboardDidHide\"] as const;\n\nconst getLatestState = () => ({\n ...KeyboardController.state(),\n isVisible: KeyboardController.isVisible(),\n});\n\ntype KeyboardStateSelector<T> = (state: IKeyboardState) => T;\n\nconst defaultSelector: KeyboardStateSelector<IKeyboardState> = (state) => state;\n\n/**\n * React Hook that represents the current keyboard state on iOS and Android.\n * It tracks keyboard visibility, height, appearance, type and other properties.\n * This hook subscribes to keyboard events and updates the state reactively.\n *\n * @template T - A type of the returned object from the `selector`.\n * @param selector - A function that receives the current keyboard state and picks only necessary properties to avoid frequent re-renders.\n * @returns Object {@link KeyboardState|containing} keyboard state information.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-state|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const isVisible = useKeyboardState((state) => state.isVisible);\n * const height = useKeyboardState((state) => state.height);\n *\n * return (\n * <View>\n * <Text>Keyboard is {isVisible ? 'visible' : 'hidden'}</Text>\n * <Text>Keyboard height: {height}</Text>\n * </View>\n * );\n * }\n * ```\n */\nfunction useKeyboardState<T = IKeyboardState>(\n selector: KeyboardStateSelector<T> = defaultSelector as KeyboardStateSelector<T>,\n): T {\n const [state, setState] = useState<T>(() => selector(getLatestState()));\n\n useEffect(() => {\n const subscriptions = EVENTS.map((event) =>\n KeyboardEvents.addListener(event, () =>\n // state will be updated by global listener first,\n // so we simply read it and don't derive data from the event\n setState(selector(getLatestState())),\n ),\n );\n // update `appearance` prematurely\n const willShowSubscription = KeyboardEvents.addListener(\n \"keyboardWillShow\",\n (e) =>\n setState(selector({ ...getLatestState(), appearance: e.appearance })),\n );\n\n // we might have missed an update between reading a value in render and\n // `addListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n setState(selector(getLatestState()));\n\n return () => {\n subscriptions.forEach((subscription) => subscription.remove());\n willShowSubscription.remove();\n };\n }, []);\n\n return state;\n}\n\nexport { useKeyboardState };\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,SAASC,cAAc,QAAQ,gBAAgB;AAC/C,SAASC,kBAAkB,QAAQ,cAAc;AAIjD,MAAMC,MAAM,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAU;AAE9D,MAAMC,cAAc,GAAGA,CAAA,MAAO;EAC5B,GAAGF,kBAAkB,CAACG,KAAK,CAAC,CAAC;EAC7BC,SAAS,EAAEJ,kBAAkB,CAACI,SAAS,CAAC;AAC1C,CAAC,CAAC;AAIF,MAAMC,eAAsD,GAAIF,KAAK,IAAKA,KAAK;;AAE/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,gBAAgBA,CACvBC,QAAkC,GAAGF,eAA2C,EAC7E;EACH,MAAM,CAACF,KAAK,EAAEK,QAAQ,CAAC,GAAGV,QAAQ,CAAI,MAAMS,QAAQ,CAACL,cAAc,CAAC,CAAC,CAAC,CAAC;EAEvEL,SAAS,CAAC,MAAM;IACd,MAAMY,aAAa,GAAGR,MAAM,CAACS,GAAG,CAAEC,KAAK,IACrCZ,cAAc,CAACa,WAAW,CAACD,KAAK,EAAE;IAChC;IACA;IACAH,QAAQ,CAACD,QAAQ,CAACL,cAAc,CAAC,CAAC,CAAC,CACrC,CACF,CAAC;IACD;IACA,MAAMW,oBAAoB,GAAGd,cAAc,CAACa,WAAW,CACrD,kBAAkB,EACjBE,CAAC,IACAN,QAAQ,CAACD,QAAQ,CAAC;MAAE,GAAGL,cAAc,CAAC,CAAC;MAAEa,UAAU,EAAED,CAAC,CAACC;IAAW,CAAC,CAAC,CACxE,CAAC;;IAED;IACA;IACA;IACAP,QAAQ,CAACD,QAAQ,CAACL,cAAc,CAAC,CAAC,CAAC,CAAC;IAEpC,OAAO,MAAM;MACXO,aAAa,CAACO,OAAO,CAAEC,YAAY,IAAKA,YAAY,CAACC,MAAM,CAAC,CAAC,CAAC;MAC9DL,oBAAoB,CAACK,MAAM,CAAC,CAAC;IAC/B,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOf,KAAK;AACd;AAEA,SAASG,gBAAgB","ignoreList":[]}
@@ -5,6 +5,7 @@ export * from "./hooks";
5
5
  export * from "./constants";
6
6
  export * from "./module";
7
7
  export * from "./types";
8
+ export * from "./compat";
8
9
  export { KeyboardAvoidingView, KeyboardStickyView, KeyboardAwareScrollView,
9
10
  // keyboard toolbar
10
11
  KeyboardToolbar, DefaultKeyboardToolbarTheme } from "./components";
@@ -1 +1 @@
1
- {"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView","KeyboardAwareScrollView","KeyboardToolbar","DefaultKeyboardToolbarTheme","OverKeyboardView","KeyboardExtender"],"sources":["index.ts"],"sourcesContent":["export * from \"./bindings\";\nexport * from \"./animated\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./constants\";\nexport * from \"./module\";\nexport * from \"./types\";\n\nexport {\n KeyboardAvoidingView,\n KeyboardStickyView,\n KeyboardAwareScrollView,\n // keyboard toolbar\n KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n} from \"./components\";\nexport type {\n KeyboardAvoidingViewProps,\n KeyboardStickyViewProps,\n KeyboardAwareScrollViewProps,\n KeyboardToolbarProps,\n} from \"./components\";\nexport { OverKeyboardView, KeyboardExtender } from \"./views\";\n"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,SAAS;AAEvB,SACEA,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB;AACvB;AACAC,eAAe,EACfC,2BAA2B,QACtB,cAAc;AAOrB,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView","KeyboardAwareScrollView","KeyboardToolbar","DefaultKeyboardToolbarTheme","OverKeyboardView","KeyboardExtender"],"sources":["index.ts"],"sourcesContent":["export * from \"./bindings\";\nexport * from \"./animated\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./constants\";\nexport * from \"./module\";\nexport * from \"./types\";\nexport * from \"./compat\";\n\nexport {\n KeyboardAvoidingView,\n KeyboardStickyView,\n KeyboardAwareScrollView,\n // keyboard toolbar\n KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n} from \"./components\";\nexport type {\n KeyboardAvoidingViewProps,\n KeyboardStickyViewProps,\n KeyboardAwareScrollViewProps,\n KeyboardAwareScrollViewRef,\n KeyboardToolbarProps,\n} from \"./components\";\nexport { OverKeyboardView, KeyboardExtender } from \"./views\";\n"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,UAAU;AAExB,SACEA,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB;AACvB;AACAC,eAAe,EACfC,2BAA2B,QACtB,cAAc;AAQrB,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,SAAS","ignoreList":[]}
@@ -1,4 +1,8 @@
1
+ import codegenNativeCommands from "react-native/Libraries/Utilities/codegenNativeCommands";
1
2
  import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
3
+ export const Commands = codegenNativeCommands({
4
+ supportedCommands: ["synchronizeFocusedInputLayout"]
5
+ });
2
6
  export default codegenNativeComponent("KeyboardControllerView", {
3
7
  interfaceOnly: true
4
8
  });
@@ -1 +1 @@
1
- {"version":3,"names":["codegenNativeComponent","interfaceOnly"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\n\nimport type { HostComponent } from \"react-native\";\nimport type { ViewProps } from \"react-native/Libraries/Components/View/ViewPropTypes\";\nimport type {\n DirectEventHandler,\n Double,\n Int32,\n} from \"react-native/Libraries/Types/CodegenTypes\";\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n duration: Int32;\n target: Int32;\n}>;\n\ntype FocusedInputLayoutChangedEvent = Readonly<{\n target: Int32;\n parentScrollViewTarget: Int32;\n layout: {\n x: Double;\n y: Double;\n width: Double;\n height: Double;\n absoluteX: Double;\n absoluteY: Double;\n };\n}>;\n\ntype FocusedInputTextChangedEvent = Readonly<{\n text: string;\n}>;\n\ntype FocusedInputSelectionChangedEvent = Readonly<{\n target: Int32;\n selection: {\n start: {\n x: Double;\n y: Double;\n position: Int32;\n };\n end: {\n x: Double;\n y: Double;\n position: Int32;\n };\n };\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n enabled?: boolean;\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n preserveEdgeToEdge?: boolean;\n // callbacks\n /// keyboard\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n /// focused input\n onFocusedInputLayoutChanged?: DirectEventHandler<FocusedInputLayoutChangedEvent>;\n onFocusedInputTextChanged?: DirectEventHandler<FocusedInputTextChangedEvent>;\n onFocusedInputSelectionChanged?: DirectEventHandler<FocusedInputSelectionChangedEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\"KeyboardControllerView\", {\n interfaceOnly: true,\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAoE5F,eAAeA,sBAAsB,CAAc,wBAAwB,EAAE;EAC3EC,aAAa,EAAE;AACjB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["codegenNativeCommands","codegenNativeComponent","Commands","supportedCommands","interfaceOnly"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import codegenNativeCommands from \"react-native/Libraries/Utilities/codegenNativeCommands\";\nimport codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\n\nimport type { HostComponent } from \"react-native\";\nimport type { ViewProps } from \"react-native/Libraries/Components/View/ViewPropTypes\";\nimport type {\n DirectEventHandler,\n Double,\n Int32,\n} from \"react-native/Libraries/Types/CodegenTypes\";\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n duration: Int32;\n target: Int32;\n}>;\n\ntype FocusedInputLayoutChangedEvent = Readonly<{\n target: Int32;\n parentScrollViewTarget: Int32;\n layout: {\n x: Double;\n y: Double;\n width: Double;\n height: Double;\n absoluteX: Double;\n absoluteY: Double;\n };\n}>;\n\ntype FocusedInputTextChangedEvent = Readonly<{\n text: string;\n}>;\n\ntype FocusedInputSelectionChangedEvent = Readonly<{\n target: Int32;\n selection: {\n start: {\n x: Double;\n y: Double;\n position: Int32;\n };\n end: {\n x: Double;\n y: Double;\n position: Int32;\n };\n };\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n enabled?: boolean;\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n preserveEdgeToEdge?: boolean;\n // callbacks\n /// keyboard\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n /// focused input\n onFocusedInputLayoutChanged?: DirectEventHandler<FocusedInputLayoutChangedEvent>;\n onFocusedInputTextChanged?: DirectEventHandler<FocusedInputTextChangedEvent>;\n onFocusedInputSelectionChanged?: DirectEventHandler<FocusedInputSelectionChangedEvent>;\n}\n\ninterface NativeCommands {\n synchronizeFocusedInputLayout: (\n viewRef: React.ElementRef<HostComponent<NativeProps>>,\n ) => void;\n}\n\nexport const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({\n supportedCommands: [\"synchronizeFocusedInputLayout\"],\n});\n\nexport default codegenNativeComponent<NativeProps>(\"KeyboardControllerView\", {\n interfaceOnly: true,\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,qBAAqB,MAAM,wDAAwD;AAC1F,OAAOC,sBAAsB,MAAM,yDAAyD;AA0E5F,OAAO,MAAMC,QAAwB,GAAGF,qBAAqB,CAAiB;EAC5EG,iBAAiB,EAAE,CAAC,+BAA+B;AACrD,CAAC,CAAC;AAEF,eAAeF,sBAAsB,CAAc,wBAAwB,EAAE;EAC3EG,aAAa,EAAE;AACjB,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["internal.ts"],"sourcesContent":["import type { EmitterSubscription } from \"react-native\";\n\nexport type FocusedInputAvailableEvents = \"focusDidSet\";\nexport type FocusedInputEventData = {\n current: number;\n count: number;\n};\nexport type FocusedInputEventsModule = {\n addListener: (\n name: FocusedInputAvailableEvents,\n cb: (e: FocusedInputEventData) => void,\n ) => EmitterSubscription;\n};\nexport type WindowDimensionsAvailableEvents = \"windowDidResize\";\nexport type WindowDimensionsEventData = {\n width: number;\n height: number;\n};\nexport type WindowDimensionsEventsModule = {\n addListener: (\n name: WindowDimensionsAvailableEvents,\n cb: (e: WindowDimensionsEventData) => void,\n ) => EmitterSubscription;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["internal.ts"],"sourcesContent":["import type { EmitterSubscription } from \"react-native\";\n\nexport type FocusedInputAvailableEvents =\n | \"focusDidSet\"\n | \"layoutDidSynchronize\";\nexport type FocusedInputEventData = {\n current: number;\n count: number;\n};\nexport type FocusedInputEventsModule = {\n addListener: (\n name: FocusedInputAvailableEvents,\n cb: (e: FocusedInputEventData) => void,\n ) => EmitterSubscription;\n};\nexport type WindowDimensionsAvailableEvents = \"windowDidResize\";\nexport type WindowDimensionsEventData = {\n width: number;\n height: number;\n};\nexport type WindowDimensionsEventsModule = {\n addListener: (\n name: WindowDimensionsAvailableEvents,\n cb: (e: WindowDimensionsEventData) => void,\n ) => EmitterSubscription;\n};\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["module.ts"],"sourcesContent":["import type { EmitterSubscription, TextInputProps } from \"react-native\";\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n /** Height of the keyboard. */\n height: number;\n /** Duration of the keyboard animation. */\n duration: number;\n /** Timestamp of the last keyboard event. */\n timestamp: number;\n /** Tag of the focused `TextInput`. */\n target: number;\n /** `keyboardType` property from focused `TextInput`. */\n type: NonNullable<TextInputProps[\"keyboardType\"]>;\n /** Keyboard appearance. Can be one of `dark` or `light`. */\n appearance: \"dark\" | \"light\";\n};\n/**\n * An object that represent current keyboard state.\n */\nexport type KeyboardState = {\n /** Whether the keyboard is currently visible. */\n isVisible: boolean;\n} & KeyboardEventData;\nexport type KeyboardEventsModule = {\n /**\n * The `addListener` function connects a JavaScript function to an identified native\n * keyboard notification event.\n *\n * This function then returns the reference to the listener.\n *\n * `name` is the string that identifies the event you're listening for. This\n * can be any of the following:\n *\n * - `keyboardWillShow`;\n * - `keyboardDidShow`;\n * - `keyboardWillHide`;\n * - `keyboardDidHide`.\n */\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void,\n ) => EmitterSubscription;\n};\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type DismissOptions = {\n /**\n * A boolean property indicating whether focus should be kept on the input after dismissing the keyboard. Default is `false`.\n */\n keepFocus: boolean;\n /**\n * A boolean property controlling whether dismissal should be animated. Default is `true`.\n */\n animated: boolean;\n};\nexport type KeyboardControllerModule = {\n // android only\n /**\n * Sets default `windowSoftInputMode` (the one that declared in `AndroidManifest.xml`).\n *\n * @platform android\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setdefaultmode-|docs} page for more details.\n */\n setDefaultMode: () => void;\n /**\n * Changes `windowSoftInputMode` on Android.\n *\n * @platform android\n * @see AndroidSoftInputModes for all possible values and {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|docs} page for more details.\n */\n setInputMode: (mode: number) => void;\n // ios only\n /**\n * A method that preloads the keyboard. It's useful when you want to avoid a delay when the user focuses the first input.\n *\n * @platform ios\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#preload-|docs} page for more details.\n */\n preload: () => void;\n // all platforms\n /**\n * Dismisses the active keyboard. Removes a focus by default, but allows to pass `{keepFocus: true}` to keep focus.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#dismiss|docs} page for more details.\n */\n dismiss: (options?: DismissOptions) => Promise<void>;\n /**\n * Moves focus to the specified direction (`next`, `prev` or `current` to restore a focus).\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setfocusto|docs} page for more details.\n */\n setFocusTo: (direction: Direction) => void;\n /**\n * Whether the keyboard is fully visible.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#isvisible|docs} page for more details.\n */\n isVisible: () => boolean;\n /**\n * Method that returns current keyboard state.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#state|docs} page for more details.\n */\n state: () => KeyboardEventData;\n};\nexport type KeyboardControllerNativeModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // ios only\n preload: () => void;\n // all platforms\n dismiss: (keepFocus: boolean, animated: boolean) => void;\n setFocusTo: (direction: Direction) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["module.ts"],"sourcesContent":["import type { EmitterSubscription, TextInputProps } from \"react-native\";\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n /** Height of the keyboard. */\n height: number;\n /** Duration of the keyboard animation. */\n duration: number;\n /** Timestamp of the last keyboard event. */\n timestamp: number;\n /** Tag of the focused `TextInput`. */\n target: number;\n /** `keyboardType` property from focused `TextInput`. */\n type: NonNullable<TextInputProps[\"keyboardType\"]>;\n /** Keyboard appearance. Can be one of `dark` or `light`. */\n appearance: \"dark\" | \"light\";\n};\n/**\n * An object that represent current keyboard state.\n */\nexport type IKeyboardState = {\n /** Whether the keyboard is currently visible. */\n isVisible: boolean;\n} & KeyboardEventData;\nexport type KeyboardEventsModule = {\n /**\n * The `addListener` function connects a JavaScript function to an identified native\n * keyboard notification event.\n *\n * This function then returns the reference to the listener.\n *\n * `name` is the string that identifies the event you're listening for. This\n * can be any of the following:\n *\n * - `keyboardWillShow`;\n * - `keyboardDidShow`;\n * - `keyboardWillHide`;\n * - `keyboardDidHide`.\n */\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void,\n ) => EmitterSubscription;\n};\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type DismissOptions = {\n /**\n * A boolean property indicating whether focus should be kept on the input after dismissing the keyboard. Default is `false`.\n */\n keepFocus: boolean;\n /**\n * A boolean property controlling whether dismissal should be animated. Default is `true`.\n */\n animated: boolean;\n};\nexport type KeyboardControllerModule = {\n // android only\n /**\n * Sets default `windowSoftInputMode` (the one that declared in `AndroidManifest.xml`).\n *\n * @platform android\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setdefaultmode-|docs} page for more details.\n */\n setDefaultMode: () => void;\n /**\n * Changes `windowSoftInputMode` on Android.\n *\n * @platform android\n * @see AndroidSoftInputModes for all possible values and {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|docs} page for more details.\n */\n setInputMode: (mode: number) => void;\n // ios only\n /**\n * A method that preloads the keyboard. It's useful when you want to avoid a delay when the user focuses the first input.\n *\n * @platform ios\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#preload-|docs} page for more details.\n */\n preload: () => void;\n // all platforms\n /**\n * Dismisses the active keyboard. Removes a focus by default, but allows to pass `{keepFocus: true}` to keep focus.\n * If you want to close keyboard immediately pass `{animated: false}`.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#dismiss|docs} page for more details.\n */\n dismiss: (options?: Partial<DismissOptions>) => Promise<void>;\n /**\n * Moves focus to the specified direction (`next`, `prev` or `current` to restore a focus).\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setfocusto|docs} page for more details.\n */\n setFocusTo: (direction: Direction) => void;\n /**\n * Whether the keyboard is fully visible.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#isvisible|docs} page for more details.\n */\n isVisible: () => boolean;\n /**\n * Method that returns current keyboard state.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#state|docs} page for more details.\n */\n state: () => KeyboardEventData;\n};\nexport type KeyboardControllerNativeModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // ios only\n preload: () => void;\n // all platforms\n dismiss: (keepFocus: boolean, animated: boolean) => void;\n setFocusTo: (direction: Direction) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n"],"mappings":"","ignoreList":[]}
@@ -22,6 +22,9 @@ export declare const WindowDimensionsEvents: WindowDimensionsEventsModule;
22
22
  * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|Documentation} page for more details.
23
23
  */
24
24
  export declare const KeyboardControllerView: React.FC<KeyboardControllerProps>;
25
+ export declare const KeyboardControllerViewCommands: {
26
+ synchronizeFocusedInputLayout: (_ref: React.Component<KeyboardControllerProps> | null) => void;
27
+ };
25
28
  /**
26
29
  * A view that defines a region on the screen, where gestures will control the keyboard position.
27
30
  *
@@ -8,6 +8,7 @@ export declare const KeyboardEvents: KeyboardEventsModule;
8
8
  export declare const FocusedInputEvents: FocusedInputEventsModule;
9
9
  export declare const WindowDimensionsEvents: WindowDimensionsEventsModule;
10
10
  export declare const KeyboardControllerView: React.FC<KeyboardControllerProps>;
11
+ export declare const KeyboardControllerViewCommands: any;
11
12
  export declare const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps>;
12
13
  export declare const RCTOverKeyboardView: React.FC<OverKeyboardViewProps>;
13
14
  export declare const KeyboardBackgroundView: React.FC<KeyboardBackgroundViewProps>;
@@ -0,0 +1,27 @@
1
+ export declare const KeyboardState: {
2
+ UNKNOWN: number;
3
+ OPENING: number;
4
+ OPEN: number;
5
+ CLOSING: number;
6
+ CLOSED: number;
7
+ };
8
+ /**
9
+ * A compatibility layer for migration from https://docs.swmansion.com/react-native-reanimated/docs/device/useAnimatedKeyboard.
10
+ *
11
+ * @returns An object containing `height` and `state` properties represented as `SharedValue<number>`.
12
+ * @example
13
+ * ```ts
14
+ * import { useAnimatedKeyboard, useAnimatedStyle } from 'react-native-keyboard-controller';
15
+ *
16
+ * export default function App() {
17
+ * const keyboard = useAnimatedKeyboard();
18
+ *
19
+ * const animatedStyles = useAnimatedStyle(() => ({
20
+ * transform: [{ translateY: -keyboard.height.value }],
21
+ * }));
22
+ * }
23
+ */
24
+ export declare const useAnimatedKeyboard: () => {
25
+ height: import("react-native-reanimated").SharedValue<number>;
26
+ state: import("react-native-reanimated").SharedValue<number>;
27
+ };
@@ -12,6 +12,9 @@ export type KeyboardAwareScrollViewProps = {
12
12
  /** Custom component for `ScrollView`. Default is `ScrollView`. */
13
13
  ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
14
14
  } & ScrollViewProps;
15
+ export type KeyboardAwareScrollViewRef = {
16
+ assureFocusedInputVisible: () => void;
17
+ } & ScrollView;
15
18
  /**
16
19
  * A ScrollView component that automatically handles keyboard appearance and disappearance
17
20
  * by adjusting its content position to ensure the focused input remains visible.
@@ -42,5 +45,5 @@ declare const KeyboardAwareScrollView: React.ForwardRefExoticComponent<{
42
45
  ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
43
46
  } & ScrollViewProps & {
44
47
  children?: React.ReactNode | undefined;
45
- } & React.RefAttributes<ScrollView>>;
48
+ } & React.RefAttributes<KeyboardAwareScrollViewRef>>;
46
49
  export default KeyboardAwareScrollView;
@@ -4,5 +4,5 @@ export { default as KeyboardAwareScrollView } from "./KeyboardAwareScrollView";
4
4
  export { default as KeyboardToolbar, DefaultKeyboardToolbarTheme, } from "./KeyboardToolbar";
5
5
  export type { KeyboardAvoidingViewProps } from "./KeyboardAvoidingView";
6
6
  export type { KeyboardStickyViewProps } from "./KeyboardStickyView";
7
- export type { KeyboardAwareScrollViewProps } from "./KeyboardAwareScrollView";
7
+ export type { KeyboardAwareScrollViewProps, KeyboardAwareScrollViewRef, } from "./KeyboardAwareScrollView";
8
8
  export type { KeyboardToolbarProps } from "./KeyboardToolbar";
@@ -29,6 +29,8 @@ export type KeyboardAnimationContext = {
29
29
  reanimated: ReanimatedContext;
30
30
  /** Layout of the focused `TextInput` represented as `SharedValue`. */
31
31
  layout: SharedValue<FocusedInputLayoutChangedEvent | null>;
32
+ /** Method for updating info about focused input layout. */
33
+ update: () => Promise<void>;
32
34
  /** Method for setting workletized keyboard handlers. */
33
35
  setKeyboardHandlers: (handlers: EventHandlerProcessed<never, never>) => () => void;
34
36
  /** Method for setting workletized handlers for tracking focused input events. */
@@ -151,6 +151,7 @@ export declare function useKeyboardController(): {
151
151
  */
152
152
  export declare function useReanimatedFocusedInput(): {
153
153
  input: import("react-native-reanimated").SharedValue<import("../types").FocusedInputLayoutChangedEvent | null>;
154
+ update: () => Promise<void>;
154
155
  };
155
156
  /**
156
157
  * Hook for handling focused input events, such as changes of selection, text etc.
@@ -1,5 +1,5 @@
1
- import type { KeyboardState } from "../../types";
2
- type KeyboardStateSelector<T> = (state: KeyboardState) => T;
1
+ import type { IKeyboardState } from "../../types";
2
+ type KeyboardStateSelector<T> = (state: IKeyboardState) => T;
3
3
  /**
4
4
  * React Hook that represents the current keyboard state on iOS and Android.
5
5
  * It tracks keyboard visibility, height, appearance, type and other properties.
@@ -24,5 +24,5 @@ type KeyboardStateSelector<T> = (state: KeyboardState) => T;
24
24
  * }
25
25
  * ```
26
26
  */
27
- declare function useKeyboardState<T = KeyboardState>(selector?: KeyboardStateSelector<T>): T;
27
+ declare function useKeyboardState<T = IKeyboardState>(selector?: KeyboardStateSelector<T>): T;
28
28
  export { useKeyboardState };
@@ -5,6 +5,7 @@ export * from "./hooks";
5
5
  export * from "./constants";
6
6
  export * from "./module";
7
7
  export * from "./types";
8
+ export * from "./compat";
8
9
  export { KeyboardAvoidingView, KeyboardStickyView, KeyboardAwareScrollView, KeyboardToolbar, DefaultKeyboardToolbarTheme, } from "./components";
9
- export type { KeyboardAvoidingViewProps, KeyboardStickyViewProps, KeyboardAwareScrollViewProps, KeyboardToolbarProps, } from "./components";
10
+ export type { KeyboardAvoidingViewProps, KeyboardStickyViewProps, KeyboardAwareScrollViewProps, KeyboardAwareScrollViewRef, KeyboardToolbarProps, } from "./components";
10
11
  export { OverKeyboardView, KeyboardExtender } from "./views";
@@ -50,5 +50,9 @@ export interface NativeProps extends ViewProps {
50
50
  onFocusedInputTextChanged?: DirectEventHandler<FocusedInputTextChangedEvent>;
51
51
  onFocusedInputSelectionChanged?: DirectEventHandler<FocusedInputSelectionChangedEvent>;
52
52
  }
53
+ interface NativeCommands {
54
+ synchronizeFocusedInputLayout: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
55
+ }
56
+ export declare const Commands: NativeCommands;
53
57
  declare const _default: HostComponent<NativeProps>;
54
58
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import type { EmitterSubscription } from "react-native";
2
- export type FocusedInputAvailableEvents = "focusDidSet";
2
+ export type FocusedInputAvailableEvents = "focusDidSet" | "layoutDidSynchronize";
3
3
  export type FocusedInputEventData = {
4
4
  current: number;
5
5
  count: number;
@@ -17,7 +17,7 @@ export type KeyboardEventData = {
17
17
  /**
18
18
  * An object that represent current keyboard state.
19
19
  */
20
- export type KeyboardState = {
20
+ export type IKeyboardState = {
21
21
  /** Whether the keyboard is currently visible. */
22
22
  isVisible: boolean;
23
23
  } & KeyboardEventData;
@@ -73,10 +73,11 @@ export type KeyboardControllerModule = {
73
73
  preload: () => void;
74
74
  /**
75
75
  * Dismisses the active keyboard. Removes a focus by default, but allows to pass `{keepFocus: true}` to keep focus.
76
+ * If you want to close keyboard immediately pass `{animated: false}`.
76
77
  *
77
78
  * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#dismiss|docs} page for more details.
78
79
  */
79
- dismiss: (options?: DismissOptions) => Promise<void>;
80
+ dismiss: (options?: Partial<DismissOptions>) => Promise<void>;
80
81
  /**
81
82
  * Moves focus to the specified direction (`next`, `prev` or `current` to restore a focus).
82
83
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.20.0-beta.0",
3
+ "version": "1.20.1",
4
4
  "description": "Keyboard manager which works in identical way on both iOS and Android",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/animated.tsx CHANGED
@@ -1,5 +1,11 @@
1
1
  /* eslint react/jsx-sort-props: off */
2
- import React, { useEffect, useMemo, useRef, useState } from "react";
2
+ import React, {
3
+ useCallback,
4
+ useEffect,
5
+ useMemo,
6
+ useRef,
7
+ useState,
8
+ } from "react";
3
9
  import { Animated, Platform, StyleSheet } from "react-native";
4
10
  import {
5
11
  controlEdgeToEdgeValues,
@@ -7,7 +13,11 @@ import {
7
13
  } from "react-native-is-edge-to-edge";
8
14
  import Reanimated, { useSharedValue } from "react-native-reanimated";
9
15
 
10
- import { KeyboardControllerView } from "./bindings";
16
+ import {
17
+ FocusedInputEvents,
18
+ KeyboardControllerView,
19
+ KeyboardControllerViewCommands,
20
+ } from "./bindings";
11
21
  import { KeyboardContext } from "./context";
12
22
  import { useAnimatedValue, useEventHandlerRegistration } from "./internal";
13
23
  import { KeyboardController } from "./module";
@@ -117,7 +127,7 @@ export const KeyboardProvider = (props: KeyboardProviderProps) => {
117
127
  preload = true,
118
128
  } = props;
119
129
  // ref
120
- const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);
130
+ const viewRef = useRef<React.Component<KeyboardControllerProps>>(null);
121
131
  // state
122
132
  const [enabled, setEnabled] = useState(initiallyEnabled);
123
133
  // animated values
@@ -127,8 +137,23 @@ export const KeyboardProvider = (props: KeyboardProviderProps) => {
127
137
  const progressSV = useSharedValue(0);
128
138
  const heightSV = useSharedValue(0);
129
139
  const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);
130
- const setKeyboardHandlers = useEventHandlerRegistration(viewTagRef);
131
- const setInputHandlers = useEventHandlerRegistration(viewTagRef);
140
+ const setKeyboardHandlers = useEventHandlerRegistration(viewRef);
141
+ const setInputHandlers = useEventHandlerRegistration(viewRef);
142
+ const update = useCallback(async () => {
143
+ KeyboardControllerViewCommands.synchronizeFocusedInputLayout(
144
+ viewRef.current,
145
+ );
146
+
147
+ await new Promise((resolve) => {
148
+ const subscription = FocusedInputEvents.addListener(
149
+ "layoutDidSynchronize",
150
+ () => {
151
+ subscription.remove();
152
+ resolve(null);
153
+ },
154
+ );
155
+ });
156
+ }, []);
132
157
  // memo
133
158
  const context = useMemo<KeyboardAnimationContext>(
134
159
  () => ({
@@ -136,6 +161,7 @@ export const KeyboardProvider = (props: KeyboardProviderProps) => {
136
161
  animated: { progress: progress, height: Animated.multiply(height, -1) },
137
162
  reanimated: { progress: progressSV, height: heightSV },
138
163
  layout,
164
+ update,
139
165
  setKeyboardHandlers,
140
166
  setInputHandlers,
141
167
  setEnabled,
@@ -232,7 +258,7 @@ export const KeyboardProvider = (props: KeyboardProviderProps) => {
232
258
  return (
233
259
  <KeyboardContext.Provider value={context}>
234
260
  <KeyboardControllerViewAnimated
235
- ref={viewTagRef}
261
+ ref={viewRef}
236
262
  enabled={enabled}
237
263
  navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}
238
264
  statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}
@@ -18,6 +18,7 @@ const LINKING_ERROR =
18
18
  "- You rebuilt the app after installing the package\n" +
19
19
  "- You are not using Expo Go\n";
20
20
 
21
+ const KeyboardControllerViewNativeComponentModule = require("./specs/KeyboardControllerViewNativeComponent");
21
22
  const RCTKeyboardController =
22
23
  require("./specs/NativeKeyboardController").default;
23
24
 
@@ -55,7 +56,9 @@ export const WindowDimensionsEvents: WindowDimensionsEventsModule = {
55
56
  eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),
56
57
  };
57
58
  export const KeyboardControllerView: React.FC<KeyboardControllerProps> =
58
- require("./specs/KeyboardControllerViewNativeComponent").default;
59
+ KeyboardControllerViewNativeComponentModule.default;
60
+ export const KeyboardControllerViewCommands =
61
+ KeyboardControllerViewNativeComponentModule.Commands;
59
62
  export const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =
60
63
  (Platform.OS === "android" && Platform.Version >= 30) || Platform.OS === "ios"
61
64
  ? require("./specs/KeyboardGestureAreaNativeComponent").default
package/src/bindings.ts CHANGED
@@ -53,6 +53,11 @@ export const WindowDimensionsEvents: WindowDimensionsEventsModule = {
53
53
  */
54
54
  export const KeyboardControllerView =
55
55
  View as unknown as React.FC<KeyboardControllerProps>;
56
+ export const KeyboardControllerViewCommands = {
57
+ synchronizeFocusedInputLayout: (
58
+ _ref: React.Component<KeyboardControllerProps> | null,
59
+ ) => {},
60
+ };
56
61
  /**
57
62
  * A view that defines a region on the screen, where gestures will control the keyboard position.
58
63
  *
package/src/compat.ts ADDED
@@ -0,0 +1,61 @@
1
+ import { useSharedValue } from "react-native-reanimated";
2
+
3
+ import { useKeyboardHandler } from "./hooks";
4
+
5
+ export const KeyboardState = {
6
+ UNKNOWN: 0,
7
+ OPENING: 1,
8
+ OPEN: 2,
9
+ CLOSING: 3,
10
+ CLOSED: 4,
11
+ };
12
+
13
+ /**
14
+ * A compatibility layer for migration from https://docs.swmansion.com/react-native-reanimated/docs/device/useAnimatedKeyboard.
15
+ *
16
+ * @returns An object containing `height` and `state` properties represented as `SharedValue<number>`.
17
+ * @example
18
+ * ```ts
19
+ * import { useAnimatedKeyboard, useAnimatedStyle } from 'react-native-keyboard-controller';
20
+ *
21
+ * export default function App() {
22
+ * const keyboard = useAnimatedKeyboard();
23
+ *
24
+ * const animatedStyles = useAnimatedStyle(() => ({
25
+ * transform: [{ translateY: -keyboard.height.value }],
26
+ * }));
27
+ * }
28
+ */
29
+ export const useAnimatedKeyboard = () => {
30
+ const height = useSharedValue(0);
31
+ const state = useSharedValue(KeyboardState.UNKNOWN);
32
+
33
+ useKeyboardHandler(
34
+ {
35
+ onStart: (e) => {
36
+ "worklet";
37
+
38
+ state.set(e.height > 0 ? KeyboardState.OPENING : KeyboardState.CLOSING);
39
+ },
40
+ onMove: (e) => {
41
+ "worklet";
42
+
43
+ height.set(e.height);
44
+ },
45
+ onInteractive: (e) => {
46
+ "worklet";
47
+
48
+ height.set(e.height);
49
+ },
50
+ onEnd: (e) => {
51
+ "worklet";
52
+
53
+ state.set(e.height > 0 ? KeyboardState.OPEN : KeyboardState.CLOSED);
54
+ height.set(e.height);
55
+ },
56
+ },
57
+ [],
58
+ );
59
+
60
+ return { height, state };
61
+ };
@@ -1,4 +1,10 @@
1
- import React, { forwardRef, useCallback, useEffect, useMemo } from "react";
1
+ import React, {
2
+ forwardRef,
3
+ useCallback,
4
+ useEffect,
5
+ useImperativeHandle,
6
+ useMemo,
7
+ } from "react";
2
8
  import Reanimated, {
3
9
  clamp,
4
10
  interpolate,
@@ -44,6 +50,9 @@ export type KeyboardAwareScrollViewProps = {
44
50
  /** Custom component for `ScrollView`. Default is `ScrollView`. */
45
51
  ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
46
52
  } & ScrollViewProps;
53
+ export type KeyboardAwareScrollViewRef = {
54
+ assureFocusedInputVisible: () => void;
55
+ } & ScrollView;
47
56
 
48
57
  // Everything begins from `onStart` handler. This handler is called every time,
49
58
  // when keyboard changes its size or when focused `TextInput` was changed. In
@@ -99,7 +108,7 @@ export type KeyboardAwareScrollViewProps = {
99
108
  * ```
100
109
  */
101
110
  const KeyboardAwareScrollView = forwardRef<
102
- ScrollView,
111
+ KeyboardAwareScrollViewRef,
103
112
  React.PropsWithChildren<KeyboardAwareScrollViewProps>
104
113
  >(
105
114
  (
@@ -117,6 +126,7 @@ const KeyboardAwareScrollView = forwardRef<
117
126
  ref,
118
127
  ) => {
119
128
  const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();
129
+ const scrollViewRef = React.useRef<ScrollView>(null);
120
130
  const scrollViewTarget = useSharedValue<number | null>(null);
121
131
  const scrollPosition = useSharedValue(0);
122
132
  const position = useScrollViewOffset(scrollViewAnimatedRef);
@@ -126,7 +136,7 @@ const KeyboardAwareScrollView = forwardRef<
126
136
  const tag = useSharedValue(-1);
127
137
  const initialKeyboardSize = useSharedValue(0);
128
138
  const scrollBeforeKeyboardMovement = useSharedValue(0);
129
- const { input } = useReanimatedFocusedInput();
139
+ const { input, update } = useReanimatedFocusedInput();
130
140
  const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);
131
141
  const lastSelection =
132
142
  useSharedValue<FocusedInputSelectionChangedEvent | null>(null);
@@ -134,11 +144,7 @@ const KeyboardAwareScrollView = forwardRef<
134
144
  const { height } = useWindowDimensions();
135
145
 
136
146
  const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {
137
- if (typeof ref === "function") {
138
- ref(assignedRef);
139
- } else if (ref) {
140
- ref.current = assignedRef;
141
- }
147
+ scrollViewRef.current = assignedRef;
142
148
 
143
149
  scrollViewAnimatedRef(assignedRef);
144
150
  }, []);
@@ -392,10 +398,36 @@ const KeyboardAwareScrollView = forwardRef<
392
398
  [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame],
393
399
  );
394
400
 
401
+ const synchronize = useCallback(async () => {
402
+ await update();
403
+
404
+ runOnUI(() => {
405
+ "worklet";
406
+
407
+ scrollFromCurrentPosition();
408
+ })();
409
+ }, [update, scrollFromCurrentPosition]);
410
+
411
+ useImperativeHandle(
412
+ ref,
413
+ () => {
414
+ const scrollView = scrollViewRef.current;
415
+
416
+ const existingMethods = scrollView ? { ...scrollView } : {};
417
+
418
+ return {
419
+ ...existingMethods,
420
+
421
+ assureFocusedInputVisible: () => {
422
+ synchronize();
423
+ },
424
+ } as KeyboardAwareScrollViewRef;
425
+ },
426
+ [synchronize],
427
+ );
428
+
395
429
  useEffect(() => {
396
- runOnUI(performScrollWithPositionRestoration)(
397
- scrollBeforeKeyboardMovement.value,
398
- );
430
+ synchronize();
399
431
  }, [bottomOffset]);
400
432
 
401
433
  useAnimatedReaction(