react-native-keyboard-controller 1.2.0 → 1.3.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 (92) hide show
  1. package/android/build.gradle +0 -40
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +44 -8
  3. package/ios/KeyboardController.xcodeproj/project.pbxproj +2 -2
  4. package/ios/KeyboardControllerModule.mm +1 -1
  5. package/ios/KeyboardControllerView.mm +4 -4
  6. package/lib/commonjs/animated.js +14 -59
  7. package/lib/commonjs/animated.js.map +1 -1
  8. package/lib/commonjs/context.js +28 -0
  9. package/lib/commonjs/context.js.map +1 -0
  10. package/lib/commonjs/hooks.js +39 -0
  11. package/lib/commonjs/hooks.js.map +1 -0
  12. package/lib/commonjs/index.js +39 -0
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/internal.js +27 -0
  15. package/lib/commonjs/internal.js.map +1 -0
  16. package/lib/commonjs/monkey-patch.js +3 -3
  17. package/lib/commonjs/monkey-patch.js.map +1 -1
  18. package/lib/commonjs/native.js +24 -21
  19. package/lib/commonjs/native.js.map +1 -1
  20. package/lib/commonjs/replicas.js +2 -2
  21. package/lib/commonjs/replicas.js.map +1 -1
  22. package/lib/commonjs/{KeyboardControllerViewNativeComponent.js → specs/KeyboardControllerViewNativeComponent.js} +0 -0
  23. package/lib/commonjs/{KeyboardControllerViewNativeComponent.js.map → specs/KeyboardControllerViewNativeComponent.js.map} +0 -0
  24. package/lib/commonjs/{NativeKeyboardController.js → specs/NativeKeyboardController.js} +0 -0
  25. package/lib/commonjs/{NativeKeyboardController.js.map → specs/NativeKeyboardController.js.map} +0 -0
  26. package/lib/commonjs/{NativeStatusBarManagerCompat.js → specs/NativeStatusBarManagerCompat.js} +0 -0
  27. package/lib/commonjs/{NativeStatusBarManagerCompat.js.map → specs/NativeStatusBarManagerCompat.js.map} +0 -0
  28. package/lib/commonjs/types.js +6 -0
  29. package/lib/commonjs/types.js.map +1 -0
  30. package/lib/module/animated.js +12 -50
  31. package/lib/module/animated.js.map +1 -1
  32. package/lib/module/context.js +18 -0
  33. package/lib/module/context.js.map +1 -0
  34. package/lib/module/hooks.js +20 -0
  35. package/lib/module/hooks.js.map +1 -0
  36. package/lib/module/index.js +3 -0
  37. package/lib/module/index.js.map +1 -1
  38. package/lib/module/internal.js +19 -0
  39. package/lib/module/internal.js.map +1 -0
  40. package/lib/module/monkey-patch.js +4 -3
  41. package/lib/module/monkey-patch.js.map +1 -1
  42. package/lib/module/native.js +23 -17
  43. package/lib/module/native.js.map +1 -1
  44. package/lib/module/replicas.js +1 -1
  45. package/lib/module/replicas.js.map +1 -1
  46. package/lib/module/{KeyboardControllerViewNativeComponent.js → specs/KeyboardControllerViewNativeComponent.js} +0 -0
  47. package/lib/module/{KeyboardControllerViewNativeComponent.js.map → specs/KeyboardControllerViewNativeComponent.js.map} +0 -0
  48. package/lib/module/{NativeKeyboardController.js → specs/NativeKeyboardController.js} +0 -0
  49. package/lib/module/{NativeKeyboardController.js.map → specs/NativeKeyboardController.js.map} +0 -0
  50. package/lib/module/{NativeStatusBarManagerCompat.js → specs/NativeStatusBarManagerCompat.js} +0 -0
  51. package/lib/module/{NativeStatusBarManagerCompat.js.map → specs/NativeStatusBarManagerCompat.js.map} +0 -0
  52. package/lib/module/types.js +2 -0
  53. package/lib/module/types.js.map +1 -0
  54. package/lib/typescript/animated.d.ts +1 -17
  55. package/lib/typescript/context.d.ts +16 -0
  56. package/lib/typescript/hooks.d.ts +4 -0
  57. package/lib/typescript/index.d.ts +3 -0
  58. package/lib/typescript/internal.d.ts +4 -0
  59. package/lib/typescript/native.d.ts +14 -26
  60. package/lib/typescript/{KeyboardControllerViewNativeComponent.d.ts → specs/KeyboardControllerViewNativeComponent.d.ts} +0 -0
  61. package/lib/typescript/{NativeKeyboardController.d.ts → specs/NativeKeyboardController.d.ts} +0 -0
  62. package/lib/typescript/{NativeStatusBarManagerCompat.d.ts → specs/NativeStatusBarManagerCompat.d.ts} +0 -0
  63. package/lib/typescript/types.d.ts +23 -0
  64. package/package.json +17 -20
  65. package/react-native-keyboard-controller.podspec +2 -1
  66. package/src/animated.tsx +12 -75
  67. package/src/context.ts +28 -0
  68. package/src/hooks.ts +28 -0
  69. package/src/index.ts +3 -0
  70. package/src/internal.ts +27 -0
  71. package/src/{monkey-patch.tsx → monkey-patch.ts} +3 -6
  72. package/src/native.ts +37 -66
  73. package/src/replicas.ts +1 -1
  74. package/src/{KeyboardControllerViewNativeComponent.ts → specs/KeyboardControllerViewNativeComponent.ts} +0 -0
  75. package/src/{NativeKeyboardController.ts → specs/NativeKeyboardController.ts} +0 -0
  76. package/src/{NativeStatusBarManagerCompat.ts → specs/NativeStatusBarManagerCompat.ts} +0 -0
  77. package/src/types.ts +42 -0
  78. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  79. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  80. package/android/gradlew +0 -185
  81. package/android/gradlew.bat +0 -89
  82. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerComponentsRegistry.kt +0 -31
  83. package/android/src/main/jni/Android.mk +0 -42
  84. package/android/src/main/jni/KeyboardControllerComponentsRegistry.cpp +0 -71
  85. package/android/src/main/jni/KeyboardControllerComponentsRegistry.h +0 -35
  86. package/android/src/main/jni/OnLoad.cpp +0 -9
  87. package/lib/commonjs/architecture.js +0 -13
  88. package/lib/commonjs/architecture.js.map +0 -1
  89. package/lib/module/architecture.js +0 -5
  90. package/lib/module/architecture.js.map +0 -1
  91. package/lib/typescript/architecture.d.ts +0 -2
  92. package/src/architecture.ts +0 -4
@@ -11,7 +11,7 @@ var _reactNative = require("react-native");
11
11
 
12
12
  var _reactNativeReanimated = require("react-native-reanimated");
13
13
 
14
- var _animated = require("./animated");
14
+ var _hooks = require("./hooks");
15
15
 
16
16
  var _native = require("./native");
17
17
 
@@ -133,6 +133,6 @@ const useReanimatedKeyboardAnimationReplica = () => {
133
133
  };
134
134
 
135
135
  exports.useReanimatedKeyboardAnimationReplica = useReanimatedKeyboardAnimationReplica;
136
- const useGradualKeyboardAnimation = _reactNative.Platform.OS === 'ios' ? useReanimatedKeyboardAnimationReplica : _animated.useReanimatedKeyboardAnimation;
136
+ const useGradualKeyboardAnimation = _reactNative.Platform.OS === 'ios' ? useReanimatedKeyboardAnimationReplica : _hooks.useReanimatedKeyboardAnimation;
137
137
  exports.useGradualKeyboardAnimation = useGradualKeyboardAnimation;
138
138
  //# sourceMappingURL=replicas.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["availableOSEventType","Platform","OS","defaultAndroidEasing","Easing","bezier","useKeyboardAnimationReplica","height","useRef","Animated","Value","progress","animation","useMemo","current","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","listener","Keyboard","addListener","e","timing","toValue","endCoordinates","duration","easing","useNativeDriver","start","remove","IOS_SPRING_CONFIG","damping","stiffness","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","useReanimatedKeyboardAnimationReplica","useSharedValue","heightEvent","useDerivedValue","value","handler","useWorkletCallback","_height","useAnimatedReaction","_keyboardHeight","result","_previousResult","_previousKeyboardHeight","withSpring","show","runOnUI","hide","useGradualKeyboardAnimation","useReanimatedKeyboardAnimation"],"sources":["replicas.ts"],"sourcesContent":["import { useRef, useEffect, useMemo } from 'react';\nimport { Animated, Easing, Keyboard, Platform } from 'react-native';\nimport {\n runOnUI,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n useWorkletCallback,\n withSpring,\n} from 'react-native-reanimated';\nimport { useReanimatedKeyboardAnimation } from './animated';\n\nimport { AndroidSoftInputModes, KeyboardController } from './native';\n\nconst availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did';\n\n// cubic-bezier(.17,.67,.34,.94)\nexport const defaultAndroidEasing = Easing.bezier(0.4, 0.0, 0.2, 1);\ntype KeyboardAnimation = {\n progress: Animated.Value;\n height: Animated.Value;\n};\n\n/**\n * An experimental implementation of tracing keyboard appearance.\n * Switch an input mode to adjust resize mode. In this case all did* events\n * are triggering before keyboard appears, and using some approximations\n * it tries to mimicries a native transition.\n *\n * @returns {Animated.Value}\n */\nexport const useKeyboardAnimationReplica = (): KeyboardAnimation => {\n const height = useRef(new Animated.Value(0));\n const progress = useRef(new Animated.Value(0));\n const animation = useMemo(\n () => ({\n height: height.current,\n progress: progress.current,\n }),\n []\n );\n\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Show`,\n (e) => {\n Animated.timing(height.current, {\n toValue: -e.endCoordinates.height,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Hide`,\n (e) => {\n Animated.timing(height.current, {\n toValue: 0,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n\n return animation;\n};\n\nconst IOS_SPRING_CONFIG = {\n damping: 500,\n stiffness: 1000,\n mass: 3,\n overshootClamping: true,\n restDisplacementThreshold: 10,\n restSpeedThreshold: 10,\n};\n\n/**\n * A close replica to native iOS keyboard animation. The problem is that\n * iOS (unlike Android) can not fire events for each keyboard frame movement.\n * As a result we can not get gradual values (for example, for progress it always\n * will be 1 or 0). So if you want to rely on gradual values you will need to use\n * this replica.\n *\n * The transition is hardcoded and may vary from one to another OS versions. But it\n * seems like last time it has been changed in iOS 7. Since RN supports at least iOS\n * 11 it doesn't make sense to replicate iOS 7 behavior. If it changes in next OS\n * versions, then this implementation should be revisited and reflect necessary changes.\n *\n * @returns {height, progress} - animated values\n */\nexport const useReanimatedKeyboardAnimationReplica = () => {\n const height = useSharedValue(0);\n const heightEvent = useSharedValue(0);\n\n const progress = useDerivedValue(() => height.value / heightEvent.value);\n\n const handler = useWorkletCallback((_height: number) => {\n heightEvent.value = _height;\n }, []);\n\n useAnimatedReaction(\n () => ({\n _keyboardHeight: heightEvent.value,\n }),\n (result, _previousResult) => {\n const { _keyboardHeight } = result;\n const _previousKeyboardHeight = _previousResult?._keyboardHeight;\n\n if (_keyboardHeight !== _previousKeyboardHeight) {\n height.value = withSpring(_keyboardHeight, IOS_SPRING_CONFIG);\n }\n },\n []\n );\n\n useEffect(() => {\n const show = Keyboard.addListener('keyboardWillShow', (e) => {\n runOnUI(handler)(-e.endCoordinates.height);\n });\n const hide = Keyboard.addListener('keyboardWillHide', () => {\n runOnUI(handler)(0);\n });\n\n return () => {\n show.remove();\n hide.remove();\n };\n }, []);\n\n return { height, progress };\n};\n\nexport const useGradualKeyboardAnimation =\n Platform.OS === 'ios'\n ? useReanimatedKeyboardAnimationReplica\n : useReanimatedKeyboardAnimation;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAQA;;AAEA;;AAEA,MAAMA,oBAAoB,GAAGC,qBAAA,CAASC,EAAT,KAAgB,KAAhB,GAAwB,MAAxB,GAAiC,KAA9D,C,CAEA;;AACO,MAAMC,oBAAoB,GAAGC,mBAAA,CAAOC,MAAP,CAAc,GAAd,EAAmB,GAAnB,EAAwB,GAAxB,EAA6B,CAA7B,CAA7B;;;;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,2BAA2B,GAAG,MAAyB;EAClE,MAAMC,MAAM,GAAG,IAAAC,aAAA,EAAO,IAAIC,qBAAA,CAASC,KAAb,CAAmB,CAAnB,CAAP,CAAf;EACA,MAAMC,QAAQ,GAAG,IAAAH,aAAA,EAAO,IAAIC,qBAAA,CAASC,KAAb,CAAmB,CAAnB,CAAP,CAAjB;EACA,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AS,iCAAA,EAAWJ,eAAX,EAA4BhB,iBAA5B,CAAf;IACD;EACF,CAXH,EAYE,EAZF;EAeA,IAAAlB,gBAAA,EAAU,MAAM;IACd,MAAMuC,IAAI,GAAGhC,qBAAA,CAASC,WAAT,CAAqB,kBAArB,EAA0CC,CAAD,IAAO;MAC3D,IAAA+B,8BAAA,EAAQV,OAAR,EAAiB,CAACrB,CAAC,CAACG,cAAF,CAAiBpB,MAAnC;IACD,CAFY,CAAb;;IAGA,MAAMiD,IAAI,GAAGlC,qBAAA,CAASC,WAAT,CAAqB,kBAArB,EAAyC,MAAM;MAC1D,IAAAgC,8BAAA,EAAQV,OAAR,EAAiB,CAAjB;IACD,CAFY,CAAb;;IAIA,OAAO,MAAM;MACXS,IAAI,CAACtB,MAAL;MACAwB,IAAI,CAACxB,MAAL;IACD,CAHD;EAID,CAZD,EAYG,EAZH;EAcA,OAAO;IAAEzB,MAAF;IAAUI;EAAV,CAAP;AACD,CAxCM;;;AA0CA,MAAM8C,2BAA2B,GACtCxD,qBAAA,CAASC,EAAT,KAAgB,KAAhB,GACIsC,qCADJ,GAEIkB,wCAHC"}
1
+ {"version":3,"names":["availableOSEventType","Platform","OS","defaultAndroidEasing","Easing","bezier","useKeyboardAnimationReplica","height","useRef","Animated","Value","progress","animation","useMemo","current","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","listener","Keyboard","addListener","e","timing","toValue","endCoordinates","duration","easing","useNativeDriver","start","remove","IOS_SPRING_CONFIG","damping","stiffness","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","useReanimatedKeyboardAnimationReplica","useSharedValue","heightEvent","useDerivedValue","value","handler","useWorkletCallback","_height","useAnimatedReaction","_keyboardHeight","result","_previousResult","_previousKeyboardHeight","withSpring","show","runOnUI","hide","useGradualKeyboardAnimation","useReanimatedKeyboardAnimation"],"sources":["replicas.ts"],"sourcesContent":["import { useRef, useEffect, useMemo } from 'react';\nimport { Animated, Easing, Keyboard, Platform } from 'react-native';\nimport {\n runOnUI,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n useWorkletCallback,\n withSpring,\n} from 'react-native-reanimated';\nimport { useReanimatedKeyboardAnimation } from './hooks';\n\nimport { AndroidSoftInputModes, KeyboardController } from './native';\n\nconst availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did';\n\n// cubic-bezier(.17,.67,.34,.94)\nexport const defaultAndroidEasing = Easing.bezier(0.4, 0.0, 0.2, 1);\ntype KeyboardAnimation = {\n progress: Animated.Value;\n height: Animated.Value;\n};\n\n/**\n * An experimental implementation of tracing keyboard appearance.\n * Switch an input mode to adjust resize mode. In this case all did* events\n * are triggering before keyboard appears, and using some approximations\n * it tries to mimicries a native transition.\n *\n * @returns {Animated.Value}\n */\nexport const useKeyboardAnimationReplica = (): KeyboardAnimation => {\n const height = useRef(new Animated.Value(0));\n const progress = useRef(new Animated.Value(0));\n const animation = useMemo(\n () => ({\n height: height.current,\n progress: progress.current,\n }),\n []\n );\n\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Show`,\n (e) => {\n Animated.timing(height.current, {\n toValue: -e.endCoordinates.height,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Hide`,\n (e) => {\n Animated.timing(height.current, {\n toValue: 0,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n\n return animation;\n};\n\nconst IOS_SPRING_CONFIG = {\n damping: 500,\n stiffness: 1000,\n mass: 3,\n overshootClamping: true,\n restDisplacementThreshold: 10,\n restSpeedThreshold: 10,\n};\n\n/**\n * A close replica to native iOS keyboard animation. The problem is that\n * iOS (unlike Android) can not fire events for each keyboard frame movement.\n * As a result we can not get gradual values (for example, for progress it always\n * will be 1 or 0). So if you want to rely on gradual values you will need to use\n * this replica.\n *\n * The transition is hardcoded and may vary from one to another OS versions. But it\n * seems like last time it has been changed in iOS 7. Since RN supports at least iOS\n * 11 it doesn't make sense to replicate iOS 7 behavior. If it changes in next OS\n * versions, then this implementation should be revisited and reflect necessary changes.\n *\n * @returns {height, progress} - animated values\n */\nexport const useReanimatedKeyboardAnimationReplica = () => {\n const height = useSharedValue(0);\n const heightEvent = useSharedValue(0);\n\n const progress = useDerivedValue(() => height.value / heightEvent.value);\n\n const handler = useWorkletCallback((_height: number) => {\n heightEvent.value = _height;\n }, []);\n\n useAnimatedReaction(\n () => ({\n _keyboardHeight: heightEvent.value,\n }),\n (result, _previousResult) => {\n const { _keyboardHeight } = result;\n const _previousKeyboardHeight = _previousResult?._keyboardHeight;\n\n if (_keyboardHeight !== _previousKeyboardHeight) {\n height.value = withSpring(_keyboardHeight, IOS_SPRING_CONFIG);\n }\n },\n []\n );\n\n useEffect(() => {\n const show = Keyboard.addListener('keyboardWillShow', (e) => {\n runOnUI(handler)(-e.endCoordinates.height);\n });\n const hide = Keyboard.addListener('keyboardWillHide', () => {\n runOnUI(handler)(0);\n });\n\n return () => {\n show.remove();\n hide.remove();\n };\n }, []);\n\n return { height, progress };\n};\n\nexport const useGradualKeyboardAnimation =\n Platform.OS === 'ios'\n ? useReanimatedKeyboardAnimationReplica\n : useReanimatedKeyboardAnimation;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAQA;;AAEA;;AAEA,MAAMA,oBAAoB,GAAGC,qBAAA,CAASC,EAAT,KAAgB,KAAhB,GAAwB,MAAxB,GAAiC,KAA9D,C,CAEA;;AACO,MAAMC,oBAAoB,GAAGC,mB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AoBG,OAApB;EACD,CAFe,EAEb,EAFa,CAAhB;EAIA,IAAAC,0CAAA,EACE,OAAO;IACLC,eAAe,EAAEP,WAAW,CAACE;EADxB,CAAP,CADF,EAIE,CAACM,MAAD,EAASC,eAAT,KAA6B;IAC3B,MAAM;MAAEF;IAAF,IAAsBC,MAA5B;;IACA,MAAME,uBAAuB,GAAGD,eAAH,aAAGA,eAAH,uBAAGA,eAAe,CAAEF,eAAjD;;IAEA,IAAIA,eAAe,KAAKG,uBAAxB,EAAiD;MAC/C7C,MAAM,CAACqC,KAAP,GAAe,IAAAS,iCAAA,EAAWJ,eAAX,EAA4BhB,iBAA5B,CAAf;IACD;EACF,CAXH,EAYE,EAZF;EAeA,IAAAlB,gBAAA,EAAU,MAAM;IACd,MAAMuC,IAAI,GAAGhC,qBAAA,CAASC,WAAT,CAAqB,kBAArB,EAA0CC,CAAD,IAAO;MAC3D,IAAA+B,8BAAA,EAAQV,OAAR,EAAiB,CAACrB,CAAC,CAACG,cAAF,CAAiBpB,MAAnC;IACD,CAFY,CAAb;;IAGA,MAAMiD,IAAI,GAAGlC,qBAAA,CAASC,WAAT,CAAqB,kBAArB,EAAyC,MAAM;MAC1D,IAAAgC,8BAAA,EAAQV,OAAR,EAAiB,CAAjB;IACD,CAFY,CAAb;;IAIA,OAAO,MAAM;MACXS,IAAI,CAACtB,MAAL;MACAwB,IAAI,CAACxB,MAAL;IACD,CAHD;EAID,CAZD,EAYG,EAZH;EAcA,OAAO;IAAEzB,MAAF;IAAUI;EAAV,CAAP;AACD,CAxCM;;;AA0CA,MAAM8C,2BAA2B,GACtCxD,qBAAA,CAASC,EAAT,KAAgB,KAAhB,GACIsC,qCADJ,GAEIkB,qCAHC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { NativeSyntheticEvent, ViewProps } from 'react-native';\n\n// DirectEventHandler events declaration\n\nexport type NativeEvent = {\n progress: number;\n height: number;\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\n\nexport type KeyboardControllerProps = {\n onKeyboardMove: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;\n // fake prop used to activate reanimated bindings\n onKeyboardMoveReanimated: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n statusBarTranslucent?: boolean;\n} & ViewProps;\n\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n\n// Event module declarations\n\nexport type KeyboardControllerEvents =\n | 'keyboardWillShow'\n | 'keyboardDidShow'\n | 'keyboardWillHide'\n | 'keyboardDidHide';\nexport type KeyboardEventData = {\n height: number;\n};\n"],"mappings":""}
@@ -1,52 +1,10 @@
1
- import React, { useContext, useMemo, useRef } from 'react';
1
+ import React, { useMemo, useRef } from 'react';
2
2
  import { Animated, StyleSheet } from 'react-native';
3
- import Reanimated, { useEvent, useHandler, useSharedValue } from 'react-native-reanimated';
4
- import { KeyboardControllerView, useResizeMode } from './native';
3
+ import Reanimated, { useSharedValue } from 'react-native-reanimated';
4
+ import { KeyboardContext } from './context';
5
+ import { useAnimatedKeyboardHandler } from './internal';
6
+ import { KeyboardControllerView } from './native';
5
7
  const KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(Animated.createAnimatedComponent(KeyboardControllerView));
6
- const defaultContext = {
7
- animated: {
8
- progress: new Animated.Value(0),
9
- height: new Animated.Value(0)
10
- },
11
- reanimated: {
12
- progress: {
13
- value: 0
14
- },
15
- height: {
16
- value: 0
17
- }
18
- }
19
- };
20
- export const KeyboardContext = /*#__PURE__*/React.createContext(defaultContext);
21
- export const useKeyboardAnimation = () => {
22
- useResizeMode();
23
- const context = useContext(KeyboardContext);
24
- return context.animated;
25
- };
26
- export const useReanimatedKeyboardAnimation = () => {
27
- useResizeMode();
28
- const context = useContext(KeyboardContext);
29
- return context.reanimated;
30
- };
31
-
32
- function useAnimatedKeyboardHandler(handlers, dependencies) {
33
- const {
34
- context,
35
- doDependenciesDiffer
36
- } = useHandler(handlers, dependencies);
37
- return useEvent(event => {
38
- 'worklet';
39
-
40
- const {
41
- onKeyboardMove
42
- } = handlers;
43
-
44
- if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
45
- onKeyboardMove(event, context);
46
- }
47
- }, ['onKeyboardMove'], doDependenciesDiffer);
48
- }
49
-
50
8
  export const styles = StyleSheet.create({
51
9
  container: {
52
10
  flex: 1
@@ -61,10 +19,13 @@ export const KeyboardProvider = _ref => {
61
19
  children,
62
20
  statusBarTranslucent
63
21
  } = _ref;
22
+ // animated values
64
23
  const progress = useRef(new Animated.Value(0)).current;
65
- const height = useRef(new Animated.Value(0)).current;
24
+ const height = useRef(new Animated.Value(0)).current; // shared values
25
+
66
26
  const progressSV = useSharedValue(0);
67
- const heightSV = useSharedValue(0);
27
+ const heightSV = useSharedValue(0); // memo
28
+
68
29
  const context = useMemo(() => ({
69
30
  animated: {
70
31
  progress: progress,
@@ -89,7 +50,8 @@ export const KeyboardProvider = _ref => {
89
50
  }
90
51
  }], {
91
52
  useNativeDriver: true
92
- }), []);
53
+ }), []); // handlers
54
+
93
55
  const handler = useAnimatedKeyboardHandler({
94
56
  onKeyboardMove: event => {
95
57
  'worklet';
@@ -1 +1 @@
1
- {"version":3,"names":["React","useContext","useMemo","useRef","Animated","StyleSheet","Reanimated","useEvent","useHandler","useSharedValue","KeyboardControllerView","useResizeMode","KeyboardControllerViewAnimated","createAnimatedComponent","defaultContext","animated","progress","Value","height","reanimated","value","KeyboardContext","createContext","useKeyboardAnimation","context","useReanimatedKeyboardAnimation","useAnimatedKeyboardHandler","handlers","dependencies","doDependenciesDiffer","event","onKeyboardMove","eventName","endsWith","styles","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","current","progressSV","heightSV","style","transform","translateX","translateY","nativeEvent","useNativeDriver","handler"],"sources":["animated.tsx"],"sourcesContent":["import React, { useContext, useMemo, useRef } from 'react';\nimport { Animated, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, {\n useEvent,\n useHandler,\n useSharedValue,\n} from 'react-native-reanimated';\nimport {\n EventWithName,\n KeyboardControllerProps,\n KeyboardControllerView,\n NativeEvent,\n useResizeMode,\n} from './native';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype AnimatedContext = {\n progress: Animated.Value;\n height: Animated.Value;\n};\ntype ReanimatedContext = {\n progress: Reanimated.SharedValue<number>;\n height: Reanimated.SharedValue<number>;\n};\ntype KeyboardAnimationContext = {\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n};\nconst defaultContext: KeyboardAnimationContext = {\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: { value: 0 },\n height: { value: 0 },\n },\n};\nexport const KeyboardContext = React.createContext(defaultContext);\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.reanimated;\n};\n\nfunction useAnimatedKeyboardHandler<TContext extends Record<string, unknown>>(\n handlers: {\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: ReadonlyArray<unknown>\n) {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event: EventWithName<NativeEvent>) => {\n 'worklet';\n const { onKeyboardMove } = handlers;\n\n if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {\n onKeyboardMove(event, context);\n }\n },\n ['onKeyboardMove'],\n doDependenciesDiffer\n );\n}\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nexport const 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 * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n}: KeyboardProviderProps) => {\n const progress = useRef(new Animated.Value(0)).current;\n const height = useRef(new Animated.Value(0)).current;\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: height },\n reanimated: { progress: progressSV, height: heightSV },\n }),\n []\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n\n const handler = useAnimatedKeyboardHandler(\n {\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n progressSV.value = event.progress;\n heightSV.value = event.height;\n },\n },\n []\n );\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMove={onKeyboardMove}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n >\n <>\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 {children}\n </>\n </KeyboardControllerViewAnimated>\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,OAA5B,EAAqCC,MAArC,QAAmD,OAAnD;AACA,SAASC,QAAT,EAAmBC,UAAnB,QAAgD,cAAhD;AACA,OAAOC,UAAP,IACEC,QADF,EAEEC,UAFF,EAGEC,cAHF,QAIO,yBAJP;AAKA,SAGEC,sBAHF,EAKEC,aALF,QAMO,UANP;AAQA,MAAMC,8BAA8B,GAAGN,UAAU,CAACO,uBAAX,CACrCT,QAAQ,CAACS,uBAAT,CACEH,sBADF,CADqC,CAAvC;AAkBA,MAAMI,cAAwC,GAAG;EAC/CC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIZ,QAAQ,CAACa,KAAb,CAAmB,CAAnB,CADF;IAERC,MAAM,EAAE,IAAId,QAAQ,CAACa,KAAb,CAAmB,CAAnB;EAFA,CADqC;EAK/CE,UAAU,EAAE;IACVH,QAAQ,EAAE;MAAEI,KAAK,EAAE;IAAT,CADA;IAEVF,MAAM,EAAE;MAAEE,KAAK,EAAE;IAAT;EAFE;AALmC,CAAjD;AAUA,OAAO,MAAMC,eAAe,gBAAGrB,KAAK,CAACsB,aAAN,CAAoBR,cAApB,CAAxB;AAEP,OAAO,MAAMS,oBAAoB,GAAG,MAAuB;EACzDZ,aAAa;EACb,MAAMa,OAAO,GAAGvB,UAAU,CAACoB,eAAD,CAA1B;EAEA,OAAOG,OAAO,CAACT,QAAf;AACD,CALM;AAOP,OAAO,MAAMU,8BAA8B,GAAG,MAAyB;EACrEd,aAAa;EACb,MAAMa,OAAO,GAAGvB,UAAU,CAACoB,eAAD,CAA1B;EAEA,OAAOG,OAAO,CAACL,UAAf;AACD,CALM;;AAOP,SAASO,0BAAT,CACEC,QADF,EAIEC,YAJF,EAKE;EACA,MAAM;IAAEJ,OAAF;IAAWK;EAAX,IAAoCrB,UAAU,CAACmB,QAA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CAACI,MADH,EAEJ;IAAEU,SAAS,EAAE,CAAC;MAAEC,UAAU,EAAE/B;IAAd,CAAD,EAAyB;MAAEgC,UAAU,EAAElC;IAAd,CAAzB;EAAb,CAFI,CADa,EAKnB,EALmB,CAArB;EAQA,MAAMe,cAAc,GAAG7B,OAAO,CAC5B,MACEE,QAAQ,CAAC0B,KAAT,CACE,CACE;IACEqB,WAAW,EAAE;MACXnC,QADW;MAEXE;IAFW;EADf,CADF,CADF,EASE;IAAEkC,eAAe,EAAE;EAAnB,CATF,CAF0B,EAa5B,EAb4B,CAA9B;EAgBA,MAAMC,OAAO,GAAG3B,0BAA0B,CACxC;IACEK,cAAc,EAAGD,KAAD,IAAwB;MACtC;;MACAe,UAAU,CAACzB,KAAX,GAAmBU,KAAK,CAACd,QAAzB;MACA8B,QAAQ,CAAC1B,KAAT,GAAiBU,KAAK,CAACZ,MAAvB;IACD;EALH,CADwC,EAQxC,EARwC,CAA1C;EAWA,oBACE,oBAAC,eAAD,CAAiB,QAAjB;IAA0B,KAAK,EAAEM;EAAjC,gBACE,oBAAC,8BAAD;IACE,wBAAwB,EAAE6B,OAD5B;IAEE,cAAc,EAAEtB,cAFlB;IAGE,oBAAoB,EAAEY,oBAHxB;IAIE,KAAK,EAAET,MAAM,CAACE;EAJhB,gBAME,uDACE,oBAAC,QAAD,CAAU,IAAV;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEW;EATT,EADF,EAYGL,QAZH,CANF,CADF,CADF;AAyBD,CA3EM"}
1
+ {"version":3,"names":["React","useMemo","useRef","Animated","StyleSheet","Reanimated","useSharedValue","KeyboardContext","useAnimatedKeyboardHandler","KeyboardControllerView","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","progress","Value","current","height","progressSV","heightSV","context","animated","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","handler","value"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { Animated, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport { useAnimatedKeyboardHandler } from './internal';\nimport { KeyboardControllerView } from './native';\n\nimport type { KeyboardControllerProps, NativeEvent } from './types';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nexport const 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 * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n}: KeyboardProviderProps) => {\n // animated values\n const progress = useRef(new Animated.Value(0)).current;\n const height = useRef(new Animated.Value(0)).current;\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n // memo\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: height },\n reanimated: { progress: progressSV, height: heightSV },\n }),\n []\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 { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const handler = useAnimatedKeyboardHandler(\n {\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n progressSV.value = event.progress;\n heightSV.value = event.height;\n },\n },\n []\n );\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMove={onKeyboardMove}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n >\n <>\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 {children}\n </>\n </KeyboardControllerViewAnimated>\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,OAAhB,EAAyBC,MAAzB,QAAuC,OAAvC;AACA,SAASC,QAAT,EAAmBC,UAAnB,QAAgD,cAAhD;AACA,OAAOC,UAAP,IAAqBC,cAArB,QAA2C,yBAA3C;AAEA,SAASC,eAAT,QAAgC,WAAhC;AACA,SAASC,0BAAT,QAA2C,YAA3C;AACA,SAASC,sBAAT,QAAuC,UAAvC;AAIA,MAAMC,8BAA8B,GAAGL,UAAU,CAACM,uBAAX,CACrCR,QAAQ,CAACQ,uBAAT,CACEF,sBADF,CADqC,CAAvC;AAWA,OAAO,MAAMG,MAAM,GAAGR,UAAU,CAACS,MAAX,CAA0B;EAC9CC,SAAS,EAAE;IACTC,IAAI,EAAE;EADG,CADmC;EAI9CC,MAAM,EAAE;IACNC,OAAO,EAAE,MADH;IAENC,QAAQ,EAAE;EAFJ;AAJsC,CAA1B,CAAf;AAwBP,OAAO,MAAMC,gBAAgB,GAAG,QAGH;EAAA,IAHI;IAC/BC,QAD+B;IAE/BC;EAF+B,CAGJ;EAC3B;EACA,MAAMC,QAAQ,GAAGpB,MAAM,CAAC,IAAIC,QAAQ,CAACoB,KAAb,CAAmB,CAAnB,CAAD,CAAN,CAA8BC,OAA/C;EACA,MAAMC,MAAM,GAAGvB,MAAM,CAAC,IAAIC,QAAQ,C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,oBAAoB,EAAEd,oBAHxB;IAIE,KAAK,EAAET,MAAM,CAACE;EAJhB,gBAME,uDACE,oBAAC,QAAD,CAAU,IAAV;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEiB;EATT,EADF,EAYGX,QAZH,CANF,CADF,CADF;AAyBD,CA7EM"}
@@ -0,0 +1,18 @@
1
+ import { createContext } from 'react';
2
+ import { Animated } from 'react-native';
3
+ const defaultContext = {
4
+ animated: {
5
+ progress: new Animated.Value(0),
6
+ height: new Animated.Value(0)
7
+ },
8
+ reanimated: {
9
+ progress: {
10
+ value: 0
11
+ },
12
+ height: {
13
+ value: 0
14
+ }
15
+ }
16
+ };
17
+ export const KeyboardContext = /*#__PURE__*/createContext(defaultContext);
18
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","Animated","defaultContext","animated","progress","Value","height","reanimated","value","KeyboardContext"],"sources":["context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\n\nimport type { SharedValue } from 'react-native-reanimated';\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.Value;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n};\nconst defaultContext: KeyboardAnimationContext = {\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: { value: 0 },\n height: { value: 0 },\n },\n};\nexport const KeyboardContext = createContext(defaultContext);\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;AAgBA,MAAMC,cAAwC,GAAG;EAC/CC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIH,QAAQ,CAACI,KAAb,CAAmB,CAAnB,CADF;IAERC,MAAM,EAAE,IAAIL,QAAQ,CAACI,KAAb,CAAmB,CAAnB;EAFA,CADqC;EAK/CE,UAAU,EAAE;IACVH,QAAQ,EAAE;MAAEI,KAAK,EAAE;IAAT,CADA;IAEVF,MAAM,EAAE;MAAEE,KAAK,EAAE;IAAT;EAFE;AALmC,CAAjD;AAUA,OAAO,MAAMC,eAAe,gBAAGT,aAAa,CAACE,cAAD,CAArC"}
@@ -0,0 +1,20 @@
1
+ import { useContext, useEffect } from 'react';
2
+ import { KeyboardContext } from './context';
3
+ import { AndroidSoftInputModes, KeyboardController } from './native';
4
+ export const useResizeMode = () => {
5
+ useEffect(() => {
6
+ KeyboardController.setInputMode(AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
7
+ return () => KeyboardController.setDefaultMode();
8
+ }, []);
9
+ };
10
+ export const useKeyboardAnimation = () => {
11
+ useResizeMode();
12
+ const context = useContext(KeyboardContext);
13
+ return context.animated;
14
+ };
15
+ export const useReanimatedKeyboardAnimation = () => {
16
+ useResizeMode();
17
+ const context = useContext(KeyboardContext);
18
+ return context.reanimated;
19
+ };
20
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useContext","useEffect","KeyboardContext","AndroidSoftInputModes","KeyboardController","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated"],"sources":["hooks.ts"],"sourcesContent":["import { useContext, useEffect } from 'react';\n\nimport { AnimatedContext, KeyboardContext, ReanimatedContext } from './context';\nimport { AndroidSoftInputModes, KeyboardController } from './native';\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.reanimated;\n};\n"],"mappings":"AAAA,SAASA,UAAT,EAAqBC,SAArB,QAAsC,OAAtC;AAEA,SAA0BC,eAA1B,QAAoE,WAApE;AACA,SAASC,qBAAT,EAAgCC,kBAAhC,QAA0D,UAA1D;AAEA,OAAO,MAAMC,aAAa,GAAG,MAAM;EACjCJ,SAAS,CAAC,MAAM;IACdG,kBAAkB,CAACE,YAAnB,CACEH,qBAAqB,CAACI,wBADxB;IAIA,OAAO,MAAMH,kBAAkB,CAACI,cAAnB,EAAb;EACD,CANQ,EAMN,EANM,CAAT;AAOD,CARM;AAUP,OAAO,MAAMC,oBAAoB,GAAG,MAAuB;EACzDJ,aAAa;EACb,MAAMK,OAAO,GAAGV,UAAU,CAACE,eAAD,CAA1B;EAEA,OAAOQ,OAAO,CAACC,QAAf;AACD,CALM;AAOP,OAAO,MAAMC,8BAA8B,GAAG,MAAyB;EACrEP,aAAa;EACb,MAAMK,OAAO,GAAGV,UAAU,CAACE,eAAD,CAA1B;EAEA,OAAOQ,OAAO,CAACG,UAAf;AACD,CALM"}
@@ -2,4 +2,7 @@ import './monkey-patch';
2
2
  export * from './native';
3
3
  export * from './animated';
4
4
  export * from './replicas';
5
+ export * from './context';
6
+ export * from './hooks';
7
+ export * from './types';
5
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './native';\nexport * from './animated';\nexport * from './replicas';\n"],"mappings":"AAAA,OAAO,gBAAP;AAEA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,YAAd"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './native';\nexport * from './animated';\nexport * from './replicas';\nexport * from './context';\nexport * from './hooks';\nexport * from './types';\n"],"mappings":"AAAA,OAAO,gBAAP;AAEA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,YAAd;AACA,cAAc,WAAd;AACA,cAAc,SAAd;AACA,cAAc,SAAd"}
@@ -0,0 +1,19 @@
1
+ import { useEvent, useHandler } from 'react-native-reanimated';
2
+ export function useAnimatedKeyboardHandler(handlers, dependencies) {
3
+ const {
4
+ context,
5
+ doDependenciesDiffer
6
+ } = useHandler(handlers, dependencies);
7
+ return useEvent(event => {
8
+ 'worklet';
9
+
10
+ const {
11
+ onKeyboardMove
12
+ } = handlers;
13
+
14
+ if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
15
+ onKeyboardMove(event, context);
16
+ }
17
+ }, ['onKeyboardMove'], doDependenciesDiffer);
18
+ }
19
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEvent","useHandler","useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","event","onKeyboardMove","eventName","endsWith"],"sources":["internal.ts"],"sourcesContent":["import { useEvent, useHandler } from 'react-native-reanimated';\n\nimport type { EventWithName, NativeEvent } from './types';\n\nexport function useAnimatedKeyboardHandler<\n TContext extends Record<string, unknown>\n>(\n handlers: {\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: ReadonlyArray<unknown>\n) {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event: EventWithName<NativeEvent>) => {\n 'worklet';\n const { onKeyboardMove } = handlers;\n\n if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {\n onKeyboardMove(event, context);\n }\n },\n ['onKeyboardMove'],\n doDependenciesDiffer\n );\n}\n"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,UAAnB,QAAqC,yBAArC;AAIA,OAAO,SAASC,0BAAT,CAGLC,QAHK,EAMLC,YANK,EAOL;EACA,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAoCL,UAAU,CAACE,QAAD,EAAWC,YAAX,CAApD;EAEA,OAAOJ,QAAQ,CACZO,KAAD,IAAuC;IACrC;;IACA,MAAM;MAAEC;IAAF,IAAqBL,QAA3B;;IAEA,IAAIK,cAAc,IAAID,KAAK,CAACE,SAAN,CAAgBC,QAAhB,CAAyB,gBAAzB,CAAtB,EAAkE;MAChEF,cAAc,CAACD,KAAD,EAAQF,OAAR,CAAd;IACD;EACF,CARY,EASb,CAAC,gBAAD,CATa,EAUbC,oBAVa,CAAf;AAYD"}
@@ -1,12 +1,13 @@
1
- import { NativeModules, Platform } from 'react-native'; // @ts-expect-error because there is no corresponding type definition
1
+ import { Platform } from 'react-native'; // @ts-expect-error because there is no corresponding type definition
2
2
 
3
3
  import * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';
4
- import { isTurboModuleEnabled } from './architecture';
5
4
  const getConstants = NativeAndroidManager.default.getConstants;
6
- const RCTStatusBarManagerCompat = isTurboModuleEnabled ? require('./NativeStatusBarManagerCompat').default : NativeModules.StatusBarManagerCompat; // On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
5
+
6
+ const RCTStatusBarManagerCompat = require('./specs/NativeStatusBarManagerCompat').default; // On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
7
7
  // in order to use library on all available platforms we have to monkey patch
8
8
  // default RN implementation and use modern `WindowInsetsControllerCompat`.
9
9
 
10
+
10
11
  if (Platform.OS === 'android') {
11
12
  NativeAndroidManager.default = {
12
13
  getConstants,
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","NativeAndroidManager","isTurboModuleEnabled","getConstants","default","RCTStatusBarManagerCompat","require","StatusBarManagerCompat","OS","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden"],"sources":["monkey-patch.tsx"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\n// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';\n\nimport { isTurboModuleEnabled } from './architecture';\n\nconst getConstants = NativeAndroidManager.default.getConstants;\n\nconst RCTStatusBarManagerCompat = isTurboModuleEnabled\n ? require('./NativeStatusBarManagerCompat').default\n : NativeModules.StatusBarManagerCompat;\n\n// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so\n// in order to use library on all available platforms we have to monkey patch\n// default RN implementation and use modern `WindowInsetsControllerCompat`.\nif (Platform.OS === 'android') {\n NativeAndroidManager.default = {\n getConstants,\n setColor(color: number, animated: boolean): void {\n RCTStatusBarManagerCompat.setColor(color, animated);\n },\n\n setTranslucent(translucent: boolean): void {\n RCTStatusBarManagerCompat.setTranslucent(translucent);\n },\n\n /**\n * - statusBarStyles can be:\n * - 'default'\n * - 'dark-content'\n */\n setStyle(statusBarStyle?: string): void {\n RCTStatusBarManagerCompat.setStyle(statusBarStyle);\n },\n\n setHidden(hidden: boolean): void {\n RCTStatusBarManagerCompat.setHidden(hidden);\n },\n };\n}\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC,C,CACA;;AACA,OAAO,KAAKC,oBAAZ,MAAsC,2EAAtC;AAEA,SAASC,oBAAT,QAAqC,gBAArC;AAEA,MAAMC,YAAY,GAAGF,oBAAoB,CAACG,OAArB,CAA6BD,YAAlD;AAEA,MAAME,yBAAyB,GAAGH,oBAAoB,GAClDI,OAAO,CAAC,gCAAD,CAAP,CAA0CF,OADQ,GAElDL,aAAa,CAACQ,sBAFlB,C,CAIA;AACA;AACA;;AACA,IAAIP,QAAQ,CAACQ,EAAT,KAAgB,SAApB,EAA+B;EAC7BP,oBAAoB,CAACG,OAArB,GAA+B;IAC7BD,YAD6B;;IAE7BM,QAAQ,CAACC,KAAD,EAAgBC,QAAhB,EAAyC;MAC/CN,yBAAyB,CAACI,QAA1B,CAAmCC,KAAnC,EAA0CC,QAA1C;IACD,CAJ4B;;IAM7BC,cAAc,CAACC,WAAD,EAA6B;MACzCR,yBAAyB,CAACO,cAA1B,CAAyCC,WAAzC;IACD,CAR4B;;IAU7B;AACJ;AACA;AACA;AACA;IACIC,QAAQ,CAACC,cAAD,EAAgC;MACtCV,yBAAyB,CAACS,QAA1B,CAAmCC,cAAnC;IACD,CAjB4B;;IAmB7BC,SAAS,CAACC,MAAD,EAAwB;MAC/BZ,yBAAyB,CAACW,SAA1B,CAAoCC,MAApC;IACD;;EArB4B,CAA/B;AAuBD"}
1
+ {"version":3,"names":["Platform","NativeAndroidManager","getConstants","default","RCTStatusBarManagerCompat","require","OS","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden"],"sources":["monkey-patch.ts"],"sourcesContent":["import { Platform } from 'react-native';\n// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';\n\nconst getConstants = NativeAndroidManager.default.getConstants;\n\nconst RCTStatusBarManagerCompat =\n require('./specs/NativeStatusBarManagerCompat').default;\n\n// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so\n// in order to use library on all available platforms we have to monkey patch\n// default RN implementation and use modern `WindowInsetsControllerCompat`.\nif (Platform.OS === 'android') {\n NativeAndroidManager.default = {\n getConstants,\n setColor(color: number, animated: boolean): void {\n RCTStatusBarManagerCompat.setColor(color, animated);\n },\n\n setTranslucent(translucent: boolean): void {\n RCTStatusBarManagerCompat.setTranslucent(translucent);\n },\n\n /**\n * - statusBarStyles can be:\n * - 'default'\n * - 'dark-content'\n */\n setStyle(statusBarStyle?: string): void {\n RCTStatusBarManagerCompat.setStyle(statusBarStyle);\n },\n\n setHidden(hidden: boolean): void {\n RCTStatusBarManagerCompat.setHidden(hidden);\n },\n };\n}\n"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB,C,CACA;;AACA,OAAO,KAAKC,oBAAZ,MAAsC,2EAAtC;AAEA,MAAMC,YAAY,GAAGD,oBAAoB,CAACE,OAArB,CAA6BD,YAAlD;;AAEA,MAAME,yBAAyB,GAC7BC,OAAO,CAAC,sCAAD,CAAP,CAAgDF,OADlD,C,CAGA;AACA;AACA;;;AACA,IAAIH,QAAQ,CAACM,EAAT,KAAgB,SAApB,EAA+B;EAC7BL,oBAAoB,CAACE,OAArB,GAA+B;IAC7BD,YAD6B;;IAE7BK,QAAQ,CAACC,KAAD,EAAgBC,QAAhB,EAAyC;MAC/CL,yBAAyB,CAACG,QAA1B,CAAmCC,KAAnC,EAA0CC,QAA1C;IACD,CAJ4B;;IAM7BC,cAAc,CAACC,WAAD,EAA6B;MACzCP,yBAAyB,CAACM,cAA1B,CAAyCC,WAAzC;IACD,CAR4B;;IAU7B;AACJ;AACA;AACA;AACA;IACIC,QAAQ,CAACC,cAAD,EAAgC;MACtCT,yBAAyB,CAACQ,QAA1B,CAAmCC,cAAnC;IACD,CAjB4B;;IAmB7BC,SAAS,CAACC,MAAD,EAAwB;MAC/BX,yBAAyB,CAACU,SAA1B,CAAoCC,MAApC;IACD;;EArB4B,CAA/B;AAuBD"}
@@ -1,10 +1,9 @@
1
- import { useEffect } from 'react';
2
- import { requireNativeComponent, UIManager, Platform, NativeModules, NativeEventEmitter } from 'react-native';
3
- import { isFabricEnabled, isTurboModuleEnabled } from './architecture';
1
+ import { Platform, NativeEventEmitter } from 'react-native';
4
2
  const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
5
3
  ios: "- You have run 'pod install'\n",
6
4
  default: ''
7
- }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
5
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; // copied from `android.view.WindowManager.LayoutParams`
6
+
8
7
  export let AndroidSoftInputModes;
9
8
 
10
9
  (function (AndroidSoftInputModes) {
@@ -12,22 +11,29 @@ export let AndroidSoftInputModes;
12
11
  AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_PAN"] = 32] = "SOFT_INPUT_ADJUST_PAN";
13
12
  AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_RESIZE"] = 16] = "SOFT_INPUT_ADJUST_RESIZE";
14
13
  AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_UNSPECIFIED"] = 0] = "SOFT_INPUT_ADJUST_UNSPECIFIED";
14
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_IS_FORWARD_NAVIGATION"] = 256] = "SOFT_INPUT_IS_FORWARD_NAVIGATION";
15
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MASK_ADJUST"] = 240] = "SOFT_INPUT_MASK_ADJUST";
16
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MASK_STATE"] = 15] = "SOFT_INPUT_MASK_STATE";
17
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MODE_CHANGED"] = 512] = "SOFT_INPUT_MODE_CHANGED";
18
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_ALWAYS_HIDDEN"] = 3] = "SOFT_INPUT_STATE_ALWAYS_HIDDEN";
19
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_ALWAYS_VISIBLE"] = 5] = "SOFT_INPUT_STATE_ALWAYS_VISIBLE";
20
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_HIDDEN"] = 2] = "SOFT_INPUT_STATE_HIDDEN";
21
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNCHANGED"] = 1] = "SOFT_INPUT_STATE_UNCHANGED";
22
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNSPECIFIED"] = 0] = "SOFT_INPUT_STATE_UNSPECIFIED";
23
+ AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_VISIBLE"] = 4] = "SOFT_INPUT_STATE_VISIBLE";
15
24
  })(AndroidSoftInputModes || (AndroidSoftInputModes = {}));
16
25
 
17
- const ComponentName = 'KeyboardControllerView';
18
- const RCTKeyboardController = isTurboModuleEnabled ? require('./NativeKeyboardController').default : NativeModules.KeyboardController;
19
- export const KeyboardController = RCTKeyboardController;
20
- const eventEmitter = new NativeEventEmitter(RCTKeyboardController);
26
+ const RCTKeyboardController = require('./specs/NativeKeyboardController').default;
27
+
28
+ export const KeyboardController = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
29
+ get() {
30
+ throw new Error(LINKING_ERROR);
31
+ }
32
+
33
+ });
34
+ const eventEmitter = new NativeEventEmitter(KeyboardController);
21
35
  export const KeyboardEvents = {
22
36
  addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
23
37
  };
24
- export const KeyboardControllerView = isFabricEnabled ? require('./KeyboardControllerViewNativeComponent').default : UIManager.getViewManagerConfig(ComponentName) != null ? requireNativeComponent(ComponentName) : () => {
25
- throw new Error(LINKING_ERROR);
26
- };
27
- export const useResizeMode = () => {
28
- useEffect(() => {
29
- KeyboardController.setInputMode(AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
30
- return () => KeyboardController.setDefaultMode();
31
- }, []);
32
- };
38
+ export const KeyboardControllerView = require('./specs/KeyboardControllerViewNativeComponent').default;
33
39
  //# sourceMappingURL=native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","requireNativeComponent","UIManager","Platform","NativeModules","NativeEventEmitter","isFabricEnabled","isTurboModuleEnabled","LINKING_ERROR","select","ios","default","AndroidSoftInputModes","ComponentName","RCTKeyboardController","require","KeyboardController","eventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView","getViewManagerConfig","Error","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode"],"sources":["native.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport {\n requireNativeComponent,\n UIManager,\n Platform,\n NativeModules,\n NativeEventEmitter,\n NativeSyntheticEvent,\n ViewProps,\n} from 'react-native';\n\nimport { isFabricEnabled, isTurboModuleEnabled } from './architecture';\n\nconst LINKING_ERROR =\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nexport enum AndroidSoftInputModes {\n SOFT_INPUT_ADJUST_NOTHING = 48,\n SOFT_INPUT_ADJUST_PAN = 32,\n SOFT_INPUT_ADJUST_RESIZE = 16,\n SOFT_INPUT_ADJUST_UNSPECIFIED = 0,\n}\n\nexport type NativeEvent = {\n progress: number;\n height: number;\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\nexport type KeyboardControllerProps = {\n onKeyboardMove: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;\n // fake prop used to activate reanimated bindings\n onKeyboardMoveReanimated: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n statusBarTranslucent?: boolean;\n} & ViewProps;\ntype KeyboardController = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: AndroidSoftInputModes) => void;\n};\n\nconst ComponentName = 'KeyboardControllerView';\n\nconst RCTKeyboardController = isTurboModuleEnabled\n ? require('./NativeKeyboardController').default\n : NativeModules.KeyboardController;\nexport const KeyboardController = RCTKeyboardController as KeyboardController;\n\nconst eventEmitter = new NativeEventEmitter(RCTKeyboardController);\ntype KeyboardControllerEvents =\n | 'keyboardWillShow'\n | 'keyboardDidShow'\n | 'keyboardWillHide'\n | 'keyboardDidHide';\ntype KeyboardEvent = {\n height: number;\n};\nexport const KeyboardEvents = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEvent) => void\n ) => eventEmitter.addListener('KeyboardController::' + name, cb),\n};\nexport const KeyboardControllerView = isFabricEnabled\n ? require('./KeyboardControllerViewNativeComponent').default\n : UIManager.getViewManagerConfig(ComponentName) != null\n ? requireNativeComponent<KeyboardControllerProps>(ComponentName)\n : () => {\n throw new Error(LINKING_ERROR);\n };\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.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,aAAa,GAAG,MAAM;EACjCzB,SAAS,CAAC,MAAM;IACdgB,kBAAkB,CAACU,YAAnB,CACEd,qBAAqB,CAACe,wBADxB;IAIA,OAAO,MAAMX,kBAAkB,CAACY,cAAnB,EAAb;EACD,CANQ,EAMN,EANM,CAAT;AAOD,CARM"}
1
+ {"version":3,"names":["Platform","NativeEventEmitter","LINKING_ERROR","select","ios","default","AndroidSoftInputModes","RCTKeyboardController","require","KeyboardController","Proxy","get","Error","eventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView"],"sources":["native.ts"],"sourcesContent":["import { Platform, NativeEventEmitter } from 'react-native';\n\nimport type {\n KeyboardControllerEvents,\n KeyboardControllerModule,\n KeyboardEventData,\n} from './types';\n\nconst LINKING_ERROR =\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\n// copied from `android.view.WindowManager.LayoutParams`\nexport enum AndroidSoftInputModes {\n SOFT_INPUT_ADJUST_NOTHING = 48,\n SOFT_INPUT_ADJUST_PAN = 32,\n SOFT_INPUT_ADJUST_RESIZE = 16,\n SOFT_INPUT_ADJUST_UNSPECIFIED = 0,\n SOFT_INPUT_IS_FORWARD_NAVIGATION = 256,\n SOFT_INPUT_MASK_ADJUST = 240,\n SOFT_INPUT_MASK_STATE = 15,\n SOFT_INPUT_MODE_CHANGED = 512,\n SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3,\n SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5,\n SOFT_INPUT_STATE_HIDDEN = 2,\n SOFT_INPUT_STATE_UNCHANGED = 1,\n SOFT_INPUT_STATE_UNSPECIFIED = 0,\n SOFT_INPUT_STATE_VISIBLE = 4,\n}\n\nconst RCTKeyboardController =\n require('./specs/NativeKeyboardController').default;\nexport const KeyboardController = (\n RCTKeyboardController\n ? RCTKeyboardController\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n )\n) as KeyboardControllerModule;\n\nconst eventEmitter = new NativeEventEmitter(KeyboardController);\n\nexport const KeyboardEvents = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void\n ) => eventEmitter.addListener('KeyboardController::' + name, cb),\n};\nexport const KeyboardControllerView =\n require('./specs/KeyboardControllerViewNativeComponent').default;\n"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,kBAAnB,QAA6C,cAA7C;AAQA,MAAMC,aAAa,GAChB,2FAAD,GACAF,QAAQ,CAACG,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,+BAJF,C,CAMA;;AACA,WAAYC,qBAAZ;;WAAYA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,KAAAA,qB;;AAiBZ,MAAMC,qBAAqB,GACzBC,OAAO,CAAC,kCAAD,CAAP,CAA4CH,OAD9C;;AAEA,OAAO,MAAMI,kBAAkB,GAC7BF,qBAAqB,GACjBA,qBADiB,GAEjB,IAAIG,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUV,aAAV,CAAN;EACD;;AAHH,CAFF,CAHC;AAaP,MAAMW,YAAY,GAAG,IAAIZ,kBAAJ,CAAuBQ,kBAAvB,CAArB;AAEA,OAAO,MAAMK,cAAc,GAAG;EAC5BC,WAAW,EAAE,CACXC,IADW,EAEXC,EAFW,KAGRJ,YAAY,CAACE,WAAb,CAAyB,yBAAyBC,IAAlD,EAAwDC,EAAxD;AAJuB,CAAvB;AAMP,OAAO,MAAMC,sBAAsB,GACjCV,OAAO,CAAC,+CAAD,CAAP,CAAyDH,OADpD"}
@@ -1,7 +1,7 @@
1
1
  import { useRef, useEffect, useMemo } from 'react';
2
2
  import { Animated, Easing, Keyboard, Platform } from 'react-native';
3
3
  import { runOnUI, useAnimatedReaction, useDerivedValue, useSharedValue, useWorkletCallback, withSpring } from 'react-native-reanimated';
4
- import { useReanimatedKeyboardAnimation } from './animated';
4
+ import { useReanimatedKeyboardAnimation } from './hooks';
5
5
  import { AndroidSoftInputModes, KeyboardController } from './native';
6
6
  const availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did'; // cubic-bezier(.17,.67,.34,.94)
7
7
 
@@ -1 +1 @@
1
- {"version":3,"names":["useRef","useEffect","useMemo","Animated","Easing","Keyboard","Platform","runOnUI","useAnimatedReaction","useDerivedValue","useSharedValue","useWorkletCallback","withSpring","useReanimatedKeyboardAnimation","AndroidSoftInputModes","KeyboardController","availableOSEventType","OS","defaultAndroidEasing","bezier","useKeyboardAnimationReplica","height","Value","progress","animation","current","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","listener","addListener","e","timing","toValue","endCoordinates","duration","easing","useNativeDriver","start","remove","IOS_SPRING_CONFIG","damping","stiffness","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","useReanimatedKeyboardAnimationReplica","heightEvent","value","handler","_height","_keyboardHeight","result","_previousResult","_previousKeyboardHeight","show","hide","useGradualKeyboardAnimation"],"sources":["replicas.ts"],"sourcesContent":["import { useRef, useEffect, useMemo } from 'react';\nimport { Animated, Easing, Keyboard, Platform } from 'react-native';\nimport {\n runOnUI,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n useWorkletCallback,\n withSpring,\n} from 'react-native-reanimated';\nimport { useReanimatedKeyboardAnimation } from './animated';\n\nimport { AndroidSoftInputModes, KeyboardController } from './native';\n\nconst availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did';\n\n// cubic-bezier(.17,.67,.34,.94)\nexport const defaultAndroidEasing = Easing.bezier(0.4, 0.0, 0.2, 1);\ntype KeyboardAnimation = {\n progress: Animated.Value;\n height: Animated.Value;\n};\n\n/**\n * An experimental implementation of tracing keyboard appearance.\n * Switch an input mode to adjust resize mode. In this case all did* events\n * are triggering before keyboard appears, and using some approximations\n * it tries to mimicries a native transition.\n *\n * @returns {Animated.Value}\n */\nexport const useKeyboardAnimationReplica = (): KeyboardAnimation => {\n const height = useRef(new Animated.Value(0));\n const progress = useRef(new Animated.Value(0));\n const animation = useMemo(\n () => ({\n height: height.current,\n progress: progress.current,\n }),\n []\n );\n\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Show`,\n (e) => {\n Animated.timing(height.current, {\n toValue: -e.endCoordinates.height,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Hide`,\n (e) => {\n Animated.timing(height.current, {\n toValue: 0,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n\n return animation;\n};\n\nconst IOS_SPRING_CONFIG = {\n damping: 500,\n stiffness: 1000,\n mass: 3,\n overshootClamping: true,\n restDisplacementThreshold: 10,\n restSpeedThreshold: 10,\n};\n\n/**\n * A close replica to native iOS keyboard animation. The problem is that\n * iOS (unlike Android) can not fire events for each keyboard frame movement.\n * As a result we can not get gradual values (for example, for progress it always\n * will be 1 or 0). So if you want to rely on gradual values you will need to use\n * this replica.\n *\n * The transition is hardcoded and may vary from one to another OS versions. But it\n * seems like last time it has been changed in iOS 7. Since RN supports at least iOS\n * 11 it doesn't make sense to replicate iOS 7 behavior. If it changes in next OS\n * versions, then this implementation should be revisited and reflect necessary changes.\n *\n * @returns {height, progress} - animated values\n */\nexport const useReanimatedKeyboardAnimationReplica = () => {\n const height = useSharedValue(0);\n const heightEvent = useSharedValue(0);\n\n const progress = useDerivedValue(() => height.value / heightEvent.value);\n\n const handler = useWorkletCallback((_height: number) => {\n heightEvent.value = _height;\n }, []);\n\n useAnimatedReaction(\n () => ({\n _keyboardHeight: heightEvent.value,\n }),\n (result, _previousResult) => {\n const { _keyboardHeight } = result;\n const _previousKeyboardHeight = _previousResult?._keyboardHeight;\n\n if (_keyboardHeight !== _previousKeyboardHeight) {\n height.value = withSpring(_keyboardHeight, IOS_SPRING_CONFIG);\n }\n },\n []\n );\n\n useEffect(() => {\n const show = Keyboard.addListener('keyboardWillShow', (e) => {\n runOnUI(handler)(-e.endCoordinates.height);\n });\n const hide = Keyboard.addListener('keyboardWillHide', () => {\n runOnUI(handler)(0);\n });\n\n return () => {\n show.remove();\n hide.remove();\n };\n }, []);\n\n return { height, progress };\n};\n\nexport const useGradualKeyboardAnimation =\n Platform.OS === 'ios'\n ? useReanimatedKeyboardAnimationReplica\n : useReanimatedKeyboardAnimation;\n"],"mappings":"AAAA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,OAA5B,QAA2C,OAA3C;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,QAA3B,EAAqCC,QAArC,QAAqD,cAArD;AACA,SACEC,OADF,EAEEC,mBAFF,EAGEC,eAHF,EAIEC,cAJF,EAKEC,kBALF,EAMEC,UANF,QAOO,yBAPP;AAQA,SAASC,8BAAT,QAA+C,YAA/C;AAEA,SAASC,qBAAT,EAAgCC,kBAAhC,QAA0D,UAA1D;AAEA,M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nimatedReaction","useDerivedValue","useSharedValue","useWorkletCallback","withSpring","useReanimatedKeyboardAnimation","AndroidSoftInputModes","KeyboardController","availableOSEventType","OS","defaultAndroidEasing","bezier","useKeyboardAnimationReplica","height","Value","progress","animation","current","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","listener","addListener","e","timing","toValue","endCoordinates","duration","easing","useNativeDriver","start","remove","IOS_SPRING_CONFIG","damping","stiffness","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","useReanimatedKeyboardAnimationReplica","heightEvent","value","handler","_height","_keyboardHeight","result","_previousResult","_previousKeyboardHeight","show","hide","useGradualKeyboardAnimation"],"sources":["replicas.ts"],"sourcesContent":["import { useRef, useEffect, useMemo } from 'react';\nimport { Animated, Easing, Keyboard, Platform } from 'react-native';\nimport {\n runOnUI,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n useWorkletCallback,\n withSpring,\n} from 'react-native-reanimated';\nimport { useReanimatedKeyboardAnimation } from './hooks';\n\nimport { AndroidSoftInputModes, KeyboardController } from './native';\n\nconst availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did';\n\n// cubic-bezier(.17,.67,.34,.94)\nexport const defaultAndroidEasing = Easing.bezier(0.4, 0.0, 0.2, 1);\ntype KeyboardAnimation = {\n progress: Animated.Value;\n height: Animated.Value;\n};\n\n/**\n * An experimental implementation of tracing keyboard appearance.\n * Switch an input mode to adjust resize mode. In this case all did* events\n * are triggering before keyboard appears, and using some approximations\n * it tries to mimicries a native transition.\n *\n * @returns {Animated.Value}\n */\nexport const useKeyboardAnimationReplica = (): KeyboardAnimation => {\n const height = useRef(new Animated.Value(0));\n const progress = useRef(new Animated.Value(0));\n const animation = useMemo(\n () => ({\n height: height.current,\n progress: progress.current,\n }),\n []\n );\n\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Show`,\n (e) => {\n Animated.timing(height.current, {\n toValue: -e.endCoordinates.height,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Hide`,\n (e) => {\n Animated.timing(height.current, {\n toValue: 0,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n\n return animation;\n};\n\nconst IOS_SPRING_CONFIG = {\n damping: 500,\n stiffness: 1000,\n mass: 3,\n overshootClamping: true,\n restDisplacementThreshold: 10,\n restSpeedThreshold: 10,\n};\n\n/**\n * A close replica to native iOS keyboard animation. The problem is that\n * iOS (unlike Android) can not fire events for each keyboard frame movement.\n * As a result we can not get gradual values (for example, for progress it always\n * will be 1 or 0). So if you want to rely on gradual values you will need to use\n * this replica.\n *\n * The transition is hardcoded and may vary from one to another OS versions. But it\n * seems like last time it has been changed in iOS 7. Since RN supports at least iOS\n * 11 it doesn't make sense to replicate iOS 7 behavior. If it changes in next OS\n * versions, then this implementation should be revisited and reflect necessary changes.\n *\n * @returns {height, progress} - animated values\n */\nexport const useReanimatedKeyboardAnimationReplica = () => {\n const height = useSharedValue(0);\n const heightEvent = useSharedValue(0);\n\n const progress = useDerivedValue(() => height.value / heightEvent.value);\n\n const handler = useWorkletCallback((_height: number) => {\n heightEvent.value = _height;\n }, []);\n\n useAnimatedReaction(\n () => ({\n _keyboardHeight: heightEvent.value,\n }),\n (result, _previousResult) => {\n const { _keyboardHeight } = result;\n const _previousKeyboardHeight = _previousResult?._keyboardHeight;\n\n if (_keyboardHeight !== _previousKeyboardHeight) {\n height.value = withSpring(_keyboardHeight, IOS_SPRING_CONFIG);\n }\n },\n []\n );\n\n useEffect(() => {\n const show = Keyboard.addListener('keyboardWillShow', (e) => {\n runOnUI(handler)(-e.endCoordinates.height);\n });\n const hide = Keyboard.addListener('keyboardWillHide', () => {\n runOnUI(handler)(0);\n });\n\n return () => {\n show.remove();\n hide.remove();\n };\n }, []);\n\n return { height, progress };\n};\n\nexport const useGradualKeyboardAnimation =\n Platform.OS === 'ios'\n ? useReanimatedKeyboardAnimationReplica\n : useReanimatedKeyboardAnimation;\n"],"mappings":"AAAA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,OAA5B,QAA2C,OAA3C;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,QAA3B,EAAqCC,QAArC,QAAqD,cAArD;AACA,SACEC,OADF,EAEEC,mBAFF,EAGEC,eAHF,EAIEC,cAJF,EAKEC,kBALF,EAMEC,UANF,QAOO,yBAPP;AAQA,SAASC,8BAAT,QAA+C,SAA/C;AAEA,SAASC,qBAAT,EAAgCC,kBAAhC,QAA0D,UAA1D;AAEA,MAAMC,oBAAoB,GAAGV,QAAQ,CAACW,EAAT,KAAgB,KAAhB,GAAwB,MAAxB,GAAiC,KAA9D,C,CAEA;;AACA,OAAO,MAAMC,oBAAoB,GAAGd,MAAM,CAACe,MAAP,CAAc,GAAd,EAAmB,GAAnB,EAAwB,GAAxB,EAA6B,CAA7B,CAA7B;;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAG,MAAyB;EAClE,MAAMC,MAAM,GAAGrB,MAAM,CAAC,IAAIG,QAAQ,CAACmB,KAAb,CAAmB,CAAnB,CAAD,CAArB;EACA,MAAMC,QAAQ,GAAGvB,MAAM,CAAC,IAAIG,QAAQ,CAACmB,KAAb,CAAmB,CAAnB,CAAD,CAAvB;EACA,MAAME,SAAS,GAAGtB,OAAO,CACvB,OAAO;IACLmB,MAAM,EAAEA,MAAM,CAACI,OADV;IAELF,QAAQ,EAAEA,QAAQ,CAACE;EAFd,CAAP,CADuB,EAK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,CAAqB,kBAArB,EAA0CC,CAAD,IAAO;MAC3DxB,OAAO,CAAC2C,OAAD,CAAP,CAAiB,CAACnB,CAAC,CAACG,cAAF,CAAiBb,MAAnC;IACD,CAFY,CAAb;IAGA,MAAMoC,IAAI,GAAGpD,QAAQ,CAACyB,WAAT,CAAqB,kBAArB,EAAyC,MAAM;MAC1DvB,OAAO,CAAC2C,OAAD,CAAP,CAAiB,CAAjB;IACD,CAFY,CAAb;IAIA,OAAO,MAAM;MACXM,IAAI,CAACjB,MAAL;MACAkB,IAAI,CAAClB,MAAL;IACD,CAHD;EAID,CAZQ,EAYN,EAZM,CAAT;EAcA,OAAO;IAAElB,MAAF;IAAUE;EAAV,CAAP;AACD,CAxCM;AA0CP,OAAO,MAAMmC,2BAA2B,GACtCpD,QAAQ,CAACW,EAAT,KAAgB,KAAhB,GACI8B,qCADJ,GAEIlC,8BAHC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { NativeSyntheticEvent, ViewProps } from 'react-native';\n\n// DirectEventHandler events declaration\n\nexport type NativeEvent = {\n progress: number;\n height: number;\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\n\nexport type KeyboardControllerProps = {\n onKeyboardMove: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;\n // fake prop used to activate reanimated bindings\n onKeyboardMoveReanimated: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n statusBarTranslucent?: boolean;\n} & ViewProps;\n\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n\n// Event module declarations\n\nexport type KeyboardControllerEvents =\n | 'keyboardWillShow'\n | 'keyboardDidShow'\n | 'keyboardWillHide'\n | 'keyboardDidHide';\nexport type KeyboardEventData = {\n height: number;\n};\n"],"mappings":""}
@@ -1,21 +1,5 @@
1
1
  import React from 'react';
2
- import { Animated, ViewStyle } from 'react-native';
3
- import Reanimated from 'react-native-reanimated';
4
- declare type AnimatedContext = {
5
- progress: Animated.Value;
6
- height: Animated.Value;
7
- };
8
- declare type ReanimatedContext = {
9
- progress: Reanimated.SharedValue<number>;
10
- height: Reanimated.SharedValue<number>;
11
- };
12
- declare type KeyboardAnimationContext = {
13
- animated: AnimatedContext;
14
- reanimated: ReanimatedContext;
15
- };
16
- export declare const KeyboardContext: React.Context<KeyboardAnimationContext>;
17
- export declare const useKeyboardAnimation: () => AnimatedContext;
18
- export declare const useReanimatedKeyboardAnimation: () => ReanimatedContext;
2
+ import { ViewStyle } from 'react-native';
19
3
  declare type Styles = {
20
4
  container: ViewStyle;
21
5
  hidden: ViewStyle;
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { Animated } from 'react-native';
3
+ import type { SharedValue } from 'react-native-reanimated';
4
+ export declare type AnimatedContext = {
5
+ progress: Animated.Value;
6
+ height: Animated.Value;
7
+ };
8
+ export declare type ReanimatedContext = {
9
+ progress: SharedValue<number>;
10
+ height: SharedValue<number>;
11
+ };
12
+ export declare type KeyboardAnimationContext = {
13
+ animated: AnimatedContext;
14
+ reanimated: ReanimatedContext;
15
+ };
16
+ export declare const KeyboardContext: import("react").Context<KeyboardAnimationContext>;
@@ -0,0 +1,4 @@
1
+ import { AnimatedContext, ReanimatedContext } from './context';
2
+ export declare const useResizeMode: () => void;
3
+ export declare const useKeyboardAnimation: () => AnimatedContext;
4
+ export declare const useReanimatedKeyboardAnimation: () => ReanimatedContext;
@@ -2,3 +2,6 @@ import './monkey-patch';
2
2
  export * from './native';
3
3
  export * from './animated';
4
4
  export * from './replicas';
5
+ export * from './context';
6
+ export * from './hooks';
7
+ export * from './types';
@@ -0,0 +1,4 @@
1
+ import type { EventWithName, NativeEvent } from './types';
2
+ export declare function useAnimatedKeyboardHandler<TContext extends Record<string, unknown>>(handlers: {
3
+ onKeyboardMove?: (e: NativeEvent, context: TContext) => void;
4
+ }, dependencies?: ReadonlyArray<unknown>): (e: import("react-native").NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;