react-native-keyboard-controller 1.5.8 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +3 -1
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +2 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt +128 -18
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationController.kt +2 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/KeyboardTransitionEvent.kt +11 -2
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +7 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +2 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +1 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +6 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/StatusBarManagerCompatModuleImpl.kt +9 -3
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +44 -27
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +119 -96
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +6 -4
- package/android/src/paper/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +2 -1
- package/ios/Extensions.swift +31 -0
- package/ios/KeyboardController-Bridging-Header.h +1 -0
- package/ios/KeyboardControllerView.mm +25 -6
- package/ios/KeyboardControllerViewManager.swift +4 -2
- package/ios/KeyboardMoveEvent.h +3 -1
- package/ios/KeyboardMoveEvent.m +8 -0
- package/ios/KeyboardMovementObserver.swift +58 -11
- package/lib/commonjs/animated.js +4 -3
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js +26 -0
- package/lib/commonjs/bindings.js.map +1 -0
- package/lib/commonjs/bindings.native.js +33 -0
- package/lib/commonjs/bindings.native.js.map +1 -0
- package/lib/commonjs/{native.js → constants.js} +2 -29
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/context.js +9 -1
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks.js +7 -6
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/index.js +15 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +0 -30
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/monkey-patch.android.js +34 -0
- package/lib/commonjs/monkey-patch.android.js.map +1 -0
- package/lib/commonjs/monkey-patch.js +1 -35
- package/lib/commonjs/monkey-patch.js.map +1 -1
- package/lib/commonjs/reanimated.js +9 -0
- package/lib/commonjs/reanimated.js.map +1 -0
- package/lib/commonjs/reanimated.native.js +37 -0
- package/lib/commonjs/reanimated.native.js.map +1 -0
- package/lib/commonjs/replicas.js +4 -3
- package/lib/commonjs/replicas.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/animated.js +3 -2
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js +16 -0
- package/lib/module/bindings.js.map +1 -0
- package/lib/module/bindings.native.js +23 -0
- package/lib/module/bindings.native.js.map +1 -0
- package/lib/module/{native.js → constants.js} +1 -24
- package/lib/module/constants.js.map +1 -0
- package/lib/module/context.js +8 -1
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks.js +7 -6
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +1 -30
- package/lib/module/internal.js.map +1 -1
- package/lib/module/monkey-patch.android.js +29 -0
- package/lib/module/monkey-patch.android.js.map +1 -0
- package/lib/module/monkey-patch.js +1 -31
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/reanimated.js +2 -0
- package/lib/module/reanimated.js.map +1 -0
- package/lib/module/reanimated.native.js +30 -0
- package/lib/module/reanimated.native.js.map +1 -0
- package/lib/module/replicas.js +2 -1
- package/lib/module/replicas.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/bindings.d.ts +6 -0
- package/lib/typescript/bindings.native.d.ts +6 -0
- package/lib/typescript/constants.d.ts +16 -0
- package/lib/typescript/context.d.ts +1 -0
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/internal.d.ts +1 -7
- package/lib/typescript/monkey-patch.android.d.ts +1 -0
- package/lib/typescript/monkey-patch.d.ts +0 -1
- package/lib/typescript/reanimated.d.ts +2 -0
- package/lib/typescript/reanimated.native.d.ts +2 -0
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +3 -1
- package/lib/typescript/types.d.ts +15 -1
- package/package.json +1 -1
- package/react-native-keyboard-controller.podspec +9 -1
- package/src/animated.tsx +3 -6
- package/src/{native.ts → bindings.native.ts} +4 -25
- package/src/bindings.ts +22 -0
- package/src/constants.ts +17 -0
- package/src/context.ts +12 -1
- package/src/hooks.ts +12 -7
- package/src/index.ts +2 -1
- package/src/internal.ts +2 -57
- package/src/monkey-patch.android.ts +33 -0
- package/src/monkey-patch.ts +1 -37
- package/src/reanimated.native.ts +51 -0
- package/src/reanimated.ts +6 -0
- package/src/replicas.ts +2 -1
- package/src/specs/KeyboardControllerViewNativeComponent.ts +3 -0
- package/src/types.ts +27 -5
- package/lib/commonjs/native.js.map +0 -1
- package/lib/module/native.js.map +0 -1
- package/lib/typescript/native.d.ts +0 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","setHandlers","broadcast","useSharedHandlers","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","Platform","OS","value","handler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { Animated, Platform, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport {
|
|
1
|
+
{"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","setHandlers","broadcast","useSharedHandlers","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","Platform","OS","value","handler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { Animated, Platform, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport { useSharedHandlers, useAnimatedValue } from './internal';\nimport { KeyboardControllerView } from './bindings';\nimport { useAnimatedKeyboardHandler } from './reanimated';\n\nimport type {\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} 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\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: 'none',\n position: 'absolute',\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n * @platform android\n */\n navigationBarTranslucent?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n}: KeyboardProviderProps) => {\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const { setHandlers, broadcast } = useSharedHandlers<KeyboardHandler>();\n // memo\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n setHandlers,\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 updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n 'worklet';\n\n if (platforms.includes(Platform.OS)) {\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const handler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onStart', event);\n updateSharedValues(event, ['ios']);\n },\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onMove', event);\n updateSharedValues(event, ['android']);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onEnd', event);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n 'worklet';\n\n updateSharedValues(event, ['android', 'ios']);\n broadcast('onInteractive', event);\n },\n },\n []\n );\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n // @ts-expect-error will be fixed when migrate to REA 3.3.0\n style={styles.container}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AAA0D;AAAA;AAQ1D,MAAMA,8BAA8B,GAAGC,8BAAU,CAACC,uBAAuB,CACvEC,qBAAQ,CAACD,uBAAuB,CAC9BE,gCAAsB,CACvB,CACF;AAOD,MAAMC,MAAM,GAAGC,uBAAU,CAACC,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAwBK,MAAMC,gBAAgB,GAAG,QAIH;EAAA,IAJI;IAC/BC,QAAQ;IACRC,oBAAoB;IACpBC;EACqB,CAAC;EACtB;EACA,MAA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ACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEiB;EAAM,EACb,CACuB;AAE/B,CAAC;AAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardController = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
const NOOP = () => {};
|
|
9
|
+
const KeyboardController = {
|
|
10
|
+
setDefaultMode: NOOP,
|
|
11
|
+
setInputMode: NOOP,
|
|
12
|
+
addListener: NOOP,
|
|
13
|
+
removeListeners: NOOP
|
|
14
|
+
};
|
|
15
|
+
exports.KeyboardController = KeyboardController;
|
|
16
|
+
const KeyboardEvents = {
|
|
17
|
+
addListener: () => ({
|
|
18
|
+
remove: NOOP
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
exports.KeyboardEvents = KeyboardEvents;
|
|
22
|
+
const KeyboardControllerView = _reactNative.View;
|
|
23
|
+
exports.KeyboardControllerView = KeyboardControllerView;
|
|
24
|
+
const KeyboardGestureArea = _reactNative.View;
|
|
25
|
+
exports.KeyboardGestureArea = KeyboardGestureArea;
|
|
26
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NOOP","KeyboardController","setDefaultMode","setInputMode","addListener","removeListeners","KeyboardEvents","remove","KeyboardControllerView","View","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { EmitterSubscription, View } from 'react-native';\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from './types';\n\nconst NOOP = () => {};\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\n"],"mappings":";;;;;;AAAA;AAQA,MAAMA,IAAI,GAAG,MAAM,CAAC,CAAC;AACd,MAAMC,kBAA4C,GAAG;EAC1DC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,WAAW,EAAEJ,IAAI;EACjBK,eAAe,EAAEL;AACnB,CAAC;AAAC;AACK,MAAMM,cAAoC,GAAG;EAClDF,WAAW,EAAE,OAAO;IAAEG,MAAM,EAAEP;EAAK,CAAC;AACtC,CAAC;AAAC;AACK,MAAMQ,sBAAsB,GACjCC,iBAAoD;AAAC;AAChD,MAAMC,mBAAmB,GAC9BD,iBAAqD;AAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardController = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
9
|
+
ios: "- You have run 'pod install'\n",
|
|
10
|
+
default: ''
|
|
11
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
12
|
+
const RCTKeyboardController = require('./specs/NativeKeyboardController').default;
|
|
13
|
+
const KeyboardController = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
14
|
+
get() {
|
|
15
|
+
throw new Error(LINKING_ERROR);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.KeyboardController = KeyboardController;
|
|
19
|
+
const eventEmitter = new _reactNative.NativeEventEmitter(KeyboardController);
|
|
20
|
+
const KeyboardEvents = {
|
|
21
|
+
addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
|
|
22
|
+
};
|
|
23
|
+
exports.KeyboardEvents = KeyboardEvents;
|
|
24
|
+
const KeyboardControllerView = require('./specs/KeyboardControllerViewNativeComponent').default;
|
|
25
|
+
exports.KeyboardControllerView = KeyboardControllerView;
|
|
26
|
+
const KeyboardGestureArea = _reactNative.Platform.OS === 'android' && _reactNative.Platform.Version >= 30 ? require('./specs/KeyboardGestureAreaNativeComponent').default : _ref => {
|
|
27
|
+
let {
|
|
28
|
+
children
|
|
29
|
+
} = _ref;
|
|
30
|
+
return children;
|
|
31
|
+
};
|
|
32
|
+
exports.KeyboardGestureArea = KeyboardGestureArea;
|
|
33
|
+
//# sourceMappingURL=bindings.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","RCTKeyboardController","require","KeyboardController","Proxy","get","Error","eventEmitter","NativeEventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView","KeyboardGestureArea","OS","Version","children"],"sources":["bindings.native.ts"],"sourcesContent":["import { Platform, NativeEventEmitter } from 'react-native';\n\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\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\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: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener('KeyboardController::' + name, cb),\n};\nexport const KeyboardControllerView: React.FC<KeyboardControllerProps> =\n require('./specs/KeyboardControllerViewNativeComponent').default;\nexport const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =\n Platform.OS === 'android' && Platform.Version >= 30\n ? require('./specs/KeyboardGestureAreaNativeComponent').default\n : ({ children }: KeyboardGestureAreaProps) => children;\n"],"mappings":";;;;;;AAAA;AASA,MAAMA,aAAa,GAChB,2FAA0F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,qBAAqB,GACzBC,OAAO,CAAC,kCAAkC,CAAC,CAACF,OAAO;AAC9C,MAAMG,kBAAkB,GAC7BF,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CAAC,CAEoB;AAAC;AAE9B,MAAMW,YAAY,GAAG,IAAIC,+BAAkB,CAACL,kBAAkB,CAAC;AAExD,MAAMM,cAAoC,GAAG;EAClDC,WAAW,EAAE,CAACC,IAAI,EAAEC,EAAE,KACpBL,YAAY,CAACG,WAAW,CAAC,sBAAsB,GAAGC,IAAI,EAAEC,EAAE;AAC9D,CAAC;AAAC;AACK,MAAMC,sBAAyD,GACpEX,OAAO,CAAC,+CAA+C,CAAC,CAACF,OAAO;AAAC;AAC5D,MAAMc,mBAAuD,GAClEjB,qBAAQ,CAACkB,EAAE,KAAK,SAAS,IAAIlB,qBAAQ,CAACmB,OAAO,IAAI,EAAE,GAC/Cd,OAAO,CAAC,4CAA4C,CAAC,CAACF,OAAO,GAC7D;EAAA,IAAC;IAAEiB;EAAmC,CAAC;EAAA,OAAKA,QAAQ;AAAA;AAAC"}
|
|
@@ -3,13 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
9
|
-
ios: "- You have run 'pod install'\n",
|
|
10
|
-
default: ''
|
|
11
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
12
|
-
|
|
6
|
+
exports.AndroidSoftInputModes = void 0;
|
|
13
7
|
// copied from `android.view.WindowManager.LayoutParams`
|
|
14
8
|
let AndroidSoftInputModes;
|
|
15
9
|
exports.AndroidSoftInputModes = AndroidSoftInputModes;
|
|
@@ -29,25 +23,4 @@ exports.AndroidSoftInputModes = AndroidSoftInputModes;
|
|
|
29
23
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNSPECIFIED"] = 0] = "SOFT_INPUT_STATE_UNSPECIFIED";
|
|
30
24
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_VISIBLE"] = 4] = "SOFT_INPUT_STATE_VISIBLE";
|
|
31
25
|
})(AndroidSoftInputModes || (exports.AndroidSoftInputModes = AndroidSoftInputModes = {}));
|
|
32
|
-
|
|
33
|
-
const KeyboardController = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
34
|
-
get() {
|
|
35
|
-
throw new Error(LINKING_ERROR);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
exports.KeyboardController = KeyboardController;
|
|
39
|
-
const eventEmitter = new _reactNative.NativeEventEmitter(KeyboardController);
|
|
40
|
-
const KeyboardEvents = {
|
|
41
|
-
addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
|
|
42
|
-
};
|
|
43
|
-
exports.KeyboardEvents = KeyboardEvents;
|
|
44
|
-
const KeyboardControllerView = require('./specs/KeyboardControllerViewNativeComponent').default;
|
|
45
|
-
exports.KeyboardControllerView = KeyboardControllerView;
|
|
46
|
-
const KeyboardGestureArea = _reactNative.Platform.OS === 'android' && _reactNative.Platform.Version >= 30 ? require('./specs/KeyboardGestureAreaNativeComponent').default : _ref => {
|
|
47
|
-
let {
|
|
48
|
-
children
|
|
49
|
-
} = _ref;
|
|
50
|
-
return children;
|
|
51
|
-
};
|
|
52
|
-
exports.KeyboardGestureArea = KeyboardGestureArea;
|
|
53
|
-
//# sourceMappingURL=native.js.map
|
|
26
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AndroidSoftInputModes"],"sources":["constants.ts"],"sourcesContent":["// 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"],"mappings":";;;;;;AAAA;AAAA,IACYA,qBAAqB;AAAA;AAAA,WAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;AAAA,GAArBA,qBAAqB,qCAArBA,qBAAqB"}
|
package/lib/commonjs/context.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.KeyboardContext = void 0;
|
|
6
|
+
exports.useKeyboardContext = exports.KeyboardContext = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
const defaultContext = {
|
|
@@ -23,4 +23,12 @@ const defaultContext = {
|
|
|
23
23
|
};
|
|
24
24
|
const KeyboardContext = /*#__PURE__*/(0, _react.createContext)(defaultContext);
|
|
25
25
|
exports.KeyboardContext = KeyboardContext;
|
|
26
|
+
const useKeyboardContext = () => {
|
|
27
|
+
const context = (0, _react.useContext)(KeyboardContext);
|
|
28
|
+
if (__DEV__ && context === defaultContext) {
|
|
29
|
+
console.warn("Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.");
|
|
30
|
+
}
|
|
31
|
+
return context;
|
|
32
|
+
};
|
|
33
|
+
exports.useKeyboardContext = useKeyboardContext;
|
|
26
34
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultContext","animated","progress","Animated","Value","height","reanimated","value","setHandlers","KeyboardContext","createContext"],"sources":["context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\n\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { KeyboardHandlers } from './types';\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n setHandlers: (handlers: KeyboardHandlers) => void;\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 setHandlers: () => {},\n};\nexport const KeyboardContext = createContext(defaultContext);\n"],"mappings":";;;;;;AAAA;AACA;AAkBA,MAAMA,cAAwC,GAAG;EAC/CC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIC,qBAAQ,CAACC,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIF,qBAAQ,CAACC,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVJ,QAAQ,EAAE;MAAEK,KAAK,EAAE;IAAE,CAAC;IACtBF,MAAM,EAAE;MAAEE,KAAK,EAAE;IAAE;EACrB,CAAC;EACDC,WAAW,EAAE,MAAM,CAAC;AACtB,CAAC;AACM,MAAMC,eAAe,gBAAG,IAAAC,oBAAa,EAACV,cAAc,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["defaultContext","animated","progress","Animated","Value","height","reanimated","value","setHandlers","KeyboardContext","createContext","useKeyboardContext","context","useContext","__DEV__","console","warn"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport { Animated } from 'react-native';\n\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { KeyboardHandlers } from './types';\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n setHandlers: (handlers: KeyboardHandlers) => void;\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 setHandlers: () => {},\n};\nexport const KeyboardContext = createContext(defaultContext);\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n\n if (__DEV__ && context === defaultContext) {\n console.warn(\n \"Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.\"\n );\n }\n\n return context;\n};\n"],"mappings":";;;;;;AAAA;AACA;AAkBA,MAAMA,cAAwC,GAAG;EAC/CC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIC,qBAAQ,CAACC,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIF,qBAAQ,CAACC,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVJ,QAAQ,EAAE;MAAEK,KAAK,EAAE;IAAE,CAAC;IACtBF,MAAM,EAAE;MAAEE,KAAK,EAAE;IAAE;EACrB,CAAC;EACDC,WAAW,EAAE,MAAM,CAAC;AACtB,CAAC;AACM,MAAMC,eAAe,gBAAG,IAAAC,oBAAa,EAACV,cAAc,CAAC;AAAC;AACtD,MAAMW,kBAAkB,GAAG,MAAM;EACtC,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACJ,eAAe,CAAC;EAE3C,IAAIK,OAAO,IAAIF,OAAO,KAAKZ,cAAc,EAAE;IACzCe,OAAO,CAACC,IAAI,CACV,sLAAsL,CACvL;EACH;EAEA,OAAOJ,OAAO;AAChB,CAAC;AAAC"}
|
package/lib/commonjs/hooks.js
CHANGED
|
@@ -9,29 +9,30 @@ exports.useKeyboardHandler = useKeyboardHandler;
|
|
|
9
9
|
exports.useResizeMode = exports.useReanimatedKeyboardAnimation = void 0;
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _context = require("./context");
|
|
12
|
-
var
|
|
12
|
+
var _bindings = require("./bindings");
|
|
13
|
+
var _constants = require("./constants");
|
|
13
14
|
var _utils = require("./utils");
|
|
14
15
|
const useResizeMode = () => {
|
|
15
16
|
(0, _react.useEffect)(() => {
|
|
16
|
-
|
|
17
|
-
return () =>
|
|
17
|
+
_bindings.KeyboardController.setInputMode(_constants.AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
|
|
18
|
+
return () => _bindings.KeyboardController.setDefaultMode();
|
|
18
19
|
}, []);
|
|
19
20
|
};
|
|
20
21
|
exports.useResizeMode = useResizeMode;
|
|
21
22
|
const useKeyboardAnimation = () => {
|
|
22
23
|
useResizeMode();
|
|
23
|
-
const context = (0,
|
|
24
|
+
const context = (0, _context.useKeyboardContext)();
|
|
24
25
|
return context.animated;
|
|
25
26
|
};
|
|
26
27
|
exports.useKeyboardAnimation = useKeyboardAnimation;
|
|
27
28
|
const useReanimatedKeyboardAnimation = () => {
|
|
28
29
|
useResizeMode();
|
|
29
|
-
const context = (0,
|
|
30
|
+
const context = (0, _context.useKeyboardContext)();
|
|
30
31
|
return context.reanimated;
|
|
31
32
|
};
|
|
32
33
|
exports.useReanimatedKeyboardAnimation = useReanimatedKeyboardAnimation;
|
|
33
34
|
function useGenericKeyboardHandler(handler, deps) {
|
|
34
|
-
const context = (0,
|
|
35
|
+
const context = (0, _context.useKeyboardContext)();
|
|
35
36
|
(0, _react.useEffect)(() => {
|
|
36
37
|
const key = (0, _utils.uuid)();
|
|
37
38
|
context.setHandlers({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useResizeMode","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","
|
|
1
|
+
{"version":3,"names":["useResizeMode","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","useKeyboardContext","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","key","uuid","setHandlers","undefined","useKeyboardHandler"],"sources":["hooks.ts"],"sourcesContent":["import { DependencyList, useEffect } from 'react';\n\nimport {\n AnimatedContext,\n ReanimatedContext,\n useKeyboardContext,\n} from './context';\nimport { KeyboardController } from './bindings';\nimport { AndroidSoftInputModes } from './constants';\nimport { uuid } from './utils';\n\nimport type { KeyboardHandler } from './types';\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 = useKeyboardContext();\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.reanimated;\n};\n\nexport function useGenericKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList\n) {\n const context = useKeyboardContext();\n\n useEffect(() => {\n const key = uuid();\n\n context.setHandlers({ [key]: handler });\n\n return () => {\n context.setHandlers({ [key]: undefined });\n };\n }, deps);\n}\n\nexport function useKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList\n) {\n useResizeMode();\n useGenericKeyboardHandler(handler, deps);\n}\n"],"mappings":";;;;;;;;;AAAA;AAEA;AAKA;AACA;AACA;AAIO,MAAMA,aAAa,GAAG,MAAM;EACjC,IAAAC,gBAAS,EAAC,MAAM;IACdC,4BAAkB,CAACC,YAAY,CAC7BC,gCAAqB,CAACC,wBAAwB,CAC/C;IAED,OAAO,MAAMH,4BAAkB,CAACI,cAAc,EAAE;EAClD,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAAC;AAEK,MAAMC,oBAAoB,GAAG,MAAuB;EACzDP,aAAa,EAAE;EACf,MAAMQ,OAAO,GAAG,IAAAC,2BAAkB,GAAE;EAEpC,OAAOD,OAAO,CAACE,QAAQ;AACzB,CAAC;AAAC;AAEK,MAAMC,8BAA8B,GAAG,MAAyB;EACrEX,aAAa,EAAE;EACf,MAAMQ,OAAO,GAAG,IAAAC,2BAAkB,GAAE;EAEpC,OAAOD,OAAO,CAACI,UAAU;AAC3B,CAAC;AAAC;AAEK,SAASC,yBAAyB,CACvCC,OAAwB,EACxBC,IAAqB,EACrB;EACA,MAAMP,OAAO,GAAG,IAAAC,2BAAkB,GAAE;EAEpC,IAAAR,gBAAS,EAAC,MAAM;IACd,MAAMe,GAAG,GAAG,IAAAC,WAAI,GAAE;IAElBT,OAAO,CAACU,WAAW,CAAC;MAAE,CAACF,GAAG,GAAGF;IAAQ,CAAC,CAAC;IAEvC,OAAO,MAAM;MACXN,OAAO,CAACU,WAAW,CAAC;QAAE,CAACF,GAAG,GAAGG;MAAU,CAAC,CAAC;IAC3C,CAAC;EACH,CAAC,EAAEJ,IAAI,CAAC;AACV;AAEO,SAASK,kBAAkB,CAChCN,OAAwB,EACxBC,IAAqB,EACrB;EACAf,aAAa,EAAE;EACfa,yBAAyB,CAACC,OAAO,EAAEC,IAAI,CAAC;AAC1C"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
require("./monkey-patch");
|
|
7
|
-
var
|
|
8
|
-
Object.keys(
|
|
7
|
+
var _bindings = require("./bindings");
|
|
8
|
+
Object.keys(_bindings).forEach(function (key) {
|
|
9
9
|
if (key === "default" || key === "__esModule") return;
|
|
10
|
-
if (key in exports && exports[key] ===
|
|
10
|
+
if (key in exports && exports[key] === _bindings[key]) return;
|
|
11
11
|
Object.defineProperty(exports, key, {
|
|
12
12
|
enumerable: true,
|
|
13
13
|
get: function () {
|
|
14
|
-
return
|
|
14
|
+
return _bindings[key];
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
});
|
|
@@ -59,6 +59,17 @@ Object.keys(_hooks).forEach(function (key) {
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
|
+
var _constants = require("./constants");
|
|
63
|
+
Object.keys(_constants).forEach(function (key) {
|
|
64
|
+
if (key === "default" || key === "__esModule") return;
|
|
65
|
+
if (key in exports && exports[key] === _constants[key]) return;
|
|
66
|
+
Object.defineProperty(exports, key, {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _constants[key];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
62
73
|
var _types = require("./types");
|
|
63
74
|
Object.keys(_types).forEach(function (key) {
|
|
64
75
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './bindings';\nexport * from './animated';\nexport * from './replicas';\nexport * from './context';\nexport * from './hooks';\nexport * from './constants';\nexport * from './types';\n"],"mappings":";;;;;AAAA;AAEA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/lib/commonjs/internal.js
CHANGED
|
@@ -3,41 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useAnimatedKeyboardHandler = useAnimatedKeyboardHandler;
|
|
7
6
|
exports.useAnimatedValue = useAnimatedValue;
|
|
8
7
|
exports.useSharedHandlers = useSharedHandlers;
|
|
9
8
|
var _react = require("react");
|
|
10
9
|
var _reactNative = require("react-native");
|
|
11
10
|
var _reactNativeReanimated = require("react-native-reanimated");
|
|
12
|
-
function useAnimatedKeyboardHandler(handlers, dependencies) {
|
|
13
|
-
const {
|
|
14
|
-
context,
|
|
15
|
-
doDependenciesDiffer
|
|
16
|
-
} = (0, _reactNativeReanimated.useHandler)(handlers, dependencies);
|
|
17
|
-
return (0, _reactNativeReanimated.useEvent)(event => {
|
|
18
|
-
'worklet';
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
onKeyboardMoveStart,
|
|
22
|
-
onKeyboardMove,
|
|
23
|
-
onKeyboardMoveEnd,
|
|
24
|
-
onKeyboardMoveInteractive
|
|
25
|
-
} = handlers;
|
|
26
|
-
if (onKeyboardMoveStart && event.eventName.endsWith('onKeyboardMoveStart')) {
|
|
27
|
-
onKeyboardMoveStart(event, context);
|
|
28
|
-
}
|
|
29
|
-
if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
|
|
30
|
-
onKeyboardMove(event, context);
|
|
31
|
-
}
|
|
32
|
-
if (onKeyboardMoveEnd && event.eventName.endsWith('onKeyboardMoveEnd')) {
|
|
33
|
-
onKeyboardMoveEnd(event, context);
|
|
34
|
-
}
|
|
35
|
-
if (onKeyboardMoveInteractive && event.eventName.endsWith('onKeyboardMoveInteractive')) {
|
|
36
|
-
onKeyboardMoveInteractive(event, context);
|
|
37
|
-
}
|
|
38
|
-
}, ['onKeyboardMoveStart', 'onKeyboardMove', 'onKeyboardMoveEnd', 'onKeyboardMoveInteractive'], doDependenciesDiffer);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
11
|
/**
|
|
42
12
|
* Hook for storing worklet handlers (objects with keys, where values are worklets).
|
|
43
13
|
* Returns methods for setting handlers and broadcasting events in them.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useSharedHandlers","handlers","useSharedValue","jsHandlers","useRef","updateSharedHandlers","value","current","setHandlers","useCallback","handler","broadcast","type","event","Object","keys","forEach","key","useAnimatedValue","initialValue","config","ref","Animated","Value"],"sources":["internal.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport { useSharedValue } from 'react-native-reanimated';\n\nimport type { Handlers, NativeEvent } from './types';\n\n/**\n * Hook for storing worklet handlers (objects with keys, where values are worklets).\n * Returns methods for setting handlers and broadcasting events in them.\n *\n * T is a generic that looks like:\n * @example\n * {\n * onEvent: () => {},\n * onEvent2: () => {},\n * }\n */\nexport function useSharedHandlers<T extends Record<string, Function>>() {\n const handlers = useSharedValue<Handlers<T>>({});\n const jsHandlers = useRef<Handlers<T>>({});\n\n // since js -> worklet -> js call is asynchronous, we can not write handlers\n // straight into shared variable (using current shared value as a previous result),\n // since there may be a race condition in a call, and closure may have out-of-dated\n // values. As a result, some of handlers may be not written to \"all handlers\" object.\n // Below we are writing all handlers to `ref` and afterwards synchronize them with\n // shared value (since `refs` are not referring to actual value in worklets).\n // This approach allow us to update synchronously handlers in js thread (and it assures,\n // that it will have all of them) and then update them in worklet thread (calls are\n // happening in FIFO order, so we will always have actual value).\n const updateSharedHandlers = () => {\n handlers.value = jsHandlers.current;\n };\n const setHandlers = useCallback((handler: Handlers<T>) => {\n jsHandlers.current = {\n ...jsHandlers.current,\n ...handler,\n };\n updateSharedHandlers();\n }, []);\n const broadcast = (type: keyof T, event: NativeEvent) => {\n 'worklet';\n\n Object.keys(handlers.value).forEach((key) =>\n handlers.value[key]?.[type]?.(event)\n );\n };\n\n return { setHandlers, broadcast };\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current == null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAiB,GAAuC;EACtE,MAAMC,QAAQ,GAAG,IAAAC,qCAAc,EAAc,CAAC,CAAC,CAAC;EAChD,MAAMC,UAAU,GAAG,IAAAC,aAAM,EAAc,CAAC,CAAC,CAAC;;EAE1C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAMC,oBAAoB,GAAG,MAAM;IACjCJ,QAAQ,CAACK,KAAK,GAAGH,UAAU,CAACI,OAAO;EACrC,CAAC;EACD,MAAMC,WAAW,GAAG,IAAAC,kBAAW,EAAEC,OAAoB,IAAK;IACxDP,UAAU,CAACI,OAAO,GAAG;MACnB,GAAGJ,UAAU,CAACI,OAAO;MACrB,GAAGG;IACL,CAAC;IACDL,oBAAoB,EAAE;EACxB,CAAC,EAAE,EAAE,CAAC;EACN,MAAMM,SAAS,GAAG,CAACC,IAAa,EAAEC,KAAkB,KAAK;IACvD,SAAS;;IAETC,MAAM,CAACC,IAAI,CAACd,QAAQ,CAACK,KAAK,CAAC,CAACU,OAAO,CAAEC,GAAG;MAAA;MAAA,8BACtChB,QAAQ,CAACK,KAAK,CAACW,GAAG,CAAC,iFAAnB,oBAAsBL,IAAI,CAAC,0DAA3B,gDAA8BC,KAAK,CAAC;IAAA,EACrC;EACH,CAAC;EAED,OAAO;IAAEL,WAAW;IAAEG;EAAU,CAAC;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,gBAAgB,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG,IAAAjB,aAAM,EAAwB,IAAI,CAAC;EAE/C,IAAIiB,GAAG,CAACd,OAAO,IAAI,IAAI,EAAE;IACvBc,GAAG,CAACd,OAAO,GAAG,IAAIe,qBAAQ,CAACC,KAAK,CAACJ,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAACd,OAAO;AACpB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var NativeAndroidManager = _interopRequireWildcard(require("react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid"));
|
|
4
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
5
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
6
|
+
// @ts-expect-error because there is no corresponding type definition
|
|
7
|
+
|
|
8
|
+
const getConstants = NativeAndroidManager.default.getConstants;
|
|
9
|
+
|
|
10
|
+
// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
|
|
11
|
+
// in order to use library on all available platforms we have to monkey patch
|
|
12
|
+
// default RN implementation and use modern `WindowInsetsControllerCompat`.
|
|
13
|
+
const RCTStatusBarManagerCompat = require('./specs/NativeStatusBarManagerCompat').default;
|
|
14
|
+
NativeAndroidManager.default = {
|
|
15
|
+
getConstants,
|
|
16
|
+
setColor(color, animated) {
|
|
17
|
+
RCTStatusBarManagerCompat.setColor(color, animated);
|
|
18
|
+
},
|
|
19
|
+
setTranslucent(translucent) {
|
|
20
|
+
RCTStatusBarManagerCompat.setTranslucent(translucent);
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* - statusBarStyles can be:
|
|
24
|
+
* - 'default'
|
|
25
|
+
* - 'dark-content'
|
|
26
|
+
*/
|
|
27
|
+
setStyle(statusBarStyle) {
|
|
28
|
+
RCTStatusBarManagerCompat.setStyle(statusBarStyle);
|
|
29
|
+
},
|
|
30
|
+
setHidden(hidden) {
|
|
31
|
+
RCTStatusBarManagerCompat.setHidden(hidden);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=monkey-patch.android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getConstants","NativeAndroidManager","default","RCTStatusBarManagerCompat","require","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden"],"sources":["monkey-patch.android.ts"],"sourcesContent":["// @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\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`.\nconst RCTStatusBarManagerCompat =\n require('./specs/NativeStatusBarManagerCompat').default;\nNativeAndroidManager.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"],"mappings":";;AACA;AAAkH;AAAA;AADlH;;AAGA,MAAMA,YAAY,GAAGC,oBAAoB,CAACC,OAAO,CAACF,YAAY;;AAE9D;AACA;AACA;AACA,MAAMG,yBAAyB,GAC7BC,OAAO,CAAC,sCAAsC,CAAC,CAACF,OAAO;AACzDD,oBAAoB,CAACC,OAAO,GAAG;EAC7BF,YAAY;EACZK,QAAQ,CAACC,KAAa,EAAEC,QAAiB,EAAQ;IAC/CJ,yBAAyB,CAACE,QAAQ,CAACC,KAAK,EAAEC,QAAQ,CAAC;EACrD,CAAC;EAEDC,cAAc,CAACC,WAAoB,EAAQ;IACzCN,yBAAyB,CAACK,cAAc,CAACC,WAAW,CAAC;EACvD,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,QAAQ,CAACC,cAAuB,EAAQ;IACtCR,yBAAyB,CAACO,QAAQ,CAACC,cAAc,CAAC;EACpD,CAAC;EAEDC,SAAS,CAACC,MAAe,EAAQ;IAC/BV,yBAAyB,CAACS,SAAS,CAACC,MAAM,CAAC;EAC7C;AACF,CAAC"}
|
|
@@ -1,37 +1,3 @@
|
|
|
1
|
+
// stub for all platforms
|
|
1
2
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var _reactNative = require("react-native");
|
|
4
|
-
var NativeAndroidManager = _interopRequireWildcard(require("react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid"));
|
|
5
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
6
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
7
|
-
// @ts-expect-error because there is no corresponding type definition
|
|
8
|
-
|
|
9
|
-
const getConstants = NativeAndroidManager.default.getConstants;
|
|
10
|
-
const RCTStatusBarManagerCompat = require('./specs/NativeStatusBarManagerCompat').default;
|
|
11
|
-
|
|
12
|
-
// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
|
|
13
|
-
// in order to use library on all available platforms we have to monkey patch
|
|
14
|
-
// default RN implementation and use modern `WindowInsetsControllerCompat`.
|
|
15
|
-
if (_reactNative.Platform.OS === 'android') {
|
|
16
|
-
NativeAndroidManager.default = {
|
|
17
|
-
getConstants,
|
|
18
|
-
setColor(color, animated) {
|
|
19
|
-
RCTStatusBarManagerCompat.setColor(color, animated);
|
|
20
|
-
},
|
|
21
|
-
setTranslucent(translucent) {
|
|
22
|
-
RCTStatusBarManagerCompat.setTranslucent(translucent);
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* - statusBarStyles can be:
|
|
26
|
-
* - 'default'
|
|
27
|
-
* - 'dark-content'
|
|
28
|
-
*/
|
|
29
|
-
setStyle(statusBarStyle) {
|
|
30
|
-
RCTStatusBarManagerCompat.setStyle(statusBarStyle);
|
|
31
|
-
},
|
|
32
|
-
setHidden(hidden) {
|
|
33
|
-
RCTStatusBarManagerCompat.setHidden(hidden);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
3
|
//# sourceMappingURL=monkey-patch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\n"],"mappings":"AAAA;AAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAnimatedKeyboardHandler = void 0;
|
|
7
|
+
const useAnimatedKeyboardHandler = () => () => {};
|
|
8
|
+
exports.useAnimatedKeyboardHandler = useAnimatedKeyboardHandler;
|
|
9
|
+
//# sourceMappingURL=reanimated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useAnimatedKeyboardHandler"],"sources":["reanimated.ts"],"sourcesContent":["import type { EventWithName, KeyboardHandlerHook, NativeEvent } from './types';\n\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n Record<string, unknown>,\n EventWithName<NativeEvent>\n> = () => () => {};\n"],"mappings":";;;;;;AAEO,MAAMA,0BAGZ,GAAG,MAAM,MAAM,CAAC,CAAC;AAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAnimatedKeyboardHandler = void 0;
|
|
7
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
8
|
+
const useAnimatedKeyboardHandler = (handlers, dependencies) => {
|
|
9
|
+
const {
|
|
10
|
+
context,
|
|
11
|
+
doDependenciesDiffer
|
|
12
|
+
} = (0, _reactNativeReanimated.useHandler)(handlers, dependencies);
|
|
13
|
+
return (0, _reactNativeReanimated.useEvent)(event => {
|
|
14
|
+
'worklet';
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
onKeyboardMoveStart,
|
|
18
|
+
onKeyboardMove,
|
|
19
|
+
onKeyboardMoveEnd,
|
|
20
|
+
onKeyboardMoveInteractive
|
|
21
|
+
} = handlers;
|
|
22
|
+
if (onKeyboardMoveStart && event.eventName.endsWith('onKeyboardMoveStart')) {
|
|
23
|
+
onKeyboardMoveStart(event, context);
|
|
24
|
+
}
|
|
25
|
+
if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
|
|
26
|
+
onKeyboardMove(event, context);
|
|
27
|
+
}
|
|
28
|
+
if (onKeyboardMoveEnd && event.eventName.endsWith('onKeyboardMoveEnd')) {
|
|
29
|
+
onKeyboardMoveEnd(event, context);
|
|
30
|
+
}
|
|
31
|
+
if (onKeyboardMoveInteractive && event.eventName.endsWith('onKeyboardMoveInteractive')) {
|
|
32
|
+
onKeyboardMoveInteractive(event, context);
|
|
33
|
+
}
|
|
34
|
+
}, ['onKeyboardMoveStart', 'onKeyboardMove', 'onKeyboardMoveEnd', 'onKeyboardMoveInteractive'], doDependenciesDiffer);
|
|
35
|
+
};
|
|
36
|
+
exports.useAnimatedKeyboardHandler = useAnimatedKeyboardHandler;
|
|
37
|
+
//# sourceMappingURL=reanimated.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","useHandler","useEvent","event","onKeyboardMoveStart","onKeyboardMove","onKeyboardMoveEnd","onKeyboardMoveInteractive","eventName","endsWith"],"sources":["reanimated.native.ts"],"sourcesContent":["import { useEvent, useHandler } from 'react-native-reanimated';\n\nimport type { EventWithName, KeyboardHandlerHook, NativeEvent } from './types';\n\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n Record<string, unknown>,\n EventWithName<NativeEvent>\n> = (handlers, dependencies) => {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event) => {\n 'worklet';\n const {\n onKeyboardMoveStart,\n onKeyboardMove,\n onKeyboardMoveEnd,\n onKeyboardMoveInteractive,\n } = handlers;\n\n if (\n onKeyboardMoveStart &&\n event.eventName.endsWith('onKeyboardMoveStart')\n ) {\n onKeyboardMoveStart(event, context);\n }\n\n if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {\n onKeyboardMove(event, context);\n }\n\n if (onKeyboardMoveEnd && event.eventName.endsWith('onKeyboardMoveEnd')) {\n onKeyboardMoveEnd(event, context);\n }\n\n if (\n onKeyboardMoveInteractive &&\n event.eventName.endsWith('onKeyboardMoveInteractive')\n ) {\n onKeyboardMoveInteractive(event, context);\n }\n },\n [\n 'onKeyboardMoveStart',\n 'onKeyboardMove',\n 'onKeyboardMoveEnd',\n 'onKeyboardMoveInteractive',\n ],\n doDependenciesDiffer\n );\n};\n"],"mappings":";;;;;;AAAA;AAIO,MAAMA,0BAGZ,GAAG,CAACC,QAAQ,EAAEC,YAAY,KAAK;EAC9B,MAAM;IAAEC,OAAO;IAAEC;EAAqB,CAAC,GAAG,IAAAC,iCAAU,EAACJ,QAAQ,EAAEC,YAAY,CAAC;EAE5E,OAAO,IAAAI,+BAAQ,EACZC,KAAK,IAAK;IACT,SAAS;;IACT,MAAM;MACJC,mBAAmB;MACnBC,cAAc;MACdC,iBAAiB;MACjBC;IACF,CAAC,GAAGV,QAAQ;IAEZ,IACEO,mBAAmB,IACnBD,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,qBAAqB,CAAC,EAC/C;MACAL,mBAAmB,CAACD,KAAK,EAAEJ,OAAO,CAAC;IACrC;IAEA,IAAIM,cAAc,IAAIF,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;MAChEJ,cAAc,CAACF,KAAK,EAAEJ,OAAO,CAAC;IAChC;IAEA,IAAIO,iBAAiB,IAAIH,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,mBAAmB,CAAC,EAAE;MACtEH,iBAAiB,CAACH,KAAK,EAAEJ,OAAO,CAAC;IACnC;IAEA,IACEQ,yBAAyB,IACzBJ,KAAK,CAACK,SAAS,CAACC,QAAQ,CAAC,2BAA2B,CAAC,EACrD;MACAF,yBAAyB,CAACJ,KAAK,EAAEJ,OAAO,CAAC;IAC3C;EACF,CAAC,EACD,CACE,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,2BAA2B,CAC5B,EACDC,oBAAoB,CACrB;AACH,CAAC;AAAC"}
|
package/lib/commonjs/replicas.js
CHANGED
|
@@ -8,7 +8,8 @@ var _react = require("react");
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _reactNativeReanimated = require("react-native-reanimated");
|
|
10
10
|
var _hooks = require("./hooks");
|
|
11
|
-
var
|
|
11
|
+
var _bindings = require("./bindings");
|
|
12
|
+
var _constants = require("./constants");
|
|
12
13
|
const availableOSEventType = _reactNative.Platform.OS === 'ios' ? 'Will' : 'Did';
|
|
13
14
|
|
|
14
15
|
// cubic-bezier(.17,.67,.34,.94)
|
|
@@ -30,8 +31,8 @@ const useKeyboardAnimationReplica = () => {
|
|
|
30
31
|
progress: progress.current
|
|
31
32
|
}), []);
|
|
32
33
|
(0, _react.useEffect)(() => {
|
|
33
|
-
|
|
34
|
-
return () =>
|
|
34
|
+
_bindings.KeyboardController.setInputMode(_constants.AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
|
|
35
|
+
return () => _bindings.KeyboardController.setDefaultMode();
|
|
35
36
|
}, []);
|
|
36
37
|
(0, _react.useEffect)(() => {
|
|
37
38
|
const listener = _reactNative.Keyboard.addListener(`keyboard${availableOSEventType}Show`, e => {
|
|
@@ -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 './hooks';\n\nimport {
|
|
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 { KeyboardController } from './bindings';\nimport { AndroidSoftInputModes } from './constants';\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;AACA;AAEA,MAAMA,oBAAoB,GAAGC,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAG,MAAM,GAAG,KAAK;;AAEnE;AACO,MAAMC,oBAAoB,GAAGC,mBAAM,CAACC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,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